version 1.100, 2015/11/26 11:44:41
|
version 1.121, 2020/04/06 10:14:06
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.1.24 |
RPL/2 (R) version 4.1.32 |
Copyright (C) 1989-2015 Dr. BERTRAND Joël |
Copyright (C) 1989-2020 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 1361 instruction_write(struct_processus *s_et
|
Line 1361 instruction_write(struct_processus *s_et
|
return; |
return; |
} |
} |
|
|
if (fwrite(chaine, sizeof(unsigned char), |
if (write(fileno((*descripteur).descripteur_c), |
(size_t) longueur_effective, |
chaine, (size_t) longueur_effective) != |
(*descripteur).descripteur_c) != |
(ssize_t) longueur_effective) |
(size_t) longueur_effective) |
|
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
return; |
return; |
Line 1507 instruction_write(struct_processus *s_et
|
Line 1506 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 1540 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 1571 instruction_write(struct_processus *s_et
|
Line 1583 instruction_write(struct_processus *s_et
|
if ((format_degenere == d_vrai) || |
if ((format_degenere == d_vrai) || |
(longueur_effective < longueur)) |
(longueur_effective < longueur)) |
{ |
{ |
if (fwrite(chaine, sizeof(unsigned char), |
if (write(fileno((*descripteur).descripteur_c), |
(size_t) longueur_effective, |
chaine, (size_t) longueur_effective) |
(*descripteur).descripteur_c) != |
!= (ssize_t) longueur_effective) |
(size_t) longueur_effective) |
|
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
d_es_erreur_fichier; |
d_es_erreur_fichier; |
Line 1583 instruction_write(struct_processus *s_et
|
Line 1594 instruction_write(struct_processus *s_et
|
} |
} |
else |
else |
{ |
{ |
if (fwrite(chaine, sizeof(unsigned char), |
if (write(fileno((*descripteur).descripteur_c), |
(size_t) longueur_effective, |
chaine, (size_t) longueur_effective) |
(*descripteur).descripteur_c) != |
!= (ssize_t) longueur) |
(size_t) longueur) |
|
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
d_es_erreur_fichier; |
d_es_erreur_fichier; |
Line 1596 instruction_write(struct_processus *s_et
|
Line 1606 instruction_write(struct_processus *s_et
|
|
|
free(chaine); |
free(chaine); |
|
|
|
if (format_oriente_ligne == d_vrai) |
|
{ |
|
if (write(fileno((*descripteur).descripteur_c), |
|
"\n", 1) != 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 1708 instruction_write(struct_processus *s_et
|
Line 1729 instruction_write(struct_processus *s_et
|
(*s_objet_argument_1).objet)).type, |
(*s_objet_argument_1).objet)).type, |
"SEQUENTIAL DATAGRAM") == 0)) |
"SEQUENTIAL DATAGRAM") == 0)) |
{ // Sockets connectées |
{ // Sockets connectées |
|
|
action.sa_handler = SIG_IGN; |
|
action.sa_flags = SA_ONSTACK; |
|
|
|
if (sigaction(SIGPIPE, &action, ®istre) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_signal; |
|
return; |
|
} |
|
|
|
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) |
if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) |
# else |
# else |
if (sem_post((*s_etat_processus).semaphore_fork) != 0) |
if (sem_post((*s_etat_processus).semaphore_fork) != 0) |
# endif |
# endif |
{ |
{ |
if (sigaction(SIGPIPE, ®istre, NULL) != 0) |
(*s_etat_processus).erreur_systeme = d_es_processus; |
{ |
return; |
(*s_etat_processus).erreur_systeme = d_es_signal; |
} |
return; |
|
} |
|
|
|
|
if (pthread_mutex_lock(&mutex_sigaction) != 0) |
|
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
} |
} |
|
|
|
action.sa_handler = SIG_IGN; |
|
action.sa_flags = 0; |
|
|
|
if (sigaction(SIGPIPE, &action, ®istre) != 0) |
|
{ |
|
pthread_mutex_unlock(&mutex_sigaction); |
|
(*s_etat_processus).erreur_systeme = d_es_signal; |
|
return; |
|
} |
|
|
if (send((*((struct_socket *) (*s_objet_argument_1).objet)) |
if (send((*((struct_socket *) (*s_objet_argument_1).objet)) |
.socket, chaine, (size_t) longueur_effective, 0) < 0) |
.socket, chaine, (size_t) longueur_effective, 0) < 0) |
{ |
{ |
Line 1741 instruction_write(struct_processus *s_et
|
Line 1762 instruction_write(struct_processus *s_et
|
|
|
if (sigaction(SIGPIPE, ®istre, NULL) != 0) |
if (sigaction(SIGPIPE, ®istre, NULL) != 0) |
{ |
{ |
|
pthread_mutex_unlock(&mutex_sigaction); |
(*s_etat_processus).erreur_systeme = d_es_signal; |
(*s_etat_processus).erreur_systeme = d_es_signal; |
return; |
return; |
} |
} |
|
|
|
if (pthread_mutex_unlock(&mutex_sigaction) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
|
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) |
while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) |
# else |
# else |
Line 1769 instruction_write(struct_processus *s_et
|
Line 1797 instruction_write(struct_processus *s_et
|
return; |
return; |
} |
} |
|
|
|
if (sigaction(SIGPIPE, ®istre, NULL) != 0) |
|
{ |
|
pthread_mutex_unlock(&mutex_sigaction); |
|
|
|
# ifndef SEMAPHORES_NOMMES |
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) |
|
# else |
|
while(sem_wait((*s_etat_processus).semaphore_fork) != 0) |
|
# endif |
|
{ |
|
if (errno != EINTR) |
|
{ |
|
if (sigaction(SIGPIPE, ®istre, NULL) != 0) |
|
{ |
|
pthread_mutex_unlock(&mutex_sigaction); |
|
(*s_etat_processus).erreur_systeme = d_es_signal; |
|
return; |
|
} |
|
|
|
pthread_mutex_unlock(&mutex_sigaction); |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
} |
|
|
|
(*s_etat_processus).erreur_systeme = d_es_signal; |
|
return; |
|
} |
|
|
|
if (pthread_mutex_unlock(&mutex_sigaction) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
|
# ifndef SEMAPHORES_NOMMES |
# ifndef SEMAPHORES_NOMMES |
while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) |
while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) |
# else |
# else |
Line 1787 instruction_write(struct_processus *s_et
|
Line 1850 instruction_write(struct_processus *s_et
|
return; |
return; |
} |
} |
} |
} |
|
|
if (sigaction(SIGPIPE, ®istre, NULL) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_signal; |
|
return; |
|
} |
|
} |
} |
else |
else |
{ // Sockets non connectées |
{ // Sockets non connectées |
Line 2268 instruction_wflock(struct_processus *s_e
|
Line 2325 instruction_wflock(struct_processus *s_e
|
return; |
return; |
} |
} |
|
|
# ifndef SEMAPHORES_NOMMES |
|
if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) |
|
# else |
|
if (sem_post((*s_etat_processus).semaphore_fork) != 0) |
|
# endif |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
|
|
# ifndef SEMAPHORES_NOMMES |
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) |
|
# else |
|
while(sem_wait((*s_etat_processus).semaphore_fork) != 0) |
|
# endif |
|
{ |
|
if (errno != EINTR) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
} |
|
|
|
if (lock.l_type == F_UNLCK) |
if (lock.l_type == F_UNLCK) |
{ |
{ |
drapeau = d_vrai; |
drapeau = d_vrai; |
Line 2326 instruction_wflock(struct_processus *s_e
|
Line 2360 instruction_wflock(struct_processus *s_e
|
registre_instruction_valide; |
registre_instruction_valide; |
} |
} |
|
|
nanosleep(&attente, NULL); |
|
scrutation_injection(s_etat_processus); |
scrutation_injection(s_etat_processus); |
|
|
|
# ifndef SEMAPHORES_NOMMES |
|
if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) |
|
# else |
|
if (sem_post((*s_etat_processus).semaphore_fork) != 0) |
|
# endif |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
|
|
nanosleep(&attente, NULL); |
|
|
INCR_GRANULARITE(attente.tv_nsec); |
INCR_GRANULARITE(attente.tv_nsec); |
|
|
|
# ifndef SEMAPHORES_NOMMES |
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) |
|
# else |
|
while(sem_wait((*s_etat_processus).semaphore_fork) != 0) |
|
# endif |
|
{ |
|
if (errno != EINTR) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
} |
} |
} |
} while((drapeau == d_faux) && ((*s_etat_processus) |
} while((drapeau == d_faux) && ((*s_etat_processus) |
.var_volatile_requete_arret != -1)); |
.var_volatile_requete_arret != -1)); |
Line 2522 instruction_wfproc(struct_processus *s_e
|
Line 2580 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 3073 options_sockets(struct_processus *s_etat
|
Line 3131 options_sockets(struct_processus *s_etat
|
} |
} |
} |
} |
|
|
|
# ifdef SO_PRIORITY |
if (((*s_socket).options & (1 << d_PRIORITY)) != 0) |
if (((*s_socket).options & (1 << d_PRIORITY)) != 0) |
{ |
{ |
if (setsockopt((*s_socket).socket, SOL_SOCKET, SO_PRIORITY, |
if (setsockopt((*s_socket).socket, SOL_SOCKET, SO_PRIORITY, |
Line 3081 options_sockets(struct_processus *s_etat
|
Line 3140 options_sockets(struct_processus *s_etat
|
return(d_erreur); |
return(d_erreur); |
} |
} |
} |
} |
|
# endif |
|
|
// Les deux options suivantes ne peuvent être positionnées simultanément. |
// Les deux options suivantes ne peuvent être positionnées simultanément. |
|
|
Line 3094 options_sockets(struct_processus *s_etat
|
Line 3154 options_sockets(struct_processus *s_etat
|
} |
} |
} |
} |
|
|
|
# ifdef SO_RCVBUFFORCE |
if (((*s_socket).options & (1 << d_FORCE_RECEIVE_BUFFER)) != 0) |
if (((*s_socket).options & (1 << d_FORCE_RECEIVE_BUFFER)) != 0) |
{ |
{ |
if (setsockopt((*s_socket).socket, SOL_SOCKET, SO_RCVBUFFORCE, |
if (setsockopt((*s_socket).socket, SOL_SOCKET, SO_RCVBUFFORCE, |
Line 3103 options_sockets(struct_processus *s_etat
|
Line 3164 options_sockets(struct_processus *s_etat
|
return(d_erreur); |
return(d_erreur); |
} |
} |
} |
} |
|
# endif |
|
|
// Même remarque |
// Même remarque |
|
|
Line 3116 options_sockets(struct_processus *s_etat
|
Line 3178 options_sockets(struct_processus *s_etat
|
} |
} |
} |
} |
|
|
|
# ifdef SO_SNDBUFFORCE |
if (((*s_socket).options & (1 << d_FORCE_SEND_BUFFER)) != 0) |
if (((*s_socket).options & (1 << d_FORCE_SEND_BUFFER)) != 0) |
{ |
{ |
if (setsockopt((*s_socket).socket, SOL_SOCKET, SO_SNDBUFFORCE, |
if (setsockopt((*s_socket).socket, SOL_SOCKET, SO_SNDBUFFORCE, |
Line 3125 options_sockets(struct_processus *s_etat
|
Line 3188 options_sockets(struct_processus *s_etat
|
return(d_erreur); |
return(d_erreur); |
} |
} |
} |
} |
|
# endif |
|
|
if (((*s_socket).options & (1 << d_RECEIVING_TIMEOUT)) != 0) |
if (((*s_socket).options & (1 << d_RECEIVING_TIMEOUT)) != 0) |
{ |
{ |
Line 3171 instruction_wfsock(struct_processus *s_e
|
Line 3235 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 3536 instruction_wfsock(struct_processus *s_e
|
Line 3598 instruction_wfsock(struct_processus *s_e
|
} 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 3544 instruction_wfsock(struct_processus *s_e
|
Line 3606 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 3860 instruction_wfswi(struct_processus *s_et
|
Line 3926 instruction_wfswi(struct_processus *s_et
|
} |
} |
else |
else |
{ |
{ |
|
# ifndef SEMAPHORES_NOMMES |
|
if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) |
|
# else |
|
if (sem_post((*s_etat_processus).semaphore_fork) != 0) |
|
# endif |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
nanosleep(&attente, NULL); |
nanosleep(&attente, NULL); |
|
|
|
# ifndef SEMAPHORES_NOMMES |
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) |
|
# else |
|
while(sem_wait((*s_etat_processus).semaphore_fork) != 0) |
|
# endif |
|
{ |
|
if (errno != EINTR) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
} |
|
|
scrutation_injection(s_etat_processus); |
scrutation_injection(s_etat_processus); |
INCR_GRANULARITE(attente.tv_nsec); |
INCR_GRANULARITE(attente.tv_nsec); |
} |
} |