2
0
Fork 0
lighttpd2/src/actions.h

83 lines
1.9 KiB
C
Raw Normal View History

2008-06-29 11:04:06 +00:00
#ifndef _LIGHTTPD_ACTIONS_H_
#define _LIGHTTPD_ACTIONS_H_
2008-06-30 10:25:01 +00:00
#include "settings.h"
typedef enum {
ACTION_GO_ON,
ACTION_FINISHED,
ACTION_ERROR,
ACTION_WAIT_FOR_EVENT
} action_result;
2008-06-29 14:10:00 +00:00
2008-06-29 11:39:09 +00:00
// action type
2008-06-30 10:25:01 +00:00
typedef enum {
ACTION_TSETTING,
ACTION_TFUNCTION,
ACTION_TCONDITION,
ACTION_TLIST
2008-06-30 10:25:01 +00:00
} action_type;
2008-06-29 11:04:06 +00:00
struct action;
typedef struct action action;
2008-06-29 15:48:28 +00:00
struct action_stack;
typedef struct action_stack action_stack;
2008-06-29 11:04:06 +00:00
2008-06-30 10:25:01 +00:00
struct action_stack {
GArray* stack;
};
2008-06-29 11:04:06 +00:00
2008-06-30 10:25:01 +00:00
struct server; struct connection;
typedef action_result (*ActionFunc)(struct server *srv, struct connection *con, gpointer param);
typedef void (*ActionFree)(struct server *srv, gpointer param);
struct action_func {
ActionFunc func;
ActionFree free;
gpointer param;
};
typedef struct action_func action_func;
2008-06-29 11:04:06 +00:00
2008-06-30 10:25:01 +00:00
#include "condition.h"
2008-07-08 20:38:22 +00:00
#include "plugin.h"
2008-07-15 20:11:53 +00:00
#include "options.h"
2008-06-29 11:04:06 +00:00
2008-06-29 15:48:28 +00:00
struct action {
2008-06-30 10:25:01 +00:00
gint refcount;
2008-06-29 11:04:06 +00:00
action_type type;
2008-06-29 15:48:28 +00:00
union {
2008-07-08 19:29:41 +00:00
option_set setting;
2008-06-29 11:55:11 +00:00
2008-06-30 10:25:01 +00:00
struct {
condition *cond;
2008-08-03 20:20:36 +00:00
action* target; /** action target to jump to if condition is fulfilled */
2008-06-30 10:25:01 +00:00
} condition;
2008-06-29 11:55:11 +00:00
action_func function;
2008-08-03 20:20:36 +00:00
GArray* list; /** array of (action*) */
2008-06-29 11:04:06 +00:00
} value;
};
2008-06-30 10:25:01 +00:00
/* 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(server *srv, action_stack *as);
LI_API void action_stack_clear(server *srv, action_stack *as);
2008-06-29 11:04:06 +00:00
2008-06-30 10:25:01 +00:00
/** handle sublist now, remember current position (stack) */
2008-08-03 20:20:36 +00:00
LI_API void action_enter(connection *con, action *a);
2008-06-30 10:25:01 +00:00
LI_API action_result action_execute(server *srv, connection *con);
2008-06-29 11:04:06 +00:00
LI_API void action_release(server *srv, action *a);
LI_API void action_acquire(action *a);
/* create new action */
2008-08-04 19:28:56 +00:00
LI_API action *action_new_setting(option_set setting);
LI_API action *action_new_function(ActionFunc func, ActionFree free, gpointer param);
LI_API action *action_new_list();
2008-08-03 20:20:36 +00:00
LI_API action *action_new_condition(condition *cond, action *target);
2008-06-29 11:04:06 +00:00
#endif