Browse Source

Prefix typenames, enums and some macros with "li" and "LI_"; CamelCase TypeNames

personal/stbuehler/wip
Stefan Bühler 13 years ago
parent
commit
99b203e3d8
  1. 102
      include/lighttpd/actions.h
  2. 4
      include/lighttpd/actions_lua.h
  3. 10
      include/lighttpd/angel.h
  4. 11
      include/lighttpd/angel_base.h
  5. 8
      include/lighttpd/angel_config_parser.h
  6. 66
      include/lighttpd/angel_connection.h
  7. 27
      include/lighttpd/angel_data.h
  8. 71
      include/lighttpd/angel_log.h
  9. 70
      include/lighttpd/angel_plugin.h
  10. 13
      include/lighttpd/angel_plugin_core.h
  11. 56
      include/lighttpd/angel_server.h
  12. 54
      include/lighttpd/angel_value.h
  13. 1
      include/lighttpd/base.h
  14. 106
      include/lighttpd/chunk.h
  15. 30
      include/lighttpd/chunk_parser.h
  16. 26
      include/lighttpd/collect.h
  17. 121
      include/lighttpd/condition.h
  18. 6
      include/lighttpd/condition_lua.h
  19. 2
      include/lighttpd/config_lua.h
  20. 33
      include/lighttpd/config_parser.h
  21. 60
      include/lighttpd/connection.h
  22. 4
      include/lighttpd/encoding.h
  23. 32
      include/lighttpd/environment.h
  24. 8
      include/lighttpd/etag.h
  25. 4
      include/lighttpd/filter_chunked.h
  26. 32
      include/lighttpd/http_headers.h
  27. 19
      include/lighttpd/http_request_parser.h
  28. 19
      include/lighttpd/http_response_parser.h
  29. 14
      include/lighttpd/idlist.h
  30. 6
      include/lighttpd/lighttpd-glue.h
  31. 103
      include/lighttpd/log.h
  32. 30
      include/lighttpd/module.h
  33. 32
      include/lighttpd/network.h
  34. 20
      include/lighttpd/options.h
  35. 100
      include/lighttpd/plugin.h
  36. 26
      include/lighttpd/plugin_core.h
  37. 5
      include/lighttpd/profiler.h
  38. 55
      include/lighttpd/radix.h
  39. 28
      include/lighttpd/request.h
  40. 16
      include/lighttpd/response.h
  41. 54
      include/lighttpd/server.h
  42. 24
      include/lighttpd/stat_cache.h
  43. 12
      include/lighttpd/sys-socket.h
  44. 9
      include/lighttpd/throttle.h
  45. 275
      include/lighttpd/typedefs.h
  46. 4
      include/lighttpd/url_parser.h
  47. 14
      include/lighttpd/utils.h
  48. 38
      include/lighttpd/value.h
  49. 2
      include/lighttpd/value_lua.h
  50. 126
      include/lighttpd/virtualrequest.h
  51. 36
      include/lighttpd/waitqueue.h
  52. 40
      include/lighttpd/worker.h
  53. 119
      src/actions.c
  54. 16
      src/actions_lua.c
  55. 20
      src/angel.c
  56. 28
      src/angel_config_parser.rl
  57. 98
      src/angel_connection.c
  58. 26
      src/angel_data.c
  59. 4
      src/angel_fake.c
  60. 22
      src/angel_log.c
  61. 2
      src/angel_main.c
  62. 80
      src/angel_plugin.c
  63. 54
      src/angel_plugin_core.c
  64. 124
      src/angel_server.c
  65. 118
      src/angel_value.c
  66. 174
      src/chunk.c
  67. 38
      src/chunk_parser.c
  68. 50
      src/collect.c
  69. 484
      src/condition.c
  70. 104
      src/condition_lua.c
  71. 38
      src/config_lua.c
  72. 226
      src/config_parser.rl
  73. 174
      src/connection.c
  74. 3
      src/encoding.c
  75. 26
      src/environment.c
  76. 24
      src/etag.c
  77. 12
      src/filter_chunked.c
  78. 68
      src/http_headers.c
  79. 78
      src/http_request_parser.rl
  80. 32
      src/http_response_parser.rl
  81. 14
      src/idlist.c
  82. 68
      src/lighttpd-glue.c
  83. 10
      src/lighttpd.c
  84. 180
      src/log.c
  85. 50
      src/module.c
  86. 68
      src/modules/mod_access.c
  87. 54
      src/modules/mod_accesslog.c
  88. 52
      src/modules/mod_balancer.c
  89. 93
      src/modules/mod_cache_disk_etag.c
  90. 54
      src/modules/mod_debug.c
  91. 109
      src/modules/mod_dirlist.c
  92. 38
      src/modules/mod_expire.c
  93. 135
      src/modules/mod_fastcgi.c
  94. 39
      src/modules/mod_fortune.c
  95. 85
      src/modules/mod_rewrite.c
  96. 62
      src/modules/mod_status.c
  97. 74
      src/modules/mod_vhost.c
  98. 18
      src/network.c
  99. 58
      src/network_sendfile.c
  100. 22
      src/network_write.c

102
include/lighttpd/actions.h

@ -5,31 +5,16 @@
#error Please include <lighttpd/base.h> instead of this file
#endif
/* action type */
typedef enum {
ACTION_TSETTING,
ACTION_TFUNCTION,
ACTION_TCONDITION,
ACTION_TLIST,
ACTION_TBALANCER
} action_type;
typedef enum {
BACKEND_OVERLOAD,
BACKEND_DEAD
} backend_error;
struct action_regex_stack_element {
struct liActionRegexStackElement {
GString *string;
GMatchInfo *match_info;
};
typedef struct action_regex_stack_element action_regex_stack_element;
struct action_stack {
struct liActionStack {
GArray* stack;
GArray* regex_stack;
gboolean backend_failed;
backend_error backend_error;
liBackendError backend_error;
};
/* param is the param registered with the callbacks;
@ -38,72 +23,71 @@ struct action_stack {
* 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;
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 struct action_func action_func;
typedef handler_t (*BackendSelect)(vrequest *vr, gboolean backlog_provided, gpointer param, gpointer *context);
typedef handler_t (*BackendFallback)(vrequest *vr, gboolean backlog_provided, gpointer param, gpointer *context, backend_error error);
typedef handler_t (*BackendFinished)(vrequest *vr, gpointer param, gpointer context);
typedef void (*BalancerFree)(server *srv, gpointer param);
struct balancer_func {
BackendSelect select;
BackendFallback fallback;
BackendFinished finished;
BalancerFree free;
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;
};
typedef struct balancer_func balancer_func;
struct action {
struct liAction {
gint refcount;
action_type type;
liActionType type;
union {
option_set setting;
liOptionSet setting;
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 */
liCondition *cond;
liAction *target; /** action target to jump to if condition is fulfilled */
liAction *target_else; /** like above but if condition is not fulfilled */
} condition;
action_func function;
liActionFunc function;
GArray* list; /** array of (action*) */
balancer_func balancer;
liBalancerFunc balancer;
} data;
};
/* 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);
LI_API void action_stack_init(liActionStack *as);
LI_API void action_stack_reset(liVRequest *vr, liActionStack *as);
LI_API void action_stack_clear(liVRequest *vr, liActionStack *as);
/** 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);
LI_API void action_enter(liVRequest *vr, liAction *a);
LI_API liHandlerResult action_execute(liVRequest *vr);
LI_API void action_release(server *srv, action *a);
LI_API void action_acquire(action *a);
LI_API void action_release(liServer *srv, liAction *a);
LI_API void action_acquire(liAction *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);
LI_API action *action_new_balancer(BackendSelect bselect, BackendFallback bfallback, BackendFinished bfinished, BalancerFree bfree, gpointer param, gboolean provide_backlog);
LI_API liAction *action_new_setting(liOptionSet setting);
LI_API liAction *action_new_function(liActionFuncCB func, liActionCleanupCB fcleanup, liActionFreeCB ffree, gpointer param);
LI_API liAction *action_new_list();
LI_API liAction *action_new_condition(liCondition *cond, liAction *target, liAction *target_else);
LI_API liAction *action_new_balancer(liBackendSelectCB bselect, liBackendFallbackCB bfallback, liBackendFinishedCB bfinished, liBalancerFreeCB bfree, gpointer param, gboolean provide_backlog);
#endif

4
include/lighttpd/actions_lua.h

@ -4,7 +4,7 @@
#include <lighttpd/base.h>
#include <lua.h>
action* lua_get_action(lua_State *L, int ndx);
int lua_push_action(server *srv, lua_State *L, action *a);
liAction* lua_get_action(lua_State *L, int ndx);
int lua_push_action(liServer *srv, lua_State *L, liAction *a);
#endif

10
include/lighttpd/angel.h

@ -2,17 +2,17 @@
#define _LIGHTTPD_ANGEL_H_
/* interface to the angel; implementation needs to work without angel too */
LI_API void angel_setup(server *srv);
LI_API void angel_setup(liServer *srv);
/* listen to a socket */
LI_API void angel_listen(server *srv, GString *str);
LI_API void angel_listen(liServer *srv, GString *str);
/* send log messages during startup to angel, frees the string */
LI_API void angel_log(server *srv, GString *str);
LI_API void angel_log(liServer *srv, GString *str);
/* angle_fake definitions, only for internal use */
int angel_fake_listen(server *srv, GString *str);
gboolean angel_fake_log(server *srv, GString *str);
int angel_fake_listen(liServer *srv, GString *str);
gboolean angel_fake_log(liServer *srv, GString *str);
#endif

