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