Browse Source

[multiple] plugin.c handles common FREE_FUNC code

(simpler for modules; less boilerplate to cut-n-paste)
personal/stbuehler/ci-build
Glenn Strauss 2 years ago
parent
commit
b73949e03f
  1. 9
      src/gw_backend.c
  2. 2
      src/gw_backend.h
  3. 12
      src/mod_access.c
  4. 18
      src/mod_accesslog.c
  5. 12
      src/mod_alias.c
  6. 15
      src/mod_auth.c
  7. 11
      src/mod_authn_file.c
  8. 11
      src/mod_authn_gssapi.c
  9. 14
      src/mod_authn_ldap.c
  10. 17
      src/mod_authn_mysql.c
  11. 11
      src/mod_authn_pam.c
  12. 18
      src/mod_authn_sasl.c
  13. 10
      src/mod_cgi.c
  14. 23
      src/mod_cml.c
  15. 8
      src/mod_compress.c
  16. 8
      src/mod_deflate.c
  17. 19
      src/mod_dirlisting.c
  18. 12
      src/mod_evasive.c
  19. 21
      src/mod_evhost.c
  20. 12
      src/mod_expire.c
  21. 18
      src/mod_extforward.c
  22. 12
      src/mod_flv_streaming.c
  23. 16
      src/mod_geoip.c
  24. 12
      src/mod_indexfile.c
  25. 8
      src/mod_magnet.c
  26. 18
      src/mod_maxminddb.c
  27. 28
      src/mod_mysql_vhost.c
  28. 13
      src/mod_openssl.c
  29. 7
      src/mod_proxy.c
  30. 16
      src/mod_redirect.c
  31. 16
      src/mod_rewrite.c
  32. 13
      src/mod_rrdtool.c
  33. 12
      src/mod_secdownload.c
  34. 12
      src/mod_setenv.c
  35. 8
      src/mod_simple_vhost.c
  36. 13
      src/mod_skeleton.c
  37. 9
      src/mod_ssi.c
  38. 12
      src/mod_staticfile.c
  39. 12
      src/mod_status.c
  40. 16
      src/mod_trigger_b4_dl.c
  41. 8
      src/mod_uploadprogress.c
  42. 12
      src/mod_userdir.c
  43. 12
      src/mod_usertrack.c
  44. 8
      src/mod_vhostdb.c
  45. 16
      src/mod_vhostdb_dbi.c
  46. 16
      src/mod_vhostdb_ldap.c
  47. 16
      src/mod_vhostdb_mysql.c
  48. 16
      src/mod_vhostdb_pgsql.c
  49. 16
      src/mod_webdav.c
  50. 25
      src/plugin.c
  51. 10
      src/plugin.h

9
src/gw_backend.c

