version 1.2, 2010/01/27 22:22:09
|
version 1.75, 2019/02/03 14:40:29
|
Line 1
|
Line 1
|
/* |
/* |
================================================================================ |
================================================================================ |
RPL/2 (R) version 4.0.10 |
RPL/2 (R) version 4.1.31 |
Copyright (C) 1989-2010 Dr. BERTRAND Joël |
Copyright (C) 1989-2019 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" |
|
|
|
|
/* |
/* |
================================================================================ |
================================================================================ |
Routine de chainage du programme (lecture du fichier puis constitution |
Routine de chaînage du programme (lecture du fichier puis constitution |
de la chaine executable) |
de la chaîne exécutable) |
================================================================================ |
================================================================================ |
Entrées: structure processus |
Entrées: structure processus |
-------------------------------------------------------------------------------- |
-------------------------------------------------------------------------------- |
Line 45 chainage(struct_processus *s_etat_proces
|
Line 45 chainage(struct_processus *s_etat_proces
|
|
|
int caractere; |
int caractere; |
int erreur; |
int erreur; |
int erreur_os; |
|
|
|
logical1 drapeau_fin; |
logical1 drapeau_fin; |
|
logical1 erreur_os; |
logical1 existence; |
logical1 existence; |
|
logical1 initialisation; |
logical1 ouverture; |
logical1 ouverture; |
logical1 presence_chaine; |
logical1 presence_chaine; |
|
|
long i; |
integer8 i; |
long nombre_caracteres_source; |
integer8 nombre_caracteres_source; |
|
|
unsigned char *commande; |
unsigned char *commande; |
unsigned char *instructions = "sed -e '1,1s/^#!/\\/\\//g' %s | " |
unsigned char *executable_candidat; |
"%s/bin/%s | " |
|
|
# ifndef OS2 |
|
unsigned char *instructions = "%s/bin/%s %s | " |
"%s/bin/rpliconv `%s/bin/rplfile " |
"%s/bin/rpliconv `%s/bin/rplfile " |
"-m %s/share/rplfiles -i %s | awk " |
"-m %s/share/rplfiles -i %s | " |
"'{ print $3; }' | awk -F= " |
"%s/bin/rplawk " |
|
"'{ print $3; }' | %s/bin/rplawk -F= " |
"'{ if ($2 != \"\") printf(\"-f %%s\", " |
"'{ if ($2 != \"\") printf(\"-f %%s\", " |
"$2); }'` -t `locale charmap`//IGNORE > %s"; |
"$2); }'` -t %s//IGNORE > %s"; |
|
# else |
|
unsigned char *instructions = BOURNE_SHELL " -c \"" |
|
"%s/bin/%s %s | " |
|
"%s/bin/rpliconv `%s/bin/rplfile " |
|
"-m %s/share/rplfiles -i %s | " |
|
"%s/bin/rplawk " |
|
"'{ print $3; }' | %s/bin/rplawk -F= " |
|
"'{ if ($2 != \\\"\\\") " |
|
"printf(\\\"-f %%s\\\", " |
|
"$2); }'` -t %s//IGNORE > %s\""; |
|
# endif |
|
|
unsigned long unite_fichier; |
unsigned long unite_fichier; |
|
|
Line 99 chainage(struct_processus *s_etat_proces
|
Line 114 chainage(struct_processus *s_etat_proces
|
return(d_erreur); |
return(d_erreur); |
} |
} |
|
|
if ((commande = (unsigned char *) malloc((strlen(ds_preprocesseur) + |
// Avant d'exécuter la commande, on teste les sommes de hashage |
(2 * strlen((*s_etat_processus).nom_fichier_source)) + |
// des utilitaires de la famille RPL/2. |
(4 * strlen(d_exec_path)) + |
|
strlen(nom_fichier_temporaire) + strlen(instructions) - 11) * |
if ((*s_etat_processus).rpl_home == NULL) |
sizeof(unsigned char))) == NULL) |
|
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
if ((commande = (unsigned char *) malloc((strlen(ds_preprocesseur) + |
|
(2 * strlen((*s_etat_processus).nom_fichier_source)) + |
|
(6 * strlen(d_exec_path)) + strlen(d_locale) + |
|
strlen(nom_fichier_temporaire) + strlen(instructions) - 21) |
|
* sizeof(unsigned char))) == NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
|
|
free(nom_fichier_temporaire); |
free(nom_fichier_temporaire); |
return(d_erreur); |
return(d_erreur); |
|
} |
|
|
|
sprintf(commande, instructions, |
|
d_exec_path, ds_preprocesseur, |
|
(*s_etat_processus).nom_fichier_source, |
|
d_exec_path, d_exec_path, |
|
d_exec_path, (*s_etat_processus).nom_fichier_source, |
|
d_exec_path, d_exec_path, d_locale, nom_fichier_temporaire); |
|
|
|
if (alsprintf(s_etat_processus, &executable_candidat, |
|
"%s/bin/rpliconv", d_exec_path) < 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
|
return(d_erreur); |
|
} |
|
|
|
if (controle_integrite(s_etat_processus, executable_candidat, |
|
"rpliconv") != d_vrai) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_somme_controle; |
|
return(d_erreur); |
|
} |
|
|
|
free(executable_candidat); |
|
|
|
if (alsprintf(s_etat_processus, &executable_candidat, |
|
"%s/bin/rplfile", d_exec_path) < 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
|
return(d_erreur); |
|
} |
|
|
|
if (controle_integrite(s_etat_processus, executable_candidat, |
|
"rplfile") != d_vrai) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_somme_controle; |
|
return(d_erreur); |
|
} |
|
|
|
free(executable_candidat); |
|
|
|
if (alsprintf(s_etat_processus, &executable_candidat, |
|
"%s/bin/rplpp", d_exec_path) < 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
|
return(d_erreur); |
|
} |
|
|
|
if (controle_integrite(s_etat_processus, executable_candidat, |
|
"rplpp") != d_vrai) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_somme_controle; |
|
return(d_erreur); |
|
} |
|
|
|
free(executable_candidat); |
|
|
|
if (alsprintf(s_etat_processus, &executable_candidat, |
|
"%s/bin/rplawk", d_exec_path) < 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
|
return(d_erreur); |
|
} |
|
|
|
if (controle_integrite(s_etat_processus, executable_candidat, |
|
"rplawk") != d_vrai) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_somme_controle; |
|
return(d_erreur); |
|
} |
|
|
|
free(executable_candidat); |
} |
} |
|
else |
|
{ |
|
if ((commande = (unsigned char *) malloc((strlen(ds_preprocesseur) + |
|
(2 * strlen((*s_etat_processus).nom_fichier_source)) + |
|
(6 * strlen((*s_etat_processus).rpl_home)) + |
|
strlen(d_locale) + |
|
strlen(nom_fichier_temporaire) + strlen(instructions) - 21) |
|
* sizeof(unsigned char))) == NULL) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
|
|
sprintf(commande, instructions, (*s_etat_processus).nom_fichier_source, |
free(nom_fichier_temporaire); |
d_exec_path, ds_preprocesseur, d_exec_path, d_exec_path, |
return(d_erreur); |
d_exec_path, (*s_etat_processus).nom_fichier_source, |
} |
nom_fichier_temporaire); |
|
|
sprintf(commande, instructions, |
|
(*s_etat_processus).rpl_home, ds_preprocesseur, |
|
(*s_etat_processus).nom_fichier_source, |
|
(*s_etat_processus).rpl_home, |
|
(*s_etat_processus).rpl_home, |
|
(*s_etat_processus).rpl_home, |
|
(*s_etat_processus).nom_fichier_source, |
|
(*s_etat_processus).rpl_home, |
|
(*s_etat_processus).rpl_home, |
|
d_locale, nom_fichier_temporaire); |
|
|
|
if (alsprintf(s_etat_processus, &executable_candidat, |
|
"%s/bin/rpliconv", (*s_etat_processus).rpl_home) < 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
|
return(d_erreur); |
|
} |
|
|
|
if (controle_integrite(s_etat_processus, executable_candidat, |
|
"rpliconv") != d_vrai) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_somme_controle; |
|
return(d_erreur); |
|
} |
|
|
|
free(executable_candidat); |
|
|
|
if (alsprintf(s_etat_processus, &executable_candidat, |
|
"%s/bin/rplfile", (*s_etat_processus).rpl_home) < 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
|
return(d_erreur); |
|
} |
|
|
|
if (controle_integrite(s_etat_processus, executable_candidat, |
|
"rplfile") != d_vrai) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_somme_controle; |
|
return(d_erreur); |
|
} |
|
|
|
free(executable_candidat); |
|
|
|
if (alsprintf(s_etat_processus, &executable_candidat, |
|
"%s/bin/rplpp", (*s_etat_processus).rpl_home) < 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
|
return(d_erreur); |
|
} |
|
|
|
if (controle_integrite(s_etat_processus, executable_candidat, |
|
"rplpp") != d_vrai) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_somme_controle; |
|
return(d_erreur); |
|
} |
|
|
|
free(executable_candidat); |
|
|
|
if (alsprintf(s_etat_processus, &executable_candidat, |
|
"%s/bin/rplawk", (*s_etat_processus).rpl_home) < 0) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
|
return(d_erreur); |
|
} |
|
|
|
if (controle_integrite(s_etat_processus, executable_candidat, |
|
"rplawk") != d_vrai) |
|
{ |
|
(*s_etat_processus).erreur_systeme = d_es_somme_controle; |
|
return(d_erreur); |
|
} |
|
|
|
free(executable_candidat); |
|
} |
|
|
if ((f_source = popen(commande, "r")) == NULL) |
if ((f_source = popen(commande, "r")) == NULL) |
{ |
{ |
Line 156 chainage(struct_processus *s_etat_proces
|
Line 333 chainage(struct_processus *s_etat_proces
|
} |
} |
|
|
(*s_etat_processus).definitions_chainees = (unsigned char *) |
(*s_etat_processus).definitions_chainees = (unsigned char *) |
malloc((nombre_caracteres_source + 1) * sizeof(unsigned char)); |
malloc((((size_t) nombre_caracteres_source) + 1) |
|
* sizeof(unsigned char)); |
|
|
if ((*s_etat_processus).definitions_chainees == NULL) |
if ((*s_etat_processus).definitions_chainees == NULL) |
{ |
{ |
Line 177 chainage(struct_processus *s_etat_proces
|
Line 355 chainage(struct_processus *s_etat_proces
|
|
|
i = 0; |
i = 0; |
drapeau_fin = d_faux; |
drapeau_fin = d_faux; |
|
initialisation = d_vrai; |
|
|
|
/* |
|
* Élimination du sharp-bang si nécessaire et des caractères |
|
* inutiles. Conversion de caractères. |
|
*/ |
|
|
while(drapeau_fin == d_faux) |
while(drapeau_fin == d_faux) |
{ |
{ |
if ((caractere = getc(f_source)) != EOF) |
if ((caractere = getc(f_source)) != EOF) |
{ |
{ |
|
if (initialisation == d_vrai) |
|
{ |
|
if (caractere == '#') |
|
{ |
|
if ((caractere = getc(f_source)) != EOF) |
|
{ |
|
if (caractere == '!') |
|
{ |
|
do |
|
{ |
|
caractere = getc(f_source); |
|
} while((caractere != EOF) && |
|
(caractere != |
|
d_code_retour_chariot)); |
|
} |
|
else |
|
{ |
|
rewind(f_source); |
|
caractere = getc(f_source); |
|
} |
|
} |
|
} |
|
|
|
initialisation = d_faux; |
|
} |
|
|
if ((caractere == d_code_retour_chariot) || |
if ((caractere == d_code_retour_chariot) || |
(caractere == d_code_tabulation) || |
(caractere == d_code_tabulation) || |
((caractere == d_code_espace) && |
((caractere == d_code_espace) && |
Line 207 chainage(struct_processus *s_etat_proces
|
Line 417 chainage(struct_processus *s_etat_proces
|
} |
} |
} |
} |
|
|
if ((((*s_etat_processus).definitions_chainees)[i] = |
if (((int) (((*s_etat_processus).definitions_chainees)[i] = |
caractere) == '\"') |
((unsigned char) caractere))) == '\"') |
{ |
{ |
if (i > 0) |
if (i > 0) |
{ |
{ |
Line 244 chainage(struct_processus *s_etat_proces
|
Line 454 chainage(struct_processus *s_etat_proces
|
} |
} |
|
|
(*s_etat_processus).longueur_definitions_chainees = |
(*s_etat_processus).longueur_definitions_chainees = |
strlen((*s_etat_processus).definitions_chainees); |
(integer8) strlen((*s_etat_processus).definitions_chainees); |
|
|
if (fclose(f_source) != 0) |
if (fclose(f_source) != 0) |
{ |
{ |
Line 278 chainage(struct_processus *s_etat_proces
|
Line 488 chainage(struct_processus *s_etat_proces
|
|
|
if (((*s_etat_processus).definitions_chainees = |
if (((*s_etat_processus).definitions_chainees = |
realloc((*s_etat_processus).definitions_chainees, |
realloc((*s_etat_processus).definitions_chainees, |
((*s_etat_processus).longueur_definitions_chainees + 1) * |
(((size_t) (*s_etat_processus).longueur_definitions_chainees) + 1) |
sizeof(unsigned char))) == NULL) |
* sizeof(unsigned char))) == NULL) |
{ |
{ |
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
(*s_etat_processus).erreur_systeme = d_es_allocation_memoire; |
return(d_erreur); |
return(d_erreur); |
Line 303 chainage(struct_processus *s_etat_proces
|
Line 513 chainage(struct_processus *s_etat_proces
|
*/ |
*/ |
|
|
unsigned char * |
unsigned char * |
compactage(unsigned char *chaine) |
compactage(struct_processus *s_etat_processus, unsigned char *chaine) |
{ |
{ |
logical1 drapeau_fin; |
logical1 drapeau_fin; |
logical1 presence_chaine; |
logical1 presence_chaine; |