version 1.7, 2010/03/09 10:18:45
|
version 1.81, 2025/04/15 10:17:52
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.0.13 |
RPL/2 (R) version 4.1.36 |
Copyright (C) 1989-2010 Dr. BERTRAND Joël |
Copyright (C) 1989-2025 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 42 instruction_delete(struct_processus *s_e
|
Line 42 instruction_delete(struct_processus *s_e
|
|
|
file *fichier; |
file *fichier; |
|
|
|
int ios; |
|
|
integer8 lecture_i64; |
integer8 lecture_i64; |
|
|
logical1 erreur; |
logical1 erreur; |
Line 59 instruction_delete(struct_processus *s_e
|
Line 61 instruction_delete(struct_processus *s_e
|
|
|
struct stat requete; |
struct stat requete; |
|
|
|
struct timespec attente; |
|
|
unsigned char *commande; |
unsigned char *commande; |
unsigned char *nom; |
unsigned char *nom; |
unsigned char *utf8; |
unsigned char *utf8; |
Line 306 instruction_delete(struct_processus *s_e
|
Line 310 instruction_delete(struct_processus *s_e
|
return; |
return; |
} |
} |
|
|
if (alsprintf(&commande, "select count(*) from data where " |
if (alsprintf(s_etat_processus, &commande, |
"id = %lld", (*((integer8 *) (*s_objet_indice).objet))) |
"select count(*) from data where id = %lld", |
< 0) |
(*((integer8 *) (*s_objet_indice).objet))) < 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
d_es_allocation_memoire; |
d_es_allocation_memoire; |
Line 316 instruction_delete(struct_processus *s_e
|
Line 320 instruction_delete(struct_processus *s_e
|
} |
} |
|
|
if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite, |
if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite, |
commande, strlen(commande), &ppStmt, &queue) |
commande, (int) strlen(commande), &ppStmt, &queue) |
!= SQLITE_OK) |
!= SQLITE_OK) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
return; |
return; |
} |
} |
|
|
if (sqlite3_step(ppStmt) != SQLITE_ROW) |
attente.tv_sec = 0; |
|
attente.tv_nsec = GRANULARITE_us * 1000; |
|
|
|
do |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
ios = sqlite3_step(ppStmt); |
return; |
|
} |
if (ios == SQLITE_ROW) |
|
{ |
|
break; |
|
} |
|
else if ((ios == SQLITE_BUSY) || (ios == SQLITE_LOCKED)) |
|
{ |
|
nanosleep(&attente, NULL); |
|
INCR_GRANULARITE(attente.tv_nsec); |
|
} |
|
else |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_erreur_fichier; |
|
return; |
|
} |
|
} while(ios != SQLITE_ROW); |
|
|
lecture_i64 = sqlite3_column_int64(ppStmt, 0); |
lecture_i64 = sqlite3_column_int64(ppStmt, 0); |
|
|
Line 355 instruction_delete(struct_processus *s_e
|
Line 377 instruction_delete(struct_processus *s_e
|
return; |
return; |
} |
} |
|
|
if (alsprintf(&commande, "delete from data where id = %lld", |
if (alsprintf(s_etat_processus, &commande, |
|
"delete from data where id = %lld", |
(*((integer8 *) (*s_objet_indice).objet))) < 0) |
(*((integer8 *) (*s_objet_indice).objet))) < 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
Line 364 instruction_delete(struct_processus *s_e
|
Line 387 instruction_delete(struct_processus *s_e
|
} |
} |
|
|
if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite, |
if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite, |
commande, strlen(commande), &ppStmt, &queue) |
commande, (int) strlen(commande), &ppStmt, &queue) |
!= SQLITE_OK) |
!= SQLITE_OK) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
Line 419 instruction_delete(struct_processus *s_e
|
Line 442 instruction_delete(struct_processus *s_e
|
return; |
return; |
} |
} |
|
|
if (alsprintf(&commande, "select id from key where key = " |
if (alsprintf(s_etat_processus, &commande, |
"'{ \"%s\" }'", utf8) < 0) |
"select id from key where key = '{ \"%s\" }'", utf8) |
|
< 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
d_es_allocation_memoire; |
d_es_allocation_memoire; |
Line 430 instruction_delete(struct_processus *s_e
|
Line 454 instruction_delete(struct_processus *s_e
|
free(utf8); |
free(utf8); |
|
|
if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite, |
if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite, |
commande, strlen(commande), &ppStmt, &queue) |
commande, (int) strlen(commande), &ppStmt, &queue) |
!= SQLITE_OK) |
!= SQLITE_OK) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
return; |
return; |
} |
} |
|
|
switch(sqlite3_step(ppStmt)) |
attente.tv_sec = 0; |
|
attente.tv_nsec = GRANULARITE_us * 1000; |
|
|
|
do |
{ |
{ |
case SQLITE_ROW: |
ios = sqlite3_step(ppStmt); |
{ |
|
// Correspondance |
|
break; |
|
} |
|
|
|
case SQLITE_DONE: |
switch(ios) |
{ |
{ |
// Aucune correspondance |
case SQLITE_ROW: |
if (sqlite3_finalize(ppStmt) != SQLITE_OK) |
|
{ |
{ |
(*s_etat_processus).erreur_systeme = |
// Correspondance |
d_es_erreur_fichier; |
break; |
return; |
|
} |
} |
|
|
free(commande); |
case SQLITE_DONE: |
|
{ |
|
// Aucune correspondance |
|
if (sqlite3_finalize(ppStmt) != SQLITE_OK) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_erreur_fichier; |
|
return; |
|
} |
|
|
liberation(s_etat_processus, s_objet_argument); |
free(commande); |
liberation(s_etat_processus, s_objet_indice); |
|
|
|
(*s_etat_processus).erreur_execution = |
liberation(s_etat_processus, s_objet_argument); |
d_ex_enregistrement_inexistant; |
liberation(s_etat_processus, s_objet_indice); |
return; |
|
} |
|
|
|
default: |
(*s_etat_processus).erreur_execution = |
{ |
d_ex_enregistrement_inexistant; |
(*s_etat_processus).erreur_systeme = |
return; |
d_es_erreur_fichier; |
} |
return; |
|
|
case SQLITE_LOCKED: |
|
case SQLITE_BUSY: |
|
{ |
|
nanosleep(&attente, NULL); |
|
INCR_GRANULARITE(attente.tv_nsec); |
|
break; |
|
} |
|
|
|
default: |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_erreur_fichier; |
|
return; |
|
} |
} |
} |
} |
} while(ios != SQLITE_ROW); |
|
|
if (sqlite3_column_type(ppStmt, 0) != SQLITE_INTEGER) |
if (sqlite3_column_type(ppStmt, 0) != SQLITE_INTEGER) |
{ |
{ |
Line 496 instruction_delete(struct_processus *s_e
|
Line 536 instruction_delete(struct_processus *s_e
|
|
|
free(commande); |
free(commande); |
|
|
if (alsprintf(&commande, "delete from data where key_id = %lld", |
if (alsprintf(s_etat_processus, &commande, |
lecture_i64) < 0) |
"delete from data where key_id = %lld", lecture_i64) |
|
< 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
d_es_allocation_memoire; |
d_es_allocation_memoire; |
Line 505 instruction_delete(struct_processus *s_e
|
Line 546 instruction_delete(struct_processus *s_e
|
} |
} |
|
|
if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite, |
if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite, |
commande, strlen(commande), &ppStmt, &queue) |
commande, (int) strlen(commande), &ppStmt, &queue) |
!= SQLITE_OK) |
!= SQLITE_OK) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
Line 527 instruction_delete(struct_processus *s_e
|
Line 568 instruction_delete(struct_processus *s_e
|
|
|
free(commande); |
free(commande); |
|
|
if (alsprintf(&commande, "delete from key where id = %lld", |
if (alsprintf(s_etat_processus, &commande, |
lecture_i64) < 0) |
"delete from key where id = %lld", lecture_i64) < 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
d_es_allocation_memoire; |
d_es_allocation_memoire; |
Line 536 instruction_delete(struct_processus *s_e
|
Line 577 instruction_delete(struct_processus *s_e
|
} |
} |
|
|
if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite, |
if (sqlite3_prepare_v2((*descripteur).descripteur_sqlite, |
commande, strlen(commande), &ppStmt, &queue) |
commande, (int) strlen(commande), &ppStmt, &queue) |
!= SQLITE_OK) |
!= SQLITE_OK) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
Line 666 instruction_drws(struct_processus *s_eta
|
Line 707 instruction_drws(struct_processus *s_eta
|
|
|
int dimensions; |
int dimensions; |
|
|
logical1 presence_variable; |
|
logical1 matrice_entiere; |
logical1 matrice_entiere; |
|
|
long i; |
|
|
|
struct_objet *s_objet_statistique; |
struct_objet *s_objet_statistique; |
|
|
unsigned char *nom_fichier; |
unsigned char *nom_fichier; |
|
|
unsigned long j; |
integer8 j; |
|
|
struct_fichier_graphique *l_fichier_courant; |
struct_fichier_graphique *l_fichier_courant; |
struct_fichier_graphique *l_fichier_precedent; |
struct_fichier_graphique *l_fichier_precedent; |
Line 717 instruction_drws(struct_processus *s_eta
|
Line 755 instruction_drws(struct_processus *s_eta
|
* Vérification de la présence de la matrice statistique |
* Vérification de la présence de la matrice statistique |
*/ |
*/ |
|
|
if (recherche_variable(s_etat_processus, ds_sdat) == d_faux) |
if (recherche_variable_globale(s_etat_processus, ds_sdat) == d_faux) |
{ |
{ |
/* |
/* |
* Aucune variable ds_sdat n'existe. |
* Aucune variable ds_sdat n'existe. |
*/ |
*/ |
|
|
(*s_etat_processus).erreur_execution = d_ex_absence_observations; |
if ((*s_etat_processus).erreur_execution == d_ex) |
(*s_etat_processus).erreur_systeme = d_es; |
|
|
|
return; |
|
} |
|
|
|
i = (*s_etat_processus).position_variable_courante; |
|
presence_variable = d_faux; |
|
|
|
while(i >= 0) |
|
{ |
|
if ((strcmp((*s_etat_processus).s_liste_variables[i].nom, |
|
ds_sdat) == 0) && ((*s_etat_processus) |
|
.s_liste_variables[i].niveau == 1)) |
|
{ |
{ |
presence_variable = d_vrai; |
(*s_etat_processus).erreur_execution = d_ex_absence_observations; |
break; |
|
} |
} |
|
|
i--; |
(*s_etat_processus).erreur_systeme = d_es; |
} |
|
|
|
if (presence_variable == d_faux) |
|
{ |
|
(*s_etat_processus).erreur_execution = d_ex_absence_observations; |
|
return; |
return; |
} |
} |
|
|
if ((s_objet_statistique = (*s_etat_processus).s_liste_variables[i].objet) |
s_objet_statistique = (*(*s_etat_processus).pointeur_variable_courante) |
== NULL) |
.objet; |
{ |
|
(*s_etat_processus).erreur_execution = d_ex_variable_partagee; |
|
return; |
|
} |
|
|
|
if ((*s_objet_statistique).type == MIN) |
if ((*s_objet_statistique).type == MIN) |
{ |
{ |
Line 840 instruction_drws(struct_processus *s_eta
|
Line 856 instruction_drws(struct_processus *s_eta
|
|
|
if (((*s_etat_processus).colonne_statistique_1 < 1) || |
if (((*s_etat_processus).colonne_statistique_1 < 1) || |
((*s_etat_processus).colonne_statistique_2 < 1) || |
((*s_etat_processus).colonne_statistique_2 < 1) || |
((*s_etat_processus).colonne_statistique_1 > (signed long) |
((*s_etat_processus).colonne_statistique_1 > |
(*((struct_matrice *) (*s_objet_statistique).objet)) |
(*((struct_matrice *) (*s_objet_statistique).objet)) |
.nombre_colonnes) || |
.nombre_colonnes) || |
((*s_etat_processus).colonne_statistique_2 > (signed long) |
((*s_etat_processus).colonne_statistique_2 > |
(*((struct_matrice *) (*s_objet_statistique).objet)) |
(*((struct_matrice *) (*s_objet_statistique).objet)) |
.nombre_colonnes)) |
.nombre_colonnes)) |
{ |
{ |
Line 1083 instruction_decr(struct_processus *s_eta
|
Line 1099 instruction_decr(struct_processus *s_eta
|
|
|
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_argument); |
|
|
if ((*s_etat_processus).s_liste_variables |
if ((*(*s_etat_processus).pointeur_variable_courante) |
[(*s_etat_processus).position_variable_courante] |
|
.variable_verrouillee == d_vrai) |
.variable_verrouillee == d_vrai) |
{ |
{ |
(*s_etat_processus).erreur_execution = |
(*s_etat_processus).erreur_execution = |
Line 1092 instruction_decr(struct_processus *s_eta
|
Line 1107 instruction_decr(struct_processus *s_eta
|
return; |
return; |
} |
} |
|
|
if ((*s_etat_processus).s_liste_variables |
if ((*(*s_etat_processus).pointeur_variable_courante).objet |
[(*s_etat_processus).position_variable_courante].objet |
|
== NULL) |
== NULL) |
{ |
{ |
if (pthread_mutex_lock(&((*(*s_etat_processus) |
|
.s_liste_variables_partagees).mutex)) != 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_processus; |
|
return; |
|
} |
|
|
|
if (recherche_variable_partagee(s_etat_processus, |
if (recherche_variable_partagee(s_etat_processus, |
(*s_etat_processus).s_liste_variables |
(*(*s_etat_processus).pointeur_variable_courante).nom, |
[(*s_etat_processus).position_variable_courante].nom, |
(*(*s_etat_processus).pointeur_variable_courante) |
(*s_etat_processus).s_liste_variables |
.variable_partagee, (*(*s_etat_processus) |
[(*s_etat_processus).position_variable_courante] |
.pointeur_variable_courante).origine) == NULL) |
.variable_partagee, (*s_etat_processus).s_liste_variables |
|
[(*s_etat_processus).position_variable_courante] |
|
.origine) == d_faux) |
|
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es; |
(*s_etat_processus).erreur_systeme = d_es; |
(*s_etat_processus).erreur_execution = |
(*s_etat_processus).erreur_execution = |
Line 1120 instruction_decr(struct_processus *s_eta
|
Line 1124 instruction_decr(struct_processus *s_eta
|
} |
} |
|
|
s_objet_argument = (*(*s_etat_processus) |
s_objet_argument = (*(*s_etat_processus) |
.s_liste_variables_partagees).table |
.pointeur_variable_partagee_courante).objet; |
[(*(*s_etat_processus).s_liste_variables_partagees) |
|
.position_variable].objet; |
|
variable_partagee = d_vrai; |
variable_partagee = d_vrai; |
} |
} |
else |
else |
{ |
{ |
s_objet_argument = (*s_etat_processus).s_liste_variables |
s_objet_argument = (*(*s_etat_processus).pointeur_variable_courante) |
[(*s_etat_processus).position_variable_courante].objet; |
.objet; |
variable_partagee = d_faux; |
variable_partagee = d_faux; |
} |
} |
|
|
Line 1138 instruction_decr(struct_processus *s_eta
|
Line 1140 instruction_decr(struct_processus *s_eta
|
if (variable_partagee == d_vrai) |
if (variable_partagee == d_vrai) |
{ |
{ |
if (pthread_mutex_unlock(&((*(*s_etat_processus) |
if (pthread_mutex_unlock(&((*(*s_etat_processus) |
.s_liste_variables_partagees).mutex)) != 0) |
.pointeur_variable_partagee_courante).mutex)) != 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
Line 1153 instruction_decr(struct_processus *s_eta
|
Line 1155 instruction_decr(struct_processus *s_eta
|
|
|
if (variable_partagee == d_vrai) |
if (variable_partagee == d_vrai) |
{ |
{ |
(*s_etat_processus).s_liste_variables[(*s_etat_processus) |
(*(*s_etat_processus).pointeur_variable_courante).objet = NULL; |
.position_variable_courante].objet = NULL; |
(*(*s_etat_processus).pointeur_variable_partagee_courante).objet = |
(*(*s_etat_processus) |
s_copie_argument; |
.s_liste_variables_partagees).table |
|
[(*(*s_etat_processus).s_liste_variables_partagees) |
|
.position_variable].objet = s_copie_argument; |
|
} |
} |
else |
else |
{ |
{ |
(*s_etat_processus).s_liste_variables[(*s_etat_processus) |
(*(*s_etat_processus).pointeur_variable_courante).objet = |
.position_variable_courante].objet = s_copie_argument; |
s_copie_argument; |
} |
} |
|
|
if ((*s_copie_argument).type == INT) |
if ((*s_copie_argument).type == INT) |
Line 1173 instruction_decr(struct_processus *s_eta
|
Line 1172 instruction_decr(struct_processus *s_eta
|
if (variable_partagee == d_vrai) |
if (variable_partagee == d_vrai) |
{ |
{ |
if (pthread_mutex_unlock(&((*(*s_etat_processus) |
if (pthread_mutex_unlock(&((*(*s_etat_processus) |
.s_liste_variables_partagees).mutex)) != 0) |
.pointeur_variable_partagee_courante).mutex)) != 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |
Line 1185 instruction_decr(struct_processus *s_eta
|
Line 1184 instruction_decr(struct_processus *s_eta
|
if (variable_partagee == d_vrai) |
if (variable_partagee == d_vrai) |
{ |
{ |
if (pthread_mutex_unlock(&((*(*s_etat_processus) |
if (pthread_mutex_unlock(&((*(*s_etat_processus) |
.s_liste_variables_partagees).mutex)) != 0) |
.pointeur_variable_partagee_courante).mutex)) != 0) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_processus; |
(*s_etat_processus).erreur_systeme = d_es_processus; |
return; |
return; |