version 1.59, 2013/03/19 12:27:56
|
version 1.60, 2013/03/19 12:46:32
|
Line 3366 formateur_fichier(struct_processus *s_et
|
Line 3366 formateur_fichier(struct_processus *s_et
|
|
|
strcpy(chaine + 1, (*((struct_fonction *) (*s_objet).objet)) |
strcpy(chaine + 1, (*((struct_fonction *) (*s_objet).objet)) |
.nom_fonction); |
.nom_fonction); |
|
(*longueur_effective) = 1 + longueur_fonction + 8; |
} |
} |
else if (longueur_fonction < (1LL << 8)) |
else if (longueur_fonction < (1LL << 8)) |
{ |
{ |
Line 3382 formateur_fichier(struct_processus *s_et
|
Line 3383 formateur_fichier(struct_processus *s_et
|
|
|
strcpy(chaine + 2, (*((struct_fonction *) (*s_objet).objet)) |
strcpy(chaine + 2, (*((struct_fonction *) (*s_objet).objet)) |
.nom_fonction); |
.nom_fonction); |
|
(*longueur_effective) = 2 + longueur_fonction + 8; |
} |
} |
else if (longueur_fonction < (1LL << 16)) |
else if (longueur_fonction < (1LL << 16)) |
{ |
{ |
Line 3399 formateur_fichier(struct_processus *s_et
|
Line 3401 formateur_fichier(struct_processus *s_et
|
|
|
strcpy(chaine + 3, (*((struct_fonction *) (*s_objet).objet)) |
strcpy(chaine + 3, (*((struct_fonction *) (*s_objet).objet)) |
.nom_fonction); |
.nom_fonction); |
|
(*longueur_effective) = 3 + longueur_fonction + 9; |
} |
} |
else if (longueur_fonction < (1LL << 32)) |
else if (longueur_fonction < (1LL << 32)) |
{ |
{ |
Line 3418 formateur_fichier(struct_processus *s_et
|
Line 3421 formateur_fichier(struct_processus *s_et
|
|
|
strcpy(chaine + 5, (*((struct_fonction *) (*s_objet).objet)) |
strcpy(chaine + 5, (*((struct_fonction *) (*s_objet).objet)) |
.nom_fonction); |
.nom_fonction); |
|
(*longueur_effective) = 5 + longueur_fonction + 8; |
} |
} |
else |
else |
{ |
{ |
Line 3441 formateur_fichier(struct_processus *s_et
|
Line 3445 formateur_fichier(struct_processus *s_et
|
|
|
strcpy(chaine + 9, (*((struct_fonction *) (*s_objet).objet)) |
strcpy(chaine + 9, (*((struct_fonction *) (*s_objet).objet)) |
.nom_fonction); |
.nom_fonction); |
|
(*longueur_effective) = 9 + longueur_fonction + 8; |
} |
} |
|
|
for(i = 1; i <= 8; i++) |
for(i = 1; i <= 8; i++) |
{ |
{ |
chaine[longueur_fonction + i] = (unsigned char) |
chaine[(*longueur_effective) - i] = (unsigned char) |
(((*((struct_fonction *) (*s_objet).objet)) |
(((*((struct_fonction *) (*s_objet).objet)) |
.nombre_arguments >> ((8 - i) * 8)) & 0xFF); |
.nombre_arguments >> ((8 - i) * 8)) & 0xFF); |
} |
} |
|
|
(*longueur_effective) = longueur_fonction + 9; |
|
} |
} |
else if (((*s_objet).type == LST) || ((*s_objet).type == ALG) |
else if (((*s_objet).type == LST) || ((*s_objet).type == ALG) |
|| ((*s_objet).type == RPN)) |
|| ((*s_objet).type == RPN)) |
Line 3863 formateur_fichier(struct_processus *s_et
|
Line 3866 formateur_fichier(struct_processus *s_et
|
/* |
/* |
-------------------------------------------------------------------------------- |
-------------------------------------------------------------------------------- |
Nom |
Nom |
|
Poids fort 0101 |
-------------------------------------------------------------------------------- |
-------------------------------------------------------------------------------- |
*/ |
*/ |
|
if (format_sortie != 'N') |
|
{ |
|
(*s_etat_processus).erreur_execution = |
|
d_ex_erreur_format_fichier; |
|
return(NULL); |
|
} |
|
|
|
longueur_fonction = strlen((*((struct_nom *) (*s_objet).objet)) |
|
.nom); |
|
|
|
if (longueur_fonction < (1LL << 3)) |
|
{ |
|
if ((chaine = malloc((1 + longueur_fonction + 1) |
|
* sizeof(unsigned char)))== NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return(NULL); |
|
} |
|
|
|
chaine[0] = 0x50 | (longueur_fonction & 0x7); |
|
|
|
strcpy(chaine + 1, (*((struct_nom *) (*s_objet).objet)).nom); |
|
(*longueur_effective) = longueur_fonction + 2; |
|
} |
|
else if (longueur_fonction < (1LL << 8)) |
|
{ |
|
if ((chaine = malloc((2 + longueur_fonction + 1) |
|
* sizeof(unsigned char)))== NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return(NULL); |
|
} |
|
|
|
chaine[0] = 0x50 | 0x08; |
|
chaine[1] = (unsigned char) (longueur_fonction & 0xFF); |
|
|
|
strcpy(chaine + 2, (*((struct_nom *) (*s_objet).objet)).nom); |
|
(*longueur_effective) = longueur_fonction + 3; |
|
} |
|
else if (longueur_fonction < (1LL << 16)) |
|
{ |
|
if ((chaine = malloc((3 + longueur_fonction + 1) |
|
* sizeof(unsigned char)))== NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return(NULL); |
|
} |
|
|
|
chaine[0] = 0x50 | 0x09; |
|
chaine[1] = (unsigned char) ((longueur_fonction >> 8) & 0xFF); |
|
chaine[2] = (unsigned char) (longueur_fonction & 0xFF); |
|
|
|
strcpy(chaine + 3, (*((struct_nom *) (*s_objet).objet)).nom); |
|
(*longueur_effective) = longueur_fonction + 4; |
|
} |
|
else if (longueur_fonction < (1LL << 32)) |
|
{ |
|
if ((chaine = malloc((5 + longueur_fonction + 1) |
|
* sizeof(unsigned char)))== NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return(NULL); |
|
} |
|
|
|
chaine[0] = 0xE0 | 0x0A; |
|
chaine[1] = (unsigned char) ((longueur_fonction >> 24) & 0xFF); |
|
chaine[2] = (unsigned char) ((longueur_fonction >> 16) & 0xFF); |
|
chaine[3] = (unsigned char) ((longueur_fonction >> 8) & 0xFF); |
|
chaine[4] = (unsigned char) (longueur_fonction & 0xFF); |
|
|
|
strcpy(chaine + 5, (*((struct_nom *) (*s_objet).objet)).nom); |
|
(*longueur_effective) = longueur_fonction + 6; |
|
} |
|
else |
|
{ |
|
if ((chaine = malloc((9 + longueur_fonction + 1) |
|
* sizeof(unsigned char)))== NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return(NULL); |
|
} |
|
|
|
chaine[0] = 0xE0 | 0x0B; |
|
chaine[1] = (unsigned char) ((longueur_fonction >> 56) & 0xFF); |
|
chaine[2] = (unsigned char) ((longueur_fonction >> 48) & 0xFF); |
|
chaine[3] = (unsigned char) ((longueur_fonction >> 40) & 0xFF); |
|
chaine[4] = (unsigned char) ((longueur_fonction >> 32) & 0xFF); |
|
chaine[5] = (unsigned char) ((longueur_fonction >> 24) & 0xFF); |
|
chaine[6] = (unsigned char) ((longueur_fonction >> 16) & 0xFF); |
|
chaine[7] = (unsigned char) ((longueur_fonction >> 8) & 0xFF); |
|
chaine[8] = (unsigned char) (longueur_fonction & 0xFF); |
|
|
|
strcpy(chaine + 9, (*((struct_nom *) (*s_objet).objet)).nom); |
|
(*longueur_effective) = longueur_fonction + 10; |
|
} |
|
|
|
chaine[(*longueur_effective) - 1] = ((*((struct_nom *) |
|
(*s_objet).objet)).symbole == d_vrai) ? 0xFF : 0x00; |
} |
} |
else if ((*s_objet).type == REL) |
else if ((*s_objet).type == REL) |
{ |
{ |
Line 5901 lecture_fichier_non_formate(struct_proce
|
Line 6008 lecture_fichier_non_formate(struct_proce
|
break; |
break; |
} |
} |
|
|
|
case 0x50: // Nom |
|
{ |
|
if ((octets[0] & 0x08) == 0) // Longueur sur 6 bits |
|
{ |
|
longueur = (octets[0] & 0x07); |
|
} |
|
else |
|
{ |
|
switch(octets[0] & 0x07) |
|
{ |
|
case 0x00: // Longueur sur 8 bits |
|
{ |
|
if (longueur_buffer < 0) |
|
{ |
|
if (fread(octets, (size_t) sizeof(unsigned char), |
|
1, fichier) != 1) |
|
{ |
|
if (feof(fichier)) |
|
{ |
|
(*s_etat_processus).erreur_execution = |
|
d_ex_syntaxe; |
|
} |
|
else |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_erreur_fichier; |
|
} |
|
|
|
return(NULL); |
|
} |
|
} |
|
else |
|
{ |
|
if ((longueur_buffer - (ptr - buffer)) >= 1) |
|
{ |
|
octets[0] = *ptr++; |
|
} |
|
else |
|
{ |
|
(*s_etat_processus).erreur_execution = |
|
d_ex_syntaxe; |
|
return(NULL); |
|
} |
|
} |
|
|
|
longueur = octets[0]; |
|
break; |
|
} |
|
|
|
case 0x01: // Longueur sur 16 bits |
|
{ |
|
if (longueur_buffer < 0) |
|
{ |
|
if (fread(octets, (size_t) sizeof(unsigned char), |
|
2, fichier) != 2) |
|
{ |
|
if (feof(fichier)) |
|
{ |
|
(*s_etat_processus).erreur_execution = |
|
d_ex_syntaxe; |
|
} |
|
else |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_erreur_fichier; |
|
} |
|
|
|
return(NULL); |
|
} |
|
} |
|
else |
|
{ |
|
if ((longueur_buffer - (ptr - buffer)) >= 2) |
|
{ |
|
for(j = 0; j < 2; octets[j++] = *ptr++); |
|
} |
|
else |
|
{ |
|
(*s_etat_processus).erreur_execution = |
|
d_ex_syntaxe; |
|
return(NULL); |
|
} |
|
} |
|
|
|
longueur = (((integer8) (octets[0])) << 8) |
|
| ((integer8) (octets[1])); |
|
break; |
|
} |
|
|
|
case 0x02: // Longueur sur 32 bits |
|
{ |
|
if (longueur_buffer < 0) |
|
{ |
|
if (fread(octets, (size_t) sizeof(unsigned char), |
|
4, fichier) != 4) |
|
{ |
|
if (feof(fichier)) |
|
{ |
|
(*s_etat_processus).erreur_execution = |
|
d_ex_syntaxe; |
|
} |
|
else |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_erreur_fichier; |
|
} |
|
|
|
return(NULL); |
|
} |
|
} |
|
else |
|
{ |
|
if ((longueur_buffer - (ptr - buffer)) >= 4) |
|
{ |
|
for(j = 0; j < 4; octets[j++] = *ptr++); |
|
} |
|
else |
|
{ |
|
(*s_etat_processus).erreur_execution = |
|
d_ex_syntaxe; |
|
return(NULL); |
|
} |
|
} |
|
|
|
longueur = (((integer8) (octets[0])) << 24) |
|
| (((integer8) (octets[1])) << 16) |
|
| (((integer8) (octets[2])) << 8) |
|
| ((integer8) (octets[3])); |
|
break; |
|
} |
|
|
|
case 0x03: // Longueur sur 64 bits |
|
{ |
|
if (longueur_buffer < 0) |
|
{ |
|
if (fread(octets, (size_t) sizeof(unsigned char), |
|
8, fichier) != 8) |
|
{ |
|
if (feof(fichier)) |
|
{ |
|
(*s_etat_processus).erreur_execution = |
|
d_ex_syntaxe; |
|
} |
|
else |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_erreur_fichier; |
|
} |
|
|
|
return(NULL); |
|
} |
|
} |
|
else |
|
{ |
|
if ((longueur_buffer - (ptr - buffer)) >= 8) |
|
{ |
|
for(j = 0; j < 8; octets[j++] = *ptr++); |
|
} |
|
else |
|
{ |
|
(*s_etat_processus).erreur_execution = |
|
d_ex_syntaxe; |
|
return(NULL); |
|
} |
|
} |
|
|
|
longueur = (((integer8) (octets[0])) << 56) |
|
| (((integer8) (octets[1])) << 48) |
|
| (((integer8) (octets[2])) << 40) |
|
| (((integer8) (octets[3])) << 32) |
|
| (((integer8) (octets[4])) << 24) |
|
| (((integer8) (octets[5])) << 16) |
|
| (((integer8) (octets[6])) << 8) |
|
| ((integer8) (octets[7])); |
|
break; |
|
} |
|
|
|
default: |
|
{ |
|
(*s_etat_processus).erreur_execution = d_ex_syntaxe; |
|
return(NULL); |
|
} |
|
} |
|
} |
|
|
|
if ((s_objet = allocation(s_etat_processus, NOM)) == NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
|
return(NULL); |
|
} |
|
|
|
if (((*((struct_nom *) (*s_objet).objet)).nom = |
|
malloc((longueur + 1) * sizeof(unsigned char))) == NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
|
return(NULL); |
|
} |
|
|
|
if (longueur_buffer < 0) |
|
{ |
|
if (fread((unsigned char *) (*((struct_nom *) (*s_objet) |
|
.objet)).nom, (size_t) sizeof(unsigned char), |
|
longueur, fichier) != (unsigned) longueur) |
|
{ |
|
if (feof(fichier)) |
|
{ |
|
(*s_etat_processus).erreur_execution = |
|
d_ex_syntaxe; |
|
} |
|
else |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_erreur_fichier; |
|
} |
|
|
|
liberation(s_etat_processus, s_objet); |
|
return(NULL); |
|
} |
|
|
|
if (fread(octets, (size_t) sizeof(unsigned char), |
|
1, fichier) != 1) |
|
{ |
|
if (feof(fichier)) |
|
{ |
|
(*s_etat_processus).erreur_execution = |
|
d_ex_syntaxe; |
|
} |
|
else |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_erreur_fichier; |
|
} |
|
|
|
liberation(s_etat_processus, s_objet); |
|
return(NULL); |
|
} |
|
} |
|
else |
|
{ |
|
if ((longueur_buffer - (ptr - buffer)) >= (longueur + 1)) |
|
{ |
|
for(j = 0; j < longueur; (*((struct_nom *) |
|
(*s_objet).objet)).nom[j] = *ptr++); |
|
octets[0] = *ptr++; |
|
} |
|
else |
|
{ |
|
liberation(s_etat_processus, s_objet); |
|
(*s_etat_processus).erreur_execution = d_ex_syntaxe; |
|
return(NULL); |
|
} |
|
} |
|
|
|
(*((struct_nom *) (*s_objet).objet)).nom[longueur] = |
|
d_code_fin_chaine; |
|
(*((struct_nom *) (*s_objet).objet)).symbole = |
|
(octets[0] == 0xFF) ? d_vrai : d_faux; |
|
break; |
|
} |
|
|
case 0xE0: // Fonction |
case 0xE0: // Fonction |
{ |
{ |
if ((octets[0] & 0x08) == 0) // Longueur sur 6 bits |
if ((octets[0] & 0x08) == 0) // Longueur sur 6 bits |