version 1.2, 2010/01/27 22:22:17
|
version 1.41, 2010/08/18 12:56:55
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.0.10 |
RPL/2 (R) version 4.0.18 |
Copyright (C) 1989-2010 Dr. BERTRAND Joël |
Copyright (C) 1989-2010 Dr. BERTRAND Joël |
|
|
This file is part of RPL/2. |
This file is part of RPL/2. |
Line 21
|
Line 21
|
|
|
|
|
#define MAIN_RPL |
#define MAIN_RPL |
#include "rpl.conv.h" |
#include "rpl-conv.h" |
|
|
|
#ifdef SEMAPHORES_SYSV |
|
#ifndef OS2 |
|
unsigned char *chemin_semaphores_SysV; |
|
#endif |
|
#endif |
|
|
|
|
/* |
/* |
Line 31
|
Line 37
|
*/ |
*/ |
|
|
int |
int |
rplinit(int argc, char *argv[], unsigned char ***resultats) |
rplinit(int argc, char *argv[], unsigned char ***resultats, char *rpl_home) |
{ |
{ |
# include "copyright.conv.h" |
# include "copyright-conv.h" |
# include "licence.conv.h" |
# include "licence-conv.h" |
|
|
file *f_source; |
file *f_source; |
|
|
Line 99 rplinit(int argc, char *argv[], unsigned
|
Line 105 rplinit(int argc, char *argv[], unsigned
|
volatile int erreur; |
volatile int erreur; |
volatile unsigned char traitement_fichier_temporaire; |
volatile unsigned char traitement_fichier_temporaire; |
|
|
|
errno = 0; |
|
|
|
# ifdef DEBUG_MEMOIRE |
|
debug_memoire_initialisation(); |
|
# endif |
|
|
setvbuf(stdout, NULL, _IOLBF, 0); |
setvbuf(stdout, NULL, _IOLBF, 0); |
setvbuf(stderr, NULL, _IOLBF, 0); |
setvbuf(stderr, NULL, _IOLBF, 0); |
|
|
|
# ifndef SEMAPHORES_NOMMES |
sem_init(&semaphore_liste_threads, 0, 1); |
sem_init(&semaphore_liste_threads, 0, 1); |
sem_init(&semaphore_gestionnaires_signaux, 0, 0); |
sem_init(&semaphore_gestionnaires_signaux, 0, 0); |
sem_init(&semaphore_gestionnaires_signaux_atomique, 0, 1); |
sem_init(&semaphore_gestionnaires_signaux_atomique, 0, 1); |
|
# else |
|
semaphore_liste_threads = sem_init2(1, sem_liste_threads); |
|
semaphore_gestionnaires_signaux = sem_init2(0, sem_gestionnaires_signaux); |
|
semaphore_gestionnaires_signaux_atomique = sem_init2(1, |
|
sem_gestionnaires_signaux_atomique); |
|
|
|
if ((semaphore_liste_threads == SEM_FAILED) || |
|
(semaphore_gestionnaires_signaux == SEM_FAILED) || |
|
(semaphore_gestionnaires_signaux_atomique == SEM_FAILED)) |
|
{ |
|
erreur = d_es_allocation_memoire; |
|
|
|
if ((langue = getenv("LANG")) != NULL) |
|
{ |
|
if (strncmp(langue, "fr", 2) == 0) |
|
{ |
|
uprintf("+++Système : Mémoire insuffisante\n"); |
|
} |
|
else |
|
{ |
|
uprintf("+++System : Not enough memory\n"); |
|
} |
|
} |
|
else |
|
{ |
|
uprintf("+++System : Not enough memory\n"); |
|
} |
|
|
|
return(EXIT_FAILURE); |
|
} |
|
# endif |
|
|
if ((s_etat_processus = malloc(sizeof(struct_processus))) == NULL) |
if ((s_etat_processus = malloc(sizeof(struct_processus))) == NULL) |
{ |
{ |
erreur = d_es_allocation_memoire; |
erreur = d_es_allocation_memoire; |
|
|
if ((*s_etat_processus).langue == 'F') |
if ((langue = getenv("LANG")) != NULL) |
{ |
{ |
printf("+++Système : Mémoire insuffisante\n"); |
if (strncmp(langue, "fr", 2) == 0) |
|
{ |
|
uprintf("+++Système : Mémoire insuffisante\n"); |
|
} |
|
else |
|
{ |
|
uprintf("+++System : Not enough memory\n"); |
|
} |
} |
} |
else |
else |
{ |
{ |
printf("+++System : Not enough memory\n"); |
uprintf("+++System : Not enough memory\n"); |
} |
} |
|
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
|
if ((langue = getenv("LANG")) != NULL) |
|
{ |
|
(*s_etat_processus).langue = (strncmp(langue, "fr", 2) == 0) |
|
? 'F' : 'E'; |
|
} |
|
else |
|
{ |
|
(*s_etat_processus).langue = 'E'; |
|
} |
|
|
(*s_etat_processus).exception = d_ep; |
(*s_etat_processus).exception = d_ep; |
(*s_etat_processus).erreur_systeme = d_es; |
(*s_etat_processus).erreur_systeme = d_es; |
(*s_etat_processus).erreur_execution = d_ex; |
(*s_etat_processus).erreur_execution = d_ex; |
|
|
|
(*s_etat_processus).rpl_home = rpl_home; |
|
|
insertion_thread(s_etat_processus, d_vrai); |
insertion_thread(s_etat_processus, d_vrai); |
|
|
pthread_mutexattr_init(&attributs_mutex); |
pthread_mutexattr_init(&attributs_mutex); |
Line 133 rplinit(int argc, char *argv[], unsigned
|
Line 196 rplinit(int argc, char *argv[], unsigned
|
pthread_mutex_init(&((*s_etat_processus).mutex), &attributs_mutex); |
pthread_mutex_init(&((*s_etat_processus).mutex), &attributs_mutex); |
pthread_mutexattr_destroy(&attributs_mutex); |
pthread_mutexattr_destroy(&attributs_mutex); |
|
|
|
pthread_mutexattr_init(&attributs_mutex); |
|
pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL); |
|
pthread_mutex_init(&((*s_etat_processus).mutex_allocation), |
|
&attributs_mutex); |
|
pthread_mutexattr_destroy(&attributs_mutex); |
|
|
|
# ifndef SEMAPHORES_NOMMES |
sem_init(&((*s_etat_processus).semaphore_fork), 0, 0); |
sem_init(&((*s_etat_processus).semaphore_fork), 0, 0); |
|
# else |
|
if (((*s_etat_processus).semaphore_fork = sem_init2(0, sem_fork)) == |
|
SEM_FAILED) |
|
{ |
|
if ((*s_etat_processus).langue == 'F') |
|
{ |
|
uprintf("+++Système : Mémoire insuffisante\n"); |
|
} |
|
else |
|
{ |
|
uprintf("+++System : Not enough memory\n"); |
|
} |
|
|
|
return(EXIT_FAILURE); |
|
} |
|
# endif |
|
|
pthread_mutexattr_init(&attributs_mutex); |
pthread_mutexattr_init(&attributs_mutex); |
pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL); |
pthread_mutexattr_settype(&attributs_mutex, PTHREAD_MUTEX_NORMAL); |
Line 153 rplinit(int argc, char *argv[], unsigned
|
Line 239 rplinit(int argc, char *argv[], unsigned
|
.mutex), &attributs_mutex); |
.mutex), &attributs_mutex); |
pthread_mutexattr_destroy(&attributs_mutex); |
pthread_mutexattr_destroy(&attributs_mutex); |
|
|
if ((langue = getenv("LANG")) != NULL) |
(*s_etat_processus).chemin_fichiers_temporaires = |
{ |
recherche_chemin_fichiers_temporaires(s_etat_processus); |
(*s_etat_processus).langue = (strncmp(langue, "fr", 2) == 0) |
|
? 'F' : 'E'; |
# ifdef SEMAPHORES_SYSV |
} |
# ifndef OS2 |
else |
chemin_semaphores_SysV = (*s_etat_processus).chemin_fichiers_temporaires; |
{ |
# endif |
(*s_etat_processus).langue = 'E'; |
# endif |
} |
|
|
# ifdef _BROKEN_SIGINFO |
|
creation_fifos_signaux(s_etat_processus); |
|
|
|
# ifdef return |
|
# undef return |
|
# endif |
|
# define return destruction_fifos_signaux(s_etat_processus); return |
|
# endif |
|
|
localisation_courante(s_etat_processus); |
localisation_courante(s_etat_processus); |
|
(*s_etat_processus).erreur_systeme = d_es; |
|
|
if ((*s_etat_processus).erreur_systeme != d_es) |
if ((*s_etat_processus).localisation == NULL) |
{ |
{ |
if ((*s_etat_processus).langue == 'F') |
if (((*s_etat_processus).localisation = malloc((strlen(d_locale) + 1) * |
|
sizeof(unsigned char))) == NULL) |
{ |
{ |
uprintf("+++Système : Mémoire insuffisante\n"); |
if ((*s_etat_processus).langue == 'F') |
} |
{ |
else |
uprintf("+++Système : Mémoire insuffisante\n"); |
{ |
} |
uprintf("+++System : Not enough memory\n"); |
else |
|
{ |
|
uprintf("+++System : Not enough memory\n"); |
|
} |
|
|
|
return(EXIT_FAILURE); |
} |
} |
|
|
return(EXIT_FAILURE); |
strcpy((*s_etat_processus).localisation, d_locale); |
} |
} |
|
|
printf("+++RPL/2 (R) version %s (%s)\n", d_version_rpl, |
printf("+++RPL/2 (R) version %s (%s)\n", d_version_rpl, |
Line 229 rplinit(int argc, char *argv[], unsigned
|
Line 330 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
|
# ifndef SEMAPHORES_NOMMES |
if (pthread_setspecific(semaphore_fork_processus_courant, |
if (pthread_setspecific(semaphore_fork_processus_courant, |
&((*s_etat_processus).semaphore_fork)) != 0) |
&((*s_etat_processus).semaphore_fork)) != 0) |
|
# else |
|
if (pthread_setspecific(semaphore_fork_processus_courant, |
|
(*s_etat_processus).semaphore_fork) != 0) |
|
# endif |
{ |
{ |
if ((*s_etat_processus).langue == 'F') |
if ((*s_etat_processus).langue == 'F') |
{ |
{ |
Line 247 rplinit(int argc, char *argv[], unsigned
|
Line 353 rplinit(int argc, char *argv[], unsigned
|
// Initialisation d'une pile de signal pour récupérer les |
// Initialisation d'une pile de signal pour récupérer les |
// débordement de pile |
// débordement de pile |
|
|
|
# if !defined(Cygwin) && !defined(OpenBSD) |
if (((*s_etat_processus).pile_signal.ss_sp = |
if (((*s_etat_processus).pile_signal.ss_sp = |
malloc((*s_etat_processus).pile_signal.ss_size = |
malloc((*s_etat_processus).pile_signal.ss_size = |
SIGSTKSZ)) == NULL) |
SIGSTKSZ)) == NULL) |
Line 283 rplinit(int argc, char *argv[], unsigned
|
Line 390 rplinit(int argc, char *argv[], unsigned
|
|
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
# endif |
|
|
|
# ifndef _BROKEN_SIGINFO |
action.sa_sigaction = interruption1; |
action.sa_sigaction = interruption1; |
|
# else |
|
action.sa_handler = interruption1; |
|
# endif |
action.sa_flags = SA_ONSTACK | SA_SIGINFO; |
action.sa_flags = SA_ONSTACK | SA_SIGINFO; |
|
|
if (sigaction(SIGINT, &action, NULL) != 0) |
if (sigaction(SIGINT, &action, NULL) != 0) |
Line 304 rplinit(int argc, char *argv[], unsigned
|
Line 416 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
|
# ifndef _BROKEN_SIGINFO |
action.sa_sigaction = interruption2; |
action.sa_sigaction = interruption2; |
|
# else |
|
action.sa_handler = interruption2; |
|
# endif |
action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; |
action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; |
|
|
if (sigaction(SIGTSTP, &action, NULL) != 0) |
if (sigaction(SIGTSTP, &action, NULL) != 0) |
Line 322 rplinit(int argc, char *argv[], unsigned
|
Line 438 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
|
# ifndef _BROKEN_SIGINFO |
action.sa_sigaction = interruption4; |
action.sa_sigaction = interruption4; |
|
# else |
|
action.sa_handler = interruption4; |
|
# endif |
action.sa_flags = SA_ONSTACK | SA_SIGINFO; |
action.sa_flags = SA_ONSTACK | SA_SIGINFO; |
|
|
if (sigaction(SIGSTART, &action, NULL) != 0) |
if (sigaction(SIGSTART, &action, NULL) != 0) |
Line 355 rplinit(int argc, char *argv[], unsigned
|
Line 475 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
|
# ifndef _BROKEN_SIGINFO |
action.sa_sigaction = interruption5; |
action.sa_sigaction = interruption5; |
|
# else |
|
action.sa_handler = interruption5; |
|
# endif |
action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; |
action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; |
|
|
if (sigaction(SIGFSTOP, &action, NULL) != 0) |
if (sigaction(SIGFSTOP, &action, NULL) != 0) |
Line 375 rplinit(int argc, char *argv[], unsigned
|
Line 499 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
|
# ifndef _BROKEN_SIGINFO |
|
action.sa_sigaction = interruption11; |
|
# else |
|
action.sa_handler = interruption11; |
|
# endif |
|
action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; |
|
|
|
if (sigaction(SIGFABORT, &action, NULL) != 0) |
|
{ |
|
erreur = d_es_signal; |
|
|
|
if ((*s_etat_processus).langue == 'F') |
|
{ |
|
printf("+++Système : Initialisation des signaux POSIX " |
|
"impossible\n"); |
|
} |
|
else |
|
{ |
|
printf("+++System : Initialization of POSIX signals failed\n"); |
|
} |
|
|
|
return(EXIT_FAILURE); |
|
} |
|
|
|
# ifndef _BROKEN_SIGINFO |
action.sa_sigaction = interruption8; |
action.sa_sigaction = interruption8; |
|
# else |
|
action.sa_handler = interruption8; |
|
# endif |
action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; |
action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; |
|
|
if (sigaction(SIGURG, &action, NULL) != 0) |
if (sigaction(SIGURG, &action, NULL) != 0) |
Line 395 rplinit(int argc, char *argv[], unsigned
|
Line 547 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
|
# ifndef _BROKEN_SIGINFO |
action.sa_sigaction = interruption7; |
action.sa_sigaction = interruption7; |
|
# else |
|
action.sa_handler = interruption7; |
|
# endif |
action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; |
action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; |
|
|
if (sigaction(SIGPIPE, &action, NULL) != 0) |
if (sigaction(SIGPIPE, &action, NULL) != 0) |
Line 415 rplinit(int argc, char *argv[], unsigned
|
Line 571 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
|
# ifndef _BROKEN_SIGINFO |
action.sa_sigaction = interruption6; |
action.sa_sigaction = interruption6; |
|
# else |
|
action.sa_handler = interruption6; |
|
# endif |
action.sa_flags = SA_ONSTACK | SA_SIGINFO; |
action.sa_flags = SA_ONSTACK | SA_SIGINFO; |
|
|
if (sigaction(SIGINJECT, &action, NULL) != 0) |
if (sigaction(SIGINJECT, &action, NULL) != 0) |
Line 435 rplinit(int argc, char *argv[], unsigned
|
Line 595 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
|
# ifndef _BROKEN_SIGINFO |
action.sa_sigaction = interruption9; |
action.sa_sigaction = interruption9; |
|
# else |
|
action.sa_handler = interruption9; |
|
# endif |
action.sa_flags = SA_ONSTACK | SA_SIGINFO; |
action.sa_flags = SA_ONSTACK | SA_SIGINFO; |
|
|
if (sigaction(SIGABORT, &action, NULL) != 0) |
if (sigaction(SIGABORT, &action, NULL) != 0) |
Line 455 rplinit(int argc, char *argv[], unsigned
|
Line 619 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
|
# ifndef _BROKEN_SIGINFO |
action.sa_sigaction = interruption1; |
action.sa_sigaction = interruption1; |
|
# else |
|
action.sa_handler = interruption1; |
|
# endif |
action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; |
action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; |
|
|
if (sigaction(SIGALRM, &action, NULL) != 0) |
if (sigaction(SIGALRM, &action, NULL) != 0) |
Line 475 rplinit(int argc, char *argv[], unsigned
|
Line 643 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
|
# ifndef _BROKEN_SIGINFO |
action.sa_sigaction = interruption3; |
action.sa_sigaction = interruption3; |
|
# else |
|
action.sa_handler = interruption3; |
|
# endif |
action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; |
action.sa_flags = SA_NODEFER | SA_ONSTACK | SA_SIGINFO; |
|
|
(*s_etat_processus).chemin_fichiers_temporaires = |
erreur = d_absence_erreur; |
recherche_chemin_fichiers_temporaires(s_etat_processus); |
|
|
|
erreur = d_os; |
|
core = d_faux; |
core = d_faux; |
mode_interactif = d_faux; |
mode_interactif = d_faux; |
(*s_etat_processus).nom_fichier_source = NULL; |
(*s_etat_processus).nom_fichier_source = NULL; |
Line 502 rplinit(int argc, char *argv[], unsigned
|
Line 671 rplinit(int argc, char *argv[], unsigned
|
|
|
if (argc == 1) |
if (argc == 1) |
{ |
{ |
erreur = d_os_ligne_de_commande; |
erreur = d_erreur; |
informations(s_etat_processus); |
informations(s_etat_processus); |
} |
} |
else |
else |
Line 554 rplinit(int argc, char *argv[], unsigned
|
Line 723 rplinit(int argc, char *argv[], unsigned
|
} |
} |
|
|
option_a = d_vrai; |
option_a = d_vrai; |
printf("\n"); |
|
|
|
if ((*s_etat_processus).langue == 'F') |
|
{ |
|
printf(" Auteur: Joël BERTRAND,\n"); |
|
printf(" Email : " |
|
"joel.bertrand@systella.fr\n"); |
|
printf(" Liste de diffusion : " |
|
"rpl2@systella.fr\n"); |
|
printf(" Page : " |
|
"http://www.rpl2.fr"); |
|
printf("\n"); |
|
} |
|
else |
|
{ |
|
printf(" Author: Joël BERTRAND,\n"); |
|
printf(" Email : " |
|
"joel.bertrand@systella.fr\n"); |
|
printf(" Mailing list : " |
|
"rpl2@systella.fr\n"); |
|
printf(" Web page : " |
|
"http://www.rpl2/net"); |
|
printf("\n"); |
|
} |
|
|
|
break; |
break; |
} |
} |
|
|
Line 1293 rplinit(int argc, char *argv[], unsigned
|
Line 1437 rplinit(int argc, char *argv[], unsigned
|
return(EXIT_FAILURE); |
return(EXIT_FAILURE); |
} |
} |
|
|
|
free(type_debug); |
break; |
break; |
} |
} |
|
|
Line 1350 rplinit(int argc, char *argv[], unsigned
|
Line 1495 rplinit(int argc, char *argv[], unsigned
|
{ |
{ |
if ((*s_etat_processus).langue == 'F') |
if ((*s_etat_processus).langue == 'F') |
{ |
{ |
printf("+++Erreur : Option -%c inconnue\n", |
printf("+++Information : Option -%c inconnue\n", |
option); |
option); |
} |
} |
else |
else |
{ |
{ |
printf("+++Error : -%c option unknown\n", |
printf("+++Warning : -%c option unknown\n", |
option); |
option); |
} |
} |
|
|
Line 1380 rplinit(int argc, char *argv[], unsigned
|
Line 1525 rplinit(int argc, char *argv[], unsigned
|
printf("+++Error : More than one definition\n"); |
printf("+++Error : More than one definition\n"); |
} |
} |
|
|
erreur = d_os_ligne_de_commande; |
erreur = d_erreur; |
} |
} |
else |
else |
{ |
{ |
Line 1427 rplinit(int argc, char *argv[], unsigned
|
Line 1572 rplinit(int argc, char *argv[], unsigned
|
|
|
if (option_n == d_vrai) |
if (option_n == d_vrai) |
{ |
{ |
|
# ifndef _BROKEN_SIGINFO |
action.sa_sigaction = interruption10; |
action.sa_sigaction = interruption10; |
|
# else |
|
action.sa_handler = interruption10; |
|
# endif |
action.sa_flags = SA_ONSTACK | SA_SIGINFO; |
action.sa_flags = SA_ONSTACK | SA_SIGINFO; |
|
|
if (sigaction(SIGHUP, &action, NULL) != 0) |
if (sigaction(SIGHUP, &action, NULL) != 0) |
Line 1566 rplinit(int argc, char *argv[], unsigned
|
Line 1715 rplinit(int argc, char *argv[], unsigned
|
&existence, &ouverture, &unite_fichier); |
&existence, &ouverture, &unite_fichier); |
} |
} |
|
|
(*s_etat_processus).recherche_types_speciaux = 'N'; |
|
|
|
if (((existence == d_faux) || (erreur_fichier != d_absence_erreur)) && |
if (((existence == d_faux) || (erreur_fichier != d_absence_erreur)) && |
(option_S == d_faux)) |
(option_S == d_faux)) |
{ |
{ |
Line 1584 rplinit(int argc, char *argv[], unsigned
|
Line 1731 rplinit(int argc, char *argv[], unsigned
|
(*s_etat_processus).nom_fichier_source); |
(*s_etat_processus).nom_fichier_source); |
} |
} |
|
|
erreur = d_os_fichier_introuvable; |
erreur = d_erreur; |
} |
} |
else |
else |
{ |
{ |
Line 1597 rplinit(int argc, char *argv[], unsigned
|
Line 1744 rplinit(int argc, char *argv[], unsigned
|
printf("+++Error : Any executable definition\n"); |
printf("+++Error : Any executable definition\n"); |
} |
} |
} |
} |
|
|
|
return(EXIT_FAILURE); |
} |
} |
|
|
if ((*s_etat_processus).chemin_fichiers_temporaires == NULL) |
if ((*s_etat_processus).chemin_fichiers_temporaires == NULL) |
Line 1629 rplinit(int argc, char *argv[], unsigned
|
Line 1778 rplinit(int argc, char *argv[], unsigned
|
} |
} |
} |
} |
|
|
if ((erreur == d_os) && (presence_definition == 'O')) |
if ((erreur == d_absence_erreur) && (presence_definition == 'O')) |
{ |
{ |
(*s_etat_processus).profilage = (option_P != 0) ? d_vrai : d_faux; |
(*s_etat_processus).profilage = (option_P != 0) ? d_vrai : d_faux; |
(*s_etat_processus).niveau_profilage = option_P; |
(*s_etat_processus).niveau_profilage = option_P; |
Line 1642 rplinit(int argc, char *argv[], unsigned
|
Line 1791 rplinit(int argc, char *argv[], unsigned
|
(*s_etat_processus).test_instruction = 'N'; |
(*s_etat_processus).test_instruction = 'N'; |
(*s_etat_processus).nombre_arguments = 0; |
(*s_etat_processus).nombre_arguments = 0; |
(*s_etat_processus).affichage_arguments = 'N'; |
(*s_etat_processus).affichage_arguments = 'N'; |
|
(*s_etat_processus).autorisation_conversion_chaine = 'Y'; |
(*s_etat_processus).autorisation_evaluation_nom = 'Y'; |
(*s_etat_processus).autorisation_evaluation_nom = 'Y'; |
|
(*s_etat_processus).autorisation_nom_implicite = 'Y'; |
(*s_etat_processus).autorisation_empilement_programme = 'N'; |
(*s_etat_processus).autorisation_empilement_programme = 'N'; |
(*s_etat_processus).requete_arret = 'N'; |
(*s_etat_processus).requete_arret = 'N'; |
|
(*s_etat_processus).evaluation_forcee = 'N'; |
|
|
(*s_etat_processus).constante_symbolique = 'N'; |
(*s_etat_processus).constante_symbolique = 'N'; |
(*s_etat_processus).traitement_symbolique = 'N'; |
(*s_etat_processus).traitement_symbolique = 'N'; |
Line 1789 rplinit(int argc, char *argv[], unsigned
|
Line 1941 rplinit(int argc, char *argv[], unsigned
|
(*s_etat_processus).pile_origine_interruptions[i] = NULL; |
(*s_etat_processus).pile_origine_interruptions[i] = NULL; |
} |
} |
|
|
|
(*s_etat_processus).at_exit = NULL; |
|
(*s_etat_processus).at_poke = NULL; |
|
(*s_etat_processus).traitement_at_poke = 'N'; |
|
|
(*s_etat_processus).pointeurs_caracteres = NULL; |
(*s_etat_processus).pointeurs_caracteres = NULL; |
(*s_etat_processus).arbre_instructions = NULL; |
(*s_etat_processus).arbre_instructions = NULL; |
|
|
Line 1804 rplinit(int argc, char *argv[], unsigned
|
Line 1960 rplinit(int argc, char *argv[], unsigned
|
(*s_etat_processus).var_volatile_traitement_sigint = 0; |
(*s_etat_processus).var_volatile_traitement_sigint = 0; |
(*s_etat_processus).var_volatile_recursivite = 0; |
(*s_etat_processus).var_volatile_recursivite = 0; |
(*s_etat_processus).var_volatile_exception_gsl = 0; |
(*s_etat_processus).var_volatile_exception_gsl = 0; |
|
(*s_etat_processus).arret_depuis_abort = 0; |
|
|
initialisation_allocateur(s_etat_processus); |
initialisation_allocateur(s_etat_processus); |
initialisation_drapeaux(s_etat_processus); |
initialisation_drapeaux(s_etat_processus); |
Line 1823 rplinit(int argc, char *argv[], unsigned
|
Line 1980 rplinit(int argc, char *argv[], unsigned
|
} |
} |
|
|
if (((*s_etat_processus).instruction_derniere_erreur = |
if (((*s_etat_processus).instruction_derniere_erreur = |
malloc(2 * sizeof(unsigned char))) == NULL) |
malloc(sizeof(unsigned char))) == NULL) |
{ |
{ |
erreur = d_es_allocation_memoire; |
erreur = d_es_allocation_memoire; |
|
|
Line 1874 rplinit(int argc, char *argv[], unsigned
|
Line 2031 rplinit(int argc, char *argv[], unsigned
|
|
|
free((*s_etat_processus).instruction_courante); |
free((*s_etat_processus).instruction_courante); |
|
|
if ((*s_etat_processus).erreur_systeme == d_es_allocation_memoire) |
if ((*s_etat_processus).erreur_systeme != d_es) |
{ |
{ |
erreur = d_es_allocation_memoire; |
erreur = d_es_allocation_memoire; |
} |
} |
Line 2541 rplinit(int argc, char *argv[], unsigned
|
Line 2698 rplinit(int argc, char *argv[], unsigned
|
free(arguments); |
free(arguments); |
} |
} |
|
|
if (option_D == d_vrai) |
if (option_a == d_vrai) |
{ |
{ |
lancement_daemon(s_etat_processus); |
fprintf(stdout, "%s\n", (*s_etat_processus) |
|
.definitions_chainees); |
} |
} |
|
else |
if (option_p == d_faux) |
|
{ |
{ |
if (setjmp(contexte_initial) == 0) |
if (option_D == d_vrai) |
{ |
{ |
erreur = sequenceur(s_etat_processus); |
lancement_daemon(s_etat_processus); |
} |
} |
} |
|
else |
if (option_p == d_faux) |
{ |
{ |
if (setjmp(contexte_initial) == 0) |
if (setjmp(contexte_initial) == 0) |
|
{ |
|
erreur = sequenceur(s_etat_processus); |
|
} |
|
} |
|
else |
|
{ |
|
if (setjmp(contexte_initial) == 0) |
|
{ |
|
erreur = sequenceur_optimise(s_etat_processus); |
|
} |
|
} |
|
|
|
if (erreur == d_absence_erreur) |
{ |
{ |
erreur = sequenceur_optimise(s_etat_processus); |
if (((*s_etat_processus).var_volatile_alarme == 0) |
|
&& ((*s_etat_processus).arret_depuis_abort |
|
== 0) && ((*s_etat_processus).at_exit |
|
!= NULL)) |
|
{ |
|
erreur = evaluation(s_etat_processus, |
|
(*s_etat_processus).at_exit, 'E'); |
|
} |
} |
} |
} |
} |
|
|
|
liberation(s_etat_processus, (*s_etat_processus).at_exit); |
|
liberation(s_etat_processus, (*s_etat_processus).at_poke); |
|
|
if ((*s_etat_processus).generateur_aleatoire != NULL) |
if ((*s_etat_processus).generateur_aleatoire != NULL) |
{ |
{ |
liberation_generateur_aleatoire(s_etat_processus); |
liberation_generateur_aleatoire(s_etat_processus); |
Line 2677 rplinit(int argc, char *argv[], unsigned
|
Line 2857 rplinit(int argc, char *argv[], unsigned
|
} |
} |
else |
else |
{ |
{ |
kill((*(*((struct_processus_fils *) |
if ((*s_etat_processus).arret_depuis_abort |
(*(*((struct_liste_chainee *) |
== -1) |
l_element_courant)).donnee).objet)) |
{ |
.thread).pid, SIGFSTOP); |
kill((*(*((struct_processus_fils *) |
|
(*(*((struct_liste_chainee *) |
|
l_element_courant)).donnee).objet)) |
|
.thread).pid, SIGFABORT); |
|
} |
|
else |
|
{ |
|
kill((*(*((struct_processus_fils *) |
|
(*(*((struct_liste_chainee *) |
|
l_element_courant)).donnee).objet)) |
|
.thread).pid, SIGFSTOP); |
|
} |
} |
} |
} |
} |
else |
else |
Line 2705 rplinit(int argc, char *argv[], unsigned
|
Line 2896 rplinit(int argc, char *argv[], unsigned
|
} |
} |
else |
else |
{ |
{ |
pthread_kill((*(*((struct_processus_fils *) |
if ((*s_etat_processus).arret_depuis_abort |
(*(*((struct_liste_chainee *) |
== -1) |
l_element_courant)).donnee).objet)) |
{ |
.thread).tid, SIGFSTOP); |
pthread_kill( |
|
(*(*((struct_processus_fils *) |
|
(*(*((struct_liste_chainee *) |
|
l_element_courant)).donnee) |
|
.objet)).thread).tid, |
|
SIGFABORT); |
|
} |
|
else |
|
{ |
|
pthread_kill( |
|
(*(*((struct_processus_fils *) |
|
(*(*((struct_liste_chainee *) |
|
l_element_courant)).donnee) |
|
.objet)).thread).tid, |
|
SIGFSTOP); |
|
} |
} |
} |
} |
} |
|
|
Line 2741 rplinit(int argc, char *argv[], unsigned
|
Line 2947 rplinit(int argc, char *argv[], unsigned
|
l_element_courant = (void *) |
l_element_courant = (void *) |
(*s_etat_processus).l_base_pile_processus; |
(*s_etat_processus).l_base_pile_processus; |
|
|
if ((*s_etat_processus) |
|
.nombre_interruptions_non_affectees != 0) |
|
{ |
|
affectation_interruptions_logicielles( |
|
s_etat_processus); |
|
} |
|
|
|
for(i = 0; i < (unsigned long) |
for(i = 0; i < (unsigned long) |
(*(*((struct_processus_fils *) |
(*(*((struct_processus_fils *) |
(*(*((struct_liste_chainee *) |
(*(*((struct_liste_chainee *) |
Line 2806 rplinit(int argc, char *argv[], unsigned
|
Line 3005 rplinit(int argc, char *argv[], unsigned
|
} |
} |
|
|
pthread_mutex_unlock(&((*s_etat_processus).mutex)); |
pthread_mutex_unlock(&((*s_etat_processus).mutex)); |
|
|
|
if ((*s_etat_processus) |
|
.nombre_interruptions_non_affectees != 0) |
|
{ |
|
affectation_interruptions_logicielles( |
|
s_etat_processus); |
|
} |
|
|
nanosleep(&attente, NULL); |
nanosleep(&attente, NULL); |
pthread_mutex_lock(&((*s_etat_processus).mutex)); |
pthread_mutex_lock(&((*s_etat_processus).mutex)); |
} |
} |
Line 3184 rplinit(int argc, char *argv[], unsigned
|
Line 3391 rplinit(int argc, char *argv[], unsigned
|
fclose((*((struct_descripteur_fichier *) |
fclose((*((struct_descripteur_fichier *) |
(*((struct_liste_chainee *) |
(*((struct_liste_chainee *) |
l_element_courant)).donnee)) |
l_element_courant)).donnee)) |
.descripteur); |
.descripteur_c); |
|
|
|
if ((*((struct_descripteur_fichier *) |
|
(*((struct_liste_chainee *) |
|
l_element_courant)).donnee)).type != 'C') |
|
{ |
|
sqlite3_close((*((struct_descripteur_fichier *) |
|
(*((struct_liste_chainee *) |
|
l_element_courant)).donnee)) |
|
.descripteur_sqlite); |
|
} |
|
|
if ((*((struct_descripteur_fichier *) |
if ((*((struct_descripteur_fichier *) |
(*((struct_liste_chainee *) |
(*((struct_liste_chainee *) |
Line 3265 rplinit(int argc, char *argv[], unsigned
|
Line 3482 rplinit(int argc, char *argv[], unsigned
|
l_element_courant = l_element_suivant; |
l_element_courant = l_element_suivant; |
} |
} |
|
|
free((*s_etat_processus).chemin_fichiers_temporaires); |
|
|
|
l_element_courant = (*s_etat_processus).s_marques; |
l_element_courant = (*s_etat_processus).s_marques; |
while(l_element_courant != NULL) |
while(l_element_courant != NULL) |
{ |
{ |
Line 3318 rplinit(int argc, char *argv[], unsigned
|
Line 3533 rplinit(int argc, char *argv[], unsigned
|
} |
} |
} |
} |
|
|
|
# if !defined(Cygwin) && !defined(OpenBSD) |
|
(*s_etat_processus).pile_signal.ss_flags = SS_DISABLE; |
|
sigaltstack(&((*s_etat_processus).pile_signal), NULL); |
free((*s_etat_processus).pile_signal.ss_sp); |
free((*s_etat_processus).pile_signal.ss_sp); |
|
# endif |
|
|
closelog(); |
closelog(); |
|
|
pthread_mutex_destroy(&((*s_etat_processus).protection_liste_mutexes)); |
pthread_mutex_destroy(&((*s_etat_processus).protection_liste_mutexes)); |
Line 3328 rplinit(int argc, char *argv[], unsigned
|
Line 3548 rplinit(int argc, char *argv[], unsigned
|
retrait_thread(s_etat_processus); |
retrait_thread(s_etat_processus); |
|
|
pthread_mutex_destroy(&((*s_etat_processus).mutex)); |
pthread_mutex_destroy(&((*s_etat_processus).mutex)); |
|
pthread_mutex_destroy(&((*s_etat_processus).mutex_allocation)); |
|
|
|
# ifndef SEMAPHORES_NOMMES |
sem_post(&((*s_etat_processus).semaphore_fork)); |
sem_post(&((*s_etat_processus).semaphore_fork)); |
sem_destroy(&((*s_etat_processus).semaphore_fork)); |
sem_destroy(&((*s_etat_processus).semaphore_fork)); |
|
# else |
|
sem_post((*s_etat_processus).semaphore_fork); |
|
sem_destroy2((*s_etat_processus).semaphore_fork, sem_fork); |
|
# endif |
|
|
free((*s_etat_processus).localisation); |
free((*s_etat_processus).localisation); |
free(s_etat_processus); |
|
|
|
|
# ifndef SEMAPHORES_NOMMES |
sem_destroy(&semaphore_liste_threads); |
sem_destroy(&semaphore_liste_threads); |
|
# else |
|
sem_destroy2(semaphore_liste_threads, sem_liste_threads); |
|
# endif |
|
# ifndef SEMAPHORES_NOMMES |
sem_post(&semaphore_gestionnaires_signaux); |
sem_post(&semaphore_gestionnaires_signaux); |
sem_destroy(&semaphore_gestionnaires_signaux); |
sem_destroy(&semaphore_gestionnaires_signaux); |
sem_destroy(&semaphore_gestionnaires_signaux_atomique); |
sem_destroy(&semaphore_gestionnaires_signaux_atomique); |
|
# else |
|
sem_post(semaphore_gestionnaires_signaux); |
|
sem_destroy2(semaphore_gestionnaires_signaux, sem_gestionnaires_signaux); |
|
sem_destroy2(semaphore_gestionnaires_signaux_atomique, |
|
sem_gestionnaires_signaux_atomique); |
|
# endif |
|
|
|
# ifdef _BROKEN_SIGINFO |
|
destruction_fifos_signaux(s_etat_processus); |
|
# undef return |
|
# endif |
|
|
|
free((*s_etat_processus).chemin_fichiers_temporaires); |
|
free(s_etat_processus); |
|
|
|
# ifdef DEBUG_MEMOIRE |
|
debug_memoire_verification(); |
|
analyse_post_mortem(); |
|
# endif |
|
|
return((erreur == d_os) ? EXIT_SUCCESS : EXIT_FAILURE); |
return((erreur == d_absence_erreur) ? EXIT_SUCCESS : EXIT_FAILURE); |
} |
} |
|
|
|
|
Line 3351 informations(struct_processus *s_etat_pr
|
Line 3601 informations(struct_processus *s_etat_pr
|
if ((*s_etat_processus).langue == 'F') |
if ((*s_etat_processus).langue == 'F') |
{ |
{ |
printf(" rpl [-options] [programme]\n"); |
printf(" rpl [-options] [programme]\n"); |
printf(" -a : informations sur l'auteur\n"); |
printf(" -a : analyse du code\n"); |
printf(" -A : paramètres passés au programme principal\n"); |
printf(" -A : paramètres passés au programme principal\n"); |
printf(" -c : génération de fichier de débogage (rpl-core)\n"); |
printf(" -c : génération de fichier de débogage (rpl-core)\n"); |
printf(" -d : option de déverminage interne\n"); |
printf(" -d : option de déverminage interne\n"); |
Line 3370 informations(struct_processus *s_etat_pr
|
Line 3620 informations(struct_processus *s_etat_pr
|
else |
else |
{ |
{ |
printf(" rpl [-options] [program]\n"); |
printf(" rpl [-options] [program]\n"); |
printf(" -a : displays informations about the author\n"); |
printf(" -a : analyzes program\n"); |
printf(" -A : sends parameters to main program\n"); |
printf(" -A : sends parameters to main program\n"); |
printf(" -c : allows creation of a rpl-core file, providing a way" |
printf(" -c : allows creation of a rpl-core file, providing a way" |
"\n" |
"\n" |