src/console.h
changeset 93 42ade8285570
parent 92 99661e5aac91
child 137 c607c357c486
--- a/src/console.h	Tue Mar 31 15:41:24 2009 +0300
+++ b/src/console.h	Tue Mar 31 19:35:51 2009 +0300
@@ -19,8 +19,12 @@
  * Callbacks for event-based actions
  */
 struct console_callbacks {
-    /** A line was read from the console */
-    void (*on_line) (char *line, void *arg);
+    /**
+     * A line was read from the console. 
+     *
+     * XXX: currently, line might be NULL on EOF, but this is probably a second callback
+     */
+    void (*on_line) (const char *line, void *arg);
 };
 
 /**
@@ -32,7 +36,9 @@
 };
 
 /**
- * The console state...
+ * The console state.
+ *
+ * You may replace the callbacks/cb_arg field with a new one at any time, using console_set_callbacks().
  */
 struct console {
     /** The input event */
@@ -49,12 +55,24 @@
 };
 
 /**
- * Initialize the console, setting up the TTY and input handler
+ * Initialize the console, setting up the TTY and input handler.
+ *
+ * @param console_ptr returned new console struct
+ * @param ev_base the libevent base to use
+ * @param config configuration things for the console
+ * @param callbacks optional callbacks, can be updated later
+ * @param cb_arg option callback argument, can be updated later
+ * @param err returned error info
  */
 err_t console_init (struct console **console_ptr, struct event_base *ev_base, const struct console_config *config,
         const struct console_callbacks *callbacks, void *cb_arg, struct error_info *err);
 
 /**
+ * Replace the current callbacks with the given new ones.
+ */
+void console_set_callbacks (struct console *console, const struct console_callbacks *callbacks, void *cb_arg);
+
+/**
  * Deinitialize the console, restoring the TTY and releasing resources
  */
 void console_destroy (struct console *console);