version 1.7, 2010/03/08 08:34:15
|
version 1.52, 2011/09/26 15:57:16
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.0.12 |
RPL/2 (R) version 4.1.4 |
Copyright (C) 1989-2010 Dr. BERTRAND Joël |
Copyright (C) 1989-2011 Dr. BERTRAND Joël |
|
|
This file is part of RPL/2. |
This file is part of RPL/2. |
|
|
Line 20
|
Line 20
|
*/ |
*/ |
|
|
|
|
#include "rpl.conv.h" |
#include "rpl-conv.h" |
|
|
|
|
/* |
/* |
Line 124 instruction_while(struct_processus *s_et
|
Line 124 instruction_while(struct_processus *s_et
|
void |
void |
instruction_warranty(struct_processus *s_etat_processus) |
instruction_warranty(struct_processus *s_etat_processus) |
{ |
{ |
# include "garanties.conv.h" |
# include "garanties-conv.h" |
|
|
(*s_etat_processus).erreur_execution = d_ex; |
(*s_etat_processus).erreur_execution = d_ex; |
|
|
Line 226 instruction_wait(struct_processus *s_eta
|
Line 226 instruction_wait(struct_processus *s_eta
|
return; |
return; |
} |
} |
|
|
if (((*s_objet).type == INT) || |
if (((*s_objet).type == INT) || ((*s_objet).type == REL)) |
((*s_objet).type == REL)) |
|
{ |
{ |
if ((*s_objet).type == INT) |
if ((*s_objet).type == INT) |
{ |
{ |
Line 262 instruction_wait(struct_processus *s_eta
|
Line 261 instruction_wait(struct_processus *s_eta
|
|
|
do |
do |
{ |
{ |
if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) |
# 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; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
Line 271 instruction_wait(struct_processus *s_eta
|
Line 274 instruction_wait(struct_processus *s_eta
|
code_retour = nanosleep(&temporisation, &temporisation); |
code_retour = nanosleep(&temporisation, &temporisation); |
erreur = errno; |
erreur = errno; |
|
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1) |
# 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 (errno != EINTR) |
{ |
{ |
Line 379 instruction_write(struct_processus *s_et
|
Line 386 instruction_write(struct_processus *s_et
|
int adresse[16]; |
int adresse[16]; |
int port; |
int port; |
|
|
|
integer8 clef; |
|
integer8 compteur; |
|
integer8 id; |
|
integer8 ordre; |
|
|
|
logical1 mise_a_jour; |
|
|
long longueur_effective; |
long longueur_effective; |
long recursivite; |
long recursivite; |
|
|
Line 388 instruction_write(struct_processus *s_et
|
Line 402 instruction_write(struct_processus *s_et
|
|
|
struct_descripteur_fichier *descripteur; |
struct_descripteur_fichier *descripteur; |
|
|
|
struct_liste_chainee *l_element_courant; |
|
struct_liste_chainee *l_element_courant_format; |
|
|
|
struct_objet *s_format; |
|
struct_objet *s_element; |
struct_objet *s_objet_argument_1; |
struct_objet *s_objet_argument_1; |
struct_objet *s_objet_argument_2; |
struct_objet *s_objet_argument_2; |
struct_objet *s_objet_argument_3; |
struct_objet *s_objet_argument_3; |
Line 396 instruction_write(struct_processus *s_et
|
Line 415 instruction_write(struct_processus *s_et
|
struct sigaction registre; |
struct sigaction registre; |
|
|
struct sockaddr_in adresse_ipv4; |
struct sockaddr_in adresse_ipv4; |
|
# ifdef IPV6 |
struct sockaddr_in6 adresse_ipv6; |
struct sockaddr_in6 adresse_ipv6; |
|
# endif |
struct sockaddr_un adresse_unix; |
struct sockaddr_un adresse_unix; |
|
|
struct flock lock; |
struct flock lock; |
Line 405 instruction_write(struct_processus *s_et
|
Line 426 instruction_write(struct_processus *s_et
|
|
|
unsigned char *chaine; |
unsigned char *chaine; |
unsigned char *chaine_utf8; |
unsigned char *chaine_utf8; |
|
unsigned char *clef_utf8; |
unsigned char *commande; |
unsigned char *commande; |
|
|
unsigned long i; |
unsigned long i; |
Line 428 instruction_write(struct_processus *s_et
|
Line 450 instruction_write(struct_processus *s_et
|
printf(" 1: %s, %s\n\n", d_FCH, d_SCK); |
printf(" 1: %s, %s\n\n", d_FCH, d_SCK); |
|
|
printf(" 3: %s\n", d_LST); |
printf(" 3: %s\n", d_LST); |
printf(" 2: %s, %s\n", d_INT, d_CHN); |
printf(" 2: %s\n", d_INT); |
printf(" 1: %s\n", d_FCH); |
printf(" 1: %s\n", d_FCH); |
return; |
return; |
} |
} |
Line 449 instruction_write(struct_processus *s_et
|
Line 471 instruction_write(struct_processus *s_et
|
if ((*(*(*s_etat_processus).l_base_pile).donnee).type == FCH) |
if ((*(*(*s_etat_processus).l_base_pile).donnee).type == FCH) |
{ |
{ |
if ((*((struct_fichier *) (*(*(*s_etat_processus).l_base_pile) |
if ((*((struct_fichier *) (*(*(*s_etat_processus).l_base_pile) |
.donnee).objet)).acces == 'S') |
.donnee).objet)).acces == 'D') |
{ |
{ |
if (empilement_pile_last(s_etat_processus, 2) == d_erreur) |
if (empilement_pile_last(s_etat_processus, 3) == d_erreur) |
{ |
{ |
return; |
return; |
} |
} |
} |
} |
else |
else |
{ |
{ |
if (empilement_pile_last(s_etat_processus, 3) == d_erreur) |
if (empilement_pile_last(s_etat_processus, 2) == d_erreur) |
{ |
{ |
return; |
return; |
} |
} |
Line 641 instruction_write(struct_processus *s_et
|
Line 663 instruction_write(struct_processus *s_et
|
return; |
return; |
} |
} |
|
|
if ((*s_objet_argument_3).objet == NULL) |
// Modification ou création d'un nouvel enregistrement |
|
|
|
if ((chaine = formateur_fichier(s_etat_processus, |
|
s_objet_argument_3, (*((struct_fichier *) |
|
(*s_objet_argument_1).objet)).format, 0, 0, ' ', |
|
'F', &longueur_effective, &recursivite)) == NULL) |
{ |
{ |
// Effacement d'un enregistrement |
liberation(s_etat_processus, s_objet_argument_3); |
|
liberation(s_etat_processus, s_objet_argument_2); |
|
liberation(s_etat_processus, s_objet_argument_1); |
|
|
if (alsprintf(&commande, "delete from data where " |
return; |
"id = %lld", (*((integer8 *) |
} |
(*s_objet_argument_2).objet))) < 0) |
|
{ |
|
liberation(s_etat_processus, s_objet_argument_3); |
|
liberation(s_etat_processus, s_objet_argument_2); |
|
liberation(s_etat_processus, s_objet_argument_1); |
|
|
|
return; |
if ((chaine_utf8 = transliteration(s_etat_processus, |
|
chaine, d_locale, "UTF-8")) == NULL) |
|
{ |
|
free(chaine); |
|
|
|
liberation(s_etat_processus, s_objet_argument_3); |
|
liberation(s_etat_processus, s_objet_argument_2); |
|
liberation(s_etat_processus, s_objet_argument_1); |
|
|
|
return; |
|
} |
|
|
|
free(chaine); |
|
|
|
if (alsprintf(&commande, "insert or replace into data " |
|
"(id, data) values (%lld, '%s')", (*((integer8 *) |
|
(*s_objet_argument_2).objet)), chaine_utf8) < 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
free(chaine_utf8); |
|
|
|
if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite, |
|
commande, strlen(commande), &ppStmt, &queue) |
|
!= SQLITE_OK) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
|
return; |
|
} |
|
|
|
if (sqlite3_step(ppStmt) != SQLITE_DONE) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
|
return; |
|
} |
|
|
|
if (sqlite3_finalize(ppStmt) != SQLITE_OK) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
|
return; |
|
} |
|
|
|
liberation(s_etat_processus, s_objet_argument_3); |
|
free(commande); |
|
} |
|
else // Fichiers indexés |
|
{ |
|
BUG(((*descripteur).type != 'S'), uprintf("Bad filetype !\n")); |
|
|
|
if ((*s_objet_argument_2).type != LST) |
|
{ |
|
liberation(s_etat_processus, s_objet_argument_2); |
|
liberation(s_etat_processus, s_objet_argument_1); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_type_argument; |
|
return; |
|
} |
|
|
|
// Récupération de la position de la clef |
|
|
|
if (alsprintf(&commande, "select key from control " |
|
"where id = 1") < 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite, |
|
commande, strlen(commande), &ppStmt, &queue) |
|
!= SQLITE_OK) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
|
return; |
|
} |
|
|
|
if (sqlite3_step(ppStmt) != SQLITE_ROW) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
|
return; |
|
} |
|
|
|
if (sqlite3_column_type(ppStmt, 0) != SQLITE_INTEGER) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
|
return; |
|
} |
|
|
|
clef = sqlite3_column_int64(ppStmt, 0); |
|
|
|
if (sqlite3_step(ppStmt) != SQLITE_DONE) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
|
return; |
|
} |
|
|
|
if (sqlite3_finalize(ppStmt) != SQLITE_OK) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
|
return; |
|
} |
|
|
|
free(commande); |
|
|
|
l_element_courant = (struct_liste_chainee *) |
|
(*s_objet_argument_2).objet; |
|
l_element_courant_format = (struct_liste_chainee *) |
|
(*(*((struct_fichier *) (*s_objet_argument_1).objet)) |
|
.format).objet; |
|
compteur = 1; |
|
|
|
while((l_element_courant != NULL) && |
|
(l_element_courant_format != NULL)) |
|
{ |
|
if (compteur == clef) |
|
{ |
|
break; |
} |
} |
|
|
|
l_element_courant = (*l_element_courant).suivant; |
|
l_element_courant_format = (*l_element_courant_format) |
|
.suivant; |
|
compteur++; |
} |
} |
else |
|
|
if ((l_element_courant == NULL) || |
|
(l_element_courant_format == NULL)) |
{ |
{ |
// Modification ou création d'un nouvel enregistrement |
(*s_etat_processus).erreur_execution = |
|
d_ex_clef_inexistante; |
|
|
|
liberation(s_etat_processus, s_objet_argument_2); |
|
liberation(s_etat_processus, s_objet_argument_1); |
|
|
if ((chaine = formateur_fichier(s_etat_processus, |
return; |
s_objet_argument_3, (*((struct_fichier *) |
} |
(*s_objet_argument_1).objet)).format, 0, 0, ' ', |
|
'F', &longueur_effective, &recursivite)) == NULL) |
if ((s_element = allocation(s_etat_processus, LST)) == NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
if (((*s_element).objet = allocation_maillon(s_etat_processus)) |
|
== NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
(*((struct_liste_chainee *) (*s_element).objet)).suivant = NULL; |
|
|
|
if (((*((struct_liste_chainee *) (*s_element).objet)) |
|
.donnee = copie_objet(s_etat_processus, |
|
(*l_element_courant).donnee, 'N')) == NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
if ((s_format = allocation(s_etat_processus, LST)) == NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
if (((*s_format).objet = allocation_maillon(s_etat_processus)) |
|
== NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
(*((struct_liste_chainee *) (*s_format).objet)).suivant = NULL; |
|
|
|
if (((*((struct_liste_chainee *) (*s_format).objet)) |
|
.donnee = copie_objet(s_etat_processus, |
|
(*l_element_courant_format).donnee, 'N')) == NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
if ((chaine = formateur_fichier(s_etat_processus, |
|
s_element, s_format, 0, 0, ' ', |
|
'F', &longueur_effective, &recursivite)) == NULL) |
|
{ |
|
liberation(s_etat_processus, s_element); |
|
liberation(s_etat_processus, s_format); |
|
liberation(s_etat_processus, s_objet_argument_2); |
|
liberation(s_etat_processus, s_objet_argument_1); |
|
|
|
return; |
|
} |
|
|
|
liberation(s_etat_processus, s_element); |
|
liberation(s_etat_processus, s_format); |
|
|
|
if ((clef_utf8 = transliteration(s_etat_processus, |
|
chaine, d_locale, "UTF-8")) == NULL) |
|
{ |
|
liberation(s_etat_processus, s_objet_argument_2); |
|
liberation(s_etat_processus, s_objet_argument_1); |
|
|
|
return; |
|
} |
|
|
|
free(chaine); |
|
|
|
// Récupération de l'identifiant de la clef |
|
|
|
if (alsprintf(&commande, "select id from key where key = " |
|
"'%s'", clef_utf8) < 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite, |
|
commande, strlen(commande), &ppStmt, &queue) |
|
!= SQLITE_OK) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
|
return; |
|
} |
|
|
|
switch(sqlite3_step(ppStmt)) |
|
{ |
|
case SQLITE_ROW: |
{ |
{ |
liberation(s_etat_processus, s_objet_argument_3); |
// Une clef existe. |
liberation(s_etat_processus, s_objet_argument_2); |
|
liberation(s_etat_processus, s_objet_argument_1); |
|
|
|
return; |
mise_a_jour = d_vrai; |
|
break; |
} |
} |
|
|
if ((chaine_utf8 = transliteration(s_etat_processus, |
case SQLITE_DONE: |
chaine, d_locale, "UTF-8")) == NULL) |
|
{ |
{ |
free(chaine); |
// Aucune clef n'existe. |
|
|
liberation(s_etat_processus, s_objet_argument_3); |
mise_a_jour = d_faux; |
liberation(s_etat_processus, s_objet_argument_2); |
|
liberation(s_etat_processus, s_objet_argument_1); |
if (sqlite3_finalize(ppStmt) != SQLITE_OK) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_erreur_fichier; |
|
return; |
|
} |
|
|
|
free(commande); |
|
|
|
if (alsprintf(&commande, "insert into key " |
|
"(key) values ('%s')", clef_utf8) < 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
if (sqlite3_prepare_v2((*descripteur) |
|
.descripteur_sqlite, |
|
commande, strlen(commande), &ppStmt, &queue) |
|
!= SQLITE_OK) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_erreur_fichier; |
|
return; |
|
} |
|
|
|
if (sqlite3_step(ppStmt) != SQLITE_DONE) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_erreur_fichier; |
|
return; |
|
} |
|
|
|
if (sqlite3_finalize(ppStmt) != SQLITE_OK) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_erreur_fichier; |
|
return; |
|
} |
|
|
|
free(commande); |
|
|
|
if (alsprintf(&commande, "select id from key " |
|
"where key = '%s'", clef_utf8) < 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
if (sqlite3_prepare_v2((*descripteur) |
|
.descripteur_sqlite, |
|
commande, strlen(commande), &ppStmt, &queue) |
|
!= SQLITE_OK) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_erreur_fichier; |
|
return; |
|
} |
|
|
|
if (sqlite3_step(ppStmt) != SQLITE_ROW) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_erreur_fichier; |
|
return; |
|
} |
|
|
|
break; |
|
} |
|
|
|
default: |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_erreur_fichier; |
return; |
return; |
} |
} |
|
} |
|
|
free(chaine); |
if (sqlite3_column_type(ppStmt, 0) != SQLITE_INTEGER) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
|
return; |
|
} |
|
|
|
id = sqlite3_column_int64(ppStmt, 0); |
|
|
|
if (sqlite3_step(ppStmt) != SQLITE_DONE) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
|
return; |
|
} |
|
|
|
if (sqlite3_finalize(ppStmt) != SQLITE_OK) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
|
return; |
|
} |
|
|
|
free(commande); |
|
|
|
// Modification de la clef |
|
|
if (alsprintf(&commande, "insert or replace into data " |
if (mise_a_jour == d_vrai) |
"(id, data) values (%lld, '%s')", (*((integer8 *) |
{ |
(*s_objet_argument_2).objet)), chaine_utf8) < 0) |
if (alsprintf(&commande, "update key set key = '%s' where " |
|
"id = %lld", clef_utf8, id) < 0) |
{ |
{ |
free(chaine_utf8); |
(*s_etat_processus).erreur_systeme = |
liberation(s_etat_processus, s_objet_argument_3); |
d_es_allocation_memoire; |
liberation(s_etat_processus, s_objet_argument_2); |
return; |
liberation(s_etat_processus, s_objet_argument_1); |
} |
|
|
|
if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite, |
|
commande, strlen(commande), &ppStmt, &queue) |
|
!= SQLITE_OK) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_erreur_fichier; |
return; |
return; |
} |
} |
|
|
free(chaine_utf8); |
if (sqlite3_step(ppStmt) != SQLITE_DONE) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_erreur_fichier; |
|
return; |
|
} |
|
|
|
if (sqlite3_finalize(ppStmt) != SQLITE_OK) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_erreur_fichier; |
|
return; |
|
} |
|
|
|
free(commande); |
|
} |
|
|
|
// Effacement de l'enregistrement existant |
|
|
|
if (alsprintf(&commande, "delete from data where " |
|
"key_id = %lld", id) < 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return; |
} |
} |
|
|
if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite, |
if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite, |
Line 721 instruction_write(struct_processus *s_et
|
Line 1099 instruction_write(struct_processus *s_et
|
return; |
return; |
} |
} |
|
|
liberation(s_etat_processus, s_objet_argument_3); |
|
free(commande); |
free(commande); |
} |
|
else |
// Modification ou création d'un nouvel enregistrement |
{ |
|
/* Fichiers indexés : panique totale ! */ |
l_element_courant = (struct_liste_chainee *) |
|
(*s_objet_argument_2).objet; |
|
l_element_courant_format = (struct_liste_chainee *) |
|
(*(*((struct_fichier *) (*s_objet_argument_1).objet)) |
|
.format).objet; |
|
compteur = 1; |
|
ordre = 1; |
|
|
|
while((l_element_courant != NULL) && |
|
(l_element_courant_format != NULL)) |
|
{ |
|
if (compteur == clef) |
|
{ |
|
l_element_courant = (*l_element_courant).suivant; |
|
l_element_courant_format = (*l_element_courant_format) |
|
.suivant; |
|
compteur++; |
|
continue; |
|
} |
|
|
|
if ((s_element = allocation(s_etat_processus, LST)) == NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
if (((*s_element).objet = |
|
allocation_maillon(s_etat_processus)) == NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
(*((struct_liste_chainee *) (*s_element).objet)).suivant |
|
= NULL; |
|
|
|
if ((s_format = allocation(s_etat_processus, LST)) == NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
if (((*s_format).objet = |
|
allocation_maillon(s_etat_processus)) == NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
(*((struct_liste_chainee *) (*s_format).objet)).suivant |
|
= NULL; |
|
|
|
if (((*((struct_liste_chainee *) (*s_element).objet)) |
|
.donnee = copie_objet(s_etat_processus, |
|
(*l_element_courant).donnee, 'N')) == NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
if (((*((struct_liste_chainee *) (*s_format).objet)) |
|
.donnee = copie_objet(s_etat_processus, |
|
(*l_element_courant_format).donnee, 'N')) == NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
if ((chaine = formateur_fichier(s_etat_processus, |
|
s_element, s_format, 0, 0, ' ', |
|
'F', &longueur_effective, &recursivite)) == NULL) |
|
{ |
|
free(clef_utf8); |
|
|
|
liberation(s_etat_processus, s_element); |
|
liberation(s_etat_processus, s_format); |
|
liberation(s_etat_processus, s_objet_argument_2); |
|
liberation(s_etat_processus, s_objet_argument_1); |
|
|
|
return; |
|
} |
|
|
|
if ((chaine_utf8 = transliteration(s_etat_processus, |
|
chaine, d_locale, "UTF-8")) == NULL) |
|
{ |
|
free(clef_utf8); |
|
free(chaine); |
|
|
|
liberation(s_etat_processus, s_objet_argument_2); |
|
liberation(s_etat_processus, s_objet_argument_1); |
|
|
|
return; |
|
} |
|
|
|
free(chaine); |
|
|
|
if (alsprintf(&commande, "insert into data " |
|
"(data, key_id, sequence) values " |
|
"('%s', %lld, %lld)", chaine_utf8, id, ordre) < 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite, |
|
commande, strlen(commande), &ppStmt, &queue) |
|
!= SQLITE_OK) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_erreur_fichier; |
|
return; |
|
} |
|
|
|
if (sqlite3_step(ppStmt) != SQLITE_DONE) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_erreur_fichier; |
|
return; |
|
} |
|
|
|
if (sqlite3_finalize(ppStmt) != SQLITE_OK) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_erreur_fichier; |
|
return; |
|
} |
|
|
|
free(commande); |
|
free(chaine_utf8); |
|
|
|
liberation(s_etat_processus, s_element); |
|
liberation(s_etat_processus, s_format); |
|
|
|
l_element_courant = (*l_element_courant).suivant; |
|
l_element_courant_format = (*l_element_courant_format) |
|
.suivant; |
|
|
|
compteur++; |
|
ordre++; |
|
} |
|
|
|
free(clef_utf8); |
|
|
|
if ((l_element_courant != NULL) || |
|
(l_element_courant_format != NULL)) |
|
{ |
|
liberation(s_etat_processus, s_objet_argument_1); |
|
liberation(s_etat_processus, s_objet_argument_2); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_format_fichier; |
|
return; |
|
} |
} |
} |
} |
} |
else if ((*((struct_fichier *) (*s_objet_argument_1).objet)).binaire |
else if ((*((struct_fichier *) (*s_objet_argument_1).objet)).binaire |
Line 786 instruction_write(struct_processus *s_et
|
Line 1322 instruction_write(struct_processus *s_et
|
/* |
/* |
* Fichiers de type FLOW |
* Fichiers de type FLOW |
*/ |
*/ |
|
|
|
if ((*((struct_fichier *) (*s_objet_argument_1).objet)).acces |
|
== 'S') |
|
{ |
|
BUG(((*descripteur).type != 'C'), uprintf("Bad filetype !\n")); |
|
|
|
if ((*((*((struct_liste_chainee *) (*s_objet_argument_2).objet)) |
|
.donnee)).type != CHN) |
|
{ |
|
liberation(s_etat_processus, s_objet_argument_2); |
|
liberation(s_etat_processus, s_objet_argument_1); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_type_argument; |
|
return; |
|
} |
|
|
|
if ((chaine = formateur_flux(s_etat_processus, (unsigned char *) |
|
(*((*((struct_liste_chainee *) (*s_objet_argument_2) |
|
.objet)).donnee)).objet, &longueur_effective)) == NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
if (fwrite(chaine, sizeof(unsigned char), longueur_effective, |
|
(*descripteur).descripteur_c) != |
|
(size_t) longueur_effective) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
|
return; |
|
} |
|
|
|
free(chaine); |
|
} |
|
else |
|
{ |
|
liberation(s_etat_processus, s_objet_argument_1); |
|
liberation(s_etat_processus, s_objet_argument_2); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_type_fichier; |
|
return; |
|
} |
} |
} |
} |
} |
else if (((*s_objet_argument_2).type == LST) && |
else if (((*s_objet_argument_2).type == LST) && |
Line 821 instruction_write(struct_processus *s_et
|
Line 1402 instruction_write(struct_processus *s_et
|
|
|
return; |
return; |
} |
} |
|
} |
|
else if ((*((struct_socket *) (*s_objet_argument_1).objet)).binaire |
|
== 'Y') |
|
{ |
|
/* |
|
* Sockets non formatées |
|
*/ |
|
|
|
chaine = NULL; |
|
} |
|
else |
|
{ |
|
/* |
|
* Sockets de type FLOW |
|
*/ |
|
|
|
if ((*((*((struct_liste_chainee *) (*s_objet_argument_2).objet)) |
|
.donnee)).type != CHN) |
|
{ |
|
liberation(s_etat_processus, s_objet_argument_2); |
|
liberation(s_etat_processus, s_objet_argument_1); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_type_argument; |
|
return; |
|
} |
|
|
|
if ((chaine = formateur_flux(s_etat_processus, (unsigned char *) |
|
(*((*((struct_liste_chainee *) (*s_objet_argument_2) |
|
.objet)).donnee)).objet, &longueur_effective)) == NULL) |
|
{ |
|
liberation(s_etat_processus, s_objet_argument_2); |
|
liberation(s_etat_processus, s_objet_argument_1); |
|
|
|
return; |
|
} |
|
} |
|
|
|
if ((strcmp((*((struct_socket *) (*s_objet_argument_1).objet)).type, |
|
"STREAM") == 0) || (strcmp((*((struct_socket *) |
|
(*s_objet_argument_1).objet)).type, |
|
"SEQUENTIAL DATAGRAM") == 0)) |
|
{ // Sockets connectées |
|
|
if ((strcmp((*((struct_socket *) (*s_objet_argument_1).objet)).type, |
action.sa_handler = SIG_IGN; |
"STREAM") == 0) || (strcmp((*((struct_socket *) |
action.sa_flags = SA_ONSTACK; |
(*s_objet_argument_1).objet)).type, |
|
"SEQUENTIAL DATAGRAM") == 0)) |
|
{ // Sockets connectées |
|
|
|
action.sa_handler = SIG_IGN; |
if (sigaction(SIGPIPE, &action, ®istre) != 0) |
action.sa_flags = SA_ONSTACK; |
{ |
|
(*s_etat_processus).erreur_systeme = d_es_signal; |
|
return; |
|
} |
|
|
if (sigaction(SIGPIPE, &action, ®istre) != 0) |
# ifndef SEMAPHORES_NOMMES |
|
if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) |
|
# else |
|
if (sem_post((*s_etat_processus).semaphore_fork) != 0) |
|
# endif |
|
{ |
|
if (sigaction(SIGPIPE, ®istre, NULL) != 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_signal; |
(*s_etat_processus).erreur_systeme = d_es_signal; |
return; |
return; |
} |
} |
|
|
if (sem_post(&((*s_etat_processus).semaphore_fork)) |
(*s_etat_processus).erreur_systeme = d_es_processus; |
!= 0) |
return; |
|
} |
|
|
|
if (send((*((struct_socket *) (*s_objet_argument_1).objet)) |
|
.socket, chaine, longueur_effective, 0) < 0) |
|
{ |
|
ios = errno; |
|
|
|
if (sigaction(SIGPIPE, ®istre, NULL) != 0) |
{ |
{ |
if (sigaction(SIGPIPE, ®istre, NULL) != 0) |
(*s_etat_processus).erreur_systeme = d_es_signal; |
|
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_signal; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
} |
} |
|
} |
|
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
if ((ios == EPIPE) || (ios == ECONNRESET)) |
|
{ |
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_acces_fichier; |
return; |
return; |
} |
} |
|
|
if (send((*((struct_socket *) (*s_objet_argument_1).objet)) |
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
.socket, chaine, strlen(chaine), 0) < 0) |
return; |
{ |
} |
ios = errno; |
|
|
|
|
# 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) |
if (sigaction(SIGPIPE, ®istre, NULL) != 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_signal; |
(*s_etat_processus).erreur_systeme = d_es_signal; |
return; |
return; |
} |
} |
|
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1) |
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
} |
|
|
|
if (sigaction(SIGPIPE, ®istre, NULL) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_signal; |
|
return; |
|
} |
|
} |
|
else |
|
{ // Sockets non connectées |
|
|
|
/* |
|
* Vérification de l'adresse distante |
|
*/ |
|
|
|
if (strcmp((*((struct_socket *) (*s_objet_argument_1).objet)) |
|
.adresse_distante, "") == 0) |
|
{ |
|
liberation(s_etat_processus, s_objet_argument_1); |
|
liberation(s_etat_processus, s_objet_argument_2); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_acces_fichier; |
|
return; |
|
} |
|
|
|
/* |
|
* Création de l'adresse logique |
|
*/ |
|
|
|
if ((*((struct_socket *) (*s_objet_argument_1).objet)) |
|
.domaine == PF_UNIX) |
|
{ |
|
adresse_unix.sun_family = AF_UNIX; |
|
strncpy(adresse_unix.sun_path, (*((struct_socket *) |
|
(*s_objet_argument_1).objet)).adresse_distante, |
|
UNIX_PATH_MAX); |
|
adresse_unix.sun_path[UNIX_PATH_MAX - 1] = |
|
d_code_fin_chaine; |
|
|
|
# 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; |
|
} |
|
|
|
if (sendto((*((struct_socket *) |
|
(*s_objet_argument_1).objet)).socket, chaine, |
|
longueur_effective, 0, (struct sockaddr *) |
|
&adresse_unix, sizeof(adresse_unix)) < 0) |
|
{ |
|
ios = errno; |
|
|
|
# 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 (errno != EINTR) |
{ |
{ |
Line 870 instruction_write(struct_processus *s_et
|
Line 1594 instruction_write(struct_processus *s_et
|
} |
} |
} |
} |
|
|
if (ios == EPIPE) |
if ((ios == EPIPE) || (ios == ECONNRESET)) |
{ |
{ |
(*s_etat_processus).erreur_execution = |
(*s_etat_processus).erreur_execution = |
d_ex_erreur_acces_fichier; |
d_ex_erreur_acces_fichier; |
return; |
return; |
} |
} |
|
|
|
|
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
return; |
return; |
} |
} |
|
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1) |
# 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 (errno != EINTR) |
{ |
{ |
if (sigaction(SIGPIPE, ®istre, NULL) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_signal; |
|
return; |
|
} |
|
|
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
} |
} |
} |
} |
|
|
if (sigaction(SIGPIPE, ®istre, NULL) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_signal; |
|
return; |
|
} |
|
} |
} |
else |
else if ((*((struct_socket *) (*s_objet_argument_1).objet)) |
{ // Sockets non connectées |
.domaine == PF_INET) |
|
{ |
/* |
if (sscanf((*((struct_socket *) |
* Vérification de l'adresse distante |
(*s_objet_argument_1).objet)) |
*/ |
.adresse_distante, "%d.%d.%d.%d(%d)", |
|
&(adresse[0]), &(adresse[1]), &(adresse[2]), |
if (strcmp((*((struct_socket *) (*s_objet_argument_1).objet)) |
&(adresse[3]), &port) == 5) |
.adresse_distante, "") == 0) |
{ // Adresse IPv4 |
{ |
calcul_adresse = 0; |
liberation(s_etat_processus, s_objet_argument_1); |
for(i = 0; i < 4; calcul_adresse = |
liberation(s_etat_processus, s_objet_argument_2); |
(256 * calcul_adresse) + adresse[i++]); |
|
|
(*s_etat_processus).erreur_execution = |
memset(&adresse_ipv4, 0, sizeof(adresse_ipv4)); |
d_ex_erreur_acces_fichier; |
adresse_ipv4.sin_family = AF_INET; |
return; |
adresse_ipv4.sin_port = htons(port); |
} |
adresse_ipv4.sin_addr.s_addr = htonl(calcul_adresse); |
|
|
/* |
# ifndef SEMAPHORES_NOMMES |
* Création de l'adresse logique |
if (sem_post(&((*s_etat_processus).semaphore_fork)) |
*/ |
!= 0) |
|
# else |
if ((*((struct_socket *) (*s_objet_argument_1).objet)) |
if (sem_post((*s_etat_processus).semaphore_fork) != 0) |
.domaine == PF_UNIX) |
# endif |
{ |
|
adresse_unix.sun_family = AF_UNIX; |
|
strncpy(adresse_unix.sun_path, (*((struct_socket *) |
|
(*s_objet_argument_1).objet)).adresse_distante, |
|
108); |
|
adresse_unix.sun_path[108 - 1] = d_code_fin_chaine; |
|
|
|
if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) |
|
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
Line 941 instruction_write(struct_processus *s_et
|
Line 1650 instruction_write(struct_processus *s_et
|
|
|
if (sendto((*((struct_socket *) |
if (sendto((*((struct_socket *) |
(*s_objet_argument_1).objet)).socket, chaine, |
(*s_objet_argument_1).objet)).socket, chaine, |
strlen(chaine), 0, (struct sockaddr *) |
longueur_effective, 0, (struct sockaddr *) |
&adresse_unix, sizeof(adresse_unix)) < 0) |
&adresse_ipv4, sizeof(adresse_ipv4)) < 0) |
{ |
{ |
while(sem_wait(&((*s_etat_processus) |
# ifndef SEMAPHORES_NOMMES |
.semaphore_fork)) == -1) |
while(sem_wait(&((*s_etat_processus) |
|
.semaphore_fork)) != 0) |
|
# else |
|
while(sem_wait((*s_etat_processus) |
|
.semaphore_fork) != 0) |
|
# endif |
{ |
{ |
if (errno != EINTR) |
if (errno != EINTR) |
{ |
{ |
Line 960 instruction_write(struct_processus *s_et
|
Line 1674 instruction_write(struct_processus *s_et
|
return; |
return; |
} |
} |
|
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1) |
# 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 (errno != EINTR) |
{ |
{ |
Line 969 instruction_write(struct_processus *s_et
|
Line 1688 instruction_write(struct_processus *s_et
|
} |
} |
} |
} |
} |
} |
else if ((*((struct_socket *) (*s_objet_argument_1).objet)) |
else |
.domaine == PF_INET) |
|
{ |
{ |
if (sscanf((*((struct_socket *) |
liberation(s_etat_processus, s_objet_argument_1); |
(*s_objet_argument_1).objet)) |
liberation(s_etat_processus, s_objet_argument_2); |
.adresse_distante, "%d.%d.%d.%d(%d)", |
|
&(adresse[0]), &(adresse[1]), &(adresse[2]), |
|
&(adresse[3]), &port) == 5) |
|
{ // Adresse IPv4 |
|
calcul_adresse = 0; |
|
for(i = 0; i < 4; calcul_adresse = |
|
(256 * calcul_adresse) + adresse[i++]); |
|
|
|
memset(&adresse_ipv4, 0, sizeof(adresse_ipv4)); |
|
adresse_ipv4.sin_family = AF_INET; |
|
adresse_ipv4.sin_port = htons(port); |
|
adresse_ipv4.sin_addr.s_addr = htonl(calcul_adresse); |
|
|
|
if (sem_post(&((*s_etat_processus) |
(*s_etat_processus).erreur_execution = |
.semaphore_fork)) != 0) |
d_ex_erreur_parametre_fichier; |
{ |
return; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
} |
return; |
} |
} |
else if ((*((struct_socket *) (*s_objet_argument_1).objet)) |
|
.domaine == PF_INET6) |
|
{ |
|
if (sscanf((*((struct_socket *) (*s_objet_argument_1) |
|
.objet)).adresse_distante, "%X:%X:%X:%X:%X:" |
|
"%X:%X:%X:%X:%X:%X:%X:%X:%X:%X:%X(%d)", |
|
&(adresse[0]), &(adresse[1]), &(adresse[2]), |
|
&(adresse[3]), &(adresse[4]), &(adresse[5]), |
|
&(adresse[6]), &(adresse[7]), &(adresse[8]), |
|
&(adresse[9]), &(adresse[10]), &(adresse[11]), |
|
&(adresse[12]), &(adresse[13]), &(adresse[14]), |
|
&(adresse[15]), &port)== 17) |
|
{ // Adresse IPv6 |
|
# ifdef IPV6 |
|
memset(&adresse_ipv6, 0, sizeof(adresse_ipv6)); |
|
adresse_ipv6.sin6_family = AF_INET6; |
|
adresse_ipv6.sin6_port = htons((uint16_t) port); |
|
|
|
for(i = 0; i < 16; |
|
adresse_ipv6.sin6_addr.s6_addr[i] = |
|
adresse[i], i++); |
|
|
|
# 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; |
|
} |
|
|
if (sendto((*((struct_socket *) |
if (sendto((*((struct_socket *) |
(*s_objet_argument_1).objet)).socket, chaine, |
(*s_objet_argument_1).objet)).socket, chaine, |
strlen(chaine), 0, (struct sockaddr *) |
longueur_effective, 0, (struct sockaddr *) |
&adresse_ipv4, sizeof(adresse_ipv4)) < 0) |
&adresse_ipv6, sizeof(adresse_ipv6)) < 0) |
{ |
{ |
|
# ifndef SEMAPHORES_NOMMES |
while(sem_wait(&((*s_etat_processus) |
while(sem_wait(&((*s_etat_processus) |
.semaphore_fork)) == -1) |
.semaphore_fork)) != 0) |
{ |
# else |
if (errno != EINTR) |
while(sem_wait((*s_etat_processus) |
{ |
.semaphore_fork) != 0) |
(*s_etat_processus).erreur_systeme = |
# endif |
d_es_processus; |
|
return; |
|
} |
|
} |
|
|
|
(*s_etat_processus).erreur_systeme = |
|
d_es_erreur_fichier; |
|
return; |
|
} |
|
|
|
while(sem_wait(&((*s_etat_processus) |
|
.semaphore_fork)) == -1) |
|
{ |
{ |
if (errno != EINTR) |
if (errno != EINTR) |
{ |
{ |
Line 1025 instruction_write(struct_processus *s_et
|
Line 1751 instruction_write(struct_processus *s_et
|
return; |
return; |
} |
} |
} |
} |
} |
|
else |
|
{ |
|
liberation(s_etat_processus, s_objet_argument_1); |
|
liberation(s_etat_processus, s_objet_argument_2); |
|
|
|
(*s_etat_processus).erreur_execution = |
(*s_etat_processus).erreur_systeme = |
d_ex_erreur_parametre_fichier; |
d_es_erreur_fichier; |
return; |
return; |
} |
} |
} |
|
else if ((*((struct_socket *) (*s_objet_argument_1).objet)) |
|
.domaine == PF_INET6) |
|
{ |
|
if (sscanf((*((struct_socket *) (*s_objet_argument_1) |
|
.objet)).adresse_distante, "%X:%X:%X:%X:%X:" |
|
"%X:%X:%X:%X:%X:%X:%X:%X:%X:%X:%X(%d)", |
|
&(adresse[0]), &(adresse[1]), &(adresse[2]), |
|
&(adresse[3]), &(adresse[4]), &(adresse[5]), |
|
&(adresse[6]), &(adresse[7]), &(adresse[8]), |
|
&(adresse[9]), &(adresse[10]), &(adresse[11]), |
|
&(adresse[12]), &(adresse[13]), &(adresse[14]), |
|
&(adresse[15]), &port)== 17) |
|
{ // Adresse IPv6 |
|
memset(&adresse_ipv6, 0, sizeof(adresse_ipv6)); |
|
adresse_ipv6.sin6_family = AF_INET6; |
|
adresse_ipv6.sin6_port = htons((uint16_t) port); |
|
|
|
for(i = 0; i < 16; |
|
adresse_ipv6.sin6_addr.s6_addr[i] = |
|
adresse[i], i++); |
|
|
|
if (sem_post(&((*s_etat_processus) |
|
.semaphore_fork)) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
|
|
if (sendto((*((struct_socket *) |
# ifndef SEMAPHORES_NOMMES |
(*s_objet_argument_1).objet)).socket, chaine, |
while(sem_wait(&((*s_etat_processus).semaphore_fork)) |
strlen(chaine), 0, (struct sockaddr *) |
!= 0) |
&adresse_ipv6, sizeof(adresse_ipv6)) < 0) |
# else |
|
while(sem_wait((*s_etat_processus).semaphore_fork) != 0) |
|
# endif |
|
{ |
|
if (errno != EINTR) |
{ |
{ |
while(sem_wait(&((*s_etat_processus) |
|
.semaphore_fork)) == -1) |
|
{ |
|
if (errno != EINTR) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_processus; |
|
return; |
|
} |
|
} |
|
|
|
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
d_es_erreur_fichier; |
d_es_processus; |
return; |
return; |
} |
} |
|
} |
while(sem_wait(&((*s_etat_processus) |
# else |
.semaphore_fork)) == -1) |
if ((*s_etat_processus).langue == 'F') |
{ |
{ |
if (errno != EINTR) |
printf("+++Attention : Support du protocole" |
{ |
" IPv6 indisponible\n"); |
(*s_etat_processus).erreur_systeme = |
|
d_es_processus; |
|
return; |
|
} |
|
} |
|
} |
} |
else |
else |
{ |
{ |
liberation(s_etat_processus, s_objet_argument_1); |
printf("+++Warning : IPv6 support " |
liberation(s_etat_processus, s_objet_argument_2); |
"unavailable\n"); |
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_parametre_fichier; |
|
return; |
|
} |
} |
|
# endif |
} |
} |
else |
else |
{ |
{ |
liberation(s_etat_processus, s_objet_argument_1); |
liberation(s_etat_processus, s_objet_argument_1); |
liberation(s_etat_processus, s_objet_argument_2); |
liberation(s_etat_processus, s_objet_argument_2); |
Line 1116 instruction_write(struct_processus *s_et
|
Line 1794 instruction_write(struct_processus *s_et
|
return; |
return; |
} |
} |
} |
} |
|
else |
|
{ |
|
liberation(s_etat_processus, s_objet_argument_1); |
|
liberation(s_etat_processus, s_objet_argument_2); |
|
|
free(chaine); |
(*s_etat_processus).erreur_execution = |
} |
d_ex_erreur_parametre_fichier; |
else if ((*((struct_socket *) (*s_objet_argument_1).objet)).binaire |
return; |
== 'Y') |
} |
{ |
|
/* |
|
* Sockets non formatées |
|
*/ |
|
} |
|
else |
|
{ |
|
/* |
|
* Sockets de type FLOW |
|
*/ |
|
} |
} |
|
|
|
free(chaine); |
} |
} |
else |
else |
{ |
{ |
Line 1292 instruction_wflock(struct_processus *s_e
|
Line 1966 instruction_wflock(struct_processus *s_e
|
return; |
return; |
} |
} |
|
|
if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) |
# 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; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
} |
} |
|
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1) |
# 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 (errno != EINTR) |
{ |
{ |
Line 1521 instruction_wfproc(struct_processus *s_e
|
Line 2203 instruction_wfproc(struct_processus *s_e
|
if ((*(*((struct_processus_fils *) (*(*l_element_courant) |
if ((*(*((struct_processus_fils *) (*(*l_element_courant) |
.donnee).objet)).thread).processus_detache == d_vrai) |
.donnee).objet)).thread).processus_detache == d_vrai) |
{ |
{ |
if (kill((*(*((struct_processus_fils *) |
if (envoi_signal_processus((*(*((struct_processus_fils *) |
(*(*l_element_courant).donnee).objet)).thread).pid, |
(*(*l_element_courant).donnee).objet)).thread).pid, |
0) != 0) |
rpl_signull) != 0) |
{ |
{ |
drapeau_fin = d_vrai; |
drapeau_fin = d_vrai; |
} |
} |
Line 1607 instruction_wfproc(struct_processus *s_e
|
Line 2289 instruction_wfproc(struct_processus *s_e
|
registre_instruction_valide; |
registre_instruction_valide; |
} |
} |
|
|
if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) |
# 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; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
Line 1615 instruction_wfproc(struct_processus *s_e
|
Line 2302 instruction_wfproc(struct_processus *s_e
|
|
|
nanosleep(&attente, NULL); |
nanosleep(&attente, NULL); |
|
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1) |
# 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 (errno != EINTR) |
{ |
{ |
Line 1866 instruction_wfdata(struct_processus *s_e
|
Line 2558 instruction_wfdata(struct_processus *s_e
|
return; |
return; |
} |
} |
|
|
if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) |
# 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; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
Line 1874 instruction_wfdata(struct_processus *s_e
|
Line 2571 instruction_wfdata(struct_processus *s_e
|
|
|
nanosleep(&attente, NULL); |
nanosleep(&attente, NULL); |
|
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1) |
# 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 (errno != EINTR) |
{ |
{ |
Line 1984 instruction_wfsock(struct_processus *s_e
|
Line 2686 instruction_wfsock(struct_processus *s_e
|
struct_objet *s_objet_resultat; |
struct_objet *s_objet_resultat; |
|
|
struct sockaddr_in adresse_ipv4; |
struct sockaddr_in adresse_ipv4; |
|
# ifdef IPV6 |
struct sockaddr_in6 adresse_ipv6; |
struct sockaddr_in6 adresse_ipv6; |
|
# endif |
|
|
unsigned long i; |
unsigned long i; |
|
|
Line 2058 instruction_wfsock(struct_processus *s_e
|
Line 2762 instruction_wfsock(struct_processus *s_e
|
{ |
{ |
drapeau = d_vrai; |
drapeau = d_vrai; |
|
|
if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) |
# 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; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
Line 2071 instruction_wfsock(struct_processus *s_e
|
Line 2779 instruction_wfsock(struct_processus *s_e
|
{ |
{ |
erreur = errno; |
erreur = errno; |
|
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1) |
# 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 (errno != EINTR) |
{ |
{ |
Line 2103 instruction_wfsock(struct_processus *s_e
|
Line 2816 instruction_wfsock(struct_processus *s_e
|
} |
} |
else |
else |
{ |
{ |
while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1) |
# 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 (errno != EINTR) |
{ |
{ |
Line 2134 instruction_wfsock(struct_processus *s_e
|
Line 2852 instruction_wfsock(struct_processus *s_e
|
else if ((*((struct_socket *) (*s_objet_resultat).objet)).domaine == |
else if ((*((struct_socket *) (*s_objet_resultat).objet)).domaine == |
PF_INET6) |
PF_INET6) |
{ |
{ |
|
# ifdef IPV6 |
longueur = sizeof(adresse_ipv6); |
longueur = sizeof(adresse_ipv6); |
|
|
do |
do |
{ |
{ |
drapeau = d_vrai; |
drapeau = d_vrai; |
|
|
if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) |
# 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; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
Line 2153 instruction_wfsock(struct_processus *s_e
|
Line 2876 instruction_wfsock(struct_processus *s_e
|
{ |
{ |
erreur = errno; |
erreur = errno; |
|
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1) |
# 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 (errno != EINTR) |
{ |
{ |
Line 2185 instruction_wfsock(struct_processus *s_e
|
Line 2913 instruction_wfsock(struct_processus *s_e
|
} |
} |
else |
else |
{ |
{ |
while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1) |
# 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 (errno != EINTR) |
{ |
{ |
Line 2221 instruction_wfsock(struct_processus *s_e
|
Line 2954 instruction_wfsock(struct_processus *s_e
|
.objet)).adresse_distante, "%s(%u)", |
.objet)).adresse_distante, "%s(%u)", |
(*((struct_socket *) (*s_objet_resultat) |
(*((struct_socket *) (*s_objet_resultat) |
.objet)).adresse_distante, ntohs(adresse_ipv6.sin6_port)); |
.objet)).adresse_distante, ntohs(adresse_ipv6.sin6_port)); |
|
# else |
|
if ((*s_etat_processus).langue == 'F') |
|
{ |
|
printf("+++Attention : Support du protocole" |
|
" IPv6 indisponible\n"); |
|
} |
|
else |
|
{ |
|
printf("+++Warning : IPv6 support " |
|
"unavailable\n"); |
|
} |
|
# endif |
} |
} |
else |
else |
{ |
{ |
Line 2230 instruction_wfsock(struct_processus *s_e
|
Line 2975 instruction_wfsock(struct_processus *s_e
|
{ |
{ |
drapeau = d_vrai; |
drapeau = d_vrai; |
|
|
if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) |
# 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; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
Line 2242 instruction_wfsock(struct_processus *s_e
|
Line 2991 instruction_wfsock(struct_processus *s_e
|
{ |
{ |
erreur = errno; |
erreur = errno; |
|
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1) |
# 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 (errno != EINTR) |
{ |
{ |
Line 2274 instruction_wfsock(struct_processus *s_e
|
Line 3028 instruction_wfsock(struct_processus *s_e
|
} |
} |
else |
else |
{ |
{ |
while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1) |
# 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 (errno != EINTR) |
{ |
{ |
Line 2560 instruction_wfpoke(struct_processus *s_e
|
Line 3319 instruction_wfpoke(struct_processus *s_e
|
|
|
do |
do |
{ |
{ |
if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) |
# 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; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
Line 2568 instruction_wfpoke(struct_processus *s_e
|
Line 3331 instruction_wfpoke(struct_processus *s_e
|
|
|
nanosleep(&attente, NULL); |
nanosleep(&attente, NULL); |
|
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1) |
# 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 (errno != EINTR) |
{ |
{ |
Line 2710 instruction_wfack(struct_processus *s_et
|
Line 3477 instruction_wfack(struct_processus *s_et
|
return; |
return; |
} |
} |
|
|
if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) |
# 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; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
Line 2719 instruction_wfack(struct_processus *s_et
|
Line 3490 instruction_wfack(struct_processus *s_et
|
nanosleep(&attente, NULL); |
nanosleep(&attente, NULL); |
INCR_GRANULARITE(attente.tv_nsec); |
INCR_GRANULARITE(attente.tv_nsec); |
|
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1) |
# 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 (errno != EINTR) |
{ |
{ |