Diff for /rpl/src/instructions_o1.c between versions 1.34 and 1.76

version 1.34, 2011/06/24 20:31:39 version 1.76, 2014/04/25 07:37:32
Line 1 Line 1
 /*  /*
 ================================================================================  ================================================================================
   RPL/2 (R) version 4.1.0.prerelease.4    RPL/2 (R) version 4.1.18
   Copyright (C) 1989-2011 Dr. BERTRAND Joël    Copyright (C) 1989-2014 Dr. BERTRAND Joël
   
   This file is part of RPL/2.    This file is part of RPL/2.
   
Line 210  instruction_or(struct_processus *s_etat_ Line 210  instruction_or(struct_processus *s_etat_
     struct_objet                *s_objet_argument_2;      struct_objet                *s_objet_argument_2;
     struct_objet                *s_objet_resultat;      struct_objet                *s_objet_resultat;
   
     unsigned long               nombre_elements;      integer8                    nombre_elements;
   
     (*s_etat_processus).erreur_execution = d_ex;      (*s_etat_processus).erreur_execution = d_ex;
   
Line 907  instruction_open(struct_processus *s_eta Line 907  instruction_open(struct_processus *s_eta
     int                         buffer_reception;      int                         buffer_reception;
     int                         drapeau;      int                         drapeau;
     int                         priorite;      int                         priorite;
       int                         prochain_descripteur;
     int                         protocole_numerique;      int                         protocole_numerique;
     int                         timeout_emission;      int                         timeout_emission;
     int                         timeout_reception;      int                         timeout_reception;
Line 919  instruction_open(struct_processus *s_eta Line 920  instruction_open(struct_processus *s_eta
   
     logical1                    erreur;      logical1                    erreur;
     logical1                    existence;      logical1                    existence;
       logical1                    negation;
     logical1                    ouverture;      logical1                    ouverture;
     logical1                    presence_port;      logical1                    presence_port;
   
Line 926  instruction_open(struct_processus *s_eta Line 928  instruction_open(struct_processus *s_eta
   
     struct_liste_chainee        *l_element_courant;      struct_liste_chainee        *l_element_courant;
     struct_liste_chainee        *l_element_courant_sous_objet;      struct_liste_chainee        *l_element_courant_sous_objet;
       struct_liste_chainee        *parametre_courant;
   
     struct flock                lock;      struct flock                lock;
   
Line 942  instruction_open(struct_processus *s_eta Line 945  instruction_open(struct_processus *s_eta
   
     struct_objet                *s_objet_argument;      struct_objet                *s_objet_argument;
     struct_objet                *s_objet_resultat;      struct_objet                *s_objet_resultat;
       struct_objet                *s_parametres_tty;
   
       struct termios              tc;
   
     uint32_t                    adresse_ipv4;      uint32_t                    adresse_ipv4;
   
Line 952  instruction_open(struct_processus *s_eta Line 958  instruction_open(struct_processus *s_eta
     unsigned char               *nom;      unsigned char               *nom;
     unsigned char               *nom_temporaire;      unsigned char               *nom_temporaire;
     unsigned char               options[12];      unsigned char               options[12];
       unsigned char               *parametre_courant_majuscule;
     unsigned char               *peripherique;      unsigned char               *peripherique;
     unsigned char               *pointeur;      unsigned char               *pointeur;
       unsigned char               *position;
     unsigned char               protection;      unsigned char               protection;
     unsigned char               protocole[16 + 1];      unsigned char               protocole[16 + 1];
     unsigned char               *protocole_socket;      unsigned char               *protocole_socket;
Line 966  instruction_open(struct_processus *s_eta Line 974  instruction_open(struct_processus *s_eta
   
     unsigned long               i;      unsigned long               i;
     unsigned long               nombre_elements;      unsigned long               nombre_elements;
     unsigned long               prochain_descripteur;  
     unsigned long               unite;      unsigned long               unite;
   
 #   define                      d_BIND_TO_DEVICE        0  #   define                      d_BIND_TO_DEVICE        0
Line 1019  instruction_open(struct_processus *s_eta Line 1026  instruction_open(struct_processus *s_eta
   
         printf("    { \"filetype\" \"access\" \"format\" { \"name\" "          printf("    { \"filetype\" \"access\" \"format\" { \"name\" "
                 "\"file name\" } \"protection\" } OPEN\n");                  "\"file name\" } \"protection\" } OPEN\n");
           printf("    { \"filetype\" \"access\" \"format\" { \"name\" "
                   "\"file name\" } \n"
                   "           { \"stty\" \"speed,bits,parity,stop\"\n"
                   "           { \"stty parameters\" ... } } } OPEN\n");
         printf("    { \"sockettype\" { \"name\" \"local name\" } } OPEN\n");          printf("    { \"sockettype\" { \"name\" \"local name\" } } OPEN\n");
         printf("    { \"sockettype\" \"socketdomain\" \"protection\" } OPEN\n");          printf("    { \"sockettype\" \"socketdomain\" \"protection\" } OPEN\n");
         printf("    \"/semaphore\" OPEN\n");          printf("    \"/semaphore\" OPEN\n\n");
   
         printf("    File type       : NEW/OLD/REPLACE/UNKNOWN/SCRATCH\n");          printf("    File type       : NEW/OLD/REPLACE/UNKNOWN/SCRATCH\n");
         printf("    File access     : SEQUENTIAL/DIRECT/KEYED\n");          printf("    File access     : SEQUENTIAL/DIRECT/KEYED\n");
Line 1031  instruction_open(struct_processus *s_eta Line 1042  instruction_open(struct_processus *s_eta
         printf("    Socket protocol : IPV4/IPV6/UNIX\n");          printf("    Socket protocol : IPV4/IPV6/UNIX\n");
         printf("    Format          : FORMATTED/UNFORMATTED/FLOW\n");          printf("    Format          : FORMATTED/UNFORMATTED/FLOW\n");
         printf("    Protection      : READONLY/WRITEONLY/READWRITE\n\n");          printf("    Protection      : READONLY/WRITEONLY/READWRITE\n\n");
           printf("    Stty parameters : can be prefixed by 'NO'\n");
           printf("            IGNBRK, BRKINT, IGNPAR, PARMRK, INPCK, ISTRIP\n");
           printf("            INLCR, IGNCR, ICRNL, IXON, IXANY, IXOFF,\n");
           printf("            IMAXBEL, OPOST, ONLCR, OCRNL, ONOCR, ONLRET,\n");
           printf("            OFILL, HUPCL, CLOCAL, CRTSCTS, ISIG, ICANON,\n");
           printf("            ECHO, ECHOE, ECHOK, ECHONL, NOFLSH, TOSTOP,\n");
           printf("            IEXTEN\n");
   
         printf("    Address         : { \"ADDRESS\" [ 127 0 0 1 ] }\n");          printf("    Address         : { \"ADDRESS\" [ 127 0 0 1 ] }\n");
         printf("                      { \"HOST\" \"hostname\" }\n");          printf("                      { \"HOST\" \"hostname\" }\n");
Line 1052  instruction_open(struct_processus *s_eta Line 1070  instruction_open(struct_processus *s_eta
         printf("    Port            : { \"PORT\" port number }\n");          printf("    Port            : { \"PORT\" port number }\n");
         printf("    Protocol        : { \"PROTOCOL\" \"protocol\" }\n\n");          printf("    Protocol        : { \"PROTOCOL\" \"protocol\" }\n\n");
   
         printf("    { { \"NAME\" \"filename\" } } OPEN\n");          printf("    { { \"NAME\" \"filename\" } \"SEQUENTIAL\" } OPEN\n");
         printf("    { \"SCRATCH\" } OPEN\n");          printf("    { \"SCRATCH\" } OPEN\n");
         printf("    { { \"NAME\" \"filename\" } \"UNKNOWN\" \"FORMATTED\" "          printf("    { { \"NAME\" \"filename\" } \"UNKNOWN\" \"FORMATTED\" "
                 "\"DIRECT\" } OPEN\n");                  "\"DIRECT\" } OPEN\n");
Line 1061  instruction_open(struct_processus *s_eta Line 1079  instruction_open(struct_processus *s_eta
         printf("    { \"STREAM\" \"READWRITE\" } OPEN\n");          printf("    { \"STREAM\" \"READWRITE\" } OPEN\n");
         printf("    { \"FOREIGN\" \"DATAGRAM\" } OPEN\n");          printf("    { \"FOREIGN\" \"DATAGRAM\" } OPEN\n");
         printf("    { \"LOCAL\" { \"NAME\" \"socket.sock\" } } OPEN\n");          printf("    { \"LOCAL\" { \"NAME\" \"socket.sock\" } } OPEN\n");
           printf("    { { \"NAME\" \"/dev/ttyS1\" } { \"STTY\" \"9600,8,N,1\" "
                   "\n            { \"NO ICANON\" \"IGNBRK\" } } } OPEN\n");
   
         return;          return;
     }      }
Line 1121  instruction_open(struct_processus *s_eta Line 1141  instruction_open(struct_processus *s_eta
         timeout_emission = 0;          timeout_emission = 0;
         timeout_reception = 0;          timeout_reception = 0;
         drapeau = -1;          drapeau = -1;
           s_parametres_tty = NULL;
   
         for(i = 0; i < 12; options[i++] = 'N');          for(i = 0; i < 12; options[i++] = 'N');
   
Line 1972  instruction_open(struct_processus *s_eta Line 1993  instruction_open(struct_processus *s_eta
                                 protocole_socket = (unsigned char *)                                  protocole_socket = (unsigned char *)
                                         (*(*l_element_courant_sous_objet)                                          (*(*l_element_courant_sous_objet)
                                         .donnee).objet;                                          .donnee).objet;
   
                                   for(i = 0; i < strlen(protocole_socket); i++)
                                   {
                                       if ((protocole_socket[i] >= 'a') &&
                                               (protocole_socket[i] <= 'z'))
                                       {
                                           protocole_socket[i] = (unsigned char)
                                                   (protocole_socket[i]
                                                   - ('a' - 'A'));
                                       }
                                   }
                             }                              }
                             else                              else
                             {                              {
Line 2112  instruction_open(struct_processus *s_eta Line 2144  instruction_open(struct_processus *s_eta
                                 {                                  {
                                     type_arguments = 'S';                                      type_arguments = 'S';
                                 }                                  }
                                 else if (type_arguments == 'F')  
                                 {                                  {
                                     liberation(s_etat_processus,                                      liberation(s_etat_processus,
                                             s_objet_argument);                                              s_objet_argument);
Line 2240  instruction_open(struct_processus *s_eta Line 2271  instruction_open(struct_processus *s_eta
                                 }                                  }
                             }                              }
                         }                          }
                           else if (strcmp(argument_majuscule, "STTY") == 0)
                           {
                               if ((*(*l_element_courant_sous_objet)
                                       .donnee).type == CHN)
                               {
                                   if (type_arguments == ' ')
                                   {
                                       type_arguments = 'F';
                                   }
                                   else if (type_arguments == 'S')
                                   {
                                       liberation(s_etat_processus,
                                               s_objet_argument);
                                       free(argument_majuscule);
   
                                       (*s_etat_processus).erreur_execution =
                                               d_ex_erreur_parametre_fichier;
                                       return;
                                   }
   
                                   s_parametres_tty = (*l_element_courant).donnee;
                               }
                           }
                         else                          else
                         {                          {
                             liberation(s_etat_processus, s_objet_argument);                              liberation(s_etat_processus, s_objet_argument);
Line 2593  instruction_open(struct_processus *s_eta Line 2647  instruction_open(struct_processus *s_eta
   
                             free(argument_majuscule);                              free(argument_majuscule);
                         }                          }
                           else if (strcmp(argument_majuscule, "STTY") == 0)
                           {
                               if (type_arguments == ' ')
                               {
                                   type_arguments = 'F';
                               }
                               else if (type_arguments == 'S')
                               {
                                   liberation(s_etat_processus, s_objet_argument);
                                   free(argument_majuscule);
   
                                   (*s_etat_processus).erreur_execution =
                                           d_ex_erreur_parametre_fichier;
                                   return;
                               }
   
                               free(argument_majuscule);
   
                               l_element_courant_sous_objet =
                                       (*l_element_courant_sous_objet).suivant;
   
                               if ((*(*l_element_courant_sous_objet)
                                       .donnee).type != CHN)
                               {
                                   liberation(s_etat_processus, s_objet_argument);
   
                                   (*s_etat_processus).erreur_execution =
                                           d_ex_erreur_parametre_fichier;
                                   return;
                               }
   
                               l_element_courant_sous_objet =
                                       (*l_element_courant_sous_objet).suivant;
   
                               if ((*(*l_element_courant_sous_objet)
                                       .donnee).type != LST)
                               {
                                   liberation(s_etat_processus, s_objet_argument);
   
                                   (*s_etat_processus).erreur_execution =
                                           d_ex_erreur_parametre_fichier;
                                   return;
                               }
   
                               s_parametres_tty = (*l_element_courant).donnee;
                           }
                         else                          else
                         {                          {
                             liberation(s_etat_processus, s_objet_argument);                              liberation(s_etat_processus, s_objet_argument);
Line 2633  instruction_open(struct_processus *s_eta Line 2733  instruction_open(struct_processus *s_eta
             l_element_courant = (*l_element_courant).suivant;              l_element_courant = (*l_element_courant).suivant;
         }          }
   
           // Si aucun paramètre n'est discriminant, l'instruction ouvre
           // par défaut un fichier.
   
           if (type_arguments == ' ')
           {
               type_arguments = 'F';
           }
   
         if (type_arguments == 'F')          if (type_arguments == 'F')
         {          {
             /*              /*
Line 2812  instruction_open(struct_processus *s_eta Line 2920  instruction_open(struct_processus *s_eta
                             return;                              return;
                         }                          }
   
                           sqlite = NULL;
   
                         if (sqlite3_open_v2(nom, &sqlite,                          if (sqlite3_open_v2(nom, &sqlite,
                                 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,                                  SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
                                 NULL) != SQLITE_OK)                                  NULL) != SQLITE_OK)
                         {                          {
                               if (sqlite != NULL)
                               {
                                   sqlite3_close(sqlite);
                               }
   
                             free(nom);                              free(nom);
   
                             liberation(s_etat_processus, s_objet_argument);                              liberation(s_etat_processus, s_objet_argument);
Line 2918  instruction_open(struct_processus *s_eta Line 3033  instruction_open(struct_processus *s_eta
                     }                      }
                     else                      else
                     {                      {
                           sqlite = NULL;
   
                         if (sqlite3_open_v2(nom, &sqlite,                          if (sqlite3_open_v2(nom, &sqlite,
                                 SQLITE_OPEN_READWRITE,                                  SQLITE_OPEN_READWRITE,
                                 NULL) != SQLITE_OK)                                  NULL) != SQLITE_OK)
                         {                          {
                               if (sqlite != NULL)
                               {
                                   sqlite3_close(sqlite);
                               }
   
                             free(nom);                              free(nom);
   
                             liberation(s_etat_processus, s_objet_argument);                              liberation(s_etat_processus, s_objet_argument);
Line 3057  instruction_open(struct_processus *s_eta Line 3179  instruction_open(struct_processus *s_eta
                     }                      }
                     else                      else
                     {                      {
                           sqlite = NULL;
   
                         if (sqlite3_open_v2(nom, &sqlite,                          if (sqlite3_open_v2(nom, &sqlite,
                                 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,                                  SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
                                 NULL) != SQLITE_OK)                                  NULL) != SQLITE_OK)
                         {                          {
                               if (sqlite != NULL)
                               {
                                   sqlite3_close(sqlite);
                               }
   
                             free(nom);                              free(nom);
   
                             liberation(s_etat_processus, s_objet_argument);                              liberation(s_etat_processus, s_objet_argument);
Line 3168  instruction_open(struct_processus *s_eta Line 3297  instruction_open(struct_processus *s_eta
                         }                          }
                         else                          else
                         {                          {
                               sqlite = NULL;
   
                             if (sqlite3_open_v2(nom, &sqlite,                              if (sqlite3_open_v2(nom, &sqlite,
                                     SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,                                      SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
                                     NULL) != SQLITE_OK)                                      NULL) != SQLITE_OK)
                             {                              {
                                   if (sqlite != NULL)
                                   {
                                       sqlite3_close(sqlite);
                                   }
   
                                 free(nom);                                  free(nom);
   
                                 liberation(s_etat_processus, s_objet_argument);                                  liberation(s_etat_processus, s_objet_argument);
Line 3262  instruction_open(struct_processus *s_eta Line 3398  instruction_open(struct_processus *s_eta
                         }                          }
                         else                          else
                         {                          {
                               sqlite = NULL;
   
                             if (sqlite3_open_v2(nom, &sqlite,                              if (sqlite3_open_v2(nom, &sqlite,
                                     SQLITE_OPEN_READWRITE,                                      SQLITE_OPEN_READWRITE,
                                     NULL) != SQLITE_OK)                                      NULL) != SQLITE_OK)
                             {                              {
                                   if (sqlite != NULL)
                                   {
                                       sqlite3_close(sqlite);
                                   }
   
                                 free(nom);                                  free(nom);
   
                                 liberation(s_etat_processus, s_objet_argument);                                  liberation(s_etat_processus, s_objet_argument);
Line 3340  instruction_open(struct_processus *s_eta Line 3483  instruction_open(struct_processus *s_eta
                             return;                              return;
                         }                          }
   
                           sqlite = NULL;
   
                         if (sqlite3_open_v2(nom, &sqlite,                          if (sqlite3_open_v2(nom, &sqlite,
                                 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,                                  SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
                                 NULL) != SQLITE_OK)                                  NULL) != SQLITE_OK)
                         {                          {
                               if (sqlite != NULL)
                               {
                                   sqlite3_close(sqlite);
                               }
   
                             free(nom);                              free(nom);
   
                             liberation(s_etat_processus, s_objet_argument);                              liberation(s_etat_processus, s_objet_argument);
Line 3428  instruction_open(struct_processus *s_eta Line 3578  instruction_open(struct_processus *s_eta
                 return;                  return;
             }              }
   
               if (s_parametres_tty != NULL)
               {
                   // Affectation des paramètres du port série.
   
                   if (tcgetattr(fileno(descripteur), &tc) != 0)
                   {
                       liberation(s_etat_processus, s_objet_argument);
                       liberation(s_etat_processus, s_objet_resultat);
   
                       (*s_etat_processus).erreur_systeme =
                               d_ex_erreur_fichier;
                       return;
                   }
   
                   // Un test a déjà été fait pour vérifier que s_parametres_tty
                   // contient deux ou trois arguments.
   
                   parametre_courant = ((*(struct_liste_chainee *)
                           (*s_parametres_tty).objet)).suivant;
   
                   // Le premier paramètre concerne la vitesse du port. Il doit
                   // toujours être présent.
   
                   if (parametre_courant == NULL)
                   {
                       liberation(s_etat_processus, s_objet_argument);
                       liberation(s_etat_processus, s_objet_resultat);
   
                       (*s_etat_processus).erreur_execution =
                               d_ex_erreur_parametre_fichier;
                       return;
                   }
   
                   if ((*(*parametre_courant).donnee).type != CHN)
                   {
                       liberation(s_etat_processus, s_objet_argument);
                       liberation(s_etat_processus, s_objet_resultat);
   
                       (*s_etat_processus).erreur_execution =
                               d_ex_erreur_parametre_fichier;
                       return;
                   }
   
                   if ((parametre_courant_majuscule = conversion_majuscule(
                           (*(*parametre_courant).donnee).objet)) == NULL)
                   {
                       liberation(s_etat_processus, s_objet_argument);
                       liberation(s_etat_processus, s_objet_resultat);
   
                       (*s_etat_processus).erreur_systeme =
                               d_es_allocation_memoire;
                       return;
                   }
   
                   position = parametre_courant_majuscule;
   
                   while((*position) != d_code_fin_chaine)
                   {
                       if ((*position) == ',')
                       {
                           (*position) = ' ';
                       }
   
                       position++;
                   }
   
                   position = parametre_courant_majuscule;
   
                   while((*position) != d_code_fin_chaine)
                   {
                       if (isalnum((*position)) != 0)
                       {
                           break;
                       }
   
                       position++;
                   }
   
                   // Vitesse
   
                   unsigned char   *vitesses[] =
                           { "50", "75", "110", "134", "150",
                           "200", "300", "600", "1200", "1800", "2400",
                           "4800", "9600", "19200", "38400",
   #ifdef B57600
                           "57600",
   #endif
   #ifdef B115200
                           "115200",
   #endif
   #ifdef B230400
                           "230400",
   #endif
                           NULL };
                   tcflag_t        vitesses_constantes[] =
                           { B50, B75, B110, B134, B150, B200, B300, B600,
                           B1200, B1800, B2400, B4800, B9600, B19200, B38400,
   #ifdef B57600
                           B57600,
   #endif
   #ifdef B115200
                           B115200,
   #endif
   #ifdef B230400
                           B230400,
   #endif
                           0 };
                   unsigned int    vitesse_courante;
   
                   vitesse_courante = 0;
   
                   while(vitesses[vitesse_courante] != NULL)
                   {
                       if (strncmp(position, vitesses[vitesse_courante],
                               strlen(vitesses[vitesse_courante])) == 0)
                       {
                           if (position[strlen(vitesses[vitesse_courante])] ==
                                   d_code_espace)
                           {
   #ifdef CBAUD
                               tc.c_cflag &= ~((tcflag_t) CBAUD);
                               tc.c_cflag |= vitesses_constantes[vitesse_courante];
   #else // POSIX
                               cfsetispeed(&tc,
                                       vitesses_constantes[vitesse_courante]);
                               cfsetospeed(&tc,
                                       vitesses_constantes[vitesse_courante]);
   #endif
                               position += strlen(vitesses[vitesse_courante]);
   
                               break;
                           }
                       }
   
                       vitesse_courante++;
                   }
   
                   if (vitesses[vitesse_courante] == NULL)
                   {
                       // La vitesse indiquée n'est pas une vitesse autorisée.
   
                       free(parametre_courant_majuscule);
                       liberation(s_etat_processus, s_objet_argument);
                       liberation(s_etat_processus, s_objet_resultat);
   
                       (*s_etat_processus).erreur_execution =
                               d_ex_erreur_parametre_fichier;
                       return;
                   }
   
                   // Nombre de bits par caractère.
   
                   while((*position) != d_code_fin_chaine)
                   {
                       if (isalnum((*position)) != 0)
                       {
                           break;
                       }
   
                       position++;
                   }
   
                   switch((*position))
                   {
                       case '5':
                       {
                           tc.c_cflag &= ~((tcflag_t) CSIZE);
                           tc.c_cflag |= CS5;
                           break;
                       }
   
                       case '6':
                       {
                           tc.c_cflag &= ~((tcflag_t) CSIZE);
                           tc.c_cflag |= CS6;
                           break;
                       }
   
                       case '7':
                       {
                           tc.c_cflag &= ~((tcflag_t) CSIZE);
                           tc.c_cflag |= CS7;
                           break;
                       }
   
                       case '8':
                       {
                           tc.c_cflag &= ~((tcflag_t) CSIZE);
                           tc.c_cflag |= CS8;
                           break;
                       }
   
                       default:
                       {
                           free(parametre_courant_majuscule);
                           liberation(s_etat_processus, s_objet_argument);
                           liberation(s_etat_processus, s_objet_resultat);
   
                           (*s_etat_processus).erreur_execution =
                                   d_ex_erreur_parametre_fichier;
                           return;
                       }
                   }
   
                   position++;
   
                   if ((*position) != d_code_espace)
                   {
                       free(parametre_courant_majuscule);
                       liberation(s_etat_processus, s_objet_argument);
                       liberation(s_etat_processus, s_objet_resultat);
   
                       (*s_etat_processus).erreur_execution =
                               d_ex_erreur_parametre_fichier;
                       return;
                   }
   
                   // Parité
   
                   while((*position) != d_code_fin_chaine)
                   {
                       if (isalnum((*position)) != 0)
                       {
                           break;
                       }
   
                       position++;
                   }
   
                   switch((*position))
                   {
                       case 'N':
                       {
                           tc.c_cflag &= ~((tcflag_t) PARENB);
                           break;
                       }
   
                       case 'O':
                       {
                           tc.c_cflag |= PARENB;
                           tc.c_cflag |= PARODD;
                           break;
                       }
   
                       case 'E':
                       {
                           tc.c_cflag |= PARENB;
                           tc.c_cflag &= ~((tcflag_t) PARODD);
                           break;
                       }
   
                       default:
                       {
                           free(parametre_courant_majuscule);
                           liberation(s_etat_processus, s_objet_argument);
                           liberation(s_etat_processus, s_objet_resultat);
   
                           (*s_etat_processus).erreur_execution =
                                   d_ex_erreur_parametre_fichier;
                           return;
                       }
                   }
   
                   position++;
   
                   if ((*position) != d_code_espace)
                   {
                       free(parametre_courant_majuscule);
                       liberation(s_etat_processus, s_objet_argument);
                       liberation(s_etat_processus, s_objet_resultat);
   
                       (*s_etat_processus).erreur_execution =
                               d_ex_erreur_parametre_fichier;
                       return;
                   }
   
                   // Bits de stop
   
                   while((*position) != d_code_fin_chaine)
                   {
                       if (isalnum((*position)) != 0)
                       {
                           break;
                       }
   
                       position++;
                   }
   
                   switch((*position))
                   {
                       case '1':
                       {
                           tc.c_cflag &= ~((tcflag_t) CSTOPB);
                           break;
                       }
   
                       case '2':
                       {
                           tc.c_cflag |= CSTOPB;
                           break;
                       }
   
                       default:
                       {
                           free(parametre_courant_majuscule);
                           liberation(s_etat_processus, s_objet_argument);
                           liberation(s_etat_processus, s_objet_resultat);
   
                           (*s_etat_processus).erreur_execution =
                                   d_ex_erreur_parametre_fichier;
                           return;
                       }
                   }
   
                   // S'il reste autre chose que des espaces, il y a un
                   // problème de paramètres.
   
                   position++;
   
                   while((*position) != d_code_fin_chaine)
                   {
                       if ((*position) != d_code_espace)
                       {
                           free(parametre_courant_majuscule);
                           liberation(s_etat_processus, s_objet_argument);
                           liberation(s_etat_processus, s_objet_resultat);
   
                           (*s_etat_processus).erreur_execution =
                                   d_ex_erreur_parametre_fichier;
                           return;
                       }
   
                       position++;
                   }
   
                   // Autres paramètres
   
                   free(parametre_courant_majuscule);
                   parametre_courant = (*parametre_courant).suivant;
   
                   if (parametre_courant != NULL)
                   {
                       parametre_courant = (*(*parametre_courant).donnee).objet;
                   }
   
                   while(parametre_courant != NULL)
                   {
                       if ((*(*parametre_courant).donnee).type != CHN)
                       {
                           liberation(s_etat_processus, s_objet_argument);
                           liberation(s_etat_processus, s_objet_resultat);
   
                           (*s_etat_processus).erreur_execution =
                                   d_ex_erreur_parametre_fichier;
                           return;
                       }
   
                       if ((parametre_courant_majuscule = conversion_majuscule(
                               (*(*parametre_courant).donnee).objet)) == NULL)
                       {
                           (*s_etat_processus).erreur_systeme =
                                   d_es_allocation_memoire;
                           return;
                       }
   
                       position = parametre_courant_majuscule;
                       negation = d_faux;
   
                       unsigned char   *fonctions[] =
                               { "IGNBRK", "BRKINT", "IGNPAR", "PARMRK",
                               "INPCK", "ISTRIP", "INLCR", "IGNCR", "ICRNL",
                               "IXON",
   #ifdef IXANY
                               "IXANY",
   #endif
                               "IXOFF", "OPOST",
                               "ONLCR", "OCRNL", "ONOCR", "ONLRET",
   #ifdef OFILL
                               "OFILL",
   #endif
                               "HUPCL", "CLOCAL",
   #ifdef CRTSCTS
                               "CRTSCTS",
   #endif
                               "ISIG", "ICANON", "ECHO", "ECHOE", "ECHOK",
                               "ECHONL", "NOFLSH", "TOSTOP", "IEXTEN", NULL };
                       tcflag_t        fonctions_constantes[] =
                               { /* c_iflag */
                               1, IGNBRK, 1, BRKINT, 1, IGNPAR, 1, PARMRK,
                               1, INPCK, 1, ISTRIP, 1, INLCR, 1, IGNCR, 1, ICRNL,
                               1, IXON,
   #ifdef IXANY
                               1, IXANY,
   #endif
                               1, IXOFF,
                               /* c_oflag */
                               2 , OPOST, 2, ONLCR, 2, OCRNL, 2, ONOCR, 2, ONLRET,
   #ifdef OFILL
                               2, OFILL,
   #endif
                               2, HUPCL,
                               /* c_cflag */
                               3, CLOCAL,
   #ifdef CRTSCTS
                               3, CRTSCTS,
   #endif
                               /* c_lfkag */
                               4, ISIG, 4, ICANON, 4, ECHO, 4, ECHOE, 4, ECHOK,
                               4, ECHONL, 4, NOFLSH, 4, TOSTOP, 4, IEXTEN };
                       unsigned int    fonction_courante;
   
                       // On vient de trouver quelque chose à interpréter.
   
                       if (strncmp(position, "NO ", 3) == 0)
                       {
                           position += 3;
                           negation = d_vrai;
                       }
   
                       for(fonction_courante = 0;
                               fonctions[fonction_courante] != NULL;
                               fonction_courante++)
                       {
                           if (strcmp(fonctions[fonction_courante], position)
                                   == 0)
                           {
                               if (negation == d_vrai)
                               {
                                   switch(fonctions_constantes
                                           [fonction_courante * 2])
                                   {
                                       case 1:
                                       {
                                           tc.c_iflag &= ~fonctions_constantes
                                                   [(fonction_courante * 2) + 1];
                                           break;
                                       }
   
                                       case 2:
                                       {
                                           tc.c_oflag &= ~fonctions_constantes
                                                   [(fonction_courante * 2) + 1];
                                           break;
                                       }
   
                                       case 3:
                                       {
                                           tc.c_cflag &= ~fonctions_constantes
                                                   [(fonction_courante * 2) + 1];
                                           break;
                                       }
   
                                       case 4:
                                       {
                                           tc.c_lflag &= ~fonctions_constantes
                                                   [(fonction_courante * 2) + 1];
                                           break;
                                       }
                                   }
                               }
                               else
                               {
                                   switch(fonctions_constantes
                                           [fonction_courante * 2])
                                   {
                                       case 1:
                                       {
                                           tc.c_iflag |= fonctions_constantes
                                                   [(fonction_courante * 2) + 1];
                                           break;
                                       }
   
                                       case 2:
                                       {
                                           tc.c_oflag |= fonctions_constantes
                                                   [(fonction_courante * 2) + 1];
                                           break;
                                       }
   
                                       case 3:
                                       {
                                           tc.c_cflag |= fonctions_constantes
                                                   [(fonction_courante * 2) + 1];
                                           break;
                                       }
   
                                       case 4:
                                       {
                                           tc.c_lflag |= fonctions_constantes
                                                   [(fonction_courante * 2) + 1];
                                           break;
                                       }
                                   }
                               }
   
                               break;
                           }
                       }
   
                       if (fonctions[fonction_courante] == NULL)
                       {
                           free(parametre_courant_majuscule);
                           liberation(s_etat_processus, s_objet_argument);
                           liberation(s_etat_processus, s_objet_resultat);
   
                           (*s_etat_processus).erreur_execution =
                                   d_ex_erreur_parametre_fichier;
                           return;
                       }
   
                       free(parametre_courant_majuscule);
                       parametre_courant = (*parametre_courant).suivant;
                   }
   
                   if (tcsetattr(fileno(descripteur), TCSANOW, &tc) != 0)
                   {
                       liberation(s_etat_processus, s_objet_argument);
                       liberation(s_etat_processus, s_objet_resultat);
   
                       (*s_etat_processus).erreur_systeme =
                               d_ex_erreur_fichier;
                       return;
                   }
               }
   
             strcpy((*((struct_fichier *) (*s_objet_resultat).objet)).nom, nom);              strcpy((*((struct_fichier *) (*s_objet_resultat).objet)).nom, nom);
             liberation(s_etat_processus, s_objet_argument);              liberation(s_etat_processus, s_objet_argument);
   
