2
0
Fork 0
lighttpd2/include/lighttpd/actions.h

94 lines
3.1 KiB
C
Raw Normal View History

2008-06-29 11:04:06 +00:00
#ifndef _LIGHTTPD_ACTIONS_H_
#define _LIGHTTPD_ACTIONS_H_
#ifndef _LIGHTTPD_BASE_H_
#error Please include <lighttpd/base.h> instead of this file
#endif
2008-06-30 10:25:01 +00:00
struct liActionRegexStackElement {
GString *string;
GMatchInfo *match_info;
};
struct liActionStack {
2008-06-30 10:25:01 +00:00
GArray* stack;
GArray* regex_stack;
gboolean backend_failed;
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!!!
*/
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;
gpointer param;
};
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;
gpointer param;
gboolean provide_backlog;
};
struct liAction {
2008-06-30 10:25:01 +00:00
gint refcount;
liActionType type;
2008-06-29 11:04:06 +00:00
2008-06-29 15:48:28 +00:00
union {
liOptionSet setting;
2008-06-29 11:55:11 +00:00
2008-06-30 10:25:01 +00:00
struct {
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
liActionFunc function;
2008-08-03 20:20:36 +00:00
GArray* list; /** array of (action*) */
liBalancerFunc balancer;
} 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
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);
/* 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