~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/tools/nmr-segment/t_gnuplot.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2   tina_gnuplot.c
  3 
  4   tina - gnuplot interface code
  5 
  6   a.lacey 21.5.98
  7 
  8 */
  9 
 10 #include <stdio.h>
 11 #include <stdlib.h>
 12 #include <math.h>
 13 #include <string.h>
 14 #include <unistd.h>
 15 #include <sys/types.h>
 16 #include <sys/stat.h>
 17 #include <tina/file.h>
 18 #include <tina/sys.h>
 19 #include <tina/sys_types.h>
 20 #include <tina/sysfuncs.h>
 21 #include <tina/math.h>
 22 #include <tina/mathfuncs.h>
 23 
 24 
 25 static   FILE   *gnu_comm = NULL;
 26 static   FILE   *gnu_data = NULL;
 27 static   char    tname[64] = {"./t_gpipe"};
 28 
 29 
 30 
 31 Bool     open_gnuplot_program_link(char *gpname)
 32 {
 33   if ((gnu_comm = (FILE *)popen(gpname, "w")) == NULL)
 34     return (false);
 35 
 36   return(true);
 37 }
 38 
 39 
 40 Bool    send_gnuplot_comm(char *comm)
 41 {
 42   if ((gnu_comm == NULL) || (comm == NULL))
 43     return(false);
 44 
 45   if (fputs(comm, gnu_comm) == EOF)
 46     return (false);
 47 
 48   fflush(gnu_comm);
 49   return (true);   
 50 }
 51 
 52 
 53 char  *get_gnuplot_tname()
 54 {
 55   return(tname);
 56 }
 57 
 58 
 59 FILE  *open_gnuplot_data_link(char *pl_comm)
 60 {
 61   if (pl_comm == NULL)
 62     return (NULL);
 63 
 64   if (mkfifo(tname, S_IRUSR | S_IWUSR) != 0)
 65     {
 66       unlink(tname);
 67       return(NULL);
 68     }
 69 
 70   send_gnuplot_comm(pl_comm);
 71   fflush(gnu_comm); 
 72 
 73   if ((gnu_data = fopen(tname, "w")) == NULL)
 74     {
 75       unlink(tname);
 76       return(NULL);
 77     }
 78 
 79   return(gnu_data); 
 80 }
 81 
 82 
 83 
 84 void    close_gnuplot_link(void (*func))
 85 {
 86   if (gnu_comm == NULL || gnu_data == NULL)
 87     return;
 88 
 89   fflush(gnu_comm); 
 90   fflush(gnu_data);
 91 
 92   fclose(gnu_data);
 93   if (func != NULL)
 94     ((void (*) ())func)();
 95   pclose(gnu_comm);
 96   unlink(tname);
 97 
 98   gnu_comm = NULL;
 99   gnu_data = NULL;
100 }
101 
102 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.