--- rpl/src/instructions_w1.c 2013/03/01 10:24:49 1.74 +++ rpl/src/instructions_w1.c 2013/03/20 17:11:45 1.78 @@ -390,13 +390,13 @@ instruction_write(struct_processus *s_et integer8 clef; integer8 compteur; integer8 id; + integer8 longueur_effective; integer8 ordre; logical1 format_degenere; logical1 mise_a_jour; long longueur; - long longueur_effective; long recursivite; sqlite3_stmt *ppStmt; @@ -592,7 +592,7 @@ instruction_write(struct_processus *s_et if ((chaine = formateur_fichier(s_etat_processus, s_objet_argument_2, (*((struct_fichier *) (*s_objet_argument_1).objet)).format, 0, 0, ' ', 'F', - &longueur_effective, &recursivite)) == NULL) + &longueur_effective, &recursivite, d_vrai)) == NULL) { liberation(s_etat_processus, s_objet_argument_2); liberation(s_etat_processus, s_objet_argument_1); @@ -674,7 +674,8 @@ instruction_write(struct_processus *s_et if ((chaine = formateur_fichier(s_etat_processus, s_objet_argument_3, (*((struct_fichier *) (*s_objet_argument_1).objet)).format, 0, 0, ' ', - 'F', &longueur_effective, &recursivite)) == NULL) + 'F', &longueur_effective, &recursivite, d_vrai)) + == NULL) { liberation(s_etat_processus, s_objet_argument_3); liberation(s_etat_processus, s_objet_argument_2); @@ -897,7 +898,8 @@ instruction_write(struct_processus *s_et if ((chaine = formateur_fichier(s_etat_processus, s_element, s_format, 0, 0, ' ', - 'F', &longueur_effective, &recursivite)) == NULL) + 'F', &longueur_effective, &recursivite, d_vrai)) + == NULL) { liberation(s_etat_processus, s_element); liberation(s_etat_processus, s_format); @@ -1211,7 +1213,8 @@ instruction_write(struct_processus *s_et if ((chaine = formateur_fichier(s_etat_processus, s_element, s_format, 0, 0, ' ', - 'F', &longueur_effective, &recursivite)) == NULL) + 'F', &longueur_effective, &recursivite, d_vrai)) + == NULL) { free(clef_utf8); @@ -1304,20 +1307,30 @@ instruction_write(struct_processus *s_et * Fichiers non formatés */ - if ((chaine = formateur_fichier(s_etat_processus, - s_objet_argument_2, (*((struct_fichier *) - (*s_objet_argument_1).objet)).format, 0, 0, ' ', 'U', - &longueur_effective, &recursivite)) == NULL) - { - liberation(s_etat_processus, s_objet_argument_2); - liberation(s_etat_processus, s_objet_argument_1); - - return; - } - if ((*((struct_fichier *) (*s_objet_argument_1).objet)).acces == 'S') { + if ((*s_objet_argument_2).type != LST) + { + liberation(s_etat_processus, s_objet_argument_2); + liberation(s_etat_processus, s_objet_argument_1); + + (*s_etat_processus).erreur_execution = + d_ex_erreur_type_argument; + return; + } + + if ((chaine = formateur_fichier(s_etat_processus, + s_objet_argument_2, (*((struct_fichier *) + (*s_objet_argument_1).objet)).format, 0, 0, ' ', 'U', + &longueur_effective, &recursivite, d_vrai)) == NULL) + { + liberation(s_etat_processus, s_objet_argument_2); + liberation(s_etat_processus, s_objet_argument_1); + + return; + } + BUG(((*descripteur).type != 'C'), uprintf("Bad filetype !\n")); if (fseek((*descripteur).descripteur_c, (long) 0, SEEK_END) @@ -1341,10 +1354,67 @@ instruction_write(struct_processus *s_et else if ((*((struct_fichier *) (*s_objet_argument_1).objet)).acces == 'D') { + if ((*s_objet_argument_2).type != INT) + { + liberation(s_etat_processus, s_objet_argument_2); + liberation(s_etat_processus, s_objet_argument_1); + + (*s_etat_processus).erreur_execution = + d_ex_erreur_type_argument; + return; + } + + if (depilement(s_etat_processus, &((*s_etat_processus) + .l_base_pile), &s_objet_argument_3) == d_erreur) + { + (*s_etat_processus).erreur_execution = d_ex_manque_argument; + return; + } + + if ((*s_objet_argument_3).type != LST) + { + liberation(s_etat_processus, s_objet_argument_3); + liberation(s_etat_processus, s_objet_argument_2); + liberation(s_etat_processus, s_objet_argument_1); + + (*s_etat_processus).erreur_execution = + d_ex_erreur_type_argument; + return; + } + + if ((chaine = formateur_fichier(s_etat_processus, + s_objet_argument_2, (*((struct_fichier *) + (*s_objet_argument_1).objet)).format, 0, 0, ' ', 'U', + &longueur_effective, &recursivite, d_faux)) == NULL) + { + liberation(s_etat_processus, s_objet_argument_2); + liberation(s_etat_processus, s_objet_argument_1); + + return; + } } - else + else // Fichiers indexés { - /* Fichiers indexés : panique totale ! */ + if ((*s_objet_argument_2).type != LST) + { + liberation(s_etat_processus, s_objet_argument_2); + liberation(s_etat_processus, s_objet_argument_1); + + (*s_etat_processus).erreur_execution = + d_ex_erreur_type_argument; + return; + } + + if ((chaine = formateur_fichier(s_etat_processus, + s_objet_argument_2, (*((struct_fichier *) + (*s_objet_argument_1).objet)).format, 0, 0, ' ', 'U', + &longueur_effective, &recursivite, d_faux)) == NULL) + { + liberation(s_etat_processus, s_objet_argument_2); + liberation(s_etat_processus, s_objet_argument_1); + + return; + } } free(chaine); @@ -1560,7 +1630,7 @@ instruction_write(struct_processus *s_et if ((chaine = formateur_fichier(s_etat_processus, s_objet_argument_2, (*((struct_socket *) (*s_objet_argument_1).objet)).format, 0, 0, ' ', 'F', - &longueur_effective, &recursivite)) == NULL) + &longueur_effective, &recursivite, d_faux)) == NULL) { liberation(s_etat_processus, s_objet_argument_2); liberation(s_etat_processus, s_objet_argument_1); @@ -1575,7 +1645,16 @@ instruction_write(struct_processus *s_et * Sockets non formatées */ - chaine = NULL; + if ((chaine = formateur_fichier(s_etat_processus, + s_objet_argument_2, (*((struct_socket *) + (*s_objet_argument_1).objet)).format, 0, 0, ' ', 'U', + &longueur_effective, &recursivite, d_faux)) == NULL) + { + liberation(s_etat_processus, s_objet_argument_2); + liberation(s_etat_processus, s_objet_argument_1); + + return; + } } else {