@ -1156,11 +1156,9 @@ void gw_plugin_config_free(gw_plugin_config *s) {
free(s);
}
handler_t gw_free(server *srv, void *p_d) {
void gw_free(void *p_d) {
gw_plugin_data * const p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
if (NULL == p->cvlist) { free(p); return HANDLER_GO_ON; }
if (NULL == p->cvlist) return;
/* (init i to 0 if global context; to 1 to skip empty global context) */
for (int i = !p->cvlist[0].v.u2[1], used = p->nconfig; i < used; ++i) {
config_plugin_value_t *cpv = p->cvlist + p->cvlist[i].v.u2[0];
@ -1175,9 +1173,6 @@ handler_t gw_free(server *srv, void *p_d) {
}
}
}
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
int gw_set_defaults_backend(server *srv, gw_plugin_data *p, const array *a, gw_plugin_config *s, int sh_exec, const char *cpkkey) {

2
src/gw_backend.h

@ -334,7 +334,7 @@ __attribute_cold__
void gw_plugin_config_free(gw_plugin_config *s);
__attribute_cold__
handler_t gw_free(server *srv, void *p_d);
void gw_free(void *p_d);
__attribute_cold__
int gw_set_defaults_backend(server *srv, gw_plugin_data *p, const array *a, gw_plugin_config *s, int sh_exec, const char *cpkkey);

12
src/mod_access.c

@ -25,17 +25,6 @@ INIT_FUNC(mod_access_init) {
return calloc(1, sizeof(plugin_data));
}
FREE_FUNC(mod_access_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_access_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* url.access-deny */
@ -189,7 +178,6 @@ int mod_access_plugin_init(plugin *p) {
p->set_defaults = mod_access_set_defaults;
p->handle_uri_clean = mod_access_uri_handler;
p->handle_subrequest_start = mod_access_uri_handler;
p->cleanup = mod_access_free;
return 0;
}

18
src/mod_accesslog.c

@ -451,7 +451,9 @@ static void mod_accesslog_free_format_fields(format_fields * const ff) {
free(ff);
}
static void mod_accesslog_free_config(plugin_data * const p) {
FREE_FUNC(mod_accesslog_free) {
plugin_data * const p = p_d;
free(p->syslog_logbuffer.ptr);
if (NULL == p->cvlist) return;
/* (init i to 0 if global context; to 1 to skip empty global context) */
for (int i = !p->cvlist[0].v.u2[1], used = p->nconfig; i < used; ++i) {
@ -476,20 +478,6 @@ static void mod_accesslog_free_config(plugin_data * const p) {
}
}
FREE_FUNC(mod_accesslog_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
mod_accesslog_free_config(p);
free(p->syslog_logbuffer.ptr);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_accesslog_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0:{/* accesslog.filename */

12
src/mod_alias.c

@ -24,17 +24,6 @@ INIT_FUNC(mod_alias_init) {
return calloc(1, sizeof(plugin_data));
}
FREE_FUNC(mod_alias_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_alias_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* alias.url */
@ -192,7 +181,6 @@ int mod_alias_plugin_init(plugin *p) {
p->init = mod_alias_init;
p->handle_physical= mod_alias_physical_handler;
p->set_defaults = mod_alias_set_defaults;
p->cleanup = mod_alias_free;
return 0;
}

15
src/mod_auth.c

@ -50,7 +50,8 @@ INIT_FUNC(mod_auth_init) {
return p;
}
static void mod_auth_free_config(plugin_data * const p) {
FREE_FUNC(mod_auth_free) {
plugin_data * const p = p_d;
if (NULL == p->cvlist) return;
/* (init i to 0 if global context; to 1 to skip empty global context) */
for (int i = !p->cvlist[0].v.u2[1], used = p->nconfig; i < used; ++i) {
@ -68,18 +69,6 @@ static void mod_auth_free_config(plugin_data * const p) {
}
}
FREE_FUNC(mod_auth_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
mod_auth_free_config(p);
free(p->cvlist);
free(p);
UNUSED(srv);
return HANDLER_GO_ON;
}
/* data type for mod_auth structured data
* (parsed from auth.require array of strings) */
typedef struct {

11
src/mod_authn_file.c

@ -89,16 +89,6 @@ INIT_FUNC(mod_authn_file_init) {
return p;
}
FREE_FUNC(mod_authn_file_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
free(p->cvlist);
free(p);
UNUSED(srv);
return HANDLER_GO_ON;
}
static void mod_authn_file_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* auth.backend.plain.groupfile */
@ -743,7 +733,6 @@ int mod_authn_file_plugin_init(plugin *p) {
p->name = "authn_file";
p->init = mod_authn_file_init;
p->set_defaults= mod_authn_file_set_defaults;
p->cleanup = mod_authn_file_free;
return 0;
}

11
src/mod_authn_gssapi.c

@ -68,16 +68,6 @@ INIT_FUNC(mod_authn_gssapi_init) {
return p;
}
FREE_FUNC(mod_authn_gssapi_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
free(p->cvlist);
free(p);
UNUSED(srv);
return HANDLER_GO_ON;
}
static void mod_authn_gssapi_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* auth.backend.gssapi.keytab */
@ -791,7 +781,6 @@ int mod_authn_gssapi_plugin_init(plugin *p) {
p->name = "authn_gssapi";
p->init = mod_authn_gssapi_init;
p->set_defaults= mod_authn_gssapi_set_defaults;
p->cleanup = mod_authn_gssapi_free;
p->connection_reset = mod_authn_gssapi_handle_reset;
return 0;

14
src/mod_authn_ldap.c

@ -56,7 +56,8 @@ INIT_FUNC(mod_authn_ldap_init) {
return p;
}
static void mod_authn_ldap_free_config(plugin_data *p) {
FREE_FUNC(mod_authn_ldap_free) {
plugin_data * const p = p_d;
if (NULL == p->cvlist) return;
/* (init i to 0 if global context; to 1 to skip empty global context) */
for (int i = !p->cvlist[0].v.u2[1], used = p->nconfig; i < used; ++i) {
@ -75,19 +76,8 @@ static void mod_authn_ldap_free_config(plugin_data *p) {
}
}
}
}
FREE_FUNC(mod_authn_ldap_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
mod_authn_ldap_free_config(p);
free(p->ldap_filter.ptr);
free(p->cvlist);
free(p);
UNUSED(srv);
return HANDLER_GO_ON;
}
static void mod_authn_ldap_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {

17
src/mod_authn_mysql.c

@ -64,7 +64,8 @@ typedef struct {
int mysql_conn_port;
} plugin_data;
static void mod_authn_mysql_sock_close(plugin_data *p) {
static void mod_authn_mysql_sock_close(void *p_d) {
plugin_data * const p = p_d;
if (NULL != p->mysql_conn) {
mysql_close(p->mysql_conn);
p->mysql_conn = NULL;
@ -155,18 +156,6 @@ INIT_FUNC(mod_authn_mysql_init) {
return p;
}
FREE_FUNC(mod_authn_mysql_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
mod_authn_mysql_sock_close(p);
free(p->cvlist);
free(p);
UNUSED(srv);
return HANDLER_GO_ON;
}
static void mod_authn_mysql_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* auth.backend.mysql.host */
@ -522,7 +511,7 @@ int mod_authn_mysql_plugin_init(plugin *p) {
p->name = "authn_mysql";
p->init = mod_authn_mysql_init;
p->set_defaults= mod_authn_mysql_set_defaults;
p->cleanup = mod_authn_mysql_free;
p->cleanup = mod_authn_mysql_sock_close;
return 0;
}

11
src/mod_authn_pam.c

@ -45,16 +45,6 @@ INIT_FUNC(mod_authn_pam_init) {
return p;
}
FREE_FUNC(mod_authn_pam_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
free(p->cvlist);
free(p);
UNUSED(srv);
return HANDLER_GO_ON;
}
static void mod_authn_pam_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* auth.backend.pam.opts */
@ -177,7 +167,6 @@ int mod_authn_pam_plugin_init(plugin *p) {
p->version = LIGHTTPD_VERSION_ID;
p->name = "authn_pam";
p->init = mod_authn_pam_init;
p->cleanup = mod_authn_pam_free;
p->set_defaults= mod_authn_pam_set_defaults;
return 0;

18
src/mod_authn_sasl.c

@ -51,7 +51,9 @@ INIT_FUNC(mod_authn_sasl_init) {
return p;
}
static void mod_authn_sasl_free_config(plugin_data * const p) {
FREE_FUNC(mod_authn_sasl_free) {
plugin_data * const p = p_d;
if (p->initonce) sasl_done();
if (NULL == p->cvlist) return;
/* (init i to 0 if global context; to 1 to skip empty global context) */
for (int i = !p->cvlist[0].v.u2[1], used = p->nconfig; i < used; ++i) {
@ -68,20 +70,6 @@ static void mod_authn_sasl_free_config(plugin_data * const p) {
}
}
FREE_FUNC(mod_authn_sasl_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
if (p->initonce) sasl_done();
mod_authn_sasl_free_config(p);
free(p->cvlist);
free(p);
UNUSED(srv);
return HANDLER_GO_ON;
}
static void mod_authn_sasl_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* auth.backend.sasl.opts */

10
src/mod_cgi.c

@ -135,12 +135,7 @@ INIT_FUNC(mod_cgi_init) {
FREE_FUNC(mod_cgi_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
buffer_pid_t *r = &(p->cgi_pid);
UNUSED(srv);
if (r->ptr) free(r->ptr);
free(p->env.ptr);
free(p->env.offsets);
@ -150,11 +145,6 @@ FREE_FUNC(mod_cgi_free) {
#ifdef __CYGWIN__
buffer_free(p->env.systemroot);
#endif
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_cgi_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {

23
src/mod_cml.c

@ -18,7 +18,11 @@ INIT_FUNC(mod_cml_init) {
return calloc(1, sizeof(plugin_data));
}
static void mod_cml_free_config(plugin_data * const p) {
FREE_FUNC(mod_cml_free) {
plugin_data * const p = p_d;
free(p->trigger_handler.ptr);
free(p->basedir.ptr);
free(p->baseurl.ptr);
if (NULL == p->cvlist) return;
#if defined(USE_MEMCACHED)
/* (init i to 0 if global context; to 1 to skip empty global context) */
@ -77,23 +81,6 @@ static int mod_cml_init_memcached(server *srv, config_plugin_value_t * const cpv
#endif
}
FREE_FUNC(mod_cml_free) {
plugin_data * const p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
free(p->trigger_handler.ptr);
free(p->basedir.ptr);
free(p->baseurl.ptr);
mod_cml_free_config(p);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_cml_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* cml.extension */

8
src/mod_compress.c

@ -91,16 +91,8 @@ INIT_FUNC(mod_compress_init) {
FREE_FUNC(mod_compress_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
buffer_free(p->ofn);
buffer_free(p->b);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
/* 0 on success, -1 for error */

8
src/mod_deflate.c

@ -233,15 +233,7 @@ INIT_FUNC(mod_deflate_init) {
FREE_FUNC(mod_deflate_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
free(p->tmp_buf.ptr);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_deflate_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {

19
src/mod_dirlisting.c

@ -116,7 +116,9 @@ INIT_FUNC(mod_dirlisting_init) {
return calloc(1, sizeof(plugin_data));
}
static void mod_dirlisting_free_config(plugin_data * const p) {
FREE_FUNC(mod_dirlisting_free) {
plugin_data * const p = p_d;
free(p->tmp_buf.ptr);
if (NULL == p->cvlist) return;
/* (init i to 0 if global context; to 1 to skip empty global context) */
for (int i = !p->cvlist[0].v.u2[1], used = p->nconfig; i < used; ++i) {
@ -138,21 +140,6 @@ static void mod_dirlisting_free_config(plugin_data * const p) {
}
}
FREE_FUNC(mod_dirlisting_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
mod_dirlisting_free_config(p);
free(p->tmp_buf.ptr);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_dirlisting_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* dir-listing.activate */

12
src/mod_evasive.c

@ -42,17 +42,6 @@ INIT_FUNC(mod_evasive_init) {
return calloc(1, sizeof(plugin_data));
}
FREE_FUNC(mod_evasive_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_evasive_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* evasive.max-conns-per-ip */
@ -163,7 +152,6 @@ int mod_evasive_plugin_init(plugin *p) {
p->init = mod_evasive_init;
p->set_defaults = mod_evasive_set_defaults;
p->handle_uri_clean = mod_evasive_uri_handler;
p->cleanup = mod_evasive_free;
return 0;
}

21
src/mod_evhost.c

@ -50,7 +50,10 @@ static void mod_evhost_free_path_pieces(const buffer *path_pieces) {
free(b);
}
static void mod_evhost_free_config(plugin_data * const p) {
FREE_FUNC(mod_evhost_free) {
plugin_data * const p = p_d;
free(p->tmp_buf.ptr);
array_free_data(&p->split_vals);
if (NULL == p->cvlist) return;
/* (init i to 0 if global context; to 1 to skip empty global context) */
for (int i = !p->cvlist[0].v.u2[1], used = p->nconfig; i < used; ++i) {
@ -68,22 +71,6 @@ static void mod_evhost_free_config(plugin_data * const p) {
}
}
FREE_FUNC(mod_evhost_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
mod_evhost_free_config(p);
free(p->tmp_buf.ptr);
array_free_data(&p->split_vals);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
__attribute_cold__
static buffer * mod_evhost_parse_pattern_err(buffer *bptr) {
for (; bptr->ptr; ++bptr) free(bptr->ptr);

12
src/mod_expire.c

@ -32,17 +32,6 @@ INIT_FUNC(mod_expire_init) {
return calloc(1, sizeof(plugin_data));
}
FREE_FUNC(mod_expire_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static int mod_expire_get_offset(server *srv, plugin_data *p, const buffer *expire, time_t *offset) {
char *ts;
int type = -1;
@ -381,7 +370,6 @@ int mod_expire_plugin_init(plugin *p) {
p->init = mod_expire_init;
p->handle_response_start = mod_expire_handler;
p->set_defaults = mod_expire_set_defaults;
p->cleanup = mod_expire_free;
return 0;
}

18
src/mod_extforward.c

@ -142,7 +142,9 @@ INIT_FUNC(mod_extforward_init) {
return calloc(1, sizeof(plugin_data));
}
static void mod_extforward_free_config(plugin_data * const p) {
FREE_FUNC(mod_extforward_free) {
plugin_data * const p = p_d;
array_free(p->default_headers);
if (NULL == p->cvlist) return;
/* (init i to 0 if global context; to 1 to skip empty global context) */
for (int i = !p->cvlist[0].v.u2[1], used = p->nconfig; i < used; ++i) {
@ -159,20 +161,6 @@ static void mod_extforward_free_config(plugin_data * const p) {
}
}
FREE_FUNC(mod_extforward_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
mod_extforward_free_config(p);
array_free(p->default_headers);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_extforward_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* extforward.forwarder */

12
src/mod_flv_streaming.c

@ -26,17 +26,6 @@ INIT_FUNC(mod_flv_streaming_init) {
return calloc(1, sizeof(plugin_data));
}
FREE_FUNC(mod_flv_streaming_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_flv_streaming_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* flv-streaming.extensions */
@ -171,7 +160,6 @@ int mod_flv_streaming_plugin_init(plugin *p) {
p->init = mod_flv_streaming_init;
p->handle_physical = mod_flv_streaming_path_handler;
p->set_defaults = mod_flv_streaming_set_defaults;
p->cleanup = mod_flv_streaming_free;
return 0;
}

16
src/mod_geoip.c

@ -69,7 +69,8 @@ INIT_FUNC(mod_geoip_init) {
return calloc(1, sizeof(plugin_data));
}
static void mod_geoip_free_config(plugin_data * const p) {
FREE_FUNC(mod_geoip_free) {
plugin_data * const p = p_d;
if (NULL == p->cvlist) return;
/* (init i to 0 if global context; to 1 to skip empty global context) */
for (int i = !p->cvlist[0].v.u2[1], used = p->nconfig; i < used; ++i) {
@ -87,19 +88,6 @@ static void mod_geoip_free_config(plugin_data * const p) {
}
}
FREE_FUNC(mod_geoip_free) {
plugin_data * const p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
mod_geoip_free_config(p);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static int mod_geoip_open_db(server *srv, config_plugin_value_t * const cpv, int mem_cache) {
/* country db filename is required! */
if (buffer_is_empty(cpv->v.b)) {

12
src/mod_indexfile.c

@ -30,17 +30,6 @@ INIT_FUNC(mod_indexfile_init) {
return calloc(1, sizeof(plugin_data));
}
FREE_FUNC(mod_indexfile_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_indexfile_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* index-file.names */
@ -192,7 +181,6 @@ int mod_indexfile_plugin_init(plugin *p) {
p->init = mod_indexfile_init;
p->handle_subrequest_start = mod_indexfile_subrequest;
p->set_defaults = mod_indexfile_set_defaults;
p->cleanup = mod_indexfile_free;
return 0;
}

8
src/mod_magnet.c

@ -49,15 +49,7 @@ INIT_FUNC(mod_magnet_init) {
FREE_FUNC(mod_magnet_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
script_cache_free_data(&p->cache);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_magnet_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {

18
src/mod_maxminddb.c

@ -107,8 +107,9 @@ INIT_FUNC(mod_maxminddb_init)
}
static void mod_maxminddb_free_config (plugin_data * const p)
FREE_FUNC(mod_maxminddb_free)
{
plugin_data * const p = p_d;
if (NULL == p->cvlist) return;
/* (init i to 0 if global context; to 1 to skip empty global context) */
for (int i = !p->cvlist[0].v.u2[1], used = p->nconfig; i < used; ++i) {
@ -142,21 +143,6 @@ static void mod_maxminddb_free_config (plugin_data * const p)
}
FREE_FUNC(mod_maxminddb_free)
{
plugin_data * const p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
mod_maxminddb_free_config(p);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static MMDB_s *
mod_maxminddb_open_db (server *srv, const buffer *db_name)
{

28
src/mod_mysql_vhost.c

@ -27,7 +27,6 @@ typedef struct {
const buffer *mysql_query;
} plugin_config;
/* global plugin data */
typedef struct {
PLUGIN_DATA;
plugin_config defaults;
@ -36,19 +35,19 @@ typedef struct {
buffer tmp_buf;
} plugin_data;
/* per connection plugin data */
typedef struct {
buffer *server_name;
buffer *document_root;
} plugin_connection_data;
/* init the plugin data */
INIT_FUNC(mod_mysql_vhost_init) {
return calloc(1, sizeof(plugin_data));
}
/* cleanup the mysql connections */
static void mod_mysql_vhost_free_config(plugin_data * const p) {
FREE_FUNC(mod_mysql_vhost_cleanup) {
plugin_data * const p = p_d;
free(p->tmp_buf.ptr);
if (NULL == p->cvlist) return;
/* (init i to 0 if global context; to 1 to skip empty global context) */
for (int i = !p->cvlist[0].v.u2[1], used = p->nconfig; i < used; ++i) {
@ -66,22 +65,6 @@ static void mod_mysql_vhost_free_config(plugin_data * const p) {
}
}
/* cleanup the plugin data */
FREE_FUNC(mod_mysql_vhost_cleanup) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
mod_mysql_vhost_free_config(p);
free(p->tmp_buf.ptr);
free(p->cvlist);
free(p);
UNUSED(srv);
return HANDLER_GO_ON;
}
/* handle the plugin per connection data */
static void* mod_mysql_vhost_connection_data(server *srv, connection *con, void *p_d)
{
plugin_data *p = p_d;
@ -98,7 +81,6 @@ static void* mod_mysql_vhost_connection_data(server *srv, connection *con, void
return con->plugin_ctx[p->id] = c;
}
/* destroy the plugin per connection data */
CONNECTION_FUNC(mod_mysql_vhost_handle_connection_reset) {
plugin_data *p = p_d;
plugin_connection_data *c = con->plugin_ctx[p->id];
@ -192,7 +174,6 @@ static MYSQL * mod_mysql_vhost_db_setup (server *srv, const char *dbname, const
return my;
}
/* set configuration values */
SETDEFAULTS_FUNC(mod_mysql_vhost_set_defaults) {
static const config_plugin_keys_t cpk[] = {
{ CONST_STR_LEN("mysql-vhost.sql"),
@ -285,7 +266,6 @@ SETDEFAULTS_FUNC(mod_mysql_vhost_set_defaults) {
return HANDLER_GO_ON;
}
/* handle document root request */
CONNECTION_FUNC(mod_mysql_vhost_handle_docroot) {
plugin_data *p = p_d;
plugin_connection_data *c;
@ -385,7 +365,7 @@ ERR500:
return HANDLER_FINISHED;
}
/* this function is called at dlopen() time and inits the callbacks */
int mod_mysql_vhost_plugin_init(plugin *p);
int mod_mysql_vhost_plugin_init(plugin *p) {
p->version = LIGHTTPD_VERSION_ID;

13
src/mod_openssl.c

@ -104,6 +104,7 @@ typedef struct {
PLUGIN_DATA;
plugin_ssl_ctx *ssl_ctxs;
plugin_config defaults;
server *srv;
array *cafiles;
} plugin_data;
@ -284,16 +285,9 @@ mod_openssl_load_ca_files (SSL_CTX *ssl_ctx, plugin_data *p, server *srv)
FREE_FUNC(mod_openssl_free)
{
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
mod_openssl_free_config(srv, p);
if (NULL == p->srv) return;
mod_openssl_free_config(p->srv, p);
mod_openssl_free_openssl();
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
@ -1581,6 +1575,7 @@ SETDEFAULTS_FUNC(mod_openssl_set_defaults)
};
plugin_data * const p = p_d;
p->srv = srv;
p->cafiles = array_init();
if (!config_plugin_values_init(srv, p, cpk, "mod_openssl"))
return HANDLER_ERROR;

7
src/mod_proxy.c

@ -92,12 +92,9 @@ static void mod_proxy_free_config(plugin_data * const p)
FREE_FUNC(mod_proxy_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
plugin_data * const p = p_d;
mod_proxy_free_config(p);
return gw_free(srv, p);
gw_free(p);
}
static void mod_proxy_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv)

16
src/mod_redirect.c

@ -27,7 +27,8 @@ INIT_FUNC(mod_redirect_init) {
return calloc(1, sizeof(plugin_data));
}
static void mod_redirect_free_config(plugin_data * const p) {
FREE_FUNC(mod_redirect_free) {
plugin_data * const p = p_d;
if (NULL == p->cvlist) return;
/* (init i to 0 if global context; to 1 to skip empty global context) */
for (int i = !p->cvlist[0].v.u2[1], used = p->nconfig; i < used; ++i) {
@ -45,19 +46,6 @@ static void mod_redirect_free_config(plugin_data * const p) {
}
}
FREE_FUNC(mod_redirect_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
mod_redirect_free_config(p);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_redirect_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* url.redirect */

16
src/mod_rewrite.c

@ -29,7 +29,8 @@ INIT_FUNC(mod_rewrite_init) {
return calloc(1, sizeof(plugin_data));
}
static void mod_rewrite_free_config(plugin_data * const p) {
FREE_FUNC(mod_rewrite_free) {
plugin_data * const p = p_d;
if (NULL == p->cvlist) return;
/* (init i to 0 if global context; to 1 to skip empty global context) */
for (int i = !p->cvlist[0].v.u2[1], used = p->nconfig; i < used; ++i) {
@ -58,19 +59,6 @@ static void mod_rewrite_free_config(plugin_data * const p) {
}
}
FREE_FUNC(mod_rewrite_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
mod_rewrite_free_config(p);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_rewrite_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* url.rewrite-once */

13
src/mod_rrdtool.c

@ -39,6 +39,7 @@ typedef struct {
int rrdtool_running;
const buffer *path_rrdtool_bin;
server *srv;
} plugin_data;
INIT_FUNC(mod_rrd_init) {
@ -64,22 +65,15 @@ static void mod_rrd_free_config(plugin_data * const p) {
FREE_FUNC(mod_rrd_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
if (NULL == p->srv) return;
mod_rrd_free_config(p);
if (p->read_fd >= 0) close(p->read_fd);
if (p->write_fd >= 0) close(p->write_fd);
if (p->rrdtool_pid > 0 && p->srv_pid == srv->pid) {
if (p->rrdtool_pid > 0 && p->srv_pid == p->srv->pid) {
/* collect status (blocking) */
while (-1 == waitpid(p->rrdtool_pid, NULL, 0) && errno == EINTR) ;
}
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static int mod_rrd_create_pipe(server *srv, plugin_data *p) {
@ -179,6 +173,7 @@ SETDEFAULTS_FUNC(mod_rrd_set_defaults) {
};
plugin_data * const p = p_d;
p->srv = srv;
if (!config_plugin_values_init(srv, p, cpk, "mod_rrdtool"))
return HANDLER_ERROR;

12
src/mod_secdownload.c

@ -229,17 +229,6 @@ INIT_FUNC(mod_secdownload_init) {
return calloc(1, sizeof(plugin_data));
}
FREE_FUNC(mod_secdownload_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static int mod_secdownload_parse_algorithm(server * const srv, config_plugin_value_t * const cpv) {
secdl_algorithm algorithm = algorithm_from_string(cpv->v.b);
switch (algorithm) {
@ -549,7 +538,6 @@ int mod_secdownload_plugin_init(plugin *p) {
p->init = mod_secdownload_init;
p->handle_physical = mod_secdownload_uri_handler;
p->set_defaults = mod_secdownload_set_defaults;
p->cleanup = mod_secdownload_free;
return 0;
}

12
src/mod_setenv.c

@ -45,17 +45,6 @@ INIT_FUNC(mod_setenv_init) {
return calloc(1, sizeof(plugin_data));
}
FREE_FUNC(mod_setenv_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_setenv_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* setenv.add-request-header */
@ -285,7 +274,6 @@ int mod_setenv_plugin_init(plugin *p) {
p->handle_request_env = mod_setenv_handle_request_env;
p->handle_response_start = mod_setenv_handle_response_start;
p->set_defaults = mod_setenv_set_defaults;
p->cleanup = mod_setenv_free;
p->connection_reset = mod_setenv_reset;

8
src/mod_simple_vhost.c

@ -33,16 +33,8 @@ INIT_FUNC(mod_simple_vhost_init) {
FREE_FUNC(mod_simple_vhost_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
free(p->tmp_buf.ptr);
free(p->last_root.ptr);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_simple_vhost_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {

13
src/mod_skeleton.c

@ -59,18 +59,6 @@ INIT_FUNC(mod_skeleton_init) {
return calloc(1, sizeof(plugin_data));
}
/* destroy the plugin data */
FREE_FUNC(mod_skeleton_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
/* handle plugin config and check values */
static void mod_skeleton_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
@ -170,7 +158,6 @@ int mod_skeleton_plugin_init(plugin *p) {
p->version = LIGHTTPD_VERSION_ID;
p->name = "skeleton";
p->init = mod_skeleton_init;
p->cleanup = mod_skeleton_free;
p->set_defaults= mod_skeleton_set_defaults;
p->handle_uri_clean = mod_skeleton_uri_handler;

9
src/mod_ssi.c

@ -72,19 +72,10 @@ INIT_FUNC(mod_ssi_init) {
FREE_FUNC(mod_ssi_free) {
plugin_data *p = p_d;
UNUSED(srv);
if (!p) return HANDLER_GO_ON;
array_free(p->ssi_vars);
array_free(p->ssi_cgi_env);
buffer_free(p->timefmt);
buffer_free(p->stat_fn);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_ssi_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {

12
src/mod_staticfile.c

@ -33,17 +33,6 @@ INIT_FUNC(mod_staticfile_init) {
return calloc(1, sizeof(plugin_data));
}
FREE_FUNC(mod_staticfile_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_staticfile_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* static-file.exclude-extensions */
@ -183,7 +172,6 @@ int mod_staticfile_plugin_init(plugin *p) {
p->init = mod_staticfile_init;
p->handle_subrequest_start = mod_staticfile_subrequest;
p->set_defaults = mod_staticfile_set_defaults;
p->cleanup = mod_staticfile_free;
return 0;
}

12
src/mod_status.c

@ -50,17 +50,6 @@ INIT_FUNC(mod_status_init) {
return calloc(1, sizeof(plugin_data));
}
FREE_FUNC(mod_status_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_status_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* status.status-url */
@ -899,7 +888,6 @@ int mod_status_plugin_init(plugin *p) {
p->name = "status";
p->init = mod_status_init;
p->cleanup = mod_status_free;
p->set_defaults= mod_status_set_defaults;
p->handle_uri_clean = mod_status_handler;

16
src/mod_trigger_b4_dl.c

@ -59,7 +59,8 @@ INIT_FUNC(mod_trigger_b4_dl_init) {
return calloc(1, sizeof(plugin_data));
}
static void mod_trigger_b4_dl_free_config(plugin_data * const p) {
FREE_FUNC(mod_trigger_b4_dl_free) {
plugin_data *p = p_d;
if (NULL == p->cvlist) return;
/* (init i to 0 if global context; to 1 to skip empty global context) */
for (int i = !p->cvlist[0].v.u2[1], used = p->nconfig; i < used; ++i) {
@ -183,19 +184,6 @@ static int mod_trigger_b4_dl_init_regex(server * const srv, config_plugin_value_
}
}
FREE_FUNC(mod_trigger_b4_dl_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
mod_trigger_b4_dl_free_config(p);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_trigger_b4_dl_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* trigger-before-download.gdbm-filename */

8
src/mod_uploadprogress.c

@ -127,15 +127,7 @@ INIT_FUNC(mod_uploadprogress_init) {
FREE_FUNC(mod_uploadprogress_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
connection_map_free_data(&p->con_map);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_uploadprogress_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {

12
src/mod_userdir.c

@ -37,17 +37,6 @@ INIT_FUNC(mod_userdir_init) {
return calloc(1, sizeof(plugin_data));
}
FREE_FUNC(mod_userdir_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_userdir_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* userdir.path */
@ -315,7 +304,6 @@ int mod_userdir_plugin_init(plugin *p) {
p->init = mod_userdir_init;
p->handle_physical = mod_userdir_docroot_handler;
p->set_defaults = mod_userdir_set_defaults;
p->cleanup = mod_userdir_free;
return 0;
}

12
src/mod_usertrack.c

@ -30,17 +30,6 @@ INIT_FUNC(mod_usertrack_init) {
return calloc(1, sizeof(plugin_data));
}
FREE_FUNC(mod_usertrack_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
UNUSED(srv);
free(p->cvlist);
free(p);
return HANDLER_GO_ON;
}
static void mod_usertrack_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {
switch (cpv->k_id) { /* index into static config_plugin_keys_t cpk[] */
case 0: /* usertrack.cookie-name */
@ -250,7 +239,6 @@ int mod_usertrack_plugin_init(plugin *p) {
p->init = mod_usertrack_init;
p->handle_uri_clean = mod_usertrack_uri_handler;
p->set_defaults = mod_usertrack_set_defaults;
p->cleanup = mod_usertrack_free;
return 0;
}

8
src/mod_vhostdb.c

@ -32,15 +32,7 @@ INIT_FUNC(mod_vhostdb_init) {
FREE_FUNC(mod_vhostdb_free) {
plugin_data *p = p_d;
if (!p) return HANDLER_GO_ON;
free(p->tmp_buf.ptr);
free(p->cvlist);
free(p);
UNUSED(srv);
return HANDLER_GO_ON;
}
static void mod_vhostdb_merge_config_cpv(plugin_config * const pconf, const config_plugin_value_t * const cpv) {

16
src/mod_vhostdb_dbi.c

@ -233,7 +233,8 @@ INIT_FUNC(mod_vhostdb_init) {
return p;
}
static void mod_vhostdb_free_config(plugin_data * const p) {
FREE_FUNC(mod_vhostdb_cleanup) {
plugin_data * const p = p_d;