version 1.4, 2010/03/04 10:17:53
|
version 1.65, 2014/04/25 07:37:33
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.0.12 |
RPL/2 (R) version 4.1.18 |
Copyright (C) 1989-2010 Dr. BERTRAND Joël |
Copyright (C) 1989-2014 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 102 instruction_splash(struct_processus *s_e
|
Line 102 instruction_splash(struct_processus *s_e
|
return; |
return; |
} |
} |
|
|
encart(s_etat_processus, (unsigned long) (attente * 1E6)); |
encart(s_etat_processus, (integer8) (attente * 1E6)); |
} |
} |
else |
else |
{ |
{ |
Line 133 instruction_splash(struct_processus *s_e
|
Line 133 instruction_splash(struct_processus *s_e
|
void |
void |
instruction_send(struct_processus *s_etat_processus) |
instruction_send(struct_processus *s_etat_processus) |
{ |
{ |
pid_t pid; |
|
|
|
pthread_t tid; |
|
|
|
sig_atomic_t registre; |
sig_atomic_t registre; |
|
|
ssize_t longueur_ecriture; |
ssize_t longueur_ecriture; |
Line 145 instruction_send(struct_processus *s_eta
|
Line 141 instruction_send(struct_processus *s_eta
|
|
|
struct timespec attente; |
struct timespec attente; |
|
|
|
unsigned char caractere; |
unsigned char tampon; |
unsigned char tampon; |
|
|
(*s_etat_processus).erreur_execution = d_ex; |
(*s_etat_processus).erreur_execution = d_ex; |
Line 242 instruction_send(struct_processus *s_eta
|
Line 239 instruction_send(struct_processus *s_eta
|
} |
} |
} |
} |
|
|
pid = -3; |
# ifndef SEMAPHORES_NOMMES |
|
if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) |
attente.tv_sec = 0; |
# else |
attente.tv_nsec = GRANULARITE_us * 1000; |
if (sem_post((*s_etat_processus).semaphore_fork) != 0) |
|
# endif |
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; |
} |
} |
|
|
while((longueur_ecriture = write_atomic(s_etat_processus, |
caractere = 1; |
(*s_etat_processus).pipe_nombre_objets_attente, |
|
&pid, sizeof(pid))) != sizeof(pid)) |
|
{ |
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1) |
|
{ |
|
if (errno != EINTR) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
} |
|
|
|
if (longueur_ecriture == -1) |
|
{ |
|
if ((*s_etat_processus).profilage == d_vrai) |
|
{ |
|
profilage(s_etat_processus, NULL); |
|
} |
|
|
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
|
|
nanosleep(&attente, NULL); |
|
INCR_GRANULARITE(attente.tv_nsec); |
|
|
|
if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
} |
|
|
|
pid = getpid(); |
|
|
|
attente.tv_sec = 0; |
attente.tv_sec = 0; |
attente.tv_nsec = GRANULARITE_us * 1000; |
attente.tv_nsec = GRANULARITE_us * 1000; |
|
|
while((longueur_ecriture = write_atomic(s_etat_processus, |
while((longueur_ecriture = write_atomic(s_etat_processus, |
(*s_etat_processus).pipe_nombre_objets_attente, |
(*s_etat_processus).pipe_nombre_elements_attente, |
&pid, sizeof(pid))) != sizeof(pid)) |
&caractere, sizeof(caractere))) != sizeof(caractere)) |
{ |
{ |
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 319 instruction_send(struct_processus *s_eta
|
Line 285 instruction_send(struct_processus *s_eta
|
nanosleep(&attente, NULL); |
nanosleep(&attente, NULL); |
INCR_GRANULARITE(attente.tv_nsec); |
INCR_GRANULARITE(attente.tv_nsec); |
|
|
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; |
} |
} |
|
|
|
scrutation_interruptions(s_etat_processus); |
} |
} |
|
|
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 347 instruction_send(struct_processus *s_eta
|
Line 323 instruction_send(struct_processus *s_eta
|
} |
} |
} |
} |
|
|
tid = -3; |
|
|
|
attente.tv_sec = 0; |
attente.tv_sec = 0; |
attente.tv_nsec = GRANULARITE_us * 1000; |
attente.tv_nsec = GRANULARITE_us * 1000; |
|
|
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((longueur_ecriture = write_atomic(s_etat_processus, |
caractere = 1; |
(*s_etat_processus).pipe_nombre_objets_attente, |
|
&tid, sizeof(tid))) != sizeof(tid)) |
|
{ |
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1) |
|
{ |
|
if (errno != EINTR) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
} |
|
|
|
if (longueur_ecriture == -1) |
|
{ |
|
if ((*s_etat_processus).profilage == d_vrai) |
|
{ |
|
profilage(s_etat_processus, NULL); |
|
} |
|
|
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
|
|
nanosleep(&attente, NULL); |
|
INCR_GRANULARITE(attente.tv_nsec); |
|
|
|
if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
} |
|
|
|
tid = pthread_self(); |
|
|
|
attente.tv_sec = 0; |
attente.tv_sec = 0; |
attente.tv_nsec = GRANULARITE_us * 1000; |
attente.tv_nsec = GRANULARITE_us * 1000; |
|
|
while((longueur_ecriture = write_atomic(s_etat_processus, |
while((longueur_ecriture = write_atomic(s_etat_processus, |
(*s_etat_processus).pipe_nombre_objets_attente, |
(*s_etat_processus).pipe_nombre_elements_attente, |
&tid, sizeof(tid))) != sizeof(tid)) |
&caractere, sizeof(caractere))) != sizeof(caractere)) |
{ |
{ |
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 424 instruction_send(struct_processus *s_eta
|
Line 372 instruction_send(struct_processus *s_eta
|
nanosleep(&attente, NULL); |
nanosleep(&attente, NULL); |
INCR_GRANULARITE(attente.tv_nsec); |
INCR_GRANULARITE(attente.tv_nsec); |
|
|
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; |
} |
} |
|
|
|
scrutation_interruptions(s_etat_processus); |
} |
} |
|
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1) |
# ifndef SEMAPHORES_NOMMES |
|
if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) |
|
# else |
|
if (sem_post((*s_etat_processus).semaphore_fork) != 0) |
|
# endif |
{ |
{ |
if (errno != EINTR) |
(*s_etat_processus).erreur_systeme = d_es_processus; |
{ |
return; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
} |
} |
} |
} |
|
|
Line 446 instruction_send(struct_processus *s_eta
|
Line 401 instruction_send(struct_processus *s_eta
|
attente.tv_sec = 0; |
attente.tv_sec = 0; |
attente.tv_nsec = GRANULARITE_us * 1000; |
attente.tv_nsec = GRANULARITE_us * 1000; |
|
|
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 455 instruction_send(struct_processus *s_eta
|
Line 414 instruction_send(struct_processus *s_eta
|
while(read_atomic(s_etat_processus, (*s_etat_processus).pipe_acquittement, |
while(read_atomic(s_etat_processus, (*s_etat_processus).pipe_acquittement, |
&tampon, sizeof(unsigned char)) != sizeof(unsigned char)) |
&tampon, sizeof(unsigned char)) != sizeof(unsigned char)) |
{ |
{ |
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 467 instruction_send(struct_processus *s_eta
|
Line 430 instruction_send(struct_processus *s_eta
|
nanosleep(&attente, NULL); |
nanosleep(&attente, NULL); |
INCR_GRANULARITE(attente.tv_nsec); |
INCR_GRANULARITE(attente.tv_nsec); |
|
|
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) |
scrutation_interruptions(s_etat_processus); |
{ |
|
if (errno != EINTR) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
} |
} |
|
|
// Envoi d'un PID invalide (-1) pour ne pas bloquer le thread |
# ifndef SEMAPHORES_NOMMES |
// de surveillance. |
while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) |
|
# else |
if ((*s_etat_processus).processus_detache == d_vrai) |
while(sem_wait((*s_etat_processus).semaphore_fork) != 0) |
|
# endif |
{ |
{ |
pid = -1; |
if (errno != EINTR) |
|
|
attente.tv_sec = 0; |
|
attente.tv_nsec = GRANULARITE_us * 1000; |
|
|
|
if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
|
|
while((longueur_ecriture = write_atomic(s_etat_processus, |
|
(*s_etat_processus).pipe_nombre_interruptions_attente, |
|
&pid, sizeof(pid))) != sizeof(pid)) |
|
{ |
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1) |
|
{ |
|
if (errno != EINTR) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
} |
|
|
|
if (longueur_ecriture == -1) |
|
{ |
|
if ((*s_etat_processus).profilage == d_vrai) |
|
{ |
|
profilage(s_etat_processus, NULL); |
|
} |
|
|
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
|
|
nanosleep(&attente, NULL); |
|
INCR_GRANULARITE(attente.tv_nsec); |
|
|
|
if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
} |
|
|
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1) |
|
{ |
|
if (errno != EINTR) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
} |
|
} |
|
else |
|
{ |
|
tid = -1; |
|
|
|
attente.tv_sec = 0; |
|
attente.tv_nsec = GRANULARITE_us * 1000; |
|
|
|
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; |
} |
} |
|
|
while((longueur_ecriture = write_atomic(s_etat_processus, |
|
(*s_etat_processus).pipe_nombre_interruptions_attente, |
|
&tid, sizeof(tid))) != sizeof(tid)) |
|
{ |
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1) |
|
{ |
|
if (errno != EINTR) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
} |
|
|
|
if (longueur_ecriture == -1) |
|
{ |
|
if ((*s_etat_processus).profilage == d_vrai) |
|
{ |
|
profilage(s_etat_processus, NULL); |
|
} |
|
|
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
|
|
nanosleep(&attente, NULL); |
|
INCR_GRANULARITE(attente.tv_nsec); |
|
|
|
if (sem_post(&((*s_etat_processus).semaphore_fork)) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
} |
|
|
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) == -1) |
|
{ |
|
if (errno != EINTR) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
} |
|
} |
} |
|
|
// ecriture_pipe() ne peut être interrompu par un signal. |
// ecriture_pipe() ne peut être interrompu par un signal. |
|
|
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 610 instruction_send(struct_processus *s_eta
|
Line 471 instruction_send(struct_processus *s_eta
|
if (ecriture_pipe(s_etat_processus, (*s_etat_processus).pipe_donnees, |
if (ecriture_pipe(s_etat_processus, (*s_etat_processus).pipe_donnees, |
s_objet) == d_erreur) |
s_objet) == d_erreur) |
{ |
{ |
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 628 instruction_send(struct_processus *s_eta
|
Line 493 instruction_send(struct_processus *s_eta
|
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 672 instruction_send(struct_processus *s_eta
|
Line 541 instruction_send(struct_processus *s_eta
|
void |
void |
instruction_sqlquery(struct_processus *s_etat_processus) |
instruction_sqlquery(struct_processus *s_etat_processus) |
{ |
{ |
# define d_LONGUEUR 1024 |
|
|
|
logical1 connexion_permanente; |
logical1 connexion_permanente; |
logical1 presence_resultat; |
|
|
|
struct_objet *s_copie_1; |
struct_objet *s_copie_1; |
struct_objet *s_objet_1; |
struct_objet *s_objet_1; |
struct_objet *s_copie_2; |
struct_objet *s_copie_2; |
struct_objet *s_objet_2; |
struct_objet *s_objet_2; |
struct_objet *s_objet_resultat; |
|
|
|
struct_liste_chainee *l_element_courant; |
|
struct_liste_chainee *l_element_courant_ligne; |
|
|
|
unsigned char *tampon; |
unsigned char *tampon; |
|
|
unsigned int i; |
|
unsigned int j; |
|
unsigned int nombre_colonnes; |
|
unsigned int nombre_lignes; |
|
|
|
(*s_etat_processus).erreur_execution = d_ex; |
(*s_etat_processus).erreur_execution = d_ex; |
|
|
if ((*s_etat_processus).affichage_arguments == 'Y') |
if ((*s_etat_processus).affichage_arguments == 'Y') |
Line 732 instruction_sqlquery(struct_processus *s
|
Line 589 instruction_sqlquery(struct_processus *s
|
printf(" { \"postgresql:iso-8859-1\" \"server\" " |
printf(" { \"postgresql:iso-8859-1\" \"server\" " |
"\"database\" \"user\" \"password\" port }\n"); |
"\"database\" \"user\" \"password\" port }\n"); |
printf(" SQLQUERY\n"); |
printf(" SQLQUERY\n"); |
|
printf(" \"select * from table\"\n"); |
|
printf(" { \"sqlite\" \"file\" } SQLQUERY\n"); |
|
|
return; |
return; |
} |
} |
Line 778 instruction_sqlquery(struct_processus *s
|
Line 637 instruction_sqlquery(struct_processus *s
|
return; |
return; |
} |
} |
|
|
|
if ((*s_etat_processus).erreur_execution == |
|
d_ex_instruction_indisponible) |
|
{ |
|
liberation(s_etat_processus, s_objet_1); |
|
liberation(s_etat_processus, s_objet_2); |
|
liberation(s_etat_processus, s_copie_1); |
|
|
|
return; |
|
} |
|
|
liberation(s_etat_processus, s_copie_1); |
liberation(s_etat_processus, s_copie_1); |
} |
} |
else |
else |
Line 839 instruction_sqlquery(struct_processus *s
|
Line 708 instruction_sqlquery(struct_processus *s
|
{ |
{ |
# ifdef MYSQL_SUPPORT |
# ifdef MYSQL_SUPPORT |
|
|
MYSQL_RES *resultat_mysql; |
unsigned int i; |
MYSQL_ROW ligne; |
unsigned int nombre_colonnes; |
|
|
|
logical1 presence_resultat; |
|
|
|
MYSQL_RES *resultat_mysql; |
|
MYSQL_ROW ligne; |
|
|
|
struct_objet *s_objet_resultat; |
|
|
|
struct_liste_chainee *l_element_courant; |
|
struct_liste_chainee *l_element_courant_ligne; |
|
|
if (mysql_real_query((*((struct_connecteur_sql *) (*s_objet_1) |
if (mysql_real_query((*((struct_connecteur_sql *) (*s_objet_1) |
.objet)).descripteur.mysql, (unsigned char *) (*s_objet_2) |
.objet)).descripteur.mysql, (unsigned char *) (*s_objet_2) |
Line 1042 instruction_sqlquery(struct_processus *s
|
Line 921 instruction_sqlquery(struct_processus *s
|
{ |
{ |
# ifdef POSTGRESQL_SUPPORT |
# ifdef POSTGRESQL_SUPPORT |
|
|
PGresult *resultat_postgresql; |
int i; |
|
int j; |
|
int nombre_colonnes; |
|
int nombre_lignes; |
|
|
|
logical1 presence_resultat; |
|
|
|
PGresult *resultat_postgresql; |
|
|
|
struct_objet *s_objet_resultat; |
|
|
|
struct_liste_chainee *l_element_courant; |
|
struct_liste_chainee *l_element_courant_ligne; |
|
|
if (PQstatus((*((struct_connecteur_sql *) (*s_objet_1).objet)) |
if (PQstatus((*((struct_connecteur_sql *) (*s_objet_1).objet)) |
.descripteur.postgresql) != CONNECTION_OK) |
.descripteur.postgresql) != CONNECTION_OK) |
Line 1208 instruction_sqlquery(struct_processus *s
|
Line 1099 instruction_sqlquery(struct_processus *s
|
else |
else |
{ |
{ |
if (((*(*l_element_courant_ligne).donnee).objet |
if (((*(*l_element_courant_ligne).donnee).objet |
= malloc((PQgetlength( |
= malloc(((size_t) (PQgetlength( |
resultat_postgresql, i, j) + 1) * |
resultat_postgresql, i, j) + 1)) * |
sizeof(unsigned char))) == NULL) |
sizeof(unsigned char))) == NULL) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
Line 1286 instruction_sqlquery(struct_processus *s
|
Line 1177 instruction_sqlquery(struct_processus *s
|
fflush(stdout); |
fflush(stdout); |
# endif |
# endif |
} |
} |
|
else if (strcmp((*((struct_connecteur_sql *) (*s_objet_1).objet)).type, |
|
"SQLITE") == 0) |
|
{ |
|
const char *queue; |
|
const unsigned char *resultat; |
|
|
|
int i; |
|
int ios; |
|
int nombre_colonnes; |
|
|
|
logical1 presence_resultat; |
|
|
|
sqlite3_stmt *ppStmt; |
|
|
|
struct_liste_chainee *l_element_courant; |
|
struct_liste_chainee *l_element_courant_ligne; |
|
|
|
struct_objet *s_objet_resultat; |
|
|
|
struct timespec attente; |
|
|
|
if (sqlite3_prepare_v2((*((struct_connecteur_sql *) |
|
(*s_objet_1).objet)).descripteur.sqlite, |
|
(unsigned char *) (*s_objet_2).objet, |
|
(int) strlen((unsigned char *) (*s_objet_2).objet), |
|
&ppStmt, &queue) != SQLITE_OK) |
|
{ |
|
if (connexion_permanente == d_faux) |
|
{ |
|
sqlite3_close((*((struct_connecteur_sql *) |
|
(*s_objet_1).objet)).descripteur.sqlite); |
|
} |
|
|
|
liberation(s_etat_processus, s_objet_1); |
|
liberation(s_etat_processus, s_objet_2); |
|
|
|
(*s_etat_processus).erreur_execution = d_ex_erreur_sql; |
|
return; |
|
} |
|
|
|
presence_resultat = d_faux; |
|
s_objet_resultat = NULL; |
|
l_element_courant = NULL; |
|
|
|
attente.tv_sec = 0; |
|
attente.tv_nsec = GRANULARITE_us * 1000; |
|
|
|
do |
|
{ |
|
switch(ios = sqlite3_step(ppStmt)) |
|
{ |
|
case SQLITE_ROW: |
|
{ |
|
if (s_objet_resultat == NULL) |
|
{ |
|
if ((s_objet_resultat = |
|
allocation(s_etat_processus, LST)) == NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
presence_resultat = d_vrai; |
|
|
|
// Création d'une liste vide |
|
|
|
(*s_objet_resultat).objet = NULL; |
|
l_element_courant = (*s_objet_resultat).objet; |
|
} |
|
|
|
// Ajout d'une liste au bout de la liste |
|
// contenant les lignes |
|
|
|
if (l_element_courant == NULL) |
|
{ |
|
if (((*s_objet_resultat).objet = |
|
allocation_maillon(s_etat_processus)) |
|
== NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
} |
|
|
|
l_element_courant = (struct_liste_chainee *) |
|
(*s_objet_resultat).objet; |
|
} |
|
else |
|
{ |
|
if (((*l_element_courant).suivant = |
|
allocation_maillon(s_etat_processus)) |
|
== NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
l_element_courant = (*l_element_courant).suivant; |
|
} |
|
|
|
(*l_element_courant).suivant = NULL; |
|
|
|
// Création de la liste fille |
|
|
|
if (((*l_element_courant).donnee = |
|
allocation(s_etat_processus, LST)) == NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
(*(*l_element_courant).donnee).objet = NULL; |
|
|
|
// Lecture de la ligne |
|
|
|
nombre_colonnes = sqlite3_data_count(ppStmt); |
|
l_element_courant_ligne = NULL; |
|
|
|
for(i = 0; i < nombre_colonnes; i++) |
|
{ |
|
if (l_element_courant_ligne == NULL) |
|
{ |
|
if (((*(*l_element_courant).donnee).objet = |
|
allocation_maillon(s_etat_processus)) |
|
== NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
l_element_courant_ligne = |
|
(struct_liste_chainee *) |
|
(*(*l_element_courant).donnee).objet; |
|
} |
|
else |
|
{ |
|
if (((*l_element_courant_ligne).suivant = |
|
allocation_maillon(s_etat_processus)) |
|
== NULL) |
|
{ |
|
l_element_courant_ligne = |
|
(*l_element_courant_ligne).suivant; |
|
} |
|
|
|
l_element_courant_ligne = |
|
(*l_element_courant_ligne).suivant; |
|
} |
|
|
|
(*l_element_courant_ligne).suivant = NULL; |
|
|
|
if (((*l_element_courant_ligne).donnee = |
|
allocation(s_etat_processus, CHN)) |
|
== NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
if (sqlite3_column_type(ppStmt, i) == SQLITE_NULL) |
|
{ |
|
if (((*(*l_element_courant_ligne).donnee).objet |
|
= malloc(5 * sizeof(unsigned char))) |
|
== NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
strcpy((unsigned char *) |
|
(*(*l_element_courant_ligne).donnee) |
|
.objet, "NULL"); |
|
} |
|
else |
|
{ |
|
if ((resultat = sqlite3_column_text(ppStmt, i)) |
|
== NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
if (((*(*l_element_courant_ligne).donnee).objet |
|
= malloc((strlen(resultat) + 1 ) * |
|
sizeof(unsigned char))) == NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
strcpy((unsigned char *) |
|
(*(*l_element_courant_ligne).donnee) |
|
.objet, resultat); |
|
} |
|
} |
|
|
|
break; |
|
} |
|
|
|
case SQLITE_DONE: |
|
{ |
|
// Fin de la lecture des données |
|
break; |
|
} |
|
|
|
case SQLITE_BUSY: |
|
case SQLITE_LOCKED: |
|
{ |
|
nanosleep(&attente, NULL); |
|
INCR_GRANULARITE(attente.tv_nsec); |
|
break; |
|
} |
|
|
|
default: |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_erreur_fichier; |
|
return; |
|
} |
|
} |
|
} while(ios != SQLITE_DONE); |
|
|
|
if (sqlite3_finalize(ppStmt) != SQLITE_OK) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
|
return; |
|
} |
|
|
|
if (connexion_permanente == d_faux) |
|
{ |
|
sqlite3_close((*((struct_connecteur_sql *) (*s_objet_1).objet)) |
|
.descripteur.sqlite); |
|
} |
|
|
|
if (presence_resultat == d_vrai) |
|
{ |
|
if (empilement(s_etat_processus, &((*s_etat_processus) |
|
.l_base_pile), s_objet_resultat) == d_erreur) |
|
{ |
|
return; |
|
} |
|
} |
|
} |
else |
else |
{ |
{ |
liberation(s_etat_processus, s_objet_1); |
liberation(s_etat_processus, s_objet_1); |
Line 1330 instruction_stop(struct_processus *s_eta
|
Line 1470 instruction_stop(struct_processus *s_eta
|
|
|
struct_objet *s_objet; |
struct_objet *s_objet; |
|
|
struct timespec attente; |
|
|
|
attente.tv_sec = 0; |
|
attente.tv_nsec = GRANULARITE_us * 1000; |
|
|
|
(*s_etat_processus).erreur_execution = d_ex; |
(*s_etat_processus).erreur_execution = d_ex; |
|
|
if ((*s_etat_processus).affichage_arguments == 'Y') |
if ((*s_etat_processus).affichage_arguments == 'Y') |
Line 1380 instruction_stop(struct_processus *s_eta
|
Line 1515 instruction_stop(struct_processus *s_eta
|
if ((*(*((struct_processus_fils *) (*s_objet).objet)).thread) |
if ((*(*((struct_processus_fils *) (*s_objet).objet)).thread) |
.processus_detache == d_vrai) |
.processus_detache == d_vrai) |
{ |
{ |
kill((*(*((struct_processus_fils *) (*s_objet).objet)).thread).pid, |
envoi_signal_processus((*(*((struct_processus_fils *) |
SIGFSTOP); |
(*s_objet).objet)).thread).pid, rpl_sigstop); |
} |
} |
else |
else |
{ |
{ |
if (pthread_mutex_lock(&((*s_etat_processus).mutex)) != 0) |
if (pthread_mutex_lock(&((*s_etat_processus).mutex_pile_processus)) |
|
!= 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
Line 1400 instruction_stop(struct_processus *s_eta
|
Line 1536 instruction_stop(struct_processus *s_eta
|
.donnee).objet)).thread).processus_detache == d_faux) |
.donnee).objet)).thread).processus_detache == d_faux) |
{ |
{ |
if ((pthread_equal((*(*((struct_processus_fils *) |
if ((pthread_equal((*(*((struct_processus_fils *) |
(*(*l_element_courant).donnee).objet)).thread).pid, |
(*(*l_element_courant).donnee).objet)).thread).tid, |
(*(*((struct_processus_fils *) |
(*(*((struct_processus_fils *) |
(*s_objet).objet)).thread).tid) != 0) && |
(*s_objet).objet)).thread).tid) != 0) && |
((*(*((struct_processus_fils *) |
((*(*((struct_processus_fils *) |
Line 1427 instruction_stop(struct_processus *s_eta
|
Line 1563 instruction_stop(struct_processus *s_eta
|
if (pthread_mutex_lock(&((*(*((struct_processus_fils *) |
if (pthread_mutex_lock(&((*(*((struct_processus_fils *) |
(*s_objet).objet)).thread).mutex)) != 0) |
(*s_objet).objet)).thread).mutex)) != 0) |
{ |
{ |
if (pthread_mutex_unlock(&((*s_etat_processus).mutex)) |
if (pthread_mutex_unlock(&((*s_etat_processus) |
!= 0) |
.mutex_pile_processus)) != 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
Line 1441 instruction_stop(struct_processus *s_eta
|
Line 1577 instruction_stop(struct_processus *s_eta
|
if ((*(*((struct_processus_fils *) |
if ((*(*((struct_processus_fils *) |
(*s_objet).objet)).thread).thread_actif == d_vrai) |
(*s_objet).objet)).thread).thread_actif == d_vrai) |
{ |
{ |
pthread_kill((*(*((struct_processus_fils *) |
envoi_signal_thread((*(*((struct_processus_fils *) |
(*s_objet).objet)).thread).tid, SIGFSTOP); |
(*s_objet).objet)).thread).tid, rpl_sigstop); |
} |
} |
|
|
if (pthread_mutex_unlock(&((*(*((struct_processus_fils *) |
if (pthread_mutex_unlock(&((*(*((struct_processus_fils *) |
(*s_objet).objet)).thread).mutex)) != 0) |
(*s_objet).objet)).thread).mutex)) != 0) |
{ |
{ |
if (pthread_mutex_unlock(&((*s_etat_processus).mutex)) |
if (pthread_mutex_unlock(&((*s_etat_processus) |
!= 0) |
.mutex_pile_processus)) != 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
Line 1461 instruction_stop(struct_processus *s_eta
|
Line 1597 instruction_stop(struct_processus *s_eta
|
} |
} |
} |
} |
|
|
if (pthread_mutex_unlock(&((*s_etat_processus).mutex)) != 0) |
if (pthread_mutex_unlock(&((*s_etat_processus) |
|
.mutex_pile_processus)) != 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |