]> mj.ucw.cz Git - libucw.git/blobdiff - lib/mainloop.h
Merge with git+ssh://cvs.ucw.cz/projects/sherlock/GIT/sherlock.git#dev-make
[libucw.git] / lib / mainloop.h
index 1e1adf38a1ad62887340711ded51e4d0d700294d..aca8914fce9671fb27c3e30457c307410ca65013 100644 (file)
@@ -7,6 +7,9 @@
  *     of the GNU Lesser General Public License.
  */
 
+#ifndef _UCW_MAINLOOP_H
+#define _UCW_MAINLOOP_H
+
 #include "lib/clists.h"
 
 typedef s64 timestamp_t;                       /* We measure time in milliseconds */
@@ -68,10 +71,17 @@ void file_close_all(void);                  /* Close all known main_file's; frequently used bef
 
 struct main_hook {
   cnode n;
-  int (*handler)(struct main_hook *ho);                /* [*] Hook function; returns 1 if should be called again */
+  int (*handler)(struct main_hook *ho);                /* [*] Hook function; returns HOOK_xxx */
   void *data;                                  /* [*] For use by the handler */
 };
 
+enum main_hook_return {
+  HOOK_IDLE,                                   /* Call again when the main loop becomes idle again */
+  HOOK_RETRY,                                  /* Call again as soon as possible */
+  HOOK_DONE = -1,                              /* Shut down the main loop if all hooks return this value */
+  HOOK_SHUTDOWN = -2                           /* Shut down the main loop immediately */
+};
+
 void hook_add(struct main_hook *ho);
 void hook_del(struct main_hook *ho);
 
@@ -81,7 +91,7 @@ struct main_process {
   cnode n;
   int pid;                                     /* Process id (0=not running) */
   int status;                                  /* Exit status (-1=fork failed) */
-  byte status_msg[EXIT_STATUS_MSG_SIZE];
+  char status_msg[EXIT_STATUS_MSG_SIZE];
   void (*handler)(struct main_process *mp);    /* [*] Called when the process exits; process_del done automatically */
   void *data;                                  /* [*] For use by the handler */
 };
@@ -95,3 +105,5 @@ int process_fork(struct main_process *mp);
 void main_init(void);
 void main_loop(void);
 void main_debug(void);
+
+#endif