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