Diff for /rpl/src/rpl.c between versions 1.194 and 1.195

version 1.194, 2017/07/02 22:28:20 version 1.195, 2017/07/04 10:28:08
Line 86  rplinit(int argc, char *argv[], char *en Line 86  rplinit(int argc, char *argv[], char *en
   
     struct_processus                    *s_etat_processus;      struct_processus                    *s_etat_processus;
   
       struct_liste_chainee                *l_bibliotheques;
       struct_liste_chainee                *l_bibliotheque_courante;
       struct_liste_chainee                *l_nouvelle_bibliotheque;
   
     struct_liste_variables_partagees    *l_element_partage_courant;      struct_liste_variables_partagees    *l_element_partage_courant;
     struct_liste_variables_partagees    *l_element_partage_suivant;      struct_liste_variables_partagees    *l_element_partage_suivant;
   
Line 125  rplinit(int argc, char *argv[], char *en Line 129  rplinit(int argc, char *argv[], char *en
     routine_recursive = 0;      routine_recursive = 0;
     nombre_thread_surveillance_processus = 0;      nombre_thread_surveillance_processus = 0;
     pid_processus_pere = getpid();      pid_processus_pere = getpid();
       affichage_rplso = d_vrai;
   
 #   ifdef DEBUG_PROC  #   ifdef DEBUG_PROC
     __proc = 0;      __proc = 0;
Line 1004  rplinit(int argc, char *argv[], char *en Line 1009  rplinit(int argc, char *argv[], char *en
     drapeau_encart = 'Y';      drapeau_encart = 'Y';
     debug = d_faux;      debug = d_faux;
     arguments = NULL;      arguments = NULL;
       l_bibliotheques = NULL;
   
     (*s_etat_processus).s_fichiers = NULL;      (*s_etat_processus).s_fichiers = NULL;
     (*s_etat_processus).s_sockets = NULL;      (*s_etat_processus).s_sockets = NULL;
Line 1594  rplinit(int argc, char *argv[], char *en Line 1600  rplinit(int argc, char *argv[], char *en
                             break;                              break;
                         }                          }
   
                           case 'm' :
                           {
                               while(*(++argv[0]) == ' ');
                               argv[0]--;
   
                               if ((*(++argv[0])) != '\0')
                               {
                                   if ((l_nouvelle_bibliotheque = malloc(
                                           sizeof(struct_liste_chainee))) == NULL)
                                   {
   #                                   ifndef SEMAPHORES_NOMMES
                                       sem_post(&((*s_etat_processus)
                                               .semaphore_fork));
                                       sem_destroy(&((*s_etat_processus)
                                               .semaphore_fork));
   #                                   else
                                       sem_post((*s_etat_processus)
                                               .semaphore_fork);
                                       sem_destroy3((*s_etat_processus)
                                               .semaphore_fork, getpid(),
                                               pthread_self(), SEM_FORK);
   #                                   endif
   
                                       liberation_contexte_cas(s_etat_processus);
                                       destruction_queue_signaux(s_etat_processus);
   
   #                                   ifdef HAVE_STACK_OVERFLOW_RECOVERY
                                       stackoverflow_deinstall_handler();
   #                                   endif
   
                                       if ((*s_etat_processus).langue == 'F')
                                       {
                                           printf("+++Système : Mémoire "
                                                   "insuffisante\n");
                                       }
                                       else
                                       {
                                           printf("+++System : Not enough "
                                                   "memory\n");
                                       }
   
                                       return(EXIT_FAILURE);
                                   }
   
                                   (*l_nouvelle_bibliotheque).suivant =
                                           l_bibliotheques;
   
                                   if (((*l_nouvelle_bibliotheque).donnee =
                                           allocation(s_etat_processus, CHN))
                                           == NULL)
                                   {
   #                                   ifndef SEMAPHORES_NOMMES
                                       sem_post(&((*s_etat_processus)
                                               .semaphore_fork));
                                       sem_destroy(&((*s_etat_processus)
                                               .semaphore_fork));
   #                                   else
                                       sem_post((*s_etat_processus)
                                               .semaphore_fork);
                                       sem_destroy3((*s_etat_processus)
                                               .semaphore_fork, getpid(),
                                               pthread_self(), SEM_FORK);
   #                                   endif
   
                                       liberation_contexte_cas(s_etat_processus);
                                       destruction_queue_signaux(s_etat_processus);
   
   #                                   ifdef HAVE_STACK_OVERFLOW_RECOVERY
                                       stackoverflow_deinstall_handler();
   #                                   endif
   
                                       if ((*s_etat_processus).langue == 'F')
                                       {
                                           printf("+++Système : Mémoire "
                                                   "insuffisante\n");
                                       }
                                       else
                                       {
                                           printf("+++System : Not enough "
                                                   "memory\n");
                                       }
   
                                       return(EXIT_FAILURE);
                                   }
   
                                   if (((*(*l_nouvelle_bibliotheque).donnee)
                                           .objet = malloc((strlen(argv[0]) + 1) *
                                           sizeof(unsigned char))) == NULL)
                                   {
   #                                   ifndef SEMAPHORES_NOMMES
                                       sem_post(&((*s_etat_processus)
                                               .semaphore_fork));
                                       sem_destroy(&((*s_etat_processus)
                                               .semaphore_fork));
   #                                   else
                                       sem_post((*s_etat_processus)
                                               .semaphore_fork);
                                       sem_destroy3((*s_etat_processus)
                                               .semaphore_fork, getpid(),
                                               pthread_self(), SEM_FORK);
   #                                   endif
   
                                       liberation_contexte_cas(s_etat_processus);
                                       destruction_queue_signaux(s_etat_processus);
   
   #                                   ifdef HAVE_STACK_OVERFLOW_RECOVERY
                                       stackoverflow_deinstall_handler();
   #                                   endif
   
                                       if ((*s_etat_processus).langue == 'F')
                                       {
                                           printf("+++Système : Mémoire "
                                                   "insuffisante\n");
                                       }
                                       else
                                       {
                                           printf("+++System : Not enough "
                                                   "memory\n");
                                       }
   
                                       return(EXIT_FAILURE);
                                   }
   
                                   strcpy((*(*l_nouvelle_bibliotheque).donnee)
                                           .objet, argv[0]);
                                   argv[0] += strlen((unsigned char *)
                                           (*(*l_nouvelle_bibliotheque).donnee)
                                           .objet) - 1;
   
                                   l_bibliotheques = l_nouvelle_bibliotheque;
                               }
                               else if ((--argc) > 0)
                               {
                                   argv++;
   
                                   if ((l_nouvelle_bibliotheque = malloc(
                                           sizeof(struct_liste_chainee))) == NULL)
                                   {
   #                                   ifndef SEMAPHORES_NOMMES
                                       sem_post(&((*s_etat_processus)
                                               .semaphore_fork));
                                       sem_destroy(&((*s_etat_processus)
                                               .semaphore_fork));
   #                                   else
                                       sem_post((*s_etat_processus)
                                               .semaphore_fork);
                                       sem_destroy3((*s_etat_processus)
                                               .semaphore_fork, getpid(),
                                               pthread_self(), SEM_FORK);
   #                                   endif
   
                                       liberation_contexte_cas(s_etat_processus);
                                       destruction_queue_signaux(s_etat_processus);
   
   #                                   ifdef HAVE_STACK_OVERFLOW_RECOVERY
                                       stackoverflow_deinstall_handler();
   #                                   endif
   
                                       if ((*s_etat_processus).langue == 'F')
                                       {
                                           printf("+++Système : Mémoire "
                                                   "insuffisante\n");
                                       }
                                       else
                                       {
                                           printf("+++System : Not enough "
                                                   "memory\n");
                                       }
   
                                       return(EXIT_FAILURE);
                                   }
   
                                   (*l_nouvelle_bibliotheque).suivant =
                                           l_bibliotheques;
   
                                   if (((*l_nouvelle_bibliotheque).donnee =
                                           allocation(s_etat_processus, CHN))
                                           == NULL)
                                   {
   #                                   ifndef SEMAPHORES_NOMMES
                                       sem_post(&((*s_etat_processus)
                                               .semaphore_fork));
                                       sem_destroy(&((*s_etat_processus)
                                               .semaphore_fork));
   #                                   else
                                       sem_post((*s_etat_processus)
                                               .semaphore_fork);
                                       sem_destroy3((*s_etat_processus)
                                               .semaphore_fork, getpid(),
                                               pthread_self(), SEM_FORK);
   #                                   endif
   
                                       liberation_contexte_cas(s_etat_processus);
                                       destruction_queue_signaux(s_etat_processus);
   
   #                                   ifdef HAVE_STACK_OVERFLOW_RECOVERY
                                       stackoverflow_deinstall_handler();
   #                                   endif
   
                                       if ((*s_etat_processus).langue == 'F')
                                       {
                                           printf("+++Système : Mémoire "
                                                   "insuffisante\n");
                                       }
                                       else
                                       {
                                           printf("+++System : Not enough "
                                                   "memory\n");
                                       }
   
                                       return(EXIT_FAILURE);
                                   }
   
                                   if (((*(*l_nouvelle_bibliotheque).donnee)
                                           .objet = malloc((strlen(argv[0]) + 1) *
                                           sizeof(unsigned char))) == NULL)
                                   {
   #                                   ifndef SEMAPHORES_NOMMES
                                       sem_post(&((*s_etat_processus)
                                               .semaphore_fork));
                                       sem_destroy(&((*s_etat_processus)
                                               .semaphore_fork));
   #                                   else
                                       sem_post((*s_etat_processus)
                                               .semaphore_fork);
                                       sem_destroy3((*s_etat_processus)
                                               .semaphore_fork, getpid(),
                                               pthread_self(), SEM_FORK);
   #                                   endif
   
                                       liberation_contexte_cas(s_etat_processus);
                                       destruction_queue_signaux(s_etat_processus);
   
   #                                   ifdef HAVE_STACK_OVERFLOW_RECOVERY
                                       stackoverflow_deinstall_handler();
   #                                   endif
   
                                       if ((*s_etat_processus).langue == 'F')
                                       {
                                           printf("+++Système : Mémoire "
                                                   "insuffisante\n");
                                       }
                                       else
                                       {
                                           printf("+++System : Not enough "
                                                   "memory\n");
                                       }
   
                                       return(EXIT_FAILURE);
                                   }
   
                                   strcpy((*(*l_nouvelle_bibliotheque).donnee)
                                           .objet, argv[0]);
                                   argv[0] += strlen((unsigned char *)
                                           (*(*l_nouvelle_bibliotheque).donnee)
                                           .objet) - 1;
   
                                   l_bibliotheques = l_nouvelle_bibliotheque;
                               }
                               else
                               {
   #                               ifndef SEMAPHORES_NOMMES
                                   sem_post(&((*s_etat_processus).semaphore_fork));
                                   sem_destroy(&((*s_etat_processus)
                                           .semaphore_fork));
   #                               else
                                   sem_post((*s_etat_processus).semaphore_fork);
                                   sem_destroy3((*s_etat_processus).semaphore_fork,
                                           getpid(), pthread_self(), SEM_FORK);
   #                               endif
   
                                   liberation_contexte_cas(s_etat_processus);
                                   destruction_queue_signaux(s_etat_processus);
   
   #                               ifdef HAVE_STACK_OVERFLOW_RECOVERY
                                   stackoverflow_deinstall_handler();
   #                               endif
   
                                   if ((*s_etat_processus).langue == 'F')
                                   {
                                       printf("+++Erreur : Aucune bibliothèque "
                                               "spécifiée après l'option -A\n");
                                   }
                                   else
                                   {
                                       printf("+++Error : Library required after "
                                               "-m option\n");
                                   }
   
                                   return(EXIT_FAILURE);
                               }
   
                               break;
                           }
   
                         case 'n' :                          case 'n' :
                         {                          {
                             if (option_n == d_vrai)                              if (option_n == d_vrai)
Line 3765  rplinit(int argc, char *argv[], char *en Line 4066  rplinit(int argc, char *argv[], char *en
                         }                          }
                     }                      }
   
                       /*
                        * Chargement des bibliothèques pour gérer des
                        * types externes lors des l'analyse syntaxique et
                        * compilation.
                        */
   
                       l_bibliotheque_courante = l_bibliotheques;
   
                       while(l_bibliotheque_courante != NULL)
                       {
                           if (empilement(s_etat_processus, &((*s_etat_processus)
                                   .l_base_pile), (*l_bibliotheque_courante)
                                   .donnee) == d_erreur)
                           {
   #                           ifndef SEMAPHORES_NOMMES
                                   sem_post(&((*s_etat_processus).semaphore_fork));
                                   sem_destroy(&((*s_etat_processus)
                                           .semaphore_fork));
   #                           else
                                   sem_post((*s_etat_processus).semaphore_fork);
                                   sem_destroy3((*s_etat_processus).semaphore_fork,
                                           getpid(), pthread_self(), SEM_FORK);
   #                           endif
   
                               liberation_contexte_cas(s_etat_processus);
                               destruction_queue_signaux(s_etat_processus);
   
   #                           ifdef HAVE_STACK_OVERFLOW_RECOVERY
                                   stackoverflow_deinstall_handler();
   #                           endif
   
   #                           ifdef HAVE_SIGSEGV_RECOVERY
                                   if (debug == d_faux)
                                   {
                                       sigsegv_deinstall_handler();
                                   }
   #                           endif
   
                               if ((*s_etat_processus).langue == 'F')
                               {
                                   printf("+++Fatal :"
                                           " Chargement de la bibliothèse %s"
                                           " impossible\n", (unsigned char *)
                                           (*(*l_bibliotheque_courante).donnee)
                                           .objet);
                               }
                               else
                               {
                                   printf("+++Fatal : Cannot load library %s\n",
                                           (*(*l_bibliotheque_courante).donnee)
                                           .objet);
                               }
   
                               if (traitement_fichier_temporaire == 'Y')
                               {
                                   if (destruction_fichier(
                                           nom_fichier_temporaire)
                                           == d_erreur)
                                   {
                                       return(EXIT_FAILURE);
                                   }
   
                                   free(nom_fichier_temporaire);
                               }
   
                               return(EXIT_FAILURE);
                           }
   
                           affichage_rplso = d_faux;
                           instruction_use(s_etat_processus);
                           affichage_rplso = d_vrai;
   
                           if (depilement(s_etat_processus, &((*s_etat_processus)
                                   .l_base_pile), &((*l_bibliotheque_courante)
                                   .donnee)) == d_erreur)
                           {
   #                           ifndef SEMAPHORES_NOMMES
                                   sem_post(&((*s_etat_processus).semaphore_fork));
                                   sem_destroy(&((*s_etat_processus)
                                           .semaphore_fork));
   #                           else
                                   sem_post((*s_etat_processus).semaphore_fork);
                                   sem_destroy3((*s_etat_processus).semaphore_fork,
                                           getpid(), pthread_self(), SEM_FORK);
   #                           endif
   
                               liberation_contexte_cas(s_etat_processus);
                               destruction_queue_signaux(s_etat_processus);
   
   #                           ifdef HAVE_STACK_OVERFLOW_RECOVERY
                                   stackoverflow_deinstall_handler();
   #                           endif
   
   #                           ifdef HAVE_SIGSEGV_RECOVERY
                                   if (debug == d_faux)
                                   {
                                       sigsegv_deinstall_handler();
                                   }
   #                           endif
   
                               if ((*s_etat_processus).langue == 'F')
                               {
                                   printf("+++Fatal :"
                                           " Chargement de la bibliothèse %s"
                                           " impossible\n", (unsigned char *)
                                           (*(*l_bibliotheque_courante).donnee)
                                           .objet);
                               }
                               else
                               {
                                   printf("+++Fatal : Cannot load library %s\n",
                                           (*(*l_bibliotheque_courante).donnee)
                                           .objet);
                               }
   
                               if (traitement_fichier_temporaire == 'Y')
                               {
                                   if (destruction_fichier(
                                           nom_fichier_temporaire)
                                           == d_erreur)
                                   {
                                       return(EXIT_FAILURE);
                                   }
   
                                   free(nom_fichier_temporaire);
                               }
   
                               return(EXIT_FAILURE);
                           }
   
                           l_bibliotheque_courante =
                                   (*l_bibliotheque_courante).suivant;
                       }
   
                     if ((erreur = compilation(s_etat_processus)) !=                      if ((erreur = compilation(s_etat_processus)) !=
                             d_absence_erreur)                              d_absence_erreur)
                     {                      {
Line 4650  rplinit(int argc, char *argv[], char *en Line 5085  rplinit(int argc, char *argv[], char *en
                         {                          {
                             if (setjmp(contexte_initial) == 0)                              if (setjmp(contexte_initial) == 0)
                             {                              {
                                   // Libération des bibliothèques
   
                                   l_bibliotheque_courante = l_bibliotheques;
   
                                   while(l_bibliotheque_courante != NULL)
                                   {
                                       if (empilement(s_etat_processus,
                                               &((*s_etat_processus).l_base_pile),
                                               (*l_bibliotheque_courante).donnee)
                                               == d_erreur)
                                       {
   #                                       ifndef SEMAPHORES_NOMMES
                                               sem_post(&((*s_etat_processus)
                                                       .semaphore_fork));
                                               sem_destroy(&((*s_etat_processus)
                                                       .semaphore_fork));
   #                                       else
                                               sem_post((*s_etat_processus)
                                                       .semaphore_fork);
                                               sem_destroy3((*s_etat_processus)
                                                       .semaphore_fork, getpid(),
                                                       pthread_self(), SEM_FORK);
   #                                       endif
   
                                           liberation_contexte_cas(
                                                   s_etat_processus);
                                           destruction_queue_signaux(
                                                   s_etat_processus);
   
   #                                       ifdef HAVE_STACK_OVERFLOW_RECOVERY
                                               stackoverflow_deinstall_handler();
   #                                       endif
   
   #                                       ifdef HAVE_SIGSEGV_RECOVERY
                                               if (debug == d_faux)
                                               {
                                                   sigsegv_deinstall_handler();
                                               }
   #                                       endif
   
                                           erreur = d_es_allocation_memoire;
   
                                           if ((*s_etat_processus).langue == 'F')
                                           {
                                               printf("+++Système : Mémoire "
                                                       "insuffisante\n");
                                           }
                                           else
                                           {
                                               printf("+++System : Not enough "
                                                       "memory\n");
                                           }
   
                                           return(EXIT_FAILURE);
                                       }
   
                                       affichage_rplso = d_faux;
                                       instruction_remove(s_etat_processus);
                                       affichage_rplso = d_vrai;
   
                                       l_nouvelle_bibliotheque =
                                               (*l_bibliotheque_courante).suivant;
                                       free(l_bibliotheque_courante);
                                       l_bibliotheque_courante =
                                               l_nouvelle_bibliotheque;
                                   }
   
                                 erreur = sequenceur(s_etat_processus);                                  erreur = sequenceur(s_etat_processus);
   
                                 if (erreur == d_absence_erreur)                                  if (erreur == d_absence_erreur)
Line 4751  rplinit(int argc, char *argv[], char *en Line 5253  rplinit(int argc, char *argv[], char *en
                         {                          {
                             if (setjmp(contexte_initial) == 0)                              if (setjmp(contexte_initial) == 0)
                             {                              {
                                 erreur = sequenceur_optimise(s_etat_processus);                                  erreur = sequenceur_optimise(s_etat_processus,
                                           l_bibliotheques);
   
                                 if (erreur == d_absence_erreur)                                  if (erreur == d_absence_erreur)
                                 {                                  {

Removed from v.1.194  
changed lines
  Added in v.1.195


CVSweb interface <joel.bertrand@systella.fr>