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

version 1.52, 2012/04/13 14:12:57 version 1.75, 2014/01/26 18:21:32
Line 1 Line 1
 /*  /*
 ================================================================================  ================================================================================
   RPL/2 (R) version 4.1.8    RPL/2 (R) version 4.1.17
   Copyright (C) 1989-2012 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 973  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 1028  instruction_open(struct_processus *s_eta Line 1028  instruction_open(struct_processus *s_eta
                 "\"file name\" } \"protection\" } OPEN\n");                  "\"file name\" } \"protection\" } OPEN\n");
         printf("    { \"filetype\" \"access\" \"format\" { \"name\" "          printf("    { \"filetype\" \"access\" \"format\" { \"name\" "
                 "\"file name\" } \n"                  "\"file name\" } \n"
                 "           { \"stty\" { \"stty parameters\" ... } } } OPEN\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 1069  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 1078  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\" "          printf("    { { \"NAME\" \"/dev/ttyS1\" } { \"STTY\" \"9600,8,N,1\" "
                 "\n            { \"NO ICANON\" \"IGNBRK\" } } } OPEN\n");                  "\n            { \"NO ICANON\" \"IGNBRK\" } } } OPEN\n");
   
         return;          return;
Line 1998  instruction_open(struct_processus *s_eta Line 1999  instruction_open(struct_processus *s_eta
                                     if ((protocole_socket[i] >= 'a') &&                                      if ((protocole_socket[i] >= 'a') &&
                                             (protocole_socket[i] <= 'z'))                                              (protocole_socket[i] <= 'z'))
                                     {                                      {
                                         protocole_socket[i] -= 'a' - 'A';                                          protocole_socket[i] = (unsigned char)
                                                   (protocole_socket[i]
                                                   - ('a' - 'A'));
                                     }                                      }
                                 }                                  }
                             }                              }
Line 2141  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 2731  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 3649  instruction_open(struct_processus *s_eta Line 3659  instruction_open(struct_processus *s_eta
                 // Vitesse                  // Vitesse
   
                 unsigned char   *vitesses[] =                  unsigned char   *vitesses[] =
                         { "0", "50", "75", "110", "134", "150",                          { "50", "75", "110", "134", "150",
                         "200", "300", "600", "1200", "1800", "2400",                          "200", "300", "600", "1200", "1800", "2400",
                         "4800", "9600", "19200", "38400", "57600",                          "4800", "9600", "19200", "38400",
                         "115200", "230400", NULL };  #ifdef B57600
                 int             vitesses_constantes[] =                          "57600",
                         { B0, B50, B75, B110, B134, B150, B200, B300, B600,  #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,                          B1200, B1800, B2400, B4800, B9600, B19200, B38400,
                         B57600, B115200, B230400, 0 };  #ifdef B57600
                           B57600,
   #endif
   #ifdef B115200
                           B115200,
   #endif
   #ifdef B230400
                           B230400,
   #endif
                           0 };
                 unsigned int    vitesse_courante;                  unsigned int    vitesse_courante;
   
                 vitesse_courante = 0;                  vitesse_courante = 0;
Line 3669  instruction_open(struct_processus *s_eta Line 3697  instruction_open(struct_processus *s_eta
                         if (position[strlen(vitesses[vitesse_courante])] ==                          if (position[strlen(vitesses[vitesse_courante])] ==
                                 d_code_espace)                                  d_code_espace)
                         {                          {
                             tc.c_cflag &= ~CBAUD;  #ifdef CBAUD
                               tc.c_cflag &= ~((tcflag_t) CBAUD);
                             tc.c_cflag |= vitesses_constantes[vitesse_courante];                              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]);                              position += strlen(vitesses[vitesse_courante]);
   
                             break;                              break;
Line 3709  instruction_open(struct_processus *s_eta Line 3744  instruction_open(struct_processus *s_eta
                 {                  {
                     case '5':                      case '5':
                     {                      {
                         tc.c_cflag &= ~CSIZE;                          tc.c_cflag &= ~((tcflag_t) CSIZE);
                         tc.c_cflag |= CS5;                          tc.c_cflag |= CS5;
                         break;                          break;
                     }                      }
   
                     case '6':                      case '6':
                     {                      {
                         tc.c_cflag &= ~CSIZE;                          tc.c_cflag &= ~((tcflag_t) CSIZE);
                         tc.c_cflag |= CS6;                          tc.c_cflag |= CS6;
                         break;                          break;
                     }                      }
   
                     case '7':                      case '7':
                     {                      {
                         tc.c_cflag &= ~CSIZE;                          tc.c_cflag &= ~((tcflag_t) CSIZE);
                         tc.c_cflag |= CS7;                          tc.c_cflag |= CS7;
                         break;                          break;
                     }                      }
   
                     case '8':                      case '8':
                     {                      {
                         tc.c_cflag &= ~CSIZE;                          tc.c_cflag &= ~((tcflag_t) CSIZE);
                         tc.c_cflag |= CS8;                          tc.c_cflag |= CS8;
                         break;                          break;
                     }                      }
Line 3776  instruction_open(struct_processus *s_eta Line 3811  instruction_open(struct_processus *s_eta
                 {                  {
                     case 'N':                      case 'N':
                     {                      {
                         tc.c_cflag &= ~PARENB;                          tc.c_cflag &= ~((tcflag_t) PARENB);
                         break;                          break;
                     }                      }
   
Line 3790  instruction_open(struct_processus *s_eta Line 3825  instruction_open(struct_processus *s_eta
                     case 'E':                      case 'E':
                     {                      {
                         tc.c_cflag |= PARENB;                          tc.c_cflag |= PARENB;
                         tc.c_cflag &= ~PARODD;                          tc.c_cflag &= ~((tcflag_t) PARODD);
                         break;                          break;
                     }                      }
   
Line 3835  instruction_open(struct_processus *s_eta Line 3870  instruction_open(struct_processus *s_eta
                 {                  {
                     case '1':                      case '1':
                     {                      {
                         tc.c_cflag &= ~CSTOPB;                          tc.c_cflag &= ~((tcflag_t) CSTOPB);
                         break;                          break;
                     }                      }
   
Line 3914  instruction_open(struct_processus *s_eta Line 3949  instruction_open(struct_processus *s_eta
                     unsigned char   *fonctions[] =                      unsigned char   *fonctions[] =
                             { "IGNBRK", "BRKINT", "IGNPAR", "PARMRK",                              { "IGNBRK", "BRKINT", "IGNPAR", "PARMRK",
                             "INPCK", "ISTRIP", "INLCR", "IGNCR", "ICRNL",                              "INPCK", "ISTRIP", "INLCR", "IGNCR", "ICRNL",
                             "IXON", "IXANY", "IXOFF", "OPOST",                              "IXON",
   #ifdef IXANY
                               "IXANY",
   #endif
                               "IXOFF", "OPOST",
                             "ONLCR", "OCRNL", "ONOCR", "ONLRET",                              "ONLCR", "OCRNL", "ONOCR", "ONLRET",
                             "OFILL", "HUPCL", "CLOCAL", "CRTSCTS",  #ifdef OFILL
                               "OFILL",
   #endif
                               "HUPCL", "CLOCAL",
   #ifdef CRTSCTS
                               "CRTSCTS",
   #endif
                             "ISIG", "ICANON", "ECHO", "ECHOE", "ECHOK",                              "ISIG", "ICANON", "ECHO", "ECHOE", "ECHOK",
                             "ECHONL", "NOFLSH", "TOSTOP", "IEXTEN", NULL };                              "ECHONL", "NOFLSH", "TOSTOP", "IEXTEN", NULL };
                     int             fonctions_constantes[] =                      tcflag_t        fonctions_constantes[] =
                             { /* c_iflag */                              { /* c_iflag */
                             1, IGNBRK, 1, BRKINT, 1, IGNPAR, 1, PARMRK,                              1, IGNBRK, 1, BRKINT, 1, IGNPAR, 1, PARMRK,
                             1, INPCK, 1, ISTRIP, 1, INLCR, 1, IGNCR, 1, ICRNL,                              1, INPCK, 1, ISTRIP, 1, INLCR, 1, IGNCR, 1, ICRNL,
                             1, IXON, 1, IXANY, 1, IXOFF,                              1, IXON,
   #ifdef IXANY
                               1, IXANY,
   #endif
                               1, IXOFF,
                             /* c_oflag */                              /* c_oflag */
                             2 , OPOST, 2, ONLCR, 2, OCRNL, 2, ONOCR, 2, ONLRET,                              2 , OPOST, 2, ONLCR, 2, OCRNL, 2, ONOCR, 2, ONLRET,
                             2, OFILL, 2, HUPCL,  #ifdef OFILL
                               2, OFILL,
   #endif
                               2, HUPCL,
                             /* c_cflag */                              /* c_cflag */
                             3, CLOCAL, 3, CRTSCTS,                              3, CLOCAL,
   #ifdef CRTSCTS
                               3, CRTSCTS,
   #endif
                             /* c_lfkag */                              /* c_lfkag */
                             4, ISIG, 4, ICANON, 4, ECHO, 4, ECHOE, 4, ECHOK,                              4, ISIG, 4, ICANON, 4, ECHO, 4, ECHOE, 4, ECHOK,
                             4, ECHONL, 4, NOFLSH, 4, TOSTOP, 4, IEXTEN };                              4, ECHONL, 4, NOFLSH, 4, TOSTOP, 4, IEXTEN };
Line 4254  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 4344  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 4638  instruction_open(struct_processus *s_eta Line 4694  instruction_open(struct_processus *s_eta
                     for(i = 0; i < 16; adresse[i++] = 0);                      for(i = 0; i < 16; adresse[i++] = 0);
                     type_adresse = '6';                      type_adresse = '6';
                 }                  }
                 else                  else if (strcmp(protocole, "UNIX") != 0)
                 {                  {
                     liberation(s_etat_processus, s_objet_argument);                      liberation(s_etat_processus, s_objet_argument);
   
Line 4682  instruction_open(struct_processus *s_eta Line 4738  instruction_open(struct_processus *s_eta
                 if (strcmp(protocole_socket, "IPV4") == 0)                  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 5194  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 5783  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);
   

Removed from v.1.52  
changed lines
  Added in v.1.75


CVSweb interface <joel.bertrand@systella.fr>