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