#include <histedit.h>
#include <stdint.h>
#include <errno.h>
const char *shim_el_gets(EditLine *el, int *count, int *err) {
errno = 0;
const char *line = el_gets(el, count);
*err = errno;
return line;
}
int shim_el_set(EditLine *el, int op, uintptr_t arg) {
return el_set(el, op, (void *)arg);
}
int shim_el_get(EditLine *el, int op, uintptr_t *arg) {
return el_get(el, op, (void **)arg);
}
int shim_el_set_clientdata(EditLine *el, void *data) {
return el_set(el, EL_CLIENTDATA, data);
}
typedef char *(*shim_prompt_fn)(EditLine *);
int shim_el_set_prompt_esc_fn(EditLine *el, shim_prompt_fn fn, char delim) {
return el_wset(el, EL_PROMPT_ESC, fn, (wchar_t)delim);
}
int shim_el_set_rprompt_esc_fn(EditLine *el, shim_prompt_fn fn, char delim) {
return el_wset(el, EL_RPROMPT_ESC, fn, (wchar_t)delim);
}
typedef unsigned char (*shim_el_fn)(EditLine *, int);
int shim_el_addfn(EditLine *el, const char *name, const char *help, shim_el_fn fn) {
return el_set(el, EL_ADDFN, name, help, fn);
}
int shim_el_bind(EditLine *el, const char *key, const char *fnname) {
return el_set(el, EL_BIND, key, fnname, (char *)NULL);
}
typedef int (*shim_getcfn)(EditLine *, wchar_t *);
int shim_el_set_getcfn(EditLine *el, shim_getcfn fn) {
return el_set(el, EL_GETCFN, fn);
}
int shim_el_set_hist(EditLine *el, History *h) {
return el_set(el, EL_HIST, history, h);
}
int shim_history_enter(History *h, HistEvent *ev, const char *s) {
return history(h, ev, H_ENTER, s);
}
int shim_history_first(History *h, HistEvent *ev) {
return history(h, ev, H_FIRST);
}
int shim_history_getsize(History *h, HistEvent *ev) {
return history(h, ev, H_GETSIZE);
}
int shim_history_setsize(History *h, HistEvent *ev, int n) {
return history(h, ev, H_SETSIZE, n);
}
int shim_history_setunique(History *h, HistEvent *ev, int unique) {
return history(h, ev, H_SETUNIQUE, unique);
}
int shim_history_clear(History *h, HistEvent *ev) {
return history(h, ev, H_CLEAR);
}
int shim_history_load(History *h, HistEvent *ev, const char *path) {
return history(h, ev, H_LOAD, path);
}
int shim_history_save(History *h, HistEvent *ev, const char *path) {
return history(h, ev, H_SAVE, path);
}