*** misc.c	Wed May  5 12:19:19 1993
--- misc.c.new	Wed May  5 12:19:19 1993
***************
*** 36,44 ****
--- 36,50 ----
   *  info-gnuplot-request@ames.arc.nasa.gov.  
   * Send bug reports to
   *  bug-gnuplot@ames.arc.nasa.gov.
+  *
+  * History:  23-APR-93 -Dave Walton- Added IPC stuff
   */
  
  #include <stdio.h>
+ #include <sys/types.h>
+ #include <sys/ipc.h>
+ #include <sys/msg.h>
+ #include <string.h>
  #include <math.h>
  #include "plot.h"
  #include "setshow.h"
***************
*** 681,686 ****
--- 687,747 ----
  
      /* pop state */
      (void) lf_pop();		/* also closes file fp */
+ }
+ 
+ pipe_receive_commands()
+ {
+   register int len;
+   extern char input_line[];
+   register int c;
+   int choice;
+   register int i;
+   int msgflg;
+   struct msgbuf *msgp;
+   struct msqid_ds buf;
+   int msgsz;
+   long msgtyp;
+   int msqid;
+   int maxmsgsz;
+   int rtrn;
+ 
+   interactive = FALSE; /* Make sure we're not interactive */
+ 
+   if ((msqid = msgget(ftok("/tmp",'A'),0)) == -1)
+   {
+     perror("msgget failed");
+     exit(1);
+   }
+ 
+   maxmsgsz = 256;
+   msgp = (struct msgbuf *)malloc((unsigned)sizeof(struct msgbuf) -
+     sizeof(msgp->mtext)+ maxmsgsz);
+   if (msgp == NULL)
+   {
+     printf ("Error allocating memory\n");
+     exit(1);
+   }
+ 
+   msgsz = 256;
+   msgtyp = 1;
+   msgflg = MSG_NOERROR;
+   do
+   {
+     rtrn = msgrcv(msqid,msgp,msgsz,msgtyp,msgflg);
+     if (rtrn == -1)
+       perror("msgrcv failed");
+     else
+     {
+       strncpy(input_line,msgp->mtext,rtrn);
+       input_line[rtrn] = NULL;
+       len=rtrn;
+       if (rtrn > 0)
+       {
+ 	screen_ok = FALSE; /* Make sure command line is echoed on error */
+ 	do_line();
+       }
+     }   
+   } while (strcmp(input_line,"quit") != 0);
  }
  
  /* pop from load_file state stack */
*** plot.c	Wed May  5 12:19:23 1993
--- plot.c.new	Wed May  5 12:19:23 1993
***************
*** 36,44 ****
--- 36,47 ----
   *  info-gnuplot-request@ames.arc.nasa.gov.  
   * Send bug reports to
   *  bug-gnuplot@ames.arc.nasa.gov.
+  *
+  * History:  24-APR-93 -Dave Walton- Added IPC mode
   */
  
  #include <stdio.h>
+ #include <string.h>
  #include <setjmp.h>
  #include <signal.h>
  #include "plot.h"
***************
*** 70,75 ****
--- 73,80 ----
  
  BOOLEAN interactive = TRUE;	/* FALSE if stdin not a terminal */
  BOOLEAN noinputfiles = TRUE;	/* FALSE if there are script files */
+ BOOLEAN ipcmode = FALSE;        /* TRUE if we're using inter-process
+ 				     communication */
  char *infile_name = NULL;	/* name of command file; NULL if terminal */
  
  #ifndef STDOUT
***************
*** 242,248 ****
       interactive = isatty(fileno(stdin));
  #endif
       if (argc > 1)
! 	  interactive = noinputfiles = FALSE;
       else
  	  noinputfiles = TRUE;
  
--- 247,257 ----
       interactive = isatty(fileno(stdin));
  #endif
       if (argc > 1)
!      {
!        interactive = noinputfiles = FALSE;
!        if ((argc == 2) && (strcmp(argv[1],"-ipc") == 0))
! 	 ipcmode = TRUE;
!      }
       else
  	  noinputfiles = TRUE;
  
***************
*** 283,289 ****
  		 done(IO_ERROR);			/* exit on non-interactive error */
  	}
  
!      if (argc > 1) {
  	    /* load filenames given as arguments */
  	    while (--argc > 0) {
  		   ++argv;
--- 292,306 ----
  		 done(IO_ERROR);			/* exit on non-interactive error */
  	}
  
!      if (argc > 1) 
!      {
!        if (ipcmode)
!        {
! 	 /* Get commands from the pipe */
! 	 pipe_receive_commands();
!        }
!        else
!        {
  	    /* load filenames given as arguments */
  	    while (--argc > 0) {
  		   ++argv;
***************
*** 290,296 ****
  		   c_token = NO_CARET; /* in case of file not found */
  		   load_file(fopen(*argv,"r"), *argv);	
  	    }
! 	} else {
  	    /* take commands from stdin */
  	    while(TRUE)
  		 com_line();
--- 307,314 ----
  		   c_token = NO_CARET; /* in case of file not found */
  		   load_file(fopen(*argv,"r"), *argv);	
  	    }
!        }
!      } else {
  	    /* take commands from stdin */
  	    while(TRUE)
  		 com_line();
