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