version 1.9, 2010/04/07 13:45:07
|
version 1.44, 2012/01/17 14:44:08
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.0.14 |
RPL/2 (R) version 4.1.6 |
Copyright (C) 1989-2010 Dr. BERTRAND Joël |
Copyright (C) 1989-2012 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 934 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 1017 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 1187 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 1939 instruction_open(struct_processus *s_eta
|
Line 1972 instruction_open(struct_processus *s_eta
|
protocole_socket = (unsigned char *) |
protocole_socket = (unsigned char *) |
(*(*l_element_courant_sous_objet) |
(*(*l_element_courant_sous_objet) |
.donnee).objet; |
.donnee).objet; |
|
|
|
for(i = 0; i < strlen(protocole_socket); i++) |
|
{ |
|
if ((protocole_socket[i] >= 'a') && |
|
(protocole_socket[i] <= 'z')) |
|
{ |
|
protocole_socket[i] -= 'a' - 'A'; |
|
} |
|
} |
|
|
} |
} |
else |
else |
{ |
{ |
Line 2779 instruction_open(struct_processus *s_eta
|
Line 2822 instruction_open(struct_processus *s_eta
|
return; |
return; |
} |
} |
|
|
|
sqlite = NULL; |
|
|
if (sqlite3_open_v2(nom, &sqlite, |
if (sqlite3_open_v2(nom, &sqlite, |
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, |
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, |
NULL) != SQLITE_OK) |
NULL) != SQLITE_OK) |
{ |
{ |
|
if (sqlite != NULL) |
|
{ |
|
sqlite3_close(sqlite); |
|
} |
|
|
free(nom); |
free(nom); |
|
|
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_argument); |
Line 2885 instruction_open(struct_processus *s_eta
|
Line 2935 instruction_open(struct_processus *s_eta
|
} |
} |
else |
else |
{ |
{ |
|
sqlite = NULL; |
|
|
if (sqlite3_open_v2(nom, &sqlite, |
if (sqlite3_open_v2(nom, &sqlite, |
SQLITE_OPEN_READWRITE, |
SQLITE_OPEN_READWRITE, |
NULL) != SQLITE_OK) |
NULL) != SQLITE_OK) |
{ |
{ |
|
if (sqlite != NULL) |
|
{ |
|
sqlite3_close(sqlite); |
|
} |
|
|
free(nom); |
free(nom); |
|
|
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_argument); |
Line 3024 instruction_open(struct_processus *s_eta
|
Line 3081 instruction_open(struct_processus *s_eta
|
} |
} |
else |
else |
{ |
{ |
|
sqlite = NULL; |
|
|
if (sqlite3_open_v2(nom, &sqlite, |
if (sqlite3_open_v2(nom, &sqlite, |
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, |
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, |
NULL) != SQLITE_OK) |
NULL) != SQLITE_OK) |
{ |
{ |
|
if (sqlite != NULL) |
|
{ |
|
sqlite3_close(sqlite); |
|
} |
|
|
free(nom); |
free(nom); |
|
|
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_argument); |
Line 3135 instruction_open(struct_processus *s_eta
|
Line 3199 instruction_open(struct_processus *s_eta
|
} |
} |
else |
else |
{ |
{ |
|
sqlite = NULL; |
|
|
if (sqlite3_open_v2(nom, &sqlite, |
if (sqlite3_open_v2(nom, &sqlite, |
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, |
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, |
NULL) != SQLITE_OK) |
NULL) != SQLITE_OK) |
{ |
{ |
|
if (sqlite != NULL) |
|
{ |
|
sqlite3_close(sqlite); |
|
} |
|
|
free(nom); |
free(nom); |
|
|
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_argument); |
Line 3229 instruction_open(struct_processus *s_eta
|
Line 3300 instruction_open(struct_processus *s_eta
|
} |
} |
else |
else |
{ |
{ |
|
sqlite = NULL; |
|
|
if (sqlite3_open_v2(nom, &sqlite, |
if (sqlite3_open_v2(nom, &sqlite, |
SQLITE_OPEN_READWRITE, |
SQLITE_OPEN_READWRITE, |
NULL) != SQLITE_OK) |
NULL) != SQLITE_OK) |
{ |
{ |
|
if (sqlite != NULL) |
|
{ |
|
sqlite3_close(sqlite); |
|
} |
|
|
free(nom); |
free(nom); |
|
|
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_argument); |
Line 3307 instruction_open(struct_processus *s_eta
|
Line 3385 instruction_open(struct_processus *s_eta
|
return; |
return; |
} |
} |
|
|
|
sqlite = NULL; |
|
|
if (sqlite3_open_v2(nom, &sqlite, |
if (sqlite3_open_v2(nom, &sqlite, |
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, |
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, |
NULL) != SQLITE_OK) |
NULL) != SQLITE_OK) |
{ |
{ |
|
if (sqlite != NULL) |
|
{ |
|
sqlite3_close(sqlite); |
|
} |
|
|
free(nom); |
free(nom); |
|
|
liberation(s_etat_processus, s_objet_argument); |
liberation(s_etat_processus, s_objet_argument); |
Line 3973 instruction_open(struct_processus *s_eta
|
Line 4058 instruction_open(struct_processus *s_eta
|
return; |
return; |
} |
} |
|
|
|
if ((type_adresse == ' ') && (type_domaine == 'L')) |
|
{ |
|
if (strcmp(protocole, "IPV4") == 0) |
|
{ |
|
for(i = 0; i < 4; adresse[i++] = 0); |
|
type_adresse = '4'; |
|
} |
|
else if (strcmp(protocole, "IPV6") == 0) |
|
{ |
|
for(i = 0; i < 16; adresse[i++] = 0); |
|
type_adresse = '6'; |
|
} |
|
else |
|
{ |
|
liberation(s_etat_processus, s_objet_argument); |
|
|
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_parametre_fichier; |
|
return; |
|
} |
|
} |
|
|
if (((strcmp(protocole, "IPV4") == 0) && (type_adresse == '6')) || |
if (((strcmp(protocole, "IPV4") == 0) && (type_adresse == '6')) || |
((strcmp(protocole, "IPV6") == 0) && (type_adresse == '4'))) |
((strcmp(protocole, "IPV6") == 0) && (type_adresse == '4'))) |
{ |
{ |
Line 4004 instruction_open(struct_processus *s_eta
|
Line 4111 instruction_open(struct_processus *s_eta
|
} |
} |
else |
else |
{ |
{ |
for(i = 0; i < strlen(protocole_socket); i++) |
if (strcmp(protocole_socket, "IPV4") == 0) |
{ |
|
if ((protocole_socket[i] >= 'A') && |
|
(protocole_socket[i] <= 'Z')) |
|
{ |
|
protocole_socket[i] += 'a' - 'A'; |
|
} |
|
} |
|
|
|
if (strcmp(protocole_socket, "ipv4") == 0) |
|
{ |
{ |
protocole_socket[2] = d_code_fin_chaine; |
protocole_socket[2] = d_code_fin_chaine; |
} |
} |
Line 4081 instruction_open(struct_processus *s_eta
|
Line 4179 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 4178 instruction_open(struct_processus *s_eta
|
Line 4280 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 4334 instruction_open(struct_processus *s_eta
|
Line 4436 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 4431 instruction_open(struct_processus *s_eta
|
Line 4534 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 4518 instruction_open(struct_processus *s_eta
|
Line 4633 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 4588 instruction_open(struct_processus *s_eta
|
Line 4704 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 4691 instruction_open(struct_processus *s_eta
|
Line 4819 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 4846 instruction_open(struct_processus *s_eta
|
Line 4974 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 4945 instruction_open(struct_processus *s_eta
|
Line 5074 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 5053 instruction_open(struct_processus *s_eta
|
Line 5194 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 5144 instruction_open(struct_processus *s_eta
|
Line 5286 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 5260 instruction_open(struct_processus *s_eta
|
Line 5414 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 |
{ |
{ |