You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lighttpd2/include/lighttpd/actions.h

76 lines
2.1 KiB

15 years ago
#ifndef _LIGHTTPD_ACTIONS_H_
#define _LIGHTTPD_ACTIONS_H_
#ifndef _LIGHTTPD_BASE_H_
#error Please include <lighttpd/base.h> instead of this file
#endif
15 years ago
/* action type */
15 years ago
typedef enum {
ACTION_TSETTING,
ACTION_TFUNCTION,
ACTION_TCONDITION,
ACTION_TLIST
15 years ago
} action_type;
15 years ago
15 years ago
struct action_stack {
GArray* stack;
};
15 years ago
/* 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 handler_t (*ActionFunc)(vrequest *vr, gpointer param, gpointer *context);
typedef handler_t (*ActionCleanup)(vrequest *vr, gpointer param, gpointer context);
typedef void (*ActionFree)(server *srv, gpointer param);
struct action_func {
ActionFunc func;
ActionCleanup cleanup;
ActionFree free;
gpointer param;
};
typedef struct action_func action_func;
15 years ago
15 years ago
struct action {
15 years ago
gint refcount;
15 years ago
action_type type;
15 years ago
union {
option_set setting;
15 years ago
15 years ago
struct {
condition *cond;
action *target; /** action target to jump to if condition is fulfilled */
action *target_else; /** like above but if condition is not fulfilled */
15 years ago
} condition;
15 years ago
action_func function;
GArray* list; /** array of (action*) */
} data;
15 years ago
};
15 years ago
/* no new/free function, so just use the struct direct (i.e. not a pointer) */
LI_API void action_stack_init(action_stack *as);
LI_API void action_stack_reset(vrequest *vr, action_stack *as);
LI_API void action_stack_clear(vrequest *vr, action_stack *as);
15 years ago
15 years ago
/** handle sublist now, remember current position (stack) */
LI_API void action_enter(struct vrequest *vr, action *a);
LI_API handler_t action_execute(struct vrequest *vr);
15 years ago
LI_API void action_release(server *srv, action *a);
LI_API void action_acquire(action *a);
/* create new action */
LI_API action *action_new_setting(option_set setting);
LI_API action *action_new_function(ActionFunc func, ActionCleanup fcleanup, ActionFree ffree, gpointer param);
LI_API action *action_new_list();
LI_API action *action_new_condition(condition *cond, action *target, action *target_else);
15 years ago
#endif