/* unireadline.c, add readline powers to Unicon tectonics: gcc -o unireadline.so -shared -fpic unireadline.c Unicon usage: readline := loadfunc("./unireadline", "unirl") Dedicated to the public domain Date: September 2016 Modified: 2016-09-07/04:53-0400 */ #include #include #include #include #include "icall.h" int unirl(int argc, descriptor *argv) { static char *line; /* need the string prompt */ if (argc < 1) Error(500); ArgString(1); /* if line already allocated, free it */ if (line) { free(line); line = (char *)NULL; } /* call readline with prompt */ line = readline(StringVal(argv[1])); /* fail when no line read (EOF for instance) or save and return */ if (!line) Fail; if (*line) add_history(line); RetString(line); }