version 1.35, 2011/09/15 17:51:43
|
version 1.56, 2013/02/27 17:11:44
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.1.3 |
RPL/2 (R) version 4.1.13 |
Copyright (C) 1989-2011 Dr. BERTRAND Joël |
Copyright (C) 1989-2013 Dr. BERTRAND Joël |
|
|
This file is part of RPL/2. |
This file is part of RPL/2. |
|
|
Line 247 instruction_send(struct_processus *s_eta
|
Line 247 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 (pthread_mutex_unlock(&((*s_etat_processus).mutex_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 257 instruction_send(struct_processus *s_eta
|
Line 261 instruction_send(struct_processus *s_eta
|
(*s_etat_processus).pipe_nombre_objets_attente, |
(*s_etat_processus).pipe_nombre_objets_attente, |
&pid, sizeof(pid))) != sizeof(pid)) |
&pid, sizeof(pid))) != sizeof(pid)) |
{ |
{ |
if (pthread_mutex_lock(&((*s_etat_processus).mutex_fork)) != 0) |
# ifndef SEMAPHORES_NOMMES |
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) |
|
# else |
|
while(sem_wait((*s_etat_processus).semaphore_fork) != 0) |
|
# endif |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
if (errno != EINTR) |
return; |
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
} |
} |
|
|
if (longueur_ecriture == -1) |
if (longueur_ecriture == -1) |
Line 277 instruction_send(struct_processus *s_eta
|
Line 288 instruction_send(struct_processus *s_eta
|
nanosleep(&attente, NULL); |
nanosleep(&attente, NULL); |
INCR_GRANULARITE(attente.tv_nsec); |
INCR_GRANULARITE(attente.tv_nsec); |
|
|
if (pthread_mutex_unlock(&((*s_etat_processus).mutex_fork)) |
# ifndef SEMAPHORES_NOMMES |
!= 0) |
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 296 instruction_send(struct_processus *s_eta
|
Line 310 instruction_send(struct_processus *s_eta
|
(*s_etat_processus).pipe_nombre_objets_attente, |
(*s_etat_processus).pipe_nombre_objets_attente, |
&pid, sizeof(pid))) != sizeof(pid)) |
&pid, sizeof(pid))) != sizeof(pid)) |
{ |
{ |
if (pthread_mutex_lock(&((*s_etat_processus).mutex_fork)) != 0) |
# ifndef SEMAPHORES_NOMMES |
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) |
|
# else |
|
while(sem_wait((*s_etat_processus).semaphore_fork) != 0) |
|
# endif |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
if (errno != EINTR) |
return; |
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
} |
} |
|
|
if (longueur_ecriture == -1) |
if (longueur_ecriture == -1) |
Line 316 instruction_send(struct_processus *s_eta
|
Line 337 instruction_send(struct_processus *s_eta
|
nanosleep(&attente, NULL); |
nanosleep(&attente, NULL); |
INCR_GRANULARITE(attente.tv_nsec); |
INCR_GRANULARITE(attente.tv_nsec); |
|
|
if (pthread_mutex_unlock(&((*s_etat_processus).mutex_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 325 instruction_send(struct_processus *s_eta
|
Line 350 instruction_send(struct_processus *s_eta
|
scrutation_interruptions(s_etat_processus); |
scrutation_interruptions(s_etat_processus); |
} |
} |
|
|
if (pthread_mutex_lock(&((*s_etat_processus).mutex_fork)) != 0) |
# ifndef SEMAPHORES_NOMMES |
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) |
|
# else |
|
while(sem_wait((*s_etat_processus).semaphore_fork) != 0) |
|
# endif |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
if (errno != EINTR) |
return; |
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
} |
} |
} |
} |
else |
else |
Line 343 instruction_send(struct_processus *s_eta
|
Line 375 instruction_send(struct_processus *s_eta
|
} |
} |
} |
} |
|
|
tid = -3; |
tid = (pthread_t) -3; |
|
|
attente.tv_sec = 0; |
attente.tv_sec = 0; |
attente.tv_nsec = GRANULARITE_us * 1000; |
attente.tv_nsec = GRANULARITE_us * 1000; |
|
|
if (pthread_mutex_unlock(&((*s_etat_processus).mutex_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 358 instruction_send(struct_processus *s_eta
|
Line 394 instruction_send(struct_processus *s_eta
|
(*s_etat_processus).pipe_nombre_objets_attente, |
(*s_etat_processus).pipe_nombre_objets_attente, |
&tid, sizeof(tid))) != sizeof(tid)) |
&tid, sizeof(tid))) != sizeof(tid)) |
{ |
{ |
while(pthread_mutex_lock(&((*s_etat_processus).mutex_fork)) != 0) |
# ifndef SEMAPHORES_NOMMES |
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) |
|
# else |
|
while(sem_wait((*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 378 instruction_send(struct_processus *s_eta
|
Line 418 instruction_send(struct_processus *s_eta
|
nanosleep(&attente, NULL); |
nanosleep(&attente, NULL); |
INCR_GRANULARITE(attente.tv_nsec); |
INCR_GRANULARITE(attente.tv_nsec); |
|
|
if (pthread_mutex_unlock(&((*s_etat_processus).mutex_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 396 instruction_send(struct_processus *s_eta
|
Line 440 instruction_send(struct_processus *s_eta
|
(*s_etat_processus).pipe_nombre_objets_attente, |
(*s_etat_processus).pipe_nombre_objets_attente, |
&tid, sizeof(tid))) != sizeof(tid)) |
&tid, sizeof(tid))) != sizeof(tid)) |
{ |
{ |
if (pthread_mutex_lock(&((*s_etat_processus).mutex_fork)) != 0) |
# ifndef SEMAPHORES_NOMMES |
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) |
|
# else |
|
while(sem_wait((*s_etat_processus).semaphore_fork) != 0) |
|
# endif |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
if (errno != EINTR) |
return; |
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
} |
} |
|
|
if (longueur_ecriture == -1) |
if (longueur_ecriture == -1) |
Line 416 instruction_send(struct_processus *s_eta
|
Line 467 instruction_send(struct_processus *s_eta
|
nanosleep(&attente, NULL); |
nanosleep(&attente, NULL); |
INCR_GRANULARITE(attente.tv_nsec); |
INCR_GRANULARITE(attente.tv_nsec); |
|
|
if (pthread_mutex_unlock(&((*s_etat_processus).mutex_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 425 instruction_send(struct_processus *s_eta
|
Line 480 instruction_send(struct_processus *s_eta
|
scrutation_interruptions(s_etat_processus); |
scrutation_interruptions(s_etat_processus); |
} |
} |
|
|
if (pthread_mutex_lock(&((*s_etat_processus).mutex_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 437 instruction_send(struct_processus *s_eta
|
Line 496 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 (pthread_mutex_unlock(&((*s_etat_processus).mutex_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 446 instruction_send(struct_processus *s_eta
|
Line 509 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)) |
{ |
{ |
if (pthread_mutex_lock(&((*s_etat_processus).mutex_fork)) != 0) |
# ifndef SEMAPHORES_NOMMES |
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) |
|
# else |
|
while(sem_wait((*s_etat_processus).semaphore_fork) != 0) |
|
# endif |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
if (errno != EINTR) |
return; |
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
} |
} |
|
|
nanosleep(&attente, NULL); |
nanosleep(&attente, NULL); |
INCR_GRANULARITE(attente.tv_nsec); |
INCR_GRANULARITE(attente.tv_nsec); |
|
|
if (pthread_mutex_unlock(&((*s_etat_processus).mutex_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 464 instruction_send(struct_processus *s_eta
|
Line 538 instruction_send(struct_processus *s_eta
|
scrutation_interruptions(s_etat_processus); |
scrutation_interruptions(s_etat_processus); |
} |
} |
|
|
if (pthread_mutex_lock(&((*s_etat_processus).mutex_fork)) != 0) |
# ifndef SEMAPHORES_NOMMES |
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) |
|
# else |
|
while(sem_wait((*s_etat_processus).semaphore_fork) != 0) |
|
# endif |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
if (errno != EINTR) |
return; |
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
} |
} |
|
|
// Envoi d'un PID invalide (-1) pour ne pas bloquer le thread |
// Envoi d'un PID invalide (-1) pour ne pas bloquer le thread |
Line 480 instruction_send(struct_processus *s_eta
|
Line 561 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 (pthread_mutex_unlock(&((*s_etat_processus).mutex_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 490 instruction_send(struct_processus *s_eta
|
Line 575 instruction_send(struct_processus *s_eta
|
(*s_etat_processus).pipe_nombre_interruptions_attente, |
(*s_etat_processus).pipe_nombre_interruptions_attente, |
&pid, sizeof(pid))) != sizeof(pid)) |
&pid, sizeof(pid))) != sizeof(pid)) |
{ |
{ |
if (pthread_mutex_lock(&((*s_etat_processus).mutex_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 510 instruction_send(struct_processus *s_eta
|
Line 599 instruction_send(struct_processus *s_eta
|
nanosleep(&attente, NULL); |
nanosleep(&attente, NULL); |
INCR_GRANULARITE(attente.tv_nsec); |
INCR_GRANULARITE(attente.tv_nsec); |
|
|
if (pthread_mutex_unlock(&((*s_etat_processus).mutex_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; |
} |
} |
} |
} |
|
|
if (pthread_mutex_lock(&((*s_etat_processus).mutex_fork)) != 0) |
# ifndef SEMAPHORES_NOMMES |
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) |
|
# else |
|
while(sem_wait((*s_etat_processus).semaphore_fork) != 0) |
|
# endif |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
if (errno != EINTR) |
return; |
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
} |
} |
|
|
scrutation_interruptions(s_etat_processus); |
scrutation_interruptions(s_etat_processus); |
} |
} |
else |
else |
{ |
{ |
tid = -1; |
tid = (pthread_t) -1; |
|
|
attente.tv_sec = 0; |
attente.tv_sec = 0; |
attente.tv_nsec = GRANULARITE_us * 1000; |
attente.tv_nsec = GRANULARITE_us * 1000; |
|
|
if (pthread_mutex_unlock(&((*s_etat_processus).mutex_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 542 instruction_send(struct_processus *s_eta
|
Line 646 instruction_send(struct_processus *s_eta
|
(*s_etat_processus).pipe_nombre_interruptions_attente, |
(*s_etat_processus).pipe_nombre_interruptions_attente, |
&tid, sizeof(tid))) != sizeof(tid)) |
&tid, sizeof(tid))) != sizeof(tid)) |
{ |
{ |
if (pthread_mutex_lock(&((*s_etat_processus).mutex_fork)) != 0) |
# ifndef SEMAPHORES_NOMMES |
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) |
|
# else |
|
while(sem_wait((*s_etat_processus).semaphore_fork) != 0) |
|
# endif |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
if (errno != EINTR) |
return; |
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
} |
} |
|
|
if (longueur_ecriture == -1) |
if (longueur_ecriture == -1) |
Line 562 instruction_send(struct_processus *s_eta
|
Line 673 instruction_send(struct_processus *s_eta
|
nanosleep(&attente, NULL); |
nanosleep(&attente, NULL); |
INCR_GRANULARITE(attente.tv_nsec); |
INCR_GRANULARITE(attente.tv_nsec); |
|
|
if (pthread_mutex_unlock(&((*s_etat_processus).mutex_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 571 instruction_send(struct_processus *s_eta
|
Line 686 instruction_send(struct_processus *s_eta
|
scrutation_interruptions(s_etat_processus); |
scrutation_interruptions(s_etat_processus); |
} |
} |
|
|
if (pthread_mutex_lock(&((*s_etat_processus).mutex_fork)) != 0) |
# ifndef SEMAPHORES_NOMMES |
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) |
|
# else |
|
while(sem_wait((*s_etat_processus).semaphore_fork) != 0) |
|
# endif |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
if (errno != EINTR) |
return; |
{ |
|
(*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 (pthread_mutex_unlock(&((*s_etat_processus).mutex_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 589 instruction_send(struct_processus *s_eta
|
Line 715 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) |
{ |
{ |
if (pthread_mutex_lock(&((*s_etat_processus).mutex_fork)) != 0) |
# ifndef SEMAPHORES_NOMMES |
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) |
|
# else |
|
while(sem_wait((*s_etat_processus).semaphore_fork) != 0) |
|
# endif |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
if (errno != EINTR) |
return; |
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
} |
} |
|
|
if ((*s_etat_processus).profilage == d_vrai) |
if ((*s_etat_processus).profilage == d_vrai) |
Line 604 instruction_send(struct_processus *s_eta
|
Line 737 instruction_send(struct_processus *s_eta
|
return; |
return; |
} |
} |
|
|
if (pthread_mutex_lock(&((*s_etat_processus).mutex_fork)) != 0) |
# ifndef SEMAPHORES_NOMMES |
|
while(sem_wait(&((*s_etat_processus).semaphore_fork)) != 0) |
|
# else |
|
while(sem_wait((*s_etat_processus).semaphore_fork) != 0) |
|
# endif |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
if (errno != EINTR) |
return; |
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
} |
} |
|
|
if ((*s_etat_processus).profilage == d_vrai) |
if ((*s_etat_processus).profilage == d_vrai) |
Line 645 instruction_send(struct_processus *s_eta
|
Line 785 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 705 instruction_sqlquery(struct_processus *s
|
Line 833 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 751 instruction_sqlquery(struct_processus *s
|
Line 881 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 812 instruction_sqlquery(struct_processus *s
|
Line 952 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 1015 instruction_sqlquery(struct_processus *s
|
Line 1165 instruction_sqlquery(struct_processus *s
|
{ |
{ |
# ifdef POSTGRESQL_SUPPORT |
# ifdef POSTGRESQL_SUPPORT |
|
|
PGresult *resultat_postgresql; |
unsigned int i; |
|
unsigned int j; |
|
unsigned int nombre_colonnes; |
|
unsigned 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 1259 instruction_sqlquery(struct_processus *s
|
Line 1421 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 ios; |
|
|
|
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; |
|
|
|
unsigned int i; |
|
unsigned int nombre_colonnes; |
|
|
|
if (sqlite3_prepare_v2((*((struct_connecteur_sql *) |
|
(*s_objet_1).objet)).descripteur.sqlite, |
|
(unsigned char *) (*s_objet_2).objet, |
|
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); |