version 1.95, 2015/02/19 11:01:28
|
version 1.111, 2018/12/21 10:56:21
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.1.21 |
RPL/2 (R) version 4.1.29 |
Copyright (C) 1989-2015 Dr. BERTRAND Joël |
Copyright (C) 1989-2018 Dr. BERTRAND Joël |
|
|
This file is part of RPL/2. |
This file is part of RPL/2. |
|
|
Line 410 instruction_write(struct_processus *s_et
|
Line 410 instruction_write(struct_processus *s_et
|
integer8 recursivite; |
integer8 recursivite; |
|
|
logical1 format_degenere; |
logical1 format_degenere; |
|
logical1 format_oriente_ligne; |
logical1 mise_a_jour; |
logical1 mise_a_jour; |
|
|
|
|
sqlite3_stmt *ppStmt; |
sqlite3_stmt *ppStmt; |
|
|
ssize_t ios; |
ssize_t ios; |
Line 1507 instruction_write(struct_processus *s_et
|
Line 1507 instruction_write(struct_processus *s_et
|
return; |
return; |
} |
} |
|
|
if (strncmp("LENGTH*(", format_chaine, 8) != 0) |
if (strcmp("LINE*(*)", format_chaine) == 0) |
{ |
{ |
free(format_chaine); |
format_oriente_ligne = d_vrai; |
|
format_degenere = d_vrai; |
liberation(s_etat_processus, s_objet_argument_2); |
|
liberation(s_etat_processus, s_objet_argument_1); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_format_fichier; |
|
return; |
|
} |
} |
|
else |
longueur = (integer8) strlen(format_chaine); |
|
|
|
if (format_chaine[longueur - 1] != ')') |
|
{ |
{ |
free(format_chaine); |
format_oriente_ligne = d_faux; |
|
|
liberation(s_etat_processus, s_objet_argument_2); |
if (strncmp("LENGTH*(", format_chaine, 8) != 0) |
liberation(s_etat_processus, s_objet_argument_1); |
{ |
|
free(format_chaine); |
|
|
(*s_etat_processus).erreur_execution = |
liberation(s_etat_processus, s_objet_argument_2); |
d_ex_erreur_format_fichier; |
liberation(s_etat_processus, s_objet_argument_1); |
return; |
|
} |
|
|
|
format_chaine[longueur] = d_code_fin_chaine; |
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_format_fichier; |
|
return; |
|
} |
|
|
if (format_chaine[8] == '*') |
longueur = (integer8) strlen(format_chaine); |
{ |
|
format_degenere = d_vrai; |
|
} |
|
else |
|
{ |
|
// Détermination de la longueur |
|
format_degenere = d_faux; |
|
|
|
if (sscanf(&(format_chaine[8]), "%lld", &longueur) != 1) |
if (format_chaine[longueur - 1] != ')') |
{ |
{ |
free(format_chaine); |
free(format_chaine); |
|
|
Line 1555 instruction_write(struct_processus *s_et
|
Line 1541 instruction_write(struct_processus *s_et
|
d_ex_erreur_format_fichier; |
d_ex_erreur_format_fichier; |
return; |
return; |
} |
} |
|
|
|
format_chaine[longueur] = d_code_fin_chaine; |
|
|
|
if (format_chaine[8] == '*') |
|
{ |
|
format_degenere = d_vrai; |
|
} |
|
else |
|
{ |
|
// Détermination de la longueur |
|
format_degenere = d_faux; |
|
|
|
if (sscanf(&(format_chaine[8]), "%lld", &longueur) |
|
!= 1) |
|
{ |
|
free(format_chaine); |
|
|
|
liberation(s_etat_processus, |
|
s_objet_argument_2); |
|
liberation(s_etat_processus, |
|
s_objet_argument_1); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_format_fichier; |
|
return; |
|
} |
|
} |
} |
} |
|
|
free(format_chaine); |
free(format_chaine); |
Line 1596 instruction_write(struct_processus *s_et
|
Line 1609 instruction_write(struct_processus *s_et
|
|
|
free(chaine); |
free(chaine); |
|
|
|
if (format_oriente_ligne == d_vrai) |
|
{ |
|
if (fwrite("\n", 1, 1, (*descripteur).descripteur_c) |
|
!= 1) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_erreur_fichier; |
|
return; |
|
} |
|
} |
|
|
l_element_courant = (*l_element_courant).suivant; |
l_element_courant = (*l_element_courant).suivant; |
l_element_courant_format = (*l_element_courant_format) |
l_element_courant_format = (*l_element_courant_format) |
.suivant; |
.suivant; |
Line 2522 instruction_wfproc(struct_processus *s_e
|
Line 2546 instruction_wfproc(struct_processus *s_e
|
{ |
{ |
if (envoi_signal_processus((*(*((struct_processus_fils *) |
if (envoi_signal_processus((*(*((struct_processus_fils *) |
(*(*l_element_courant).donnee).objet)).thread).pid, |
(*(*l_element_courant).donnee).objet)).thread).pid, |
rpl_signull) != 0) |
rpl_signull, d_faux) != 0) |
{ |
{ |
drapeau_fin = d_vrai; |
drapeau_fin = d_vrai; |
} |
} |
Line 3041 instruction_wfdata(struct_processus *s_e
|
Line 3065 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 |
void |
instruction_wfsock(struct_processus *s_etat_processus) |
instruction_wfsock(struct_processus *s_etat_processus) |
{ |
{ |
Line 3062 instruction_wfsock(struct_processus *s_e
|
Line 3201 instruction_wfsock(struct_processus *s_e
|
struct sockaddr_in6 adresse_ipv6; |
struct sockaddr_in6 adresse_ipv6; |
# endif |
# endif |
|
|
unsigned long i; |
|
|
|
if ((*s_etat_processus).affichage_arguments == 'Y') |
if ((*s_etat_processus).affichage_arguments == 'Y') |
{ |
{ |
printf("\n WFSOCK "); |
printf("\n WFSOCK "); |
Line 3226 instruction_wfsock(struct_processus *s_e
|
Line 3363 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 3246 instruction_wfsock(struct_processus *s_e
|
Line 3383 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 3284 instruction_wfsock(struct_processus *s_e
|
Line 3421 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 3299 instruction_wfsock(struct_processus *s_e
|
Line 3436 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 3329 instruction_wfsock(struct_processus *s_e
|
Line 3477 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 3347 instruction_wfsock(struct_processus *s_e
|
Line 3495 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 3386 instruction_wfsock(struct_processus *s_e
|
Line 3534 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 3401 instruction_wfsock(struct_processus *s_e
|
Line 3549 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); |
|
|
if (((*((struct_socket *) (*s_objet_resultat).objet)) |
if (((*((struct_socket *) (*s_objet_resultat).objet)) |
.adresse_distante = malloc(55 * |
.adresse_distante = malloc(47 * |
sizeof(unsigned char))) == NULL) |
sizeof(unsigned char))) == NULL) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
Line 3413 instruction_wfsock(struct_processus *s_e
|
Line 3572 instruction_wfsock(struct_processus *s_e
|
return; |
return; |
} |
} |
|
|
(*((struct_socket *) (*s_objet_resultat).objet)) |
|
.adresse_distante = d_code_fin_chaine; |
|
|
|
for(i = 0; i < 16; i++) |
|
{ |
|
sprintf((*((struct_socket *) (*s_objet_resultat) |
|
.objet)).adresse_distante, (i == 0) ? "%s%X" |
|
: "%s:%X", (*((struct_socket *) (*s_objet_resultat) |
|
.objet)).adresse_distante, |
|
adresse_ipv6.sin6_addr.s6_addr[i]); |
|
} |
|
|
|
sprintf((*((struct_socket *) (*s_objet_resultat) |
sprintf((*((struct_socket *) (*s_objet_resultat) |
.objet)).adresse_distante, "%s(%u)", |
|
(*((struct_socket *) (*s_objet_resultat) |
|
.objet)).adresse_distante, |
.objet)).adresse_distante, |
|
"%02X%02X:%02X%02X:%02X%02X:%02X%02X:" |
|
"%02X%02X:%02X%02X:%02X%02X:%02X%02X(%u)", |
|
adresse_ipv6.sin6_addr.s6_addr[0], |
|
adresse_ipv6.sin6_addr.s6_addr[1], |
|
adresse_ipv6.sin6_addr.s6_addr[2], |
|
adresse_ipv6.sin6_addr.s6_addr[3], |
|
adresse_ipv6.sin6_addr.s6_addr[4], |
|
adresse_ipv6.sin6_addr.s6_addr[5], |
|
adresse_ipv6.sin6_addr.s6_addr[6], |
|
adresse_ipv6.sin6_addr.s6_addr[7], |
|
adresse_ipv6.sin6_addr.s6_addr[8], |
|
adresse_ipv6.sin6_addr.s6_addr[9], |
|
adresse_ipv6.sin6_addr.s6_addr[10], |
|
adresse_ipv6.sin6_addr.s6_addr[11], |
|
adresse_ipv6.sin6_addr.s6_addr[12], |
|
adresse_ipv6.sin6_addr.s6_addr[13], |
|
adresse_ipv6.sin6_addr.s6_addr[14], |
|
adresse_ipv6.sin6_addr.s6_addr[15], |
ntohs(adresse_ipv6.sin6_port)); |
ntohs(adresse_ipv6.sin6_port)); |
# else |
# else |
if ((*s_etat_processus).langue == 'F') |
if ((*s_etat_processus).langue == 'F') |
Line 3451 instruction_wfsock(struct_processus *s_e
|
Line 3614 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 3469 instruction_wfsock(struct_processus *s_e
|
Line 3632 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 3508 instruction_wfsock(struct_processus *s_e
|
Line 3671 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 3523 instruction_wfsock(struct_processus *s_e
|
Line 3686 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); |
} |
} |