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