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