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