/* readline.C: Readline interface */ /* Taken almost exactly out of the readline sample code. */ #include #include /* Note: The readline include files are not compatable with C++. This fudges enough of thems for things to work. */ extern "C" char* readline(char*); extern "C" void add_history(char*); /* A static variable for holding the line. */ static char *line_read = (char *)NULL; /* Read a string, and return a pointer to it. Returns NULL on EOF. */ char * rl_gets (char* prompt) { /* If the buffer has already been allocated, return the memory to the free pool. */ if (line_read) { free (line_read); line_read = (char *)NULL; } /* Get a line from the user. */ line_read = readline (prompt); /* If the line has any text in it, save it on the history. */ if (line_read && *line_read) add_history (line_read); return (line_read); }