2008-06-29 11:04:06 +00:00
|
|
|
#ifndef _LIGHTTPD_ACTIONS_H_
|
|
|
|
#define _LIGHTTPD_ACTIONS_H_
|
|
|
|
|
2008-10-28 21:11:50 +00:00
|
|
|
#ifndef _LIGHTTPD_BASE_H_
|
2008-11-16 20:33:53 +00:00
|
|
|
#error Please include <lighttpd/base.h> instead of this file
|
2008-10-28 21:11:50 +00:00
|
|
|
#endif
|
2008-06-30 10:25:01 +00:00
|
|
|
|
2009-07-08 19:06:07 +00:00
|
|
|
struct liActionRegexStackElement {
|
2009-06-05 17:07:48 +00:00
|
|
|
GString *string;
|
|
|
|
GMatchInfo *match_info;
|
|
|
|
};
|
|
|
|
|
2009-07-08 19:06:07 +00:00
|
|
|
struct liActionStack {
|
2008-06-30 10:25:01 +00:00
|
|
|
GArray* stack;
|
2009-06-05 17:07:48 +00:00
|
|
|
GArray* regex_stack;
|
2008-12-31 01:57:27 +00:00
|
|
|
gboolean backend_failed;
|
2009-07-08 19:06:07 +00:00
|
|
|
liBackendError backend_error;
|
2008-06-30 10:25:01 +00:00
|
|
|
};
|
2008-06-29 11:04:06 +00:00
|
|
|
|
2008-12-09 23:23:27 +00:00
|
|
|
/* param is the param registered with the callbacks;
|
|
|
|
* in context the function can save extra data (like data for the stat-call)
|
|
|
|
* If the context gets popped from the action stack and context is not zero,
|
|
|
|
* the cleanup callback gets called.
|
|
|
|
* you should not use *context without a cleanup callback!!!
|
|
|
|
*/
|
2009-07-08 19:06:07 +00:00
|
|
|
typedef liHandlerResult (*liActionFuncCB)(liVRequest *vr, gpointer param, gpointer *context);
|
|
|
|
typedef liHandlerResult (*liActionCleanupCB)(liVRequest *vr, gpointer param, gpointer context);
|
|
|
|
typedef void (*liActionFreeCB)(liServer *srv, gpointer param);
|
|
|
|
|
|
|
|
struct liActionFunc {
|
|
|
|
liActionFuncCB func;
|
|
|
|
liActionCleanupCB cleanup;
|
|
|
|
liActionFreeCB free;
|
2008-07-23 19:34:19 +00:00
|
|
|
gpointer param;
|
|
|
|
};
|
2009-07-08 19:06:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
typedef liHandlerResult (*liBackendSelectCB)(liVRequest *vr, gboolean backlog_provided, gpointer param, gpointer *context);
|
|
|
|
typedef liHandlerResult (*liBackendFallbackCB)(liVRequest *vr, gboolean backlog_provided, gpointer param, gpointer *context, liBackendError error);
|
|
|
|
typedef liHandlerResult (*liBackendFinishedCB)(liVRequest *vr, gpointer param, gpointer context);
|
|
|
|
typedef void (*liBalancerFreeCB)(liServer *srv, gpointer param);
|
|
|
|
|
|
|
|
struct liBalancerFunc {
|
|
|
|
liBackendSelectCB select;
|
|
|
|
liBackendFallbackCB fallback;
|
|
|
|
liBackendFinishedCB finished;
|
|
|
|
liBalancerFreeCB free;
|
2008-12-30 20:55:00 +00:00
|
|
|
gpointer param;
|
|
|
|
gboolean provide_backlog;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-07-08 19:06:07 +00:00
|
|
|
struct liAction {
|
2008-06-30 10:25:01 +00:00
|
|
|
gint refcount;
|
2009-07-08 19:06:07 +00:00
|
|
|
liActionType type;
|
2008-06-29 11:04:06 +00:00
|
|
|
|
2008-06-29 15:48:28 +00:00
|
|
|
union {
|
2009-07-08 19:06:07 +00:00
|
|
|
liOptionSet setting;
|
2008-06-29 11:55:11 +00:00
|
|
|
|
2008-06-30 10:25:01 +00:00
|
|
|
struct {
|
2009-07-08 19:06:07 +00:00
|
|
|
liCondition *cond;
|
|
|
|
liAction *target; /** action target to jump to if condition is fulfilled */
|
|
|
|
liAction *target_else; /** like above but if condition is not fulfilled */
|
2008-06-30 10:25:01 +00:00
|
|
|
} condition;
|
2008-06-29 11:55:11 +00:00
|
|
|
|
2009-07-08 19:06:07 +00:00
|
|
|
liActionFunc function;
|
2008-07-24 11:25:40 +00:00
|
|
|
|
2008-08-03 20:20:36 +00:00
|
|
|
GArray* list; /** array of (action*) */
|
2008-12-30 20:55:00 +00:00
|
|
|
|
2009-07-08 19:06:07 +00:00
|
|
|
liBalancerFunc balancer;
|
2008-09-26 14:11:08 +00:00
|
|
|
} data;
|
2008-06-29 11:04:06 +00:00
|
|
|
};
|
|
|
|
|
2008-06-30 10:25:01 +00:00
|
|
|
/* no new/free function, so just use the struct direct (i.e. not a pointer) */
|
2009-07-09 20:17:24 +00:00
|
|
|
LI_API void li_action_stack_init(liActionStack *as);
|
|
|
|
LI_API void li_action_stack_reset(liVRequest *vr, liActionStack *as);
|
|
|
|
LI_API void li_action_stack_clear(liVRequest *vr, liActionStack *as);
|
2008-06-29 11:04:06 +00:00
|
|
|
|
2008-06-30 10:25:01 +00:00
|
|
|
/** handle sublist now, remember current position (stack) */
|
2009-07-09 20:17:24 +00:00
|
|
|
LI_API void li_action_enter(liVRequest *vr, liAction *a);
|
|
|
|
LI_API liHandlerResult li_action_execute(liVRequest *vr);
|
2008-06-29 11:04:06 +00:00
|
|
|
|
2008-07-17 19:39:29 +00:00
|
|
|
|
2009-07-09 20:17:24 +00:00
|
|
|
LI_API void li_action_release(liServer *srv, liAction *a);
|
|
|
|
LI_API void li_action_acquire(liAction *a);
|
2008-07-17 19:39:29 +00:00
|
|
|
/* create new action */
|
2009-07-09 20:17:24 +00:00
|
|
|
LI_API liAction *li_action_new_setting(liOptionSet setting);
|
|
|
|
LI_API liAction *li_action_new_function(liActionFuncCB func, liActionCleanupCB fcleanup, liActionFreeCB ffree, gpointer param);
|
|
|
|
LI_API liAction *li_action_new_list();
|
|
|
|
LI_API liAction *li_action_new_condition(liCondition *cond, liAction *target, liAction *target_else);
|
|
|
|
LI_API liAction *li_action_new_balancer(liBackendSelectCB bselect, liBackendFallbackCB bfallback, liBackendFinishedCB bfinished, liBalancerFreeCB bfree, gpointer param, gboolean provide_backlog);
|
2008-08-03 20:20:36 +00:00
|
|
|
|
2008-06-29 11:04:06 +00:00
|
|
|
#endif
|