--- rpl/src/instructions_o1.c 2012/06/21 16:07:25 1.56 +++ rpl/src/instructions_o1.c 2017/01/18 15:44:21 1.89 @@ -1,7 +1,7 @@ /* ================================================================================ - RPL/2 (R) version 4.1.9 - Copyright (C) 1989-2012 Dr. BERTRAND Joël + RPL/2 (R) version 4.1.26 + Copyright (C) 1989-2017 Dr. BERTRAND Joël This file is part of RPL/2. @@ -210,7 +210,7 @@ instruction_or(struct_processus *s_etat_ struct_objet *s_objet_argument_2; struct_objet *s_objet_resultat; - unsigned long nombre_elements; + integer8 nombre_elements; (*s_etat_processus).erreur_execution = d_ex; @@ -869,6 +869,237 @@ instruction_or(struct_processus *s_etat_ ================================================================================ */ + +static inline logical1 +options_socket(struct_processus *s_etat_processus, + struct_objet *s_objet_resultat, unsigned char *options, + unsigned char *peripherique, int *priorite, + int *buffer_emission, int *buffer_reception, + int *timeout_emission, int *timeout_reception) +{ + int drapeau; + + /* + * Options des sockets + */ + + drapeau = -1; + +# define WARNING(message) { \ + if ((*s_etat_processus).langue != 'F') \ + printf("+++Warning : %s unavailable on host system\n", message); \ + else \ + printf("+++Attention : %s non disponible sur le système hôte\n", \ + message); } while(0) + + if (options[d_BIND_TO_DEVICE] == 'Y') + { +# ifdef SO_BINDTODEVICE + if (setsockopt((*((struct_socket *) (*s_objet_resultat).objet)) + .socket, SOL_SOCKET, SO_BINDTODEVICE, peripherique, + (socklen_t) strlen(peripherique)) != 0) + { + (*s_etat_processus).erreur_execution = + d_ex_erreur_parametre_fichier; + return(d_erreur); + } + + (*((struct_socket *) (*s_objet_resultat).objet)).options |= + ((integer8) 1) << d_BIND_TO_DEVICE; +# else + WARNING("BIND TO DEVICE"); +# endif + } + + if (options[d_BROADCAST] == 'Y') + { + if (setsockopt((*((struct_socket *) (*s_objet_resultat).objet)).socket, + SOL_SOCKET, SO_BROADCAST, &drapeau, sizeof(drapeau)) != 0) + { + (*s_etat_processus).erreur_execution = + d_ex_erreur_parametre_fichier; + return(d_erreur); + } + + (*((struct_socket *) (*s_objet_resultat).objet)).options |= + ((integer8) 1) << d_BROADCAST; + } + + if (options[d_DONT_ROUTE] == 'Y') + { + if (setsockopt((*((struct_socket *) (*s_objet_resultat).objet)).socket, + SOL_SOCKET, SO_DONTROUTE, &drapeau, sizeof(drapeau)) != 0) + { + (*s_etat_processus).erreur_execution = + d_ex_erreur_parametre_fichier; + return(d_erreur); + } + + (*((struct_socket *) (*s_objet_resultat).objet)).options |= + ((integer8) 1) << d_DONT_ROUTE; + } + + if (options[d_KEEP_ALIVE] == 'Y') + { + if (setsockopt((*((struct_socket *) (*s_objet_resultat).objet)).socket, + SOL_SOCKET, SO_KEEPALIVE, &drapeau, sizeof(drapeau)) != 0) + { + (*s_etat_processus).erreur_execution = + d_ex_erreur_parametre_fichier; + return(d_erreur); + } + } + + if (options[d_PRIORITY] == 'Y') + { +# ifdef SO_PRIORITY + if (setsockopt((*((struct_socket *) (*s_objet_resultat).objet)) + .socket, SOL_SOCKET, SO_PRIORITY, priorite, + sizeof((*priorite))) != 0) + { + (*s_etat_processus).erreur_execution = + d_ex_erreur_parametre_fichier; + return(d_erreur); + } + + (*((struct_socket *) (*s_objet_resultat).objet)).options |= + ((integer8) 1) << d_PRIORITY; + (*((struct_socket *) (*s_objet_resultat).objet)).priorite = + (*priorite); +# else + WARNING("PRIORITY"); +# endif + } + + if (options[d_RECEIVE_BUFFER] == 'Y') + { + if (setsockopt((*((struct_socket *) (*s_objet_resultat).objet)).socket, + SOL_SOCKET, SO_RCVBUF, buffer_reception, + sizeof((*buffer_reception))) != 0) + { + (*s_etat_processus).erreur_execution = + d_ex_erreur_parametre_fichier; + return(d_erreur); + } + + (*((struct_socket *) (*s_objet_resultat).objet)).options |= + ((integer8) 1) << d_RECEIVE_BUFFER; + (*((struct_socket *) (*s_objet_resultat).objet)).buffer_reception = + (*buffer_reception); + } + + if (options[d_FORCE_RECEIVE_BUFFER] == 'Y') + { +# ifdef SO_RCVBUFFORCE + if (setsockopt((*((struct_socket *) (*s_objet_resultat).objet)) + .socket, SOL_SOCKET, SO_RCVBUFFORCE, + buffer_reception, sizeof((*buffer_reception))) != 0) + { + (*s_etat_processus).erreur_execution = + d_ex_erreur_parametre_fichier; + return(d_erreur); + } + + (*((struct_socket *) (*s_objet_resultat).objet)).options |= + ((integer8) 1) << d_FORCE_RECEIVE_BUFFER; + (*((struct_socket *) (*s_objet_resultat).objet)).buffer_reception = + (*buffer_reception); +# else + WARNING("FORCE_RECEIVE_BUFFER"); +# endif + } + + if (options[d_SEND_BUFFER] == 'Y') + { + if (setsockopt((*((struct_socket *) (*s_objet_resultat).objet)).socket, + SOL_SOCKET, SO_SNDBUF, buffer_emission, + sizeof((*buffer_emission))) != 0) + { + (*s_etat_processus).erreur_execution = + d_ex_erreur_parametre_fichier; + return(d_erreur); + } + + (*((struct_socket *) (*s_objet_resultat).objet)).options |= + ((integer8) 1) << d_SEND_BUFFER; + (*((struct_socket *) (*s_objet_resultat).objet)).buffer_emission = + (*buffer_emission); + } + + if (options[d_FORCE_SEND_BUFFER] == 'Y') + { +# ifdef SO_SNDBUFFORCE + if (setsockopt((*((struct_socket *) (*s_objet_resultat).objet)) + .socket, SOL_SOCKET, SO_SNDBUFFORCE, buffer_emission, + sizeof((*buffer_emission))) != 0) + { + (*s_etat_processus).erreur_execution = + d_ex_erreur_parametre_fichier; + return(d_erreur); + } + + (*((struct_socket *) (*s_objet_resultat).objet)).options |= + ((integer8) 1) << d_FORCE_SEND_BUFFER; + (*((struct_socket *) (*s_objet_resultat).objet)).buffer_emission = + (*buffer_emission); +# else + WARNING("FORCE_SEND_BUFFER"); +# endif + } + + if (options[d_RECEIVING_TIMEOUT] == 'Y') + { + if (setsockopt((*((struct_socket *) (*s_objet_resultat).objet)).socket, + SOL_SOCKET, SO_RCVTIMEO, + timeout_reception, sizeof((*timeout_reception))) != 0) + { + (*s_etat_processus).erreur_execution = + d_ex_erreur_parametre_fichier; + return(d_erreur); + } + + (*((struct_socket *) (*s_objet_resultat).objet)).options |= + ((integer8) 1) << d_RECEIVING_TIMEOUT; + (*((struct_socket *) (*s_objet_resultat).objet)).timeout_reception = + (*timeout_reception); + } + + if (options[d_SENDING_TIMEOUT] == 'Y') + { + if (setsockopt((*((struct_socket *) (*s_objet_resultat).objet)).socket, + SOL_SOCKET, SO_SNDTIMEO, + timeout_emission, sizeof((*timeout_emission))) != 0) + { + (*s_etat_processus).erreur_execution = + d_ex_erreur_parametre_fichier; + return(d_erreur); + } + + (*((struct_socket *) (*s_objet_resultat).objet)).options |= + ((integer8) 1) << d_SENDING_TIMEOUT; + (*((struct_socket *) (*s_objet_resultat).objet)).timeout_emission = + (*timeout_emission); + } + + if (options[d_REUSE_ADDRESS] == 'Y') + { + if (setsockopt((*((struct_socket *) (*s_objet_resultat).objet)).socket, + SOL_SOCKET, SO_REUSEADDR, &drapeau, sizeof(drapeau)) != 0) + { + (*s_etat_processus).erreur_execution = + d_ex_erreur_parametre_fichier; + return(d_erreur); + } + + (*((struct_socket *) (*s_objet_resultat).objet)).options |= + ((integer8) 1) << d_REUSE_ADDRESS; + } + + return(d_absence_erreur); +# undef WARNING +} + + void instruction_open(struct_processus *s_etat_processus) { @@ -905,8 +1136,8 @@ instruction_open(struct_processus *s_eta int buffer_emission; int buffer_reception; - int drapeau; int priorite; + int prochain_descripteur; int protocole_numerique; int timeout_emission; int timeout_reception; @@ -973,22 +1204,8 @@ instruction_open(struct_processus *s_eta unsigned long i; unsigned long nombre_elements; - unsigned long prochain_descripteur; unsigned long unite; -# define d_BIND_TO_DEVICE 0 -# define d_BROADCAST 1 -# define d_DONT_ROUTE 2 -# define d_KEEP_ALIVE 3 -# define d_PRIORITY 4 -# define d_RECEIVE_BUFFER 5 -# define d_FORCE_RECEIVE_BUFFER 6 -# define d_SEND_BUFFER 7 -# define d_FORCE_SEND_BUFFER 8 -# define d_RECEIVING_TIMEOUT 9 -# define d_SENDING_TIMEOUT 10 -# define d_REUSE_ADDRESS 11 - /* * Argument : { "ouverture" "accès" "format" [ { "nom" } 'protection' ] } */ @@ -1028,7 +1245,8 @@ instruction_open(struct_processus *s_eta "\"file name\" } \"protection\" } OPEN\n"); printf(" { \"filetype\" \"access\" \"format\" { \"name\" " "\"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\" \"socketdomain\" \"protection\" } OPEN\n"); printf(" \"/semaphore\" OPEN\n\n"); @@ -1078,7 +1296,7 @@ instruction_open(struct_processus *s_eta printf(" { \"STREAM\" \"READWRITE\" } OPEN\n"); printf(" { \"FOREIGN\" \"DATAGRAM\" } 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"); return; @@ -1139,7 +1357,6 @@ instruction_open(struct_processus *s_eta buffer_reception = 0; timeout_emission = 0; timeout_reception = 0; - drapeau = -1; s_parametres_tty = NULL; for(i = 0; i < 12; options[i++] = 'N'); @@ -1148,8 +1365,9 @@ instruction_open(struct_processus *s_eta { if ((*(*l_element_courant).donnee).type == CHN) { - if ((argument_majuscule = conversion_majuscule((unsigned char *) - (*(*l_element_courant).donnee).objet)) == NULL) + if ((argument_majuscule = conversion_majuscule(s_etat_processus, + (unsigned char *) (*(*l_element_courant).donnee).objet)) + == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; @@ -1763,7 +1981,7 @@ instruction_open(struct_processus *s_eta if ((*(*l_element_courant_sous_objet).donnee).type == CHN) { if ((argument_majuscule = conversion_majuscule( - (unsigned char *) + s_etat_processus, (unsigned char *) (*(*l_element_courant_sous_objet) .donnee).objet)) == NULL) { @@ -1829,7 +2047,7 @@ instruction_open(struct_processus *s_eta free(argument_majuscule); if ((argument_majuscule = conversion_majuscule( - (unsigned char *) + s_etat_processus, (unsigned char *) (*(*l_element_courant_sous_objet) .donnee).objet)) == NULL) { @@ -1998,7 +2216,9 @@ instruction_open(struct_processus *s_eta if ((protocole_socket[i] >= 'a') && (protocole_socket[i] <= 'z')) { - protocole_socket[i] -= 'a' - 'A'; + protocole_socket[i] = (unsigned char) + (protocole_socket[i] + - ('a' - 'A')); } } } @@ -2141,7 +2361,6 @@ instruction_open(struct_processus *s_eta { type_arguments = 'S'; } - else if (type_arguments == 'F') { liberation(s_etat_processus, s_objet_argument); @@ -2318,7 +2537,7 @@ instruction_open(struct_processus *s_eta if ((*(*l_element_courant_sous_objet).donnee).type == CHN) { if ((argument_majuscule = conversion_majuscule( - (unsigned char *) + s_etat_processus, (unsigned char *) (*(*l_element_courant_sous_objet) .donnee).objet)) == NULL) { @@ -2359,7 +2578,7 @@ instruction_open(struct_processus *s_eta } if ((argument_majuscule = conversion_majuscule( - (unsigned char *) + s_etat_processus, (unsigned char *) (*(*l_element_courant_sous_objet) .donnee).objet)) == NULL) { @@ -3620,7 +3839,8 @@ instruction_open(struct_processus *s_eta } if ((parametre_courant_majuscule = conversion_majuscule( - (*(*parametre_courant).donnee).objet)) == NULL) + s_etat_processus, (*(*parametre_courant).donnee).objet)) + == NULL) { liberation(s_etat_processus, s_objet_argument); liberation(s_etat_processus, s_objet_resultat); @@ -3657,14 +3877,32 @@ instruction_open(struct_processus *s_eta // Vitesse unsigned char *vitesses[] = - { "0", "50", "75", "110", "134", "150", + { "50", "75", "110", "134", "150", "200", "300", "600", "1200", "1800", "2400", - "4800", "9600", "19200", "38400", "57600", - "115200", "230400", NULL }; - int vitesses_constantes[] = - { B0, B50, B75, B110, B134, B150, B200, B300, B600, + "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, - B57600, B115200, B230400, 0 }; +#ifdef B57600 + B57600, +#endif +#ifdef B115200 + B115200, +#endif +#ifdef B230400 + B230400, +#endif + 0 }; unsigned int vitesse_courante; vitesse_courante = 0; @@ -3677,8 +3915,15 @@ instruction_open(struct_processus *s_eta if (position[strlen(vitesses[vitesse_courante])] == d_code_espace) { - tc.c_cflag &= ~CBAUD; +#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; @@ -3717,28 +3962,28 @@ instruction_open(struct_processus *s_eta { case '5': { - tc.c_cflag &= ~CSIZE; + tc.c_cflag &= ~((tcflag_t) CSIZE); tc.c_cflag |= CS5; break; } case '6': { - tc.c_cflag &= ~CSIZE; + tc.c_cflag &= ~((tcflag_t) CSIZE); tc.c_cflag |= CS6; break; } case '7': { - tc.c_cflag &= ~CSIZE; + tc.c_cflag &= ~((tcflag_t) CSIZE); tc.c_cflag |= CS7; break; } case '8': { - tc.c_cflag &= ~CSIZE; + tc.c_cflag &= ~((tcflag_t) CSIZE); tc.c_cflag |= CS8; break; } @@ -3784,7 +4029,7 @@ instruction_open(struct_processus *s_eta { case 'N': { - tc.c_cflag &= ~PARENB; + tc.c_cflag &= ~((tcflag_t) PARENB); break; } @@ -3798,7 +4043,7 @@ instruction_open(struct_processus *s_eta case 'E': { tc.c_cflag |= PARENB; - tc.c_cflag &= ~PARODD; + tc.c_cflag &= ~((tcflag_t) PARODD); break; } @@ -3843,7 +4088,7 @@ instruction_open(struct_processus *s_eta { case '1': { - tc.c_cflag &= ~CSTOPB; + tc.c_cflag &= ~((tcflag_t) CSTOPB); break; } @@ -3909,7 +4154,8 @@ instruction_open(struct_processus *s_eta } if ((parametre_courant_majuscule = conversion_majuscule( - (*(*parametre_courant).donnee).objet)) == NULL) + s_etat_processus, (*(*parametre_courant).donnee) + .objet)) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; @@ -3922,21 +4168,41 @@ instruction_open(struct_processus *s_eta unsigned char *fonctions[] = { "IGNBRK", "BRKINT", "IGNPAR", "PARMRK", "INPCK", "ISTRIP", "INLCR", "IGNCR", "ICRNL", - "IXON", "IXANY", "IXOFF", "OPOST", + "IXON", +#ifdef IXANY + "IXANY", +#endif + "IXOFF", "OPOST", "ONLCR", "OCRNL", "ONOCR", "ONLRET", - "OFILL", "HUPCL", "CLOCAL", "CRTSCTS", +#ifdef OFILL + "OFILL", +#endif + "HUPCL", "CLOCAL", +#ifdef CRTSCTS + "CRTSCTS", +#endif "ISIG", "ICANON", "ECHO", "ECHOE", "ECHOK", "ECHONL", "NOFLSH", "TOSTOP", "IEXTEN", NULL }; - int fonctions_constantes[] = + 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, 1, IXANY, 1, IXOFF, + 1, IXON, +#ifdef IXANY + 1, IXANY, +#endif + 1, IXOFF, /* c_oflag */ 2 , OPOST, 2, ONLCR, 2, OCRNL, 2, ONOCR, 2, ONLRET, - 2, OFILL, 2, HUPCL, +#ifdef OFILL + 2, OFILL, +#endif + 2, HUPCL, /* c_cflag */ - 3, CLOCAL, 3, CRTSCTS, + 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 }; @@ -4262,7 +4528,7 @@ instruction_open(struct_processus *s_eta return; } - prochain_descripteur = i; + prochain_descripteur = (int) i; /* * Ajout d'un élément à la fin de la liste chaînée @@ -4332,222 +4598,6 @@ instruction_open(struct_processus *s_eta * Traitement des sockets */ - - inline logical1 options_socket() - { - /* - * Options des sockets - */ - -# define WARNING(message) \ - if ((*s_etat_processus).langue != 'F') \ - printf("+++Warning : %s unavailable on host system\n", \ - message); \ - else \ - printf("+++Attention : %s non disponible sur le système " \ - "hôte\n", message) - - if (options[d_BIND_TO_DEVICE] == 'Y') - { -# ifdef SO_BINDTODEVICE - if (setsockopt((*((struct_socket *) (*s_objet_resultat) - .objet)).socket, SOL_SOCKET, SO_BINDTODEVICE, - peripherique, strlen(peripherique)) != 0) - { - 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(d_erreur); - } -# else - WARNING("BIND TO DEVICE"); -# endif - } - - if (options[d_BROADCAST] == 'Y') - { - if (setsockopt((*((struct_socket *) (*s_objet_resultat) - .objet)).socket, SOL_SOCKET, SO_BROADCAST, - &drapeau, sizeof(drapeau)) != 0) - { - 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(d_erreur); - } - } - - if (options[d_DONT_ROUTE] == 'Y') - { - if (setsockopt((*((struct_socket *) (*s_objet_resultat) - .objet)).socket, SOL_SOCKET, SO_DONTROUTE, - &drapeau, sizeof(drapeau)) != 0) - { - 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(d_erreur); - } - } - - if (options[d_KEEP_ALIVE] == 'Y') - { - if (setsockopt((*((struct_socket *) (*s_objet_resultat) - .objet)).socket, SOL_SOCKET, SO_KEEPALIVE, - &drapeau, sizeof(drapeau)) != 0) - { - 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(d_erreur); - } - } - - if (options[d_PRIORITY] == 'Y') - { -# ifdef SO_PRIORITY - if (setsockopt((*((struct_socket *) (*s_objet_resultat) - .objet)).socket, SOL_SOCKET, SO_PRIORITY, - &priorite, sizeof(priorite)) != 0) - { - 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(d_erreur); - } -# else - WARNING("PRIORITY"); -# endif - } - - if (options[d_RECEIVE_BUFFER] == 'Y') - { - if (setsockopt((*((struct_socket *) (*s_objet_resultat) - .objet)).socket, SOL_SOCKET, SO_RCVBUF, - &buffer_reception, sizeof(buffer_reception)) != 0) - { - 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(d_erreur); - } - } - - if (options[d_FORCE_RECEIVE_BUFFER] == 'Y') - { -# ifdef SO_RCVBUFFORCE - if (setsockopt((*((struct_socket *) (*s_objet_resultat) - .objet)).socket, SOL_SOCKET, SO_RCVBUFFORCE, - &buffer_reception, sizeof(buffer_reception)) - != 0) - { - 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(d_erreur); - } -# else - WARNING("FORCE_RECEIVE_BUFFER"); -# endif - } - - if (options[d_SEND_BUFFER] == 'Y') - { - if (setsockopt((*((struct_socket *) (*s_objet_resultat) - .objet)).socket, SOL_SOCKET, SO_SNDBUF, - &buffer_emission, sizeof(buffer_emission)) != 0) - { - 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(d_erreur); - } - } - - if (options[d_FORCE_SEND_BUFFER] == 'Y') - { -# ifdef SO_SNDBUFFORCE - if (setsockopt((*((struct_socket *) (*s_objet_resultat) - .objet)).socket, SOL_SOCKET, SO_SNDBUFFORCE, - &buffer_emission, sizeof(buffer_emission)) != 0) - { - 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(d_erreur); - } -# else - WARNING("FORCE_SEND_BUFFER"); -# endif - } - - if (options[d_RECEIVING_TIMEOUT] == 'Y') - { - if (setsockopt((*((struct_socket *) (*s_objet_resultat) - .objet)).socket, SOL_SOCKET, SO_RCVTIMEO, - &timeout_reception, sizeof(timeout_reception)) != 0) - { - 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(d_erreur); - } - } - - if (options[d_SENDING_TIMEOUT] == 'Y') - { - if (setsockopt((*((struct_socket *) (*s_objet_resultat) - .objet)).socket, SOL_SOCKET, SO_SNDTIMEO, - &timeout_emission, sizeof(timeout_emission)) != 0) - { - 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(d_erreur); - } - } - - if (options[d_REUSE_ADDRESS] == 'Y') - { - if (setsockopt((*((struct_socket *) (*s_objet_resultat) - .objet)).socket, SOL_SOCKET, SO_REUSEADDR, - &drapeau, sizeof(drapeau)) != 0) - { - 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(d_erreur); - } - } - - return(d_absence_erreur); -#undef WARNING - } - /* * Vérification de la cohérence des arguments et traitement * des valeurs par défaut. @@ -4646,7 +4696,7 @@ instruction_open(struct_processus *s_eta for(i = 0; i < 16; adresse[i++] = 0); type_adresse = '6'; } - else + else if (strcmp(protocole, "UNIX") != 0) { liberation(s_etat_processus, s_objet_argument); @@ -4690,18 +4740,22 @@ instruction_open(struct_processus *s_eta if (strcmp(protocole_socket, "IPV4") == 0) { protocole_socket[2] = d_code_fin_chaine; + protocole_numerique = 0; } - - if ((s_protocole = getprotobyname(protocole_socket)) == NULL) + else { - 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 = - d_ex_erreur_parametre_fichier; - return; - } + (*s_etat_processus).erreur_execution = + d_ex_erreur_parametre_fichier; + return; + } - protocole_numerique = (*s_protocole).p_proto; + protocole_numerique = (*s_protocole).p_proto; + } } if ((s_objet_resultat = allocation(s_etat_processus, SCK)) @@ -4821,6 +4875,7 @@ instruction_open(struct_processus *s_eta = 'Y'; (*((struct_socket *) (*s_objet_resultat).objet)).socket_connectee = d_faux; + (*((struct_socket *) (*s_objet_resultat).objet)).options = 0; if (type_domaine == 'L') { // Socket serveur @@ -4860,7 +4915,10 @@ instruction_open(struct_processus *s_eta strncpy(socket_unix.sun_path, pointeur, UNIX_PATH_MAX); socket_unix.sun_path[UNIX_PATH_MAX - 1] = d_code_fin_chaine; - if (options_socket() == d_erreur) + if (options_socket(s_etat_processus, s_objet_resultat, + options, peripherique, &priorite, + &buffer_emission, &buffer_reception, + &timeout_emission, &timeout_reception) == d_erreur) { liberation(s_etat_processus, s_objet_argument); liberation(s_etat_processus, s_objet_resultat); @@ -4964,7 +5022,12 @@ instruction_open(struct_processus *s_eta (*resolution_courante).ai_addr)) .sin_addr.s_addr; - if (options_socket() == d_erreur) + if (options_socket(s_etat_processus, + s_objet_resultat, + options, peripherique, &priorite, + &buffer_emission, &buffer_reception, + &timeout_emission, &timeout_reception) + == d_erreur) { liberation(s_etat_processus, s_objet_argument); liberation(s_etat_processus, s_objet_resultat); @@ -5071,7 +5134,12 @@ instruction_open(struct_processus *s_eta (*resolution_courante).ai_addr)) .sin6_addr.s6_addr[i], i++); - if (options_socket() == d_erreur) + if (options_socket(s_etat_processus, + s_objet_resultat, + options, peripherique, &priorite, + &buffer_emission, &buffer_reception, + &timeout_emission, &timeout_reception) + == d_erreur) { liberation(s_etat_processus, s_objet_argument); liberation(s_etat_processus, s_objet_resultat); @@ -5202,11 +5270,17 @@ instruction_open(struct_processus *s_eta adresse_ipv4 = 0; 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); - if (options_socket() == d_erreur) + if (options_socket(s_etat_processus, + s_objet_resultat, + options, peripherique, &priorite, + &buffer_emission, &buffer_reception, + &timeout_emission, &timeout_reception) + == d_erreur) { liberation(s_etat_processus, s_objet_argument); liberation(s_etat_processus, s_objet_resultat); @@ -5283,7 +5357,12 @@ instruction_open(struct_processus *s_eta socket_ipv6.sin6_addr.s6_addr[i] = (unsigned char) (adresse[i]), i++); - if (options_socket() == d_erreur) + if (options_socket(s_etat_processus, + s_objet_resultat, + options, peripherique, &priorite, + &buffer_emission, &buffer_reception, + &timeout_emission, &timeout_reception) + == d_erreur) { liberation(s_etat_processus, s_objet_argument); liberation(s_etat_processus, s_objet_resultat); @@ -5791,7 +5870,8 @@ instruction_open(struct_processus *s_eta adresse_ipv4 = 0; 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);