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