Prefix LI_API functions with "li_"

personal/stbuehler/wip
Stefan Bühler 13 years ago
parent 99b203e3d8
commit 282a2d1b4a
  1. 24
      include/lighttpd/actions.h
  2. 6
      include/lighttpd/angel.h
  3. 6
      include/lighttpd/angel_config_parser.h
  4. 26
      include/lighttpd/angel_connection.h
  5. 24
      include/lighttpd/angel_data.h
  6. 18
      include/lighttpd/angel_log.h
  7. 2
      include/lighttpd/angel_plugin.h
  8. 22
      include/lighttpd/angel_server.h
  9. 22
      include/lighttpd/angel_value.h
  10. 58
      include/lighttpd/chunk.h
  11. 16
      include/lighttpd/chunk_parser.h
  12. 10
      include/lighttpd/collect.h
  13. 26
      include/lighttpd/condition.h
  14. 2
      include/lighttpd/config_lua.h
  15. 18
      include/lighttpd/connection.h
  16. 20
      include/lighttpd/environment.h
  17. 8
      include/lighttpd/etag.h
  18. 4
      include/lighttpd/filter_chunked.h
  19. 28
      include/lighttpd/http_headers.h
  20. 8
      include/lighttpd/http_request_parser.h
  21. 8
      include/lighttpd/http_response_parser.h
  22. 10
      include/lighttpd/idlist.h
  23. 6
      include/lighttpd/ip_parsers.h
  24. 10
      include/lighttpd/lighttpd-glue.h
  25. 36
      include/lighttpd/log.h
  26. 20
      include/lighttpd/module.h
  27. 16
      include/lighttpd/network.h
  28. 8
      include/lighttpd/options.h
  29. 38
      include/lighttpd/plugin.h
  30. 22
      include/lighttpd/radix.h
  31. 14
      include/lighttpd/request.h
  32. 10
      include/lighttpd/response.h
  33. 32
      include/lighttpd/server.h
  34. 8
      include/lighttpd/stat_cache.h
  35. 4
      include/lighttpd/typedefs.h
  36. 4
      include/lighttpd/url_parser.h
  37. 56
      include/lighttpd/utils.h
  38. 26
      include/lighttpd/value.h
  39. 4
      include/lighttpd/value_lua.h
  40. 46
      include/lighttpd/virtualrequest.h
  41. 20
      include/lighttpd/waitqueue.h
  42. 22
      include/lighttpd/worker.h
  43. 58
      src/actions.c
  44. 2
      src/actions_lua.c
  45. 24
      src/angel.c
  46. 42
      src/angel_config_parser.rl
  47. 86
      src/angel_connection.c
  48. 28
      src/angel_data.c
  49. 6
      src/angel_fake.c
  50. 4
      src/angel_log.c
  51. 4
      src/angel_main.c
  52. 22
      src/angel_plugin.c
  53. 32
      src/angel_plugin_core.c
  54. 60
      src/angel_server.c
  55. 54
      src/angel_value.c
  56. 80
      src/chunk.c
  57. 24
      src/chunk_parser.c
  58. 6
      src/collect.c
  59. 82
      src/condition.c
  60. 24
      src/condition_lua.c
  61. 20
      src/config_lua.c
  62. 210
      src/config_parser.rl
  63. 158
      src/connection.c
  64. 22
      src/environment.c
  65. 40
      src/etag.c
  66. 12
      src/filter_chunked.c
  67. 48
      src/http_headers.c
  68. 44
      src/http_request_parser.rl
  69. 46
      src/http_response_parser.rl
  70. 10
      src/idlist.c
  71. 6
      src/ip_parsers.rl
  72. 10
      src/lighttpd-glue.c
  73. 20
      src/lighttpd.c
  74. 30
      src/log.c
  75. 20
      src/module.c
  76. 42
      src/modules/mod_access.c
  77. 16
      src/modules/mod_accesslog.c
  78. 20
      src/modules/mod_balancer.c
  79. 34
      src/modules/mod_cache_disk_etag.c
  80. 24
      src/modules/mod_debug.c
  81. 50
      src/modules/mod_dirlist.c
  82. 14
      src/modules/mod_expire.c
  83. 116
      src/modules/mod_fastcgi.c
  84. 18
      src/modules/mod_fortune.c
  85. 8
      src/modules/mod_rewrite.c
  86. 78
      src/modules/mod_status.c
  87. 24
      src/modules/mod_vhost.c
  88. 18
      src/network.c
  89. 10
      src/network_sendfile.c
  90. 8
      src/network_write.c
  91. 10
      src/network_writev.c
  92. 14
      src/options.c
  93. 96
      src/plugin.c
  94. 204
      src/plugin_core.c
  95. 18
      src/radix.c
  96. 44
      src/request.c
  97. 64
      src/response.c
  98. 106
      src/server.c
  99. 34
      src/stat_cache.c
  100. 20
      src/tests.c
  101. Some files were not shown because too many files have changed in this diff Show More

@ -72,22 +72,22 @@ struct liAction {
};
/* no new/free function, so just use the struct direct (i.e. not a pointer) */
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);
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);
/** handle sublist now, remember current position (stack) */
LI_API void action_enter(liVRequest *vr, liAction *a);
LI_API liHandlerResult action_execute(liVRequest *vr);
LI_API void li_action_enter(liVRequest *vr, liAction *a);
LI_API liHandlerResult li_action_execute(liVRequest *vr);
LI_API void action_release(liServer *srv, liAction *a);
LI_API void action_acquire(liAction *a);
LI_API void li_action_release(liServer *srv, liAction *a);
LI_API void li_action_acquire(liAction *a);
/* create new action */
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);
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);
#endif

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

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

