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