diff --git a/src/iocsh/epicsReadline.c b/src/iocsh/epicsReadline.c new file mode 100644 index 000000000..b6cd6a3be --- /dev/null +++ b/src/iocsh/epicsReadline.c @@ -0,0 +1,49 @@ +/* epicsReadline.c */ +/* Author: Eric Norum Date: 18DEC2000 */ + +/* + * Wrappers around readline calls to work around the fact that + * on many machines readline.h declares functions with old-style + * (i.e. non-prototype) syntax. The old syntax is incompatible + * with C++. + */ + +#include +#include "epicsReadline.h" + +#ifdef IOCSH_USE_READLINE + +#include +#include + +#else + +/* + * Fake versions of some readline/history routines + */ +#define readline(p) do { } while(0) +#define stifle_history(n) do { } while(0) +#define add_history(l) do { } while(0) +#define rl_bind_key(c,f) do { } while(0) + +#endif + +char *epics_readline (const char *prompt) +{ + return readline (prompt); +} + +void epics_stifle_history (int n) +{ + stifle_history (n); +} + +void epics_add_history (const char *line) +{ + add_history (line); +} + +void epics_bind_keys (void) +{ + rl_bind_key ('\t', rl_insert); +} diff --git a/src/iocsh/epicsReadline.h b/src/iocsh/epicsReadline.h new file mode 100644 index 000000000..1355d786c --- /dev/null +++ b/src/iocsh/epicsReadline.h @@ -0,0 +1,29 @@ +/* epicsReadline.h */ +/* Author: Eric Norum Date: 18DEC2000 */ + +/* + * Wrappers around readline calls to work around the fact that + * on many machines readline.h declares functions with old-style + * (i.e. non-prototype) syntax. The old syntax is incompatible + * with C++. + */ + +#ifndef _EPICS_READLINE_H_ +#define _EPICS_READLINE_H_ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +epicsShareFunc char * epicsShareAPI epics_readline (const char *prompt); +epicsShareFunc void epicsShareAPI epics_stifle_history (int n); +epicsShareFunc void epicsShareAPI epics_add_history (const char *line); +epicsShareFunc void epicsShareAPI epics_bind_keys (void); + +#ifdef __cplusplus +} +#endif + +#endif /* _EPICS_READLINE_H_ */