![]() ![]() | ![]() |
1.1 bertrand 1: /*
2: ================================================================================
1.2 bertrand 3: RPL/2 (R) version 4.0.10
1.1 bertrand 4: Copyright (C) 1989-2010 Dr. BERTRAND Joël
5:
6: This file is part of RPL/2.
7:
8: RPL/2 is free software; you can redistribute it and/or modify it
9: under the terms of the CeCILL V2 License as published by the french
10: CEA, CNRS and INRIA.
11:
12: RPL/2 is distributed in the hope that it will be useful, but WITHOUT
13: ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14: FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL V2 License
15: for more details.
16:
17: You should have received a copy of the CeCILL License
18: along with RPL/2. If not, write to info@cecill.info.
19: ================================================================================
20: */
21:
22:
23: #define MAIN_RPL
24: #include "rpl.conv.h"
25:
26:
27: /*
28: ================================================================================
29: Programme principal
30: ================================================================================
31: */
32:
33: int
34: rplinit(int argc, char *argv[], unsigned char ***resultats)
35: {
36: # include "copyright.conv.h"
37: # include "licence.conv.h"
38:
39: file *f_source;
40:
41: int erreur_historique;
42: int option_P;
43: int status;
44:
45: logical1 core;
46: logical1 debug;
47: logical1 erreur_fichier;
48: logical1 existence;
49: logical1 mode_interactif;
50: logical1 option_a;
51: logical1 option_A;
52: logical1 option_c;
53: logical1 option_d;
54: logical1 option_D;
55: logical1 option_h;
56: logical1 option_i;
57: logical1 option_l;
58: logical1 option_n;
59: logical1 option_p;
60: logical1 option_s;
61: logical1 option_S;
62: logical1 option_t;
63: logical1 option_v;
64: logical1 ouverture;
65:
66: pthread_mutexattr_t attributs_mutex;
67:
68: ssize_t longueur_ecriture;
69:
70: struct_objet *s_objet;
71:
72: struct_processus *s_etat_processus;
73:
74: struct_table_variables_partagees s_variables_partagees;
75:
76: struct sigaction action;
77: struct sigaction registre;
78:
79: struct timespec attente;
80:
81: unsigned char *arguments;
82: unsigned char drapeau_encart;
83: unsigned char *type_debug;
84: unsigned char *home;
85: unsigned char *langue;
86: unsigned char *message;
87: unsigned char *nom_fichier_temporaire;
88: unsigned char option;
89: unsigned char presence_definition;
90: unsigned char *ptr;
91: unsigned char *tampon;
92:
93: unsigned long i;
94: unsigned long unite_fichier;
95:
96: void *l_element_courant;
97: void *l_element_suivant;
98:
99: volatile int erreur;
100: volatile unsigned char traitement_fichier_temporaire;
101:
102: setvbuf(stdout, NULL, _IOLBF, 0);
103: setvbuf(stderr, NULL, _IOLBF, 0);
104:
105: sem_init(&semaphore_liste_threads, 0, 1);
106: sem_init(&semaphore_gestionnaires_signaux, 0, 0);
107: sem_init(&semaphore_gestionnaires_signaux_atomique, 0, 1);
108:
109: if ((s_etat_processus = malloc(sizeof(struct_processus))) == NULL)
110: {
111: erreur = d_es_allocation_memoire;
112:
113: if ((*s_etat_processus).langue == 'F')
114: {
115: printf("+++Système : Mémoire insuffisante\n");
116: }
117: else
118: {
119: printf("+++System : Not enough memory\n");
120: }
121:
122: return(EXIT_FAILURE);
123: }
124:
125: (*s_etat_processus).exception = d_ep;
126: (*s_etat_processus).erreur_systeme = d_es;
127: (*s_etat_processus).erreur_execution = d_ex;
128:
129: insertion_thread(s_etat_processus, d_vrai);
130:
131: pthread_mutexattr_init(&attributs_mutex);
132: pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL);
133: pthread_mutex_init(&((*s_etat_processus).mutex), &attributs_mutex);
134: pthread_mutexattr_destroy(&attributs_mutex);
135:
136: sem_init(&((*s_etat_processus).semaphore_fork), 0, 0);
137:
138: pthread_mutexattr_init(&attributs_mutex);
139: pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL);
140: pthread_mutex_init(&((*s_etat_processus).protection_liste_mutexes),
141: &attributs_mutex);
142: pthread_mutexattr_destroy(&attributs_mutex);
143:
144: (*s_etat_processus).s_liste_variables_partagees = &s_variables_partagees;
145:
146: s_variables_partagees.nombre_variables = 0;
147: s_variables_partagees.nombre_variables_allouees = 0;
148: s_variables_partagees.table = NULL;
149:
150: pthread_mutexattr_init(&attributs_mutex);
151: pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL);
152: pthread_mutex_init(&((*((*s_etat_processus).s_liste_variables_partagees))
153: .mutex), &attributs_mutex);
154: pthread_mutexattr_destroy(&attributs_mutex);
155:
156: if ((langue = getenv("LANG")) != NULL)
157: {
158: (*s_etat_processus).langue = (strncmp(langue, "fr", 2) == 0)
159: ? 'F' : 'E';
160: }
161: else
162: {
163: (*s_etat_processus).langue = 'E';
164: }
165:
166: localisation_courante(s_etat_processus);
167:
168: if ((*s_etat_processus).erreur_systeme != d_es)
169: {
170: if ((*s_etat_processus).langue == 'F')
171: {
172: uprintf("+++Système : Mémoire insuffisante\n");
173: }
174: else
175: {
176: uprintf("+++System : Not enough memory\n");
177: }
178:
179: return(EXIT_FAILURE);
180: }
181:
182: printf("+++RPL/2 (R) version %s (%s)\n", d_version_rpl,
183: ((*s_etat_processus).langue == 'F') ? d_date_rpl : d_date_en_rpl);
184:
185: if ((*s_etat_processus).langue == 'F')
186: {
187: printf("+++Copyright (C) 1989 à 2009, 2010 BERTRAND Joël\n");
188: }
189: else
190: {
191: printf("+++Copyright (C) 1989 to 2009, 2010 BERTRAND Joel\n");
192: }
193:
194: if (getenv("HOME") != NULL)
195: {
196: home = getenv("HOME");
197: }
198: else if ((getenv("USER") != NULL) && (getpwnam(getenv("USER")) != NULL))
199: {
200: home = getpwnam(getenv("USER"))->pw_dir;
201: }
202: else if ((getenv("LOGNAME") != NULL) && (getpwnam(getenv("LOGNAME"))
203: != NULL))
204: {
205: home = getpwnam(getenv("LOGNAME"))->pw_dir;
206: }
207: else if ((getuid() != ((uid_t) -1)) && (getpwuid(getuid()) != NULL))
208: {
209: home = getpwuid(getuid())->pw_dir;
210: }
211: else
212: {
213: home = "";
214: }
215:
216: // Initialisation d'une clef
217:
218: if (pthread_key_create(&semaphore_fork_processus_courant, NULL) != 0)
219: {
220: if ((*s_etat_processus).langue == 'F')
221: {
222: printf("+++Système : Mémoire insuffisante\n");
223: }
224: else
225: {
226: printf("+++System : Not enough memory\n");
227: }
228:
229: return(EXIT_FAILURE);
230: }
231:
232: if (pthread_setspecific(semaphore_fork_processus_courant,
233: &((*s_etat_processus).semaphore_fork)) != 0)
234: {
235: if ((*s_etat_processus).langue == 'F')
236: {
237: printf("+++Système : Mémoire insuffisante\n");
238: }
239: else
240: {
241: printf("+++System : Not enough memory\n");
242: }
243:
244: return(EXIT_FAILURE);
245: }
246:
247: // Initialisation d'une pile de signal pour récupérer les
248: // débordement de pile
249:
250: if (((*s_etat_processus).pile_signal.ss_sp =
251: malloc((*s_etat_processus).pile_signal.ss_size =
252: SIGSTKSZ)) == NULL)
253: {
254: erreur = d_es_allocation_memoire;
255:
256: if ((*s_etat_processus).langue == 'F')
257: {
258: printf("+++Système : Mémoire insuffisante\n");
259: }
260: else
261: {
262: printf("+++System : Not enough memory\n");
263: }
264:
265: return(EXIT_FAILURE);
266: }
267:
268: (*s_etat_processus).pile_signal.ss_flags = 0;
269:
270: if (sigaltstack(&((*s_etat_processus).pile_signal), NULL) != 0)
271: {
272: erreur = d_es_signal;
273:
274: if ((*s_etat_processus).langue == 'F')
275: {
276: printf("+++Système : Initialisation de la pile spécifique de signal"
277: " impossible\n");
278: }
279: else
280: {
281: printf("+++System : Initialization of signal stack failed\n");
282: }
283:
284: return(EXIT_FAILURE);
285: }
286:
287: action.sa_sigaction = interruption1;
288: action.sa_flags = SA_ONSTACK | SA_SIGINFO;
289:
290: if (sigaction(SIGINT, &action, NULL) != 0)
291: {
292: erreur = d_es_signal;
293:
294: if ((*s_etat_processus).langue == 'F')
295: {
296: printf("+++Système : Initialisation des signaux POSIX "
297: "impossible\n");
298: }
299: else
300: {
301: printf("+++System : Initialization of POSIX signals failed\n");
302: }
303:
304: return(EXIT_FAILURE);
305: }
306:
307: action.sa_sigaction = interruption2;
308: action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO;
309:
310: if (sigaction(SIGTSTP, &action, NULL) != 0)
311: {
312: if ((*s_etat_processus).langue == 'F')
313: {
314: printf("+++Système : Initialisation des signaux POSIX "
315: "impossible\n");
316: }
317: else
318: {
319: printf("+++System : Initialization of POSIX signals failed\n");
320: }
321:
322: return(EXIT_FAILURE);
323: }
324:
325: action.sa_sigaction = interruption4;
326: action.sa_flags = SA_ONSTACK | SA_SIGINFO;
327:
328: if (sigaction(SIGSTART, &action, NULL) != 0)
329: {
330: if ((*s_etat_processus).langue == 'F')
331: {
332: printf("+++Système : Initialisation des signaux POSIX "
333: "impossible\n");
334: }
335: else
336: {
337: printf("+++System : Initialization of POSIX signals failed\n");
338: }
339:
340: return(EXIT_FAILURE);
341: }
342:
343: if (sigaction(SIGCONT, &action, NULL) != 0)
344: {
345: if ((*s_etat_processus).langue == 'F')
346: {
347: printf("+++Système : Initialisation des signaux POSIX "
348: "impossible\n");
349: }
350: else
351: {
352: printf("+++System : Initialization of POSIX signals failed\n");
353: }
354:
355: return(EXIT_FAILURE);
356: }
357:
358: action.sa_sigaction = interruption5;
359: action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO;
360:
361: if (sigaction(SIGFSTOP, &action, NULL) != 0)
362: {
363: erreur = d_es_signal;
364:
365: if ((*s_etat_processus).langue == 'F')
366: {
367: printf("+++Système : Initialisation des signaux POSIX "
368: "impossible\n");
369: }
370: else
371: {
372: printf("+++System : Initialization of POSIX signals failed\n");
373: }
374:
375: return(EXIT_FAILURE);
376: }
377:
378: action.sa_sigaction = interruption8;
379: action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO;
380:
381: if (sigaction(SIGURG, &action, NULL) != 0)
382: {
383: erreur = d_es_signal;
384:
385: if ((*s_etat_processus).langue == 'F')
386: {
387: printf("+++Système : Initialisation des signaux POSIX "
388: "impossible\n");
389: }
390: else
391: {
392: printf("+++System : Initialization of POSIX signals failed\n");
393: }
394:
395: return(EXIT_FAILURE);
396: }
397:
398: action.sa_sigaction = interruption7;
399: action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO;
400:
401: if (sigaction(SIGPIPE, &action, NULL) != 0)
402: {
403: erreur = d_es_signal;
404:
405: if ((*s_etat_processus).langue == 'F')
406: {
407: printf("+++Système : Initialisation des signaux POSIX "
408: "impossible\n");
409: }
410: else
411: {
412: printf("+++System : Initialization of POSIX signals failed\n");
413: }
414:
415: return(EXIT_FAILURE);
416: }
417:
418: action.sa_sigaction = interruption6;
419: action.sa_flags = SA_ONSTACK | SA_SIGINFO;
420:
421: if (sigaction(SIGINJECT, &action, NULL) != 0)
422: {
423: erreur = d_es_signal;
424:
425: if ((*s_etat_processus).langue == 'F')
426: {
427: printf("+++Système : Initialisation des signaux POSIX "
428: "impossible\n");
429: }
430: else
431: {
432: printf("+++System : Initialization of POSIX signals failed\n");
433: }
434:
435: return(EXIT_FAILURE);
436: }
437:
438: action.sa_sigaction = interruption9;
439: action.sa_flags = SA_ONSTACK | SA_SIGINFO;
440:
441: if (sigaction(SIGABORT, &action, NULL) != 0)
442: {
443: erreur = d_es_signal;
444:
445: if ((*s_etat_processus).langue == 'F')
446: {
447: printf("+++Système : Initialisation des signaux POSIX "
448: "impossible\n");
449: }
450: else
451: {
452: printf("+++System : Initialization of POSIX signals failed\n");
453: }
454:
455: return(EXIT_FAILURE);
456: }
457:
458: action.sa_sigaction = interruption1;
459: action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO;
460:
461: if (sigaction(SIGALRM, &action, NULL) != 0)
462: {
463: erreur = d_es_signal;
464:
465: if ((*s_etat_processus).langue == 'F')
466: {
467: printf("+++Système : Initialisation des signaux POSIX "
468: "impossible\n");
469: }
470: else
471: {
472: printf("+++System : Initialization of POSIX signals failed\n");
473: }
474:
475: return(EXIT_FAILURE);
476: }
477:
478: action.sa_sigaction = interruption3;
479: action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO;
480:
481: (*s_etat_processus).chemin_fichiers_temporaires =
482: recherche_chemin_fichiers_temporaires(s_etat_processus);
483:
484: erreur = d_os;
485: core = d_faux;
486: mode_interactif = d_faux;
487: (*s_etat_processus).nom_fichier_source = NULL;
488: (*s_etat_processus).definitions_chainees = NULL;
489: (*s_etat_processus).type_debug = 0;
490: traitement_fichier_temporaire = 'N';
491: option = ' ';
492: drapeau_encart = 'Y';
493: debug = d_faux;
494: arguments = NULL;
495:
496: (*s_etat_processus).s_fichiers = NULL;
497: (*s_etat_processus).s_sockets = NULL;
498: (*s_etat_processus).s_connecteurs_sql = NULL;
499:
500: setlogmask(LOG_MASK(LOG_NOTICE));
501: openlog(argv[0], LOG_ODELAY | LOG_PID, LOG_USER);
502:
503: if (argc == 1)
504: {
505: erreur = d_os_ligne_de_commande;
506: informations(s_etat_processus);
507: }
508: else
509: {
510: presence_definition = 'N';
511: (*s_etat_processus).debug = d_faux;
512: (*s_etat_processus).lancement_interactif = d_faux;
513:
514: option_a = d_faux;
515: option_A = d_faux;
516: option_c = d_faux;
517: option_d = d_faux;
518: option_D = d_faux;
519: option_h = d_faux;
520: option_i = d_faux;
521: option_l = d_faux;
522: option_n = d_faux;
523: option_p = d_faux;
524: option_P = 0;
525: option_s = d_faux;
526: option_S = d_faux;
527: option_t = d_faux;
528: option_v = d_faux;
529:
530: while((--argc) > 0)
531: {
532: if ((*(++argv))[0] == '-')
533: {
534: while((option = *(++argv[0])) != '\0')
535: {
536: switch(option)
537: {
538: case 'a' :
539: {
540: if (option_a == d_vrai)
541: {
542: if ((*s_etat_processus).langue == 'F')
543: {
544: printf("+++Erreur : option -a présente "
545: "plus d'une fois\n");
546: }
547: else
548: {
549: printf("+++Error : more than one -a "
550: "on command line");
551: }
552:
553: return(EXIT_FAILURE);
554: }
555:
556: option_a = d_vrai;
557: printf("\n");
558:
559: if ((*s_etat_processus).langue == 'F')
560: {
561: printf(" Auteur: Joël BERTRAND,\n");
562: printf(" Email : "
563: "joel.bertrand@systella.fr\n");
564: printf(" Liste de diffusion : "
565: "rpl2@systella.fr\n");
566: printf(" Page : "
567: "http://www.rpl2.fr");
568: printf("\n");
569: }
570: else
571: {
572: printf(" Author: Joël BERTRAND,\n");
573: printf(" Email : "
574: "joel.bertrand@systella.fr\n");
575: printf(" Mailing list : "
576: "rpl2@systella.fr\n");
577: printf(" Web page : "
578: "http://www.rpl2/net");
579: printf("\n");
580: }
581:
582: break;
583: }
584:
585: case 'A' :
586: {
587: if (option_A == d_vrai)
588: {
589: if ((*s_etat_processus).langue == 'F')
590: {
591: printf("+++Erreur : option -A présente "
592: "plus d'une fois\n");
593: }
594: else
595: {
596: printf("+++Error : more than one -A "
597: "on command line");
598: }
599:
600: return(EXIT_FAILURE);
601: }
602:
603: option_A = d_vrai;
604:
605: while(*(++argv[0]) == ' ');
606: argv[0]--;
607:
608: if ((*(++argv[0])) != '\0')
609: {
610: if ((arguments = malloc((strlen(argv[0]) + 7) *
611: sizeof(unsigned char))) == NULL)
612: {
613: if ((*s_etat_processus).langue == 'F')
614: {
615: printf("+++Système : Mémoire "
616: "insuffisante\n");
617: }
618: else
619: {
620: printf("+++System : Not enough "
621: "memory\n");
622: }
623:
624: return(EXIT_FAILURE);
625: }
626:
627: ptr = arguments;
628: (*ptr) = d_code_fin_chaine;
629: strcat(ptr, "<< ");
630: ptr += 3;
631:
632: while(*(argv[0]) != '\0')
633: {
634: *(ptr++) = *(argv[0]++);
635: }
636:
637: (*ptr) = '\0';
638:
639: strcat(arguments, " >>");
640: argv[0]--;
641: }
642: else if ((--argc) > 0)
643: {
644: argv++;
645:
646: if ((arguments = malloc((strlen(argv[0]) + 7) *
647: sizeof(unsigned char))) == NULL)
648: {
649: if ((*s_etat_processus).langue == 'F')
650: {
651: printf("+++Système : Mémoire "
652: "insuffisante\n");
653: }
654: else
655: {
656: printf("+++System : Not enough "
657: "memory\n");
658: }
659:
660: return(EXIT_FAILURE);
661: }
662:
663: ptr = arguments;
664: (*ptr) = d_code_fin_chaine;
665: strcat(ptr, "<< ");
666: ptr += 3;
667:
668: while(*(argv[0]) != '\0')
669: {
670: *(ptr++) = *(argv[0]++);
671: }
672:
673: (*ptr) = '\0';
674:
675: strcat(arguments, " >>");
676: argv[0]--;
677: }
678: else
679: {
680: if ((*s_etat_processus).langue == 'F')
681: {
682: printf("+++Erreur : Aucune donnée "
683: "spécifié après l'option -A\n");
684: }
685: else
686: {
687: printf("+++Error : Data required after "
688: "-A option\n");
689: }
690:
691: return(EXIT_FAILURE);
692: }
693:
694: break;
695: }
696:
697: case 'c' :
698: {
699: if (option_c == d_vrai)
700: {
701: if ((*s_etat_processus).langue == 'F')
702: {
703: printf("+++Erreur : option -c présente "
704: "plus d'une fois\n");
705: }
706: else
707: {
708: printf("+++Error : more than one -c "
709: "on command line");
710: }
711:
712: return(EXIT_FAILURE);
713: }
714:
715: option_c = d_vrai;
716: core = d_vrai;
717: break;
718: }
719:
720: case 'd' :
721: {
722: if (option_d == d_vrai)
723: {
724: if ((*s_etat_processus).langue == 'F')
725: {
726: printf("+++Erreur : option -d présente "
727: "plus d'une fois\n");
728: }
729: else
730: {
731: printf("+++Error : more than one -d "
732: "on command line");
733: }
734:
735: return(EXIT_FAILURE);
736: }
737:
738: option_d = d_vrai;
739: debug = d_vrai;
740: break;
741: }
742:
743: case 'D' :
744: {
745: if (option_D == d_vrai)
746: {
747: if ((*s_etat_processus).langue == 'F')
748: {
749: printf("+++Erreur : option -D présente "
750: "plus d'une fois\n");
751: }
752: else
753: {
754: printf("+++Error : more than one -D "
755: "on command line");
756: }
757:
758: return(EXIT_FAILURE);
759: }
760:
761: option_D = d_vrai;
762: break;
763: }
764:
765: case 'h' :
766: {
767: if (option_h == d_vrai)
768: {
769: if ((*s_etat_processus).langue == 'F')
770: {
771: printf("+++Erreur : option -h présente "
772: "plus d'une fois\n");
773: }
774: else
775: {
776: printf("+++Error : more than one -h "
777: "on command line");
778: }
779:
780: return(EXIT_FAILURE);
781: }
782:
783: option_h = d_vrai;
784: informations(s_etat_processus);
785: break;
786: }
787:
788: case 'i' :
789: {
790: if (option_i == d_vrai)
791: {
792: if ((*s_etat_processus).langue == 'F')
793: {
794: printf("+++Erreur : option -i présente "
795: "plus d'une fois\n");
796: }
797: else
798: {
799: printf("+++Error : more than one -i "
800: "on command line");
801: }
802:
803: return(EXIT_FAILURE);
804: }
805: else if (option_S == d_vrai)
806: {
807: if ((*s_etat_processus).langue == 'F')
808: {
809: printf("+++Erreur : options -i et -S "
810: "incompatibles\n");
811: }
812: else
813: {
814: printf("+++Error : incompatible options -i "
815: "and -S\n");
816: }
817:
818: return(EXIT_FAILURE);
819: }
820: else if (option_p == d_vrai)
821: {
822: if ((*s_etat_processus).langue == 'F')
823: {
824: printf("+++Erreur : options -i et -p "
825: "incompatibles\n");
826: }
827: else
828: {
829: printf("+++Error : incompatible options -i "
830: "and -p\n");
831: }
832:
833: return(EXIT_FAILURE);
834: }
835:
836: option_i = d_vrai;
837: mode_interactif = d_vrai;
838: presence_definition = 'O';
839: break;
840: }
841:
842: case 'l' :
843: {
844: if (option_l == d_vrai)
845: {
846: if ((*s_etat_processus).langue == 'F')
847: {
848: printf("+++Erreur : option -l présente "
849: "plus d'une fois\n");
850: }
851: else
852: {
853: printf("+++Error : more than one -l "
854: "on command line");
855: }
856:
857: return(EXIT_FAILURE);
858: }
859:
860: option_l = d_vrai;
861:
862: if ((*s_etat_processus).langue == 'F')
863: {
864: printf("%s\n\n", CeCILL_fr);
865: }
866: else
867: {
868: printf("%s\n\n", CeCILL_en);
869: }
870:
871: break;
872: }
873:
874: case 'n' :
875: {
876: if (option_n == d_vrai)
877: {
878: if ((*s_etat_processus).langue == 'F')
879: {
880: printf("+++Erreur : option -n présente "
881: "plus d'une fois\n");
882: }
883: else
884: {
885: printf("+++Error : more than one -n "
886: "on command line");
887: }
888:
889: return(EXIT_FAILURE);
890: }
891:
892: option_n = d_vrai;
893:
894: break;
895: }
896:
897: case 'p' :
898: {
899: if (option_p == d_vrai)
900: {
901: if ((*s_etat_processus).langue == 'F')
902: {
903: printf("+++Erreur : option -p présente "
904: "plus d'une fois\n");
905: }
906: else
907: {
908: printf("+++Error : more than one -p "
909: "on command line");
910: }
911:
912: return(EXIT_FAILURE);
913: }
914: else if (option_i == d_vrai)
915: {
916: if ((*s_etat_processus).langue == 'F')
917: {
918: printf("+++Erreur : options -i et -p "
919: "incompatibles\n");
920: }
921: else
922: {
923: printf("+++Error : incompatible options -i "
924: "and -p\n");
925: }
926:
927: return(EXIT_FAILURE);
928: }
929:
930: option_p = d_vrai;
931:
932: break;
933: }
934:
935: case 'P' :
936: {
937: if (option_P > 2)
938: {
939: if ((*s_etat_processus).langue == 'F')
940: {
941: printf("+++Erreur : option -P présente "
942: "plus de deux fois\n");
943: }
944: else
945: {
946: printf("+++Error : more than two -P "
947: "on command line");
948: }
949:
950: return(EXIT_FAILURE);
951: }
952:
953: option_P++;
954:
955: break;
956: }
957:
958: case 's' :
959: {
960: if (option_s == d_vrai)
961: {
962: if ((*s_etat_processus).langue == 'F')
963: {
964: printf("+++Erreur : option -s présente "
965: "plus d'une fois\n");
966: }
967: else
968: {
969: printf("+++Error : more than one -s "
970: "on command line");
971: }
972:
973: return(EXIT_FAILURE);
974: }
975:
976: option_s = d_vrai;
977: drapeau_encart = 'N';
978: break;
979: }
980:
981: case 'S' :
982: {
983: if (option_S == d_vrai)
984: {
985: if ((*s_etat_processus).langue == 'F')
986: {
987: printf("+++Erreur : option -S présente "
988: "plus d'une fois\n");
989: }
990: else
991: {
992: printf("+++Error : more than one -S "
993: "on command line");
994: }
995:
996: return(EXIT_FAILURE);
997: }
998: else if (option_i == d_vrai)
999: {
1000: if ((*s_etat_processus).langue == 'F')
1001: {
1002: printf("+++Erreur : options -i et -S "
1003: "incompatibles\n");
1004: }
1005: else
1006: {
1007: printf("+++Error : incompatible options -S "
1008: "and -i\n");
1009: }
1010:
1011: return(EXIT_FAILURE);
1012: }
1013:
1014: option_S = d_vrai;
1015:
1016: while(*(++argv[0]) == ' ');
1017: argv[0]--;
1018:
1019: if ((*(++argv[0])) != '\0')
1020: {
1021: if (((*s_etat_processus).definitions_chainees =
1022: malloc((strlen(argv[0]) + 1) *
1023: sizeof(unsigned char))) == NULL)
1024: {
1025: if ((*s_etat_processus).langue == 'F')
1026: {
1027: printf("+++Système : Mémoire "
1028: "insuffisante\n");
1029: }
1030: else
1031: {
1032: printf("+++System : Not enough "
1033: "memory\n");
1034: }
1035:
1036: return(EXIT_FAILURE);
1037: }
1038:
1039: ptr = (*s_etat_processus).definitions_chainees;
1040:
1041: while(*(argv[0]) != '\0')
1042: {
1043: *(ptr++) = *(argv[0]++);
1044: }
1045:
1046: (*ptr) = '\0';
1047:
1048: argv[0]--;
1049: presence_definition = 'O';
1050: }
1051: else if ((--argc) > 0)
1052: {
1053: argv++;
1054:
1055: if (((*s_etat_processus).definitions_chainees =
1056: malloc((strlen(argv[0]) + 1) *
1057: sizeof(unsigned char))) == NULL)
1058: {
1059: if ((*s_etat_processus).langue == 'F')
1060: {
1061: printf("+++Système : Mémoire "
1062: "insuffisante\n");
1063: }
1064: else
1065: {
1066: printf("+++System : Not enough "
1067: "memory\n");
1068: }
1069:
1070: return(EXIT_FAILURE);
1071: }
1072:
1073: ptr = (*s_etat_processus).definitions_chainees;
1074:
1075: while(*(argv[0]) != '\0')
1076: {
1077: *(ptr++) = *(argv[0]++);
1078: }
1079:
1080: (*ptr) = '\0';
1081:
1082: argv[0]--;
1083: presence_definition = 'O';
1084: }
1085: else
1086: {
1087: if ((*s_etat_processus).langue == 'F')
1088: {
1089: printf("+++Erreur : Aucun script "
1090: "spécifié après l'option -S\n");
1091: }
1092: else
1093: {
1094: printf("+++Error : Script required after "
1095: "-S option\n");
1096: }
1097:
1098: return(EXIT_FAILURE);
1099: }
1100:
1101: if (((*s_etat_processus).definitions_chainees =
1102: compactage((*s_etat_processus)
1103: .definitions_chainees)) == NULL)
1104: {
1105: if ((*s_etat_processus).langue == 'F')
1106: {
1107: printf("+++Système : Mémoire "
1108: "insuffisante\n");
1109: }
1110: else
1111: {
1112: printf("+++System : Not enough "
1113: "memory\n");
1114: }
1115:
1116: return(EXIT_FAILURE);
1117: }
1118:
1119: (*s_etat_processus).longueur_definitions_chainees =
1120: strlen((*s_etat_processus)
1121: .definitions_chainees);
1122:
1123: break;
1124: }
1125:
1126: case 't' :
1127: {
1128: if (option_t == d_vrai)
1129: {
1130: if ((*s_etat_processus).langue == 'F')
1131: {
1132: printf("+++Erreur : option -t présente "
1133: "plus d'une fois\n");
1134: }
1135: else
1136: {
1137: printf("+++Error : more than one -t "
1138: "on command line");
1139: }
1140:
1141: return(EXIT_FAILURE);
1142: }
1143:
1144: option_t = d_vrai;
1145: (*s_etat_processus).debug = d_vrai;
1146:
1147: while(*(++argv[0]) == ' ');
1148: argv[0]--;
1149:
1150: if ((*(++argv[0])) != '\0')
1151: {
1152: if ((type_debug = malloc((strlen(argv[0]) + 1) *
1153: sizeof(unsigned char))) == NULL)
1154: {
1155: if ((*s_etat_processus).langue == 'F')
1156: {
1157: printf("+++Système : Mémoire "
1158: "insuffisante\n");
1159: }
1160: else
1161: {
1162: printf("+++System : Not enough "
1163: "memory\n");
1164: }
1165:
1166: return(EXIT_FAILURE);
1167: }
1168:
1169: ptr = type_debug;
1170:
1171: while((*(argv[0]) != '\0') &&
1172: (*(argv[0]) != ' '))
1173: {
1174: *(ptr++) = *(argv[0]++);
1175: }
1176:
1177: (*ptr) = '\0';
1178:
1179: argv[0]--;
1180: }
1181: else if ((--argc) > 0)
1182: {
1183: argv++;
1184:
1185: if ((type_debug =
1186: malloc((strlen(argv[0]) + 1) *
1187: sizeof(unsigned char))) == NULL)
1188: {
1189: if ((*s_etat_processus).langue == 'F')
1190: {
1191: printf("+++Système : Mémoire "
1192: "insuffisante\n");
1193: }
1194: else
1195: {
1196: printf("+++System : Not enough "
1197: "memory\n");
1198: }
1199:
1200: return(EXIT_FAILURE);
1201: }
1202:
1203: ptr = type_debug;
1204:
1205: while(*(argv[0]) != '\0')
1206: {
1207: *(ptr++) = *(argv[0]++);
1208: }
1209:
1210: (*ptr) = '\0';
1211:
1212: argv[0]--;
1213: }
1214: else
1215: {
1216: if ((*s_etat_processus).langue == 'F')
1217: {
1218: printf("+++Erreur : Aucun niveau "
1219: "de débogage spécifié après "
1220: "l'option -t\n");
1221: }
1222: else
1223: {
1224: printf("+++Error : Debug level not "
1225: "specified after -t option\n");
1226: }
1227:
1228: return(EXIT_FAILURE);
1229: }
1230:
1231: ptr = type_debug;
1232:
1233: while(*ptr != '\0')
1234: {
1235: switch(*ptr)
1236: {
1237: case '0':
1238: case '1':
1239: case '2':
1240: case '3':
1241: case '4':
1242: case '5':
1243: case '6':
1244: case '7':
1245: case '8':
1246: case '9':
1247: case 'A':
1248: case 'B':
1249: case 'C':
1250: case 'D':
1251: case 'E':
1252: case 'F':
1253: {
1254: break;
1255: }
1256:
1257: default:
1258: {
1259: if ((*s_etat_processus).langue == 'F')
1260: {
1261: printf("+++Erreur : Niveau "
1262: "de débogage non "
1263: "hexadécimal\n");
1264: }
1265: else
1266: {
1267: printf("+++Error : Debug level must"
1268: " be hexadecimal "
1269: "integer\n");
1270: }
1271:
1272: return(EXIT_FAILURE);
1273: }
1274: }
1275:
1276: ptr++;
1277: }
1278:
1279: if (sscanf(type_debug, "%llX",
1280: &((*s_etat_processus).type_debug)) != 1)
1281: {
1282: if ((*s_etat_processus).langue == 'F')
1283: {
1284: printf("+++Erreur : Niveau "
1285: "de débogage non entier\n");
1286: }
1287: else
1288: {
1289: printf("+++Error : Debug level must"
1290: " be integer\n");
1291: }
1292:
1293: return(EXIT_FAILURE);
1294: }
1295:
1296: break;
1297: }
1298:
1299: case 'v' :
1300: {
1301: if (option_v == d_vrai)
1302: {
1303: if ((*s_etat_processus).langue == 'F')
1304: {
1305: printf("+++Erreur : option -v présente "
1306: "plus d'une fois\n");
1307: }
1308: else
1309: {
1310: printf("+++Error : more than one -v "
1311: "on command line");
1312: }
1313:
1314: return(EXIT_FAILURE);
1315: }
1316:
1317: option_v = d_vrai;
1318: printf("\n");
1319:
1320: if ((*s_etat_processus).langue == 'F')
1321: {
1322: printf(" Reverse Polish Lisp/2 version %s "
1323: "pour systèmes "
1324: "POSIX\n", d_version_rpl);
1325: printf(" Langage procédural de très haut "
1326: "niveau, semi-compilé, "
1327: "extensible,\n");
1328: printf(" destiné principalement aux "
1329: "calculs scientifiques et "
1330: "symboliques\n");
1331: printf("%s\n", copyright);
1332: }
1333: else
1334: {
1335: printf(" Reverse Polish Lisp/2 version %s "
1336: "for POSIX operating systems\n",
1337: d_version_rpl);
1338: printf(" Half-compiled, high-level "
1339: "procedural language,\n");
1340: printf(" mainly aiming at scientific "
1341: "calculations\n");
1342: printf("%s\n", copyright_anglais);
1343: }
1344:
1345: printf("\n");
1346: break;
1347: }
1348:
1349: default :
1350: {
1351: if ((*s_etat_processus).langue == 'F')
1352: {
1.3 bertrand 1353: printf("+++Information : Option -%c inconnue\n",
1.1 bertrand 1354: option);
1355: }
1356: else
1357: {
1.3 bertrand 1358: printf("+++Warning : -%c option unknown\n",
1.1 bertrand 1359: option);
1360: }
1361:
1362: informations(s_etat_processus);
1363: break;
1364: }
1365: }
1366: }
1367: }
1368: else
1369: {
1370: if (presence_definition == 'O')
1371: {
1372: argc = 0;
1373:
1374: if ((*s_etat_processus).langue == 'F')
1375: {
1376: printf("+++Erreur : Plusieurs définitions\n");
1377: }
1378: else
1379: {
1380: printf("+++Error : More than one definition\n");
1381: }
1382:
1383: erreur = d_os_ligne_de_commande;
1384: }
1385: else
1386: {
1387: (*s_etat_processus).nom_fichier_source = argv[0];
1388: presence_definition = 'O';
1389: }
1390: }
1391: }
1392:
1393: if (debug == d_faux)
1394: {
1395: if (sigaction(SIGSEGV, &action, NULL) != 0)
1396: {
1397: if ((*s_etat_processus).langue == 'F')
1398: {
1399: printf("+++Système : Initialisation des signaux POSIX "
1400: "impossible\n");
1401: }
1402: else
1403: {
1404: printf("+++System : Initialization of POSIX signals "
1405: "failed\n");
1406: }
1407:
1408: return(EXIT_FAILURE);
1409: }
1410:
1411: if (sigaction(SIGBUS, &action, NULL) != 0)
1412: {
1413: if ((*s_etat_processus).langue == 'F')
1414: {
1415: printf("+++Système : Initialisation des signaux POSIX "
1416: "impossible\n");
1417: }
1418: else
1419: {
1420: printf("+++System : Initialization of POSIX signals "
1421: "failed\n");
1422: }
1423:
1424: return(EXIT_FAILURE);
1425: }
1426: }
1427:
1428: if (option_n == d_vrai)
1429: {
1430: action.sa_sigaction = interruption10;
1431: action.sa_flags = SA_ONSTACK | SA_SIGINFO;
1432:
1433: if (sigaction(SIGHUP, &action, NULL) != 0)
1434: {
1435: if ((*s_etat_processus).langue == 'F')
1436: {
1437: printf("+++Système : Initialisation des signaux POSIX "
1438: "impossible\n");
1439: }
1440: else
1441: {
1442: printf("+++System : Initialization of POSIX signals "
1443: "failed\n");
1444: }
1445:
1446: return(EXIT_FAILURE);
1447: }
1448: }
1449:
1450: if (mode_interactif == d_vrai)
1451: {
1452: printf("\n");
1453:
1454: if ((*s_etat_processus).langue == 'F')
1455: {
1456: printf("+++Ce logiciel est un logiciel libre"
1457: " sans aucune garantie de "
1458: "fonctionnement.\n");
1459: printf("+++Pour plus de détails, utilisez la "
1460: "commande 'warranty'.\n");
1461: }
1462: else
1463: {
1464: printf("+++This is a free software with "
1465: "absolutely no warranty.\n");
1466: printf("+++For details, type 'warranty'.\n");
1467: }
1468:
1469: printf("\n");
1470:
1471: traitement_fichier_temporaire = 'Y';
1472:
1473: if ((nom_fichier_temporaire =
1474: creation_nom_fichier(s_etat_processus, (*s_etat_processus)
1475: .chemin_fichiers_temporaires)) == NULL)
1476: {
1477: if ((*s_etat_processus).langue == 'F')
1478: {
1479: printf("+++Système : Fichier indisponible\n");
1480: }
1481: else
1482: {
1483: printf("+++System : File unavailable\n");
1484: }
1485:
1486: return(EXIT_FAILURE);
1487: }
1488:
1489: if ((f_source = fopen(nom_fichier_temporaire, "w"))
1490: == NULL)
1491: {
1492: if ((*s_etat_processus).langue == 'F')
1493: {
1494: printf("+++Système : Fichier introuvable\n");
1495: }
1496: else
1497: {
1498: printf("+++System : File not found\n");
1499: }
1500:
1501: return(EXIT_FAILURE);
1502: }
1503:
1504: if (fprintf(f_source, "MODE_INTERACTIF\n") < 0)
1505: {
1506: if ((*s_etat_processus).langue == 'F')
1507: {
1508: printf("+++Système : Erreur d'écriture dans un fichier\n");
1509: }
1510: else
1511: {
1512: printf("+++System : Cannot write in file\n");
1513: }
1514:
1515: return(EXIT_FAILURE);
1516: }
1517:
1518: if (fprintf(f_source,
1519: "<< DO HALT UNTIL FALSE END >>\n") < 0)
1520: {
1521: if ((*s_etat_processus).langue == 'F')
1522: {
1523: printf("+++Système : Erreur d'écriture dans un fichier\n");
1524: }
1525: else
1526: {
1527: printf("+++System : Cannot write in file\n");
1528: }
1529:
1530: return(EXIT_FAILURE);
1531: }
1532:
1533: if (fclose(f_source) != 0)
1534: {
1535: if ((*s_etat_processus).langue == 'F')
1536: {
1537: printf("+++Système : Fichier indisponible\n");
1538: }
1539: else
1540: {
1541: printf("+++System : File unavailable\n");
1542: }
1543:
1544: return(EXIT_FAILURE);
1545: }
1546:
1547: (*s_etat_processus).lancement_interactif = d_vrai;
1548: (*s_etat_processus).nom_fichier_source =
1549: nom_fichier_temporaire;
1550:
1551: presence_definition = 'O';
1552: }
1553: else
1554: {
1555: nom_fichier_temporaire = NULL;
1556: }
1557:
1558: if ((*s_etat_processus).nom_fichier_source == NULL)
1559: {
1560: erreur_fichier = d_erreur;
1561: }
1562: else
1563: {
1564: erreur_fichier = caracteristiques_fichier(s_etat_processus,
1565: (*s_etat_processus).nom_fichier_source,
1566: &existence, &ouverture, &unite_fichier);
1567: }
1568:
1569: (*s_etat_processus).recherche_types_speciaux = 'N';
1570:
1571: if (((existence == d_faux) || (erreur_fichier != d_absence_erreur)) &&
1572: (option_S == d_faux))
1573: {
1574: if (presence_definition == 'O')
1575: {
1576: if ((*s_etat_processus).langue == 'F')
1577: {
1578: printf("+++Erreur : Fichier %s inexistant\n",
1579: (*s_etat_processus).nom_fichier_source);
1580: }
1581: else
1582: {
1583: printf("+++Error : File %s not found\n",
1584: (*s_etat_processus).nom_fichier_source);
1585: }
1586:
1587: erreur = d_os_fichier_introuvable;
1588: }
1589: else
1590: {
1591: if ((*s_etat_processus).langue == 'F')
1592: {
1593: printf("+++Erreur : Absence de définition à exécuter\n");
1594: }
1595: else
1596: {
1597: printf("+++Error : Any executable definition\n");
1598: }
1599: }
1.3 bertrand 1600:
1601: return(EXIT_FAILURE);
1.1 bertrand 1602: }
1603:
1604: if ((*s_etat_processus).chemin_fichiers_temporaires == NULL)
1605: {
1606: if ((*s_etat_processus).langue == 'F')
1607: {
1608: printf("+++Système : Chemin des fichiers temporaires nul\n");
1609: }
1610: else
1611: {
1612: printf("+++System : Null temporary files path\n");
1613: }
1614:
1615: return(EXIT_FAILURE);
1616: }
1617:
1618: if ((*s_etat_processus).debug == d_vrai)
1619: {
1620: if ((*s_etat_processus).langue == 'F')
1621: {
1622: printf("[%d] Chemin des fichiers temporaires %s\n\n",
1623: (int) getpid(),
1624: (*s_etat_processus).chemin_fichiers_temporaires);
1625: }
1626: else
1627: {
1628: printf("[%d] Temporary files path %s\n\n",
1629: (int) getpid(),
1630: (*s_etat_processus).chemin_fichiers_temporaires);
1631: }
1632: }
1633:
1634: if ((erreur == d_os) && (presence_definition == 'O'))
1635: {
1636: (*s_etat_processus).profilage = (option_P != 0) ? d_vrai : d_faux;
1637: (*s_etat_processus).niveau_profilage = option_P;
1638: (*s_etat_processus).pile_profilage = NULL;
1639: (*s_etat_processus).pile_profilage_fonctions = NULL;
1640: gettimeofday(&((*s_etat_processus).horodatage_profilage), NULL);
1641:
1642: (*s_etat_processus).liste_mutexes = NULL;
1643:
1644: (*s_etat_processus).test_instruction = 'N';
1645: (*s_etat_processus).nombre_arguments = 0;
1646: (*s_etat_processus).affichage_arguments = 'N';
1647: (*s_etat_processus).autorisation_evaluation_nom = 'Y';
1648: (*s_etat_processus).autorisation_empilement_programme = 'N';
1649: (*s_etat_processus).requete_arret = 'N';
1.4 ! bertrand 1650: (*s_etat_processus).evaluation_forcee = 'N';
1.1 bertrand 1651:
1652: (*s_etat_processus).constante_symbolique = 'N';
1653: (*s_etat_processus).traitement_symbolique = 'N';
1654:
1655: (*s_etat_processus).expression_courante = NULL;
1656: (*s_etat_processus).objet_courant = NULL;
1657: (*s_etat_processus).evaluation_expression_compilee = 'N';
1658:
1659: (*s_etat_processus).l_base_pile = NULL;
1660: (*s_etat_processus).l_base_pile_last = NULL;
1661:
1662: (*s_etat_processus).s_liste_variables = NULL;
1663: (*s_etat_processus).gel_liste_variables = d_faux;
1664: (*s_etat_processus).nombre_variables = 0;
1665: (*s_etat_processus).nombre_variables_allouees = 0;
1666: (*s_etat_processus).s_liste_variables_statiques = NULL;
1667: (*s_etat_processus).nombre_variables_statiques = 0;
1668: (*s_etat_processus).nombre_variables_statiques_allouees = 0;
1669: (*s_etat_processus).niveau_courant = 0;
1670: (*s_etat_processus).niveau_initial = 0;
1671: (*s_etat_processus).creation_variables_statiques = d_faux;
1672: (*s_etat_processus).creation_variables_partagees = d_faux;
1673: (*s_etat_processus).position_variable_courante = 0;
1674: (*s_etat_processus).position_variable_statique_courante = 0;
1675:
1676: (*s_etat_processus).s_bibliotheques = NULL;
1677: (*s_etat_processus).s_instructions_externes = NULL;
1678: (*s_etat_processus).nombre_instructions_externes = 0;
1679:
1680: (*s_etat_processus).systeme_axes = 0;
1681:
1682: (*s_etat_processus).x_min = -10.;
1683: (*s_etat_processus).x_max = 10.;
1684: (*s_etat_processus).y_min = -10.;
1685: (*s_etat_processus).y_max = 10.;
1686: (*s_etat_processus).z_min = -10.;
1687: (*s_etat_processus).z_max = 10.;
1688:
1689: (*s_etat_processus).x2_min = -10.;
1690: (*s_etat_processus).x2_max = 10.;
1691: (*s_etat_processus).y2_min = -10.;
1692: (*s_etat_processus).y2_max = 10.;
1693: (*s_etat_processus).z2_min = -10.;
1694: (*s_etat_processus).z2_max = 10.;
1695:
1696: (*s_etat_processus).resolution = .01;
1697:
1698: (*s_etat_processus).souris_active = d_faux;
1699:
1700: (*s_etat_processus).echelle_automatique_x = d_faux;
1701: (*s_etat_processus).echelle_automatique_y = d_faux;
1702: (*s_etat_processus).echelle_automatique_z = d_faux;
1703:
1704: (*s_etat_processus).echelle_automatique_x2 = d_faux;
1705: (*s_etat_processus).echelle_automatique_y2 = d_faux;
1706: (*s_etat_processus).echelle_automatique_z2 = d_faux;
1707:
1708: (*s_etat_processus).echelle_log_x = d_faux;
1709: (*s_etat_processus).echelle_log_y = d_faux;
1710: (*s_etat_processus).echelle_log_z = d_faux;
1711:
1712: (*s_etat_processus).echelle_log_x2 = d_faux;
1713: (*s_etat_processus).echelle_log_y2 = d_faux;
1714: (*s_etat_processus).echelle_log_z2 = d_faux;
1715:
1716: (*s_etat_processus).point_de_vue_theta = 4 * atan((real8) 1) / 6;
1717: (*s_etat_processus).point_de_vue_phi = 4 * atan((real8) 1) / 3;
1718: (*s_etat_processus).echelle_3D = 1;
1719:
1720: strcpy((*s_etat_processus).type_trace_eq, "FONCTION");
1721: strcpy((*s_etat_processus).type_trace_sigma, "POINTS");
1722: (*s_etat_processus).fichiers_graphiques = NULL;
1723: (*s_etat_processus).nom_fichier_impression = NULL;
1724: strcpy((*s_etat_processus).format_papier, "a4paper");
1725: (*s_etat_processus).entree_standard = NULL;
1726: (*s_etat_processus).s_marques = NULL;
1727: (*s_etat_processus).requete_nouveau_plan = d_vrai;
1728: (*s_etat_processus).mise_a_jour_trace_requise = d_faux;
1729:
1730: (*s_etat_processus).l_base_pile = NULL;
1731: (*s_etat_processus).hauteur_pile_operationnelle = 0;
1732: (*s_etat_processus).l_base_pile_contextes = NULL;
1733: (*s_etat_processus).l_base_pile_taille_contextes = NULL;
1734:
1735: (*s_etat_processus).position_courante = 0;
1736:
1737: (*s_etat_processus).l_base_pile_systeme = NULL;
1738: (*s_etat_processus).hauteur_pile_systeme = 0;
1739:
1740: (*s_etat_processus).l_base_pile_processus = NULL;
1741: (*s_etat_processus).presence_pipes = d_faux;
1742: (*s_etat_processus).pipe_donnees = 0;
1743: (*s_etat_processus).pipe_acquittement = 0;
1744: (*s_etat_processus).pipe_injections = 0;
1745: (*s_etat_processus).pipe_nombre_injections = 0;
1746: (*s_etat_processus).nombre_objets_injectes = 0;
1747: (*s_etat_processus).nombre_objets_envoyes_non_lus = 0;
1748: (*s_etat_processus).pourcentage_maximal_cpu = 100;
1749: (*s_etat_processus).temps_maximal_cpu = 0;
1750: (*s_etat_processus).thread_fusible = 0;
1751: (*s_etat_processus).presence_fusible = d_faux;
1752:
1753: (*s_etat_processus).niveau_recursivite = 0;
1754: (*s_etat_processus).generateur_aleatoire = NULL;
1755: (*s_etat_processus).type_generateur_aleatoire = NULL;
1756:
1757: (*s_etat_processus).colonne_statistique_1 = 1;
1758: (*s_etat_processus).colonne_statistique_2 = 2;
1759:
1760: (*s_etat_processus).debug_programme = d_faux;
1761: (*s_etat_processus).execution_pas_suivant = d_faux;
1762: (*s_etat_processus).traitement_instruction_halt = d_faux;
1763:
1764: (*s_etat_processus).derniere_exception = d_ep;
1765: (*s_etat_processus).derniere_erreur_systeme = d_es;
1766: (*s_etat_processus).derniere_erreur_execution = d_ex;
1767: (*s_etat_processus).derniere_erreur_evaluation = d_ex;
1768: (*s_etat_processus).derniere_erreur_fonction_externe = 0;
1769:
1770: (*s_etat_processus).erreur_processus_fils = d_faux;
1771: (*s_etat_processus).erreur_systeme_processus_fils = d_es;
1772: (*s_etat_processus).erreur_execution_processus_fils = d_ex;
1773: (*s_etat_processus).pid_erreur_processus_fils = 0;
1774: (*s_etat_processus).exception_processus_fils = d_ep;
1775: (*s_etat_processus).core = core;
1776: (*s_etat_processus).invalidation_message_erreur = d_faux;
1777: (*s_etat_processus).s_objet_errone = NULL;
1778: (*s_etat_processus).s_objet_erreur = NULL;
1779:
1780: (*s_etat_processus).retour_routine_evaluation = 'N';
1781:
1782: (*s_etat_processus).traitement_interruption = 'N';
1783: (*s_etat_processus).traitement_interruptible = 'Y';
1784: (*s_etat_processus).nombre_interruptions_en_queue = 0;
1785: (*s_etat_processus).nombre_interruptions_non_affectees = 0;
1786:
1787: for(i = 0; i < d_NOMBRE_INTERRUPTIONS; i++)
1788: {
1789: (*s_etat_processus).masque_interruptions[i] = 'N';
1790: (*s_etat_processus).queue_interruptions[i] = 0;
1791: (*s_etat_processus).corps_interruptions[i] = NULL;
1792: (*s_etat_processus).pile_origine_interruptions[i] = NULL;
1793: }
1794:
1795: (*s_etat_processus).pointeurs_caracteres = NULL;
1796: (*s_etat_processus).arbre_instructions = NULL;
1797:
1798: (*s_etat_processus).tid_processus_pere = pthread_self();
1799: (*s_etat_processus).pid_processus_pere = getpid();
1800: (*s_etat_processus).processus_detache = d_vrai;
1801: (*s_etat_processus).var_volatile_processus_pere = -1;
1802: (*s_etat_processus).var_volatile_traitement_retarde_stop = 0;
1803: (*s_etat_processus).var_volatile_alarme = 0;
1804: (*s_etat_processus).var_volatile_requete_arret = 0;
1805: (*s_etat_processus).var_volatile_requete_arret2 = 0;
1806: (*s_etat_processus).var_volatile_traitement_retarde_stop = 0;
1807: (*s_etat_processus).var_volatile_traitement_sigint = 0;
1808: (*s_etat_processus).var_volatile_recursivite = 0;
1809: (*s_etat_processus).var_volatile_exception_gsl = 0;
1810:
1811: initialisation_allocateur(s_etat_processus);
1812: initialisation_drapeaux(s_etat_processus);
1813:
1814: if ((*s_etat_processus).erreur_systeme != d_es)
1815: {
1816: if ((*s_etat_processus).langue == 'F')
1817: {
1818: printf("+++Système : Mémoire insuffisante\n");
1819: }
1820: else
1821: {
1822: printf("+++System : Not enough memory\n");
1823: }
1824:
1825: return(EXIT_FAILURE);
1826: }
1827:
1828: if (((*s_etat_processus).instruction_derniere_erreur =
1829: malloc(2 * sizeof(unsigned char))) == NULL)
1830: {
1831: erreur = d_es_allocation_memoire;
1832:
1833: if ((*s_etat_processus).langue == 'F')
1834: {
1835: printf("+++Système : Mémoire insuffisante\n");
1836: }
1837: else
1838: {
1839: printf("+++System : Not enough memory\n");
1840: }
1841:
1842: return(EXIT_FAILURE);
1843: }
1844:
1845: strcpy((*s_etat_processus).instruction_derniere_erreur, "");
1846: (*s_etat_processus).niveau_derniere_erreur = 0;
1847:
1848: if (traitement_fichier_temporaire == 'Y')
1849: {
1850: (*s_etat_processus).mode_interactif = 'Y';
1851: }
1852: else
1853: {
1854: (*s_etat_processus).mode_interactif = 'N';
1855: }
1856:
1857: if (((*s_etat_processus).instruction_courante = (unsigned char *)
1858: malloc(sizeof(unsigned char))) == NULL)
1859: {
1860: erreur = d_es_allocation_memoire;
1861:
1862: if ((*s_etat_processus).langue == 'F')
1863: {
1864: printf("+++Système : Mémoire insuffisante\n");
1865: }
1866: else
1867: {
1868: printf("+++System : Not enough memory\n");
1869: }
1870:
1871: return(EXIT_FAILURE);
1872: }
1873:
1874: (*s_etat_processus).instruction_courante[0] = d_code_fin_chaine;
1875:
1876: empilement_pile_systeme(s_etat_processus);
1877:
1878: free((*s_etat_processus).instruction_courante);
1879:
1880: if ((*s_etat_processus).erreur_systeme == d_es_allocation_memoire)
1881: {
1882: erreur = d_es_allocation_memoire;
1883: }
1884: else
1885: {
1886: (*((*s_etat_processus).l_base_pile_systeme))
1887: .retour_definition = 'Y';
1888:
1889: (*s_etat_processus).indep = (struct_objet *) malloc(
1890: sizeof(struct_objet));
1891: (*s_etat_processus).depend = (struct_objet *) malloc(
1892: sizeof(struct_objet));
1893: (*s_etat_processus).parametres_courbes_de_niveau =
1894: (struct_objet *) malloc(sizeof(struct_objet));
1895:
1896: if (((*s_etat_processus).indep != NULL) &&
1897: ((*s_etat_processus).depend != NULL) &&
1898: ((*s_etat_processus).parametres_courbes_de_niveau
1899: != NULL))
1900: {
1901: (*((*s_etat_processus).indep)).type = NOM;
1902: (*((*s_etat_processus).depend)).type = NOM;
1903: (*((*s_etat_processus).
1904: parametres_courbes_de_niveau)).type = LST;
1905:
1906: initialisation_objet((*s_etat_processus).indep);
1907: initialisation_objet((*s_etat_processus).depend);
1908: initialisation_objet((*s_etat_processus)
1909: .parametres_courbes_de_niveau);
1910:
1911: (*((*s_etat_processus).indep)).objet = (struct_nom *)
1912: malloc(sizeof(struct_nom));
1913: (*((*s_etat_processus).depend)).objet = (struct_nom *)
1914: malloc(sizeof(struct_nom));
1915: (*((*s_etat_processus).parametres_courbes_de_niveau))
1916: .objet = (struct_liste_chainee *)
1917: malloc(sizeof(struct_liste_chainee));
1918:
1919: if (((*((*s_etat_processus).depend)).objet == NULL) ||
1920: ((*((*s_etat_processus).depend)).objet == NULL) ||
1921: ((*((*s_etat_processus).
1922: parametres_courbes_de_niveau)).objet == NULL))
1923: {
1924: erreur = d_es_allocation_memoire;
1925:
1926: if ((*s_etat_processus).langue == 'F')
1927: {
1928: printf("+++Système : Mémoire insuffisante\n");
1929: }
1930: else
1931: {
1932: printf("+++System : Not enough memory\n");
1933: }
1934:
1935: return(EXIT_FAILURE);
1936: }
1937:
1938: (*((struct_nom *) (*((*s_etat_processus).indep)).objet))
1939: .nom = malloc(2 * sizeof(unsigned char));
1940: (*((struct_nom *) (*((*s_etat_processus).depend)).objet))
1941: .nom = malloc(2 * sizeof(unsigned char));
1942:
1943: if (((*((struct_nom *) (*((*s_etat_processus).indep))
1944: .objet)).nom == NULL) || ((*((struct_nom *)
1945: (*((*s_etat_processus).depend)).objet)).nom ==
1946: NULL))
1947: {
1948: erreur = d_es_allocation_memoire;
1949:
1950: if ((*s_etat_processus).langue == 'F')
1951: {
1952: printf("+++Système : Mémoire insuffisante\n");
1953: }
1954: else
1955: {
1956: printf("+++System : Not enough memory\n");
1957: }
1958:
1959: return(EXIT_FAILURE);
1960: }
1961:
1962: strcpy((*((struct_nom *) (*((*s_etat_processus).indep))
1963: .objet)).nom, "X");
1964: strcpy((*((struct_nom *) (*((*s_etat_processus).depend))
1965: .objet)).nom, "Y");
1966:
1967: (*((struct_nom *) (*((*s_etat_processus).indep))
1968: .objet)).symbole = d_vrai;
1969: (*((struct_nom *) (*((*s_etat_processus).depend))
1970: .objet)).symbole = d_vrai;
1971:
1972: (*((struct_liste_chainee *) (*((*s_etat_processus)
1973: .parametres_courbes_de_niveau)).objet)).suivant
1974: = NULL;
1975:
1976: (*((struct_liste_chainee *) (*((*s_etat_processus)
1977: .parametres_courbes_de_niveau)).objet)).donnee
1978: = malloc(sizeof(struct_objet));
1979:
1980: (*s_etat_processus).legende =
1981: malloc(sizeof(unsigned char));
1982: (*s_etat_processus).label_x =
1983: malloc(sizeof(unsigned char));
1984: (*s_etat_processus).label_y =
1985: malloc(sizeof(unsigned char));
1986: (*s_etat_processus).label_z =
1987: malloc(sizeof(unsigned char));
1988: (*s_etat_processus).titre =
1989: malloc(sizeof(unsigned char));
1990:
1991: if (((*s_etat_processus).label_x == NULL) ||
1992: ((*s_etat_processus).label_y == NULL) ||
1993: ((*s_etat_processus).label_z == NULL) ||
1994: ((*s_etat_processus).titre == NULL) ||
1995: ((*s_etat_processus).legende == NULL) ||
1996: ((*((struct_liste_chainee *) (*((*s_etat_processus)
1997: .parametres_courbes_de_niveau)).objet)).donnee
1998: == NULL))
1999: {
2000: erreur = d_es_allocation_memoire;
2001:
2002: if ((*s_etat_processus).langue == 'F')
2003: {
2004: printf("+++Système : Mémoire insuffisante\n");
2005: }
2006: else
2007: {
2008: printf("+++System : Not enough memory\n");
2009: }
2010:
2011: return(EXIT_FAILURE);
2012: }
2013:
2014: (*(*((struct_liste_chainee *) (*((*s_etat_processus)
2015: .parametres_courbes_de_niveau)).objet)).donnee)
2016: .type = CHN;
2017:
2018: initialisation_objet((*((struct_liste_chainee *)
2019: (*((*s_etat_processus)
2020: .parametres_courbes_de_niveau))
2021: .objet)).donnee);
2022:
2023: if (((*(*((struct_liste_chainee *) (*((*s_etat_processus)
2024: .parametres_courbes_de_niveau)).objet)).donnee)
2025: .objet = malloc(10 * sizeof(unsigned char)))
2026: == NULL)
2027: {
2028: erreur = d_es_allocation_memoire;
2029:
2030: if ((*s_etat_processus).langue == 'F')
2031: {
2032: printf("+++Système : Mémoire insuffisante\n");
2033: }
2034: else
2035: {
2036: printf("+++System : Not enough memory\n");
2037: }
2038:
2039: return(EXIT_FAILURE);
2040: }
2041:
2042: strcpy((unsigned char *) (*(*((struct_liste_chainee *)
2043: (*((*s_etat_processus)
2044: .parametres_courbes_de_niveau))
2045: .objet)).donnee).objet, "AUTOMATIC");
2046:
2047: (*s_etat_processus).label_x[0] = d_code_fin_chaine;
2048: (*s_etat_processus).label_y[0] = d_code_fin_chaine;
2049: (*s_etat_processus).label_z[0] = d_code_fin_chaine;
2050: (*s_etat_processus).titre[0] = d_code_fin_chaine;
2051: (*s_etat_processus).legende[0] = d_code_fin_chaine;
2052:
2053: (*s_etat_processus).nom_fichier_gnuplot = NULL;
2054: (*s_etat_processus).type_fichier_gnuplot = NULL;
2055:
2056: (*s_etat_processus).x_tics = 0;
2057: (*s_etat_processus).y_tics = 0;
2058: (*s_etat_processus).z_tics = 0;
2059:
2060: (*s_etat_processus).x_lines = d_vrai;
2061: (*s_etat_processus).y_lines = d_vrai;
2062: (*s_etat_processus).z_lines = d_vrai;
2063:
2064: (*s_etat_processus).mx_tics = -1;
2065: (*s_etat_processus).my_tics = -1;
2066: (*s_etat_processus).mz_tics = -1;
2067:
2068: (*s_etat_processus).mx_lines = d_faux;
2069: (*s_etat_processus).my_lines = d_faux;
2070: (*s_etat_processus).mz_lines = d_faux;
2071:
2072: (*s_etat_processus).x2_tics = -1;
2073: (*s_etat_processus).y2_tics = -1;
2074: (*s_etat_processus).z2_tics = -1;
2075:
2076: (*s_etat_processus).x2_lines = d_faux;
2077: (*s_etat_processus).y2_lines = d_faux;
2078: (*s_etat_processus).z2_lines = d_faux;
2079:
2080: (*s_etat_processus).mx2_tics = -1;
2081: (*s_etat_processus).my2_tics = -1;
2082: (*s_etat_processus).mz2_tics = -1;
2083:
2084: (*s_etat_processus).mx2_lines = d_faux;
2085: (*s_etat_processus).my2_lines = d_faux;
2086: (*s_etat_processus).mz2_lines = d_faux;
2087:
2088: if ((*s_etat_processus).erreur_systeme != d_es)
2089: {
2090: if ((*s_etat_processus).langue == 'F')
2091: {
2092: printf("+++Système : Mémoire insuffisante\n");
2093: }
2094: else
2095: {
2096: printf("+++System : Not enough memory\n");
2097: }
2098:
2099: return(EXIT_FAILURE);
2100: }
2101:
2102: (*s_etat_processus).mode_evaluation_expression = 'N';
2103: (*s_etat_processus).mode_execution_programme = 'Y';
2104:
2105: if ((*s_etat_processus).definitions_chainees == NULL)
2106: {
2107: if ((erreur = chainage(s_etat_processus)) !=
2108: d_absence_erreur)
2109: {
2110: if ((*s_etat_processus).langue == 'F')
2111: {
2112: printf("+++Fatal :"
2113: " Chaînage des définitions"
2114: " impossible\n");
2115: }
2116: else
2117: {
2118: printf("+++Fatal : Error in "
2119: "compilation\n");
2120: }
2121:
2122: if (traitement_fichier_temporaire == 'Y')
2123: {
2124: if (destruction_fichier(
2125: nom_fichier_temporaire)
2126: == d_erreur)
2127: {
2128: return(EXIT_FAILURE);
2129: }
2130:
2131: free(nom_fichier_temporaire);
2132: }
2133:
2134: return(EXIT_FAILURE);
2135: }
2136: }
2137:
2138: if ((erreur = compilation(s_etat_processus)) !=
2139: d_absence_erreur)
2140: {
2141: if (traitement_fichier_temporaire == 'Y')
2142: {
2143: if (destruction_fichier(nom_fichier_temporaire)
2144: == d_erreur)
2145: {
2146: return(EXIT_FAILURE);
2147: }
2148:
2149: free(nom_fichier_temporaire);
2150: }
2151:
2152: printf("%s [%d]\n", message =
2153: messages(s_etat_processus), (int) getpid());
2154: free(message);
2155:
2156: if (test_cfsf(s_etat_processus, 51) == d_faux)
2157: {
2158: printf("%s", ds_beep);
2159: }
2160:
2161: if ((*s_etat_processus).core == d_vrai)
2162: {
2163: printf("\n");
2164:
2165: if ((*s_etat_processus).langue == 'F')
2166: {
2167: printf("+++Information : Génération du fichier "
2168: "rpl-core [%d]\n", (int) getpid());
2169: }
2170: else
2171: {
2172: printf("+++Information : Writing rpl-core "
2173: "file [%d]\n", (int) getpid());
2174: }
2175:
2176: rplcore(s_etat_processus);
2177:
2178: if ((*s_etat_processus).langue == 'F')
2179: {
2180: printf("+++Information : Processus tracé "
2181: "[%d]\n", (int) getpid());
2182: }
2183: else
2184: {
2185: printf("+++Information : Done [%d]\n",
2186: (int) getpid());
2187: }
2188:
2189: printf("\n");
2190: }
2191:
2192: return(EXIT_FAILURE);
2193: }
2194:
2195: (*s_etat_processus).position_courante = 0;
2196: (*s_etat_processus).traitement_cycle_exit = 'N';
2197:
2198: if ((*s_etat_processus).nombre_variables == 0)
2199: {
2200: if ((*s_etat_processus).langue == 'F')
2201: {
2202: printf("+++Fatal : Aucun point d'entrée\n");
2203: }
2204: else
2205: {
2206: printf("+++Fatal : Any entry point\n");
2207: }
2208:
2209: if (test_cfsf(s_etat_processus, 51) == d_faux)
2210: {
2211: printf("%s", ds_beep);
2212: }
2213:
2214: return(EXIT_FAILURE);
2215: }
2216:
2217: if (recherche_instruction_suivante(s_etat_processus)
2218: == d_erreur)
2219: {
2220: if ((*s_etat_processus).langue == 'F')
2221: {
2222: printf("+++Fatal : Aucun point d'entrée\n");
2223: }
2224: else
2225: {
2226: printf("+++Fatal : Any entry point\n");
2227: }
2228:
2229: if (test_cfsf(s_etat_processus, 51) == d_faux)
2230: {
2231: printf("%s", ds_beep);
2232: }
2233:
2234: return(EXIT_FAILURE);
2235: }
2236:
2237: if (recherche_variable(s_etat_processus,
2238: (*s_etat_processus)
2239: .instruction_courante) == d_faux)
2240: {
2241: if ((*s_etat_processus).langue == 'F')
2242: {
2243: printf("+++Fatal : Aucun point d'entrée\n");
2244: }
2245: else
2246: {
2247: printf("+++Fatal : Any entry point\n");
2248: }
2249:
2250: if (test_cfsf(s_etat_processus, 51) == d_faux)
2251: {
2252: printf("%s", ds_beep);
2253: }
2254:
2255: return(EXIT_FAILURE);
2256: }
2257:
2258: if ((*s_etat_processus).s_liste_variables
2259: [(*s_etat_processus)
2260: .position_variable_courante].niveau != 0)
2261: {
2262: if ((*s_etat_processus).langue == 'F')
2263: {
2264: printf("+++Fatal : Aucun point d'entrée\n");
2265: }
2266: else
2267: {
2268: printf("+++Fatal : Any entry point\n");
2269: }
2270:
2271: if (test_cfsf(s_etat_processus, 51) == d_faux)
2272: {
2273: printf("%s", ds_beep);
2274: }
2275:
2276: return(EXIT_FAILURE);
2277: }
2278:
2279: free((*s_etat_processus).instruction_courante);
2280: (*s_etat_processus).position_courante = 0;
2281:
2282: if (((*s_etat_processus).nom_fichier_historique =
2283: malloc((strlen(home) +
2284: strlen(ds_fichier_historique) + 2) *
2285: sizeof(unsigned char))) == NULL)
2286: {
2287: erreur = d_es_allocation_memoire;
2288:
2289: if ((*s_etat_processus).langue == 'F')
2290: {
2291: printf("+++Système : Mémoire insuffisante\n");
2292: }
2293: else
2294: {
2295: printf("+++System : Not enough memory\n");
2296: }
2297:
2298: return(EXIT_FAILURE);
2299: }
2300:
2301: sprintf((*s_etat_processus).nom_fichier_historique, "%s/%s",
2302: home, ds_fichier_historique);
2303:
2304: using_history();
2305: erreur_historique = read_history(
2306: (*s_etat_processus).nom_fichier_historique);
2307:
2308: gsl_set_error_handler(&traitement_exceptions_gsl);
2309:
2310: if (drapeau_encart == 'Y')
2311: {
2312: (*s_etat_processus).erreur_systeme = d_es;
2313: encart(s_etat_processus,
2314: (unsigned long) (5 * 1000000));
2315:
2316: if ((*s_etat_processus).erreur_systeme != d_es)
2317: {
2318: if ((message = messages(s_etat_processus))
2319: == NULL)
2320: {
2321: erreur = d_es_allocation_memoire;
2322:
2323: if ((*s_etat_processus).langue == 'F')
2324: {
2325: printf("+++Système : Mémoire "
2326: "insuffisante\n");
2327: }
2328: else
2329: {
2330: printf("+++System : Not enough "
2331: "memory\n");
2332: }
2333:
2334: return(EXIT_FAILURE);
2335: }
2336:
2337: printf("%s [%d]\n", message, (int) getpid());
2338: free(message);
2339:
2340: return(EXIT_FAILURE);
2341: }
2342: }
2343:
2344: fflush(stdout);
2345:
2346: initialisation_instructions(s_etat_processus);
2347:
2348: if (arguments != NULL)
2349: {
2350: tampon = (*s_etat_processus).definitions_chainees;
2351: (*s_etat_processus).definitions_chainees =
2352: arguments;
2353:
2354: if (analyse_syntaxique(s_etat_processus) ==
2355: d_erreur)
2356: {
2357: if ((*s_etat_processus).erreur_systeme != d_es)
2358: {
2359: erreur = d_es_allocation_memoire;
2360:
2361: if ((*s_etat_processus).langue == 'F')
2362: {
2363: printf("+++Système : Mémoire "
2364: "insuffisante\n");
2365: }
2366: else
2367: {
2368: printf("+++System : Not enough "
2369: "memory\n");
2370: }
2371:
2372: return(EXIT_FAILURE);
2373: }
2374: else
2375: {
2376: if ((*s_etat_processus).langue == 'F')
2377: {
2378: printf("+++Erreur : Erreur de "
2379: "syntaxe\n");
2380: }
2381: else
2382: {
2383: printf("+++Error : Syntax error\n");
2384: }
2385:
2386: return(EXIT_FAILURE);
2387: }
2388: }
2389:
2390: (*s_etat_processus).instruction_courante
2391: = arguments;
2392: (*s_etat_processus).definitions_chainees = tampon;
2393: (*s_etat_processus).position_courante = 0;
2394:
2395: recherche_type(s_etat_processus);
2396:
2397: if ((*s_etat_processus).erreur_systeme != d_es)
2398: {
2399: if ((message = messages(s_etat_processus))
2400: == NULL)
2401: {
2402: erreur = d_es_allocation_memoire;
2403:
2404: if ((*s_etat_processus).langue == 'F')
2405: {
2406: printf("+++Système : Mémoire "
2407: "insuffisante\n");
2408: }
2409: else
2410: {
2411: printf("+++System : Not enough "
2412: "memory\n");
2413: }
2414:
2415: return(EXIT_FAILURE);
2416: }
2417:
2418: printf("%s [%d]\n", message, (int) getpid());
2419: free(message);
2420:
2421: return(EXIT_FAILURE);
2422: }
2423:
2424: if ((*s_etat_processus).erreur_execution != d_ex)
2425: {
2426: if ((message = messages(s_etat_processus))
2427: == NULL)
2428: {
2429: erreur = d_es_allocation_memoire;
2430:
2431: if ((*s_etat_processus).langue == 'F')
2432: {
2433: printf("+++Erreur : Mémoire "
2434: "insuffisante\n");
2435: }
2436: else
2437: {
2438: printf("+++Error : Not enough "
2439: "memory\n");
2440: }
2441:
2442: return(EXIT_FAILURE);
2443: }
2444:
2445: printf("%s [%d]\n", message, (int) getpid());
2446: free(message);
2447:
2448: return(EXIT_FAILURE);
2449: }
2450:
2451: if (depilement(s_etat_processus,
2452: &((*s_etat_processus).l_base_pile),
2453: &s_objet) == d_erreur)
2454: {
2455: if ((message = messages(s_etat_processus))
2456: == NULL)
2457: {
2458: erreur = d_es_allocation_memoire;
2459:
2460: if ((*s_etat_processus).langue == 'F')
2461: {
2462: printf("+++Erreur : Mémoire "
2463: "insuffisante\n");
2464: }
2465: else
2466: {
2467: printf("+++Error : Not enough "
2468: "memory\n");
2469: }
2470:
2471: return(EXIT_FAILURE);
2472: }
2473:
2474: printf("%s [%d]\n", message, (int) getpid());
2475: free(message);
2476:
2477: return(EXIT_FAILURE);
2478: }
2479:
2480: if (evaluation(s_etat_processus, s_objet, 'E')
2481: == d_erreur)
2482: {
2483: if ((*s_etat_processus).erreur_systeme != d_es)
2484: {
2485: if ((message = messages(s_etat_processus))
2486: == NULL)
2487: {
2488: erreur = d_es_allocation_memoire;
2489:
2490: if ((*s_etat_processus).langue == 'F')
2491: {
2492: printf("+++Système : Mémoire "
2493: "insuffisante\n");
2494: }
2495: else
2496: {
2497: printf("+++System : Not enough "
2498: "memory\n");
2499: }
2500:
2501: return(EXIT_FAILURE);
2502: }
2503:
2504: printf("%s [%d]\n", message,
2505: (int) getpid());
2506: free(message);
2507:
2508: return(EXIT_FAILURE);
2509: }
2510:
2511: if ((*s_etat_processus).erreur_execution
2512: != d_ex)
2513: {
2514: if ((message = messages(s_etat_processus))
2515: == NULL)
2516: {
2517: erreur = d_es_allocation_memoire;
2518:
2519: if ((*s_etat_processus).langue == 'F')
2520: {
2521: printf("+++Erreur : Mémoire "
2522: "insuffisante\n");
2523: }
2524: else
2525: {
2526: printf("+++Error : Not enough "
2527: "memory\n");
2528: }
2529:
2530: return(EXIT_FAILURE);
2531: }
2532:
2533: printf("%s [%d]\n", message,
2534: (int) getpid());
2535: free(message);
2536:
2537: return(EXIT_FAILURE);
2538: }
2539: }
2540:
2541: (*s_etat_processus).instruction_courante = NULL;
2542: liberation(s_etat_processus, s_objet);
2543:
2544: free(arguments);
2545: }
2546:
2547: if (option_D == d_vrai)
2548: {
2549: lancement_daemon(s_etat_processus);
2550: }
2551:
2552: if (option_p == d_faux)
2553: {
2554: if (setjmp(contexte_initial) == 0)
2555: {
2556: erreur = sequenceur(s_etat_processus);
2557: }
2558: }
2559: else
2560: {
2561: if (setjmp(contexte_initial) == 0)
2562: {
2563: erreur = sequenceur_optimise(s_etat_processus);
2564: }
2565: }
2566:
2567: if ((*s_etat_processus).generateur_aleatoire != NULL)
2568: {
2569: liberation_generateur_aleatoire(s_etat_processus);
2570: }
2571:
2572: l_element_courant = (*s_etat_processus).liste_mutexes;
2573: while(l_element_courant != NULL)
2574: {
2575: pthread_mutex_trylock(&((*((struct_mutex *)
2576: (*(*((struct_liste_chainee *)
2577: l_element_courant)).donnee).objet)).mutex));
2578: pthread_mutex_unlock(&((*((struct_mutex *)
2579: (*(*((struct_liste_chainee *)
2580: l_element_courant)).donnee).objet)).mutex));
2581: pthread_mutex_destroy(&((*((struct_mutex *)
2582: (*(*((struct_liste_chainee *)
2583: l_element_courant)).donnee).objet)).mutex));
2584:
2585: liberation(s_etat_processus,
2586: (*((struct_liste_chainee *)
2587: l_element_courant)).donnee);
2588: l_element_suivant = (*((struct_liste_chainee *)
2589: l_element_courant)).suivant;
2590: free((struct_liste_chainee *) l_element_courant);
2591: l_element_courant = l_element_suivant;
2592: }
2593:
2594: /*
2595: * Arrêt des processus fils
2596: */
2597:
2598: if ((*s_etat_processus).presence_fusible == d_vrai)
2599: {
2600: pthread_cancel((*s_etat_processus).thread_fusible);
2601: }
2602:
2603: pthread_mutex_lock(&((*s_etat_processus).mutex));
2604:
2605: l_element_courant = (void *) (*s_etat_processus)
2606: .l_base_pile_processus;
2607:
2608: while(l_element_courant != NULL)
2609: {
2610: if ((*s_etat_processus).debug == d_vrai)
2611: {
2612: if (((*s_etat_processus).type_debug &
2613: d_debug_processus) != 0)
2614: {
2615: if ((*(*((struct_processus_fils *)
2616: (*(*((struct_liste_chainee *)
2617: l_element_courant)).donnee)
2618: .objet)).thread)
2619: .processus_detache == d_vrai)
2620: {
2621: if ((*s_etat_processus).langue == 'F')
2622: {
2623: printf("[%d] Signalement pour arrêt du "
2624: "processus %d\n",
2625: (int) getpid(), (int)
2626: (*(*((struct_processus_fils *)
2627: (*(*((struct_liste_chainee *)
2628: l_element_courant)).donnee)
2629: .objet)).thread).pid);
2630: }
2631: else
2632: {
2633: printf("[%d] Send stop signal to "
2634: "process %d\n",
2635: (int) getpid(), (int)
2636: (*(*((struct_processus_fils *)
2637: (*(*((struct_liste_chainee *)
2638: l_element_courant)).donnee)
2639: .objet)).thread).pid);
2640: }
2641: }
2642: else
2643: {
2644: if ((*s_etat_processus).langue == 'F')
2645: {
2646: printf("[%d] Signalement pour arrêt du "
2647: "thread %llu\n", (int) getpid(),
2648: (unsigned long long)
2649: (*(*((struct_processus_fils *)
2650: (*(*((struct_liste_chainee *)
2651: l_element_courant)).donnee)
2652: .objet)).thread).tid);
2653: }
2654: else
2655: {
2656: printf("[%d] Send stop signal to "
2657: "thread %llu\n",
2658: (int) getpid(),
2659: (unsigned long long)
2660: (*(*((struct_processus_fils *)
2661: (*(*((struct_liste_chainee *)
2662: l_element_courant)).donnee)
2663: .objet)).thread).tid);
2664: }
2665: }
2666: }
2667: }
2668:
2669: if ((*(*((struct_processus_fils *)
2670: (*(*((struct_liste_chainee *)
2671: l_element_courant)).donnee).objet))
2672: .thread).processus_detache == d_vrai)
2673: {
2674: if ((*s_etat_processus).var_volatile_alarme != 0)
2675: {
2676: kill((*(*((struct_processus_fils *)
2677: (*(*((struct_liste_chainee *)
2678: l_element_courant)).donnee).objet))
2679: .thread).pid, SIGURG);
2680: }
2681: else
2682: {
2683: kill((*(*((struct_processus_fils *)
2684: (*(*((struct_liste_chainee *)
2685: l_element_courant)).donnee).objet))
2686: .thread).pid, SIGFSTOP);
2687: }
2688: }
2689: else
2690: {
2691: pthread_mutex_lock(&((*(*((struct_processus_fils *)
2692: (*(*((struct_liste_chainee *)
2693: l_element_courant)).donnee).objet)).thread)
2694: .mutex));
2695:
2696: if ((*(*((struct_processus_fils *)
2697: (*(*((struct_liste_chainee *)
2698: l_element_courant)).donnee).objet)).thread)
2699: .thread_actif == d_vrai)
2700: {
2701: if ((*s_etat_processus).var_volatile_alarme
2702: != 0)
2703: {
2704: pthread_kill((*(*((struct_processus_fils *)
2705: (*(*((struct_liste_chainee *)
2706: l_element_courant)).donnee).objet))
2707: .thread).tid, SIGURG);
2708: }
2709: else
2710: {
2711: pthread_kill((*(*((struct_processus_fils *)
2712: (*(*((struct_liste_chainee *)
2713: l_element_courant)).donnee).objet))
2714: .thread).tid, SIGFSTOP);
2715: }
2716: }
2717:
2718: pthread_mutex_unlock(
2719: &((*(*((struct_processus_fils *)
2720: (*(*((struct_liste_chainee *)
2721: l_element_courant)).donnee).objet)).thread)
2722: .mutex));
2723: }
2724:
2725: l_element_courant = (*((struct_liste_chainee *)
2726: l_element_courant)).suivant;
2727: }
2728:
2729: /*
2730: * Attente de la fin de tous les processus fils
2731: */
2732:
2733: for(i = 0; i < d_NOMBRE_INTERRUPTIONS;
2734: (*s_etat_processus).masque_interruptions[i++]
2735: = 'I');
2736:
2737: attente.tv_sec = 0;
2738: attente.tv_nsec = GRANULARITE_us * 1000;
2739:
2740: while((*s_etat_processus).l_base_pile_processus != NULL)
2741: {
2742: status = 0;
2743:
2744: l_element_courant = (void *)
2745: (*s_etat_processus).l_base_pile_processus;
2746:
2747: if ((*s_etat_processus)
2748: .nombre_interruptions_non_affectees != 0)
2749: {
2750: affectation_interruptions_logicielles(
2751: s_etat_processus);
2752: }
2753:
2754: for(i = 0; i < (unsigned long)
2755: (*(*((struct_processus_fils *)
2756: (*(*((struct_liste_chainee *)
2757: l_element_courant)).donnee).objet)).thread)
2758: .nombre_objets_dans_pipe; i++)
2759: {
2760: if ((s_objet = lecture_pipe(
2761: s_etat_processus,
2762: (*(*((struct_processus_fils *)
2763: (*(*((struct_liste_chainee *)
2764: l_element_courant)).donnee).objet)).thread)
2765: .pipe_objets[0])) != NULL)
2766: {
2767: liberation(s_etat_processus, s_objet);
2768:
2769: (*(*((struct_processus_fils *)
2770: (*(*((struct_liste_chainee *)
2771: l_element_courant)).donnee).objet))
2772: .thread).nombre_objets_dans_pipe--;
2773:
2774: action.sa_handler = SIG_IGN;
2775: action.sa_flags = SA_ONSTACK;
2776:
2777: if (sigaction(SIGPIPE, &action, ®istre)
2778: != 0)
2779: {
2780: pthread_mutex_unlock(
2781: &((*s_etat_processus).mutex));
2782: return(EXIT_FAILURE);
2783: }
2784:
2785: while((longueur_ecriture =
2786: write_atomic(s_etat_processus,
2787: (*(*((struct_processus_fils *)
2788: (*(*((struct_liste_chainee *)
2789: l_element_courant)).donnee).objet))
2790: .thread).pipe_nombre_injections[1], "+",
2791: sizeof(unsigned char))) !=
2792: sizeof(unsigned char))
2793: {
2794: if (longueur_ecriture == -1)
2795: {
2796: // Le processus n'existe plus.
2797: break;
2798: }
2799: }
2800:
2801: if (sigaction(SIGPIPE, ®istre, NULL)
2802: != 0)
2803: {
2804: pthread_mutex_unlock(
2805: &((*s_etat_processus).mutex));
2806: return(EXIT_FAILURE);
2807: }
2808: }
2809: }
2810:
2811: pthread_mutex_unlock(&((*s_etat_processus).mutex));
2812: nanosleep(&attente, NULL);
2813: pthread_mutex_lock(&((*s_etat_processus).mutex));
2814: }
2815:
2816: pthread_mutex_unlock(&((*s_etat_processus).mutex));
2817:
2818: erreur_historique = write_history(
2819: (*s_etat_processus).nom_fichier_historique);
2820: clear_history();
2821:
2822: if (erreur_historique != 0)
2823: {
2824: if ((*s_etat_processus).langue == 'F')
2825: {
2826: printf("+++Erreur : L'historique ne peut être "
2827: "écrit\n");
2828: }
2829: else
2830: {
2831: printf("+++Error : History cannot be "
2832: "written\n");
2833: }
2834:
2835: if (test_cfsf(s_etat_processus, 51) == d_faux)
2836: {
2837: printf("%s", ds_beep);
2838: }
2839: }
2840:
2841: free((*s_etat_processus).nom_fichier_historique);
2842:
2843: if (((*s_etat_processus).core == d_vrai) &&
2844: (erreur == d_erreur) &&
2845: ((*s_etat_processus).var_volatile_traitement_sigint
2846: == 0))
2847: {
2848: printf("\n");
2849:
2850: if ((*s_etat_processus).langue == 'F')
2851: {
2852: printf("+++Information : Génération du fichier "
2853: "rpl-core [%d]\n", (int) getpid());
2854: }
2855: else
2856: {
2857: printf("+++Information : Writing rpl-core "
2858: "file [%d]\n", (int) getpid());
2859: }
2860:
2861: rplcore(s_etat_processus);
2862:
2863: if ((*s_etat_processus).langue == 'F')
2864: {
2865: printf("+++Information : Processus tracé [%d]\n",
2866: (int) getpid());
2867: }
2868: else
2869: {
2870: printf("+++Information : Done [%d]\n",
2871: (int) getpid());
2872: }
2873:
2874: printf("\n");
2875: }
2876:
2877: free((*s_etat_processus).definitions_chainees);
2878:
2879: /*
2880: * Libération de l'arbre des instructions
2881: */
2882:
2883: liberation_arbre_instructions(s_etat_processus,
2884: (*s_etat_processus).arbre_instructions);
2885: free((*s_etat_processus).pointeurs_caracteres);
2886:
2887: if ((*s_etat_processus).entree_standard != NULL)
2888: {
2889: pclose((*s_etat_processus).entree_standard);
2890: (*s_etat_processus).entree_standard = NULL;
2891: }
2892:
2893: if ((*s_etat_processus).nom_fichier_impression != NULL)
2894: {
2895: if (test_cfsf(s_etat_processus, 51) == d_faux)
2896: {
2897: printf("%s", ds_beep);
2898: }
2899:
2900: if ((*s_etat_processus).langue == 'F')
2901: {
2902: printf("+++Attention : Queue d'impression "
2903: "non vide !\n");
2904: }
2905: else
2906: {
2907: printf("+++Warning : Non empty printing "
2908: "spool queue !\n");
2909: }
2910:
2911: instruction_erase(s_etat_processus);
2912: }
2913:
2914: if ((*s_etat_processus).fichiers_graphiques != NULL)
2915: {
2916: instruction_cllcd(s_etat_processus);
2917: }
2918:
2919: liberation(s_etat_processus, (*s_etat_processus).indep);
2920: liberation(s_etat_processus, (*s_etat_processus).depend);
2921:
2922: free((*s_etat_processus).label_x);
2923: free((*s_etat_processus).label_y);
2924: free((*s_etat_processus).label_z);
2925: free((*s_etat_processus).titre);
2926: free((*s_etat_processus).legende);
2927:
2928: liberation(s_etat_processus, (*s_etat_processus)
2929: .parametres_courbes_de_niveau);
2930:
2931: for(i = 0; i < d_NOMBRE_INTERRUPTIONS; i++)
2932: {
2933: liberation(s_etat_processus,
2934: (*s_etat_processus).corps_interruptions[i]);
2935:
2936: l_element_courant = (*s_etat_processus)
2937: .pile_origine_interruptions[i];
2938:
2939: while(l_element_courant != NULL)
2940: {
2941: l_element_suivant = (*((struct_liste_chainee *)
2942: l_element_courant)).suivant;
2943:
2944: liberation(s_etat_processus,
2945: (*((struct_liste_chainee *)
2946: l_element_courant)).donnee);
2947: free(l_element_courant);
2948:
2949: l_element_courant = l_element_suivant;
2950: }
2951: }
2952:
2953: if ((*s_etat_processus).instruction_derniere_erreur
2954: != NULL)
2955: {
2956: free((*s_etat_processus).instruction_derniere_erreur);
2957: (*s_etat_processus).instruction_derniere_erreur = NULL;
2958: }
2959:
2960: /*
2961: * Le pointeur s_etat_processus.nom_fichier_source est
2962: * alloué par le système. Il ne faut donc pas
2963: * le libérer...
2964: */
2965:
2966: for(i = 0; i < (*s_etat_processus).nombre_variables; i++)
2967: {
2968: liberation(s_etat_processus,
2969: (*s_etat_processus).s_liste_variables[i].objet);
2970: free((*s_etat_processus).s_liste_variables[i].nom);
2971: }
2972:
2973: free((*s_etat_processus).s_liste_variables);
2974:
2975: for(i = 0; i < (*s_etat_processus)
2976: .nombre_variables_statiques; i++)
2977: {
2978: liberation(s_etat_processus, (*s_etat_processus)
2979: .s_liste_variables_statiques[i].objet);
2980: free((*s_etat_processus)
2981: .s_liste_variables_statiques[i].nom);
2982: }
2983:
2984: free((*s_etat_processus).s_liste_variables_statiques);
2985:
2986: for(i = 0; i < (*((*s_etat_processus)
2987: .s_liste_variables_partagees)).nombre_variables;
2988: i++)
2989: {
2990: liberation(s_etat_processus, (*((*s_etat_processus)
2991: .s_liste_variables_partagees)).table[i].objet);
2992: free((*((*s_etat_processus)
2993: .s_liste_variables_partagees)).table[i].nom);
2994: }
2995:
2996: free((struct_variable_partagee *)
2997: (*((*s_etat_processus).s_liste_variables_partagees))
2998: .table);
2999:
3000: /*
3001: * Si resultats est non nul, rplinit a été appelé
3002: * depuis rpl() [librpl] et non main().
3003: * On copie alors le contenu de la * pile dans un
3004: * tableau **resultats dont le pointeur de base a
3005: * été alloué dans rpl().
3006: */
3007:
3008: if (resultats != NULL)
3009: {
3010: if ((*resultats) != NULL)
3011: {
3012: free((*resultats));
3013:
3014: if (((*resultats) = malloc(((*s_etat_processus)
3015: .hauteur_pile_operationnelle + 1)
3016: * sizeof(unsigned char **))) != NULL)
3017: {
3018: (*resultats)[(*s_etat_processus)
3019: .hauteur_pile_operationnelle] = NULL;
3020: l_element_courant = (void *) (*s_etat_processus)
3021: .l_base_pile;
3022:
3023: for(i = 0; i < (*s_etat_processus)
3024: .hauteur_pile_operationnelle; i++)
3025: {
3026: if (l_element_courant != NULL)
3027: {
3028: (*resultats)[i] =
3029: formateur(s_etat_processus,
3030: 0, (*((struct_liste_chainee *)
3031: l_element_courant)).donnee);
3032:
3033: if ((*resultats)[i] == NULL)
3034: {
3035: i = (*s_etat_processus).
3036: hauteur_pile_operationnelle;
3037: }
3038: else
3039: {
3040: l_element_suivant =
3041: (*((struct_liste_chainee *)
3042: l_element_courant)).suivant;
3043: }
3044: }
3045: }
3046: }
3047: else
3048: {
3049: (*resultats) = NULL;
3050: erreur = d_es_allocation_memoire;
3051: }
3052: }
3053: }
3054:
3055: l_element_courant = (void *) (*s_etat_processus)
3056: .l_base_pile;
3057: while(l_element_courant != NULL)
3058: {
3059: l_element_suivant = (*((struct_liste_chainee *)
3060: l_element_courant)).suivant;
3061:
3062: liberation(s_etat_processus,
3063: (*((struct_liste_chainee *)
3064: l_element_courant)).donnee);
3065: free((struct_liste_chainee *) l_element_courant);
3066:
3067: l_element_courant = l_element_suivant;
3068: }
3069:
3070: l_element_courant = (void *) (*s_etat_processus)
3071: .l_base_pile_contextes;
3072: while(l_element_courant != NULL)
3073: {
3074: l_element_suivant = (*((struct_liste_chainee *)
3075: l_element_courant)).suivant;
3076:
3077: liberation(s_etat_processus,
3078: (*((struct_liste_chainee *)
3079: l_element_courant)).donnee);
3080: free((struct_liste_chainee *) l_element_courant);
3081:
3082: l_element_courant = l_element_suivant;
3083: }
3084:
3085: l_element_courant = (void *) (*s_etat_processus)
3086: .l_base_pile_taille_contextes;
3087: while(l_element_courant != NULL)
3088: {
3089: l_element_suivant = (*((struct_liste_chainee *)
3090: l_element_courant)).suivant;
3091:
3092: liberation(s_etat_processus,
3093: (*((struct_liste_chainee *)
3094: l_element_courant)).donnee);
3095: free((struct_liste_chainee *) l_element_courant);
3096:
3097: l_element_courant = l_element_suivant;
3098: }
3099:
3100: for(i = 0; i < (*s_etat_processus)
3101: .nombre_instructions_externes; i++)
3102: {
3103: free((*s_etat_processus).s_instructions_externes[i]
3104: .nom);
3105: free((*s_etat_processus).s_instructions_externes[i]
3106: .nom_bibliotheque);
3107: }
3108:
3109: if ((*s_etat_processus).nombre_instructions_externes != 0)
3110: {
3111: free((*s_etat_processus).s_instructions_externes);
3112: }
3113:
3114: l_element_courant = (void *) (*s_etat_processus)
3115: .s_bibliotheques;
3116:
3117: while(l_element_courant != NULL)
3118: {
3119: l_element_suivant = (*((struct_liste_chainee *)
3120: l_element_courant)).suivant;
3121:
3122: free((*((struct_bibliotheque *)
3123: (*((struct_liste_chainee *)
3124: l_element_courant)).donnee)).nom);
3125: dlclose((*((struct_bibliotheque *)
3126: (*((struct_liste_chainee *)
3127: l_element_courant)).donnee)).descripteur);
3128: free((*((struct_liste_chainee *) l_element_courant))
3129: .donnee);
3130: free(l_element_courant);
3131:
3132: l_element_courant = l_element_suivant;
3133: }
3134:
3135: l_element_courant = (void *) (*s_etat_processus)
3136: .l_base_pile_last;
3137: while(l_element_courant != NULL)
3138: {
3139: l_element_suivant = (*((struct_liste_chainee *)
3140: l_element_courant)).suivant;
3141:
3142: liberation(s_etat_processus,
3143: (*((struct_liste_chainee *)
3144: l_element_courant)).donnee);
3145: free((struct_liste_chainee *) l_element_courant);
3146:
3147: l_element_courant = l_element_suivant;
3148: }
3149:
3150: l_element_courant = (void *) (*s_etat_processus)
3151: .l_base_pile_systeme;
3152: while(l_element_courant != NULL)
3153: {
3154: l_element_suivant = (*((struct_liste_pile_systeme *)
3155: l_element_courant)).suivant;
3156:
3157: liberation(s_etat_processus,
3158: (*((struct_liste_pile_systeme *)
3159: l_element_courant)).indice_boucle);
3160: liberation(s_etat_processus,
3161: (*((struct_liste_pile_systeme *)
3162: l_element_courant)).limite_indice_boucle);
3163: liberation(s_etat_processus,
3164: (*((struct_liste_pile_systeme *)
3165: l_element_courant)).objet_de_test);
3166:
3167: if ((*((struct_liste_pile_systeme *)
3168: l_element_courant)).nom_variable != NULL)
3169: {
3170: free((*((struct_liste_pile_systeme *)
3171: l_element_courant)).nom_variable);
3172: }
3173:
3174: free((struct_liste_pile_systeme *)
3175: l_element_courant);
3176:
3177: l_element_courant = l_element_suivant;
3178: }
3179:
3180: l_element_courant = (void *)
3181: (*s_etat_processus).s_fichiers;
3182: while(l_element_courant != NULL)
3183: {
3184: l_element_suivant = (*((struct_liste_chainee *)
3185: l_element_courant)).suivant;
3186:
3187: fclose((*((struct_descripteur_fichier *)
3188: (*((struct_liste_chainee *)
3189: l_element_courant)).donnee))
3190: .descripteur);
3191:
3192: if ((*((struct_descripteur_fichier *)
3193: (*((struct_liste_chainee *)
3194: l_element_courant)).donnee))
3195: .effacement == 'Y')
3196: {
3197: unlink((*((struct_descripteur_fichier *)
3198: (*((struct_liste_chainee *)
3199: l_element_courant)).donnee))
3200: .nom);
3201: }
3202:
3203: free((*((struct_descripteur_fichier *)
3204: (*((struct_liste_chainee *)
3205: l_element_courant)).donnee)).nom);
3206: free((struct_descripteur_fichier *)
3207: (*((struct_liste_chainee *)
3208: l_element_courant)).donnee);
3209: free(l_element_courant);
3210:
3211: l_element_courant = l_element_suivant;
3212: }
3213:
3214: l_element_courant = (void *)
3215: (*s_etat_processus).s_sockets;
3216: while(l_element_courant != NULL)
3217: {
3218: l_element_suivant = (*((struct_liste_chainee *)
3219: l_element_courant)).suivant;
3220:
3221: if ((*((struct_socket *)
3222: (*(*((struct_liste_chainee *)
3223: l_element_courant)).donnee).objet))
3224: .socket_connectee == d_vrai)
3225: {
3226: shutdown((*((struct_socket *)
3227: (*(*((struct_liste_chainee *)
3228: l_element_courant)).donnee).objet))
3229: .socket, SHUT_RDWR);
3230: }
3231:
3232: close((*((struct_socket *)
3233: (*(*((struct_liste_chainee *)
3234: l_element_courant)).donnee).objet)).socket);
3235:
3236: if ((*((struct_socket *) (*(*((struct_liste_chainee *)
3237: l_element_courant)).donnee).objet)).effacement
3238: == 'Y')
3239: {
3240: unlink((*((struct_socket *)
3241: (*(*((struct_liste_chainee *)
3242: l_element_courant)).donnee).objet))
3243: .adresse);
3244: }
3245:
3246: liberation(s_etat_processus,
3247: (*((struct_liste_chainee *)
3248: l_element_courant)).donnee);
3249: free(l_element_courant);
3250:
3251: l_element_courant = l_element_suivant;
3252: }
3253:
3254: l_element_courant = (void *)
3255: (*s_etat_processus).s_connecteurs_sql;
3256: while(l_element_courant != NULL)
3257: {
3258: l_element_suivant = (*((struct_liste_chainee *)
3259: l_element_courant)).suivant;
3260:
3261: sqlclose((*((struct_liste_chainee *)
3262: l_element_courant)).donnee);
3263: liberation(s_etat_processus,
3264: (*((struct_liste_chainee *)
3265: l_element_courant)).donnee);
3266: free(l_element_courant);
3267:
3268: l_element_courant = l_element_suivant;
3269: }
3270:
3271: free((*s_etat_processus).chemin_fichiers_temporaires);
3272:
3273: l_element_courant = (*s_etat_processus).s_marques;
3274: while(l_element_courant != NULL)
3275: {
3276: free((*((struct_marque *) l_element_courant)).label);
3277: free((*((struct_marque *) l_element_courant)).position);
3278: l_element_suivant = (*((struct_marque *)
3279: l_element_courant)).suivant;
3280: free(l_element_courant);
3281: l_element_courant = l_element_suivant;
3282: }
3283: }
3284: else
3285: {
3286: erreur = d_es_allocation_memoire;
3287:
3288: if (test_cfsf(s_etat_processus, 51) == d_faux)
3289: {
3290: printf("%s", ds_beep);
3291: }
3292:
3293: if ((*s_etat_processus).langue == 'F')
3294: {
3295: printf("+++Système : Mémoire insuffisante\n");
3296: }
3297: else
3298: {
3299: printf("+++System : Not enough memory\n");
3300: }
3301: }
3302: }
3303:
3304: liberation_allocateur(s_etat_processus);
3305: }
3306:
3307: if (traitement_fichier_temporaire == 'Y')
3308: {
3309: if (destruction_fichier(nom_fichier_temporaire) == d_erreur)
3310: {
3311: return(EXIT_FAILURE);
3312: }
3313:
3314: free(nom_fichier_temporaire);
3315: }
3316:
3317: if ((*s_etat_processus).profilage == d_vrai)
3318: {
3319: ecriture_profil(s_etat_processus);
3320: liberation_profil(s_etat_processus);
3321: }
3322: }
3323:
3324: free((*s_etat_processus).pile_signal.ss_sp);
3325: closelog();
3326:
3327: pthread_mutex_destroy(&((*s_etat_processus).protection_liste_mutexes));
3328: pthread_mutex_destroy(&((*((*s_etat_processus).s_liste_variables_partagees))
3329: .mutex));
3330:
3331: retrait_thread(s_etat_processus);
3332:
3333: pthread_mutex_destroy(&((*s_etat_processus).mutex));
3334: sem_post(&((*s_etat_processus).semaphore_fork));
3335: sem_destroy(&((*s_etat_processus).semaphore_fork));
3336:
3337: free((*s_etat_processus).localisation);
3338: free(s_etat_processus);
3339:
3340: sem_destroy(&semaphore_liste_threads);
3341: sem_post(&semaphore_gestionnaires_signaux);
3342: sem_destroy(&semaphore_gestionnaires_signaux);
3343: sem_destroy(&semaphore_gestionnaires_signaux_atomique);
3344:
3345: return((erreur == d_os) ? EXIT_SUCCESS : EXIT_FAILURE);
3346: }
3347:
3348:
3349: void
3350: informations(struct_processus *s_etat_processus)
3351: {
3352: printf("\n");
3353:
3354: if ((*s_etat_processus).langue == 'F')
3355: {
3356: printf(" rpl [-options] [programme]\n");
3357: printf(" -a : informations sur l'auteur\n");
3358: printf(" -A : paramètres passés au programme principal\n");
3359: printf(" -c : génération de fichier de débogage (rpl-core)\n");
3360: printf(" -d : option de déverminage interne\n");
3361: printf(" -D : lancement d'un daemon\n");
3362: printf(" -h : aide sur la ligne de commande\n");
3363: printf(" -i : fonctionnement interactif\n");
3364: printf(" -l : licence d'utilisation\n");
3365: printf(" -n : ignorance du signal HUP\n");
3366: printf(" -p : précompilation du script avant exécution\n");
3367: printf(" -P : profilage\n");
3368: printf(" -s : empêchement de l'ouverture de l'écran initial\n");
3369: printf(" -S : exécution du script passé en ligne de commande\n");
3370: printf(" -t : trace\n");
3371: printf(" -v : version\n");
3372: }
3373: else
3374: {
3375: printf(" rpl [-options] [program]\n");
3376: printf(" -a : displays informations about the author\n");
3377: printf(" -A : sends parameters to main program\n");
3378: printf(" -c : allows creation of a rpl-core file, providing a way"
3379: "\n"
3380: " to debug a program\n");
3381: printf(" -d : internal debug process\n");
3382: printf(" -D : starts in daemon mode\n");
3383: printf(" -h : shows a summary of available options\n");
3384: printf(" -i : runs the RPL/2 sequencer in interactive mode\n");
3385: printf(" -l : prints the user licence of the software\n");
3386: printf(" -n : ignores HUP signal\n");
3387: printf(" -p : precompiles script\n");
3388: printf(" -P : computes profile data\n");
3389: printf(" -s : disables splash screen\n");
3390: printf(" -S : executes script written in command line\n");
3391: printf(" -t : enables tracing mode\n");
3392: printf(" -v : prints the version number\n");
3393: }
3394:
3395: printf("\n");
3396:
3397: return;
3398: }
3399:
3400: // vim: ts=4