Diff for /rpl/src/instructions_o1.c between versions 1.20 and 1.45

version 1.20, 2010/08/13 21:00:37 version 1.45, 2012/02/23 13:05:08
Line 1 Line 1
 /*  /*
 ================================================================================  ================================================================================
   RPL/2 (R) version 4.0.18    RPL/2 (R) version 4.1.6
   Copyright (C) 1989-2010 Dr. BERTRAND Joël    Copyright (C) 1989-2012 Dr. BERTRAND Joël
   
   This file is part of RPL/2.    This file is part of RPL/2.
   
Line 897  instruction_open(struct_processus *s_eta Line 897  instruction_open(struct_processus *s_eta
      * Format :       * Format :
      *   FORMATTED   : fichier texte ;       *   FORMATTED   : fichier texte ;
      *   UNFORMATTED : fichier binaire.       *   UNFORMATTED : fichier binaire.
        *   FLOW        : chaîne de caractères sans format (en tant qu'objet
        *                 binaire comme "\x00avz\xFD")
      */       */
   
     file                        *descripteur;      file                        *descripteur;
Line 940  instruction_open(struct_processus *s_eta Line 942  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 1017  instruction_open(struct_processus *s_eta Line 1022  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\" { \"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");
Line 1029  instruction_open(struct_processus *s_eta Line 1037  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, VEOF, VEOL, VERASE, VINTR, VKILL,\n");
           printf("            VQUIT, VSTART, VSTOP, VSUSP\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 1059  instruction_open(struct_processus *s_eta Line 1075  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("    { \"/dev/ttyS1\" { \"STTY\" { \"9600,8,N,1\" "
                   "\"NO ICANON\" \"IGNBRK\" } }\n");
   
         return;          return;
     }      }
Line 1119  instruction_open(struct_processus *s_eta Line 1137  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 1190  instruction_open(struct_processus *s_eta Line 1209  instruction_open(struct_processus *s_eta
   
                     type_ouverture = 'R';                      type_ouverture = 'R';
                 }                  }
                   else if (strcmp(argument_majuscule, "OLD") == 0)
                   {
                       if (type_ouverture != ' ')
                       {
                           liberation(s_etat_processus, s_objet_argument);
                           free(argument_majuscule);
   
                           (*s_etat_processus).erreur_execution =
                                   d_ex_erreur_parametre_fichier;
                           return;
                       }
   
                       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;
                       }
   
                       type_ouverture = 'O';
                   }
                 else if (strcmp(argument_majuscule, "UNKNOWN") == 0)                  else if (strcmp(argument_majuscule, "UNKNOWN") == 0)
                 {                  {
                     if (type_ouverture != ' ')                      if (type_ouverture != ' ')
Line 1942  instruction_open(struct_processus *s_eta Line 1989  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] -= 'a' - 'A';
                                       }
                                   }
                             }                              }
                             else                              else
                             {                              {
Line 2210  instruction_open(struct_processus *s_eta Line 2266  instruction_open(struct_processus *s_eta
                                 }                                  }
                             }                              }
                         }                          }
                           else if (strcmp(argument_majuscule, "STTY") == 0)
                           {
                               if ((*(*l_element_courant_sous_objet)
                                       .donnee).type == LST)
                               {
                                   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_sous_objet).donnee;
                               }
                           }
                         else                          else
                         {                          {
                             liberation(s_etat_processus, s_objet_argument);                              liberation(s_etat_processus, s_objet_argument);
Line 2782  instruction_open(struct_processus *s_eta Line 2862  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 2888  instruction_open(struct_processus *s_eta Line 2975  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 3027  instruction_open(struct_processus *s_eta Line 3121  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 3138  instruction_open(struct_processus *s_eta Line 3239  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 3232  instruction_open(struct_processus *s_eta Line 3340  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 3310  instruction_open(struct_processus *s_eta Line 3425  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 3398  instruction_open(struct_processus *s_eta Line 3520  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;
                   }
               }
   
             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 3976  instruction_open(struct_processus *s_eta Line 4113  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
                   {
                       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 4007  instruction_open(struct_processus *s_eta Line 4166  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;
                 }                  }
Line 4185  instruction_open(struct_processus *s_eta Line 4335  instruction_open(struct_processus *s_eta
                         pointeur++;                          pointeur++;
                     }                      }
   
                     strncpy(socket_unix.sun_path, pointeur, 108);                      strncpy(socket_unix.sun_path, pointeur, UNIX_PATH_MAX);
                     socket_unix.sun_path[108 - 1] = d_code_fin_chaine;                      socket_unix.sun_path[UNIX_PATH_MAX - 1] = d_code_fin_chaine;
   
                     if (options_socket() == d_erreur)                      if (options_socket() == d_erreur)
                     {                      {
Line 4447  instruction_open(struct_processus *s_eta Line 4597  instruction_open(struct_processus *s_eta
                             }                              }
                             else                              else
                             {                              {
                                 printf("+++Attention : IPv6 support "                                  printf("+++Warning : IPv6 support "
                                         "unavailable\n");                                          "unavailable\n");
                             }                              }
 #                           endif  #                           endif
Line 4617  instruction_open(struct_processus *s_eta Line 4767  instruction_open(struct_processus *s_eta
                             }                              }
                             else                              else
                             {                              {
                                 printf("+++Attention : IPv6 support "                                  printf("+++Warning : IPv6 support "
                                         "unavailable\n");                                          "unavailable\n");
                             }                              }
 #                           endif  #                           endif
Line 4724  instruction_open(struct_processus *s_eta Line 4874  instruction_open(struct_processus *s_eta
   
                     socket_unix.sun_family = AF_UNIX;                      socket_unix.sun_family = AF_UNIX;
                     strncpy(socket_unix.sun_path, (*((struct_socket *)                      strncpy(socket_unix.sun_path, (*((struct_socket *)
                             (*s_objet_resultat).objet)).adresse, 108);                              (*s_objet_resultat).objet)).adresse, UNIX_PATH_MAX);
                     socket_unix.sun_path[108 - 1] = d_code_fin_chaine;                      socket_unix.sun_path[UNIX_PATH_MAX - 1] = d_code_fin_chaine;
   
                     if ((type_socket == 'S') || (type_socket == 'Q'))                      if ((type_socket == 'S') || (type_socket == 'Q'))
                     {                      {
Line 4987  instruction_open(struct_processus *s_eta Line 5137  instruction_open(struct_processus *s_eta
                             }                              }
                             else                              else
                             {                              {
                                 printf("+++Attention : IPv6 support "                                  printf("+++Warning : IPv6 support "
                                         "unavailable\n");                                          "unavailable\n");
                             }                              }
 #                           endif  #                           endif
Line 5199  instruction_open(struct_processus *s_eta Line 5349  instruction_open(struct_processus *s_eta
                             }                              }
                             else                              else
                             {                              {
                                 printf("+++Attention : IPv6 support "                                  printf("+++Warning : IPv6 support "
                                         "unavailable\n");                                          "unavailable\n");
                             }                              }
 #                           endif  #                           endif

Removed from v.1.20  
changed lines
  Added in v.1.45


CVSweb interface <joel.bertrand@systella.fr>