version 1.2, 2010/01/27 22:22:14
|
version 1.31, 2011/06/21 07:45:25
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.0.10 |
RPL/2 (R) version 4.1.0.prerelease.1 |
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 897 instruction_open(struct_processus *s_eta
|
Line 897 instruction_open(struct_processus *s_eta
|
* Format : |
* Format : |
* FORMATTED : fichier texte ; |
* FORMATTED : fichier texte ; |
* UNFORMATTED : fichier binaire. |
* UNFORMATTED : fichier binaire. |
|
* FLOW : chaîne de caractères sans format (en tant qu'objet |
|
* binaire comme "\x00avz\xFD") |
*/ |
*/ |
|
|
file *descripteur; |
file *descripteur; |
Line 915 instruction_open(struct_processus *s_eta
|
Line 917 instruction_open(struct_processus *s_eta
|
integer8 port; |
integer8 port; |
integer8 position_clef; |
integer8 position_clef; |
|
|
logical1 autorisation_liberation_nom; |
|
logical1 erreur; |
logical1 erreur; |
logical1 existence; |
logical1 existence; |
logical1 ouverture; |
logical1 ouverture; |
logical1 presence_port; |
logical1 presence_port; |
|
|
|
sqlite3 *sqlite; |
|
|
struct_liste_chainee *l_element_courant; |
struct_liste_chainee *l_element_courant; |
struct_liste_chainee *l_element_courant_sous_objet; |
struct_liste_chainee *l_element_courant_sous_objet; |
|
|
Line 933 instruction_open(struct_processus *s_eta
|
Line 936 instruction_open(struct_processus *s_eta
|
|
|
struct sockaddr_un socket_unix; |
struct sockaddr_un socket_unix; |
struct sockaddr_in socket_ipv4; |
struct sockaddr_in socket_ipv4; |
|
# ifdef IPV6 |
struct sockaddr_in6 socket_ipv6; |
struct sockaddr_in6 socket_ipv6; |
|
# endif |
|
|
struct_objet *s_objet_argument; |
struct_objet *s_objet_argument; |
struct_objet *s_objet_resultat; |
struct_objet *s_objet_resultat; |
Line 1016 instruction_open(struct_processus *s_eta
|
Line 1021 instruction_open(struct_processus *s_eta
|
"\"file name\" } \"protection\" } OPEN\n"); |
"\"file name\" } \"protection\" } OPEN\n"); |
printf(" { \"sockettype\" { \"name\" \"local name\" } } OPEN\n"); |
printf(" { \"sockettype\" { \"name\" \"local name\" } } OPEN\n"); |
printf(" { \"sockettype\" \"socketdomain\" \"protection\" } OPEN\n"); |
printf(" { \"sockettype\" \"socketdomain\" \"protection\" } OPEN\n"); |
|
printf(" \"/semaphore\" OPEN\n"); |
|
|
printf(" File type : NEW/OLD/REPLACE/UNKNOWN/SCRATCH\n"); |
printf(" File type : NEW/OLD/REPLACE/UNKNOWN/SCRATCH\n"); |
printf(" File access : SEQUENTIAL/DIRECT/KEYED\n"); |
printf(" File access : SEQUENTIAL/DIRECT/KEYED\n"); |
Line 1186 instruction_open(struct_processus *s_eta
|
Line 1192 instruction_open(struct_processus *s_eta
|
|
|
type_ouverture = 'R'; |
type_ouverture = 'R'; |
} |
} |
|
else if (strcmp(argument_majuscule, "OLD") == 0) |
|
{ |
|
if (type_ouverture != ' ') |
|
{ |
|
liberation(s_etat_processus, s_objet_argument); |
|
free(argument_majuscule); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_parametre_fichier; |
|
return; |
|
} |
|
|
|
if (type_arguments == ' ') |
|
{ |
|
type_arguments = 'F'; |
|
} |
|
else if (type_arguments == 'S') |
|
{ |
|
liberation(s_etat_processus, s_objet_argument); |
|
free(argument_majuscule); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_parametre_fichier; |
|
return; |
|
} |
|
|
|
type_ouverture = 'O'; |
|
} |
else if (strcmp(argument_majuscule, "UNKNOWN") == 0) |
else if (strcmp(argument_majuscule, "UNKNOWN") == 0) |
{ |
{ |
if (type_ouverture != ' ') |
if (type_ouverture != ' ') |
Line 2648 instruction_open(struct_processus *s_eta
|
Line 2682 instruction_open(struct_processus *s_eta
|
} |
} |
|
|
if (((type_acces != 'I') && (position_clef != 0)) || |
if (((type_acces != 'I') && (position_clef != 0)) || |
((type_acces == 'I') && (position_clef == 0))) |
((type_acces == 'I') && (position_clef == 0) && |
|
((type_ouverture == 'N') || (type_ouverture == 'R') || |
|
(type_ouverture == 'S')))) |
{ |
{ |
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_argument); |
|
|
Line 2684 instruction_open(struct_processus *s_eta
|
Line 2720 instruction_open(struct_processus *s_eta
|
|
|
sprintf(nom, "%s.rpl", nom_temporaire); |
sprintf(nom, "%s.rpl", nom_temporaire); |
free(nom_temporaire); |
free(nom_temporaire); |
|
|
autorisation_liberation_nom = d_vrai; |
|
} |
} |
else |
else |
{ |
{ |
autorisation_liberation_nom = d_faux; |
if ((nom = transliteration(s_etat_processus, nom, |
|
d_locale, "UTF-8")) == NULL) |
|
{ |
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
return; |
|
} |
} |
} |
|
|
/* |
/* |
Line 2712 instruction_open(struct_processus *s_eta
|
Line 2752 instruction_open(struct_processus *s_eta
|
if (((*((struct_fichier *) (*s_objet_resultat).objet)).format = |
if (((*((struct_fichier *) (*s_objet_resultat).objet)).format = |
allocation(s_etat_processus, LST)) == NULL) |
allocation(s_etat_processus, LST)) == NULL) |
{ |
{ |
|
free(nom); |
|
|
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
return; |
return; |
} |
} |
Line 2719 instruction_open(struct_processus *s_eta
|
Line 2761 instruction_open(struct_processus *s_eta
|
(*(*((struct_fichier *) (*s_objet_resultat).objet)) |
(*(*((struct_fichier *) (*s_objet_resultat).objet)) |
.format).objet = NULL; |
.format).objet = NULL; |
|
|
|
descripteur = NULL; |
|
|
switch(type_ouverture) |
switch(type_ouverture) |
{ |
{ |
case 'N' : |
case 'N' : |
Line 2728 instruction_open(struct_processus *s_eta
|
Line 2772 instruction_open(struct_processus *s_eta
|
|
|
if ((erreur != 0) || (unite != 0)) |
if ((erreur != 0) || (unite != 0)) |
{ |
{ |
|
free(nom); |
|
|
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_resultat); |
liberation(s_etat_processus, s_objet_resultat); |
|
|
Line 2736 instruction_open(struct_processus *s_eta
|
Line 2782 instruction_open(struct_processus *s_eta
|
return; |
return; |
} |
} |
|
|
if ((descripteur = fopen(nom, "w+")) == NULL) |
if (type_acces == 'S') |
{ |
{ |
liberation(s_etat_processus, s_objet_argument); |
if ((descripteur = fopen(nom, "w+")) == NULL) |
liberation(s_etat_processus, s_objet_resultat); |
{ |
|
free(nom); |
|
|
(*s_etat_processus).erreur_execution = |
liberation(s_etat_processus, s_objet_argument); |
d_ex_erreur_acces_fichier; |
liberation(s_etat_processus, s_objet_resultat); |
return; |
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_acces_fichier; |
|
return; |
|
} |
|
} |
|
else |
|
{ |
|
// Si le fichier existe, on le supprime. |
|
|
|
if (unlink(nom) != 0) |
|
{ |
|
free(nom); |
|
|
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_acces_fichier; |
|
return; |
|
} |
|
|
|
if (sqlite3_open_v2(nom, &sqlite, |
|
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, |
|
NULL) != SQLITE_OK) |
|
{ |
|
free(nom); |
|
|
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_acces_fichier; |
|
return; |
|
} |
|
|
|
if ((descripteur = fopen(nom, "a+")) == NULL) |
|
{ |
|
free(nom); |
|
|
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_acces_fichier; |
|
return; |
|
} |
|
|
|
if (type_acces == 'D') |
|
{ |
|
if (initialisation_fichier_acces_direct( |
|
s_etat_processus, sqlite, |
|
(format == 'N') ? d_faux : d_vrai) |
|
!= d_absence_erreur) |
|
{ |
|
free(nom); |
|
|
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
return; |
|
} |
|
} |
|
else |
|
{ |
|
if (position_clef == 0) |
|
{ |
|
free(nom); |
|
|
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_parametre_fichier; |
|
return; |
|
} |
|
|
|
if (initialisation_fichier_acces_indexe( |
|
s_etat_processus, sqlite, position_clef, |
|
(format == 'N') ? d_faux : d_vrai) |
|
!= d_absence_erreur) |
|
{ |
|
free(nom); |
|
|
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
return; |
|
} |
|
} |
} |
} |
|
|
break; |
break; |
Line 2751 instruction_open(struct_processus *s_eta
|
Line 2887 instruction_open(struct_processus *s_eta
|
|
|
case 'O' : |
case 'O' : |
{ |
{ |
erreur = caracteristiques_fichier(s_etat_processus, |
erreur = caracteristiques_fichier(s_etat_processus, nom, |
nom, &existence, &ouverture, &unite); |
&existence, &ouverture, &unite); |
|
|
if ((erreur != d_absence_erreur) || (existence == d_faux)) |
if ((erreur != d_absence_erreur) || (existence == d_faux)) |
{ |
{ |
|
free(nom); |
|
|
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_resultat); |
liberation(s_etat_processus, s_objet_resultat); |
|
|
Line 2764 instruction_open(struct_processus *s_eta
|
Line 2902 instruction_open(struct_processus *s_eta
|
return; |
return; |
} |
} |
|
|
if ((descripteur = fopen(nom, "r+")) == NULL) |
if (type_acces == 'S') |
{ |
{ |
liberation(s_etat_processus, s_objet_argument); |
if ((descripteur = fopen(nom, "r+")) == NULL) |
liberation(s_etat_processus, s_objet_resultat); |
{ |
|
free(nom); |
|
|
(*s_etat_processus).erreur_execution = |
liberation(s_etat_processus, s_objet_argument); |
d_ex_erreur_acces_fichier; |
liberation(s_etat_processus, s_objet_resultat); |
return; |
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_acces_fichier; |
|
return; |
|
} |
|
} |
|
else |
|
{ |
|
if (sqlite3_open_v2(nom, &sqlite, |
|
SQLITE_OPEN_READWRITE, |
|
NULL) != SQLITE_OK) |
|
{ |
|
free(nom); |
|
|
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_acces_fichier; |
|
return; |
|
} |
|
|
|
if ((descripteur = fopen(nom, "a+")) == NULL) |
|
{ |
|
free(nom); |
|
|
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_acces_fichier; |
|
return; |
|
} |
} |
} |
|
|
break; |
break; |
Line 2784 instruction_open(struct_processus *s_eta
|
Line 2955 instruction_open(struct_processus *s_eta
|
|
|
if ((erreur != d_absence_erreur) || (existence == d_faux)) |
if ((erreur != d_absence_erreur) || (existence == d_faux)) |
{ |
{ |
|
free(nom); |
|
|
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_resultat); |
liberation(s_etat_processus, s_objet_resultat); |
|
|
Line 2796 instruction_open(struct_processus *s_eta
|
Line 2969 instruction_open(struct_processus *s_eta
|
|
|
if ((descripteur = fopen(nom, "r")) == NULL) |
if ((descripteur = fopen(nom, "r")) == NULL) |
{ |
{ |
|
free(nom); |
|
|
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_resultat); |
liberation(s_etat_processus, s_objet_resultat); |
|
|
Line 2812 instruction_open(struct_processus *s_eta
|
Line 2987 instruction_open(struct_processus *s_eta
|
|
|
if (fcntl(fileno(descripteur), F_GETLK, &lock) == -1) |
if (fcntl(fileno(descripteur), F_GETLK, &lock) == -1) |
{ |
{ |
|
free(nom); |
|
|
if (fclose(descripteur) != 0) |
if (fclose(descripteur) != 0) |
{ |
{ |
|
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_resultat); |
liberation(s_etat_processus, s_objet_resultat); |
|
|
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
Line 2821 instruction_open(struct_processus *s_eta
|
Line 2999 instruction_open(struct_processus *s_eta
|
return; |
return; |
} |
} |
|
|
|
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_resultat); |
liberation(s_etat_processus, s_objet_resultat); |
|
|
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
Line 2828 instruction_open(struct_processus *s_eta
|
Line 3007 instruction_open(struct_processus *s_eta
|
return; |
return; |
} |
} |
|
|
if (fclose(descripteur) != 0) |
if (lock.l_type != F_UNLCK) |
{ |
{ |
|
free(nom); |
|
|
|
if (fclose(descripteur) != 0) |
|
{ |
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_systeme = |
|
d_es_erreur_fichier; |
|
return; |
|
} |
|
|
|
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_resultat); |
liberation(s_etat_processus, s_objet_resultat); |
|
|
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_execution = |
d_es_erreur_fichier; |
d_ex_fichier_verrouille; |
return; |
return; |
} |
} |
|
|
if ((descripteur = fopen(nom, "w+")) == NULL) |
if (fclose(descripteur) != 0) |
{ |
{ |
|
free(nom); |
|
|
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_resultat); |
liberation(s_etat_processus, s_objet_resultat); |
|
|
(*s_etat_processus).erreur_execution = |
(*s_etat_processus).erreur_systeme = |
d_ex_erreur_acces_fichier; |
d_es_erreur_fichier; |
return; |
return; |
} |
} |
|
|
|
if (type_acces == 'S') |
|
{ |
|
if ((descripteur = fopen(nom, "w+")) == NULL) |
|
{ |
|
free(nom); |
|
|
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_acces_fichier; |
|
return; |
|
} |
|
} |
|
else |
|
{ |
|
if (sqlite3_open_v2(nom, &sqlite, |
|
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, |
|
NULL) != SQLITE_OK) |
|
{ |
|
free(nom); |
|
|
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_acces_fichier; |
|
return; |
|
} |
|
|
|
// Ouverture du fichier pour pouvoir gérer les |
|
// verrous à la façon des fichiers séquentiels. |
|
|
|
if ((descripteur = fopen(nom, "a+")) == NULL) |
|
{ |
|
free(nom); |
|
|
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_acces_fichier; |
|
return; |
|
} |
|
|
|
if (type_acces == 'D') |
|
{ |
|
if (initialisation_fichier_acces_direct( |
|
s_etat_processus, sqlite, |
|
(format == 'N') ? d_faux : d_vrai) |
|
!= d_absence_erreur) |
|
{ |
|
free(nom); |
|
|
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
return; |
|
} |
|
} |
|
else |
|
{ |
|
if (position_clef == 0) |
|
{ |
|
free(nom); |
|
|
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_parametre_fichier; |
|
return; |
|
} |
|
|
|
if (initialisation_fichier_acces_indexe( |
|
s_etat_processus, sqlite, position_clef, |
|
(format == 'N') ? d_faux : d_vrai) |
|
!= d_absence_erreur) |
|
{ |
|
free(nom); |
|
|
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
return; |
|
} |
|
} |
|
} |
|
|
break; |
break; |
} |
} |
|
|
Line 2857 instruction_open(struct_processus *s_eta
|
Line 3140 instruction_open(struct_processus *s_eta
|
|
|
if (erreur == d_erreur) |
if (erreur == d_erreur) |
{ |
{ |
|
free(nom); |
|
|
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_resultat); |
liberation(s_etat_processus, s_objet_resultat); |
|
|
Line 2867 instruction_open(struct_processus *s_eta
|
Line 3152 instruction_open(struct_processus *s_eta
|
|
|
if (existence == d_faux) |
if (existence == d_faux) |
{ |
{ |
if ((descripteur = fopen(nom, "w+")) == NULL) |
if (type_acces == 'S') |
{ |
{ |
liberation(s_etat_processus, s_objet_argument); |
if ((descripteur = fopen(nom, "w+")) == NULL) |
liberation(s_etat_processus, s_objet_resultat); |
{ |
|
free(nom); |
|
|
(*s_etat_processus).erreur_execution = |
liberation(s_etat_processus, s_objet_argument); |
d_ex_erreur_acces_fichier; |
liberation(s_etat_processus, s_objet_resultat); |
return; |
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_acces_fichier; |
|
return; |
|
} |
|
} |
|
else |
|
{ |
|
if (sqlite3_open_v2(nom, &sqlite, |
|
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, |
|
NULL) != SQLITE_OK) |
|
{ |
|
free(nom); |
|
|
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_acces_fichier; |
|
return; |
|
} |
|
|
|
if ((descripteur = fopen(nom, "a+")) == NULL) |
|
{ |
|
free(nom); |
|
|
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_acces_fichier; |
|
return; |
|
} |
|
|
|
if (type_acces == 'D') |
|
{ |
|
if (initialisation_fichier_acces_direct( |
|
s_etat_processus, sqlite, |
|
(format == 'N') ? d_faux : d_vrai) |
|
!= d_absence_erreur) |
|
{ |
|
free(nom); |
|
|
|
liberation(s_etat_processus, |
|
s_objet_argument); |
|
liberation(s_etat_processus, |
|
s_objet_resultat); |
|
|
|
return; |
|
} |
|
} |
|
else |
|
{ |
|
if (position_clef == 0) |
|
{ |
|
free(nom); |
|
|
|
liberation(s_etat_processus, |
|
s_objet_argument); |
|
liberation(s_etat_processus, |
|
s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_parametre_fichier; |
|
return; |
|
} |
|
|
|
if (initialisation_fichier_acces_indexe( |
|
s_etat_processus, sqlite, position_clef, |
|
(format == 'N') ? d_faux : d_vrai) |
|
!= d_absence_erreur) |
|
{ |
|
free(nom); |
|
|
|
liberation(s_etat_processus, |
|
s_objet_argument); |
|
liberation(s_etat_processus, |
|
s_objet_resultat); |
|
|
|
return; |
|
} |
|
} |
} |
} |
} |
} |
else |
else |
{ |
{ |
if ((descripteur = fopen(nom, "r+")) == NULL) |
if (type_acces == 'S') |
{ |
{ |
liberation(s_etat_processus, s_objet_argument); |
if ((descripteur = fopen(nom, "r+")) == NULL) |
liberation(s_etat_processus, s_objet_resultat); |
{ |
|
free(nom); |
|
|
(*s_etat_processus).erreur_execution = |
liberation(s_etat_processus, s_objet_argument); |
d_ex_erreur_acces_fichier; |
liberation(s_etat_processus, s_objet_resultat); |
return; |
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_acces_fichier; |
|
return; |
|
} |
|
} |
|
else |
|
{ |
|
if (sqlite3_open_v2(nom, &sqlite, |
|
SQLITE_OPEN_READWRITE, |
|
NULL) != SQLITE_OK) |
|
{ |
|
free(nom); |
|
|
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_acces_fichier; |
|
return; |
|
} |
|
|
|
if ((descripteur = fopen(nom, "a+")) == NULL) |
|
{ |
|
free(nom); |
|
|
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_acces_fichier; |
|
return; |
|
} |
} |
} |
} |
} |
|
|
Line 2900 instruction_open(struct_processus *s_eta
|
Line 3300 instruction_open(struct_processus *s_eta
|
|
|
if ((erreur != d_absence_erreur) || (existence != d_faux)) |
if ((erreur != d_absence_erreur) || (existence != d_faux)) |
{ |
{ |
|
free(nom); |
|
|
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_resultat); |
liberation(s_etat_processus, s_objet_resultat); |
|
|
Line 2908 instruction_open(struct_processus *s_eta
|
Line 3310 instruction_open(struct_processus *s_eta
|
return; |
return; |
} |
} |
|
|
if ((descripteur = fopen(nom, "w+")) == NULL) |
if (type_acces == 'S') |
{ |
{ |
liberation(s_etat_processus, s_objet_argument); |
if ((descripteur = fopen(nom, "w+")) == NULL) |
liberation(s_etat_processus, s_objet_resultat); |
{ |
|
free(nom); |
|
|
(*s_etat_processus).erreur_execution = |
liberation(s_etat_processus, s_objet_argument); |
d_ex_erreur_acces_fichier; |
liberation(s_etat_processus, s_objet_resultat); |
return; |
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_acces_fichier; |
|
return; |
|
} |
|
} |
|
else |
|
{ |
|
// Si le fichier existe, on le supprime. |
|
|
|
if (unlink(nom) != 0) |
|
{ |
|
free(nom); |
|
|
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_acces_fichier; |
|
return; |
|
} |
|
|
|
if (sqlite3_open_v2(nom, &sqlite, |
|
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, |
|
NULL) != SQLITE_OK) |
|
{ |
|
free(nom); |
|
|
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_acces_fichier; |
|
return; |
|
} |
|
|
|
if ((descripteur = fopen(nom, "a+")) == NULL) |
|
{ |
|
free(nom); |
|
|
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_acces_fichier; |
|
return; |
|
} |
|
|
|
if (type_acces == 'D') |
|
{ |
|
if (initialisation_fichier_acces_direct( |
|
s_etat_processus, sqlite, |
|
(format == 'N') ? d_faux : d_vrai) |
|
!= d_absence_erreur) |
|
{ |
|
free(nom); |
|
|
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
return; |
|
} |
|
} |
|
else |
|
{ |
|
if (position_clef == 0) |
|
{ |
|
free(nom); |
|
|
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_parametre_fichier; |
|
return; |
|
} |
|
|
|
if (initialisation_fichier_acces_indexe( |
|
s_etat_processus, sqlite, position_clef, |
|
(format == 'N') ? d_faux : d_vrai) |
|
!= d_absence_erreur) |
|
{ |
|
free(nom); |
|
|
|
liberation(s_etat_processus, s_objet_argument); |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
return; |
|
} |
|
} |
} |
} |
|
|
break; |
break; |
Line 2944 instruction_open(struct_processus *s_eta
|
Line 3436 instruction_open(struct_processus *s_eta
|
(*((struct_fichier *) (*s_objet_resultat).objet)).position_clef = |
(*((struct_fichier *) (*s_objet_resultat).objet)).position_clef = |
position_clef; |
position_clef; |
|
|
if (autorisation_liberation_nom == d_vrai) |
|
{ |
|
free(nom); |
|
} |
|
|
|
rewind(descripteur); |
rewind(descripteur); |
|
|
lock.l_type = F_WRLCK; |
lock.l_type = F_WRLCK; |
Line 2963 instruction_open(struct_processus *s_eta
|
Line 3450 instruction_open(struct_processus *s_eta
|
{ |
{ |
liberation(s_etat_processus, s_objet_resultat); |
liberation(s_etat_processus, s_objet_resultat); |
|
|
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
(*s_etat_processus).erreur_systeme = |
|
d_es_erreur_fichier; |
return; |
return; |
} |
} |
|
|
Line 2998 instruction_open(struct_processus *s_eta
|
Line 3486 instruction_open(struct_processus *s_eta
|
|
|
liberation(s_etat_processus, s_objet_resultat); |
liberation(s_etat_processus, s_objet_resultat); |
|
|
(*s_etat_processus).erreur_systeme = d_es_erreur_fichier; |
(*s_etat_processus).erreur_systeme = |
|
d_es_erreur_fichier; |
return; |
return; |
} |
} |
} |
} |
Line 3010 instruction_open(struct_processus *s_eta
|
Line 3499 instruction_open(struct_processus *s_eta
|
|
|
if ((lock.l_type == F_RDLCK) && (protection != 'R')) |
if ((lock.l_type == F_RDLCK) && (protection != 'R')) |
{ |
{ |
|
free(nom); |
|
|
if (fclose(descripteur) != 0) |
if (fclose(descripteur) != 0) |
{ |
{ |
liberation(s_etat_processus, s_objet_resultat); |
liberation(s_etat_processus, s_objet_resultat); |
Line 3027 instruction_open(struct_processus *s_eta
|
Line 3518 instruction_open(struct_processus *s_eta
|
} |
} |
else if ((lock.l_type == F_WRLCK) && (protection != 'W')) |
else if ((lock.l_type == F_WRLCK) && (protection != 'W')) |
{ |
{ |
|
free(nom); |
|
|
if (fclose(descripteur) != 0) |
if (fclose(descripteur) != 0) |
{ |
{ |
liberation(s_etat_processus, s_objet_resultat); |
liberation(s_etat_processus, s_objet_resultat); |
Line 3044 instruction_open(struct_processus *s_eta
|
Line 3537 instruction_open(struct_processus *s_eta
|
} |
} |
else |
else |
{ |
{ |
|
free(nom); |
|
|
|
if (fclose(descripteur) != 0) |
|
{ |
|
liberation(s_etat_processus, s_objet_resultat); |
|
|
|
(*s_etat_processus).erreur_systeme = |
|
d_es_erreur_fichier; |
|
return; |
|
} |
|
|
liberation(s_etat_processus, s_objet_resultat); |
liberation(s_etat_processus, s_objet_resultat); |
|
|
(*s_etat_processus).erreur_execution = |
(*s_etat_processus).erreur_execution = |
Line 3087 instruction_open(struct_processus *s_eta
|
Line 3591 instruction_open(struct_processus *s_eta
|
* Recherche du premier descripteur libre |
* Recherche du premier descripteur libre |
*/ |
*/ |
|
|
if ((chaine_descripteurs = malloc( |
if ((chaine_descripteurs = malloc(sizeof(unsigned char) * |
ds_nombre_maximum_fichiers_ouverts + 1)) == NULL) |
(ds_nombre_maximum_fichiers_ouverts + 1))) == NULL) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
(*s_etat_processus).erreur_systeme = |
d_es_allocation_memoire; |
d_es_allocation_memoire; |
Line 3166 instruction_open(struct_processus *s_eta
|
Line 3670 instruction_open(struct_processus *s_eta
|
= prochain_descripteur; |
= prochain_descripteur; |
(*((struct_descripteur_fichier *) (*l_element_courant).donnee)) |
(*((struct_descripteur_fichier *) (*l_element_courant).donnee)) |
.identifiant = prochain_descripteur; |
.identifiant = prochain_descripteur; |
(*((struct_descripteur_fichier *) (*l_element_courant).donnee)) |
|
.descripteur = descripteur; |
if (type_acces == 'S') |
|
{ |
|
(*((struct_descripteur_fichier *) (*l_element_courant).donnee)) |
|
.type = 'C'; |
|
(*((struct_descripteur_fichier *) (*l_element_courant).donnee)) |
|
.descripteur_c = descripteur; |
|
} |
|
else |
|
{ |
|
(*((struct_descripteur_fichier *) (*l_element_courant).donnee)) |
|
.type = 'S'; |
|
(*((struct_descripteur_fichier *) (*l_element_courant).donnee)) |
|
.descripteur_c = descripteur; |
|
(*((struct_descripteur_fichier *) (*l_element_courant).donnee)) |
|
.descripteur_sqlite = sqlite; |
|
} |
|
|
(*((struct_descripteur_fichier *) (*l_element_courant).donnee)) |
(*((struct_descripteur_fichier *) (*l_element_courant).donnee)) |
.pid = getpid(); |
.pid = getpid(); |
(*((struct_descripteur_fichier *) (*l_element_courant).donnee)) |
(*((struct_descripteur_fichier *) (*l_element_courant).donnee)) |
Line 3175 instruction_open(struct_processus *s_eta
|
Line 3695 instruction_open(struct_processus *s_eta
|
(*((struct_descripteur_fichier *) (*l_element_courant).donnee)) |
(*((struct_descripteur_fichier *) (*l_element_courant).donnee)) |
.effacement = (type_ouverture == 'S') ? 'Y' : 'N'; |
.effacement = (type_ouverture == 'S') ? 'Y' : 'N'; |
|
|
if (((*((struct_descripteur_fichier *) (*l_element_courant) |
(*((struct_descripteur_fichier *) (*l_element_courant) |
.donnee)).nom = malloc((strlen((*((struct_fichier *) |
.donnee)).nom = nom; |
(*s_objet_resultat).objet)).nom) + 1) * |
|
sizeof(unsigned char))) == NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
|
return; |
|
} |
|
|
|
strcpy((*((struct_descripteur_fichier *) (*l_element_courant) |
|
.donnee)).nom, (*((struct_fichier *) (*s_objet_resultat) |
|
.objet)).nom); |
|
|
|
} |
} |
else if (type_arguments == 'S') |
else if (type_arguments == 'S') |
{ |
{ |
Line 3605 instruction_open(struct_processus *s_eta
|
Line 4114 instruction_open(struct_processus *s_eta
|
strcpy((*((struct_socket *) (*s_objet_resultat).objet)). |
strcpy((*((struct_socket *) (*s_objet_resultat).objet)). |
type, "ROBUST DATAGRAM"); |
type, "ROBUST DATAGRAM"); |
break; |
break; |
|
|
|
default : |
|
BUG(1, printf("type_socket=%c\n", type_socket)); |
|
break; |
} |
} |
|
|
if ((protection != 'N') && ((type_socket != 'S') && |
if ((protection != 'N') && ((type_socket != 'S') && |
Line 3634 instruction_open(struct_processus *s_eta
|
Line 4147 instruction_open(struct_processus *s_eta
|
else |
else |
{ |
{ |
if (((*((struct_socket *) (*s_objet_resultat).objet)).adresse = |
if (((*((struct_socket *) (*s_objet_resultat).objet)).adresse = |
malloc((strlen(nom) + 1) * sizeof(unsigned char))) |
transliteration(s_etat_processus, nom, |
== NULL) |
d_locale, "UTF-8")) == NULL) |
{ |
{ |
(*s_etat_processus).erreur_systeme = |
liberation(s_etat_processus, s_objet_argument); |
d_es_allocation_memoire; |
liberation(s_etat_processus, s_objet_resultat); |
return; |
return; |
} |
} |
|
|
strcpy((*((struct_socket *) (*s_objet_resultat).objet)).adresse, |
|
nom); |
|
} |
} |
|
|
if (((*((struct_socket *) (*s_objet_resultat).objet)) |
if (((*((struct_socket *) (*s_objet_resultat).objet)) |
Line 3705 instruction_open(struct_processus *s_eta
|
Line 4215 instruction_open(struct_processus *s_eta
|
pointeur++; |
pointeur++; |
} |
} |
|
|
strncpy(socket_unix.sun_path, pointeur, 108); |
strncpy(socket_unix.sun_path, pointeur, UNIX_PATH_MAX); |
socket_unix.sun_path[108 - 1] = d_code_fin_chaine; |
socket_unix.sun_path[UNIX_PATH_MAX - 1] = d_code_fin_chaine; |
|
|
if (options_socket() == d_erreur) |
if (options_socket() == d_erreur) |
{ |
{ |
Line 3861 instruction_open(struct_processus *s_eta
|
Line 4371 instruction_open(struct_processus *s_eta
|
} |
} |
else |
else |
{ // Accès en IPv6 |
{ // Accès en IPv6 |
|
# ifdef IPV6 |
resolution_courante = resolution; |
resolution_courante = resolution; |
|
|
while(resolution_courante != NULL) |
while(resolution_courante != NULL) |
Line 3958 instruction_open(struct_processus *s_eta
|
Line 4469 instruction_open(struct_processus *s_eta
|
(*resolution_courante).ai_addr)) |
(*resolution_courante).ai_addr)) |
.sin6_addr.s6_addr[i]); |
.sin6_addr.s6_addr[i]); |
} |
} |
|
# else |
|
if ((*s_etat_processus).langue == 'F') |
|
{ |
|
printf("+++Attention : Support du protocole" |
|
" IPv6 indisponible\n"); |
|
} |
|
else |
|
{ |
|
printf("+++Warning : IPv6 support " |
|
"unavailable\n"); |
|
} |
|
# endif |
} |
} |
|
|
freeaddrinfo(resolution); |
freeaddrinfo(resolution); |
Line 4045 instruction_open(struct_processus *s_eta
|
Line 4568 instruction_open(struct_processus *s_eta
|
} |
} |
else |
else |
{ // Accès en IPv6 |
{ // Accès en IPv6 |
|
# ifdef IPV6 |
if (((*((struct_socket *) (*s_objet_resultat) |
if (((*((struct_socket *) (*s_objet_resultat) |
.objet)).adresse = malloc(55 * |
.objet)).adresse = malloc(55 * |
sizeof(unsigned char))) == NULL) |
sizeof(unsigned char))) == NULL) |
Line 4115 instruction_open(struct_processus *s_eta
|
Line 4639 instruction_open(struct_processus *s_eta
|
d_ex_erreur_acces_fichier; |
d_ex_erreur_acces_fichier; |
return; |
return; |
} |
} |
|
# else |
|
if ((*s_etat_processus).langue == 'F') |
|
{ |
|
printf("+++Attention : Support du protocole" |
|
" IPv6 indisponible\n"); |
|
} |
|
else |
|
{ |
|
printf("+++Warning : IPv6 support " |
|
"unavailable\n"); |
|
} |
|
# endif |
} |
} |
} |
} |
|
|
Line 4218 instruction_open(struct_processus *s_eta
|
Line 4754 instruction_open(struct_processus *s_eta
|
|
|
socket_unix.sun_family = AF_UNIX; |
socket_unix.sun_family = AF_UNIX; |
strncpy(socket_unix.sun_path, (*((struct_socket *) |
strncpy(socket_unix.sun_path, (*((struct_socket *) |
(*s_objet_resultat).objet)).adresse, 108); |
(*s_objet_resultat).objet)).adresse, UNIX_PATH_MAX); |
socket_unix.sun_path[108 - 1] = d_code_fin_chaine; |
socket_unix.sun_path[UNIX_PATH_MAX - 1] = d_code_fin_chaine; |
|
|
if ((type_socket == 'S') || (type_socket == 'Q')) |
if ((type_socket == 'S') || (type_socket == 'Q')) |
{ |
{ |
Line 4373 instruction_open(struct_processus *s_eta
|
Line 4909 instruction_open(struct_processus *s_eta
|
} |
} |
else |
else |
{ // Accès en IPv6 |
{ // Accès en IPv6 |
|
# ifdef IPV6 |
resolution_courante = resolution; |
resolution_courante = resolution; |
|
|
while(resolution_courante != NULL) |
while(resolution_courante != NULL) |
Line 4472 instruction_open(struct_processus *s_eta
|
Line 5009 instruction_open(struct_processus *s_eta
|
(*resolution_courante).ai_addr)) |
(*resolution_courante).ai_addr)) |
.sin6_addr.s6_addr[i]); |
.sin6_addr.s6_addr[i]); |
} |
} |
|
# else |
|
if ((*s_etat_processus).langue == 'F') |
|
{ |
|
printf("+++Attention : Support du protocole" |
|
" IPv6 indisponible\n"); |
|
} |
|
else |
|
{ |
|
printf("+++Warning : IPv6 support " |
|
"unavailable\n"); |
|
} |
|
# endif |
} |
} |
|
|
freeaddrinfo(resolution); |
freeaddrinfo(resolution); |
Line 4580 instruction_open(struct_processus *s_eta
|
Line 5129 instruction_open(struct_processus *s_eta
|
} |
} |
else if (strcmp(protocole, "IPV6") == 0) |
else if (strcmp(protocole, "IPV6") == 0) |
{ // Accès en IPv6 |
{ // Accès en IPv6 |
|
# ifdef IPV6 |
if (type_adresse == '6') |
if (type_adresse == '6') |
{ |
{ |
if (((*((struct_socket *) (*s_objet_resultat) |
if (((*((struct_socket *) (*s_objet_resultat) |
Line 4671 instruction_open(struct_processus *s_eta
|
Line 5221 instruction_open(struct_processus *s_eta
|
(*((struct_socket *) (*s_objet_resultat).objet)) |
(*((struct_socket *) (*s_objet_resultat).objet)) |
.socket_en_ecoute = 'N'; |
.socket_en_ecoute = 'N'; |
} |
} |
|
# 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 |
{ // Socket UNIX |
{ // Socket UNIX |
Line 4787 instruction_open(struct_processus *s_eta
|
Line 5349 instruction_open(struct_processus *s_eta
|
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
return; |
return; |
} |
} |
|
|
|
liberation(s_etat_processus, s_objet_argument); |
} |
} |
else |
else |
{ |
{ |