Annotation of rpl/src/rpl.c, revision 1.21
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:
1.20 bertrand 1843: (*s_etat_processus).at_exit = NULL;
1.19 bertrand 1844:
1.1 bertrand 1845: (*s_etat_processus).pointeurs_caracteres = NULL;
1846: (*s_etat_processus).arbre_instructions = NULL;
1847:
1848: (*s_etat_processus).tid_processus_pere = pthread_self();
1849: (*s_etat_processus).pid_processus_pere = getpid();
1850: (*s_etat_processus).processus_detache = d_vrai;
1851: (*s_etat_processus).var_volatile_processus_pere = -1;
1852: (*s_etat_processus).var_volatile_traitement_retarde_stop = 0;
1853: (*s_etat_processus).var_volatile_alarme = 0;
1854: (*s_etat_processus).var_volatile_requete_arret = 0;
1855: (*s_etat_processus).var_volatile_requete_arret2 = 0;
1856: (*s_etat_processus).var_volatile_traitement_retarde_stop = 0;
1857: (*s_etat_processus).var_volatile_traitement_sigint = 0;
1858: (*s_etat_processus).var_volatile_recursivite = 0;
1859: (*s_etat_processus).var_volatile_exception_gsl = 0;
1860:
1861: initialisation_allocateur(s_etat_processus);
1862: initialisation_drapeaux(s_etat_processus);
1863:
1864: if ((*s_etat_processus).erreur_systeme != d_es)
1865: {
1866: if ((*s_etat_processus).langue == 'F')
1867: {
1868: printf("+++Système : Mémoire insuffisante\n");
1869: }
1870: else
1871: {
1872: printf("+++System : Not enough memory\n");
1873: }
1874:
1875: return(EXIT_FAILURE);
1876: }
1877:
1878: if (((*s_etat_processus).instruction_derniere_erreur =
1879: malloc(2 * sizeof(unsigned char))) == NULL)
1880: {
1881: erreur = d_es_allocation_memoire;
1882:
1883: if ((*s_etat_processus).langue == 'F')
1884: {
1885: printf("+++Système : Mémoire insuffisante\n");
1886: }
1887: else
1888: {
1889: printf("+++System : Not enough memory\n");
1890: }
1891:
1892: return(EXIT_FAILURE);
1893: }
1894:
1895: strcpy((*s_etat_processus).instruction_derniere_erreur, "");
1896: (*s_etat_processus).niveau_derniere_erreur = 0;
1897:
1898: if (traitement_fichier_temporaire == 'Y')
1899: {
1900: (*s_etat_processus).mode_interactif = 'Y';
1901: }
1902: else
1903: {
1904: (*s_etat_processus).mode_interactif = 'N';
1905: }
1906:
1907: if (((*s_etat_processus).instruction_courante = (unsigned char *)
1908: malloc(sizeof(unsigned char))) == NULL)
1909: {
1910: erreur = d_es_allocation_memoire;
1911:
1912: if ((*s_etat_processus).langue == 'F')
1913: {
1914: printf("+++Système : Mémoire insuffisante\n");
1915: }
1916: else
1917: {
1918: printf("+++System : Not enough memory\n");
1919: }
1920:
1921: return(EXIT_FAILURE);
1922: }
1923:
1924: (*s_etat_processus).instruction_courante[0] = d_code_fin_chaine;
1925:
1926: empilement_pile_systeme(s_etat_processus);
1927:
1928: free((*s_etat_processus).instruction_courante);
1929:
1930: if ((*s_etat_processus).erreur_systeme == d_es_allocation_memoire)
1931: {
1932: erreur = d_es_allocation_memoire;
1933: }
1934: else
1935: {
1936: (*((*s_etat_processus).l_base_pile_systeme))
1937: .retour_definition = 'Y';
1938:
1939: (*s_etat_processus).indep = (struct_objet *) malloc(
1940: sizeof(struct_objet));
1941: (*s_etat_processus).depend = (struct_objet *) malloc(
1942: sizeof(struct_objet));
1943: (*s_etat_processus).parametres_courbes_de_niveau =
1944: (struct_objet *) malloc(sizeof(struct_objet));
1945:
1946: if (((*s_etat_processus).indep != NULL) &&
1947: ((*s_etat_processus).depend != NULL) &&
1948: ((*s_etat_processus).parametres_courbes_de_niveau
1949: != NULL))
1950: {
1951: (*((*s_etat_processus).indep)).type = NOM;
1952: (*((*s_etat_processus).depend)).type = NOM;
1953: (*((*s_etat_processus).
1954: parametres_courbes_de_niveau)).type = LST;
1955:
1956: initialisation_objet((*s_etat_processus).indep);
1957: initialisation_objet((*s_etat_processus).depend);
1958: initialisation_objet((*s_etat_processus)
1959: .parametres_courbes_de_niveau);
1960:
1961: (*((*s_etat_processus).indep)).objet = (struct_nom *)
1962: malloc(sizeof(struct_nom));
1963: (*((*s_etat_processus).depend)).objet = (struct_nom *)
1964: malloc(sizeof(struct_nom));
1965: (*((*s_etat_processus).parametres_courbes_de_niveau))
1966: .objet = (struct_liste_chainee *)
1967: malloc(sizeof(struct_liste_chainee));
1968:
1969: if (((*((*s_etat_processus).depend)).objet == NULL) ||
1970: ((*((*s_etat_processus).depend)).objet == NULL) ||
1971: ((*((*s_etat_processus).
1972: parametres_courbes_de_niveau)).objet == NULL))
1973: {
1974: erreur = d_es_allocation_memoire;
1975:
1976: if ((*s_etat_processus).langue == 'F')
1977: {
1978: printf("+++Système : Mémoire insuffisante\n");
1979: }
1980: else
1981: {
1982: printf("+++System : Not enough memory\n");
1983: }
1984:
1985: return(EXIT_FAILURE);
1986: }
1987:
1988: (*((struct_nom *) (*((*s_etat_processus).indep)).objet))
1989: .nom = malloc(2 * sizeof(unsigned char));
1990: (*((struct_nom *) (*((*s_etat_processus).depend)).objet))
1991: .nom = malloc(2 * sizeof(unsigned char));
1992:
1993: if (((*((struct_nom *) (*((*s_etat_processus).indep))
1994: .objet)).nom == NULL) || ((*((struct_nom *)
1995: (*((*s_etat_processus).depend)).objet)).nom ==
1996: NULL))
1997: {
1998: erreur = d_es_allocation_memoire;
1999:
2000: if ((*s_etat_processus).langue == 'F')
2001: {
2002: printf("+++Système : Mémoire insuffisante\n");
2003: }
2004: else
2005: {
2006: printf("+++System : Not enough memory\n");
2007: }
2008:
2009: return(EXIT_FAILURE);
2010: }
2011:
2012: strcpy((*((struct_nom *) (*((*s_etat_processus).indep))
2013: .objet)).nom, "X");
2014: strcpy((*((struct_nom *) (*((*s_etat_processus).depend))
2015: .objet)).nom, "Y");
2016:
2017: (*((struct_nom *) (*((*s_etat_processus).indep))
2018: .objet)).symbole = d_vrai;
2019: (*((struct_nom *) (*((*s_etat_processus).depend))
2020: .objet)).symbole = d_vrai;
2021:
2022: (*((struct_liste_chainee *) (*((*s_etat_processus)
2023: .parametres_courbes_de_niveau)).objet)).suivant
2024: = NULL;
2025:
2026: (*((struct_liste_chainee *) (*((*s_etat_processus)
2027: .parametres_courbes_de_niveau)).objet)).donnee
2028: = malloc(sizeof(struct_objet));
2029:
2030: (*s_etat_processus).legende =
2031: malloc(sizeof(unsigned char));
2032: (*s_etat_processus).label_x =
2033: malloc(sizeof(unsigned char));
2034: (*s_etat_processus).label_y =
2035: malloc(sizeof(unsigned char));
2036: (*s_etat_processus).label_z =
2037: malloc(sizeof(unsigned char));
2038: (*s_etat_processus).titre =
2039: malloc(sizeof(unsigned char));
2040:
2041: if (((*s_etat_processus).label_x == NULL) ||
2042: ((*s_etat_processus).label_y == NULL) ||
2043: ((*s_etat_processus).label_z == NULL) ||
2044: ((*s_etat_processus).titre == NULL) ||
2045: ((*s_etat_processus).legende == NULL) ||
2046: ((*((struct_liste_chainee *) (*((*s_etat_processus)
2047: .parametres_courbes_de_niveau)).objet)).donnee
2048: == 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_liste_chainee *) (*((*s_etat_processus)
2065: .parametres_courbes_de_niveau)).objet)).donnee)
2066: .type = CHN;
2067:
2068: initialisation_objet((*((struct_liste_chainee *)
2069: (*((*s_etat_processus)
2070: .parametres_courbes_de_niveau))
2071: .objet)).donnee);
2072:
2073: if (((*(*((struct_liste_chainee *) (*((*s_etat_processus)
2074: .parametres_courbes_de_niveau)).objet)).donnee)
2075: .objet = malloc(10 * sizeof(unsigned char)))
2076: == NULL)
2077: {
2078: erreur = d_es_allocation_memoire;
2079:
2080: if ((*s_etat_processus).langue == 'F')
2081: {
2082: printf("+++Système : Mémoire insuffisante\n");
2083: }
2084: else
2085: {
2086: printf("+++System : Not enough memory\n");
2087: }
2088:
2089: return(EXIT_FAILURE);
2090: }
2091:
2092: strcpy((unsigned char *) (*(*((struct_liste_chainee *)
2093: (*((*s_etat_processus)
2094: .parametres_courbes_de_niveau))
2095: .objet)).donnee).objet, "AUTOMATIC");
2096:
2097: (*s_etat_processus).label_x[0] = d_code_fin_chaine;
2098: (*s_etat_processus).label_y[0] = d_code_fin_chaine;
2099: (*s_etat_processus).label_z[0] = d_code_fin_chaine;
2100: (*s_etat_processus).titre[0] = d_code_fin_chaine;
2101: (*s_etat_processus).legende[0] = d_code_fin_chaine;
2102:
2103: (*s_etat_processus).nom_fichier_gnuplot = NULL;
2104: (*s_etat_processus).type_fichier_gnuplot = NULL;
2105:
2106: (*s_etat_processus).x_tics = 0;
2107: (*s_etat_processus).y_tics = 0;
2108: (*s_etat_processus).z_tics = 0;
2109:
2110: (*s_etat_processus).x_lines = d_vrai;
2111: (*s_etat_processus).y_lines = d_vrai;
2112: (*s_etat_processus).z_lines = d_vrai;
2113:
2114: (*s_etat_processus).mx_tics = -1;
2115: (*s_etat_processus).my_tics = -1;
2116: (*s_etat_processus).mz_tics = -1;
2117:
2118: (*s_etat_processus).mx_lines = d_faux;
2119: (*s_etat_processus).my_lines = d_faux;
2120: (*s_etat_processus).mz_lines = d_faux;
2121:
2122: (*s_etat_processus).x2_tics = -1;
2123: (*s_etat_processus).y2_tics = -1;
2124: (*s_etat_processus).z2_tics = -1;
2125:
2126: (*s_etat_processus).x2_lines = d_faux;
2127: (*s_etat_processus).y2_lines = d_faux;
2128: (*s_etat_processus).z2_lines = d_faux;
2129:
2130: (*s_etat_processus).mx2_tics = -1;
2131: (*s_etat_processus).my2_tics = -1;
2132: (*s_etat_processus).mz2_tics = -1;
2133:
2134: (*s_etat_processus).mx2_lines = d_faux;
2135: (*s_etat_processus).my2_lines = d_faux;
2136: (*s_etat_processus).mz2_lines = d_faux;
2137:
2138: if ((*s_etat_processus).erreur_systeme != d_es)
2139: {
2140: if ((*s_etat_processus).langue == 'F')
2141: {
2142: printf("+++Système : Mémoire insuffisante\n");
2143: }
2144: else
2145: {
2146: printf("+++System : Not enough memory\n");
2147: }
2148:
2149: return(EXIT_FAILURE);
2150: }
2151:
2152: (*s_etat_processus).mode_evaluation_expression = 'N';
2153: (*s_etat_processus).mode_execution_programme = 'Y';
2154:
2155: if ((*s_etat_processus).definitions_chainees == NULL)
2156: {
2157: if ((erreur = chainage(s_etat_processus)) !=
2158: d_absence_erreur)
2159: {
2160: if ((*s_etat_processus).langue == 'F')
2161: {
2162: printf("+++Fatal :"
2163: " Chaînage des définitions"
2164: " impossible\n");
2165: }
2166: else
2167: {
2168: printf("+++Fatal : Error in "
2169: "compilation\n");
2170: }
2171:
2172: if (traitement_fichier_temporaire == 'Y')
2173: {
2174: if (destruction_fichier(
2175: nom_fichier_temporaire)
2176: == d_erreur)
2177: {
2178: return(EXIT_FAILURE);
2179: }
2180:
2181: free(nom_fichier_temporaire);
2182: }
2183:
2184: return(EXIT_FAILURE);
2185: }
2186: }
2187:
2188: if ((erreur = compilation(s_etat_processus)) !=
2189: d_absence_erreur)
2190: {
2191: if (traitement_fichier_temporaire == 'Y')
2192: {
2193: if (destruction_fichier(nom_fichier_temporaire)
2194: == d_erreur)
2195: {
2196: return(EXIT_FAILURE);
2197: }
2198:
2199: free(nom_fichier_temporaire);
2200: }
2201:
2202: printf("%s [%d]\n", message =
2203: messages(s_etat_processus), (int) getpid());
2204: free(message);
2205:
2206: if (test_cfsf(s_etat_processus, 51) == d_faux)
2207: {
2208: printf("%s", ds_beep);
2209: }
2210:
2211: if ((*s_etat_processus).core == d_vrai)
2212: {
2213: printf("\n");
2214:
2215: if ((*s_etat_processus).langue == 'F')
2216: {
2217: printf("+++Information : Génération du fichier "
2218: "rpl-core [%d]\n", (int) getpid());
2219: }
2220: else
2221: {
2222: printf("+++Information : Writing rpl-core "
2223: "file [%d]\n", (int) getpid());
2224: }
2225:
2226: rplcore(s_etat_processus);
2227:
2228: if ((*s_etat_processus).langue == 'F')
2229: {
2230: printf("+++Information : Processus tracé "
2231: "[%d]\n", (int) getpid());
2232: }
2233: else
2234: {
2235: printf("+++Information : Done [%d]\n",
2236: (int) getpid());
2237: }
2238:
2239: printf("\n");
2240: }
2241:
2242: return(EXIT_FAILURE);
2243: }
2244:
2245: (*s_etat_processus).position_courante = 0;
2246: (*s_etat_processus).traitement_cycle_exit = 'N';
2247:
2248: if ((*s_etat_processus).nombre_variables == 0)
2249: {
2250: if ((*s_etat_processus).langue == 'F')
2251: {
2252: printf("+++Fatal : Aucun point d'entrée\n");
2253: }
2254: else
2255: {
2256: printf("+++Fatal : Any entry point\n");
2257: }
2258:
2259: if (test_cfsf(s_etat_processus, 51) == d_faux)
2260: {
2261: printf("%s", ds_beep);
2262: }
2263:
2264: return(EXIT_FAILURE);
2265: }
2266:
2267: if (recherche_instruction_suivante(s_etat_processus)
2268: == d_erreur)
2269: {
2270: if ((*s_etat_processus).langue == 'F')
2271: {
2272: printf("+++Fatal : Aucun point d'entrée\n");
2273: }
2274: else
2275: {
2276: printf("+++Fatal : Any entry point\n");
2277: }
2278:
2279: if (test_cfsf(s_etat_processus, 51) == d_faux)
2280: {
2281: printf("%s", ds_beep);
2282: }
2283:
2284: return(EXIT_FAILURE);
2285: }
2286:
2287: if (recherche_variable(s_etat_processus,
2288: (*s_etat_processus)
2289: .instruction_courante) == d_faux)
2290: {
2291: if ((*s_etat_processus).langue == 'F')
2292: {
2293: printf("+++Fatal : Aucun point d'entrée\n");
2294: }
2295: else
2296: {
2297: printf("+++Fatal : Any entry point\n");
2298: }
2299:
2300: if (test_cfsf(s_etat_processus, 51) == d_faux)
2301: {
2302: printf("%s", ds_beep);
2303: }
2304:
2305: return(EXIT_FAILURE);
2306: }
2307:
2308: if ((*s_etat_processus).s_liste_variables
2309: [(*s_etat_processus)
2310: .position_variable_courante].niveau != 0)
2311: {
2312: if ((*s_etat_processus).langue == 'F')
2313: {
2314: printf("+++Fatal : Aucun point d'entrée\n");
2315: }
2316: else
2317: {
2318: printf("+++Fatal : Any entry point\n");
2319: }
2320:
2321: if (test_cfsf(s_etat_processus, 51) == d_faux)
2322: {
2323: printf("%s", ds_beep);
2324: }
2325:
2326: return(EXIT_FAILURE);
2327: }
2328:
2329: free((*s_etat_processus).instruction_courante);
2330: (*s_etat_processus).position_courante = 0;
2331:
2332: if (((*s_etat_processus).nom_fichier_historique =
2333: malloc((strlen(home) +
2334: strlen(ds_fichier_historique) + 2) *
2335: sizeof(unsigned char))) == NULL)
2336: {
2337: erreur = d_es_allocation_memoire;
2338:
2339: if ((*s_etat_processus).langue == 'F')
2340: {
2341: printf("+++Système : Mémoire insuffisante\n");
2342: }
2343: else
2344: {
2345: printf("+++System : Not enough memory\n");
2346: }
2347:
2348: return(EXIT_FAILURE);
2349: }
2350:
2351: sprintf((*s_etat_processus).nom_fichier_historique, "%s/%s",
2352: home, ds_fichier_historique);
2353:
2354: using_history();
2355: erreur_historique = read_history(
2356: (*s_etat_processus).nom_fichier_historique);
2357:
2358: gsl_set_error_handler(&traitement_exceptions_gsl);
2359:
2360: if (drapeau_encart == 'Y')
2361: {
2362: (*s_etat_processus).erreur_systeme = d_es;
2363: encart(s_etat_processus,
2364: (unsigned long) (5 * 1000000));
2365:
2366: if ((*s_etat_processus).erreur_systeme != d_es)
2367: {
2368: if ((message = messages(s_etat_processus))
2369: == NULL)
2370: {
2371: erreur = d_es_allocation_memoire;
2372:
2373: if ((*s_etat_processus).langue == 'F')
2374: {
2375: printf("+++Système : Mémoire "
2376: "insuffisante\n");
2377: }
2378: else
2379: {
2380: printf("+++System : Not enough "
2381: "memory\n");
2382: }
2383:
2384: return(EXIT_FAILURE);
2385: }
2386:
2387: printf("%s [%d]\n", message, (int) getpid());
2388: free(message);
2389:
2390: return(EXIT_FAILURE);
2391: }
2392: }
2393:
2394: fflush(stdout);
2395:
2396: initialisation_instructions(s_etat_processus);
2397:
2398: if (arguments != NULL)
2399: {
2400: tampon = (*s_etat_processus).definitions_chainees;
2401: (*s_etat_processus).definitions_chainees =
2402: arguments;
2403:
2404: if (analyse_syntaxique(s_etat_processus) ==
2405: d_erreur)
2406: {
2407: if ((*s_etat_processus).erreur_systeme != d_es)
2408: {
2409: erreur = d_es_allocation_memoire;
2410:
2411: if ((*s_etat_processus).langue == 'F')
2412: {
2413: printf("+++Système : Mémoire "
2414: "insuffisante\n");
2415: }
2416: else
2417: {
2418: printf("+++System : Not enough "
2419: "memory\n");
2420: }
2421:
2422: return(EXIT_FAILURE);
2423: }
2424: else
2425: {
2426: if ((*s_etat_processus).langue == 'F')
2427: {
2428: printf("+++Erreur : Erreur de "
2429: "syntaxe\n");
2430: }
2431: else
2432: {
2433: printf("+++Error : Syntax error\n");
2434: }
2435:
2436: return(EXIT_FAILURE);
2437: }
2438: }
2439:
2440: (*s_etat_processus).instruction_courante
2441: = arguments;
2442: (*s_etat_processus).definitions_chainees = tampon;
2443: (*s_etat_processus).position_courante = 0;
2444:
2445: recherche_type(s_etat_processus);
2446:
2447: if ((*s_etat_processus).erreur_systeme != d_es)
2448: {
2449: if ((message = messages(s_etat_processus))
2450: == NULL)
2451: {
2452: erreur = d_es_allocation_memoire;
2453:
2454: if ((*s_etat_processus).langue == 'F')
2455: {
2456: printf("+++Système : Mémoire "
2457: "insuffisante\n");
2458: }
2459: else
2460: {
2461: printf("+++System : Not enough "
2462: "memory\n");
2463: }
2464:
2465: return(EXIT_FAILURE);
2466: }
2467:
2468: printf("%s [%d]\n", message, (int) getpid());
2469: free(message);
2470:
2471: return(EXIT_FAILURE);
2472: }
2473:
2474: if ((*s_etat_processus).erreur_execution != d_ex)
2475: {
2476: if ((message = messages(s_etat_processus))
2477: == NULL)
2478: {
2479: erreur = d_es_allocation_memoire;
2480:
2481: if ((*s_etat_processus).langue == 'F')
2482: {
2483: printf("+++Erreur : Mémoire "
2484: "insuffisante\n");
2485: }
2486: else
2487: {
2488: printf("+++Error : Not enough "
2489: "memory\n");
2490: }
2491:
2492: return(EXIT_FAILURE);
2493: }
2494:
2495: printf("%s [%d]\n", message, (int) getpid());
2496: free(message);
2497:
2498: return(EXIT_FAILURE);
2499: }
2500:
2501: if (depilement(s_etat_processus,
2502: &((*s_etat_processus).l_base_pile),
2503: &s_objet) == d_erreur)
2504: {
2505: if ((message = messages(s_etat_processus))
2506: == NULL)
2507: {
2508: erreur = d_es_allocation_memoire;
2509:
2510: if ((*s_etat_processus).langue == 'F')
2511: {
2512: printf("+++Erreur : Mémoire "
2513: "insuffisante\n");
2514: }
2515: else
2516: {
2517: printf("+++Error : Not enough "
2518: "memory\n");
2519: }
2520:
2521: return(EXIT_FAILURE);
2522: }
2523:
2524: printf("%s [%d]\n", message, (int) getpid());
2525: free(message);
2526:
2527: return(EXIT_FAILURE);
2528: }
2529:
2530: if (evaluation(s_etat_processus, s_objet, 'E')
2531: == d_erreur)
2532: {
2533: if ((*s_etat_processus).erreur_systeme != d_es)
2534: {
2535: if ((message = messages(s_etat_processus))
2536: == NULL)
2537: {
2538: erreur = d_es_allocation_memoire;
2539:
2540: if ((*s_etat_processus).langue == 'F')
2541: {
2542: printf("+++Système : Mémoire "
2543: "insuffisante\n");
2544: }
2545: else
2546: {
2547: printf("+++System : Not enough "
2548: "memory\n");
2549: }
2550:
2551: return(EXIT_FAILURE);
2552: }
2553:
2554: printf("%s [%d]\n", message,
2555: (int) getpid());
2556: free(message);
2557:
2558: return(EXIT_FAILURE);
2559: }
2560:
2561: if ((*s_etat_processus).erreur_execution
2562: != d_ex)
2563: {
2564: if ((message = messages(s_etat_processus))
2565: == NULL)
2566: {
2567: erreur = d_es_allocation_memoire;
2568:
2569: if ((*s_etat_processus).langue == 'F')
2570: {
2571: printf("+++Erreur : Mémoire "
2572: "insuffisante\n");
2573: }
2574: else
2575: {
2576: printf("+++Error : Not enough "
2577: "memory\n");
2578: }
2579:
2580: return(EXIT_FAILURE);
2581: }
2582:
2583: printf("%s [%d]\n", message,
2584: (int) getpid());
2585: free(message);
2586:
2587: return(EXIT_FAILURE);
2588: }
2589: }
2590:
2591: (*s_etat_processus).instruction_courante = NULL;
2592: liberation(s_etat_processus, s_objet);
2593:
2594: free(arguments);
2595: }
2596:
1.13 bertrand 2597: if (option_a == d_vrai)
1.1 bertrand 2598: {
1.13 bertrand 2599: fprintf(stdout, "%s\n", (*s_etat_processus)
2600: .definitions_chainees);
1.1 bertrand 2601: }
1.13 bertrand 2602: else
2603: {
2604: if (option_D == d_vrai)
2605: {
2606: lancement_daemon(s_etat_processus);
2607: }
1.1 bertrand 2608:
1.13 bertrand 2609: if (option_p == d_faux)
1.1 bertrand 2610: {
1.13 bertrand 2611: if (setjmp(contexte_initial) == 0)
2612: {
2613: erreur = sequenceur(s_etat_processus);
2614: }
1.1 bertrand 2615: }
1.13 bertrand 2616: else
1.1 bertrand 2617: {
1.13 bertrand 2618: if (setjmp(contexte_initial) == 0)
2619: {
2620: erreur = sequenceur_optimise(s_etat_processus);
2621: }
1.1 bertrand 2622: }
1.19 bertrand 2623:
2624: if (erreur == d_absence_erreur)
2625: {
1.21 ! bertrand 2626: if ((*s_etat_processus).at_exit != NULL)
! 2627: {
! 2628: erreur = evaluation(s_etat_processus,
! 2629: (*s_etat_processus).at_exit, 'E');
! 2630: }
1.19 bertrand 2631: }
2632:
2633: liberation(s_etat_processus,
1.20 bertrand 2634: (*s_etat_processus).at_exit);
1.1 bertrand 2635: }
2636:
2637: if ((*s_etat_processus).generateur_aleatoire != NULL)
2638: {
2639: liberation_generateur_aleatoire(s_etat_processus);
2640: }
2641:
2642: l_element_courant = (*s_etat_processus).liste_mutexes;
2643: while(l_element_courant != NULL)
2644: {
2645: pthread_mutex_trylock(&((*((struct_mutex *)
2646: (*(*((struct_liste_chainee *)
2647: l_element_courant)).donnee).objet)).mutex));
2648: pthread_mutex_unlock(&((*((struct_mutex *)
2649: (*(*((struct_liste_chainee *)
2650: l_element_courant)).donnee).objet)).mutex));
2651: pthread_mutex_destroy(&((*((struct_mutex *)
2652: (*(*((struct_liste_chainee *)
2653: l_element_courant)).donnee).objet)).mutex));
2654:
2655: liberation(s_etat_processus,
2656: (*((struct_liste_chainee *)
2657: l_element_courant)).donnee);
2658: l_element_suivant = (*((struct_liste_chainee *)
2659: l_element_courant)).suivant;
2660: free((struct_liste_chainee *) l_element_courant);
2661: l_element_courant = l_element_suivant;
2662: }
2663:
2664: /*
2665: * Arrêt des processus fils
2666: */
2667:
2668: if ((*s_etat_processus).presence_fusible == d_vrai)
2669: {
2670: pthread_cancel((*s_etat_processus).thread_fusible);
2671: }
2672:
2673: pthread_mutex_lock(&((*s_etat_processus).mutex));
2674:
2675: l_element_courant = (void *) (*s_etat_processus)
2676: .l_base_pile_processus;
2677:
2678: while(l_element_courant != NULL)
2679: {
2680: if ((*s_etat_processus).debug == d_vrai)
2681: {
2682: if (((*s_etat_processus).type_debug &
2683: d_debug_processus) != 0)
2684: {
2685: if ((*(*((struct_processus_fils *)
2686: (*(*((struct_liste_chainee *)
2687: l_element_courant)).donnee)
2688: .objet)).thread)
2689: .processus_detache == d_vrai)
2690: {
2691: if ((*s_etat_processus).langue == 'F')
2692: {
2693: printf("[%d] Signalement pour arrêt du "
2694: "processus %d\n",
2695: (int) getpid(), (int)
2696: (*(*((struct_processus_fils *)
2697: (*(*((struct_liste_chainee *)
2698: l_element_courant)).donnee)
2699: .objet)).thread).pid);
2700: }
2701: else
2702: {
2703: printf("[%d] Send stop signal to "
2704: "process %d\n",
2705: (int) getpid(), (int)
2706: (*(*((struct_processus_fils *)
2707: (*(*((struct_liste_chainee *)
2708: l_element_courant)).donnee)
2709: .objet)).thread).pid);
2710: }
2711: }
2712: else
2713: {
2714: if ((*s_etat_processus).langue == 'F')
2715: {
2716: printf("[%d] Signalement pour arrêt du "
2717: "thread %llu\n", (int) getpid(),
2718: (unsigned long long)
2719: (*(*((struct_processus_fils *)
2720: (*(*((struct_liste_chainee *)
2721: l_element_courant)).donnee)
2722: .objet)).thread).tid);
2723: }
2724: else
2725: {
2726: printf("[%d] Send stop signal to "
2727: "thread %llu\n",
2728: (int) getpid(),
2729: (unsigned long long)
2730: (*(*((struct_processus_fils *)
2731: (*(*((struct_liste_chainee *)
2732: l_element_courant)).donnee)
2733: .objet)).thread).tid);
2734: }
2735: }
2736: }
2737: }
2738:
2739: if ((*(*((struct_processus_fils *)
2740: (*(*((struct_liste_chainee *)
2741: l_element_courant)).donnee).objet))
2742: .thread).processus_detache == d_vrai)
2743: {
2744: if ((*s_etat_processus).var_volatile_alarme != 0)
2745: {
2746: kill((*(*((struct_processus_fils *)
2747: (*(*((struct_liste_chainee *)
2748: l_element_courant)).donnee).objet))
2749: .thread).pid, SIGURG);
2750: }
2751: else
2752: {
2753: kill((*(*((struct_processus_fils *)
2754: (*(*((struct_liste_chainee *)
2755: l_element_courant)).donnee).objet))
2756: .thread).pid, SIGFSTOP);
2757: }
2758: }
2759: else
2760: {
2761: pthread_mutex_lock(&((*(*((struct_processus_fils *)
2762: (*(*((struct_liste_chainee *)
2763: l_element_courant)).donnee).objet)).thread)
2764: .mutex));
2765:
2766: if ((*(*((struct_processus_fils *)
2767: (*(*((struct_liste_chainee *)
2768: l_element_courant)).donnee).objet)).thread)
2769: .thread_actif == d_vrai)
2770: {
2771: if ((*s_etat_processus).var_volatile_alarme
2772: != 0)
2773: {
2774: pthread_kill((*(*((struct_processus_fils *)
2775: (*(*((struct_liste_chainee *)
2776: l_element_courant)).donnee).objet))
2777: .thread).tid, SIGURG);
2778: }
2779: else
2780: {
2781: pthread_kill((*(*((struct_processus_fils *)
2782: (*(*((struct_liste_chainee *)
2783: l_element_courant)).donnee).objet))
2784: .thread).tid, SIGFSTOP);
2785: }
2786: }
2787:
2788: pthread_mutex_unlock(
2789: &((*(*((struct_processus_fils *)
2790: (*(*((struct_liste_chainee *)
2791: l_element_courant)).donnee).objet)).thread)
2792: .mutex));
2793: }
2794:
2795: l_element_courant = (*((struct_liste_chainee *)
2796: l_element_courant)).suivant;
2797: }
2798:
2799: /*
2800: * Attente de la fin de tous les processus fils
2801: */
2802:
2803: for(i = 0; i < d_NOMBRE_INTERRUPTIONS;
2804: (*s_etat_processus).masque_interruptions[i++]
2805: = 'I');
2806:
2807: attente.tv_sec = 0;
2808: attente.tv_nsec = GRANULARITE_us * 1000;
2809:
2810: while((*s_etat_processus).l_base_pile_processus != NULL)
2811: {
2812: status = 0;
2813:
2814: l_element_courant = (void *)
2815: (*s_etat_processus).l_base_pile_processus;
2816:
2817: if ((*s_etat_processus)
2818: .nombre_interruptions_non_affectees != 0)
2819: {
2820: affectation_interruptions_logicielles(
2821: s_etat_processus);
2822: }
2823:
2824: for(i = 0; i < (unsigned long)
2825: (*(*((struct_processus_fils *)
2826: (*(*((struct_liste_chainee *)
2827: l_element_courant)).donnee).objet)).thread)
2828: .nombre_objets_dans_pipe; i++)
2829: {
2830: if ((s_objet = lecture_pipe(
2831: s_etat_processus,
2832: (*(*((struct_processus_fils *)
2833: (*(*((struct_liste_chainee *)
2834: l_element_courant)).donnee).objet)).thread)
2835: .pipe_objets[0])) != NULL)
2836: {
2837: liberation(s_etat_processus, s_objet);
2838:
2839: (*(*((struct_processus_fils *)
2840: (*(*((struct_liste_chainee *)
2841: l_element_courant)).donnee).objet))
2842: .thread).nombre_objets_dans_pipe--;
2843:
2844: action.sa_handler = SIG_IGN;
2845: action.sa_flags = SA_ONSTACK;
2846:
2847: if (sigaction(SIGPIPE, &action, ®istre)
2848: != 0)
2849: {
2850: pthread_mutex_unlock(
2851: &((*s_etat_processus).mutex));
2852: return(EXIT_FAILURE);
2853: }
2854:
2855: while((longueur_ecriture =
2856: write_atomic(s_etat_processus,
2857: (*(*((struct_processus_fils *)
2858: (*(*((struct_liste_chainee *)
2859: l_element_courant)).donnee).objet))
2860: .thread).pipe_nombre_injections[1], "+",
2861: sizeof(unsigned char))) !=
2862: sizeof(unsigned char))
2863: {
2864: if (longueur_ecriture == -1)
2865: {
2866: // Le processus n'existe plus.
2867: break;
2868: }
2869: }
2870:
2871: if (sigaction(SIGPIPE, ®istre, NULL)
2872: != 0)
2873: {
2874: pthread_mutex_unlock(
2875: &((*s_etat_processus).mutex));
2876: return(EXIT_FAILURE);
2877: }
2878: }
2879: }
2880:
2881: pthread_mutex_unlock(&((*s_etat_processus).mutex));
2882: nanosleep(&attente, NULL);
2883: pthread_mutex_lock(&((*s_etat_processus).mutex));
2884: }
2885:
2886: pthread_mutex_unlock(&((*s_etat_processus).mutex));
2887:
2888: erreur_historique = write_history(
2889: (*s_etat_processus).nom_fichier_historique);
2890: clear_history();
2891:
2892: if (erreur_historique != 0)
2893: {
2894: if ((*s_etat_processus).langue == 'F')
2895: {
2896: printf("+++Erreur : L'historique ne peut être "
2897: "écrit\n");
2898: }
2899: else
2900: {
2901: printf("+++Error : History cannot be "
2902: "written\n");
2903: }
2904:
2905: if (test_cfsf(s_etat_processus, 51) == d_faux)
2906: {
2907: printf("%s", ds_beep);
2908: }
2909: }
2910:
2911: free((*s_etat_processus).nom_fichier_historique);
2912:
2913: if (((*s_etat_processus).core == d_vrai) &&
2914: (erreur == d_erreur) &&
2915: ((*s_etat_processus).var_volatile_traitement_sigint
2916: == 0))
2917: {
2918: printf("\n");
2919:
2920: if ((*s_etat_processus).langue == 'F')
2921: {
2922: printf("+++Information : Génération du fichier "
2923: "rpl-core [%d]\n", (int) getpid());
2924: }
2925: else
2926: {
2927: printf("+++Information : Writing rpl-core "
2928: "file [%d]\n", (int) getpid());
2929: }
2930:
2931: rplcore(s_etat_processus);
2932:
2933: if ((*s_etat_processus).langue == 'F')
2934: {
2935: printf("+++Information : Processus tracé [%d]\n",
2936: (int) getpid());
2937: }
2938: else
2939: {
2940: printf("+++Information : Done [%d]\n",
2941: (int) getpid());
2942: }
2943:
2944: printf("\n");
2945: }
2946:
2947: free((*s_etat_processus).definitions_chainees);
2948:
2949: /*
2950: * Libération de l'arbre des instructions
2951: */
2952:
2953: liberation_arbre_instructions(s_etat_processus,
2954: (*s_etat_processus).arbre_instructions);
2955: free((*s_etat_processus).pointeurs_caracteres);
2956:
2957: if ((*s_etat_processus).entree_standard != NULL)
2958: {
2959: pclose((*s_etat_processus).entree_standard);
2960: (*s_etat_processus).entree_standard = NULL;
2961: }
2962:
2963: if ((*s_etat_processus).nom_fichier_impression != NULL)
2964: {
2965: if (test_cfsf(s_etat_processus, 51) == d_faux)
2966: {
2967: printf("%s", ds_beep);
2968: }
2969:
2970: if ((*s_etat_processus).langue == 'F')
2971: {
2972: printf("+++Attention : Queue d'impression "
2973: "non vide !\n");
2974: }
2975: else
2976: {
2977: printf("+++Warning : Non empty printing "
2978: "spool queue !\n");
2979: }
2980:
2981: instruction_erase(s_etat_processus);
2982: }
2983:
2984: if ((*s_etat_processus).fichiers_graphiques != NULL)
2985: {
2986: instruction_cllcd(s_etat_processus);
2987: }
2988:
2989: liberation(s_etat_processus, (*s_etat_processus).indep);
2990: liberation(s_etat_processus, (*s_etat_processus).depend);
2991:
2992: free((*s_etat_processus).label_x);
2993: free((*s_etat_processus).label_y);
2994: free((*s_etat_processus).label_z);
2995: free((*s_etat_processus).titre);
2996: free((*s_etat_processus).legende);
2997:
2998: liberation(s_etat_processus, (*s_etat_processus)
2999: .parametres_courbes_de_niveau);
3000:
3001: for(i = 0; i < d_NOMBRE_INTERRUPTIONS; i++)
3002: {
3003: liberation(s_etat_processus,
3004: (*s_etat_processus).corps_interruptions[i]);
3005:
3006: l_element_courant = (*s_etat_processus)
3007: .pile_origine_interruptions[i];
3008:
3009: while(l_element_courant != NULL)
3010: {
3011: l_element_suivant = (*((struct_liste_chainee *)
3012: l_element_courant)).suivant;
3013:
3014: liberation(s_etat_processus,
3015: (*((struct_liste_chainee *)
3016: l_element_courant)).donnee);
3017: free(l_element_courant);
3018:
3019: l_element_courant = l_element_suivant;
3020: }
3021: }
3022:
3023: if ((*s_etat_processus).instruction_derniere_erreur
3024: != NULL)
3025: {
3026: free((*s_etat_processus).instruction_derniere_erreur);
3027: (*s_etat_processus).instruction_derniere_erreur = NULL;
3028: }
3029:
3030: /*
3031: * Le pointeur s_etat_processus.nom_fichier_source est
3032: * alloué par le système. Il ne faut donc pas
3033: * le libérer...
3034: */
3035:
3036: for(i = 0; i < (*s_etat_processus).nombre_variables; i++)
3037: {
3038: liberation(s_etat_processus,
3039: (*s_etat_processus).s_liste_variables[i].objet);
3040: free((*s_etat_processus).s_liste_variables[i].nom);
3041: }
3042:
3043: free((*s_etat_processus).s_liste_variables);
3044:
3045: for(i = 0; i < (*s_etat_processus)
3046: .nombre_variables_statiques; i++)
3047: {
3048: liberation(s_etat_processus, (*s_etat_processus)
3049: .s_liste_variables_statiques[i].objet);
3050: free((*s_etat_processus)
3051: .s_liste_variables_statiques[i].nom);
3052: }
3053:
3054: free((*s_etat_processus).s_liste_variables_statiques);
3055:
3056: for(i = 0; i < (*((*s_etat_processus)
3057: .s_liste_variables_partagees)).nombre_variables;
3058: i++)
3059: {
3060: liberation(s_etat_processus, (*((*s_etat_processus)
3061: .s_liste_variables_partagees)).table[i].objet);
3062: free((*((*s_etat_processus)
3063: .s_liste_variables_partagees)).table[i].nom);
3064: }
3065:
3066: free((struct_variable_partagee *)
3067: (*((*s_etat_processus).s_liste_variables_partagees))
3068: .table);
3069:
3070: /*
3071: * Si resultats est non nul, rplinit a été appelé
3072: * depuis rpl() [librpl] et non main().
3073: * On copie alors le contenu de la * pile dans un
3074: * tableau **resultats dont le pointeur de base a
3075: * été alloué dans rpl().
3076: */
3077:
3078: if (resultats != NULL)
3079: {
3080: if ((*resultats) != NULL)
3081: {
3082: free((*resultats));
3083:
3084: if (((*resultats) = malloc(((*s_etat_processus)
3085: .hauteur_pile_operationnelle + 1)
3086: * sizeof(unsigned char **))) != NULL)
3087: {
3088: (*resultats)[(*s_etat_processus)
3089: .hauteur_pile_operationnelle] = NULL;
3090: l_element_courant = (void *) (*s_etat_processus)
3091: .l_base_pile;
3092:
3093: for(i = 0; i < (*s_etat_processus)
3094: .hauteur_pile_operationnelle; i++)
3095: {
3096: if (l_element_courant != NULL)
3097: {
3098: (*resultats)[i] =
3099: formateur(s_etat_processus,
3100: 0, (*((struct_liste_chainee *)
3101: l_element_courant)).donnee);
3102:
3103: if ((*resultats)[i] == NULL)
3104: {
3105: i = (*s_etat_processus).
3106: hauteur_pile_operationnelle;
3107: }
3108: else
3109: {
3110: l_element_suivant =
3111: (*((struct_liste_chainee *)
3112: l_element_courant)).suivant;
3113: }
3114: }
3115: }
3116: }
3117: else
3118: {
3119: (*resultats) = NULL;
3120: erreur = d_es_allocation_memoire;
3121: }
3122: }
3123: }
3124:
3125: l_element_courant = (void *) (*s_etat_processus)
3126: .l_base_pile;
3127: while(l_element_courant != NULL)
3128: {
3129: l_element_suivant = (*((struct_liste_chainee *)
3130: l_element_courant)).suivant;
3131:
3132: liberation(s_etat_processus,
3133: (*((struct_liste_chainee *)
3134: l_element_courant)).donnee);
3135: free((struct_liste_chainee *) l_element_courant);
3136:
3137: l_element_courant = l_element_suivant;
3138: }
3139:
3140: l_element_courant = (void *) (*s_etat_processus)
3141: .l_base_pile_contextes;
3142: while(l_element_courant != NULL)
3143: {
3144: l_element_suivant = (*((struct_liste_chainee *)
3145: l_element_courant)).suivant;
3146:
3147: liberation(s_etat_processus,
3148: (*((struct_liste_chainee *)
3149: l_element_courant)).donnee);
3150: free((struct_liste_chainee *) l_element_courant);
3151:
3152: l_element_courant = l_element_suivant;
3153: }
3154:
3155: l_element_courant = (void *) (*s_etat_processus)
3156: .l_base_pile_taille_contextes;
3157: while(l_element_courant != NULL)
3158: {
3159: l_element_suivant = (*((struct_liste_chainee *)
3160: l_element_courant)).suivant;
3161:
3162: liberation(s_etat_processus,
3163: (*((struct_liste_chainee *)
3164: l_element_courant)).donnee);
3165: free((struct_liste_chainee *) l_element_courant);
3166:
3167: l_element_courant = l_element_suivant;
3168: }
3169:
3170: for(i = 0; i < (*s_etat_processus)
3171: .nombre_instructions_externes; i++)
3172: {
3173: free((*s_etat_processus).s_instructions_externes[i]
3174: .nom);
3175: free((*s_etat_processus).s_instructions_externes[i]
3176: .nom_bibliotheque);
3177: }
3178:
3179: if ((*s_etat_processus).nombre_instructions_externes != 0)
3180: {
3181: free((*s_etat_processus).s_instructions_externes);
3182: }
3183:
3184: l_element_courant = (void *) (*s_etat_processus)
3185: .s_bibliotheques;
3186:
3187: while(l_element_courant != NULL)
3188: {
3189: l_element_suivant = (*((struct_liste_chainee *)
3190: l_element_courant)).suivant;
3191:
3192: free((*((struct_bibliotheque *)
3193: (*((struct_liste_chainee *)
3194: l_element_courant)).donnee)).nom);
3195: dlclose((*((struct_bibliotheque *)
3196: (*((struct_liste_chainee *)
3197: l_element_courant)).donnee)).descripteur);
3198: free((*((struct_liste_chainee *) l_element_courant))
3199: .donnee);
3200: free(l_element_courant);
3201:
3202: l_element_courant = l_element_suivant;
3203: }
3204:
3205: l_element_courant = (void *) (*s_etat_processus)
3206: .l_base_pile_last;
3207: while(l_element_courant != NULL)
3208: {
3209: l_element_suivant = (*((struct_liste_chainee *)
3210: l_element_courant)).suivant;
3211:
3212: liberation(s_etat_processus,
3213: (*((struct_liste_chainee *)
3214: l_element_courant)).donnee);
3215: free((struct_liste_chainee *) l_element_courant);
3216:
3217: l_element_courant = l_element_suivant;
3218: }
3219:
3220: l_element_courant = (void *) (*s_etat_processus)
3221: .l_base_pile_systeme;
3222: while(l_element_courant != NULL)
3223: {
3224: l_element_suivant = (*((struct_liste_pile_systeme *)
3225: l_element_courant)).suivant;
3226:
3227: liberation(s_etat_processus,
3228: (*((struct_liste_pile_systeme *)
3229: l_element_courant)).indice_boucle);
3230: liberation(s_etat_processus,
3231: (*((struct_liste_pile_systeme *)
3232: l_element_courant)).limite_indice_boucle);
3233: liberation(s_etat_processus,
3234: (*((struct_liste_pile_systeme *)
3235: l_element_courant)).objet_de_test);
3236:
3237: if ((*((struct_liste_pile_systeme *)
3238: l_element_courant)).nom_variable != NULL)
3239: {
3240: free((*((struct_liste_pile_systeme *)
3241: l_element_courant)).nom_variable);
3242: }
3243:
3244: free((struct_liste_pile_systeme *)
3245: l_element_courant);
3246:
3247: l_element_courant = l_element_suivant;
3248: }
3249:
3250: l_element_courant = (void *)
3251: (*s_etat_processus).s_fichiers;
3252: while(l_element_courant != NULL)
3253: {
3254: l_element_suivant = (*((struct_liste_chainee *)
3255: l_element_courant)).suivant;
3256:
3257: fclose((*((struct_descripteur_fichier *)
3258: (*((struct_liste_chainee *)
3259: l_element_courant)).donnee))
1.12 bertrand 3260: .descripteur_c);
3261:
3262: if ((*((struct_descripteur_fichier *)
3263: (*((struct_liste_chainee *)
3264: l_element_courant)).donnee)).type != 'C')
3265: {
3266: sqlite3_close((*((struct_descripteur_fichier *)
3267: (*((struct_liste_chainee *)
3268: l_element_courant)).donnee))
3269: .descripteur_sqlite);
3270: }
1.1 bertrand 3271:
3272: if ((*((struct_descripteur_fichier *)
3273: (*((struct_liste_chainee *)
3274: l_element_courant)).donnee))
3275: .effacement == 'Y')
3276: {
3277: unlink((*((struct_descripteur_fichier *)
3278: (*((struct_liste_chainee *)
3279: l_element_courant)).donnee))
3280: .nom);
3281: }
3282:
3283: free((*((struct_descripteur_fichier *)
3284: (*((struct_liste_chainee *)
3285: l_element_courant)).donnee)).nom);
3286: free((struct_descripteur_fichier *)
3287: (*((struct_liste_chainee *)
3288: l_element_courant)).donnee);
3289: free(l_element_courant);
3290:
3291: l_element_courant = l_element_suivant;
3292: }
3293:
3294: l_element_courant = (void *)
3295: (*s_etat_processus).s_sockets;
3296: while(l_element_courant != NULL)
3297: {
3298: l_element_suivant = (*((struct_liste_chainee *)
3299: l_element_courant)).suivant;
3300:
3301: if ((*((struct_socket *)
3302: (*(*((struct_liste_chainee *)
3303: l_element_courant)).donnee).objet))
3304: .socket_connectee == d_vrai)
3305: {
3306: shutdown((*((struct_socket *)
3307: (*(*((struct_liste_chainee *)
3308: l_element_courant)).donnee).objet))
3309: .socket, SHUT_RDWR);
3310: }
3311:
3312: close((*((struct_socket *)
3313: (*(*((struct_liste_chainee *)
3314: l_element_courant)).donnee).objet)).socket);
3315:
3316: if ((*((struct_socket *) (*(*((struct_liste_chainee *)
3317: l_element_courant)).donnee).objet)).effacement
3318: == 'Y')
3319: {
3320: unlink((*((struct_socket *)
3321: (*(*((struct_liste_chainee *)
3322: l_element_courant)).donnee).objet))
3323: .adresse);
3324: }
3325:
3326: liberation(s_etat_processus,
3327: (*((struct_liste_chainee *)
3328: l_element_courant)).donnee);
3329: free(l_element_courant);
3330:
3331: l_element_courant = l_element_suivant;
3332: }
3333:
3334: l_element_courant = (void *)
3335: (*s_etat_processus).s_connecteurs_sql;
3336: while(l_element_courant != NULL)
3337: {
3338: l_element_suivant = (*((struct_liste_chainee *)
3339: l_element_courant)).suivant;
3340:
3341: sqlclose((*((struct_liste_chainee *)
3342: l_element_courant)).donnee);
3343: liberation(s_etat_processus,
3344: (*((struct_liste_chainee *)
3345: l_element_courant)).donnee);
3346: free(l_element_courant);
3347:
3348: l_element_courant = l_element_suivant;
3349: }
3350:
3351: free((*s_etat_processus).chemin_fichiers_temporaires);
3352:
3353: l_element_courant = (*s_etat_processus).s_marques;
3354: while(l_element_courant != NULL)
3355: {
3356: free((*((struct_marque *) l_element_courant)).label);
3357: free((*((struct_marque *) l_element_courant)).position);
3358: l_element_suivant = (*((struct_marque *)
3359: l_element_courant)).suivant;
3360: free(l_element_courant);
3361: l_element_courant = l_element_suivant;
3362: }
3363: }
3364: else
3365: {
3366: erreur = d_es_allocation_memoire;
3367:
3368: if (test_cfsf(s_etat_processus, 51) == d_faux)
3369: {
3370: printf("%s", ds_beep);
3371: }
3372:
3373: if ((*s_etat_processus).langue == 'F')
3374: {
3375: printf("+++Système : Mémoire insuffisante\n");
3376: }
3377: else
3378: {
3379: printf("+++System : Not enough memory\n");
3380: }
3381: }
3382: }
3383:
3384: liberation_allocateur(s_etat_processus);
3385: }
3386:
3387: if (traitement_fichier_temporaire == 'Y')
3388: {
3389: if (destruction_fichier(nom_fichier_temporaire) == d_erreur)
3390: {
3391: return(EXIT_FAILURE);
3392: }
3393:
3394: free(nom_fichier_temporaire);
3395: }
3396:
3397: if ((*s_etat_processus).profilage == d_vrai)
3398: {
3399: ecriture_profil(s_etat_processus);
3400: liberation_profil(s_etat_processus);
3401: }
3402: }
3403:
1.9 bertrand 3404: # ifndef Cygwin
1.1 bertrand 3405: free((*s_etat_processus).pile_signal.ss_sp);
1.9 bertrand 3406: # endif
3407:
1.1 bertrand 3408: closelog();
3409:
3410: pthread_mutex_destroy(&((*s_etat_processus).protection_liste_mutexes));
3411: pthread_mutex_destroy(&((*((*s_etat_processus).s_liste_variables_partagees))
3412: .mutex));
3413:
3414: retrait_thread(s_etat_processus);
3415:
3416: pthread_mutex_destroy(&((*s_etat_processus).mutex));
1.17 bertrand 3417: # ifndef SEMAPHORES_NOMMES
1.1 bertrand 3418: sem_post(&((*s_etat_processus).semaphore_fork));
3419: sem_destroy(&((*s_etat_processus).semaphore_fork));
1.17 bertrand 3420: # else
3421: sem_post((*s_etat_processus).semaphore_fork);
3422: sem_destroy2((*s_etat_processus).semaphore_fork, sem_fork);
3423: # endif
1.1 bertrand 3424:
3425: free((*s_etat_processus).localisation);
3426: free(s_etat_processus);
3427:
1.17 bertrand 3428: # ifndef SEMAPHORES_NOMMES
1.1 bertrand 3429: sem_destroy(&semaphore_liste_threads);
1.17 bertrand 3430: # else
3431: sem_destroy2(semaphore_liste_threads, sem_liste_threads);
3432: # endif
3433: # ifndef SEMAPHORES_NOMMES
1.1 bertrand 3434: sem_post(&semaphore_gestionnaires_signaux);
3435: sem_destroy(&semaphore_gestionnaires_signaux);
3436: sem_destroy(&semaphore_gestionnaires_signaux_atomique);
1.17 bertrand 3437: # else
3438: sem_post(semaphore_gestionnaires_signaux);
3439: sem_destroy2(semaphore_gestionnaires_signaux, sem_gestionnaires_signaux);
3440: sem_destroy2(semaphore_gestionnaires_signaux_atomique,
3441: sem_gestionnaires_signaux_atomique);
3442: # endif
1.1 bertrand 3443:
1.8 bertrand 3444: # ifdef DEBUG_MEMOIRE
3445: debug_memoire_verification(s_etat_processus);
3446: # endif
3447:
1.13 bertrand 3448: return((erreur == d_absence_erreur) ? EXIT_SUCCESS : EXIT_FAILURE);
1.1 bertrand 3449: }
3450:
3451:
3452: void
3453: informations(struct_processus *s_etat_processus)
3454: {
3455: printf("\n");
3456:
3457: if ((*s_etat_processus).langue == 'F')
3458: {
3459: printf(" rpl [-options] [programme]\n");
1.13 bertrand 3460: printf(" -a : analyse du code\n");
1.1 bertrand 3461: printf(" -A : paramètres passés au programme principal\n");
3462: printf(" -c : génération de fichier de débogage (rpl-core)\n");
3463: printf(" -d : option de déverminage interne\n");
3464: printf(" -D : lancement d'un daemon\n");
3465: printf(" -h : aide sur la ligne de commande\n");
3466: printf(" -i : fonctionnement interactif\n");
3467: printf(" -l : licence d'utilisation\n");
3468: printf(" -n : ignorance du signal HUP\n");
3469: printf(" -p : précompilation du script avant exécution\n");
3470: printf(" -P : profilage\n");
3471: printf(" -s : empêchement de l'ouverture de l'écran initial\n");
3472: printf(" -S : exécution du script passé en ligne de commande\n");
3473: printf(" -t : trace\n");
3474: printf(" -v : version\n");
3475: }
3476: else
3477: {
3478: printf(" rpl [-options] [program]\n");
1.13 bertrand 3479: printf(" -a : analyzes program\n");
1.1 bertrand 3480: printf(" -A : sends parameters to main program\n");
3481: printf(" -c : allows creation of a rpl-core file, providing a way"
3482: "\n"
3483: " to debug a program\n");
3484: printf(" -d : internal debug process\n");
3485: printf(" -D : starts in daemon mode\n");
3486: printf(" -h : shows a summary of available options\n");
3487: printf(" -i : runs the RPL/2 sequencer in interactive mode\n");
3488: printf(" -l : prints the user licence of the software\n");
3489: printf(" -n : ignores HUP signal\n");
3490: printf(" -p : precompiles script\n");
3491: printf(" -P : computes profile data\n");
3492: printf(" -s : disables splash screen\n");
3493: printf(" -S : executes script written in command line\n");
3494: printf(" -t : enables tracing mode\n");
3495: printf(" -v : prints the version number\n");
3496: }
3497:
3498: printf("\n");
3499:
3500: return;
3501: }
3502:
3503: // vim: ts=4
CVSweb interface <joel.bertrand@systella.fr>