![]() ![]() | ![]() |
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: if (((existence == d_faux) || (erreur_fichier != d_absence_erreur)) &&
1570: (option_S == d_faux))
1571: {
1572: if (presence_definition == 'O')
1573: {
1574: if ((*s_etat_processus).langue == 'F')
1575: {
1576: printf("+++Erreur : Fichier %s inexistant\n",
1577: (*s_etat_processus).nom_fichier_source);
1578: }
1579: else
1580: {
1581: printf("+++Error : File %s not found\n",
1582: (*s_etat_processus).nom_fichier_source);
1583: }
1584:
1585: erreur = d_os_fichier_introuvable;
1586: }
1587: else
1588: {
1589: if ((*s_etat_processus).langue == 'F')
1590: {
1591: printf("+++Erreur : Absence de définition à exécuter\n");
1592: }
1593: else
1594: {
1595: printf("+++Error : Any executable definition\n");
1596: }
1597: }
1.3 bertrand 1598:
1599: return(EXIT_FAILURE);
1.1 bertrand 1600: }
1601:
1602: if ((*s_etat_processus).chemin_fichiers_temporaires == NULL)
1603: {
1604: if ((*s_etat_processus).langue == 'F')
1605: {
1606: printf("+++Système : Chemin des fichiers temporaires nul\n");
1607: }
1608: else
1609: {
1610: printf("+++System : Null temporary files path\n");
1611: }
1612:
1613: return(EXIT_FAILURE);
1614: }
1615:
1616: if ((*s_etat_processus).debug == d_vrai)
1617: {
1618: if ((*s_etat_processus).langue == 'F')
1619: {
1620: printf("[%d] Chemin des fichiers temporaires %s\n\n",
1621: (int) getpid(),
1622: (*s_etat_processus).chemin_fichiers_temporaires);
1623: }
1624: else
1625: {
1626: printf("[%d] Temporary files path %s\n\n",
1627: (int) getpid(),
1628: (*s_etat_processus).chemin_fichiers_temporaires);
1629: }
1630: }
1631:
1632: if ((erreur == d_os) && (presence_definition == 'O'))
1633: {
1634: (*s_etat_processus).profilage = (option_P != 0) ? d_vrai : d_faux;
1635: (*s_etat_processus).niveau_profilage = option_P;
1636: (*s_etat_processus).pile_profilage = NULL;
1637: (*s_etat_processus).pile_profilage_fonctions = NULL;
1638: gettimeofday(&((*s_etat_processus).horodatage_profilage), NULL);
1639:
1640: (*s_etat_processus).liste_mutexes = NULL;
1641:
1642: (*s_etat_processus).test_instruction = 'N';
1643: (*s_etat_processus).nombre_arguments = 0;
1644: (*s_etat_processus).affichage_arguments = 'N';
1.6 ! bertrand 1645: (*s_etat_processus).autorisation_conversion_chaine = 'Y';
1.1 bertrand 1646: (*s_etat_processus).autorisation_evaluation_nom = 'Y';
1647: (*s_etat_processus).autorisation_empilement_programme = 'N';
1648: (*s_etat_processus).requete_arret = 'N';
1.4 bertrand 1649: (*s_etat_processus).evaluation_forcee = 'N';
1.1 bertrand 1650:
1651: (*s_etat_processus).constante_symbolique = 'N';
1652: (*s_etat_processus).traitement_symbolique = 'N';
1653:
1654: (*s_etat_processus).expression_courante = NULL;
1655: (*s_etat_processus).objet_courant = NULL;
1656: (*s_etat_processus).evaluation_expression_compilee = 'N';
1657:
1658: (*s_etat_processus).l_base_pile = NULL;
1659: (*s_etat_processus).l_base_pile_last = NULL;
1660:
1661: (*s_etat_processus).s_liste_variables = NULL;
1662: (*s_etat_processus).gel_liste_variables = d_faux;
1663: (*s_etat_processus).nombre_variables = 0;
1664: (*s_etat_processus).nombre_variables_allouees = 0;
1665: (*s_etat_processus).s_liste_variables_statiques = NULL;
1666: (*s_etat_processus).nombre_variables_statiques = 0;
1667: (*s_etat_processus).nombre_variables_statiques_allouees = 0;
1668: (*s_etat_processus).niveau_courant = 0;
1669: (*s_etat_processus).niveau_initial = 0;
1670: (*s_etat_processus).creation_variables_statiques = d_faux;
1671: (*s_etat_processus).creation_variables_partagees = d_faux;
1672: (*s_etat_processus).position_variable_courante = 0;
1673: (*s_etat_processus).position_variable_statique_courante = 0;
1674:
1675: (*s_etat_processus).s_bibliotheques = NULL;
1676: (*s_etat_processus).s_instructions_externes = NULL;
1677: (*s_etat_processus).nombre_instructions_externes = 0;
1678:
1679: (*s_etat_processus).systeme_axes = 0;
1680:
1681: (*s_etat_processus).x_min = -10.;
1682: (*s_etat_processus).x_max = 10.;
1683: (*s_etat_processus).y_min = -10.;
1684: (*s_etat_processus).y_max = 10.;
1685: (*s_etat_processus).z_min = -10.;
1686: (*s_etat_processus).z_max = 10.;
1687:
1688: (*s_etat_processus).x2_min = -10.;
1689: (*s_etat_processus).x2_max = 10.;
1690: (*s_etat_processus).y2_min = -10.;
1691: (*s_etat_processus).y2_max = 10.;
1692: (*s_etat_processus).z2_min = -10.;
1693: (*s_etat_processus).z2_max = 10.;
1694:
1695: (*s_etat_processus).resolution = .01;
1696:
1697: (*s_etat_processus).souris_active = d_faux;
1698:
1699: (*s_etat_processus).echelle_automatique_x = d_faux;
1700: (*s_etat_processus).echelle_automatique_y = d_faux;
1701: (*s_etat_processus).echelle_automatique_z = d_faux;
1702:
1703: (*s_etat_processus).echelle_automatique_x2 = d_faux;
1704: (*s_etat_processus).echelle_automatique_y2 = d_faux;
1705: (*s_etat_processus).echelle_automatique_z2 = d_faux;
1706:
1707: (*s_etat_processus).echelle_log_x = d_faux;
1708: (*s_etat_processus).echelle_log_y = d_faux;
1709: (*s_etat_processus).echelle_log_z = d_faux;
1710:
1711: (*s_etat_processus).echelle_log_x2 = d_faux;
1712: (*s_etat_processus).echelle_log_y2 = d_faux;
1713: (*s_etat_processus).echelle_log_z2 = d_faux;
1714:
1715: (*s_etat_processus).point_de_vue_theta = 4 * atan((real8) 1) / 6;
1716: (*s_etat_processus).point_de_vue_phi = 4 * atan((real8) 1) / 3;
1717: (*s_etat_processus).echelle_3D = 1;
1718:
1719: strcpy((*s_etat_processus).type_trace_eq, "FONCTION");
1720: strcpy((*s_etat_processus).type_trace_sigma, "POINTS");
1721: (*s_etat_processus).fichiers_graphiques = NULL;
1722: (*s_etat_processus).nom_fichier_impression = NULL;
1723: strcpy((*s_etat_processus).format_papier, "a4paper");
1724: (*s_etat_processus).entree_standard = NULL;
1725: (*s_etat_processus).s_marques = NULL;
1726: (*s_etat_processus).requete_nouveau_plan = d_vrai;
1727: (*s_etat_processus).mise_a_jour_trace_requise = d_faux;
1728:
1729: (*s_etat_processus).l_base_pile = NULL;
1730: (*s_etat_processus).hauteur_pile_operationnelle = 0;
1731: (*s_etat_processus).l_base_pile_contextes = NULL;
1732: (*s_etat_processus).l_base_pile_taille_contextes = NULL;
1733:
1734: (*s_etat_processus).position_courante = 0;
1735:
1736: (*s_etat_processus).l_base_pile_systeme = NULL;
1737: (*s_etat_processus).hauteur_pile_systeme = 0;
1738:
1739: (*s_etat_processus).l_base_pile_processus = NULL;
1740: (*s_etat_processus).presence_pipes = d_faux;
1741: (*s_etat_processus).pipe_donnees = 0;
1742: (*s_etat_processus).pipe_acquittement = 0;
1743: (*s_etat_processus).pipe_injections = 0;
1744: (*s_etat_processus).pipe_nombre_injections = 0;
1745: (*s_etat_processus).nombre_objets_injectes = 0;
1746: (*s_etat_processus).nombre_objets_envoyes_non_lus = 0;
1747: (*s_etat_processus).pourcentage_maximal_cpu = 100;
1748: (*s_etat_processus).temps_maximal_cpu = 0;
1749: (*s_etat_processus).thread_fusible = 0;
1750: (*s_etat_processus).presence_fusible = d_faux;
1751:
1752: (*s_etat_processus).niveau_recursivite = 0;
1753: (*s_etat_processus).generateur_aleatoire = NULL;
1754: (*s_etat_processus).type_generateur_aleatoire = NULL;
1755:
1756: (*s_etat_processus).colonne_statistique_1 = 1;
1757: (*s_etat_processus).colonne_statistique_2 = 2;
1758:
1759: (*s_etat_processus).debug_programme = d_faux;
1760: (*s_etat_processus).execution_pas_suivant = d_faux;
1761: (*s_etat_processus).traitement_instruction_halt = d_faux;
1762:
1763: (*s_etat_processus).derniere_exception = d_ep;
1764: (*s_etat_processus).derniere_erreur_systeme = d_es;
1765: (*s_etat_processus).derniere_erreur_execution = d_ex;
1766: (*s_etat_processus).derniere_erreur_evaluation = d_ex;
1767: (*s_etat_processus).derniere_erreur_fonction_externe = 0;
1768:
1769: (*s_etat_processus).erreur_processus_fils = d_faux;
1770: (*s_etat_processus).erreur_systeme_processus_fils = d_es;
1771: (*s_etat_processus).erreur_execution_processus_fils = d_ex;
1772: (*s_etat_processus).pid_erreur_processus_fils = 0;
1773: (*s_etat_processus).exception_processus_fils = d_ep;
1774: (*s_etat_processus).core = core;
1775: (*s_etat_processus).invalidation_message_erreur = d_faux;
1776: (*s_etat_processus).s_objet_errone = NULL;
1777: (*s_etat_processus).s_objet_erreur = NULL;
1778:
1779: (*s_etat_processus).retour_routine_evaluation = 'N';
1780:
1781: (*s_etat_processus).traitement_interruption = 'N';
1782: (*s_etat_processus).traitement_interruptible = 'Y';
1783: (*s_etat_processus).nombre_interruptions_en_queue = 0;
1784: (*s_etat_processus).nombre_interruptions_non_affectees = 0;
1785:
1786: for(i = 0; i < d_NOMBRE_INTERRUPTIONS; i++)
1787: {
1788: (*s_etat_processus).masque_interruptions[i] = 'N';
1789: (*s_etat_processus).queue_interruptions[i] = 0;
1790: (*s_etat_processus).corps_interruptions[i] = NULL;
1791: (*s_etat_processus).pile_origine_interruptions[i] = NULL;
1792: }
1793:
1794: (*s_etat_processus).pointeurs_caracteres = NULL;
1795: (*s_etat_processus).arbre_instructions = NULL;
1796:
1797: (*s_etat_processus).tid_processus_pere = pthread_self();
1798: (*s_etat_processus).pid_processus_pere = getpid();
1799: (*s_etat_processus).processus_detache = d_vrai;
1800: (*s_etat_processus).var_volatile_processus_pere = -1;
1801: (*s_etat_processus).var_volatile_traitement_retarde_stop = 0;
1802: (*s_etat_processus).var_volatile_alarme = 0;
1803: (*s_etat_processus).var_volatile_requete_arret = 0;
1804: (*s_etat_processus).var_volatile_requete_arret2 = 0;
1805: (*s_etat_processus).var_volatile_traitement_retarde_stop = 0;
1806: (*s_etat_processus).var_volatile_traitement_sigint = 0;
1807: (*s_etat_processus).var_volatile_recursivite = 0;
1808: (*s_etat_processus).var_volatile_exception_gsl = 0;
1809:
1810: initialisation_allocateur(s_etat_processus);
1811: initialisation_drapeaux(s_etat_processus);
1812:
1813: if ((*s_etat_processus).erreur_systeme != d_es)
1814: {
1815: if ((*s_etat_processus).langue == 'F')
1816: {
1817: printf("+++Système : Mémoire insuffisante\n");
1818: }
1819: else
1820: {
1821: printf("+++System : Not enough memory\n");
1822: }
1823:
1824: return(EXIT_FAILURE);
1825: }
1826:
1827: if (((*s_etat_processus).instruction_derniere_erreur =
1828: malloc(2 * sizeof(unsigned char))) == NULL)
1829: {
1830: erreur = d_es_allocation_memoire;
1831:
1832: if ((*s_etat_processus).langue == 'F')
1833: {
1834: printf("+++Système : Mémoire insuffisante\n");
1835: }
1836: else
1837: {
1838: printf("+++System : Not enough memory\n");
1839: }
1840:
1841: return(EXIT_FAILURE);
1842: }
1843:
1844: strcpy((*s_etat_processus).instruction_derniere_erreur, "");
1845: (*s_etat_processus).niveau_derniere_erreur = 0;
1846:
1847: if (traitement_fichier_temporaire == 'Y')
1848: {
1849: (*s_etat_processus).mode_interactif = 'Y';
1850: }
1851: else
1852: {
1853: (*s_etat_processus).mode_interactif = 'N';
1854: }
1855:
1856: if (((*s_etat_processus).instruction_courante = (unsigned char *)
1857: malloc(sizeof(unsigned char))) == NULL)
1858: {
1859: erreur = d_es_allocation_memoire;
1860:
1861: if ((*s_etat_processus).langue == 'F')
1862: {
1863: printf("+++Système : Mémoire insuffisante\n");
1864: }
1865: else
1866: {
1867: printf("+++System : Not enough memory\n");
1868: }
1869:
1870: return(EXIT_FAILURE);
1871: }
1872:
1873: (*s_etat_processus).instruction_courante[0] = d_code_fin_chaine;
1874:
1875: empilement_pile_systeme(s_etat_processus);
1876:
1877: free((*s_etat_processus).instruction_courante);
1878:
1879: if ((*s_etat_processus).erreur_systeme == d_es_allocation_memoire)
1880: {
1881: erreur = d_es_allocation_memoire;
1882: }
1883: else
1884: {
1885: (*((*s_etat_processus).l_base_pile_systeme))
1886: .retour_definition = 'Y';
1887:
1888: (*s_etat_processus).indep = (struct_objet *) malloc(
1889: sizeof(struct_objet));
1890: (*s_etat_processus).depend = (struct_objet *) malloc(
1891: sizeof(struct_objet));
1892: (*s_etat_processus).parametres_courbes_de_niveau =
1893: (struct_objet *) malloc(sizeof(struct_objet));
1894:
1895: if (((*s_etat_processus).indep != NULL) &&
1896: ((*s_etat_processus).depend != NULL) &&
1897: ((*s_etat_processus).parametres_courbes_de_niveau
1898: != NULL))
1899: {
1900: (*((*s_etat_processus).indep)).type = NOM;
1901: (*((*s_etat_processus).depend)).type = NOM;
1902: (*((*s_etat_processus).
1903: parametres_courbes_de_niveau)).type = LST;
1904:
1905: initialisation_objet((*s_etat_processus).indep);
1906: initialisation_objet((*s_etat_processus).depend);
1907: initialisation_objet((*s_etat_processus)
1908: .parametres_courbes_de_niveau);
1909:
1910: (*((*s_etat_processus).indep)).objet = (struct_nom *)
1911: malloc(sizeof(struct_nom));
1912: (*((*s_etat_processus).depend)).objet = (struct_nom *)
1913: malloc(sizeof(struct_nom));
1914: (*((*s_etat_processus).parametres_courbes_de_niveau))
1915: .objet = (struct_liste_chainee *)
1916: malloc(sizeof(struct_liste_chainee));
1917:
1918: if (((*((*s_etat_processus).depend)).objet == NULL) ||
1919: ((*((*s_etat_processus).depend)).objet == NULL) ||
1920: ((*((*s_etat_processus).
1921: parametres_courbes_de_niveau)).objet == NULL))
1922: {
1923: erreur = d_es_allocation_memoire;
1924:
1925: if ((*s_etat_processus).langue == 'F')
1926: {
1927: printf("+++Système : Mémoire insuffisante\n");
1928: }
1929: else
1930: {
1931: printf("+++System : Not enough memory\n");
1932: }
1933:
1934: return(EXIT_FAILURE);
1935: }
1936:
1937: (*((struct_nom *) (*((*s_etat_processus).indep)).objet))
1938: .nom = malloc(2 * sizeof(unsigned char));
1939: (*((struct_nom *) (*((*s_etat_processus).depend)).objet))
1940: .nom = malloc(2 * sizeof(unsigned char));
1941:
1942: if (((*((struct_nom *) (*((*s_etat_processus).indep))
1943: .objet)).nom == NULL) || ((*((struct_nom *)
1944: (*((*s_etat_processus).depend)).objet)).nom ==
1945: NULL))
1946: {
1947: erreur = d_es_allocation_memoire;
1948:
1949: if ((*s_etat_processus).langue == 'F')
1950: {
1951: printf("+++Système : Mémoire insuffisante\n");
1952: }
1953: else
1954: {
1955: printf("+++System : Not enough memory\n");
1956: }
1957:
1958: return(EXIT_FAILURE);
1959: }
1960:
1961: strcpy((*((struct_nom *) (*((*s_etat_processus).indep))
1962: .objet)).nom, "X");
1963: strcpy((*((struct_nom *) (*((*s_etat_processus).depend))
1964: .objet)).nom, "Y");
1965:
1966: (*((struct_nom *) (*((*s_etat_processus).indep))
1967: .objet)).symbole = d_vrai;
1968: (*((struct_nom *) (*((*s_etat_processus).depend))
1969: .objet)).symbole = d_vrai;
1970:
1971: (*((struct_liste_chainee *) (*((*s_etat_processus)
1972: .parametres_courbes_de_niveau)).objet)).suivant
1973: = NULL;
1974:
1975: (*((struct_liste_chainee *) (*((*s_etat_processus)
1976: .parametres_courbes_de_niveau)).objet)).donnee
1977: = malloc(sizeof(struct_objet));
1978:
1979: (*s_etat_processus).legende =
1980: malloc(sizeof(unsigned char));
1981: (*s_etat_processus).label_x =
1982: malloc(sizeof(unsigned char));
1983: (*s_etat_processus).label_y =
1984: malloc(sizeof(unsigned char));
1985: (*s_etat_processus).label_z =
1986: malloc(sizeof(unsigned char));
1987: (*s_etat_processus).titre =
1988: malloc(sizeof(unsigned char));
1989:
1990: if (((*s_etat_processus).label_x == NULL) ||
1991: ((*s_etat_processus).label_y == NULL) ||
1992: ((*s_etat_processus).label_z == NULL) ||
1993: ((*s_etat_processus).titre == NULL) ||
1994: ((*s_etat_processus).legende == NULL) ||
1995: ((*((struct_liste_chainee *) (*((*s_etat_processus)
1996: .parametres_courbes_de_niveau)).objet)).donnee
1997: == NULL))
1998: {
1999: erreur = d_es_allocation_memoire;
2000:
2001: if ((*s_etat_processus).langue == 'F')
2002: {
2003: printf("+++Système : Mémoire insuffisante\n");
2004: }
2005: else
2006: {
2007: printf("+++System : Not enough memory\n");
2008: }
2009:
2010: return(EXIT_FAILURE);
2011: }
2012:
2013: (*(*((struct_liste_chainee *) (*((*s_etat_processus)
2014: .parametres_courbes_de_niveau)).objet)).donnee)
2015: .type = CHN;
2016:
2017: initialisation_objet((*((struct_liste_chainee *)
2018: (*((*s_etat_processus)
2019: .parametres_courbes_de_niveau))
2020: .objet)).donnee);
2021:
2022: if (((*(*((struct_liste_chainee *) (*((*s_etat_processus)
2023: .parametres_courbes_de_niveau)).objet)).donnee)
2024: .objet = malloc(10 * sizeof(unsigned char)))
2025: == NULL)
2026: {
2027: erreur = d_es_allocation_memoire;
2028:
2029: if ((*s_etat_processus).langue == 'F')
2030: {
2031: printf("+++Système : Mémoire insuffisante\n");
2032: }
2033: else
2034: {
2035: printf("+++System : Not enough memory\n");
2036: }
2037:
2038: return(EXIT_FAILURE);
2039: }
2040:
2041: strcpy((unsigned char *) (*(*((struct_liste_chainee *)
2042: (*((*s_etat_processus)
2043: .parametres_courbes_de_niveau))
2044: .objet)).donnee).objet, "AUTOMATIC");
2045:
2046: (*s_etat_processus).label_x[0] = d_code_fin_chaine;
2047: (*s_etat_processus).label_y[0] = d_code_fin_chaine;
2048: (*s_etat_processus).label_z[0] = d_code_fin_chaine;
2049: (*s_etat_processus).titre[0] = d_code_fin_chaine;
2050: (*s_etat_processus).legende[0] = d_code_fin_chaine;
2051:
2052: (*s_etat_processus).nom_fichier_gnuplot = NULL;
2053: (*s_etat_processus).type_fichier_gnuplot = NULL;
2054:
2055: (*s_etat_processus).x_tics = 0;
2056: (*s_etat_processus).y_tics = 0;
2057: (*s_etat_processus).z_tics = 0;
2058:
2059: (*s_etat_processus).x_lines = d_vrai;
2060: (*s_etat_processus).y_lines = d_vrai;
2061: (*s_etat_processus).z_lines = d_vrai;
2062:
2063: (*s_etat_processus).mx_tics = -1;
2064: (*s_etat_processus).my_tics = -1;
2065: (*s_etat_processus).mz_tics = -1;
2066:
2067: (*s_etat_processus).mx_lines = d_faux;
2068: (*s_etat_processus).my_lines = d_faux;
2069: (*s_etat_processus).mz_lines = d_faux;
2070:
2071: (*s_etat_processus).x2_tics = -1;
2072: (*s_etat_processus).y2_tics = -1;
2073: (*s_etat_processus).z2_tics = -1;
2074:
2075: (*s_etat_processus).x2_lines = d_faux;
2076: (*s_etat_processus).y2_lines = d_faux;
2077: (*s_etat_processus).z2_lines = d_faux;
2078:
2079: (*s_etat_processus).mx2_tics = -1;
2080: (*s_etat_processus).my2_tics = -1;
2081: (*s_etat_processus).mz2_tics = -1;
2082:
2083: (*s_etat_processus).mx2_lines = d_faux;
2084: (*s_etat_processus).my2_lines = d_faux;
2085: (*s_etat_processus).mz2_lines = d_faux;
2086:
2087: if ((*s_etat_processus).erreur_systeme != d_es)
2088: {
2089: if ((*s_etat_processus).langue == 'F')
2090: {
2091: printf("+++Système : Mémoire insuffisante\n");
2092: }
2093: else
2094: {
2095: printf("+++System : Not enough memory\n");
2096: }
2097:
2098: return(EXIT_FAILURE);
2099: }
2100:
2101: (*s_etat_processus).mode_evaluation_expression = 'N';
2102: (*s_etat_processus).mode_execution_programme = 'Y';
2103:
2104: if ((*s_etat_processus).definitions_chainees == NULL)
2105: {
2106: if ((erreur = chainage(s_etat_processus)) !=
2107: d_absence_erreur)
2108: {
2109: if ((*s_etat_processus).langue == 'F')
2110: {
2111: printf("+++Fatal :"
2112: " Chaînage des définitions"
2113: " impossible\n");
2114: }
2115: else
2116: {
2117: printf("+++Fatal : Error in "
2118: "compilation\n");
2119: }
2120:
2121: if (traitement_fichier_temporaire == 'Y')
2122: {
2123: if (destruction_fichier(
2124: nom_fichier_temporaire)
2125: == d_erreur)
2126: {
2127: return(EXIT_FAILURE);
2128: }
2129:
2130: free(nom_fichier_temporaire);
2131: }
2132:
2133: return(EXIT_FAILURE);
2134: }
2135: }
2136:
2137: if ((erreur = compilation(s_etat_processus)) !=
2138: d_absence_erreur)
2139: {
2140: if (traitement_fichier_temporaire == 'Y')
2141: {
2142: if (destruction_fichier(nom_fichier_temporaire)
2143: == d_erreur)
2144: {
2145: return(EXIT_FAILURE);
2146: }
2147:
2148: free(nom_fichier_temporaire);
2149: }
2150:
2151: printf("%s [%d]\n", message =
2152: messages(s_etat_processus), (int) getpid());
2153: free(message);
2154:
2155: if (test_cfsf(s_etat_processus, 51) == d_faux)
2156: {
2157: printf("%s", ds_beep);
2158: }
2159:
2160: if ((*s_etat_processus).core == d_vrai)
2161: {
2162: printf("\n");
2163:
2164: if ((*s_etat_processus).langue == 'F')
2165: {
2166: printf("+++Information : Génération du fichier "
2167: "rpl-core [%d]\n", (int) getpid());
2168: }
2169: else
2170: {
2171: printf("+++Information : Writing rpl-core "
2172: "file [%d]\n", (int) getpid());
2173: }
2174:
2175: rplcore(s_etat_processus);
2176:
2177: if ((*s_etat_processus).langue == 'F')
2178: {
2179: printf("+++Information : Processus tracé "
2180: "[%d]\n", (int) getpid());
2181: }
2182: else
2183: {
2184: printf("+++Information : Done [%d]\n",
2185: (int) getpid());
2186: }
2187:
2188: printf("\n");
2189: }
2190:
2191: return(EXIT_FAILURE);
2192: }
2193:
2194: (*s_etat_processus).position_courante = 0;
2195: (*s_etat_processus).traitement_cycle_exit = 'N';
2196:
2197: if ((*s_etat_processus).nombre_variables == 0)
2198: {
2199: if ((*s_etat_processus).langue == 'F')
2200: {
2201: printf("+++Fatal : Aucun point d'entrée\n");
2202: }
2203: else
2204: {
2205: printf("+++Fatal : Any entry point\n");
2206: }
2207:
2208: if (test_cfsf(s_etat_processus, 51) == d_faux)
2209: {
2210: printf("%s", ds_beep);
2211: }
2212:
2213: return(EXIT_FAILURE);
2214: }
2215:
2216: if (recherche_instruction_suivante(s_etat_processus)
2217: == d_erreur)
2218: {
2219: if ((*s_etat_processus).langue == 'F')
2220: {
2221: printf("+++Fatal : Aucun point d'entrée\n");
2222: }
2223: else
2224: {
2225: printf("+++Fatal : Any entry point\n");
2226: }
2227:
2228: if (test_cfsf(s_etat_processus, 51) == d_faux)
2229: {
2230: printf("%s", ds_beep);
2231: }
2232:
2233: return(EXIT_FAILURE);
2234: }
2235:
2236: if (recherche_variable(s_etat_processus,
2237: (*s_etat_processus)
2238: .instruction_courante) == d_faux)
2239: {
2240: if ((*s_etat_processus).langue == 'F')
2241: {
2242: printf("+++Fatal : Aucun point d'entrée\n");
2243: }
2244: else
2245: {
2246: printf("+++Fatal : Any entry point\n");
2247: }
2248:
2249: if (test_cfsf(s_etat_processus, 51) == d_faux)
2250: {
2251: printf("%s", ds_beep);
2252: }
2253:
2254: return(EXIT_FAILURE);
2255: }
2256:
2257: if ((*s_etat_processus).s_liste_variables
2258: [(*s_etat_processus)
2259: .position_variable_courante].niveau != 0)
2260: {
2261: if ((*s_etat_processus).langue == 'F')
2262: {
2263: printf("+++Fatal : Aucun point d'entrée\n");
2264: }
2265: else
2266: {
2267: printf("+++Fatal : Any entry point\n");
2268: }
2269:
2270: if (test_cfsf(s_etat_processus, 51) == d_faux)
2271: {
2272: printf("%s", ds_beep);
2273: }
2274:
2275: return(EXIT_FAILURE);
2276: }
2277:
2278: free((*s_etat_processus).instruction_courante);
2279: (*s_etat_processus).position_courante = 0;
2280:
2281: if (((*s_etat_processus).nom_fichier_historique =
2282: malloc((strlen(home) +
2283: strlen(ds_fichier_historique) + 2) *
2284: sizeof(unsigned char))) == NULL)
2285: {
2286: erreur = d_es_allocation_memoire;
2287:
2288: if ((*s_etat_processus).langue == 'F')
2289: {
2290: printf("+++Système : Mémoire insuffisante\n");
2291: }
2292: else
2293: {
2294: printf("+++System : Not enough memory\n");
2295: }
2296:
2297: return(EXIT_FAILURE);
2298: }
2299:
2300: sprintf((*s_etat_processus).nom_fichier_historique, "%s/%s",
2301: home, ds_fichier_historique);
2302:
2303: using_history();
2304: erreur_historique = read_history(
2305: (*s_etat_processus).nom_fichier_historique);
2306:
2307: gsl_set_error_handler(&traitement_exceptions_gsl);
2308:
2309: if (drapeau_encart == 'Y')
2310: {
2311: (*s_etat_processus).erreur_systeme = d_es;
2312: encart(s_etat_processus,
2313: (unsigned long) (5 * 1000000));
2314:
2315: if ((*s_etat_processus).erreur_systeme != d_es)
2316: {
2317: if ((message = messages(s_etat_processus))
2318: == NULL)
2319: {
2320: erreur = d_es_allocation_memoire;
2321:
2322: if ((*s_etat_processus).langue == 'F')
2323: {
2324: printf("+++Système : Mémoire "
2325: "insuffisante\n");
2326: }
2327: else
2328: {
2329: printf("+++System : Not enough "
2330: "memory\n");
2331: }
2332:
2333: return(EXIT_FAILURE);
2334: }
2335:
2336: printf("%s [%d]\n", message, (int) getpid());
2337: free(message);
2338:
2339: return(EXIT_FAILURE);
2340: }
2341: }
2342:
2343: fflush(stdout);
2344:
2345: initialisation_instructions(s_etat_processus);
2346:
2347: if (arguments != NULL)
2348: {
2349: tampon = (*s_etat_processus).definitions_chainees;
2350: (*s_etat_processus).definitions_chainees =
2351: arguments;
2352:
2353: if (analyse_syntaxique(s_etat_processus) ==
2354: d_erreur)
2355: {
2356: if ((*s_etat_processus).erreur_systeme != d_es)
2357: {
2358: erreur = d_es_allocation_memoire;
2359:
2360: if ((*s_etat_processus).langue == 'F')
2361: {
2362: printf("+++Système : Mémoire "
2363: "insuffisante\n");
2364: }
2365: else
2366: {
2367: printf("+++System : Not enough "
2368: "memory\n");
2369: }
2370:
2371: return(EXIT_FAILURE);
2372: }
2373: else
2374: {
2375: if ((*s_etat_processus).langue == 'F')
2376: {
2377: printf("+++Erreur : Erreur de "
2378: "syntaxe\n");
2379: }
2380: else
2381: {
2382: printf("+++Error : Syntax error\n");
2383: }
2384:
2385: return(EXIT_FAILURE);
2386: }
2387: }
2388:
2389: (*s_etat_processus).instruction_courante
2390: = arguments;
2391: (*s_etat_processus).definitions_chainees = tampon;
2392: (*s_etat_processus).position_courante = 0;
2393:
2394: recherche_type(s_etat_processus);
2395:
2396: if ((*s_etat_processus).erreur_systeme != d_es)
2397: {
2398: if ((message = messages(s_etat_processus))
2399: == NULL)
2400: {
2401: erreur = d_es_allocation_memoire;
2402:
2403: if ((*s_etat_processus).langue == 'F')
2404: {
2405: printf("+++Système : Mémoire "
2406: "insuffisante\n");
2407: }
2408: else
2409: {
2410: printf("+++System : Not enough "
2411: "memory\n");
2412: }
2413:
2414: return(EXIT_FAILURE);
2415: }
2416:
2417: printf("%s [%d]\n", message, (int) getpid());
2418: free(message);
2419:
2420: return(EXIT_FAILURE);
2421: }
2422:
2423: if ((*s_etat_processus).erreur_execution != d_ex)
2424: {
2425: if ((message = messages(s_etat_processus))
2426: == NULL)
2427: {
2428: erreur = d_es_allocation_memoire;
2429:
2430: if ((*s_etat_processus).langue == 'F')
2431: {
2432: printf("+++Erreur : Mémoire "
2433: "insuffisante\n");
2434: }
2435: else
2436: {
2437: printf("+++Error : Not enough "
2438: "memory\n");
2439: }
2440:
2441: return(EXIT_FAILURE);
2442: }
2443:
2444: printf("%s [%d]\n", message, (int) getpid());
2445: free(message);
2446:
2447: return(EXIT_FAILURE);
2448: }
2449:
2450: if (depilement(s_etat_processus,
2451: &((*s_etat_processus).l_base_pile),
2452: &s_objet) == d_erreur)
2453: {
2454: if ((message = messages(s_etat_processus))
2455: == NULL)
2456: {
2457: erreur = d_es_allocation_memoire;
2458:
2459: if ((*s_etat_processus).langue == 'F')
2460: {
2461: printf("+++Erreur : Mémoire "
2462: "insuffisante\n");
2463: }
2464: else
2465: {
2466: printf("+++Error : Not enough "
2467: "memory\n");
2468: }
2469:
2470: return(EXIT_FAILURE);
2471: }
2472:
2473: printf("%s [%d]\n", message, (int) getpid());
2474: free(message);
2475:
2476: return(EXIT_FAILURE);
2477: }
2478:
2479: if (evaluation(s_etat_processus, s_objet, 'E')
2480: == d_erreur)
2481: {
2482: if ((*s_etat_processus).erreur_systeme != d_es)
2483: {
2484: if ((message = messages(s_etat_processus))
2485: == NULL)
2486: {
2487: erreur = d_es_allocation_memoire;
2488:
2489: if ((*s_etat_processus).langue == 'F')
2490: {
2491: printf("+++Système : Mémoire "
2492: "insuffisante\n");
2493: }
2494: else
2495: {
2496: printf("+++System : Not enough "
2497: "memory\n");
2498: }
2499:
2500: return(EXIT_FAILURE);
2501: }
2502:
2503: printf("%s [%d]\n", message,
2504: (int) getpid());
2505: free(message);
2506:
2507: return(EXIT_FAILURE);
2508: }
2509:
2510: if ((*s_etat_processus).erreur_execution
2511: != d_ex)
2512: {
2513: if ((message = messages(s_etat_processus))
2514: == NULL)
2515: {
2516: erreur = d_es_allocation_memoire;
2517:
2518: if ((*s_etat_processus).langue == 'F')
2519: {
2520: printf("+++Erreur : Mémoire "
2521: "insuffisante\n");
2522: }
2523: else
2524: {
2525: printf("+++Error : Not enough "
2526: "memory\n");
2527: }
2528:
2529: return(EXIT_FAILURE);
2530: }
2531:
2532: printf("%s [%d]\n", message,
2533: (int) getpid());
2534: free(message);
2535:
2536: return(EXIT_FAILURE);
2537: }
2538: }
2539:
2540: (*s_etat_processus).instruction_courante = NULL;
2541: liberation(s_etat_processus, s_objet);
2542:
2543: free(arguments);
2544: }
2545:
2546: if (option_D == d_vrai)
2547: {
2548: lancement_daemon(s_etat_processus);
2549: }
2550:
2551: if (option_p == d_faux)
2552: {
2553: if (setjmp(contexte_initial) == 0)
2554: {
2555: erreur = sequenceur(s_etat_processus);
2556: }
2557: }
2558: else
2559: {
2560: if (setjmp(contexte_initial) == 0)
2561: {
2562: erreur = sequenceur_optimise(s_etat_processus);
2563: }
2564: }
2565:
2566: if ((*s_etat_processus).generateur_aleatoire != NULL)
2567: {
2568: liberation_generateur_aleatoire(s_etat_processus);
2569: }
2570:
2571: l_element_courant = (*s_etat_processus).liste_mutexes;
2572: while(l_element_courant != NULL)
2573: {
2574: pthread_mutex_trylock(&((*((struct_mutex *)
2575: (*(*((struct_liste_chainee *)
2576: l_element_courant)).donnee).objet)).mutex));
2577: pthread_mutex_unlock(&((*((struct_mutex *)
2578: (*(*((struct_liste_chainee *)
2579: l_element_courant)).donnee).objet)).mutex));
2580: pthread_mutex_destroy(&((*((struct_mutex *)
2581: (*(*((struct_liste_chainee *)
2582: l_element_courant)).donnee).objet)).mutex));
2583:
2584: liberation(s_etat_processus,
2585: (*((struct_liste_chainee *)
2586: l_element_courant)).donnee);
2587: l_element_suivant = (*((struct_liste_chainee *)
2588: l_element_courant)).suivant;
2589: free((struct_liste_chainee *) l_element_courant);
2590: l_element_courant = l_element_suivant;
2591: }
2592:
2593: /*
2594: * Arrêt des processus fils
2595: */
2596:
2597: if ((*s_etat_processus).presence_fusible == d_vrai)
2598: {
2599: pthread_cancel((*s_etat_processus).thread_fusible);
2600: }
2601:
2602: pthread_mutex_lock(&((*s_etat_processus).mutex));
2603:
2604: l_element_courant = (void *) (*s_etat_processus)
2605: .l_base_pile_processus;
2606:
2607: while(l_element_courant != NULL)
2608: {
2609: if ((*s_etat_processus).debug == d_vrai)
2610: {
2611: if (((*s_etat_processus).type_debug &
2612: d_debug_processus) != 0)
2613: {
2614: if ((*(*((struct_processus_fils *)
2615: (*(*((struct_liste_chainee *)
2616: l_element_courant)).donnee)
2617: .objet)).thread)
2618: .processus_detache == d_vrai)
2619: {
2620: if ((*s_etat_processus).langue == 'F')
2621: {
2622: printf("[%d] Signalement pour arrêt du "
2623: "processus %d\n",
2624: (int) getpid(), (int)
2625: (*(*((struct_processus_fils *)
2626: (*(*((struct_liste_chainee *)
2627: l_element_courant)).donnee)
2628: .objet)).thread).pid);
2629: }
2630: else
2631: {
2632: printf("[%d] Send stop signal to "
2633: "process %d\n",
2634: (int) getpid(), (int)
2635: (*(*((struct_processus_fils *)
2636: (*(*((struct_liste_chainee *)
2637: l_element_courant)).donnee)
2638: .objet)).thread).pid);
2639: }
2640: }
2641: else
2642: {
2643: if ((*s_etat_processus).langue == 'F')
2644: {
2645: printf("[%d] Signalement pour arrêt du "
2646: "thread %llu\n", (int) getpid(),
2647: (unsigned long long)
2648: (*(*((struct_processus_fils *)
2649: (*(*((struct_liste_chainee *)
2650: l_element_courant)).donnee)
2651: .objet)).thread).tid);
2652: }
2653: else
2654: {
2655: printf("[%d] Send stop signal to "
2656: "thread %llu\n",
2657: (int) getpid(),
2658: (unsigned long long)
2659: (*(*((struct_processus_fils *)
2660: (*(*((struct_liste_chainee *)
2661: l_element_courant)).donnee)
2662: .objet)).thread).tid);
2663: }
2664: }
2665: }
2666: }
2667:
2668: if ((*(*((struct_processus_fils *)
2669: (*(*((struct_liste_chainee *)
2670: l_element_courant)).donnee).objet))
2671: .thread).processus_detache == d_vrai)
2672: {
2673: if ((*s_etat_processus).var_volatile_alarme != 0)
2674: {
2675: kill((*(*((struct_processus_fils *)
2676: (*(*((struct_liste_chainee *)
2677: l_element_courant)).donnee).objet))
2678: .thread).pid, SIGURG);
2679: }
2680: else
2681: {
2682: kill((*(*((struct_processus_fils *)
2683: (*(*((struct_liste_chainee *)
2684: l_element_courant)).donnee).objet))
2685: .thread).pid, SIGFSTOP);
2686: }
2687: }
2688: else
2689: {
2690: pthread_mutex_lock(&((*(*((struct_processus_fils *)
2691: (*(*((struct_liste_chainee *)
2692: l_element_courant)).donnee).objet)).thread)
2693: .mutex));
2694:
2695: if ((*(*((struct_processus_fils *)
2696: (*(*((struct_liste_chainee *)
2697: l_element_courant)).donnee).objet)).thread)
2698: .thread_actif == d_vrai)
2699: {
2700: if ((*s_etat_processus).var_volatile_alarme
2701: != 0)
2702: {
2703: pthread_kill((*(*((struct_processus_fils *)
2704: (*(*((struct_liste_chainee *)
2705: l_element_courant)).donnee).objet))
2706: .thread).tid, SIGURG);
2707: }
2708: else
2709: {
2710: pthread_kill((*(*((struct_processus_fils *)
2711: (*(*((struct_liste_chainee *)
2712: l_element_courant)).donnee).objet))
2713: .thread).tid, SIGFSTOP);
2714: }
2715: }
2716:
2717: pthread_mutex_unlock(
2718: &((*(*((struct_processus_fils *)
2719: (*(*((struct_liste_chainee *)
2720: l_element_courant)).donnee).objet)).thread)
2721: .mutex));
2722: }
2723:
2724: l_element_courant = (*((struct_liste_chainee *)
2725: l_element_courant)).suivant;
2726: }
2727:
2728: /*
2729: * Attente de la fin de tous les processus fils
2730: */
2731:
2732: for(i = 0; i < d_NOMBRE_INTERRUPTIONS;
2733: (*s_etat_processus).masque_interruptions[i++]
2734: = 'I');
2735:
2736: attente.tv_sec = 0;
2737: attente.tv_nsec = GRANULARITE_us * 1000;
2738:
2739: while((*s_etat_processus).l_base_pile_processus != NULL)
2740: {
2741: status = 0;
2742:
2743: l_element_courant = (void *)
2744: (*s_etat_processus).l_base_pile_processus;
2745:
2746: if ((*s_etat_processus)
2747: .nombre_interruptions_non_affectees != 0)
2748: {
2749: affectation_interruptions_logicielles(
2750: s_etat_processus);
2751: }
2752:
2753: for(i = 0; i < (unsigned long)
2754: (*(*((struct_processus_fils *)
2755: (*(*((struct_liste_chainee *)
2756: l_element_courant)).donnee).objet)).thread)
2757: .nombre_objets_dans_pipe; i++)
2758: {
2759: if ((s_objet = lecture_pipe(
2760: s_etat_processus,
2761: (*(*((struct_processus_fils *)
2762: (*(*((struct_liste_chainee *)
2763: l_element_courant)).donnee).objet)).thread)
2764: .pipe_objets[0])) != NULL)
2765: {
2766: liberation(s_etat_processus, s_objet);
2767:
2768: (*(*((struct_processus_fils *)
2769: (*(*((struct_liste_chainee *)
2770: l_element_courant)).donnee).objet))
2771: .thread).nombre_objets_dans_pipe--;
2772:
2773: action.sa_handler = SIG_IGN;
2774: action.sa_flags = SA_ONSTACK;
2775:
2776: if (sigaction(SIGPIPE, &action, ®istre)
2777: != 0)
2778: {
2779: pthread_mutex_unlock(
2780: &((*s_etat_processus).mutex));
2781: return(EXIT_FAILURE);
2782: }
2783:
2784: while((longueur_ecriture =
2785: write_atomic(s_etat_processus,
2786: (*(*((struct_processus_fils *)
2787: (*(*((struct_liste_chainee *)
2788: l_element_courant)).donnee).objet))
2789: .thread).pipe_nombre_injections[1], "+",
2790: sizeof(unsigned char))) !=
2791: sizeof(unsigned char))
2792: {
2793: if (longueur_ecriture == -1)
2794: {
2795: // Le processus n'existe plus.
2796: break;
2797: }
2798: }
2799:
2800: if (sigaction(SIGPIPE, ®istre, NULL)
2801: != 0)
2802: {
2803: pthread_mutex_unlock(
2804: &((*s_etat_processus).mutex));
2805: return(EXIT_FAILURE);
2806: }
2807: }
2808: }
2809:
2810: pthread_mutex_unlock(&((*s_etat_processus).mutex));
2811: nanosleep(&attente, NULL);
2812: pthread_mutex_lock(&((*s_etat_processus).mutex));
2813: }
2814:
2815: pthread_mutex_unlock(&((*s_etat_processus).mutex));
2816:
2817: erreur_historique = write_history(
2818: (*s_etat_processus).nom_fichier_historique);
2819: clear_history();
2820:
2821: if (erreur_historique != 0)
2822: {
2823: if ((*s_etat_processus).langue == 'F')
2824: {
2825: printf("+++Erreur : L'historique ne peut être "
2826: "écrit\n");
2827: }
2828: else
2829: {
2830: printf("+++Error : History cannot be "
2831: "written\n");
2832: }
2833:
2834: if (test_cfsf(s_etat_processus, 51) == d_faux)
2835: {
2836: printf("%s", ds_beep);
2837: }
2838: }
2839:
2840: free((*s_etat_processus).nom_fichier_historique);
2841:
2842: if (((*s_etat_processus).core == d_vrai) &&
2843: (erreur == d_erreur) &&
2844: ((*s_etat_processus).var_volatile_traitement_sigint
2845: == 0))
2846: {
2847: printf("\n");
2848:
2849: if ((*s_etat_processus).langue == 'F')
2850: {
2851: printf("+++Information : Génération du fichier "
2852: "rpl-core [%d]\n", (int) getpid());
2853: }
2854: else
2855: {
2856: printf("+++Information : Writing rpl-core "
2857: "file [%d]\n", (int) getpid());
2858: }
2859:
2860: rplcore(s_etat_processus);
2861:
2862: if ((*s_etat_processus).langue == 'F')
2863: {
2864: printf("+++Information : Processus tracé [%d]\n",
2865: (int) getpid());
2866: }
2867: else
2868: {
2869: printf("+++Information : Done [%d]\n",
2870: (int) getpid());
2871: }
2872:
2873: printf("\n");
2874: }
2875:
2876: free((*s_etat_processus).definitions_chainees);
2877:
2878: /*
2879: * Libération de l'arbre des instructions
2880: */
2881:
2882: liberation_arbre_instructions(s_etat_processus,
2883: (*s_etat_processus).arbre_instructions);
2884: free((*s_etat_processus).pointeurs_caracteres);
2885:
2886: if ((*s_etat_processus).entree_standard != NULL)
2887: {
2888: pclose((*s_etat_processus).entree_standard);
2889: (*s_etat_processus).entree_standard = NULL;
2890: }
2891:
2892: if ((*s_etat_processus).nom_fichier_impression != NULL)
2893: {
2894: if (test_cfsf(s_etat_processus, 51) == d_faux)
2895: {
2896: printf("%s", ds_beep);
2897: }
2898:
2899: if ((*s_etat_processus).langue == 'F')
2900: {
2901: printf("+++Attention : Queue d'impression "
2902: "non vide !\n");
2903: }
2904: else
2905: {
2906: printf("+++Warning : Non empty printing "
2907: "spool queue !\n");
2908: }
2909:
2910: instruction_erase(s_etat_processus);
2911: }
2912:
2913: if ((*s_etat_processus).fichiers_graphiques != NULL)
2914: {
2915: instruction_cllcd(s_etat_processus);
2916: }
2917:
2918: liberation(s_etat_processus, (*s_etat_processus).indep);
2919: liberation(s_etat_processus, (*s_etat_processus).depend);
2920:
2921: free((*s_etat_processus).label_x);
2922: free((*s_etat_processus).label_y);
2923: free((*s_etat_processus).label_z);
2924: free((*s_etat_processus).titre);
2925: free((*s_etat_processus).legende);
2926:
2927: liberation(s_etat_processus, (*s_etat_processus)
2928: .parametres_courbes_de_niveau);
2929:
2930: for(i = 0; i < d_NOMBRE_INTERRUPTIONS; i++)
2931: {
2932: liberation(s_etat_processus,
2933: (*s_etat_processus).corps_interruptions[i]);
2934:
2935: l_element_courant = (*s_etat_processus)
2936: .pile_origine_interruptions[i];
2937:
2938: while(l_element_courant != NULL)
2939: {
2940: l_element_suivant = (*((struct_liste_chainee *)
2941: l_element_courant)).suivant;
2942:
2943: liberation(s_etat_processus,
2944: (*((struct_liste_chainee *)
2945: l_element_courant)).donnee);
2946: free(l_element_courant);
2947:
2948: l_element_courant = l_element_suivant;
2949: }
2950: }
2951:
2952: if ((*s_etat_processus).instruction_derniere_erreur
2953: != NULL)
2954: {
2955: free((*s_etat_processus).instruction_derniere_erreur);
2956: (*s_etat_processus).instruction_derniere_erreur = NULL;
2957: }
2958:
2959: /*
2960: * Le pointeur s_etat_processus.nom_fichier_source est
2961: * alloué par le système. Il ne faut donc pas
2962: * le libérer...
2963: */
2964:
2965: for(i = 0; i < (*s_etat_processus).nombre_variables; i++)
2966: {
2967: liberation(s_etat_processus,
2968: (*s_etat_processus).s_liste_variables[i].objet);
2969: free((*s_etat_processus).s_liste_variables[i].nom);
2970: }
2971:
2972: free((*s_etat_processus).s_liste_variables);
2973:
2974: for(i = 0; i < (*s_etat_processus)
2975: .nombre_variables_statiques; i++)
2976: {
2977: liberation(s_etat_processus, (*s_etat_processus)
2978: .s_liste_variables_statiques[i].objet);
2979: free((*s_etat_processus)
2980: .s_liste_variables_statiques[i].nom);
2981: }
2982:
2983: free((*s_etat_processus).s_liste_variables_statiques);
2984:
2985: for(i = 0; i < (*((*s_etat_processus)
2986: .s_liste_variables_partagees)).nombre_variables;
2987: i++)
2988: {
2989: liberation(s_etat_processus, (*((*s_etat_processus)
2990: .s_liste_variables_partagees)).table[i].objet);
2991: free((*((*s_etat_processus)
2992: .s_liste_variables_partagees)).table[i].nom);
2993: }
2994:
2995: free((struct_variable_partagee *)
2996: (*((*s_etat_processus).s_liste_variables_partagees))
2997: .table);
2998:
2999: /*
3000: * Si resultats est non nul, rplinit a été appelé
3001: * depuis rpl() [librpl] et non main().
3002: * On copie alors le contenu de la * pile dans un
3003: * tableau **resultats dont le pointeur de base a
3004: * été alloué dans rpl().
3005: */
3006:
3007: if (resultats != NULL)
3008: {
3009: if ((*resultats) != NULL)
3010: {
3011: free((*resultats));
3012:
3013: if (((*resultats) = malloc(((*s_etat_processus)
3014: .hauteur_pile_operationnelle + 1)
3015: * sizeof(unsigned char **))) != NULL)
3016: {
3017: (*resultats)[(*s_etat_processus)
3018: .hauteur_pile_operationnelle] = NULL;
3019: l_element_courant = (void *) (*s_etat_processus)
3020: .l_base_pile;
3021:
3022: for(i = 0; i < (*s_etat_processus)
3023: .hauteur_pile_operationnelle; i++)
3024: {
3025: if (l_element_courant != NULL)
3026: {
3027: (*resultats)[i] =
3028: formateur(s_etat_processus,
3029: 0, (*((struct_liste_chainee *)
3030: l_element_courant)).donnee);
3031:
3032: if ((*resultats)[i] == NULL)
3033: {
3034: i = (*s_etat_processus).
3035: hauteur_pile_operationnelle;
3036: }
3037: else
3038: {
3039: l_element_suivant =
3040: (*((struct_liste_chainee *)
3041: l_element_courant)).suivant;
3042: }
3043: }
3044: }
3045: }
3046: else
3047: {
3048: (*resultats) = NULL;
3049: erreur = d_es_allocation_memoire;
3050: }
3051: }
3052: }
3053:
3054: l_element_courant = (void *) (*s_etat_processus)
3055: .l_base_pile;
3056: while(l_element_courant != NULL)
3057: {
3058: l_element_suivant = (*((struct_liste_chainee *)
3059: l_element_courant)).suivant;
3060:
3061: liberation(s_etat_processus,
3062: (*((struct_liste_chainee *)
3063: l_element_courant)).donnee);
3064: free((struct_liste_chainee *) l_element_courant);
3065:
3066: l_element_courant = l_element_suivant;
3067: }
3068:
3069: l_element_courant = (void *) (*s_etat_processus)
3070: .l_base_pile_contextes;
3071: while(l_element_courant != NULL)
3072: {
3073: l_element_suivant = (*((struct_liste_chainee *)
3074: l_element_courant)).suivant;
3075:
3076: liberation(s_etat_processus,
3077: (*((struct_liste_chainee *)
3078: l_element_courant)).donnee);
3079: free((struct_liste_chainee *) l_element_courant);
3080:
3081: l_element_courant = l_element_suivant;
3082: }
3083:
3084: l_element_courant = (void *) (*s_etat_processus)
3085: .l_base_pile_taille_contextes;
3086: while(l_element_courant != NULL)
3087: {
3088: l_element_suivant = (*((struct_liste_chainee *)
3089: l_element_courant)).suivant;
3090:
3091: liberation(s_etat_processus,
3092: (*((struct_liste_chainee *)
3093: l_element_courant)).donnee);
3094: free((struct_liste_chainee *) l_element_courant);
3095:
3096: l_element_courant = l_element_suivant;
3097: }
3098:
3099: for(i = 0; i < (*s_etat_processus)
3100: .nombre_instructions_externes; i++)
3101: {
3102: free((*s_etat_processus).s_instructions_externes[i]
3103: .nom);
3104: free((*s_etat_processus).s_instructions_externes[i]
3105: .nom_bibliotheque);
3106: }
3107:
3108: if ((*s_etat_processus).nombre_instructions_externes != 0)
3109: {
3110: free((*s_etat_processus).s_instructions_externes);
3111: }
3112:
3113: l_element_courant = (void *) (*s_etat_processus)
3114: .s_bibliotheques;
3115:
3116: while(l_element_courant != NULL)
3117: {
3118: l_element_suivant = (*((struct_liste_chainee *)
3119: l_element_courant)).suivant;
3120:
3121: free((*((struct_bibliotheque *)
3122: (*((struct_liste_chainee *)
3123: l_element_courant)).donnee)).nom);
3124: dlclose((*((struct_bibliotheque *)
3125: (*((struct_liste_chainee *)
3126: l_element_courant)).donnee)).descripteur);
3127: free((*((struct_liste_chainee *) l_element_courant))
3128: .donnee);
3129: free(l_element_courant);
3130:
3131: l_element_courant = l_element_suivant;
3132: }
3133:
3134: l_element_courant = (void *) (*s_etat_processus)
3135: .l_base_pile_last;
3136: while(l_element_courant != NULL)
3137: {
3138: l_element_suivant = (*((struct_liste_chainee *)
3139: l_element_courant)).suivant;
3140:
3141: liberation(s_etat_processus,
3142: (*((struct_liste_chainee *)
3143: l_element_courant)).donnee);
3144: free((struct_liste_chainee *) l_element_courant);
3145:
3146: l_element_courant = l_element_suivant;
3147: }
3148:
3149: l_element_courant = (void *) (*s_etat_processus)
3150: .l_base_pile_systeme;
3151: while(l_element_courant != NULL)
3152: {
3153: l_element_suivant = (*((struct_liste_pile_systeme *)
3154: l_element_courant)).suivant;
3155:
3156: liberation(s_etat_processus,
3157: (*((struct_liste_pile_systeme *)
3158: l_element_courant)).indice_boucle);
3159: liberation(s_etat_processus,
3160: (*((struct_liste_pile_systeme *)
3161: l_element_courant)).limite_indice_boucle);
3162: liberation(s_etat_processus,
3163: (*((struct_liste_pile_systeme *)
3164: l_element_courant)).objet_de_test);
3165:
3166: if ((*((struct_liste_pile_systeme *)
3167: l_element_courant)).nom_variable != NULL)
3168: {
3169: free((*((struct_liste_pile_systeme *)
3170: l_element_courant)).nom_variable);
3171: }
3172:
3173: free((struct_liste_pile_systeme *)
3174: l_element_courant);
3175:
3176: l_element_courant = l_element_suivant;
3177: }
3178:
3179: l_element_courant = (void *)
3180: (*s_etat_processus).s_fichiers;
3181: while(l_element_courant != NULL)
3182: {
3183: l_element_suivant = (*((struct_liste_chainee *)
3184: l_element_courant)).suivant;
3185:
3186: fclose((*((struct_descripteur_fichier *)
3187: (*((struct_liste_chainee *)
3188: l_element_courant)).donnee))
3189: .descripteur);
3190:
3191: if ((*((struct_descripteur_fichier *)
3192: (*((struct_liste_chainee *)
3193: l_element_courant)).donnee))
3194: .effacement == 'Y')
3195: {
3196: unlink((*((struct_descripteur_fichier *)
3197: (*((struct_liste_chainee *)
3198: l_element_courant)).donnee))
3199: .nom);
3200: }
3201:
3202: free((*((struct_descripteur_fichier *)
3203: (*((struct_liste_chainee *)
3204: l_element_courant)).donnee)).nom);
3205: free((struct_descripteur_fichier *)
3206: (*((struct_liste_chainee *)
3207: l_element_courant)).donnee);
3208: free(l_element_courant);
3209:
3210: l_element_courant = l_element_suivant;
3211: }
3212:
3213: l_element_courant = (void *)
3214: (*s_etat_processus).s_sockets;
3215: while(l_element_courant != NULL)
3216: {
3217: l_element_suivant = (*((struct_liste_chainee *)
3218: l_element_courant)).suivant;
3219:
3220: if ((*((struct_socket *)
3221: (*(*((struct_liste_chainee *)
3222: l_element_courant)).donnee).objet))
3223: .socket_connectee == d_vrai)
3224: {
3225: shutdown((*((struct_socket *)
3226: (*(*((struct_liste_chainee *)
3227: l_element_courant)).donnee).objet))
3228: .socket, SHUT_RDWR);
3229: }
3230:
3231: close((*((struct_socket *)
3232: (*(*((struct_liste_chainee *)
3233: l_element_courant)).donnee).objet)).socket);
3234:
3235: if ((*((struct_socket *) (*(*((struct_liste_chainee *)
3236: l_element_courant)).donnee).objet)).effacement
3237: == 'Y')
3238: {
3239: unlink((*((struct_socket *)
3240: (*(*((struct_liste_chainee *)
3241: l_element_courant)).donnee).objet))
3242: .adresse);
3243: }
3244:
3245: liberation(s_etat_processus,
3246: (*((struct_liste_chainee *)
3247: l_element_courant)).donnee);
3248: free(l_element_courant);
3249:
3250: l_element_courant = l_element_suivant;
3251: }
3252:
3253: l_element_courant = (void *)
3254: (*s_etat_processus).s_connecteurs_sql;
3255: while(l_element_courant != NULL)
3256: {
3257: l_element_suivant = (*((struct_liste_chainee *)
3258: l_element_courant)).suivant;
3259:
3260: sqlclose((*((struct_liste_chainee *)
3261: l_element_courant)).donnee);
3262: liberation(s_etat_processus,
3263: (*((struct_liste_chainee *)
3264: l_element_courant)).donnee);
3265: free(l_element_courant);
3266:
3267: l_element_courant = l_element_suivant;
3268: }
3269:
3270: free((*s_etat_processus).chemin_fichiers_temporaires);
3271:
3272: l_element_courant = (*s_etat_processus).s_marques;
3273: while(l_element_courant != NULL)
3274: {
3275: free((*((struct_marque *) l_element_courant)).label);
3276: free((*((struct_marque *) l_element_courant)).position);
3277: l_element_suivant = (*((struct_marque *)
3278: l_element_courant)).suivant;
3279: free(l_element_courant);
3280: l_element_courant = l_element_suivant;
3281: }
3282: }
3283: else
3284: {
3285: erreur = d_es_allocation_memoire;
3286:
3287: if (test_cfsf(s_etat_processus, 51) == d_faux)
3288: {
3289: printf("%s", ds_beep);
3290: }
3291:
3292: if ((*s_etat_processus).langue == 'F')
3293: {
3294: printf("+++Système : Mémoire insuffisante\n");
3295: }
3296: else
3297: {
3298: printf("+++System : Not enough memory\n");
3299: }
3300: }
3301: }
3302:
3303: liberation_allocateur(s_etat_processus);
3304: }
3305:
3306: if (traitement_fichier_temporaire == 'Y')
3307: {
3308: if (destruction_fichier(nom_fichier_temporaire) == d_erreur)
3309: {
3310: return(EXIT_FAILURE);
3311: }
3312:
3313: free(nom_fichier_temporaire);
3314: }
3315:
3316: if ((*s_etat_processus).profilage == d_vrai)
3317: {
3318: ecriture_profil(s_etat_processus);
3319: liberation_profil(s_etat_processus);
3320: }
3321: }
3322:
3323: free((*s_etat_processus).pile_signal.ss_sp);
3324: closelog();
3325:
3326: pthread_mutex_destroy(&((*s_etat_processus).protection_liste_mutexes));
3327: pthread_mutex_destroy(&((*((*s_etat_processus).s_liste_variables_partagees))
3328: .mutex));
3329:
3330: retrait_thread(s_etat_processus);
3331:
3332: pthread_mutex_destroy(&((*s_etat_processus).mutex));
3333: sem_post(&((*s_etat_processus).semaphore_fork));
3334: sem_destroy(&((*s_etat_processus).semaphore_fork));
3335:
3336: free((*s_etat_processus).localisation);
3337: free(s_etat_processus);
3338:
3339: sem_destroy(&semaphore_liste_threads);
3340: sem_post(&semaphore_gestionnaires_signaux);
3341: sem_destroy(&semaphore_gestionnaires_signaux);
3342: sem_destroy(&semaphore_gestionnaires_signaux_atomique);
3343:
3344: return((erreur == d_os) ? EXIT_SUCCESS : EXIT_FAILURE);
3345: }
3346:
3347:
3348: void
3349: informations(struct_processus *s_etat_processus)
3350: {
3351: printf("\n");
3352:
3353: if ((*s_etat_processus).langue == 'F')
3354: {
3355: printf(" rpl [-options] [programme]\n");
3356: printf(" -a : informations sur l'auteur\n");
3357: printf(" -A : paramètres passés au programme principal\n");
3358: printf(" -c : génération de fichier de débogage (rpl-core)\n");
3359: printf(" -d : option de déverminage interne\n");
3360: printf(" -D : lancement d'un daemon\n");
3361: printf(" -h : aide sur la ligne de commande\n");
3362: printf(" -i : fonctionnement interactif\n");
3363: printf(" -l : licence d'utilisation\n");
3364: printf(" -n : ignorance du signal HUP\n");
3365: printf(" -p : précompilation du script avant exécution\n");
3366: printf(" -P : profilage\n");
3367: printf(" -s : empêchement de l'ouverture de l'écran initial\n");
3368: printf(" -S : exécution du script passé en ligne de commande\n");
3369: printf(" -t : trace\n");
3370: printf(" -v : version\n");
3371: }
3372: else
3373: {
3374: printf(" rpl [-options] [program]\n");
3375: printf(" -a : displays informations about the author\n");
3376: printf(" -A : sends parameters to main program\n");
3377: printf(" -c : allows creation of a rpl-core file, providing a way"
3378: "\n"
3379: " to debug a program\n");
3380: printf(" -d : internal debug process\n");
3381: printf(" -D : starts in daemon mode\n");
3382: printf(" -h : shows a summary of available options\n");
3383: printf(" -i : runs the RPL/2 sequencer in interactive mode\n");
3384: printf(" -l : prints the user licence of the software\n");
3385: printf(" -n : ignores HUP signal\n");
3386: printf(" -p : precompiles script\n");
3387: printf(" -P : computes profile data\n");
3388: printf(" -s : disables splash screen\n");
3389: printf(" -S : executes script written in command line\n");
3390: printf(" -t : enables tracing mode\n");
3391: printf(" -v : prints the version number\n");
3392: }
3393:
3394: printf("\n");
3395:
3396: return;
3397: }
3398:
3399: // vim: ts=4