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