#ifndef __LINK_H__ #define __LINK_H__ /* link.h * * Link module allows a program to form links to other separately * executing programs and communicate with them. Links can be * opened and closed, and the program using this library can * writeto and read from the other program over the link. * */ typedef struct _link_handle /* holds all info relevant to one link. */ { int pipefd1[2], pipefd2[2]; int pid; FILE *fpin, *fpout; } link_handle; void link_open(link_handle *l, char name[], char param[]); void link_open2(link_handle *l, char name[], const char *params[]); void link_close(link_handle *l); /* Close the link to a program that has terminated. Use link_kill if the program needs to be terminated as well */ int link_read(link_handle *l, char s[]); /* read from the program started with link_open. Returns a 0 if there was stuff to read, or a 1 if the linked program terminated. */ int link_input_waiting(link_handle *l); /* Returns the number of bytes waiting in the input buffer. If 0, then link_read will block if it is called. */ void link_write(link_handle *l, char s[]); /* write a string to the program, with a newline. */ void link_kill(link_handle *); /* kill the program and close the link. If the program has terminated on its own use link_close instead. */ #endif /* __LINK_H__ */