]> mj.ucw.cz Git - libucw.git/blobdiff - ucw/mainloop.h
UCW::CGI: Let url_param_escape() encode non-ASCII characters
[libucw.git] / ucw / mainloop.h
index 336439beed7ed0cc881d628d581dd34c51e9f601..5669e22e38ff27babcb6578675414db03ae2ba1a 100644 (file)
 #ifndef _UCW_MAINLOOP_H
 #define _UCW_MAINLOOP_H
 
 #ifndef _UCW_MAINLOOP_H
 #define _UCW_MAINLOOP_H
 
-#include "ucw/clists.h"
-#include "ucw/process.h"
+#include <ucw/clists.h>
+#include <ucw/process.h>
 
 #include <signal.h>
 
 
 #include <signal.h>
 
+#ifdef CONFIG_UCW_CLEAN_ABI
+#define block_io_add ucw_block_io_add
+#define block_io_del ucw_block_io_del
+#define block_io_read ucw_block_io_read
+#define block_io_set_timeout ucw_block_io_set_timeout
+#define block_io_write ucw_block_io_write
+#define file_add ucw_file_add
+#define file_chg ucw_file_chg
+#define file_debug ucw_file_debug
+#define file_del ucw_file_del
+#define hook_add ucw_hook_add
+#define hook_debug ucw_hook_debug
+#define hook_del ucw_hook_del
+#define main_cleanup ucw_main_cleanup
+#define main_current ucw_main_current
+#define main_debug_context ucw_main_debug_context
+#define main_delete ucw_main_delete
+#define main_destroy ucw_main_destroy
+#define main_get_time ucw_main_get_time
+#define main_init ucw_main_init
+#define main_loop ucw_main_loop
+#define main_new ucw_main_new
+#define main_step ucw_main_step
+#define main_switch_context ucw_main_switch_context
+#define main_teardown ucw_main_teardown
+#define process_add ucw_process_add
+#define process_debug ucw_process_debug
+#define process_del ucw_process_del
+#define process_fork ucw_process_fork
+#define rec_io_add ucw_rec_io_add
+#define rec_io_del ucw_rec_io_del
+#define rec_io_parse_line ucw_rec_io_parse_line
+#define rec_io_set_timeout ucw_rec_io_set_timeout
+#define rec_io_start_read ucw_rec_io_start_read
+#define rec_io_stop_read ucw_rec_io_stop_read
+#define rec_io_write ucw_rec_io_write
+#define signal_add ucw_signal_add
+#define signal_debug ucw_signal_debug
+#define signal_del ucw_signal_del
+#define timer_add ucw_timer_add
+#define timer_add_rel ucw_timer_add_rel
+#define timer_debug ucw_timer_debug
+#define timer_del ucw_timer_del
+#endif
+
 /***
  * [[basic]]
  * Basic operations
 /***
  * [[basic]]
  * Basic operations
@@ -25,8 +70,7 @@
 
 /** The main loop context **/
 struct main_context {
 
 /** The main loop context **/
 struct main_context {
-  timestamp_t now;                     /* [*] Current time in milliseconds since the UNIX epoch. See main_get_time(). */
-  ucw_time_t now_seconds;              /* [*] Current time in seconds since the epoch. */
+  timestamp_t now;                     /* [*] Current time in milliseconds since an unknown epoch. See main_get_time(). */
   timestamp_t idle_time;               /* [*] Total time in milliseconds spent by waiting for events. */
   uns shutdown;                                /* [*] Setting this to nonzero forces the main_loop() function to terminate. */
   clist file_list;
   timestamp_t idle_time;               /* [*] Total time in milliseconds spent by waiting for events. */
   uns shutdown;                                /* [*] Setting this to nonzero forces the main_loop() function to terminate. */
   clist file_list;
@@ -112,12 +156,11 @@ static inline void main_shut_down(void)
 
 /**
  * Show the current state of a given context (use @main_debug() for the current context).
 
 /**
  * Show the current state of a given context (use @main_debug() for the current context).
- * Available only if LibUCW has been compiled with `CONFIG_DEBUG`.
+ * Available only if LibUCW has been compiled with `CONFIG_UCW_DEBUG`.
  **/
 void main_debug_context(struct main_context *m);
 
  **/
 void main_debug_context(struct main_context *m);
 
-static inline void
-main_debug(void)
+static inline void main_debug(void)
 {
   main_debug_context(main_current());
 }
 {
   main_debug_context(main_current());
 }
@@ -144,12 +187,6 @@ static inline timestamp_t main_get_now(void)
   return main_current()->now;
 }
 
   return main_current()->now;
 }
 
