Diff for /rpl/src/interface_gnuplot.c between versions 1.1 and 1.56

version 1.1, 2010/01/26 15:22:45 version 1.56, 2015/09/18 13:41:19
Line 1 Line 1
 /*  /*
 ================================================================================  ================================================================================
   RPL/2 (R) version 4.0.9    RPL/2 (R) version 4.1.23
   Copyright (C) 1989-2010 Dr. BERTRAND Joël    Copyright (C) 1989-2015 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"
 #include "gnuplot.conv.h"  #include "gnuplot-conv.h"
   
 #ifdef DEBUG  
 #   define fprintf(flux, ...) ({ printf(__VA_ARGS__); \  
         fprintf(flux, __VA_ARGS__); })  
 #endif  
   
   
 /*  /*
Line 41 Line 36
 ================================================================================  ================================================================================
 */  */
   
   #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  void
 appel_gnuplot(struct_processus *s_etat_processus, unsigned char persistance)  appel_gnuplot(struct_processus *s_etat_processus, unsigned char persistance)
 {  {
Line 221  appel_gnuplot(struct_processus *s_etat_p Line 234  appel_gnuplot(struct_processus *s_etat_p
                             (*l_base_liste).type);                              (*l_base_liste).type);
                     (*(*s_etat_processus).fichiers_graphiques).dimensions =                      (*(*s_etat_processus).fichiers_graphiques).dimensions =
                             (*l_base_liste).dimensions;                              (*l_base_liste).dimensions;
                       (*(*s_etat_processus).fichiers_graphiques).systeme_axes =
                               (*l_base_liste).systeme_axes;
                 }                  }
                 else                  else
                 {                  {
Line 245  appel_gnuplot(struct_processus *s_etat_p Line 260  appel_gnuplot(struct_processus *s_etat_p
                     (*l_fichier_courant).legende = NULL;                      (*l_fichier_courant).legende = NULL;
                     (*l_fichier_courant).presence_axes = d_faux;                      (*l_fichier_courant).presence_axes = d_faux;
                     strcpy((*l_fichier_courant).type, (*l_base_liste).type);                      strcpy((*l_fichier_courant).type, (*l_base_liste).type);
                     (*(*s_etat_processus).fichiers_graphiques).dimensions =                      (*l_fichier_courant).dimensions =
                             (*l_base_liste).dimensions;                              (*l_base_liste).dimensions;
                       (*l_fichier_courant).systeme_axes =
                               (*l_base_liste).systeme_axes;
                 }                  }
             }              }
   
