Re: [ng-spice] Readline Response
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: