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