-/** An analog of @main_get_now() returning the number of seconds since the system epoch. **/
-static inline ucw_time_t main_get_now_seconds(void)
-{
-  return main_current()->now_seconds;
-}
-
 /**
  * This is a description of a timer.
  * You define the handler function and possibly user-defined data you wish
 /**
  * This is a description of a timer.
  * You define the handler function and possibly user-defined data you wish
@@ -169,7 +206,8 @@ struct main_timer {
  * timer. It is permitted (and usual) to call this function from the
  * timer's handler itself if you want the timer to trigger again.
  *
  * timer. It is permitted (and usual) to call this function from the
  * timer's handler itself if you want the timer to trigger again.
  *
- * The @expire parameter is absolute, use @timer_add_rel() for a relative version.
+ * The @expire parameter is absolute (in the same time scale as @main_get_now()),
+ * use @timer_add_rel() for a relative version.
  **/
 void timer_add(struct main_timer *tm, timestamp_t expires);
 
  **/
 void timer_add(struct main_timer *tm, timestamp_t expires);
 
@@ -197,7 +235,7 @@ static inline int timer_is_active(struct main_timer *tm)
  **/
 void main_get_time(void);
 
  **/
 void main_get_time(void);
 
-/** Show current state of a timer. Available only if LibUCW has been compiled with `CONFIG_DEBUG`. **/
+/** Show current state of a timer. Available only if LibUCW has been compiled with `CONFIG_UCW_DEBUG`. **/
 void timer_debug(struct main_timer *tm);
 
 /***
 void timer_debug(struct main_timer *tm);
 
 /***
@@ -266,7 +304,7 @@ static inline int hook_is_active(struct main_hook *ho)
   return clist_is_linked(&ho->n);
 }
 
   return clist_is_linked(&ho->n);
 }
 
-/** Show current state of a hook. Available only if LibUCW has been compiled with `CONFIG_DEBUG`. **/
+/** Show current state of a hook. Available only if LibUCW has been compiled with `CONFIG_UCW_DEBUG`. **/
 void hook_debug(struct main_hook *ho);
 
 
 void hook_debug(struct main_hook *ho);
 
 
@@ -353,7 +391,7 @@ static inline int file_is_active(struct main_file *fi)
   return clist_is_linked(&fi->n);
 }
 
   return clist_is_linked(&fi->n);
 }
 
-/** Show current state of a file. Available only if LibUCW has been compiled with `CONFIG_DEBUG`. **/
+/** Show current state of a file. Available only if LibUCW has been compiled with `CONFIG_UCW_DEBUG`. **/
 void file_debug(struct main_file *fi);
 
 /***
 void file_debug(struct main_file *fi);
 
 /***
@@ -540,7 +578,7 @@ void rec_io_start_read(struct main_rec_io *rio);
 void rec_io_stop_read(struct main_rec_io *rio);
 
 /** Analogous to @block_io_set_timeout(). **/
 void rec_io_stop_read(struct main_rec_io *rio);
 
 /** Analogous to @block_io_set_timeout(). **/
-void rec_io_set_timeout(struct main_rec_io *bio, timestamp_t expires_delta);
+void rec_io_set_timeout(struct main_rec_io *rio, timestamp_t expires_delta);
 
 void rec_io_write(struct main_rec_io *rio, void *data, uns len);
 
 
 void rec_io_write(struct main_rec_io *rio, void *data, uns len);
 
@@ -638,7 +676,7 @@ static inline int process_is_active(struct main_process *mp)
   return clist_is_linked(&mp->n);
 }
 
   return clist_is_linked(&mp->n);
 }
 
-/** Show current state of a process. Available only if LibUCW has been compiled with `CONFIG_DEBUG`. **/
+/** Show current state of a process. Available only if LibUCW has been compiled with `CONFIG_UCW_DEBUG`. **/
 void process_debug(struct main_process *pr);
 
 /***
 void process_debug(struct main_process *pr);
 
 /***
@@ -687,7 +725,7 @@ static inline int signal_is_active(struct main_signal *ms)
   return clist_is_linked(&ms->n);
 }
 
   return clist_is_linked(&ms->n);
 }
 
-/** Show current state of a signal catcher. Available only if LibUCW has been compiled with `CONFIG_DEBUG`. **/
+/** Show current state of a signal catcher. Available only if LibUCW has been compiled with `CONFIG_UCW_DEBUG`. **/
 void signal_debug(struct main_signal *sg);
 
 #endif
 void signal_debug(struct main_signal *sg);
 
 #endif