}
else if (ret == RDLINE_RES_EOF)
return -1;
+ else if (ret == RDLINE_RES_EXITED)
+ return -1;
}
return i;
}
+void
+cmdline_quit(struct cmdline *cl)
+{
+ rdline_quit(&cl->rdl);
+}
+
void
cmdline_interact(struct cmdline *cl)
{
int cmdline_in(struct cmdline *cl, const char *buf, int size);
void cmdline_write_char(struct rdline *rdl, char c);
void cmdline_interact(struct cmdline *cl);
+void cmdline_quit(struct cmdline *cl);
#endif /* _CMDLINE_SOCKET_H_ */
rdl->status = RDLINE_INIT;
}
+void
+rdline_quit(struct rdline *rdl)
+{
+ rdl->status = RDLINE_EXITED;
+}
+
void
rdline_restart(struct rdline *rdl)
{
char *buf;
#endif
+ if (rdl->status == RDLINE_EXITED)
+ return RDLINE_RES_EXITED;
if (rdl->status != RDLINE_RUNNING)
return RDLINE_RES_NOT_RUNNING;
if (rdl->validate)
rdl->validate(rdl, rdl->left_buf, CIRBUF_GET_LEN(&rdl->left)+2);
+ /* user may have stopped rdline */
+ if (rdl->status == RDLINE_EXITED)
+ return RDLINE_RES_EXITED;
return RDLINE_RES_VALIDATED;
#ifndef NO_RDLINE_HISTORY
enum rdline_status {
RDLINE_INIT,
- RDLINE_RUNNING
+ RDLINE_RUNNING,
+ RDLINE_EXITED
};
struct rdline;
void rdline_stop(struct rdline *rdl);
/**
- * Restart after a call to rdline_stop()
+ * Same than rdline_stop() except that next calls to rdline_char_in()
+ * will return RDLINE_RES_EXITED.
+ * \param rdl A pointer to a struct rdline
+ */
+void rdline_quit(struct rdline *rdl);
+
+/**
+ * Restart after a call to rdline_stop() or rdline_quit()
* \param rdl A pointer to a struct rdline
*/
void rdline_restart(struct rdline *rdl);
#define RDLINE_RES_COMPLETE 2
#define RDLINE_RES_NOT_RUNNING -1
#define RDLINE_RES_EOF -2
+#define RDLINE_RES_EXITED -3
/**
* append a char to the readline buffer.