--- rpl/src/gestion_fichiers.c 2010/03/06 18:29:06 1.6 +++ rpl/src/gestion_fichiers.c 2010/03/07 17:03:29 1.7 @@ -451,12 +451,12 @@ initialisation_fichier_acces_indexe(stru { const char commande1[] = "create table data(id integer primary key asc, key_id integer, " - "lock text)"; + "data text, order integer)"; const char commande10[] = "create table key(id integer primary key asc, key text)"; const char commande2[] = "create table data(id integer primary key asc, key_id integer, " - "lock blob)"; + "data blob, order integer)"; const char commande20[] = "create table key(id integer primary key asc, key blob)"; const char commande3[] = @@ -600,9 +600,9 @@ initialisation_fichier_acces_direct(stru sqlite3 *sqlite, logical1 binaire) { const char commande1[] = - "create table data(id integer primary key asc, lock text)"; + "create table data(id integer primary key asc, data text)"; const char commande2[] = - "create table data(id integer primary key asc, lock blob)"; + "create table data(id integer primary key asc, data blob)"; const char commande3[] = "create index data_idx on data(id)"; const char *queue; @@ -680,97 +680,4 @@ initialisation_fichier_acces_direct(stru return(d_absence_erreur); } -unsigned char * -verrouillage_fichier_sqlite(struct_processus *s_etat_processus, - sqlite3 *sqlite, unsigned char *operation) -{ - const char commande1[] = - "select lock from control where id = 1"; - const char commande2[] = - "update control set lock = '%s'"; - const char *queue; - - const unsigned char *resultat; - - sqlite3_stmt *ppStmt; - - unsigned char *verrou; - - resultat = NULL; - - if (operation == NULL) - { - // Lecture du verrou - - if (sqlite3_prepare_v2(sqlite, commande1, strlen(commande1), &ppStmt, - &queue) != SQLITE_OK) - { - (*s_etat_processus).erreur_systeme = d_es_erreur_fichier; - return(NULL); - } - - if (sqlite3_step(ppStmt) != SQLITE_ROW) - { - (*s_etat_processus).erreur_systeme = d_es_erreur_fichier; - return(NULL); - } - - if (sqlite3_column_type(ppStmt, 0) != SQLITE_TEXT) - { - (*s_etat_processus).erreur_systeme = d_es_erreur_fichier; - return(NULL); - } - - resultat = sqlite3_column_text(ppStmt, 0); - - if ((verrou = malloc((strlen(resultat) + 1) * sizeof(unsigned char))) - == NULL) - { - return(NULL); - } - - strcpy(verrou, resultat); - - if (sqlite3_finalize(ppStmt) != SQLITE_OK) - { - (*s_etat_processus).erreur_systeme = d_es_erreur_fichier; - return(NULL); - } - } - else - { - // Positionnement d'un verrou - - if (alsprintf(&verrou, commande2, operation) < 0) - { - (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; - return(NULL); - } - - if (sqlite3_prepare_v2(sqlite, verrou, strlen(verrou), &ppStmt, - &queue) != SQLITE_OK) - { - (*s_etat_processus).erreur_systeme = d_es_erreur_fichier; - return(NULL); - } - - if (sqlite3_step(ppStmt) != SQLITE_DONE) - { - (*s_etat_processus).erreur_systeme = d_es_erreur_fichier; - return(NULL); - } - - if (sqlite3_finalize(ppStmt) != SQLITE_OK) - { - (*s_etat_processus).erreur_systeme = d_es_erreur_fichier; - return(NULL); - } - - free(verrou); - verrou = NULL; - } - - return(verrou); -} - // vim: ts=4