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