Line 267  appel_gnuplot(struct_processus *s_etat_p Line 284  appel_gnuplot(struct_processus *s_etat_p
         if ((*s_etat_processus).entree_standard == NULL)          if ((*s_etat_processus).entree_standard == NULL)
         {          {
 #ifdef FORCE_GNUPLOT_PATH  #ifdef FORCE_GNUPLOT_PATH
             if ((commande_gnuplot = malloc((strlen(d_exec_path) + 6 +              if ((*s_etat_processus).rpl_home == NULL)
                     strlen(ds_gnuplot_commande)) * sizeof(unsigned char)))  
                     == NULL)  
             {              {
                 (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;                  if ((commande_gnuplot = malloc((strlen(d_exec_path) + 6 +
                 return;                          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,                  sprintf(commande_gnuplot, "%s/bin/%s",
                     ds_gnuplot_commande);                          (*s_etat_processus).rpl_home, ds_gnuplot_commande);
               }
 #else  #else
             if ((commande_gnuplot = malloc((1 +              if ((commande_gnuplot = malloc((1 +
                     strlen(ds_gnuplot_commande)) * sizeof(unsigned char)))                      strlen(ds_gnuplot_commande)) * sizeof(unsigned char)))
Line 289  appel_gnuplot(struct_processus *s_etat_p Line 325  appel_gnuplot(struct_processus *s_etat_p
             sprintf(commande_gnuplot, "%s", ds_gnuplot_commande);              sprintf(commande_gnuplot, "%s", ds_gnuplot_commande);
 #endif  #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 =              if (((*s_etat_processus).entree_standard =
                     popen(commande_gnuplot, "w")) == NULL)                      popen(commande_gnuplot, "w")) == NULL)
             {              {
Line 321  appel_gnuplot(struct_processus *s_etat_p Line 365  appel_gnuplot(struct_processus *s_etat_p
         entree_standard = (*s_etat_processus).entree_standard;          entree_standard = (*s_etat_processus).entree_standard;
   
 #if FORCE_GNUPLOT_PATH  #if FORCE_GNUPLOT_PATH
         if ((commande_gnuplot = malloc((strlen(d_exec_path) + 6 +          if ((*s_etat_processus).rpl_home == NULL)
                 strlen(ds_gnuplot_commande_persistante)) *  
                 sizeof(unsigned char))) == NULL)  
         {          {
             (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;              if ((commande_gnuplot = malloc((strlen(d_exec_path) + 6 +
             return;                      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,              sprintf(commande_gnuplot, "%s/bin/%s", (*s_etat_processus).rpl_home,
                 ds_gnuplot_commande_persistante);                      ds_gnuplot_commande_persistante);
           }
 #else  #else
         if ((commande_gnuplot = malloc((1 +          if ((commande_gnuplot = malloc((1 +
                 strlen(ds_gnuplot_commande_persistante)) *                  strlen(ds_gnuplot_commande_persistante)) *
Line 343  appel_gnuplot(struct_processus *s_etat_p Line 404  appel_gnuplot(struct_processus *s_etat_p
         sprintf(commande_gnuplot, "%s", ds_gnuplot_commande_persistante);          sprintf(commande_gnuplot, "%s", ds_gnuplot_commande_persistante);
 #endif  #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 =          if (((*s_etat_processus).entree_standard =
                 popen(commande_gnuplot, "w")) == NULL)                  popen(commande_gnuplot, "w")) == NULL)
         {          {
Line 374  appel_gnuplot(struct_processus *s_etat_p Line 443  appel_gnuplot(struct_processus *s_etat_p
         entree_standard = (*s_etat_processus).entree_standard;          entree_standard = (*s_etat_processus).entree_standard;
   
 #ifdef FORCE_GNUPLOT_PATH  #ifdef FORCE_GNUPLOT_PATH
         if ((commande_gnuplot = malloc((strlen(d_exec_path) + 6 +          if ((*s_etat_processus).rpl_home == NULL)
                 strlen(ds_gnuplot_commande)) * sizeof(unsigned char)))  
                 == NULL)  
         {          {
             (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;              if ((commande_gnuplot = malloc((strlen(d_exec_path) + 6 +
             return;                      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,              sprintf(commande_gnuplot, "%s/bin/%s", (*s_etat_processus).rpl_home,
                 ds_gnuplot_commande);                      ds_gnuplot_commande);
           }
 #else  #else
         if ((commande_gnuplot = malloc((1 +          if ((commande_gnuplot = malloc((1 +
                 strlen(ds_gnuplot_commande)) * sizeof(unsigned char)))                  strlen(ds_gnuplot_commande)) * sizeof(unsigned char)))
Line 396  appel_gnuplot(struct_processus *s_etat_p Line 481  appel_gnuplot(struct_processus *s_etat_p
         sprintf(commande_gnuplot, "%s", ds_gnuplot_commande);          sprintf(commande_gnuplot, "%s", ds_gnuplot_commande);
 #endif  #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 =          if (((*s_etat_processus).entree_standard =
                 popen(commande_gnuplot, "w")) == NULL)                  popen(commande_gnuplot, "w")) == NULL)
         {          {
Line 438  appel_gnuplot(struct_processus *s_etat_p Line 531  appel_gnuplot(struct_processus *s_etat_p
         entree_standard = (*s_etat_processus).entree_standard;          entree_standard = (*s_etat_processus).entree_standard;
   
 #ifdef FORCE_GNUPLOT_PATH  #ifdef FORCE_GNUPLOT_PATH
         if ((commande_gnuplot = malloc((strlen(d_exec_path) + 6 +          if ((*s_etat_processus).rpl_home == NULL)
                 strlen(ds_gnuplot_commande)) * sizeof(unsigned char)))  
                 == NULL)  
         {          {
             (*s_etat_processus).erreur_systeme = d_es_allocation_memoire;              if ((commande_gnuplot = malloc((strlen(d_exec_path) + 6 +
             return;                      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,              sprintf(commande_gnuplot, "%s/bin/%s", (*s_etat_processus).rpl_home,
                 ds_gnuplot_commande);                      ds_gnuplot_commande);
           }
 #else  #else
         if ((commande_gnuplot = malloc((1 +          if ((commande_gnuplot = malloc((1 +
                 strlen(ds_gnuplot_commande)) * sizeof(unsigned char)))                  strlen(ds_gnuplot_commande)) * sizeof(unsigned char)))
Line 460  appel_gnuplot(struct_processus *s_etat_p Line 569  appel_gnuplot(struct_processus *s_etat_p
         sprintf(commande_gnuplot, "%s", ds_gnuplot_commande);          sprintf(commande_gnuplot, "%s", ds_gnuplot_commande);
 #endif  #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 =          if (((*s_etat_processus).entree_standard =
                 popen(commande_gnuplot, "w")) == NULL)                  popen(commande_gnuplot, "w")) == NULL)
         {          {
Line 1717  appel_gnuplot(struct_processus *s_etat_p Line 1834  appel_gnuplot(struct_processus *s_etat_p
             return;              return;
         }          }
   
         if (fprintf(fichier_impression, "\\begin{figure}[hp]\n") < 0)          if (tex_fprintf(s_etat_processus, fichier_impression,
                       "\\begin{figure}[hp]\n") < 0)
         {          {
             (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;              (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
             return;              return;
Line 1732  appel_gnuplot(struct_processus *s_etat_p Line 1850  appel_gnuplot(struct_processus *s_etat_p
             }              }
         }          }
   
           if (fclose(fichier_image) != 0)
           {
               (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
               return;
           }
   
         if (strlen((*s_etat_processus).titre) > 0)          if (strlen((*s_etat_processus).titre) > 0)
         {          {
             if (fprintf(fichier_impression, "\\caption{%s}\n",              if (tex_fprintf(s_etat_processus, fichier_impression,
                     (*s_etat_processus).titre) < 0)                      "\\caption{%s}\n", (*s_etat_processus).titre) < 0)
             {              {
                 (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;                  (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
                 return;                  return;
             }              }
         }          }
   
         if (fprintf(fichier_impression, "\\end{figure}\n") < 0)          if (tex_fprintf(s_etat_processus, fichier_impression,
                       "\\end{figure}\n") < 0)
         {          {
             (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;              (*s_etat_processus).erreur_systeme = d_es_erreur_fichier;
             return;              return;

Removed from v.1.1  
changed lines
  Added in v.1.56


CVSweb interface <joel.bertrand@systella.fr>