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