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