--- rpl/src/interface_gnuplot.c 2010/02/28 14:47:14 1.4 +++ rpl/src/interface_gnuplot.c 2011/06/20 17:54:20 1.22 @@ -1,7 +1,7 @@ /* ================================================================================ - RPL/2 (R) version 4.0.11 - 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,8 +20,8 @@ */ -#include "rpl.conv.h" -#include "gnuplot.conv.h" +#include "rpl-conv.h" +#include "gnuplot-conv.h" /* @@ -36,6 +36,26 @@ ================================================================================ */ +#ifdef OS2 + +static unsigned char * +ajout_shell(unsigned char *commande) +{ + unsigned char *tampon; + + if ((tampon = malloc((strlen(BOURNE_SHELL) + 5 + strlen(commande) + 2) * + sizeof(unsigned char))) == NULL) + { + return(NULL); + } + + sprintf(tampon, "%s -c \"%s\"", BOURNE_SHELL, commande); + free(commande); + return(tampon); +} + +#endif + void appel_gnuplot(struct_processus *s_etat_processus, unsigned char persistance) { @@ -266,16 +286,35 @@ appel_gnuplot(struct_processus *s_etat_p if ((*s_etat_processus).entree_standard == NULL) { #ifdef FORCE_GNUPLOT_PATH - if ((commande_gnuplot = malloc((strlen(d_exec_path) + 6 + - strlen(ds_gnuplot_commande)) * sizeof(unsigned char))) - == NULL) + if ((*s_etat_processus).rpl_home == NULL) { - (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; - return; + if ((commande_gnuplot = malloc((strlen(d_exec_path) + 6 + + strlen(ds_gnuplot_commande)) * sizeof(unsigned char))) + == NULL) + { + (*s_etat_processus).erreur_systeme = + d_es_allocation_memoire; + return; + } + + sprintf(commande_gnuplot, "%s/bin/%s", d_exec_path, + ds_gnuplot_commande); } + else + { + if ((commande_gnuplot = malloc((strlen( + (*s_etat_processus).rpl_home) + 6 + + strlen(ds_gnuplot_commande)) * sizeof(unsigned char))) + == NULL) + { + (*s_etat_processus).erreur_systeme = + d_es_allocation_memoire; + return; + } - sprintf(commande_gnuplot, "%s/bin/%s", d_exec_path, - ds_gnuplot_commande); + sprintf(commande_gnuplot, "%s/bin/%s", + (*s_etat_processus).rpl_home, ds_gnuplot_commande); + } #else if ((commande_gnuplot = malloc((1 + strlen(ds_gnuplot_commande)) * sizeof(unsigned char))) @@ -288,6 +327,14 @@ appel_gnuplot(struct_processus *s_etat_p sprintf(commande_gnuplot, "%s", ds_gnuplot_commande); #endif +#ifdef OS2 + if ((commande_gnuplot = ajout_shell(commande_gnuplot)) == NULL) + { + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } +#endif + if (((*s_etat_processus).entree_standard = popen(commande_gnuplot, "w")) == NULL) { @@ -320,16 +367,33 @@ appel_gnuplot(struct_processus *s_etat_p entree_standard = (*s_etat_processus).entree_standard; #if FORCE_GNUPLOT_PATH - if ((commande_gnuplot = malloc((strlen(d_exec_path) + 6 + - strlen(ds_gnuplot_commande_persistante)) * - sizeof(unsigned char))) == NULL) + if ((*s_etat_processus).rpl_home == NULL) { - (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; - return; + if ((commande_gnuplot = malloc((strlen(d_exec_path) + 6 + + strlen(ds_gnuplot_commande_persistante)) * + sizeof(unsigned char))) == NULL) + { + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } + + sprintf(commande_gnuplot, "%s/bin/%s", d_exec_path, + ds_gnuplot_commande_persistante); } + else + { + if ((commande_gnuplot = malloc((strlen( + (*s_etat_processus).rpl_home) + 6 + + strlen(ds_gnuplot_commande_persistante)) * + sizeof(unsigned char))) == NULL) + { + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } - sprintf(commande_gnuplot, "%s/bin/%s", d_exec_path, - ds_gnuplot_commande_persistante); + sprintf(commande_gnuplot, "%s/bin/%s", (*s_etat_processus).rpl_home, + ds_gnuplot_commande_persistante); + } #else if ((commande_gnuplot = malloc((1 + strlen(ds_gnuplot_commande_persistante)) * @@ -342,6 +406,14 @@ appel_gnuplot(struct_processus *s_etat_p sprintf(commande_gnuplot, "%s", ds_gnuplot_commande_persistante); #endif +#ifdef OS2 + if ((commande_gnuplot = ajout_shell(commande_gnuplot)) == NULL) + { + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } +#endif + if (((*s_etat_processus).entree_standard = popen(commande_gnuplot, "w")) == NULL) { @@ -373,16 +445,32 @@ appel_gnuplot(struct_processus *s_etat_p entree_standard = (*s_etat_processus).entree_standard; #ifdef FORCE_GNUPLOT_PATH - if ((commande_gnuplot = malloc((strlen(d_exec_path) + 6 + - strlen(ds_gnuplot_commande)) * sizeof(unsigned char))) - == NULL) + if ((*s_etat_processus).rpl_home == NULL) { - (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; - return; + if ((commande_gnuplot = malloc((strlen(d_exec_path) + 6 + + strlen(ds_gnuplot_commande)) * sizeof(unsigned char))) + == NULL) + { + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } + + sprintf(commande_gnuplot, "%s/bin/%s", d_exec_path, + ds_gnuplot_commande); } + else + { + if ((commande_gnuplot = malloc((strlen((*s_etat_processus).rpl_home) + + 6 + strlen(ds_gnuplot_commande)) * sizeof(unsigned char))) + == NULL) + { + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } - sprintf(commande_gnuplot, "%s/bin/%s", d_exec_path, - ds_gnuplot_commande); + sprintf(commande_gnuplot, "%s/bin/%s", (*s_etat_processus).rpl_home, + ds_gnuplot_commande); + } #else if ((commande_gnuplot = malloc((1 + strlen(ds_gnuplot_commande)) * sizeof(unsigned char))) @@ -395,6 +483,13 @@ appel_gnuplot(struct_processus *s_etat_p sprintf(commande_gnuplot, "%s", ds_gnuplot_commande); #endif +#ifdef OS2 + if ((commande_gnuplot = ajout_shell(commande_gnuplot)) == NULL) + { + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } +#endif if (((*s_etat_processus).entree_standard = popen(commande_gnuplot, "w")) == NULL) { @@ -437,16 +532,32 @@ appel_gnuplot(struct_processus *s_etat_p entree_standard = (*s_etat_processus).entree_standard; #ifdef FORCE_GNUPLOT_PATH - if ((commande_gnuplot = malloc((strlen(d_exec_path) + 6 + - strlen(ds_gnuplot_commande)) * sizeof(unsigned char))) - == NULL) + if ((*s_etat_processus).rpl_home == NULL) { - (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; - return; + if ((commande_gnuplot = malloc((strlen(d_exec_path) + 6 + + strlen(ds_gnuplot_commande)) * sizeof(unsigned char))) + == NULL) + { + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } + + sprintf(commande_gnuplot, "%s/bin/%s", d_exec_path, + ds_gnuplot_commande); } + else + { + if ((commande_gnuplot = malloc((strlen((*s_etat_processus).rpl_home) + + 6 + strlen(ds_gnuplot_commande)) * sizeof(unsigned char))) + == NULL) + { + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } - sprintf(commande_gnuplot, "%s/bin/%s", d_exec_path, - ds_gnuplot_commande); + sprintf(commande_gnuplot, "%s/bin/%s", (*s_etat_processus).rpl_home, + ds_gnuplot_commande); + } #else if ((commande_gnuplot = malloc((1 + strlen(ds_gnuplot_commande)) * sizeof(unsigned char))) @@ -459,6 +570,13 @@ appel_gnuplot(struct_processus *s_etat_p sprintf(commande_gnuplot, "%s", ds_gnuplot_commande); #endif +#ifdef OS2 + if ((commande_gnuplot = ajout_shell(commande_gnuplot)) == NULL) + { + (*s_etat_processus).erreur_systeme = d_es_allocation_memoire; + return; + } +#endif if (((*s_etat_processus).entree_standard = popen(commande_gnuplot, "w")) == NULL) {