Diff for /rpl/src/instructions_o1.c between versions 1.48 and 1.52

version 1.48, 2012/02/24 15:02:54 version 1.52, 2012/04/13 14:12:57
Line 1 Line 1
 /*  /*
 ================================================================================  ================================================================================
   RPL/2 (R) version 4.1.6    RPL/2 (R) version 4.1.8
   Copyright (C) 1989-2012 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 1078  instruction_open(struct_processus *s_eta Line 1078  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\" "          printf("    { { \"NAME\" \"/dev/ttyS1\" } { \"STTY\" { \"9600,8,N,1\" "
                 "\"NO ICANON\" \"IGNBRK\" } }\n");                  "\n            { \"NO ICANON\" \"IGNBRK\" } } } OPEN\n");
   
         return;          return;
     }      }
Line 2272  instruction_open(struct_processus *s_eta Line 2272  instruction_open(struct_processus *s_eta
                         else if (strcmp(argument_majuscule, "STTY") == 0)                          else if (strcmp(argument_majuscule, "STTY") == 0)
                         {                          {
                             if ((*(*l_element_courant_sous_objet)                              if ((*(*l_element_courant_sous_objet)
                                     .donnee).type == LST)                                      .donnee).type == CHN)
                             {                              {
                                 if (type_arguments == ' ')                                  if (type_arguments == ' ')
                                 {                                  {
Line 2289  instruction_open(struct_processus *s_eta Line 2289  instruction_open(struct_processus *s_eta
                                     return;                                      return;
                                 }                                  }
   
                                 s_parametres_tty =                                  s_parametres_tty = (*l_element_courant).donnee;
                                         (*l_element_courant_sous_objet).donnee;  
                             }                              }
                         }                          }
                         else                          else
Line 2646  instruction_open(struct_processus *s_eta Line 2645  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 3537  instruction_open(struct_processus *s_eta Line 3582  instruction_open(struct_processus *s_eta
                     return;                      return;
                 }                  }
   
                 parametre_courant = (*s_parametres_tty).objet;                  // 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                  // Le premier paramètre concerne la vitesse du port. Il doit
                 // toujours être présent.                  // toujours être présent.
Line 3600  instruction_open(struct_processus *s_eta Line 3649  instruction_open(struct_processus *s_eta
                 // Vitesse                  // Vitesse
   
                 unsigned char   *vitesses[] =                  unsigned char   *vitesses[] =
                         { "B0", "B50", "B75", "B110", "B134", "B150",                          { "0", "50", "75", "110", "134", "150",
                         "B200", "B300", "B600", "B1200", "B1800", "B2400",                          "200", "300", "600", "1200", "1800", "2400",
                         "B4800", "B9600", "B19200", "B38400", "B57600",                          "4800", "9600", "19200", "38400", "57600",
                         "B115200", "B230400", NULL };                          "115200", "230400", NULL };
                 int             vitesses_constantes[] =                  int             vitesses_constantes[] =
                         { B0, B50, B75, B110, B134, B150, B200, B300, B600,                          { B0, B50, B75, B110, B134, B150, B200, B300, B600,
                         B1200, B1800, B2400, B4800, B9600, B19200, B38400,                          B1200, B1800, B2400, B4800, B9600, B19200, B38400,
Line 3757  instruction_open(struct_processus *s_eta Line 3806  instruction_open(struct_processus *s_eta
                     }                      }
                 }                  }
   
                   position++;
   
                 if ((*position) != d_code_espace)                  if ((*position) != d_code_espace)
                 {                  {
                     free(parametre_courant_majuscule);                      free(parametre_courant_majuscule);
Line 3809  instruction_open(struct_processus *s_eta Line 3860  instruction_open(struct_processus *s_eta
                 // S'il reste autre chose que des espaces, il y a un                  // S'il reste autre chose que des espaces, il y a un
                 // problème de paramètres.                  // problème de paramètres.
   
                   position++;
   
                 while((*position) != d_code_fin_chaine)                  while((*position) != d_code_fin_chaine)
                 {                  {
                     if ((*position) != d_code_espace)                      if ((*position) != d_code_espace)
Line 3830  instruction_open(struct_processus *s_eta Line 3883  instruction_open(struct_processus *s_eta
                 free(parametre_courant_majuscule);                  free(parametre_courant_majuscule);
                 parametre_courant = (*parametre_courant).suivant;                  parametre_courant = (*parametre_courant).suivant;
   
                   if (parametre_courant != NULL)
                   {
                       parametre_courant = (*(*parametre_courant).donnee).objet;
                   }
   
                 while(parametre_courant != NULL)                  while(parametre_courant != NULL)
                 {                  {
                     if ((*(*parametre_courant).donnee).type != CHN)                      if ((*(*parametre_courant).donnee).type != CHN)
Line 3876  instruction_open(struct_processus *s_eta Line 3934  instruction_open(struct_processus *s_eta
                             4, ECHONL, 4, NOFLSH, 4, TOSTOP, 4, IEXTEN };                              4, ECHONL, 4, NOFLSH, 4, TOSTOP, 4, IEXTEN };
                     unsigned int    fonction_courante;                      unsigned int    fonction_courante;
   
                     if (isalnum((*position)) != 0)                      // On vient de trouver quelque chose à interpréter.
                     {  
                         // On vient de trouver quelque chose à interpréter.  
   
                         if (strncmp(position, "NO ", 3) == 0)                      if (strncmp(position, "NO ", 3) == 0)
                         {                      {
                             position += 3;                          position += 3;
                             negation = d_vrai;                          negation = d_vrai;
                         }  
                     }                      }
   
                     for(fonction_courante = 0;                      for(fonction_courante = 0;
Line 3902  instruction_open(struct_processus *s_eta Line 3957  instruction_open(struct_processus *s_eta
                                     case 1:                                      case 1:
                                     {                                      {
                                         tc.c_iflag &= ~fonctions_constantes                                          tc.c_iflag &= ~fonctions_constantes
                                                 [(fonction_courante * 2) - 1];                                                  [(fonction_courante * 2) + 1];
                                         break;                                          break;
                                     }                                      }
   
                                     case 2:                                      case 2:
                                     {                                      {
                                         tc.c_oflag &= ~fonctions_constantes                                          tc.c_oflag &= ~fonctions_constantes
                                                 [(fonction_courante * 2) - 1];                                                  [(fonction_courante * 2) + 1];
                                         break;                                          break;
                                     }                                      }
   
                                     case 3:                                      case 3:
                                     {                                      {
                                         tc.c_cflag &= ~fonctions_constantes                                          tc.c_cflag &= ~fonctions_constantes
                                                 [(fonction_courante * 2) - 1];                                                  [(fonction_courante * 2) + 1];
                                         break;                                          break;
                                     }                                      }
   
                                     case 4:                                      case 4:
                                     {                                      {
                                         tc.c_lflag &= ~fonctions_constantes                                          tc.c_lflag &= ~fonctions_constantes
                                                 [(fonction_courante * 2) - 1];                                                  [(fonction_courante * 2) + 1];
                                         break;                                          break;
                                     }                                      }
                                 }                                  }
Line 3936  instruction_open(struct_processus *s_eta Line 3991  instruction_open(struct_processus *s_eta
                                     case 1:                                      case 1:
                                     {                                      {
                                         tc.c_iflag |= fonctions_constantes                                          tc.c_iflag |= fonctions_constantes
                                                 [(fonction_courante * 2) - 1];                                                  [(fonction_courante * 2) + 1];
                                         break;                                          break;
                                     }                                      }
   
                                     case 2:                                      case 2:
                                     {                                      {
                                         tc.c_oflag |= fonctions_constantes                                          tc.c_oflag |= fonctions_constantes
                                                 [(fonction_courante * 2) - 1];                                                  [(fonction_courante * 2) + 1];
                                         break;                                          break;
                                     }                                      }
   
                                     case 3:                                      case 3:
                                     {                                      {
                                         tc.c_cflag |= fonctions_constantes                                          tc.c_cflag |= fonctions_constantes
                                                 [(fonction_courante * 2) - 1];                                                  [(fonction_courante * 2) + 1];
                                         break;                                          break;
                                     }                                      }
   
                                     case 4:                                      case 4:
                                     {                                      {
                                         tc.c_lflag |= fonctions_constantes                                          tc.c_lflag |= fonctions_constantes
                                                 [(fonction_courante * 2) - 1];                                                  [(fonction_courante * 2) + 1];
                                         break;                                          break;
                                     }                                      }
                                 }                                  }
Line 4660  instruction_open(struct_processus *s_eta Line 4715  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 4923  instruction_open(struct_processus *s_eta Line 4979  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 5027  instruction_open(struct_processus *s_eta Line 5086  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 5058  instruction_open(struct_processus *s_eta Line 5120  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 5072  instruction_open(struct_processus *s_eta Line 5143  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 5147  instruction_open(struct_processus *s_eta Line 5221  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 5228  instruction_open(struct_processus *s_eta Line 5305  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 5461  instruction_open(struct_processus *s_eta Line 5545  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 5567  instruction_open(struct_processus *s_eta Line 5654  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 5598  instruction_open(struct_processus *s_eta Line 5688  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 5614  instruction_open(struct_processus *s_eta Line 5713  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 5643  instruction_open(struct_processus *s_eta Line 5745  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 5710  instruction_open(struct_processus *s_eta Line 5815  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 5740  instruction_open(struct_processus *s_eta Line 5848  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 5810  instruction_open(struct_processus *s_eta Line 5921  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.48  
changed lines
  Added in v.1.52


CVSweb interface <joel.bertrand@systella.fr>