Line 3634  instruction_open(struct_processus *s_eta Line 4309  instruction_open(struct_processus *s_eta
                     return;                      return;
                 }                  }
   
                 prochain_descripteur = i;                  prochain_descripteur = (int) i;
   
                 /*                  /*
                  * Ajout d'un élément à la fin de la liste chaînée                   * Ajout d'un élément à la fin de la liste chaînée
Line 3724  instruction_open(struct_processus *s_eta Line 4399  instruction_open(struct_processus *s_eta
 #                   ifdef SO_BINDTODEVICE  #                   ifdef SO_BINDTODEVICE
                         if (setsockopt((*((struct_socket *) (*s_objet_resultat)                          if (setsockopt((*((struct_socket *) (*s_objet_resultat)
                                 .objet)).socket, SOL_SOCKET, SO_BINDTODEVICE,                                  .objet)).socket, SOL_SOCKET, SO_BINDTODEVICE,
                                 peripherique, strlen(peripherique)) != 0)                                  peripherique, (socklen_t) strlen(peripherique))
                                   != 0)
                         {                          {
                             liberation(s_etat_processus, s_objet_argument);                              liberation(s_etat_processus, s_objet_argument);
                             liberation(s_etat_processus, s_objet_resultat);                              liberation(s_etat_processus, s_objet_resultat);
Line 4006  instruction_open(struct_processus *s_eta Line 4682  instruction_open(struct_processus *s_eta
                 return;                  return;
             }              }
   
               if ((type_adresse == ' ') && (type_domaine == 'L'))
               {
                   if (strcmp(protocole, "IPV4") == 0)
                   {
                       for(i = 0; i < 4; adresse[i++] = 0);
                       type_adresse = '4';
                   }
                   else if (strcmp(protocole, "IPV6") == 0)
                   {
                       for(i = 0; i < 16; adresse[i++] = 0);
                       type_adresse = '6';
                   }
                   else if (strcmp(protocole, "UNIX") != 0)
                   {
                       liberation(s_etat_processus, s_objet_argument);
   
                       (*s_etat_processus).erreur_execution =
                               d_ex_erreur_parametre_fichier;
                       return;
                   }
               }
   
             if (((strcmp(protocole, "IPV4") == 0) && (type_adresse == '6')) ||              if (((strcmp(protocole, "IPV4") == 0) && (type_adresse == '6')) ||
                     ((strcmp(protocole, "IPV6") == 0) && (type_adresse == '4')))                      ((strcmp(protocole, "IPV6") == 0) && (type_adresse == '4')))
             {              {
Line 4037  instruction_open(struct_processus *s_eta Line 4735  instruction_open(struct_processus *s_eta
             }              }
             else              else
             {              {
                 for(i = 0; i < strlen(protocole_socket); i++)                  if (strcmp(protocole_socket, "IPV4") == 0)
                 {  
                     if ((protocole_socket[i] >= 'A') &&  
                             (protocole_socket[i] <= 'Z'))  
                     {  
                         protocole_socket[i] += 'a' - 'A';  
                     }  
                 }  
   
                 if (strcmp(protocole_socket, "ipv4") == 0)  
                 {                  {
                     protocole_socket[2] = d_code_fin_chaine;                      protocole_socket[2] = d_code_fin_chaine;
                       protocole_numerique = 0;
                 }                  }
                   else
                 if ((s_protocole = getprotobyname(protocole_socket)) == NULL)  
                 {                  {
                     liberation(s_etat_processus, s_objet_argument);                      if ((s_protocole = getprotobyname(protocole_socket))
                               == NULL)
                       {
                           liberation(s_etat_processus, s_objet_argument);
   
                     (*s_etat_processus).erreur_execution =                          (*s_etat_processus).erreur_execution =
                             d_ex_erreur_parametre_fichier;                                  d_ex_erreur_parametre_fichier;
                     return;                          return;
                 }                      }
   
                 protocole_numerique = (*s_protocole).p_proto;                      protocole_numerique = (*s_protocole).p_proto;
                   }
             }              }
   
             if ((s_objet_resultat = allocation(s_etat_processus, SCK))              if ((s_objet_resultat = allocation(s_etat_processus, SCK))
Line 4082  instruction_open(struct_processus *s_eta Line 4775  instruction_open(struct_processus *s_eta
                     = protection;                      = protection;
             (*(*((struct_socket *) (*s_objet_resultat).objet))              (*(*((struct_socket *) (*s_objet_resultat).objet))
                     .format).objet = NULL;                      .format).objet = NULL;
               (*((struct_socket *) (*s_objet_resultat).objet)).adresse = NULL;
   
             switch(type_socket)              switch(type_socket)
             {              {
Line 4345  instruction_open(struct_processus *s_eta Line 5039  instruction_open(struct_processus *s_eta
                                 return;                                  return;
                             }                              }
   
                               free((*((struct_socket *) (*s_objet_resultat)
                                       .objet)).adresse);
   
                             if (((*((struct_socket *) (*s_objet_resultat)                              if (((*((struct_socket *) (*s_objet_resultat)
                                     .objet)).adresse = malloc(22 *                                      .objet)).adresse = malloc(22 *
                                     sizeof(unsigned char))) == NULL)                                      sizeof(unsigned char))) == NULL)
Line 4449  instruction_open(struct_processus *s_eta Line 5146  instruction_open(struct_processus *s_eta
                                 return;                                  return;
                             }                              }
   
                               free((*((struct_socket *) (*s_objet_resultat)
                                       .objet)).adresse);
   
                             if (((*((struct_socket *) (*s_objet_resultat)                              if (((*((struct_socket *) (*s_objet_resultat)
                                     .objet)).adresse = malloc(55 *                                      .objet)).adresse = malloc(55 *
                                     sizeof(unsigned char))) == NULL)                                      sizeof(unsigned char))) == NULL)
Line 4480  instruction_open(struct_processus *s_eta Line 5180  instruction_open(struct_processus *s_eta
                                 printf("+++Warning : IPv6 support "                                  printf("+++Warning : IPv6 support "
                                         "unavailable\n");                                          "unavailable\n");
                             }                              }
   
                               liberation(s_etat_processus, s_objet_argument);
                               liberation(s_etat_processus, s_objet_resultat);
   
                               freeaddrinfo(resolution);
   
                               (*s_etat_processus).erreur_execution =
                                       d_ex_instruction_indisponible;
                               return;
 #                           endif  #                           endif
                         }                          }
   
Line 4494  instruction_open(struct_processus *s_eta Line 5203  instruction_open(struct_processus *s_eta
                     { // Hôte défini par une adresse                      { // Hôte défini par une adresse
                         if (strcmp(protocole, "IPV4") == 0)                          if (strcmp(protocole, "IPV4") == 0)
                         { // Accès en IPv4                          { // Accès en IPv4
                               free((*((struct_socket *) (*s_objet_resultat)
                                       .objet)).adresse);
   
                             if (((*((struct_socket *) (*s_objet_resultat)                              if (((*((struct_socket *) (*s_objet_resultat)
                                     .objet)).adresse = malloc(22 *                                      .objet)).adresse = malloc(22 *
                                     sizeof(unsigned char))) == NULL)                                      sizeof(unsigned char))) == NULL)
Line 4542  instruction_open(struct_processus *s_eta Line 5254  instruction_open(struct_processus *s_eta
   
                             adresse_ipv4 = 0;                              adresse_ipv4 = 0;
                             for(i = 0; i < 4; adresse_ipv4 =                              for(i = 0; i < 4; adresse_ipv4 =
                                     (256 * adresse_ipv4) + adresse[i++]);                                      (256 * adresse_ipv4) +
                                       ((unsigned char) adresse[i++]));
   
                             socket_ipv4.sin_addr.s_addr = htonl(adresse_ipv4);                              socket_ipv4.sin_addr.s_addr = htonl(adresse_ipv4);
   
Line 4569  instruction_open(struct_processus *s_eta Line 5282  instruction_open(struct_processus *s_eta
                         else                          else
                         { // Accès en IPv6                          { // Accès en IPv6
 #                           ifdef IPV6  #                           ifdef IPV6
                               free((*((struct_socket *) (*s_objet_resultat)
                                       .objet)).adresse);
   
                             if (((*((struct_socket *) (*s_objet_resultat)                              if (((*((struct_socket *) (*s_objet_resultat)
                                     .objet)).adresse = malloc(55 *                                      .objet)).adresse = malloc(55 *
                                     sizeof(unsigned char))) == NULL)                                      sizeof(unsigned char))) == NULL)
Line 4650  instruction_open(struct_processus *s_eta Line 5366  instruction_open(struct_processus *s_eta
                                 printf("+++Warning : IPv6 support "                                  printf("+++Warning : IPv6 support "
                                         "unavailable\n");                                          "unavailable\n");
                             }                              }
                               
                               liberation(s_etat_processus, s_objet_argument);
                               liberation(s_etat_processus, s_objet_resultat);
   
                               (*s_etat_processus).erreur_execution =
                                       d_ex_instruction_indisponible;
                               return;
 #                           endif  #                           endif
                         }                          }
                     }                      }
Line 4883  instruction_open(struct_processus *s_eta Line 5606  instruction_open(struct_processus *s_eta
                                         .socket_en_ecoute = 'N';                                          .socket_en_ecoute = 'N';
                             }                              }
   
                               free((*((struct_socket *) (*s_objet_resultat)
                                       .objet)).adresse);
   
                             if (((*((struct_socket *) (*s_objet_resultat)                              if (((*((struct_socket *) (*s_objet_resultat)
                                     .objet)).adresse = malloc(22 *                                      .objet)).adresse = malloc(22 *
                                     sizeof(unsigned char))) == NULL)                                      sizeof(unsigned char))) == NULL)
Line 4989  instruction_open(struct_processus *s_eta Line 5715  instruction_open(struct_processus *s_eta
                                         .socket_en_ecoute = 'N';                                          .socket_en_ecoute = 'N';
                             }                              }
   
                               free((*((struct_socket *) (*s_objet_resultat)
                                       .objet)).adresse);
   
                             if (((*((struct_socket *) (*s_objet_resultat)                              if (((*((struct_socket *) (*s_objet_resultat)
                                     .objet)).adresse = malloc(55 *                                      .objet)).adresse = malloc(55 *
                                     sizeof(unsigned char))) == NULL)                                      sizeof(unsigned char))) == NULL)
Line 5020  instruction_open(struct_processus *s_eta Line 5749  instruction_open(struct_processus *s_eta
                                 printf("+++Warning : IPv6 support "                                  printf("+++Warning : IPv6 support "
                                         "unavailable\n");                                          "unavailable\n");
                             }                              }
   
                               liberation(s_etat_processus, s_objet_argument);
                               liberation(s_etat_processus, s_objet_resultat);
   
                               freeaddrinfo(resolution);
   
                               (*s_etat_processus).erreur_execution =
                                       d_ex_instruction_indisponible;
                               return;
 #                           endif  #                           endif
                         }                          }
   
Line 5036  instruction_open(struct_processus *s_eta Line 5774  instruction_open(struct_processus *s_eta
                         { // Accès en IPv4                          { // Accès en IPv4
                             if (type_adresse == '4')                              if (type_adresse == '4')
                             {                              {
                                   free((*((struct_socket *) (*s_objet_resultat)
                                           .objet)).adresse);
   
                                 if (((*((struct_socket *) (*s_objet_resultat)                                  if (((*((struct_socket *) (*s_objet_resultat)
                                         .objet)).adresse = malloc(22 *                                          .objet)).adresse = malloc(22 *
                                         sizeof(unsigned char))) == NULL)                                          sizeof(unsigned char))) == NULL)
Line 5065  instruction_open(struct_processus *s_eta Line 5806  instruction_open(struct_processus *s_eta
                             }                              }
                             else                              else
                             {                              {
                                   free((*((struct_socket *) (*s_objet_resultat)
                                           .objet)).adresse);
   
                                 if (((*((struct_socket *) (*s_objet_resultat)                                  if (((*((struct_socket *) (*s_objet_resultat)
                                         .objet)).adresse = malloc(                                          .objet)).adresse = malloc(
                                         sizeof(unsigned char))) == NULL)                                          sizeof(unsigned char))) == NULL)
Line 5100  instruction_open(struct_processus *s_eta Line 5844  instruction_open(struct_processus *s_eta
   
                             adresse_ipv4 = 0;                              adresse_ipv4 = 0;
                             for(i = 0; i < 4; adresse_ipv4 =                              for(i = 0; i < 4; adresse_ipv4 =
                                     (256 * adresse_ipv4) + adresse[i++]);                                      (256 * adresse_ipv4)
                                       + ((unsigned char) adresse[i++]));
   
                             socket_ipv4.sin_addr.s_addr = htonl(adresse_ipv4);                              socket_ipv4.sin_addr.s_addr = htonl(adresse_ipv4);
   
Line 5132  instruction_open(struct_processus *s_eta Line 5877  instruction_open(struct_processus *s_eta
 #                           ifdef IPV6  #                           ifdef IPV6
                             if (type_adresse == '6')                              if (type_adresse == '6')
                             {                              {
                                   free((*((struct_socket *) (*s_objet_resultat)
                                           .objet)).adresse);
   
                                 if (((*((struct_socket *) (*s_objet_resultat)                                  if (((*((struct_socket *) (*s_objet_resultat)
                                         .objet)).adresse = malloc(55 *                                          .objet)).adresse = malloc(55 *
                                         sizeof(unsigned char))) == NULL)                                          sizeof(unsigned char))) == NULL)
Line 5162  instruction_open(struct_processus *s_eta Line 5910  instruction_open(struct_processus *s_eta
                             }                              }
                             else                              else
                             {                              {
                                   free((*((struct_socket *) (*s_objet_resultat)
                                           .objet)).adresse);
   
                                 if (((*((struct_socket *) (*s_objet_resultat)                                  if (((*((struct_socket *) (*s_objet_resultat)
                                         .objet)).adresse = malloc(                                          .objet)).adresse = malloc(
                                         sizeof(unsigned char))) == NULL)                                          sizeof(unsigned char))) == NULL)
Line 5232  instruction_open(struct_processus *s_eta Line 5983  instruction_open(struct_processus *s_eta
                                 printf("+++Warning : IPv6 support "                                  printf("+++Warning : IPv6 support "
                                         "unavailable\n");                                          "unavailable\n");
                             }                              }
   
                               liberation(s_etat_processus, s_objet_argument);
                               liberation(s_etat_processus, s_objet_resultat);
   
                               (*s_etat_processus).erreur_execution =
                                       d_ex_instruction_indisponible;
                               return;
 #                           endif  #                           endif
                         }                          }
                         else                          else
                         { // Socket UNIX                          { // Socket UNIX
                               free((*((struct_socket *) (*s_objet_resultat)
                                       .objet)).adresse);
   
                             if (((*((struct_socket *) (*s_objet_resultat)                              if (((*((struct_socket *) (*s_objet_resultat)
                                     .objet)).adresse = malloc(                                      .objet)).adresse = malloc(
                                     sizeof(unsigned char))) == NULL)                                      sizeof(unsigned char))) == NULL)

Removed from v.1.34  
changed lines
  Added in v.1.76


CVSweb interface <joel.bertrand@systella.fr>