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