@ -59,11 +59,11 @@ struct liAngelCall {
};
/* error handling */
#define LI_ANGEL_CALL_ERROR angel_call_error_quark()
LI_API GQuark angel_call_error_quark();
#define LI_ANGEL_CALL_ERROR li_angel_call_error_quark()
LI_API GQuark li_angel_call_error_quark();
#define LI_ANGEL_CONNECTION_ERROR angel_connection_error_quark()
LI_API GQuark angel_connection_error_quark();
#define LI_ANGEL_CONNECTION_ERROR li_angel_connection_error_quark()
LI_API GQuark li_angel_connection_error_quark();
typedef enum {
LI_ANGEL_CALL_ALREADY_RUNNING, /* the angel_call struct is already in use for a call */
@ -77,39 +77,39 @@ typedef enum {
} liAngelConnectionError;
/* create connection */
LI_API liAngelConnection* angel_connection_new(
LI_API liAngelConnection* li_angel_connection_new(
struct ev_loop *loop, int fd, gpointer data,
liAngelReceiveCallCB recv_call, liAngelCloseCB close_cb);
LI_API void angel_connection_free(liAngelConnection *acon);
LI_API void li_angel_connection_free(liAngelConnection *acon);
LI_API liAngelCall *angel_call_new(liAngelCallCB callback, ev_tstamp timeout);
LI_API liAngelCall *li_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(liAngelCall *call);
LI_API gboolean li_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(
LI_API gboolean li_angel_send_simple_call(
liAngelConnection *acon,
const gchar *mod, gsize mod_len, const gchar *action, gsize action_len,
GString *data,
GError **err);
LI_API gboolean angel_send_call(
LI_API gboolean li_angel_send_call(
liAngelConnection *acon,
const gchar *mod, gsize mod_len, const gchar *action, gsize action_len,
liAngelCall *call,
GString *data,
GError **err);
LI_API gboolean angel_send_result(
LI_API gboolean li_angel_send_result(
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(liAngelConnection *acon);
LI_API void li_angel_cleanup_tables(liAngelConnection *acon);
/* Usage */
#if 0
@ -131,7 +131,7 @@ gboolean start_call(curctx) {
return TRUE;
}
data = build_call_data();
if (!angel_send_call(acon, CONST_STR_LEN("mymod"), CONST_STR_LEN("myaction"), &ctx->call, 10, data, &err)) {
if (!li_angel_send_call(acon, CONST_STR_LEN("mymod"), CONST_STR_LEN("myaction"), &ctx->call, 10, data, &err)) {
unlock();
report_error(&err);
return FALSE;

@ -27,8 +27,8 @@ struct liAngelBuffer {
};
/* error handling */
#define LI_ANGEL_DATA_ERROR angel_data_error_quark()
LI_API GQuark angel_data_error_quark();
#define LI_ANGEL_DATA_ERROR li_angel_data_error_quark()
LI_API GQuark li_angel_data_error_quark();
typedef enum {
LI_ANGEL_DATA_ERROR_EOF, /* not enough data to read value */
@ -37,11 +37,11 @@ typedef enum {
} liAngelDataError;
/* write */
LI_API gboolean angel_data_write_int32(GString *buf, gint32 i, GError **err);
LI_API gboolean angel_data_write_int64(GString *buf, gint64 i, GError **err);
LI_API gboolean angel_data_write_char (GString *buf, gchar c, GError **err);
LI_API gboolean angel_data_write_str (GString *buf, const GString *str, GError **err);
LI_API gboolean angel_data_write_cstr (GString *buf, const gchar *str, gsize len, GError **err);
LI_API gboolean li_angel_data_write_int32(GString *buf, gint32 i, GError **err);
LI_API gboolean li_angel_data_write_int64(GString *buf, gint64 i, GError **err);
LI_API gboolean li_angel_data_write_char (GString *buf, gchar c, GError **err);
LI_API gboolean li_angel_data_write_str (GString *buf, const GString *str, GError **err);
LI_API gboolean li_angel_data_write_cstr (GString *buf, const gchar *str, gsize len, GError **err);
/* read:
* - if the val pointer is NULL, the data will be discarded
@ -49,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(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);
LI_API gboolean li_angel_data_read_int32(liAngelBuffer *buf, gint32 *val, GError **err);
LI_API gboolean li_angel_data_read_int64(liAngelBuffer *buf, gint64 *val, GError **err);
LI_API gboolean li_angel_data_read_char (liAngelBuffer *buf, gchar *val, GError **err);
LI_API gboolean li_angel_data_read_str (liAngelBuffer *buf, GString **val, GError **err);
LI_API gboolean li_angel_data_read_mem (liAngelBuffer *buf, GString **val, gsize len, GError **err);
#endif

@ -9,34 +9,34 @@
#define LI_REMOVE_PATH_FROM_FILE 1
#if LI_REMOVE_PATH_FROM_FILE
LI_API const char *remove_path(const char *path);
#define LI_REMOVE_PATH(file) remove_path(file)
LI_API const char *li_remove_path(const char *path);
#define LI_REMOVE_PATH(file) li_remove_path(file)
#else
#define LI_REMOVE_PATH(file) file
#endif
#define SEGFAULT(srv, fmt, ...) \
do { \
log_write_(srv, LI_LOG_LEVEL_ABORT, LI_LOG_FLAG_TIMESTAMP, "(crashing) %s.%d: "fmt, LI_REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__); \
li_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, LI_LOG_LEVEL_ERROR, LI_LOG_FLAG_TIMESTAMP, "error (%s:%d): "fmt, LI_REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__)
li_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, LI_LOG_LEVEL_WARNING, LI_LOG_FLAG_TIMESTAMP, "warning (%s:%d): "fmt, LI_REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__)
li_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, LI_LOG_LEVEL_INFO, LI_LOG_FLAG_TIMESTAMP, "info (%s:%d): "fmt, LI_REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__)
li_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, LI_LOG_LEVEL_DEBUG, LI_LOG_FLAG_TIMESTAMP, "debug (%s:%d): "fmt, LI_REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__)
li_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, LI_LOG_LEVEL_ERROR, LI_LOG_FLAG_NONE, "lighttpd[%d]: %s", (int) inst->pid, msg)
li_log_write(srv, LI_LOG_LEVEL_ERROR, LI_LOG_FLAG_NONE, "lighttpd[%d]: %s", (int) inst->pid, msg)
typedef enum {
LI_LOG_LEVEL_DEBUG,
@ -76,6 +76,6 @@ struct liLog {
void log_init(liServer *srv);
void log_clean(liServer *srv);
LI_API void log_write(liServer *srv, liLogLevel log_level, guint flags, const gchar *fmt, ...) G_GNUC_PRINTF(4, 5);
LI_API void li_log_write(liServer *srv, liLogLevel log_level, guint flags, const gchar *fmt, ...) G_GNUC_PRINTF(4, 5);
#endif

@ -77,6 +77,6 @@ void plugins_handle_item(liServer *srv, GString *itemname, liValue *hash);
/* "core" is a reserved module name for interal use */
gboolean plugins_load_module(liServer *srv, const gchar *name);
/* Needed by modules to register their plugin(s) */
LI_API liPlugin *angel_plugin_register(liServer *srv, liModule *mod, const gchar *name, liPluginInitCB init);
LI_API liPlugin *li_angel_plugin_register(liServer *srv, liModule *mod, const gchar *name, liPluginInitCB init);
#endif

@ -60,20 +60,20 @@ struct liServer {
liLog log;
};
LI_API liServer* server_new(const gchar *module_dir);
LI_API void server_free(liServer* srv);
LI_API liServer* li_server_new(const gchar *module_dir);
LI_API void li_server_free(liServer* srv);
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 liInstance* li_server_new_instance(liServer *srv, liInstanceConf *ic);
LI_API void li_instance_replace(liInstance *oldi, liInstance *newi);
LI_API void li_instance_set_state(liInstance *i, liInstanceState s);
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 liInstanceConf* li_instance_conf_new(gchar **cmd, GString *username, uid_t uid, gid_t gid);
LI_API void li_instance_conf_release(liInstanceConf *ic);
LI_API void li_instance_conf_acquire(liInstanceConf *ic);
LI_API void instance_release(liInstance *i);
LI_API void instance_acquire(liInstance *i);
LI_API void li_instance_release(liInstance *i);
LI_API void li_instance_acquire(liInstance *i);
LI_API void instance_job_append(liInstance *i);
LI_API void li_instance_job_append(liInstance *i);
#endif

@ -40,19 +40,19 @@ struct liValue {
} data;
};
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 liValue* li_value_new_none();
LI_API liValue* li_value_new_bool(gboolean val);
LI_API liValue* li_value_new_number(gint64 val);
LI_API liValue* li_value_new_string(GString *val);
LI_API liValue* li_value_new_range(liValueRange val);
LI_API liValue* li_value_new_list();
LI_API liValue* li_value_new_hash();
LI_API liValue* value_copy(liValue* val);
LI_API void value_free(liValue* val);
LI_API liValue* li_value_copy(liValue* val);
LI_API void li_value_free(liValue* val);
LI_API const char* value_type_string(liValueType type);
LI_API const char* li_value_type_string(liValueType type);
LI_API GString *value_to_string(liValue *val);
LI_API GString *li_value_to_string(liValue *val);
#endif

@ -77,7 +77,7 @@ struct liChunkIter {
/* open the file cf->name if it is not already opened for reading
* may return HANDLER_GO_ON, HANDLER_ERROR
*/
LI_API liHandlerResult chunkfile_open(liVRequest *vr, liChunkFile *cf);
LI_API liHandlerResult li_chunkfile_open(liVRequest *vr, liChunkFile *cf);
/******************
* chunk iterator *
@ -91,12 +91,12 @@ INLINE goffset chunkiter_length(liChunkIter iter);
* 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 liHandlerResult chunkiter_read(liVRequest *vr, liChunkIter iter, off_t start, off_t length, char **data_start, off_t *data_len);
LI_API liHandlerResult li_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();
/* same as li_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 liHandlerResult chunkiter_read_mmap(liVRequest *vr, liChunkIter iter, off_t start, off_t length, char **data_start, off_t *data_len);
LI_API liHandlerResult li_chunkiter_read_mmap(liVRequest *vr, liChunkIter iter, off_t start, off_t length, char **data_start, off_t *data_len);
/******************
* chunk *
@ -108,66 +108,66 @@ INLINE goffset chunk_length(liChunk *c);
* cqlimit *
******************/
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);
LI_API liCQLimit* li_cqlimit_new(liVRequest *vr);
LI_API void li_cqlimit_reset(liCQLimit *cql);
LI_API void li_cqlimit_acquire(liCQLimit *cql);
LI_API void li_cqlimit_release(liCQLimit *cql);
LI_API void li_cqlimit_set_limit(liCQLimit *cql, goffset limit);
/******************
* chunkqueue *
******************/
LI_API liChunkQueue* chunkqueue_new();
LI_API void chunkqueue_reset(liChunkQueue *cq);
LI_API void chunkqueue_free(liChunkQueue *cq);
LI_API liChunkQueue* li_chunkqueue_new();
LI_API void li_chunkqueue_reset(liChunkQueue *cq);
LI_API void li_chunkqueue_free(liChunkQueue *cq);
LI_API void chunkqueue_use_limit(liChunkQueue *cq, liVRequest *vr);
LI_API void chunkqueue_set_limit(liChunkQueue *cq, liCQLimit* cql);
LI_API void li_chunkqueue_use_limit(liChunkQueue *cq, liVRequest *vr);
LI_API void li_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(liChunkQueue *cq);
LI_API goffset li_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(liChunkQueue *cq, GString *str);
LI_API void li_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(liChunkQueue *cq, GByteArray *mem);
LI_API void li_chunkqueue_append_bytearr(liChunkQueue *cq, GByteArray *mem);
/* memory gets copied */
LI_API void chunkqueue_append_mem(liChunkQueue *cq, const void *mem, gssize len);
LI_API void li_chunkqueue_append_mem(liChunkQueue *cq, const void *mem, gssize len);
/* pass ownership of filename, do not free it */
LI_API void chunkqueue_append_file(liChunkQueue *cq, GString *filename, off_t start, off_t length);
LI_API void li_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(liChunkQueue *cq, GString *filename, off_t start, off_t length, int fd);
LI_API void li_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(liChunkQueue *cq, GString *filename, off_t start, off_t length);
LI_API void li_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(liChunkQueue *cq, GString *filename, off_t start, off_t length, int fd);
LI_API void li_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(liChunkQueue *out, liChunkQueue *in, goffset length);
LI_API goffset li_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(liChunkQueue *out, liChunkQueue *in);
LI_API goffset li_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(liChunkQueue *out, liChunkQueue *in);
LI_API goffset li_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(liChunkQueue *cq, goffset length);
LI_API goffset li_chunkqueue_skip(liChunkQueue *cq, goffset length);
/* skip all chunks in a queue (similar to reset, but keeps stats) */
LI_API goffset chunkqueue_skip_all(liChunkQueue *cq);
LI_API goffset li_chunkqueue_skip_all(liChunkQueue *cq);
/* if the chunk an iterator refers gets stolen/skipped/...,
* the iterator isn't valid anymore
@ -176,8 +176,8 @@ INLINE liChunkIter chunkqueue_iter(liChunkQueue *cq);
INLINE liChunk* chunkqueue_first_chunk(liChunkQueue *cq);
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);
LI_API gboolean li_chunkqueue_extract_to(liVRequest *vr, liChunkQueue *cq, goffset len, GString *dest);
LI_API gboolean li_chunkqueue_extract_to_bytearr(liVRequest *vr, liChunkQueue *cq, goffset len, GByteArray *dest);
/********************
* Inline functions *

@ -25,14 +25,14 @@ struct liChunkParserMark {
off_t pos;
};
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(liVRequest *vr, liChunkParserMark from, liChunkParserMark to, GString *dest);
LI_API GString* chunk_extract(liVRequest *vr, liChunkParserMark from, liChunkParserMark to);
LI_API void li_chunk_parser_init(liChunkParserCtx *ctx, liChunkQueue *cq);
LI_API void li_chunk_parser_reset(liChunkParserCtx *ctx);
LI_API liHandlerResult li_chunk_parser_prepare(liChunkParserCtx *ctx);
LI_API liHandlerResult li_chunk_parser_next(liVRequest *vr, liChunkParserCtx *ctx, char **p, char **pe);
LI_API void li_chunk_parser_done(liChunkParserCtx *ctx, goffset len);
LI_API gboolean li_chunk_extract_to(liVRequest *vr, liChunkParserMark from, liChunkParserMark to, GString *dest);
LI_API GString* li_chunk_extract(liVRequest *vr, liChunkParserMark from, liChunkParserMark to);
INLINE liChunkParserMark chunk_parser_getmark(liChunkParserCtx *ctx, const char *fpc);

@ -20,17 +20,17 @@ typedef gpointer (*liCollectFuncCB)(liWorker *wrk, gpointer fdata);
* - fdata : the data the CollectFunc got (this data must be valid until cb is called)
* - result: the return values
* - complete: determines if cbdata is still valid
* if this is FALSE, it may be called from another context than collect_start was called
* if this is FALSE, it may be called from another context than li_collect_start was called
*/
typedef void (*liCollectCB)(gpointer cbdata, gpointer fdata, GPtrArray *result, gboolean complete);
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 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 */
/** li_collect_start returns NULL if the callback was called directly (e.g. for only one worker and ctx = wrk) */
LI_API liCollectInfo* li_collect_start(liWorker *ctx, liCollectFuncCB func, gpointer fdata, liCollectCB cb, gpointer cbdata);
LI_API void li_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);
LI_API void li_collect_watcher_cb(struct ev_loop *loop, ev_async *w, int revents);
#endif

@ -52,7 +52,7 @@ typedef enum {
LI_COMP_PHYSICAL_ISFILE,
/* needs a key */
LI_COMP_REQUEST_HEADER, /**< needs lowercase key, enforced by condition_lvalue_new */
LI_COMP_REQUEST_HEADER, /**< needs lowercase key, enforced by li_condition_lvalue_new */
LI_COMP_UNKNOWN
} liCondLValue;
@ -106,21 +106,21 @@ struct liCondition {
};
/* 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 liConditionLValue* li_condition_lvalue_new(liCondLValue type, GString *key);
LI_API void li_condition_lvalue_acquire(liConditionLValue *lvalue);
LI_API void li_condition_lvalue_release(liConditionLValue *lvalue);
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 liCondition* li_condition_new_bool(liServer *srv, liConditionLValue *lvalue, gboolean b);
LI_API liCondition* li_condition_new_string(liServer *srv, liCompOperator op, liConditionLValue *lvalue, GString *str);
LI_API liCondition* li_condition_new_int(liServer *srv, liCompOperator op, liConditionLValue *lvalue, gint64 i);
LI_API void condition_acquire(liCondition *c);
LI_API void condition_release(liServer *srv, liCondition* c);
LI_API void li_condition_acquire(liCondition *c);
LI_API void li_condition_release(liServer *srv, liCondition* c);
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);
LI_API const char* li_comp_op_to_string(liCompOperator op);
LI_API const char* li_cond_lvalue_to_string(liCondLValue t);
LI_API liCondLValue li_cond_lvalue_from_string(const gchar *str, guint len);
LI_API liHandlerResult condition_check(liVRequest *vr, liCondition *cond, gboolean *result);
LI_API liHandlerResult li_condition_check(liVRequest *vr, liCondition *cond, gboolean *result);
#endif

@ -3,6 +3,6 @@
#include <lighttpd/base.h>
LI_API gboolean config_lua_load(liServer *srv, const gchar *filename);
LI_API gboolean li_config_lua_load(liServer *srv, const gchar *filename);
#endif

@ -93,17 +93,17 @@ struct liConnection {
} stats;
};
LI_API liConnection* connection_new(liWorker *wrk);
LI_API void connection_reset(liConnection *con);
LI_API void connection_reset_keep_alive(liConnection *con);
LI_API void connection_free(liConnection *con);
LI_API liConnection* li_connection_new(liWorker *wrk);
LI_API void li_connection_reset(liConnection *con);
LI_API void li_connection_reset_keep_alive(liConnection *con);
LI_API void li_connection_free(liConnection *con);
LI_API void connection_error(liConnection *con);
LI_API void connection_internal_error(liConnection *con);
LI_API void li_connection_error(liConnection *con);
LI_API void li_connection_internal_error(liConnection *con);
LI_API void connection_handle_direct(liConnection *con);
LI_API void connection_handle_indirect(liConnection *con, liPlugin *p);
LI_API void li_connection_handle_direct(liConnection *con);
LI_API void li_connection_handle_indirect(liConnection *con, liPlugin *p);
LI_API gchar *connection_state_str(liConnectionState state);
LI_API gchar *li_connection_state_str(liConnectionState state);
#endif

@ -17,25 +17,25 @@ struct liEnvironmentDup {
GHashTable *table;
};
LI_API void environment_init(liEnvironment *env);
LI_API void environment_reset(liEnvironment *env);
LI_API void environment_clear(liEnvironment *env);
LI_API void li_environment_init(liEnvironment *env);
LI_API void li_environment_reset(liEnvironment *env);
LI_API void li_environment_clear(liEnvironment *env);
/* overwrite previous value */
LI_API void environment_set(liEnvironment *env, const gchar *key, size_t keylen, const gchar *val, size_t valuelen);
LI_API void li_environment_set(liEnvironment *env, const gchar *key, size_t keylen, const gchar *val, size_t valuelen);
/* do not overwrite */
LI_API void environment_insert(liEnvironment *env, const gchar *key, size_t keylen, const gchar *val, size_t valuelen);
LI_API void environment_remove(liEnvironment *env, const gchar *key, size_t keylen);
LI_API GString* environment_get(liEnvironment *env, const gchar *key, size_t keylen);
LI_API void li_environment_insert(liEnvironment *env, const gchar *key, size_t keylen, const gchar *val, size_t valuelen);
LI_API void li_environment_remove(liEnvironment *env, const gchar *key, size_t keylen);
LI_API GString* li_environment_get(liEnvironment *env, const gchar *key, size_t keylen);
/* create (data) read only copy of a environment; don't modify the real environment
while using the duplicate */
LI_API liEnvironmentDup* environment_make_dup(liEnvironment *env);
LI_API void environment_dup_free(liEnvironmentDup *envdup);
LI_API liEnvironmentDup* li_environment_make_dup(liEnvironment *env);
LI_API void li_environment_dup_free(liEnvironmentDup *envdup);
/* remove an entry (this is allowed - it doesn't modify anything in the original environment);
you must not modify the returned GString */
LI_API GString* environment_dup_pop(liEnvironmentDup *envdup, const gchar *key, size_t keylen);
LI_API GString* li_environment_dup_pop(liEnvironmentDup *envdup, const gchar *key, size_t keylen);
#endif

@ -5,11 +5,11 @@
#error Please include <lighttpd/base.h> instead of this file
#endif
LI_API tristate_t http_response_handle_cachable_etag(liVRequest *vr, GString *etag);
LI_API tristate_t http_response_handle_cachable_modified(liVRequest *vr, GString *last_modified);
LI_API tristate_t li_http_response_handle_cachable_etag(liVRequest *vr, GString *etag);
LI_API tristate_t li_http_response_handle_cachable_modified(liVRequest *vr, GString *last_modified);
/* mut maybe the same as etag */
LI_API void etag_mutate(GString *mut, GString *etag);
LI_API void etag_set_header(liVRequest *vr, struct stat *st, gboolean *cachable);
LI_API void li_etag_mutate(GString *mut, GString *etag);
LI_API void li_etag_set_header(liVRequest *vr, struct stat *st, gboolean *cachable);
#endif

@ -3,7 +3,7 @@
#include <lighttpd/base.h>
LI_API liHandlerResult filter_chunked_encode(liConnection *con, liChunkQueue *out, liChunkQueue *in);
LI_API liHandlerResult filter_chunked_decode(liConnection *con, liChunkQueue *out, liChunkQueue *in);
LI_API liHandlerResult li_filter_chunked_encode(liConnection *con, liChunkQueue *out, liChunkQueue *in);
LI_API liHandlerResult li_filter_chunked_decode(liConnection *con, liChunkQueue *out, liChunkQueue *in);
#endif

@ -22,30 +22,30 @@ struct liHttpHeaders {
/* strings alweays get copied, so you should free key and value yourself */
LI_API liHttpHeaders* http_headers_new();
LI_API void http_headers_reset(liHttpHeaders* headers);
LI_API void http_headers_free(liHttpHeaders* headers);
LI_API liHttpHeaders* li_http_headers_new();
LI_API void li_http_headers_reset(liHttpHeaders* headers);
LI_API void li_http_headers_free(liHttpHeaders* headers);
/** If header does not exist, just insert normal header. If it exists, append (", %s", value) */
LI_API void http_header_append(liHttpHeaders *headers, const gchar *key, size_t keylen, const gchar *val, size_t valuelen);
LI_API void li_http_header_append(liHttpHeaders *headers, const gchar *key, size_t keylen, const gchar *val, size_t valuelen);
/** If header does not exist, just insert normal header. If it exists, append ("\r\n%s: %s", key, value) */
LI_API void http_header_insert(liHttpHeaders *headers, const gchar *key, size_t keylen, const gchar *val, size_t valuelen);
LI_API void li_http_header_insert(liHttpHeaders *headers, const gchar *key, size_t keylen, const gchar *val, size_t valuelen);
/** If header does not exist, just insert normal header. If it exists, overwrite the value */
LI_API void http_header_overwrite(liHttpHeaders *headers, const gchar *key, size_t keylen, const gchar *val, size_t valuelen);
LI_API gboolean http_header_remove(liHttpHeaders *headers, const gchar *key, size_t keylen);
LI_API void http_header_remove_link(liHttpHeaders *headers, GList *l);
LI_API void li_http_header_overwrite(liHttpHeaders *headers, const gchar *key, size_t keylen, const gchar *val, size_t valuelen);
LI_API gboolean li_http_header_remove(liHttpHeaders *headers, const gchar *key, size_t keylen);
LI_API void li_http_header_remove_link(liHttpHeaders *headers, GList *l);
LI_API liHttpHeader* http_header_lookup(liHttpHeaders *headers, const gchar *key, size_t keylen);
LI_API liHttpHeader* li_http_header_lookup(liHttpHeaders *headers, const gchar *key, size_t keylen);
LI_API GList* http_header_find_first(liHttpHeaders *headers, const gchar *key, size_t keylen);
LI_API GList* http_header_find_next(GList *l, const gchar *key, size_t keylen);
LI_API GList* http_header_find_last(liHttpHeaders *headers, const gchar *key, size_t keylen);
LI_API GList* li_http_header_find_first(liHttpHeaders *headers, const gchar *key, size_t keylen);
LI_API GList* li_http_header_find_next(GList *l, const gchar *key, size_t keylen);
LI_API GList* li_http_header_find_last(liHttpHeaders *headers, const gchar *key, size_t keylen);
/** Use lowercase keys! values are compared case-insensitive */
LI_API gboolean http_header_is(liHttpHeaders *headers, const gchar *key, size_t keylen, const gchar *val, size_t valuelen);
LI_API gboolean li_http_header_is(liHttpHeaders *headers, const gchar *key, size_t keylen, const gchar *val, size_t valuelen);
/** concats all headers with key with ', ' - empty if no header exists - use lowercase key*/
LI_API void http_header_get_fast(GString *dest, liHttpHeaders *headers, const gchar *key, size_t keylen);
LI_API void li_http_header_get_fast(GString *dest, liHttpHeaders *headers, const gchar *key, size_t keylen);
INLINE gboolean http_header_key_is(liHttpHeader *h, const gchar *key, size_t keylen) {
return (h->keylen == keylen && 0 == g_ascii_strncasecmp(key, h->data->str, keylen));

@ -13,11 +13,11 @@ struct liHttpRequestCtx {
GString *h_key, *h_value;
};
LI_API void http_request_parser_init(liHttpRequestCtx* ctx, liRequest *req, liChunkQueue *cq);
LI_API void http_request_parser_reset(liHttpRequestCtx* ctx);
LI_API void http_request_parser_clear(liHttpRequestCtx *ctx);
LI_API void li_http_request_parser_init(liHttpRequestCtx* ctx, liRequest *req, liChunkQueue *cq);
LI_API void li_http_request_parser_reset(liHttpRequestCtx* ctx);
LI_API void li_http_request_parser_clear(liHttpRequestCtx *ctx);
LI_API liHandlerResult http_request_parse(liVRequest *vr, liHttpRequestCtx *ctx);
LI_API liHandlerResult li_http_request_parse(liVRequest *vr, liHttpRequestCtx *ctx);
#endif

@ -15,11 +15,11 @@ struct liHttpResponseCtx {
GString *h_key, *h_value;
};
LI_API void http_response_parser_init(liHttpResponseCtx* ctx, liResponse *req, liChunkQueue *cq, gboolean accept_cgi, gboolean accept_nph);
LI_API void http_response_parser_reset(liHttpResponseCtx* ctx);
LI_API void http_response_parser_clear(liHttpResponseCtx *ctx);
LI_API void li_http_response_parser_init(liHttpResponseCtx* ctx, liResponse *req, liChunkQueue *cq, gboolean accept_cgi, gboolean accept_nph);
LI_API void li_http_response_parser_reset(liHttpResponseCtx* ctx);
LI_API void li_http_response_parser_clear(liHttpResponseCtx *ctx);
LI_API liHandlerResult http_response_parse(liVRequest *vr, liHttpResponseCtx *ctx);
LI_API liHandlerResult li_http_response_parse(liVRequest *vr, liHttpResponseCtx *ctx);
#endif

@ -24,18 +24,18 @@ struct liIDList {
};
/* create new idlist; the parameter max_ids is "signed" on purpose */
LI_API liIDList* idlist_new(gint max_ids);
LI_API liIDList* li_idlist_new(gint max_ids);
/* free idlist */
LI_API void idlist_free(liIDList *l);
LI_API void li_idlist_free(liIDList *l);
/* request new id; return -1 if no id is available, valid ids are always > 0 */
LI_API gint idlist_get(liIDList *l);
LI_API gint li_idlist_get(liIDList *l);
/* check whether an id is in use and can be "_put" */
LI_API gboolean idlist_is_used(liIDList *l, gint id);
LI_API gboolean li_idlist_is_used(liIDList *l, gint id);
/* release id. never release an id more than once! */
LI_API void idlist_put(liIDList *l, gint id);
LI_API void li_idlist_put(liIDList *l, gint id);
#endif

@ -4,10 +4,10 @@
#include <lighttpd/settings.h>
/** parse an IPv4 (if netmask is not NULL with optional cidr netmask, if port is not NULL with optional port) */
LI_API gboolean parse_ipv4(const char *str, guint32 *ip, guint32 *netmask, guint16 *port);
LI_API gboolean li_parse_ipv4(const char *str, guint32 *ip, guint32 *netmask, guint16 *port);
/** parse an IPv6 (if network is not NULL with optional cidr network, if port is not NULL with optional port if the ip/cidr part is in [...]) */
LI_API gboolean parse_ipv6(const char *str, guint8 *ip, guint *network, guint16 *port);
LI_API gboolean li_parse_ipv6(const char *str, guint8 *ip, guint *network, guint16 *port);
/** print the ip into dest, return dest */
LI_API GString* ipv6_tostring(GString *dest, const guint8 ip[16]);
LI_API GString* li_ipv6_tostring(GString *dest, const guint8 ip[16]);
#endif

@ -6,15 +6,15 @@
#endif
/* returns the description for a given http status code and sets the len to the length of the returned string */
LI_API gchar *http_status_string(guint status_code, guint *len);
LI_API gchar *li_http_status_string(guint status_code, guint *len);
/* returns the http method as a string and sets len to the length of the returned string */
LI_API gchar *http_method_string(liHttpMethod method, guint *len);
LI_API gchar *li_http_method_string(liHttpMethod method, guint *len);
/* returns the http version as a string and sets len to the length of the returned string */
LI_API gchar *http_version_string(liHttpVersion method, guint *len);
LI_API gchar *li_http_version_string(liHttpVersion method, guint *len);
/* converts a given 3 digit http status code to a gchar[3] string. e.g. 403 to {'4','0','3'} */
LI_API void http_status_to_str(gint status_code, gchar status_str[]);
LI_API void li_http_status_to_str(gint status_code, gchar status_str[]);
/* looks up the mimetype for a filename by comparing suffixes. first match is returned. do not free the result */
LI_API GString *mimetype_get(liVRequest *vr, GString *filename);
LI_API GString *li_mimetype_get(liVRequest *vr, GString *filename);
#endif

@ -9,35 +9,35 @@
#define REMOVE_PATH_FROM_FILE 1
#if REMOVE_PATH_FROM_FILE
LI_API const char *remove_path(const char *path);
#define REMOVE_PATH(file) remove_path(file)
LI_API const char *li_remove_path(const char *path);
#define REMOVE_PATH(file) li_remove_path(file)
#else
#define REMOVE_PATH(file) file
#endif
#define _SEGFAULT(srv, vr, fmt, ...) \
do { \
log_write_(srv, NULL, LI_LOG_LEVEL_ABORT, LOG_FLAG_TIMESTAMP, "(crashing) %s.%d: "fmt, REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__); \
li_log_write_(srv, NULL, LI_LOG_LEVEL_ABORT, LOG_FLAG_TIMESTAMP, "(crashing) %s.%d: "fmt, REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__); \
/* VALGRIND_PRINTF_BACKTRACE(fmt, __VA_ARGS__); */\
abort();\
} while(0)
#define _ERROR(srv, vr, fmt, ...) \
log_write_(srv, vr, LI_LOG_LEVEL_ERROR, LOG_FLAG_TIMESTAMP, "(error) %s.%d: "fmt, REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__)
li_log_write_(srv, vr, LI_LOG_LEVEL_ERROR, LOG_FLAG_TIMESTAMP, "(error) %s.%d: "fmt, REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__)
#define _WARNING(srv, vr, fmt, ...) \
log_write_(srv, vr, LI_LOG_LEVEL_WARNING, LOG_FLAG_TIMESTAMP, "(warning) %s.%d: "fmt, REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__)
li_log_write_(srv, vr, LI_LOG_LEVEL_WARNING, LOG_FLAG_TIMESTAMP, "(warning) %s.%d: "fmt, REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__)
#define _INFO(srv, vr, fmt, ...) \
log_write_(srv, vr, LI_LOG_LEVEL_INFO, LOG_FLAG_TIMESTAMP, "(info) %s.%d: "fmt, REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__)
li_log_write_(srv, vr, LI_LOG_LEVEL_INFO, LOG_FLAG_TIMESTAMP, "(info) %s.%d: "fmt, REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__)
#define _DEBUG(srv, vr, fmt, ...) \
log_write_(srv, vr, LI_LOG_LEVEL_DEBUG, LOG_FLAG_TIMESTAMP, "(debug) %s.%d: "fmt, REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__)
li_log_write_(srv, vr, LI_LOG_LEVEL_DEBUG, LOG_FLAG_TIMESTAMP, "(debug) %s.%d: "fmt, REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__)
#define _BACKEND(srv, vr, fmt, ...) \
log_write_(srv, vr, LI_LOG_LEVEL_BACKEND, LOG_FLAG_TIMESTAMP, "(backend) %s.%d: "fmt, REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__)
li_log_write_(srv, vr, LI_LOG_LEVEL_BACKEND, LOG_FLAG_TIMESTAMP, "(backend) %s.%d: "fmt, REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__)
#define _BACKEND_LINES(srv, vr, txt, fmt, ...) \
log_split_lines_(srv, vr, LI_LOG_LEVEL_BACKEND, LOG_FLAG_TIMESTAMP, txt, "(backend) %s.%d: "fmt, REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__)
li_log_split_lines_(srv, vr, LI_LOG_LEVEL_BACKEND, LOG_FLAG_TIMESTAMP, txt, "(backend) %s.%d: "fmt, REMOVE_PATH(__FILE__), __LINE__, __VA_ARGS__)
#define VR_SEGFAULT(vr, fmt, ...) _SEGFAULT(vr->wrk->srv, vr, fmt, __VA_ARGS__)
@ -55,7 +55,7 @@ LI_API const char *remove_path(const char *path);
#define DEBUG(srv, fmt, ...) _DEBUG(srv, NULL, fmt, __VA_ARGS__)
#define BACKEND(srv, fmt, ...) _BACKEND(srv, NULL, fmt, __VA_ARGS__)
/* flags for log_write */
/* flags for li_log_write */
#define LOG_FLAG_NONE (0x0) /* default flag */
#define LOG_FLAG_TIMESTAMP (0x1) /* prepend a timestamp to the log message */
#define LOG_FLAG_NOLOCK (0x1 << 1) /* for internal use only */
@ -118,17 +118,17 @@ void log_thread_wakeup(liServer *srv);
void log_init(liServer *srv);
void log_cleanup(liServer *srv);
/* log_write is used to directly write a message to a log target */
LI_API void log_write(liServer *srv, liLog *log, GString *msg);
/* log_write_ is used to write to the errorlog */
LI_API gboolean log_write_(liServer *srv, liVRequest *vr, liLogLevel log_level, guint flags, const gchar *fmt, ...) G_GNUC_PRINTF(5, 6);
/* li_log_write is used to directly write a message to a log target */
LI_API void li_log_write(liServer *srv, liLog *log, GString *msg);
/* li_log_write_ is used to write to the errorlog */
LI_API gboolean li_log_write_(liServer *srv, liVRequest *vr, liLogLevel log_level, guint flags, const gchar *fmt, ...) G_GNUC_PRINTF(5, 6);
LI_API liLogTimestamp *log_timestamp_new(liServer *srv, GString *format);
LI_API gboolean log_timestamp_free(liServer *srv, liLogTimestamp *ts);
LI_API liLogTimestamp *li_log_timestamp_new(liServer *srv, GString *format);
LI_API gboolean li_log_timestamp_free(liServer *srv, liLogTimestamp *ts);
/* replaces '\r' and '\n' with '\0' */
LI_API void log_split_lines(liServer *srv, liVRequest *vr, liLogLevel log_level, guint flags, gchar *txt, const gchar *prefix);
LI_API void log_split_lines_(liServer *srv, liVRequest *vr, liLogLevel log_level, guint flags, gchar *txt, const gchar *fmt, ...) G_GNUC_PRINTF(6, 7);
LI_API void li_log_split_lines(liServer *srv, liVRequest *vr, liLogLevel log_level, guint flags, gchar *txt, const gchar *prefix);
LI_API void li_log_split_lines_(liServer *srv, liVRequest *vr, liLogLevel log_level, guint flags, gchar *txt, const gchar *fmt, ...) G_GNUC_PRINTF(6, 7);
#endif

@ -15,9 +15,9 @@
} \
} while(0)
/** see module_load */
/** see li_module_load */
#define MODULE_DEPENDS(mods, name) do { \
if (!module_load(mods, name)) { \
if (!li_module_load(mods, name)) { \
ERROR(mods->main, "Couldn't load dependency '%s'", name); \
return FALSE; \
} } while(0)
@ -50,20 +50,20 @@ struct liModules {
guint8 sizeof_off_t; /** holds the value of sizeof(off_t) to check if loaded module was compiled with the same flags */
};
LI_API liModules* modules_new(gpointer main, const gchar *module_dir);
LI_API void modules_free(liModules *mods);
LI_API liModules* li_modules_new(gpointer main, const gchar *module_dir);
LI_API void li_modules_free(liModules *mods);
/** Loads a module if not loaded yet and returns the module struct for it (after increasing refcount)
* returns NULL if it couldn't load the module.
*
* You should release modules after you used them with module_release or module_release_name */
LI_API liModule* module_load(liModules *mods, const gchar* name);
* You should release modules after you used them with li_module_release or li_module_release_name */
LI_API liModule* li_module_load(liModules *mods, const gchar* name);
/* find module by name */
LI_API liModule *module_lookup(liModules *mods, const gchar *name);
LI_API liModule *li_module_lookup(liModules *mods, const gchar *name);
LI_API void module_acquire(liModule *mod);
LI_API void module_release(liModules *mods, liModule *mod);
LI_API void module_release_name(liModules *mods, const gchar* name);
LI_API void li_module_acquire(liModule *mod);
LI_API void li_module_release(liModules *mods, liModule *mod);
LI_API void li_module_release_name(liModules *mods, const gchar* name);
#endif

@ -19,25 +19,25 @@ typedef enum {
} liNetworkStatus;
/** repeats write after EINTR */
LI_API ssize_t net_write(int fd, void *buf, ssize_t nbyte);
LI_API ssize_t li_net_write(int fd, void *buf, ssize_t nbyte);
/** repeats read after EINTR */
LI_API ssize_t net_read(int fd, void *buf, ssize_t nbyte);
LI_API ssize_t li_net_read(int fd, void *buf, ssize_t nbyte);
LI_API liNetworkStatus network_write(liVRequest *vr, int fd, liChunkQueue *cq, goffset write_max);
LI_API liNetworkStatus network_read(liVRequest *vr, int fd, liChunkQueue *cq);
LI_API liNetworkStatus li_network_write(liVRequest *vr, int fd, liChunkQueue *cq, goffset write_max);
LI_API liNetworkStatus li_network_read(liVRequest *vr, int fd, liChunkQueue *cq);
/* use writev for mem chunks, buffered read/write for files */
LI_API liNetworkStatus network_write_writev(liVRequest *vr, int fd, liChunkQueue *cq, goffset *write_max);
LI_API liNetworkStatus li_network_write_writev(liVRequest *vr, int fd, liChunkQueue *cq, goffset *write_max);
#ifdef USE_SENDFILE
/* use sendfile for files, writev for mem chunks */
LI_API liNetworkStatus network_write_sendfile(liVRequest *vr, int fd, liChunkQueue *cq, goffset *write_max);
LI_API liNetworkStatus li_network_write_sendfile(liVRequest *vr, int fd, liChunkQueue *cq, goffset *write_max);
#endif
/* write backends */
LI_API liNetworkStatus network_backend_write(liVRequest *vr, int fd, liChunkQueue *cq, goffset *write_max);
LI_API liNetworkStatus network_backend_writev(liVRequest *vr, int fd, liChunkQueue *cq, goffset *write_max);
LI_API liNetworkStatus li_network_backend_write(liVRequest *vr, int fd, liChunkQueue *cq, goffset *write_max);
LI_API liNetworkStatus li_network_backend_writev(liVRequest *vr, int fd, liChunkQueue *cq, goffset *write_max);
#define LI_NETWORK_FALLBACK(f, write_max) do { \
liNetworkStatus res; \

@ -25,10 +25,10 @@ struct liOptionSet {
};
/* Extract content from value, value set to none */
LI_API liOptionValue value_extract(liValue *val);
LI_API liOptionValue li_value_extract(liValue *val);
LI_API gpointer value_extract_ptr(liValue *val);
LI_API gint64 value_extract_number(liValue *val);
LI_API gboolean value_extract_bool(liValue *val);
LI_API gpointer li_value_extract_ptr(liValue *val);
LI_API gint64 li_value_extract_number(liValue *val);
LI_API gboolean li_value_extract_bool(liValue *val);
#endif

@ -54,13 +54,13 @@ struct liPluginOption {
liValueType type;
gpointer default_value;
liPluginParseOptionCB parse_option;
liPluginParseOptionCB li_parse_option;
liPluginFreeOptionCB free_option;
};
struct liPluginAction {
const gchar *name;
liPluginCreateActionCB create_action;
liPluginCreateActionCB li_create_action;
};
struct liliPluginSetupCB {
@ -72,14 +72,14 @@ struct liliPluginSetupCB {
struct liServerOption {
liPlugin *p;
/** the value is freed with value_free after the parse call, so you
* probably want to extract the content via value_extract*
/** the value is freed with li_value_free after the parse call, so you
* probably want to extract the content via li_value_extract*
* val is zero to get the global default value if nothing is specified
* save result in value
*
* Default behaviour (NULL) is to extract the inner value from val
*/
liPluginParseOptionCB parse_option;
liPluginParseOptionCB li_parse_option;
/** the free_option handler has to free all allocated resources;
* it may get called with 0 initialized options, so you have to
@ -87,7 +87,7 @@ struct liServerOption {
*/
liPluginFreeOptionCB free_option;
/** if parse_option is NULL, the default_value is used; it is only used
/** if li_parse_option is NULL, the default_value is used; it is only used
* for the following value types:
* - BOOLEAN, NUMBER: casted with GPOINTER_TO_INT, i.e. set it with GINT_TO_POINTER
* the numbers are limited to the 32-bit range according to the glib docs
@ -101,7 +101,7 @@ struct liServerOption {
struct liServerAction {
liPlugin *p;
liPluginCreateActionCB create_action;
liPluginCreateActionCB li_create_action;
};
struct liServerSetup {
@ -110,32 +110,32 @@ struct liServerSetup {
};
/* Needed by modules to register their plugin(s) */
LI_API liPlugin *plugin_register(liServer *srv, const gchar *name, liPluginInitCB init);
LI_API liPlugin *li_plugin_register(liServer *srv, const gchar *name, liPluginInitCB init);
/* Internal needed functions */
LI_API void plugin_free(liServer *srv, liPlugin *p);
LI_API void server_plugins_free(liServer *srv);
LI_API void li_plugin_free(liServer *srv, liPlugin *p);
LI_API void li_server_plugins_free(liServer *srv);
/** free val after call (val may be modified by parser) */
LI_API gboolean parse_option(liServer *srv, const char *name, liValue *val, liOptionSet *mark);
LI_API void release_option(liServer *srv, liOptionSet *mark); /**< Does not free the option_set memory */
LI_API gboolean li_parse_option(liServer *srv, const char *name, liValue *val, liOptionSet *mark);
LI_API void li_release_option(liServer *srv, liOptionSet *mark); /**< Does not free the option_set memory */
LI_API void plugins_prepare_callbacks(liServer *srv);
LI_API void plugins_handle_close(liConnection *con);
LI_API void plugins_handle_vrclose(liVRequest *vr);
LI_API void li_plugins_prepare_callbacks(liServer *srv);
LI_API void li_plugins_handle_close(liConnection *con);
LI_API void li_plugins_handle_vrclose(liVRequest *vr);
/* Needed for config frontends */
/** For parsing 'somemod.option = "somevalue"', free value after call */
LI_API liAction* option_action(liServer *srv, const gchar *name, liValue *val);
LI_API liAction* li_option_action(liServer *srv, const gchar *name, liValue *val);
/** For parsing 'somemod.action value', e.g. 'rewrite "/url" => "/destination"'
* free value after call
*/
LI_API liAction* create_action(liServer *srv, const gchar *name, liValue *val);
LI_API liAction* li_create_action(liServer *srv, const gchar *name, liValue *val);
/** For setup function, e.g. 'listen "127.0.0.1:8080"'; free value after call */
LI_API gboolean call_setup(liServer *srv, const char *name, liValue *val);
LI_API gboolean li_call_setup(liServer *srv, const char *name, liValue *val);
/** free val after call */
LI_API gboolean plugin_set_default_option(liServer *srv, const gchar* name, liValue *val);
LI_API gboolean li_plugin_set_default_option(liServer *srv, const gchar* name, liValue *val);
/* needs vrequest *vr and plugin *p */
#define OPTION(idx) _OPTION(vr, p, idx)

@ -27,19 +27,19 @@ struct liRadixTree32 {
};
LI_API liRadixTree32 *radixtree32_new(guint32 root_width);
LI_API guint32 radixtree32_free(liRadixTree32 *tree);
LI_API liRadixTree32 *li_radixtree32_new(guint32 root_width);
LI_API guint32 li_radixtree32_free(liRadixTree32 *tree);
LI_API void radixtree32_insert(liRadixTree32 *tree, guint32 key, guint32 mask, gpointer data);
LI_API gboolean radixtree32_remove(liRadixTree32 *tree, guint32 key, guint32 mask);
LI_API void li_radixtree32_insert(liRadixTree32 *tree, guint32 key, guint32 mask, gpointer data);
LI_API gboolean li_radixtree32_remove(liRadixTree32 *tree, guint32 key, guint32 mask);
/* lookup tree node (best match) */
LI_API liRadixNode32 *radixtree32_lookup_node(liRadixTree32 *tree, guint32 key);
LI_API liRadixNode32 *li_radixtree32_lookup_node(liRadixTree32 *tree, guint32 key);
/* lookup data pointer (best match) */
LI_API gpointer radixtree32_lookup(liRadixTree32 *tree, guint32 key);
LI_API gpointer li_radixtree32_lookup(liRadixTree32 *tree, guint32 key);
/* lookup data pointer (exact match) */
LI_API gpointer radixtree32_lookup_exact(liRadixTree32 *tree, guint32 key);
LI_API gpointer li_radixtree32_lookup_exact(liRadixTree32 *tree, guint32 key);