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