version 1.86, 2013/06/21 14:15:56
|
version 1.100, 2015/11/26 11:44:41
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.1.15 |
RPL/2 (R) version 4.1.24 |
Copyright (C) 1989-2013 Dr. BERTRAND Joël |
Copyright (C) 1989-2015 Dr. BERTRAND Joël |
|
|
This file is part of RPL/2. |
This file is part of RPL/2. |
|
|
Line 712 instruction_write(struct_processus *s_et
|
Line 712 instruction_write(struct_processus *s_et
|
|
|
free(chaine); |
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 *) |
"(id, data) values (%lld, '%s')", (*((integer8 *) |
(*s_objet_argument_2).objet)), chaine_utf8) < 0) |
(*s_objet_argument_2).objet)), chaine_utf8) < 0) |
{ |
{ |
Line 762 instruction_write(struct_processus *s_et
|
Line 763 instruction_write(struct_processus *s_et
|
|
|
// Récupération de la position de la clef |
// Récupération de la position de la clef |
|
|
if (alsprintf(&commande, "select key from control " |
if (alsprintf(s_etat_processus, &commande, |
"where id = 1") < 0) |
"select key from control where id = 1") < 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
d_es_allocation_memoire; |
d_es_allocation_memoire; |
Line 939 instruction_write(struct_processus *s_et
|
Line 940 instruction_write(struct_processus *s_et
|
|
|
// Récupération de l'identifiant de la clef |
// Récupération de l'identifiant de la clef |
|
|
if (alsprintf(&commande, "select id from key where key = " |
if (alsprintf(s_etat_processus, &commande, |
"'%s'", clef_utf8) < 0) |
"select id from key where key = '%s'", clef_utf8) < 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
d_es_allocation_memoire; |
d_es_allocation_memoire; |
Line 985 instruction_write(struct_processus *s_et
|
Line 986 instruction_write(struct_processus *s_et
|
|
|
free(commande); |
free(commande); |
|
|
if (alsprintf(&commande, "insert into key " |
if (alsprintf(s_etat_processus, &commande, |
"(key) values ('%s')", clef_utf8) < 0) |
"insert into key (key) values ('%s')", |
|
clef_utf8) < 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
d_es_allocation_memoire; |
d_es_allocation_memoire; |
Line 1019 instruction_write(struct_processus *s_et
|
Line 1021 instruction_write(struct_processus *s_et
|
|
|
free(commande); |
free(commande); |
|
|
if (alsprintf(&commande, "select id from key " |
if (alsprintf(s_etat_processus, &commande, |
"where key = '%s'", clef_utf8) < 0) |
"select id from key where key = '%s'", |
|
clef_utf8) < 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
d_es_allocation_memoire; |
d_es_allocation_memoire; |
Line 1083 instruction_write(struct_processus *s_et
|
Line 1086 instruction_write(struct_processus *s_et
|
|
|
if (mise_a_jour == d_vrai) |
if (mise_a_jour == d_vrai) |
{ |
{ |
if (alsprintf(&commande, "update key set key = '%s' where " |
if (alsprintf(s_etat_processus, &commande, |
"id = %lld", clef_utf8, id) < 0) |
"update key set key = '%s' where id = %lld", |
|
clef_utf8, id) < 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
d_es_allocation_memoire; |
d_es_allocation_memoire; |
Line 1119 instruction_write(struct_processus *s_et
|
Line 1123 instruction_write(struct_processus *s_et
|
|
|
// Effacement de l'enregistrement existant |
// Effacement de l'enregistrement existant |
|
|
if (alsprintf(&commande, "delete from data where " |
if (alsprintf(s_etat_processus, &commande, |
"key_id = %lld", id) < 0) |
"delete from data where key_id = %lld", id) < 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
d_es_allocation_memoire; |
d_es_allocation_memoire; |
Line 1254 instruction_write(struct_processus *s_et
|
Line 1258 instruction_write(struct_processus *s_et
|
|
|
free(chaine); |
free(chaine); |
|
|
if (alsprintf(&commande, "insert into data " |
if (alsprintf(s_etat_processus, &commande, |
"(data, key_id, sequence) values " |
"insert into data (data, key_id, sequence) values " |
"('%s', %lld, %lld)", chaine_utf8, id, ordre) < 0) |
"('%s', %lld, %lld)", chaine_utf8, id, ordre) < 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
Line 1494 instruction_write(struct_processus *s_et
|
Line 1498 instruction_write(struct_processus *s_et
|
return; |
return; |
} |
} |
|
|
if ((format_chaine = conversion_majuscule((unsigned char *) |
if ((format_chaine = conversion_majuscule(s_etat_processus, |
(*(*l_element_courant_format).donnee).objet)) |
(unsigned char *) (*(*l_element_courant_format) |
== NULL) |
.donnee).objet)) == NULL) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
d_es_allocation_memoire; |
d_es_allocation_memoire; |
Line 2211 instruction_wflock(struct_processus *s_e
|
Line 2215 instruction_wflock(struct_processus *s_e
|
|
|
do |
do |
{ |
{ |
if ((chaine = conversion_majuscule((unsigned char *) |
if ((chaine = conversion_majuscule(s_etat_processus, |
(*s_objet_argument_1).objet)) == NULL) |
(unsigned char *) (*s_objet_argument_1).objet)) == NULL) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
return; |
return; |
Line 3037 instruction_wfdata(struct_processus *s_e
|
Line 3041 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); |
|
} |
|
} |
|
|
|
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); |
|
} |
|
} |
|
|
|
// 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); |
|
} |
|
} |
|
|
|
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); |
|
} |
|
} |
|
|
|
// 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); |
|
} |
|
} |
|
|
|
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); |
|
} |
|
} |
|
|
|
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 |
void |
instruction_wfsock(struct_processus *s_etat_processus) |
instruction_wfsock(struct_processus *s_etat_processus) |
{ |
{ |
Line 3222 instruction_wfsock(struct_processus *s_e
|
Line 3335 instruction_wfsock(struct_processus *s_e
|
{ |
{ |
drapeau = d_vrai; |
drapeau = d_vrai; |
|
|
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
if (sem_post(&((*s_etat_processus).semaphore_fork)) |
if (sem_post(&((*s_etat_processus).semaphore_fork)) |
!= 0) |
!= 0) |
# else |
# else |
if (sem_post((*s_etat_processus).semaphore_fork) != 0) |
if (sem_post((*s_etat_processus).semaphore_fork) != 0) |
# endif |
# endif |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
Line 3242 instruction_wfsock(struct_processus *s_e
|
Line 3355 instruction_wfsock(struct_processus *s_e
|
erreur = errno; |
erreur = errno; |
|
|
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
while(sem_wait(&((*s_etat_processus) |
while(sem_wait(&((*s_etat_processus) |
.semaphore_fork)) != 0) |
.semaphore_fork)) != 0) |
# else |
# else |
while(sem_wait((*s_etat_processus).semaphore_fork) |
while(sem_wait((*s_etat_processus).semaphore_fork) |
!= 0) |
!= 0) |
# endif |
# endif |
{ |
{ |
if (errno != EINTR) |
if (errno != EINTR) |
Line 3280 instruction_wfsock(struct_processus *s_e
|
Line 3393 instruction_wfsock(struct_processus *s_e
|
} |
} |
else |
else |
{ |
{ |
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
while(sem_wait(&((*s_etat_processus) |
while(sem_wait(&((*s_etat_processus) |
.semaphore_fork)) != 0) |
.semaphore_fork)) != 0) |
# else |
# else |
while(sem_wait((*s_etat_processus).semaphore_fork) |
while(sem_wait((*s_etat_processus).semaphore_fork) |
!= 0) |
!= 0) |
# endif |
# endif |
{ |
{ |
if (errno != EINTR) |
if (errno != EINTR) |
{ |
{ |
Line 3295 instruction_wfsock(struct_processus *s_e
|
Line 3408 instruction_wfsock(struct_processus *s_e
|
return; |
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); |
} while(drapeau == d_faux); |
|
|
Line 3325 instruction_wfsock(struct_processus *s_e
|
Line 3449 instruction_wfsock(struct_processus *s_e
|
{ |
{ |
drapeau = d_vrai; |
drapeau = d_vrai; |
|
|
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
if (sem_post(&((*s_etat_processus).semaphore_fork)) |
if (sem_post(&((*s_etat_processus).semaphore_fork)) |
!= 0) |
!= 0) |
# else |
# else |
if (sem_post((*s_etat_processus).semaphore_fork) != 0) |
if (sem_post((*s_etat_processus).semaphore_fork) != 0) |
# endif |
# endif |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
Line 3343 instruction_wfsock(struct_processus *s_e
|
Line 3467 instruction_wfsock(struct_processus *s_e
|
{ |
{ |
erreur = errno; |
erreur = errno; |
|
|
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
while(sem_wait(&((*s_etat_processus) |
while(sem_wait(&((*s_etat_processus) |
.semaphore_fork)) != 0) |
.semaphore_fork)) != 0) |
# else |
# else |
while(sem_wait((*s_etat_processus).semaphore_fork) |
while(sem_wait((*s_etat_processus).semaphore_fork) |
!= 0) |
!= 0) |
# endif |
# endif |
{ |
{ |
if (errno != EINTR) |
if (errno != EINTR) |
{ |
{ |
Line 3382 instruction_wfsock(struct_processus *s_e
|
Line 3506 instruction_wfsock(struct_processus *s_e
|
} |
} |
else |
else |
{ |
{ |
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
while(sem_wait(&((*s_etat_processus) |
while(sem_wait(&((*s_etat_processus) |
.semaphore_fork)) != 0) |
.semaphore_fork)) != 0) |
# else |
# else |
while(sem_wait((*s_etat_processus).semaphore_fork) |
while(sem_wait((*s_etat_processus).semaphore_fork) |
!= 0) |
!= 0) |
# endif |
# endif |
{ |
{ |
if (errno != EINTR) |
if (errno != EINTR) |
{ |
{ |
Line 3397 instruction_wfsock(struct_processus *s_e
|
Line 3521 instruction_wfsock(struct_processus *s_e
|
return; |
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); |
} while(drapeau == d_faux); |
|
|
Line 3447 instruction_wfsock(struct_processus *s_e
|
Line 3582 instruction_wfsock(struct_processus *s_e
|
{ |
{ |
drapeau = d_vrai; |
drapeau = d_vrai; |
|
|
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
if (sem_post(&((*s_etat_processus).semaphore_fork)) |
if (sem_post(&((*s_etat_processus).semaphore_fork)) |
!= 0) |
!= 0) |
# else |
# else |
if (sem_post((*s_etat_processus).semaphore_fork) != 0) |
if (sem_post((*s_etat_processus).semaphore_fork) != 0) |
# endif |
# endif |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
Line 3465 instruction_wfsock(struct_processus *s_e
|
Line 3600 instruction_wfsock(struct_processus *s_e
|
{ |
{ |
erreur = errno; |
erreur = errno; |
|
|
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
while(sem_wait(&((*s_etat_processus) |
while(sem_wait(&((*s_etat_processus) |
.semaphore_fork)) != 0) |
.semaphore_fork)) != 0) |
# else |
# else |
while(sem_wait((*s_etat_processus).semaphore_fork) |
while(sem_wait((*s_etat_processus).semaphore_fork) |
!= 0) |
!= 0) |
# endif |
# endif |
{ |
{ |
if (errno != EINTR) |
if (errno != EINTR) |
{ |
{ |
Line 3504 instruction_wfsock(struct_processus *s_e
|
Line 3639 instruction_wfsock(struct_processus *s_e
|
} |
} |
else |
else |
{ |
{ |
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
while(sem_wait(&((*s_etat_processus) |
while(sem_wait(&((*s_etat_processus) |
.semaphore_fork)) != 0) |
.semaphore_fork)) != 0) |
# else |
# else |
while(sem_wait((*s_etat_processus).semaphore_fork) |
while(sem_wait((*s_etat_processus).semaphore_fork) |
!= 0) |
!= 0) |
# endif |
# endif |
{ |
{ |
if (errno != EINTR) |
if (errno != EINTR) |
{ |
{ |
Line 3519 instruction_wfsock(struct_processus *s_e
|
Line 3654 instruction_wfsock(struct_processus *s_e
|
return; |
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); |
} while(drapeau == d_faux); |
} |
} |