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