Re: [ng-spice] Readline Response


To ng-spice@ieee.ing.uniroma1.it
From Arno <A.W.Peters@ieee.org>
Date Fri, 27 Aug 1999 13:48:17 +0200
Delivered-To mailing list ng-spice@ieee.ing.uniroma1.it
In-Reply-To <Pine.LNX.3.96.990827082107.13352B-100000@ieee.ing.uniroma1.it >
Mailing-List contact ng-spice-help@ieee.ing.uniroma1.it; run by ezmlm
References <37C5A9E8.61172643@wanadoo.fr > <Pine.LNX.3.96.990827082107.13352B-100000@ieee.ing.uniroma1.it >
Reply-To ng-spice@ieee.ing.uniroma1.it
User-Agent Mutt/0.95.7i

On Fri, Aug 27, 1999 at 08:27:57AM +0200, Paolo Nenzi wrote:
> On Thu, 26 Aug 1999, Manu Rouat wrote:
> 
> > This means that we would need the readline library to be LGPL'd
> > rather than GPL'd to link ngspice against it (or ngspice to be GPL'd)
>
> Ok, should I write again to Stallman or not, what Manu says is very clear:
> we cannot do it. Is there any replacement for libreadline ?

You can also circumvent the license problem by coding a utility whose
only function is to provide readline functionality.  It opens two
pipes for communication with the ng-spice core program.  When the user
presses Enter, it sends ng-spice a whole line at a time.  The output
from ng-spice is captured using the other pipe.

Following (untested) code snippet shows how:

        int spice_in_pipe[2];
        int spice_out_pipe[2];
        pid_t pid;

        pipe(spice_in_pipe);
        pipe(spice_out_pipe);
        pid = fork();
        if (pid == 0) {
                /* parent */
                FILE *to_spice;
                FILE *from_spice;

                to_spice = open(spice_in_pipe[1]);
                from_spice = open(spice_out_pipe[0]);
                do_readline_loop(to_spice, from_spice);
                close(from_spice);
                close(to_spice);
        } else {
                /* child */
                /* Connect STDIN and STDOUT to pipes */
                dup2(spice_in_pipe[0], STDIN_FILENO);
                dup2(spice_out_pipe[1], STDOUT_FILENO);
                execv(spice_program);
                assert(0);      /* NEVER REACHED */
        }

Regards,
Arno

Partial thread listing: