--- rpl/src/instructions_w1.c 2014/01/26 18:21:34 1.89 +++ rpl/src/instructions_w1.c 2016/03/16 12:19:34 1.104 @@ -1,7 +1,7 @@ /* ================================================================================ - RPL/2 (R) version 4.1.17 - Copyright (C) 1989-2014 Dr. BERTRAND Joël + RPL/2 (R) version 4.1.25 + Copyright (C) 1989-2016 Dr. BERTRAND Joël This file is part of RPL/2. @@ -712,7 +712,8 @@ instruction_write(struct_processus *s_et free(chaine); - if (alsprintf(&commande, "insert or replace into data " + if (alsprintf(s_etat_processus, &commande, + "insert or replace into data " "(id, data) values (%lld, '%s')", (*((integer8 *) (*s_objet_argument_2).objet)), chaine_utf8) < 0) { @@ -762,8 +763,8 @@ instruction_write(struct_processus *s_et // Récupération de la position de la clef - if (alsprintf(&commande, "select key from control " - "where id = 1") < 0) + if (alsprintf(s_etat_processus, &commande, + "select key from control where id = 1") < 0) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; @@ -939,8 +940,8 @@ instruction_write(struct_processus *s_et // Récupération de l'identifiant de la clef - if (alsprintf(&commande, "select id from key where key = " - "'%s'", clef_utf8) < 0) + if (alsprintf(s_etat_processus, &commande, + "select id from key where key = '%s'", clef_utf8) < 0) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; @@ -985,8 +986,9 @@ instruction_write(struct_processus *s_et free(commande); - if (alsprintf(&commande, "insert into key " - "(key) values ('%s')", clef_utf8) < 0) + if (alsprintf(s_etat_processus, &commande, + "insert into key (key) values ('%s')", + clef_utf8) < 0) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; @@ -1019,8 +1021,9 @@ instruction_write(struct_processus *s_et free(commande); - if (alsprintf(&commande, "select id from key " - "where key = '%s'", clef_utf8) < 0) + if (alsprintf(s_etat_processus, &commande, + "select id from key where key = '%s'", + clef_utf8) < 0) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; @@ -1083,8 +1086,9 @@ instruction_write(struct_processus *s_et if (mise_a_jour == d_vrai) { - if (alsprintf(&commande, "update key set key = '%s' where " - "id = %lld", clef_utf8, id) < 0) + if (alsprintf(s_etat_processus, &commande, + "update key set key = '%s' where id = %lld", + clef_utf8, id) < 0) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; @@ -1119,8 +1123,8 @@ instruction_write(struct_processus *s_et // Effacement de l'enregistrement existant - if (alsprintf(&commande, "delete from data where " - "key_id = %lld", id) < 0) + if (alsprintf(s_etat_processus, &commande, + "delete from data where key_id = %lld", id) < 0) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; @@ -1254,8 +1258,8 @@ instruction_write(struct_processus *s_et free(chaine); - if (alsprintf(&commande, "insert into data " - "(data, key_id, sequence) values " + if (alsprintf(s_etat_processus, &commande, + "insert into data (data, key_id, sequence) values " "('%s', %lld, %lld)", chaine_utf8, id, ordre) < 0) { (*s_etat_processus).erreur_systeme = @@ -1494,9 +1498,9 @@ instruction_write(struct_processus *s_et return; } - if ((format_chaine = conversion_majuscule((unsigned char *) - (*(*l_element_courant_format).donnee).objet)) - == NULL) + if ((format_chaine = conversion_majuscule(s_etat_processus, + (unsigned char *) (*(*l_element_courant_format) + .donnee).objet)) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; @@ -2211,8 +2215,8 @@ instruction_wflock(struct_processus *s_e do { - if ((chaine = conversion_majuscule((unsigned char *) - (*s_objet_argument_1).objet)) == NULL) + if ((chaine = conversion_majuscule(s_etat_processus, + (unsigned char *) (*s_objet_argument_1).objet)) == NULL) { (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; @@ -2518,7 +2522,7 @@ instruction_wfproc(struct_processus *s_e { if (envoi_signal_processus((*(*((struct_processus_fils *) (*(*l_element_courant).donnee).objet)).thread).pid, - rpl_signull) != 0) + rpl_signull, d_faux) != 0) { drapeau_fin = d_vrai; } @@ -3037,6 +3041,121 @@ instruction_wfdata(struct_processus *s_e ================================================================================ */ +static inline logical1 +options_sockets(struct_processus *s_etat_processus, struct_socket *s_socket) +{ + int drapeau; + + if (((*s_socket).options & (1 << d_BROADCAST)) != 0) + { + if (setsockopt((*s_socket).socket, SOL_SOCKET, SO_BROADCAST, &drapeau, + sizeof(drapeau)) != 0) + { + return(d_erreur); + } + } + + if (((*s_socket).options & (1 << d_DONT_ROUTE)) != 0) + { + if (setsockopt((*s_socket).socket, SOL_SOCKET, SO_DONTROUTE, &drapeau, + sizeof(drapeau)) != 0) + { + return(d_erreur); + } + } + + if (((*s_socket).options & (1 << d_KEEP_ALIVE)) != 0) + { + if (setsockopt((*s_socket).socket, SOL_SOCKET, SO_KEEPALIVE, &drapeau, + sizeof(drapeau)) != 0) + { + return(d_erreur); + } + } + +# ifdef SO_PRIORITY + if (((*s_socket).options & (1 << d_PRIORITY)) != 0) + { + if (setsockopt((*s_socket).socket, SOL_SOCKET, SO_PRIORITY, + &((*s_socket).priorite), sizeof((*s_socket).priorite)) != 0) + { + return(d_erreur); + } + } +# endif + + // Les deux options suivantes ne peuvent être positionnées simultanément. + + if (((*s_socket).options & (1 << d_RECEIVE_BUFFER)) != 0) + { + if (setsockopt((*s_socket).socket, SOL_SOCKET, SO_RCVBUF, + &((*s_socket).buffer_reception), + sizeof((*s_socket).buffer_reception)) != 0) + { + return(d_erreur); + } + } + +# ifdef SO_RCVBUFFORCE + if (((*s_socket).options & (1 << d_FORCE_RECEIVE_BUFFER)) != 0) + { + if (setsockopt((*s_socket).socket, SOL_SOCKET, SO_RCVBUFFORCE, + &((*s_socket).buffer_reception), + sizeof((*s_socket).buffer_reception)) != 0) + { + return(d_erreur); + } + } +# endif + + // Même remarque + + if (((*s_socket).options & (1 << d_SEND_BUFFER)) != 0) + { + if (setsockopt((*s_socket).socket, SOL_SOCKET, SO_SNDBUF, + &((*s_socket).buffer_emission), + sizeof((*s_socket).buffer_emission)) != 0) + { + return(d_erreur); + } + } + +# ifdef SO_SNDBUFFORCE + if (((*s_socket).options & (1 << d_FORCE_SEND_BUFFER)) != 0) + { + if (setsockopt((*s_socket).socket, SOL_SOCKET, SO_SNDBUFFORCE, + &((*s_socket).buffer_emission), + sizeof((*s_socket).buffer_emission)) != 0) + { + return(d_erreur); + } + } +# endif + + if (((*s_socket).options & (1 << d_RECEIVING_TIMEOUT)) != 0) + { + if (setsockopt((*s_socket).socket, SOL_SOCKET, SO_RCVTIMEO, + &((*s_socket).timeout_emission), + sizeof((*s_socket).timeout_emission)) != 0) + { + return(d_erreur); + } + } + + if (((*s_socket).options & (1 << d_SENDING_TIMEOUT)) != 0) + { + if (setsockopt((*s_socket).socket, SOL_SOCKET, SO_SNDTIMEO, + &((*s_socket).timeout_emission), + sizeof((*s_socket).timeout_emission)) != 0) + { + return(d_erreur); + } + } + + return(d_absence_erreur);; +} + + void instruction_wfsock(struct_processus *s_etat_processus) { @@ -3222,12 +3341,12 @@ instruction_wfsock(struct_processus *s_e { drapeau = d_vrai; -# ifndef SEMAPHORES_NOMMES +# ifndef SEMAPHORES_NOMMES if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) -# else +# else if (sem_post((*s_etat_processus).semaphore_fork) != 0) -# endif +# endif { (*s_etat_processus).erreur_systeme = d_es_processus; return; @@ -3242,11 +3361,11 @@ instruction_wfsock(struct_processus *s_e erreur = errno; # ifndef SEMAPHORES_NOMMES - while(sem_wait(&((*s_etat_processus) - .semaphore_fork)) != 0) + while(sem_wait(&((*s_etat_processus) + .semaphore_fork)) != 0) # else - while(sem_wait((*s_etat_processus).semaphore_fork) - != 0) + while(sem_wait((*s_etat_processus).semaphore_fork) + != 0) # endif { if (errno != EINTR) @@ -3280,13 +3399,13 @@ instruction_wfsock(struct_processus *s_e } else { -# ifndef SEMAPHORES_NOMMES +# ifndef SEMAPHORES_NOMMES while(sem_wait(&((*s_etat_processus) .semaphore_fork)) != 0) -# else +# else while(sem_wait((*s_etat_processus).semaphore_fork) != 0) -# endif +# endif { if (errno != EINTR) { @@ -3295,6 +3414,17 @@ instruction_wfsock(struct_processus *s_e return; } } + + if (options_sockets(s_etat_processus, + (*s_objet_resultat).objet) != d_absence_erreur) + { + 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; + } } } while(drapeau == d_faux); @@ -3325,12 +3455,12 @@ instruction_wfsock(struct_processus *s_e { drapeau = d_vrai; -# ifndef SEMAPHORES_NOMMES +# ifndef SEMAPHORES_NOMMES if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) -# else +# else if (sem_post((*s_etat_processus).semaphore_fork) != 0) -# endif +# endif { (*s_etat_processus).erreur_systeme = d_es_processus; return; @@ -3343,13 +3473,13 @@ instruction_wfsock(struct_processus *s_e { erreur = errno; -# ifndef SEMAPHORES_NOMMES +# ifndef SEMAPHORES_NOMMES while(sem_wait(&((*s_etat_processus) .semaphore_fork)) != 0) -# else +# else while(sem_wait((*s_etat_processus).semaphore_fork) != 0) -# endif +# endif { if (errno != EINTR) { @@ -3382,13 +3512,13 @@ instruction_wfsock(struct_processus *s_e } else { -# ifndef SEMAPHORES_NOMMES +# ifndef SEMAPHORES_NOMMES while(sem_wait(&((*s_etat_processus) .semaphore_fork)) != 0) -# else +# else while(sem_wait((*s_etat_processus).semaphore_fork) != 0) -# endif +# endif { if (errno != EINTR) { @@ -3397,6 +3527,17 @@ instruction_wfsock(struct_processus *s_e return; } } + + if (options_sockets(s_etat_processus, + (*s_objet_resultat).objet) != d_absence_erreur) + { + 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; + } } } while(drapeau == d_faux); @@ -3447,12 +3588,12 @@ instruction_wfsock(struct_processus *s_e { drapeau = d_vrai; -# ifndef SEMAPHORES_NOMMES +# ifndef SEMAPHORES_NOMMES if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) -# else +# else if (sem_post((*s_etat_processus).semaphore_fork) != 0) -# endif +# endif { (*s_etat_processus).erreur_systeme = d_es_processus; return; @@ -3465,13 +3606,13 @@ instruction_wfsock(struct_processus *s_e { erreur = errno; -# ifndef SEMAPHORES_NOMMES +# ifndef SEMAPHORES_NOMMES while(sem_wait(&((*s_etat_processus) .semaphore_fork)) != 0) -# else +# else while(sem_wait((*s_etat_processus).semaphore_fork) != 0) -# endif +# endif { if (errno != EINTR) { @@ -3504,13 +3645,13 @@ instruction_wfsock(struct_processus *s_e } else { -# ifndef SEMAPHORES_NOMMES +# ifndef SEMAPHORES_NOMMES while(sem_wait(&((*s_etat_processus) .semaphore_fork)) != 0) -# else +# else while(sem_wait((*s_etat_processus).semaphore_fork) != 0) -# endif +# endif { if (errno != EINTR) { @@ -3519,6 +3660,17 @@ instruction_wfsock(struct_processus *s_e return; } } + + if (options_sockets(s_etat_processus, + (*s_objet_resultat).objet) != d_absence_erreur) + { + 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; + } } } while(drapeau == d_faux); }