11
include/lighttpd/angel_base.h

@ -11,14 +11,9 @@
/* angel_server.h */
struct server;
typedef struct server server;
struct instance;
typedef struct instance instance;
struct instance_conf;
typedef struct instance_conf instance_conf;
typedef struct liServer liServer;
typedef struct liInstance liInstance;
typedef struct liInstanceConf liInstanceConf;
#include <lighttpd/angel_value.h>

8
include/lighttpd/angel_config_parser.h

@ -2,13 +2,13 @@
#define _LIGHTTPD_ANGEL_CONIG_PARSER_H_
/* error handling */
#define ANGEL_CONFIG_PARSER_ERROR angel_config_parser_error_quark()
#define LI_ANGEL_CONFIG_PARSER_ERROR angel_config_parser_error_quark()
LI_API GQuark angel_config_parser_error_quark();
typedef enum {
ANGEL_CONFIG_PARSER_ERROR_PARSE, /* parse error */
} AngelConfigParserError;
LI_ANGEL_CONFIG_PARSER_ERROR_PARSE, /* parse error */
} liAngelConfigParserError;
LI_API gboolean angel_config_parse_file(server *srv, const gchar *filename, GError **err);
LI_API gboolean angel_config_parse_file(liServer *srv, const gchar *filename, GError **err);
#endif

66
include/lighttpd/angel_connection.h

