version 1.19, 2012/01/05 10:18:59
|
version 1.33, 2013/03/01 09:29:30
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.1.5 |
RPL/2 (R) version 4.1.13 |
Copyright (C) 1989-2012 Dr. BERTRAND Joël |
Copyright (C) 1989-2013 Dr. BERTRAND Joël |
|
|
This file is part of RPL/2. |
This file is part of RPL/2. |
|
|
Line 165 formateur_flux(struct_processus *s_etat_
|
Line 165 formateur_flux(struct_processus *s_etat_
|
{ |
{ |
printf("+++Information : " |
printf("+++Information : " |
"Séquence d'échappement " |
"Séquence d'échappement " |
"inconnue [%d]\n", |
"inconnue (\\x%c%c) [%d]\n", |
|
*ptr_lecture, *(ptr_lecture + 1), |
(int) getpid()); |
(int) getpid()); |
} |
} |
else |
else |
{ |
{ |
printf("+++Warning : Unknown " |
printf("+++Warning : Unknown " |
"escape code " |
"escape code (\\x%c%c) [%d]\n", |
"[%d]\n", (int) getpid()); |
*ptr_lecture, *(ptr_lecture + 1), |
|
(int) getpid()); |
} |
} |
} |
} |
} |
} |
Line 182 formateur_flux(struct_processus *s_etat_
|
Line 184 formateur_flux(struct_processus *s_etat_
|
{ |
{ |
printf("+++Information : " |
printf("+++Information : " |
"Séquence d'échappement " |
"Séquence d'échappement " |
"inconnue [%d]\n", (int) getpid()); |
"tronquée [%d]\n", (int) getpid()); |
} |
} |
else |
else |
{ |
{ |
printf("+++Warning : Unknown escape code " |
printf("+++Warning : Truncated escape code " |
"[%d]\n", (int) getpid()); |
"[%d]\n", (int) getpid()); |
} |
} |
} |
} |
Line 212 formateur_flux(struct_processus *s_etat_
|
Line 214 formateur_flux(struct_processus *s_etat_
|
} |
} |
else |
else |
{ |
{ |
if ((*s_etat_processus).langue == 'F') |
if ((*(ptr_lecture + 1)) == d_code_fin_chaine) |
{ |
{ |
printf("+++Information : Séquence d'échappement " |
if ((*s_etat_processus).langue == 'F') |
"inconnue [%d]\n", (int) getpid()); |
{ |
|
printf("+++Information : " |
|
"Séquence d'échappement " |
|
"tronquée [%d]\n", (int) getpid()); |
|
} |
|
else |
|
{ |
|
printf("+++Warning : Truncated escape code " |
|
"[%d]\n", (int) getpid()); |
|
} |
} |
} |
else |
else |
{ |
{ |
printf("+++Warning : Unknown escape code " |
if ((*s_etat_processus).langue == 'F') |
"[%d]\n", (int) getpid()); |
{ |
|
printf("+++Information : Séquence d'échappement " |
|
"inconnue (%c%c) [%d]\n", |
|
*ptr_lecture, *(ptr_lecture + 1), |
|
(int) getpid()); |
|
} |
|
else |
|
{ |
|
printf("+++Warning : Unknown escape code (%c%c) " |
|
"[%d]\n", *ptr_lecture, *(ptr_lecture + 1), |
|
(int) getpid()); |
|
} |
} |
} |
} |
} |
} |
} |
Line 240 formateur_flux(struct_processus *s_etat_
|
Line 262 formateur_flux(struct_processus *s_etat_
|
|
|
return(chaine); |
return(chaine); |
} |
} |
|
|
|
|
|
/* |
|
================================================================================ |
|
Routine de d'analyse d'un flux |
|
================================================================================ |
|
Entrées : structure sur l'état du processus et objet à afficher |
|
-------------------------------------------------------------------------------- |
|
Sorties : chaine de caractères |
|
-------------------------------------------------------------------------------- |
|
Effets de bord : néant |
|
================================================================================ |
|
*/ |
|
|
|
unsigned char * |
|
analyse_flux(struct_processus *s_etat_processus, unsigned char *donnees, |
|
long longueur) |
|
{ |
|
long longueur_courante; |
|
long offset; |
|
|
|
unsigned char *chaine; |
|
unsigned char hexadecimal[3]; |
|
unsigned char *ptr_ecriture; |
|
unsigned char *ptr_lecture; |
|
|
|
if ((chaine = malloc((longueur_courante = longueur + 1) * |
|
sizeof(unsigned char))) == NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
|
return(NULL); |
|
} |
|
|
|
ptr_lecture = donnees; |
|
ptr_ecriture = chaine; |
|
|
|
while(longueur > 0) |
|
{ |
|
// Début de la séquence d'échappement |
|
|
|
switch((*ptr_lecture)) |
|
{ |
|
case '"': |
|
case '\b': |
|
case '\n': |
|
case '\t': |
|
case '\\': |
|
{ |
|
offset = ptr_ecriture - chaine; |
|
|
|
if ((chaine = realloc(chaine, (++longueur_courante) |
|
* sizeof(unsigned char))) == NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return(NULL); |
|
} |
|
|
|
ptr_ecriture = chaine + offset; |
|
*ptr_ecriture++ = '\\'; |
|
|
|
switch((*ptr_lecture++)) |
|
{ |
|
case '"': |
|
{ |
|
*ptr_ecriture++ = '"'; |
|
break; |
|
} |
|
|
|
case '\b': |
|
{ |
|
*ptr_ecriture++ = 'b'; |
|
break; |
|
} |
|
|
|
case '\n': |
|
{ |
|
*ptr_ecriture++ = 'n'; |
|
break; |
|
} |
|
|
|
case '\t': |
|
{ |
|
*ptr_ecriture++ = 't'; |
|
break; |
|
} |
|
|
|
case '\\': |
|
{ |
|
*ptr_ecriture++ = '\\'; |
|
break; |
|
} |
|
} |
|
|
|
break; |
|
} |
|
|
|
case ' ': |
|
{ |
|
*ptr_ecriture++ = *ptr_lecture++; |
|
break; |
|
} |
|
|
|
default: |
|
{ |
|
if (isgraph((*ptr_lecture))) |
|
{ |
|
*ptr_ecriture++ = *ptr_lecture++; |
|
} |
|
else |
|
{ |
|
offset = ptr_ecriture - chaine; |
|
|
|
if ((chaine = realloc(chaine, (longueur_courante = |
|
longueur_courante + 3) * sizeof(unsigned char))) |
|
== NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = |
|
d_es_allocation_memoire; |
|
return(NULL); |
|
} |
|
|
|
ptr_ecriture = chaine + offset; |
|
*ptr_ecriture++ = '\\'; |
|
*ptr_ecriture++ = 'x'; |
|
|
|
sprintf(hexadecimal, "%02X", *ptr_lecture++); |
|
|
|
*ptr_ecriture++ = hexadecimal[0]; |
|
*ptr_ecriture++ = hexadecimal[1]; |
|
} |
|
|
|
break; |
|
} |
|
} |
|
|
|
longueur--; |
|
} |
|
|
|
(*ptr_ecriture) = d_code_fin_chaine; |
|
|
|
return(chaine); |
|
} |
|
|
|
|
/* |
/* |