--- rpl/src/instructions_o1.c 2010/03/06 18:29:07 1.6 +++ rpl/src/instructions_o1.c 2011/06/20 17:54:18 1.30 @@ -1,7 +1,7 @@ /* ================================================================================ - RPL/2 (R) version 4.0.12 - Copyright (C) 1989-2010 Dr. BERTRAND Joël + RPL/2 (R) version 4.1.0.prerelease.1 + Copyright (C) 1989-2011 Dr. BERTRAND Joël This file is part of RPL/2. @@ -20,7 +20,7 @@ */ -#include "rpl.conv.h" +#include "rpl-conv.h" /* @@ -897,6 +897,8 @@ instruction_open(struct_processus *s_eta * Format : * FORMATTED : fichier texte ; * UNFORMATTED : fichier binaire. + * FLOW : chaîne de caractères sans format (en tant qu'objet + * binaire comme "\x00avz\xFD") */ file *descripteur; @@ -934,7 +936,9 @@ instruction_open(struct_processus *s_eta struct sockaddr_un socket_unix; struct sockaddr_in socket_ipv4; +# ifdef IPV6 struct sockaddr_in6 socket_ipv6; +# endif struct_objet *s_objet_argument; struct_objet *s_objet_resultat; @@ -1017,6 +1021,7 @@ instruction_open(struct_processus *s_eta "\"file name\" } \"protection\" } OPEN\n"); printf(" { \"sockettype\" { \"name\" \"local name\" } } OPEN\n"); printf(" { \"sockettype\" \"socketdomain\" \"protection\" } OPEN\n"); + printf(" \"/semaphore\" OPEN\n"); printf(" File type : NEW/OLD/REPLACE/UNKNOWN/SCRATCH\n"); printf(" File access : SEQUENTIAL/DIRECT/KEYED\n"); @@ -1187,6 +1192,34 @@ instruction_open(struct_processus *s_eta 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) { if (type_ouverture != ' ') @@ -2649,7 +2682,9 @@ instruction_open(struct_processus *s_eta } 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); @@ -2820,8 +2855,20 @@ instruction_open(struct_processus *s_eta } 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, + s_etat_processus, sqlite, position_clef, (format == 'N') ? d_faux : d_vrai) != d_absence_erreur) { @@ -3056,8 +3103,20 @@ instruction_open(struct_processus *s_eta } 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, + s_etat_processus, sqlite, position_clef, (format == 'N') ? d_faux : d_vrai) != d_absence_erreur) { @@ -3154,8 +3213,22 @@ instruction_open(struct_processus *s_eta } 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, + s_etat_processus, sqlite, position_clef, (format == 'N') ? d_faux : d_vrai) != d_absence_erreur) { @@ -3309,9 +3382,21 @@ instruction_open(struct_processus *s_eta } } 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, + s_etat_processus, sqlite, position_clef, (format == 'N') ? d_faux : d_vrai) != d_absence_erreur) { @@ -4029,6 +4114,10 @@ instruction_open(struct_processus *s_eta strcpy((*((struct_socket *) (*s_objet_resultat).objet)). type, "ROBUST DATAGRAM"); break; + + default : + BUG(1, printf("type_socket=%c\n", type_socket)); + break; } if ((protection != 'N') && ((type_socket != 'S') && @@ -4126,8 +4215,8 @@ instruction_open(struct_processus *s_eta pointeur++; } - strncpy(socket_unix.sun_path, pointeur, 108); - socket_unix.sun_path[108 - 1] = d_code_fin_chaine; + strncpy(socket_unix.sun_path, pointeur, UNIX_PATH_MAX); + socket_unix.sun_path[UNIX_PATH_MAX - 1] = d_code_fin_chaine; if (options_socket() == d_erreur) { @@ -4282,6 +4371,7 @@ instruction_open(struct_processus *s_eta } else { // Accès en IPv6 +# ifdef IPV6 resolution_courante = resolution; while(resolution_courante != NULL) @@ -4379,6 +4469,18 @@ instruction_open(struct_processus *s_eta (*resolution_courante).ai_addr)) .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); @@ -4466,6 +4568,7 @@ instruction_open(struct_processus *s_eta } else { // Accès en IPv6 +# ifdef IPV6 if (((*((struct_socket *) (*s_objet_resultat) .objet)).adresse = malloc(55 * sizeof(unsigned char))) == NULL) @@ -4536,6 +4639,18 @@ instruction_open(struct_processus *s_eta d_ex_erreur_acces_fichier; return; } +# else + if ((*s_etat_processus).langue == 'F') + { + printf("+++Attention : Support du protocole" + " IPv6 indisponible\n"); + } + else + { + printf("+++Warning : IPv6 support " + "unavailable\n"); + } +# endif } } @@ -4639,8 +4754,8 @@ instruction_open(struct_processus *s_eta socket_unix.sun_family = AF_UNIX; strncpy(socket_unix.sun_path, (*((struct_socket *) - (*s_objet_resultat).objet)).adresse, 108); - socket_unix.sun_path[108 - 1] = d_code_fin_chaine; + (*s_objet_resultat).objet)).adresse, UNIX_PATH_MAX); + socket_unix.sun_path[UNIX_PATH_MAX - 1] = d_code_fin_chaine; if ((type_socket == 'S') || (type_socket == 'Q')) { @@ -4794,6 +4909,7 @@ instruction_open(struct_processus *s_eta } else { // Accès en IPv6 +# ifdef IPV6 resolution_courante = resolution; while(resolution_courante != NULL) @@ -4893,6 +5009,18 @@ instruction_open(struct_processus *s_eta (*resolution_courante).ai_addr)) .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); @@ -5001,6 +5129,7 @@ instruction_open(struct_processus *s_eta } else if (strcmp(protocole, "IPV6") == 0) { // Accès en IPv6 +# ifdef IPV6 if (type_adresse == '6') { if (((*((struct_socket *) (*s_objet_resultat) @@ -5092,6 +5221,18 @@ instruction_open(struct_processus *s_eta (*((struct_socket *) (*s_objet_resultat).objet)) .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 { // Socket UNIX @@ -5208,6 +5349,8 @@ instruction_open(struct_processus *s_eta (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; return; } + + liberation(s_etat_processus, s_objet_argument); } else {