@ -5,37 +5,35 @@
#define ANGEL_CALL_MAX_STR_LEN (64*1024) /* must fit into a gint32 */
struct angel_connection;
typedef struct angel_connection angel_connection;
typedef struct liAngelConnection liAngelConnection;
struct angel_call;
typedef struct angel_call angel_call;
typedef struct liAngelCall liAngelCall;
/* error, data and fds-array will be freed/closed by the angel api itself; if you want to use the fds set the array size to 0 */
typedef void (*AngelCallback)(angel_call *acall, gpointer ctx, gboolean timeout, GString *error, GString *data, GArray *fds);
typedef void (*liAngelCallCB)(liAngelCall *acall, gpointer ctx, gboolean timeout, GString *error, GString *data, GArray *fds);
typedef void (*AngelReceiveCall)(angel_connection *acon,
typedef void (*liAngelReceiveCallCB)(liAngelConnection *acon,
const gchar *mod, gsize mod_len, const gchar *action, gsize action_len,
gint32 id,
GString *data);
/* gets called after read/write errors */
typedef void (*AngelCloseCallback)(angel_connection *acon, GError *err);
typedef void (*liAngelCloseCB)(liAngelConnection *acon, GError *err);
struct angel_connection {
struct liAngelConnection {
gpointer data;
GMutex *mutex;
struct ev_loop *loop;
int fd;
idlist *call_id_list;
liIDList *call_id_list;
GPtrArray *call_table;
ev_io fd_watcher;
ev_async out_notify_watcher;
GQueue *out;
angel_buffer in;
liAngelBuffer in;
AngelReceiveCall recv_call;
AngelCloseCallback close_cb;
liAngelReceiveCallCB recv_call;
liAngelCloseCB close_cb;
/* parse input */
struct {
@ -51,67 +49,67 @@ struct angel_connection {
/* with multi-threading you should protect the structure
* containing the angel_call with a lock
*/
struct angel_call {
struct liAngelCall {
gpointer context;
AngelCallback callback;
liAngelCallCB callback;
/* internal data */
gint32 id; /* id is -1 if there is no call pending (the callback may still be running) */
angel_connection *acon;
liAngelConnection *acon;
ev_timer timeout_watcher;
};
/* error handling */
#define ANGEL_CALL_ERROR angel_call_error_quark()
#define LI_ANGEL_CALL_ERROR angel_call_error_quark()
LI_API GQuark angel_call_error_quark();
#define ANGEL_CONNECTION_ERROR angel_connection_error_quark()
#define LI_ANGEL_CONNECTION_ERROR angel_connection_error_quark()
LI_API GQuark angel_connection_error_quark();
typedef enum {
ANGEL_CALL_ALREADY_RUNNING, /* the angel_call struct is already in use for a call */
ANGEL_CALL_OUT_OF_CALL_IDS, /* too many calls already pending */
ANGEL_CALL_INVALID /* invalid params */
} AngelCallError;
LI_ANGEL_CALL_ALREADY_RUNNING, /* the angel_call struct is already in use for a call */
LI_ANGEL_CALL_OUT_OF_CALL_IDS, /* too many calls already pending */
LI_ANGEL_CALL_INVALID /* invalid params */
} liAngelCallError;
typedef enum {
ANGEL_CONNECTION_CLOSED, /* error on socket */
ANGEL_CONNECTION_INVALID_DATA /* invalid data from stream */
} AngelConnectionError;
LI_ANGEL_CONNECTION_CLOSED, /* error on socket */
LI_ANGEL_CONNECTION_INVALID_DATA /* invalid data from stream */
} liAngelConnectionError;
/* create connection */
LI_API angel_connection* angel_connection_new(
LI_API liAngelConnection* angel_connection_new(
struct ev_loop *loop, int fd, gpointer data,
AngelReceiveCall recv_call, AngelCloseCallback close_cb);
LI_API void angel_connection_free(angel_connection *acon);
liAngelReceiveCallCB recv_call, liAngelCloseCB close_cb);
LI_API void angel_connection_free(liAngelConnection *acon);
LI_API angel_call *angel_call_new(AngelCallback callback, ev_tstamp timeout);
LI_API liAngelCall *angel_call_new(liAngelCallCB callback, ev_tstamp timeout);
/* returns TRUE if a call was cancelled; make sure you don't call free while you're calling send_call */
LI_API gboolean angel_call_free(angel_call *call);
LI_API gboolean angel_call_free(liAngelCall *call);
/* calls */
/* the GString* parameters get stolen by the angel call (moved to chunkqueue) */
LI_API gboolean angel_send_simple_call(
angel_connection *acon,
liAngelConnection *acon,
const gchar *mod, gsize mod_len, const gchar *action, gsize action_len,
GString *data,
GError **err);
LI_API gboolean angel_send_call(
angel_connection *acon,
liAngelConnection *acon,
const gchar *mod, gsize mod_len, const gchar *action, gsize action_len,
angel_call *call,
liAngelCall *call,
GString *data,
GError **err);
LI_API gboolean angel_send_result(
angel_connection *acon,
liAngelConnection *acon,
gint32 id,
GString *error, GString *data, GArray *fds,
GError **err);
/* free temporary needed memroy; call this once in while after some activity */
LI_API void angel_cleanup_tables(angel_connection *acon);
LI_API void angel_cleanup_tables(liAngelConnection *acon);
/* Usage */
#if 0

27
include/lighttpd/angel_data.h

@ -17,25 +17,24 @@
/* The buffer may be bigger of course, but a single string should not
* exceed this length: */
#define ANGEL_DATA_MAX_STR_LEN 1024 /* must fit into a gint32 */
#define LI_ANGEL_DATA_MAX_STR_LEN 1024 /* must fit into a gint32 */
/* Needed for reading data */
struct angel_buffer;
typedef struct angel_buffer angel_buffer;
struct angel_buffer {
typedef struct liAngelBuffer liAngelBuffer;
struct liAngelBuffer {
GString *data;
gsize pos;
};
/* error handling */
#define ANGEL_DATA_ERROR angel_data_error_quark()
#define LI_ANGEL_DATA_ERROR angel_data_error_quark()
LI_API GQuark angel_data_error_quark();
typedef enum {
ANGEL_DATA_ERROR_EOF, /* not enough data to read value */
ANGEL_DATA_ERROR_INVALID_STRING_LENGTH, /* invalid string length read from buffer (< 0 || > max-str-len) */
ANGEL_DATA_ERROR_STRING_TOO_LONG /* string too long (len > max-str-len) */
} AngelDataError;
LI_ANGEL_DATA_ERROR_EOF, /* not enough data to read value */
LI_ANGEL_DATA_ERROR_INVALID_STRING_LENGTH, /* invalid string length read from buffer (< 0 || > max-str-len) */
LI_ANGEL_DATA_ERROR_STRING_TOO_LONG /* string too long (len > max-str-len) */
} liAngelDataError;
/* write */
LI_API gboolean angel_data_write_int32(GString *buf, gint32 i, GError **err);
@ -50,10 +49,10 @@ LI_API gboolean angel_data_write_cstr (GString *buf, const gchar *str, gsize len
* otherwise a new GString* will be created
* - *val will only be modified if no error is returned
*/
LI_API gboolean angel_data_read_int32(angel_buffer *buf, gint32 *val, GError **err);
LI_API gboolean angel_data_read_int64(angel_buffer *buf, gint64 *val, GError **err);
LI_API gboolean angel_data_read_char (angel_buffer *buf, gchar *val, GError **err);
LI_API gboolean angel_data_read_str (angel_buffer *buf, GString **val, GError **err);
LI_API gboolean angel_data_read_mem (angel_buffer *buf, GString **val, gsize len, GError **err);
LI_API gboolean angel_data_read_int32(liAngelBuffer *buf, gint32 *val, GError **err);
LI_API gboolean angel_data_read_int64(liAngelBuffer *buf, gint64 *val, GError **err);
LI_API gboolean angel_data_read_char (liAngelBuffer *buf, gchar *val, GError **err);
LI_API gboolean angel_data_read_str (liAngelBuffer *buf, GString **val, GError **err);
LI_API gboolean angel_data_read_mem (liAngelBuffer *buf, GString **val, gsize len, GError **err);
#endif

71
include/lighttpd/angel_log.h

@ -7,64 +7,63 @@
/* #include <lighttpd/valgrind/valgrind.h> */
#define REMOVE_PATH_FROM_FILE 1
#if REMOVE_PATH_FROM_FILE
#define LI_REMOVE_PATH_FROM_FILE 1
#if LI_REMOVE_PATH_FROM_FILE
LI_API const char *remove_path(const char *path);
#define REMOVE_PATH(file) remove_path(file)
#define LI_REMOVE_PATH(file) remove_path(file)
#else
#define REMOVE_PATH(file) file
#define LI_REMOVE_PATH(file) file
#endif
#define SEGFAULT(srv, fmt, ...) \
do { \
log_write_(srv, LOG_LEVEL_ABORT, LOG_FLAG_TIMESTAMP, "(crashing) %s.%d: "fmt, REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__); \
log_write_(srv, LI_LOG_LEVEL_ABORT, LI_LOG_FLAG_TIMESTAMP, "(crashing) %s.%d: "fmt, LI_REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__); \
/* VALGRIND_PRINTF_BACKTRACE(fmt, __VA_ARGS__); */\
abort();\
} while(0)
#define ERROR(srv, fmt, ...) \
log_write(srv, LOG_LEVEL_ERROR, LOG_FLAG_TIMESTAMP, "error (%s:%d): "fmt, REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__)
log_write(srv, LI_LOG_LEVEL_ERROR, LI_LOG_FLAG_TIMESTAMP, "error (%s:%d): "fmt, LI_REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__)
#define WARNING(srv, fmt, ...) \
log_write(srv, LOG_LEVEL_WARNING, LOG_FLAG_TIMESTAMP, "warning (%s:%d): "fmt, REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__)
log_write(srv, LI_LOG_LEVEL_WARNING, LI_LOG_FLAG_TIMESTAMP, "warning (%s:%d): "fmt, LI_REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__)
#define INFO(srv, fmt, ...) \
log_write(srv, LOG_LEVEL_INFO, LOG_FLAG_TIMESTAMP, "info (%s:%d): "fmt, REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__)
log_write(srv, LI_LOG_LEVEL_INFO, LI_LOG_FLAG_TIMESTAMP, "info (%s:%d): "fmt, LI_REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__)
#define DEBUG(srv, fmt, ...) \
log_write(srv, LOG_LEVEL_DEBUG, LOG_FLAG_TIMESTAMP, "debug (%s:%d): "fmt, REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__)
log_write(srv, LI_LOG_LEVEL_DEBUG, LI_LOG_FLAG_TIMESTAMP, "debug (%s:%d): "fmt, LI_REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__)
/* log messages from lighty always as ERROR */
#define INSTANCE(srv, inst, msg) \
log_write(srv, LOG_LEVEL_ERROR, LOG_FLAG_NONE, "lighttpd[%d]: %s", (int) inst->pid, msg)
log_write(srv, LI_LOG_LEVEL_ERROR, LI_LOG_FLAG_NONE, "lighttpd[%d]: %s", (int) inst->pid, msg)
typedef enum {
LOG_LEVEL_DEBUG,
LOG_LEVEL_INFO,
LOG_LEVEL_WARNING,
LOG_LEVEL_ERROR,
LOG_LEVEL_ABORT
} log_level_t;
LI_LOG_LEVEL_DEBUG,
LI_LOG_LEVEL_INFO,
LI_LOG_LEVEL_WARNING,
LI_LOG_LEVEL_ERROR,
LI_LOG_LEVEL_ABORT
} liLogLevel;
#define LOG_LEVEL_COUNT (LOG_LEVEL_ABORT+1)
#define LI_LOG_LEVEL_COUNT (LI_LOG_LEVEL_ABORT+1)
typedef enum {
LOG_TYPE_STDERR,
LOG_TYPE_FILE,
LOG_TYPE_PIPE,
LOG_TYPE_SYSLOG,
LOG_TYPE_NONE
} log_type_t;
#define LOG_FLAG_NONE (0x0) /* default flag */
#define LOG_FLAG_TIMESTAMP (0x1) /* prepend a timestamp to the log message */
struct log_t;
typedef struct log_t log_t;
struct log_t {
log_type_t type;
gboolean levels[LOG_LEVEL_COUNT];
LI_LOG_TYPE_STDERR,
LI_LOG_TYPE_FILE,
LI_LOG_TYPE_PIPE,
LI_LOG_TYPE_SYSLOG,
LI_LOG_TYPE_NONE
} liLogType;
#define LI_LOG_FLAG_NONE (0x0) /* default flag */
#define LI_LOG_FLAG_TIMESTAMP (0x1) /* prepend a timestamp to the log message */
typedef struct liLog liLog;
struct liLog {
liLogType type;
gboolean levels[LI_LOG_LEVEL_COUNT];
GString *path;
gint fd;
@ -74,9 +73,9 @@ struct log_t {
GString *log_line;
};
void log_init(server *srv);
void log_clean(server *srv);
void log_init(liServer *srv);
void log_clean(liServer *srv);
LI_API void log_write(server *srv, log_level_t log_level, guint flags, const gchar *fmt, ...) G_GNUC_PRINTF(4, 5);
LI_API void log_write(liServer *srv, liLogLevel log_level, guint flags, const gchar *fmt, ...) G_GNUC_PRINTF(4, 5);
#endif

70
include/lighttpd/angel_plugin.h

@ -5,60 +5,60 @@
#error Please include <lighttpd/angel_base.h> instead of this file
#endif
typedef struct plugin_item plugin_item;
typedef struct plugin_item_option plugin_item_option;
typedef struct plugin plugin;
typedef struct Plugins Plugins;
typedef struct liPluginItem liPluginItem;
typedef struct liPluginItemOption liPluginItemOption;
typedef struct liPlugin liPlugin;
typedef struct liPlugins liPlugins;
typedef gboolean (*PluginInit) (server *srv, plugin *p);
typedef void (*PluginFree) (server *srv, plugin *p);
typedef gboolean (*liPluginInitCB) (liServer *srv, liPlugin *p);
typedef void (*liPluginFreeCB) (liServer *srv, liPlugin *p);
typedef void (*PluginCleanConfig) (server *srv, plugin *p);
typedef gboolean (*PluginCheckConfig) (server *srv, plugin *p);
typedef void (*PluginActivateConfig)(server *srv, plugin *p);
typedef void (*PluginParseItem) (server *srv, plugin *p, value **options);
typedef void (*liPluginCleanConfigCB) (liServer *srv, liPlugin *p);
typedef gboolean (*liPluginCheckConfigCB) (liServer *srv, liPlugin *p);
typedef void (*liPluginActivateConfigCB)(liServer *srv, liPlugin *p);
typedef void (*liPluginParseItemCB) (liServer *srv, liPlugin *p, liValue **options);
typedef void (*PluginHandleCall) (server *srv, instance *i, plugin *p, gint32 id, GString *data);
typedef void (*liPluginHandleCallCB) (liServer *srv, liInstance *i, liPlugin *p, gint32 id, GString *data);
typedef enum {
PLUGIN_ITEM_OPTION_MANDATORY = 1
} plugin_item_option_flags;
LI_PLUGIN_ITEM_OPTION_MANDATORY = 1
} liPluginItemOptionFlags;
struct plugin_item_option {
struct liPluginItemOption {
const gchar *name; /**< name of the option */
value_type type; /**< type of the option; may be VALUE_NONE to accept anything */
plugin_item_option_flags flags; /**< flags of the option */
liValueType type; /**< type of the option; may be LI_VALUE_NONE to accept anything */
liPluginItemOptionFlags flags; /**< flags of the option */
};
struct plugin_item {
struct liPluginItem {
const gchar *name;
PluginParseItem handle_parse_item;
liPluginParseItemCB handle_parse_item;
const plugin_item_option *options;
const liPluginItemOption *options;
};
struct plugin {
struct liPlugin {
size_t version;
const gchar *name; /**< name of the plugin */
gpointer data; /**< private plugin data */
const plugin_item *items;
GHashTable *angel_callbacks; /**< map (const gchar*) -> PluginHandleCall */
const liPluginItem *items;
GHashTable *angel_callbacks; /**< map (const gchar*) -> liPluginHandleCallCB */
PluginFree handle_free; /**< called before plugin is unloaded */
liPluginFreeCB handle_free; /**< called before plugin is unloaded */
PluginCleanConfig handle_clean_config; /**< called before the reloading of the config is started or after the reloading failed */
PluginCheckConfig handle_check_config; /**< called before activating a config to ensure everything works */
PluginActivateConfig handle_activate_config; /**< called to activate a config after successful loading it. this cannot fail */
liPluginCleanConfigCB handle_clean_config; /**< called before the reloading of the config is started or after the reloading failed */
liPluginCheckConfigCB handle_check_config; /**< called before activating a config to ensure everything works */
liPluginActivateConfigCB handle_activate_config; /**< called to activate a config after successful loading it. this cannot fail */
};
struct Plugins {
struct liPlugins {
GString *config_filename;
GHashTable *items, *load_items; /**< gchar* -> server_item */
struct modules *modules;
liModules *modules;
GHashTable *module_refs, *load_module_refs; /** gchar* -> server_module */
GHashTable *ht_plugins, *load_ht_plugins;
@ -66,17 +66,17 @@ struct Plugins {
GPtrArray *plugins, *load_plugins; /* plugin* */
};
void plugins_init(server *srv, const gchar *module_dir);
void plugins_clear(server *srv);
void plugins_init(liServer *srv, const gchar *module_dir);
void plugins_clear(liServer *srv);
void plugins_config_clean(server *srv);
gboolean plugins_config_load(server *srv, const gchar *filename);
void plugins_config_clean(liServer *srv);
gboolean plugins_config_load(liServer *srv, const gchar *filename);
void plugins_handle_item(server *srv, GString *itemname, value *hash);
void plugins_handle_item(liServer *srv, GString *itemname, liValue *hash);
/* "core" is a reserved module name for interal use */
gboolean plugins_load_module(server *srv, const gchar *name);
gboolean plugins_load_module(liServer *srv, const gchar *name);
/* Needed by modules to register their plugin(s) */
LI_API plugin *angel_plugin_register(server *srv, module *mod, const gchar *name, PluginInit init);
LI_API liPlugin *angel_plugin_register(liServer *srv, liModule *mod, const gchar *name, liPluginInitCB init);
#endif

13
include/lighttpd/angel_plugin_core.h

@ -3,16 +3,17 @@
#include <lighttpd/angel_base.h>
typedef struct {
typedef struct liPluginCoreConfig liPluginCoreConfig;
struct liPluginCoreConfig {
/* Load */
instance_conf *load_instconf;
liInstanceConf *load_instconf;
gboolean load_failed;
/* Running */
instance_conf *instconf;
instance *inst;
} plugin_core_config_t;
liInstanceConf *instconf;
liInstance *inst;
};
gboolean plugin_core_init(server *srv);
gboolean plugin_core_init(liServer *srv);
#endif

56
include/lighttpd/angel_server.h

@ -10,14 +10,14 @@
#endif
typedef enum {
INSTANCE_DOWN, /* not running */
INSTANCE_LOADING, /* startup */
INSTANCE_WARMUP, /* running, but logging to files disabled */
INSTANCE_ACTIVE, /* everything running */
INSTANCE_SUSPEND /* handle remaining connections, suspend logs+accept() */
} instance_state_t;
struct instance_conf {
LI_INSTANCE_DOWN, /* not running */
LI_INSTANCE_LOADING, /* startup */
LI_INSTANCE_WARMUP, /* running, but logging to files disabled */
LI_INSTANCE_ACTIVE, /* everything running */
LI_INSTANCE_SUSPEND /* handle remaining connections, suspend logs+accept() */
} liInstanceState;
struct liInstanceConf {
gint refcount;
gchar **cmd;
@ -26,24 +26,24 @@ struct instance_conf {
gid_t gid;
};
struct instance {
struct liInstance {
gint refcount;
server *srv;
instance_conf *ic;
liServer *srv;
liInstanceConf *ic;
pid_t pid;
ev_child child_watcher;
instance_state_t s_cur, s_dest;
liInstanceState s_cur, s_dest;
instance *replace, *replace_by;
liInstance *replace, *replace_by;
angel_connection *acon;
liAngelConnection *acon;
gboolean in_jobqueue;
};
struct server {
struct liServer {
guint32 magic; /** server magic version, check against LIGHTTPD_ANGEL_MAGIC in plugins */
struct ev_loop *loop;
@ -55,25 +55,25 @@ struct server {
GQueue job_queue;
ev_async job_watcher;
Plugins plugins;
liPlugins plugins;
log_t log;
liLog log;
};
LI_API server* server_new(const gchar *module_dir);
LI_API void server_free(server* srv);
LI_API liServer* server_new(const gchar *module_dir);
LI_API void server_free(liServer* srv);
LI_API instance* server_new_instance(server *srv, instance_conf *ic);
LI_API void instance_replace(instance *oldi, instance *newi);
LI_API void instance_set_state(instance *i, instance_state_t s);
LI_API liInstance* server_new_instance(liServer *srv, liInstanceConf *ic);
LI_API void instance_replace(liInstance *oldi, liInstance *newi);
LI_API void instance_set_state(liInstance *i, liInstanceState s);
LI_API instance_conf* instance_conf_new(gchar **cmd, GString *username, uid_t uid, gid_t gid);
LI_API void instance_conf_release(instance_conf *ic);
LI_API void instance_conf_acquire(instance_conf *ic);
LI_API liInstanceConf* instance_conf_new(gchar **cmd, GString *username, uid_t uid, gid_t gid);
LI_API void instance_conf_release(liInstanceConf *ic);
LI_API void instance_conf_acquire(liInstanceConf *ic);
LI_API void instance_release(instance *i);
LI_API void instance_acquire(instance *i);
LI_API void instance_release(liInstance *i);
LI_API void instance_acquire(liInstance *i);
LI_API void instance_job_append(instance *i);
LI_API void instance_job_append(liInstance *i);
#endif

54
include/lighttpd/angel_value.h

@ -5,56 +5,54 @@
#error Please include <lighttpd/angel_base.h> instead of this file
#endif
struct value;
typedef struct value value;
typedef struct liValue liValue;
struct value_range;
typedef struct value_range value_range;
typedef struct liValueRange liValueRange;
typedef enum {
VALUE_NONE,
LI_VALUE_NONE,
/* primitive types */
VALUE_BOOLEAN,
VALUE_NUMBER,
VALUE_STRING,
VALUE_RANGE,
LI_VALUE_BOOLEAN,
LI_VALUE_NUMBER,
LI_VALUE_STRING,
LI_VALUE_RANGE,
/* container */
VALUE_LIST,
VALUE_HASH
} value_type;
LI_VALUE_LIST,
LI_VALUE_HASH
} liValueType;
struct value_range {
struct liValueRange {
guint64 from, to;
};
struct value {
value_type type;
struct liValue {
liValueType type;
union {
gboolean boolean;
gint64 number;
GString *string;
value_range range;
/* array of (value*) */
liValueRange range;
/* array of (liValue*) */
GPtrArray *list;
/* hash GString => value */
GHashTable *hash;
} data;
};
LI_API value* value_new_none();
LI_API value* value_new_bool(gboolean val);
LI_API value* value_new_number(gint64 val);
LI_API value* value_new_string(GString *val);
LI_API value* value_new_range(value_range val);
LI_API value* value_new_list();
LI_API value* value_new_hash();
LI_API liValue* value_new_none();
LI_API liValue* value_new_bool(gboolean val);
LI_API liValue* value_new_number(gint64 val);
LI_API liValue* value_new_string(GString *val);
LI_API liValue* value_new_range(liValueRange val);
LI_API liValue* value_new_list();
LI_API liValue* value_new_hash();
LI_API value* value_copy(value* val);
LI_API void value_free(value* val);
LI_API liValue* value_copy(liValue* val);
LI_API void value_free(liValue* val);
LI_API const char* value_type_string(value_type type);
LI_API const char* value_type_string(liValueType type);
LI_API GString *value_to_string(value *val);
LI_API GString *value_to_string(liValue *val);
#endif

1
include/lighttpd/base.h

@ -60,7 +60,6 @@
#include <lighttpd/filter_chunked.h>
#include <lighttpd/collect.h>
#include <lighttpd/network.h>
#include <lighttpd/encoding.h>
#include <lighttpd/etag.h>
#include <lighttpd/lighttpd-glue.h>
#include <lighttpd/utils.h>

106
include/lighttpd/chunk.h

@ -9,7 +9,7 @@
* as a file may get split into many chunks, we
* use this struct to keep track of the usage
*/
struct chunkfile {
struct liChunkFile {
gint refcount;
GString *name; /* name of the file */
@ -17,7 +17,7 @@ struct chunkfile {
gboolean is_temp; /* file is temporary and will be deleted on cleanup */
};
struct chunk {
struct liChunk {
enum { UNUSED_CHUNK, STRING_CHUNK, MEM_CHUNK, FILE_CHUNK } type;
goffset offset;
@ -29,7 +29,7 @@ struct chunk {
GByteArray *mem;
struct {
chunkfile *file;
liChunkFile *file;
off_t start; /* starting offset in the file */
off_t length; /* octets to send from the starting offset */
@ -41,31 +41,31 @@ struct chunk {
} file;
};
typedef void (*cqlimit_notify)(vrequest *vr, gpointer context, gboolean locked);
struct cqlimit {
typedef void (*liCQLimitNnotifyCB)(liVRequest *vr, gpointer context, gboolean locked);
struct liCQLimit {
gint refcount;
vrequest *vr;
liVRequest *vr;
goffset limit, current;
gboolean locked;
ev_io *io_watcher;
cqlimit_notify notify; /* callback to reactivate input */
liCQLimitNnotifyCB notify; /* callback to reactivate input */
gpointer context;
};
struct chunkqueue {
struct liChunkQueue {
/* public */
gboolean is_closed;
/* read only */
goffset bytes_in, bytes_out, length, mem_usage;
cqlimit *limit; /* limit is the sum of all { c->mem->len | c->type == STRING_CHUNK } */
liCQLimit *limit; /* limit is the sum of all { c->mem->len | c->type == STRING_CHUNK } */
/* private */
GQueue *queue;
};
struct chunkiter {
struct liChunkIter {
/* private */
GList *element;
};
@ -77,127 +77,127 @@ struct chunkiter {
/* open the file cf->name if it is not already opened for reading
* may return HANDLER_GO_ON, HANDLER_ERROR
*/
LI_API handler_t chunkfile_open(struct vrequest *vr, chunkfile *cf);
LI_API liHandlerResult chunkfile_open(liVRequest *vr, liChunkFile *cf);
/******************
* chunk iterator *
******************/
INLINE chunk* chunkiter_chunk(chunkiter iter);
INLINE gboolean chunkiter_next(chunkiter *iter);
INLINE goffset chunkiter_length(chunkiter iter);
INLINE liChunk* chunkiter_chunk(liChunkIter iter);
INLINE gboolean chunkiter_next(liChunkIter *iter);
INLINE goffset chunkiter_length(liChunkIter iter);
/* get the data from a chunk; easy in case of a STRING_CHUNK,
* but needs to do io in case of FILE_CHUNK; the data is _not_ marked as "done"
* may return HANDLER_GO_ON, HANDLER_ERROR
*/
LI_API handler_t chunkiter_read(struct vrequest *vr, chunkiter iter, off_t start, off_t length, char **data_start, off_t *data_len);
LI_API liHandlerResult chunkiter_read(liVRequest *vr, liChunkIter iter, off_t start, off_t length, char **data_start, off_t *data_len);
/* same as chunkiter_read, but tries mmap() first and falls back to read();
* as accessing mmap()-ed areas may result in SIGBUS, you have to handle that signal somehow.
*/
LI_API handler_t chunkiter_read_mmap(struct vrequest *vr, chunkiter iter, off_t start, off_t length, char **data_start, off_t *data_len);
LI_API liHandlerResult chunkiter_read_mmap(liVRequest *vr, liChunkIter iter, off_t start, off_t length, char **data_start, off_t *data_len);
/******************
* chunk *
******************/
INLINE goffset chunk_length(chunk *c);
INLINE goffset chunk_length(liChunk *c);
/******************
* cqlimit *
******************/
LI_API cqlimit* cqlimit_new(vrequest *vr);
LI_API void cqlimit_reset(cqlimit *cql);
LI_API void cqlimit_acquire(cqlimit *cql);
LI_API void cqlimit_release(cqlimit *cql);
LI_API void cqlimit_set_limit(cqlimit *cql, goffset limit);
LI_API liCQLimit* cqlimit_new(liVRequest *vr);
LI_API void cqlimit_reset(liCQLimit *cql);
LI_API void cqlimit_acquire(liCQLimit *cql);
LI_API void cqlimit_release(liCQLimit *cql);
LI_API void cqlimit_set_limit(liCQLimit *cql, goffset limit);
/******************
* chunkqueue *
******************/
LI_API chunkqueue* chunkqueue_new();
LI_API void chunkqueue_reset(chunkqueue *cq);
LI_API void chunkqueue_free(chunkqueue *cq);
LI_API liChunkQueue* chunkqueue_new();
LI_API void chunkqueue_reset(liChunkQueue *cq);
LI_API void chunkqueue_free(liChunkQueue *cq);
LI_API void chunkqueue_use_limit(chunkqueue *cq, vrequest *vr);
LI_API void chunkqueue_set_limit(chunkqueue *cq, cqlimit* cql);
LI_API void chunkqueue_use_limit(liChunkQueue *cq, liVRequest *vr);
LI_API void chunkqueue_set_limit(liChunkQueue *cq, liCQLimit* cql);
/* return -1 for unlimited, 0 for full and n > 0 for n bytes free */
LI_API goffset chunkqueue_limit_available(chunkqueue *cq);
LI_API goffset chunkqueue_limit_available(liChunkQueue *cq);
/* pass ownership of str to chunkqueue, do not free/modify it afterwards
* you may modify the data (not the length) if you are sure it isn't sent before.
* if the length is NULL, str is destroyed immediately
*/
LI_API void chunkqueue_append_string(chunkqueue *cq, GString *str);
LI_API void chunkqueue_append_string(liChunkQueue *cq, GString *str);
/* pass ownership of mem to chunkqueue, do not free/modify it afterwards
* you may modify the data (not the length) if you are sure it isn't sent before.
* if the length is NULL, mem is destroyed immediately
*/
LI_API void chunkqueue_append_bytearr(chunkqueue *cq, GByteArray *mem);
LI_API void chunkqueue_append_bytearr(liChunkQueue *cq, GByteArray *mem);
/* memory gets copied */
LI_API void chunkqueue_append_mem(chunkqueue *cq, const void *mem, gssize len);
LI_API void chunkqueue_append_mem(liChunkQueue *cq, const void *mem, gssize len);
/* pass ownership of filename, do not free it */
LI_API void chunkqueue_append_file(chunkqueue *cq, GString *filename, off_t start, off_t length);
LI_API void chunkqueue_append_file(liChunkQueue *cq, GString *filename, off_t start, off_t length);
/* if you already opened the file, you can pass the fd here - do not close it */
LI_API void chunkqueue_append_file_fd(chunkqueue *cq, GString *filename, off_t start, off_t length, int fd);
LI_API void chunkqueue_append_file_fd(liChunkQueue *cq, GString *filename, off_t start, off_t length, int fd);
/* temp files get deleted after usage */
/* pass ownership of filename, do not free it */
LI_API void chunkqueue_append_tempfile(chunkqueue *cq, GString *filename, off_t start, off_t length);
LI_API void chunkqueue_append_tempfile(liChunkQueue *cq, GString *filename, off_t start, off_t length);
/* if you already opened the file, you can pass the fd here - do not close it */
LI_API void chunkqueue_append_tempfile_fd(chunkqueue *cq, GString *filename, off_t start, off_t length, int fd);
LI_API void chunkqueue_append_tempfile_fd(liChunkQueue *cq, GString *filename, off_t start, off_t length, int fd);
/* steal up to length bytes from in and put them into out, return number of bytes stolen */
LI_API goffset chunkqueue_steal_len(chunkqueue *out, chunkqueue *in, goffset length);
LI_API goffset chunkqueue_steal_len(liChunkQueue *out, liChunkQueue *in, goffset length);
/* steal all chunks from in and put them into out, return number of bytes stolen */
LI_API goffset chunkqueue_steal_all(chunkqueue *out, chunkqueue *in);
LI_API goffset chunkqueue_steal_all(liChunkQueue *out, liChunkQueue *in);
/* steal the first chunk from in and append it to out, return number of bytes stolen */
LI_API goffset chunkqueue_steal_chunk(chunkqueue *out, chunkqueue *in);
LI_API goffset chunkqueue_steal_chunk(liChunkQueue *out, liChunkQueue *in);
/* skip up to length bytes in a chunkqueue, return number of bytes skipped */
LI_API goffset chunkqueue_skip(chunkqueue *cq, goffset length);
LI_API goffset chunkqueue_skip(liChunkQueue *cq, goffset length);
/* skip all chunks in a queue (similar to reset, but keeps stats) */
LI_API goffset chunkqueue_skip_all(chunkqueue *cq);
LI_API goffset chunkqueue_skip_all(liChunkQueue *cq);
/* if the chunk an iterator refers gets stolen/skipped/...,
* the iterator isn't valid anymore
*/
INLINE chunkiter chunkqueue_iter(chunkqueue *cq);
INLINE liChunkIter chunkqueue_iter(liChunkQueue *cq);
INLINE chunk* chunkqueue_first_chunk(chunkqueue *cq);
INLINE liChunk* chunkqueue_first_chunk(liChunkQueue *cq);
LI_API gboolean chunkqueue_extract_to(vrequest *vr, chunkqueue *cq, goffset len, GString *dest);
LI_API gboolean chunkqueue_extract_to_bytearr(vrequest *vr, chunkqueue *cq, goffset len, GByteArray *dest);
LI_API gboolean chunkqueue_extract_to(liVRequest *vr, liChunkQueue *cq, goffset len, GString *dest);
LI_API gboolean chunkqueue_extract_to_bytearr(liVRequest *vr, liChunkQueue *cq, goffset len, GByteArray *dest);
/********************
* Inline functions *
********************/
INLINE chunk* chunkiter_chunk(chunkiter iter) {
INLINE liChunk* chunkiter_chunk(liChunkIter iter) {
if (!iter.element) return NULL;
return (chunk*) iter.element->data;
return (liChunk*) iter.element->data;
}
INLINE gboolean chunkiter_next(chunkiter *iter) {
INLINE gboolean chunkiter_next(liChunkIter *iter) {
if (!iter || !iter->element) return FALSE;
return NULL != (iter->element = g_list_next(iter->element));
}
INLINE goffset chunkiter_length(chunkiter iter) {
INLINE goffset chunkiter_length(liChunkIter iter) {
return chunk_length(chunkiter_chunk(iter));
}
INLINE goffset chunk_length(chunk *c) {
INLINE goffset chunk_length(liChunk *c) {
if (!c) return 0;
switch (c->type) {
case UNUSED_CHUNK:
@ -212,14 +212,14 @@ INLINE goffset chunk_length(chunk *c) {
return 0;
}
INLINE chunkiter chunkqueue_iter(chunkqueue *cq) {
chunkiter i;
INLINE liChunkIter chunkqueue_iter(liChunkQueue *cq) {
liChunkIter i;
i.element = g_queue_peek_head_link(cq->queue);
return i;
}
INLINE chunk* chunkqueue_first_chunk(chunkqueue *cq) {
return (chunk*) g_queue_peek_head(cq->queue);
INLINE liChunk* chunkqueue_first_chunk(liChunkQueue *cq) {
return (liChunk*) g_queue_peek_head(cq->queue);
}
#endif

30
include/lighttpd/chunk_parser.h

@ -5,43 +5,43 @@
#error Please include <lighttpd/base.h> instead of this file
#endif
struct chunk_parser_ctx {
chunkqueue *cq;
struct liChunkParserCtx {
liChunkQueue *cq;
goffset bytes_in;
/* current position
* buf is curi[start..start+length)
*/
chunkiter curi;
liChunkIter curi;
off_t start, length;
char *buf;
int cs;
};
struct chunk_parser_mark {
chunkiter ci;
struct liChunkParserMark {
liChunkIter ci;
off_t pos;
};
LI_API void chunk_parser_init(chunk_parser_ctx *ctx, chunkqueue *cq);
LI_API void chunk_parser_reset(chunk_parser_ctx *ctx);
LI_API handler_t chunk_parser_prepare(chunk_parser_ctx *ctx);
LI_API handler_t chunk_parser_next(struct vrequest *vr, chunk_parser_ctx *ctx, char **p, char **pe);
LI_API void chunk_parser_done(chunk_parser_ctx *ctx, goffset len);
LI_API void chunk_parser_init(liChunkParserCtx *ctx, liChunkQueue *cq);
LI_API void chunk_parser_reset(liChunkParserCtx *ctx);
LI_API liHandlerResult chunk_parser_prepare(liChunkParserCtx *ctx);
LI_API liHandlerResult chunk_parser_next(liVRequest *vr, liChunkParserCtx *ctx, char **p, char **pe);
LI_API void chunk_parser_done(liChunkParserCtx *ctx, goffset len);
LI_API gboolean chunk_extract_to(struct vrequest *vr, chunk_parser_mark from, chunk_parser_mark to, GString *dest);
LI_API GString* chunk_extract(struct vrequest *vr, chunk_parser_mark from, chunk_parser_mark to);
LI_API gboolean chunk_extract_to(liVRequest *vr, liChunkParserMark from, liChunkParserMark to, GString *dest);
LI_API GString* chunk_extract(liVRequest *vr, liChunkParserMark from, liChunkParserMark to);
INLINE chunk_parser_mark chunk_parser_getmark(chunk_parser_ctx *ctx, const char *fpc);
INLINE liChunkParserMark chunk_parser_getmark(liChunkParserCtx *ctx, const char *fpc);
/********************
* Inline functions *
********************/
INLINE chunk_parser_mark chunk_parser_getmark(chunk_parser_ctx *ctx, const char *fpc) {
chunk_parser_mark m;
INLINE liChunkParserMark chunk_parser_getmark(liChunkParserCtx *ctx, const char *fpc) {
liChunkParserMark m;
m.ci = ctx->curi;
m.pos = ctx->start + fpc - ctx->buf;
return m;

26
include/lighttpd/collect.h

@ -12,7 +12,7 @@
* - fdata: optional user data
* the return value will be placed in the GArray
*/
typedef gpointer (*CollectFunc)(worker *wrk, gpointer fdata);
typedef gpointer (*liCollectFuncCB)(liWorker *wrk, gpointer fdata);
/** CollectCallback: the type of functions to call after a function was called in each workers context
* - cbdata: optional callback data
@ -22,29 +22,13 @@ typedef gpointer (*CollectFunc)(worker *wrk, gpointer fdata);
* - complete: determines if cbdata is still valid
* if this is FALSE, it may be called from another context than collect_start was called
*/
typedef void (*CollectCallback)(gpointer cbdata, gpointer fdata, GPtrArray *result, gboolean complete);
typedef void (*liCollectCB)(gpointer cbdata, gpointer fdata, GPtrArray *result, gboolean complete);
struct collect_info;
typedef struct collect_info collect_info;
/* internal structure */
struct collect_info {
worker *wrk;
gint counter;
gboolean stopped;
CollectFunc func;
gpointer fdata;
CollectCallback cb;
gpointer cbdata;
GPtrArray *results;
};
typedef struct liCollectInfo liCollectInfo;
/** collect_start returns NULL if the callback was called directly (e.g. for only one worker and ctx = wrk) */
LI_API collect_info* collect_start(worker *ctx, CollectFunc func, gpointer fdata, CollectCallback cb, gpointer cbdata);
LI_API void collect_break(collect_info* ci); /** this will result in complete == FALSE in the callback; call it if cbdata gets invalid */
LI_API liCollectInfo* collect_start(liWorker *ctx, liCollectFuncCB func, gpointer fdata, liCollectCB cb, gpointer cbdata);
LI_API void collect_break(liCollectInfo* ci); /** this will result in complete == FALSE in the callback; call it if cbdata gets invalid */
/* internal functions */
LI_API void collect_watcher_cb(struct ev_loop *loop, ev_async *w, int revents);

121
include/lighttpd/condition.h

@ -10,76 +10,76 @@
*/
typedef enum {
/* everything */
CONFIG_COND_EQ, /** == */
CONFIG_COND_NE, /** != */
LI_CONFIG_COND_EQ, /** == */
LI_CONFIG_COND_NE, /** != */
/* only with string */
CONFIG_COND_PREFIX, /** =^ */
CONFIG_COND_NOPREFIX,/** !^ */
CONFIG_COND_SUFFIX, /** =$ */
CONFIG_COND_NOSUFFIX,/** !$ */
LI_CONFIG_COND_PREFIX, /** =^ */
LI_CONFIG_COND_NOPREFIX,/** !^ */
LI_CONFIG_COND_SUFFIX, /** =$ */
LI_CONFIG_COND_NOSUFFIX,/** !$ */
/* only usable with pcre */
CONFIG_COND_MATCH, /** =~ */
CONFIG_COND_NOMATCH, /** !~ */
LI_CONFIG_COND_MATCH, /** =~ */
LI_CONFIG_COND_NOMATCH, /** !~ */
CONFIG_COND_IP,
CONFIG_COND_NOTIP,
LI_CONFIG_COND_IP,
LI_CONFIG_COND_NOTIP,
/* only with int */
CONFIG_COND_GT, /** > */
CONFIG_COND_GE, /** >= */
CONFIG_COND_LT, /** < */
CONFIG_COND_LE /** <= */
} comp_operator_t;
LI_CONFIG_COND_GT, /** > */
LI_CONFIG_COND_GE, /** >= */
LI_CONFIG_COND_LT, /** < */
LI_CONFIG_COND_LE /** <= */
} liCompOperator;
/**
* possible fields to match against
*/
typedef enum {
COMP_REQUEST_LOCALIP,
COMP_REQUEST_REMOTEIP,
COMP_REQUEST_PATH,
COMP_REQUEST_HOST,
COMP_REQUEST_SCHEME,
COMP_REQUEST_QUERY_STRING,
COMP_REQUEST_METHOD,
COMP_REQUEST_CONTENT_LENGTH,
COMP_PHYSICAL_PATH,
COMP_PHYSICAL_PATH_EXISTS,
COMP_PHYSICAL_SIZE,
COMP_PHYSICAL_ISDIR,
COMP_PHYSICAL_ISFILE,
LI_COMP_REQUEST_LOCALIP,
LI_COMP_REQUEST_REMOTEIP,
LI_COMP_REQUEST_PATH,
LI_COMP_REQUEST_HOST,
LI_COMP_REQUEST_SCHEME,
LI_COMP_REQUEST_QUERY_STRING,
LI_COMP_REQUEST_METHOD,
LI_COMP_REQUEST_CONTENT_LENGTH,
LI_COMP_PHYSICAL_PATH,
LI_COMP_PHYSICAL_PATH_EXISTS,
LI_COMP_PHYSICAL_SIZE,
LI_COMP_PHYSICAL_ISDIR,
LI_COMP_PHYSICAL_ISFILE,
/* needs a key */
COMP_REQUEST_HEADER, /**< needs lowercase key, enforced by condition_lvalue_new */
LI_COMP_REQUEST_HEADER, /**< needs lowercase key, enforced by condition_lvalue_new */
COMP_UNKNOWN
} cond_lvalue_t;
LI_COMP_UNKNOWN
} liCondLValue;
#define COND_LVALUE_FIRST_WITH_KEY COMP_REQUEST_HEADER
#define COND_LVALUE_END (1+COMP_REQUEST_HEADER)
#define LI_COND_LVALUE_FIRST_WITH_KEY LI_COMP_REQUEST_HEADER
#define LI_COND_LVALUE_END (1+LI_COMP_REQUEST_HEADER)
struct condition_lvalue {
struct liConditionLValue {
int refcount;
cond_lvalue_t type;
liCondLValue type;
GString *key;
};
typedef enum {
COND_VALUE_BOOL,
COND_VALUE_NUMBER,
COND_VALUE_STRING,
LI_COND_VALUE_BOOL,
LI_COND_VALUE_NUMBER,
LI_COND_VALUE_STRING,
#ifdef HAVE_PCRE_H
COND_VALUE_REGEXP,
LI_COND_VALUE_REGEXP,
#endif
COND_VALUE_SOCKET_IPV4, /** only match ip/netmask */
COND_VALUE_SOCKET_IPV6 /** only match ip/netmask */
} cond_rvalue_t;
LI_COND_VALUE_SOCKET_IPV4, /** only match ip/netmask */
LI_COND_VALUE_SOCKET_IPV6 /** only match ip/netmask */
} liCondRValue;
struct condition_rvalue {
cond_rvalue_t type;
struct liConditionRValue {
liCondRValue type;
gboolean b;
GString *string;
@ -97,31 +97,30 @@ struct condition_rvalue {
#include <lighttpd/base.h>
struct condition {
struct liCondition {
int refcount;
comp_operator_t op;
condition_lvalue *lvalue;
condition_rvalue rvalue;
liCompOperator op;
liConditionLValue *lvalue;
liConditionRValue rvalue;
};
/* lvalue */
LI_API condition_lvalue* condition_lvalue_new(cond_lvalue_t type, GString *key);
LI_API void condition_lvalue_acquire(condition_lvalue *lvalue);
LI_API void condition_lvalue_release(condition_lvalue *lvalue);
LI_API liConditionLValue* condition_lvalue_new(liCondLValue type, GString *key);
LI_API void condition_lvalue_acquire(liConditionLValue *lvalue);
LI_API void condition_lvalue_release(liConditionLValue *lvalue);
LI_API condition* condition_new_bool(server *srv, condition_lvalue *lvalue, gboolean b);
LI_API condition* condition_new_string(server *srv, comp_operator_t op, condition_lvalue *lvalue, GString *str);
LI_API condition* condition_new_int(server *srv, comp_operator_t op, condition_lvalue *lvalue, gint64 i);
LI_API liCondition* condition_new_bool(liServer *srv, liConditionLValue *lvalue, gboolean b);
LI_API liCondition* condition_new_string(liServer *srv, liCompOperator op, liConditionLValue *lvalue, GString *str);
LI_API liCondition* condition_new_int(liServer *srv, liCompOperator op, liConditionLValue *lvalue, gint64 i);
LI_API void condition_acquire(condition *c);
LI_API void condition_release(server *srv, condition* c);
LI_API void condition_acquire(liCondition *c);
LI_API void condition_release(liServer *srv, liCondition* c);
LI_API const char* comp_op_to_string(comp_operator_t op);
LI_API const char* cond_lvalue_to_string(cond_lvalue_t t);
LI_API cond_lvalue_t cond_lvalue_from_string(const gchar *str, guint len);
LI_API const char* comp_op_to_string(liCompOperator op);
LI_API const char* cond_lvalue_to_string(liCondLValue t);
LI_API liCondLValue cond_lvalue_from_string(const gchar *str, guint len);
struct vrequest;