Browse Source

[core] isolate use of data_config, configfile.h

personal/stbuehler/ci-build
Glenn Strauss 2 years ago
parent
commit
5977ce2b4a
  1. 2
      src/Makefile.am
  2. 123
      src/configfile.h
  3. 1
      src/connections.c
  4. 2
      src/mod_extforward.c
  5. 1
      src/mod_webdav.c
  6. 1
      src/network.c
  7. 2
      src/plugin.h
  8. 128
      src/plugin_config.h
  9. 2
      src/response.c
  10. 1
      src/server.c

2
src/Makefile.am

@ -425,7 +425,7 @@ hdr = base64.h buffer.h burl.h network.h log.h http_kv.h keyvalue.h \
first.h settings.h http_chunk.h \
algo_sha1.h md5.h http_auth.h http_header.h http_vhostdb.h stream.h \
fdevent.h gw_backend.h connections.h base.h base_decls.h stat_cache.h \
plugin.h \
plugin.h plugin_config.h \
etag.h array.h vector.h crc32.h \
fdevent_impl.h network_write.h configfile.h \
mod_ssi.h mod_ssi_expr.h inet_ntop_cache.h \

123
src/configfile.h

@ -3,55 +3,11 @@
#include "first.h"
#include "base_decls.h"
#include "plugin_config.h"
#include "array.h"
#include "buffer.h"
#include "vector.h"
/**
* possible compare ops in the configfile parser
*/
typedef enum {
CONFIG_COND_UNSET,
CONFIG_COND_EQ, /** == */
CONFIG_COND_MATCH, /** =~ */
CONFIG_COND_NE, /** != */
CONFIG_COND_NOMATCH, /** !~ */
CONFIG_COND_ELSE /** (always true if reached) */
} config_cond_t;
/**
* possible fields to match against
*/
typedef enum {
COMP_UNSET,
COMP_SERVER_SOCKET,
COMP_HTTP_URL,
COMP_HTTP_HOST,
COMP_HTTP_REFERER, /*(subsumed by COMP_HTTP_REQUEST_HEADER)*/
COMP_HTTP_USER_AGENT, /*(subsumed by COMP_HTTP_REQUEST_HEADER)*/
COMP_HTTP_LANGUAGE, /*(subsumed by COMP_HTTP_REQUEST_HEADER)*/
COMP_HTTP_COOKIE, /*(subsumed by COMP_HTTP_REQUEST_HEADER)*/
COMP_HTTP_REMOTE_IP,
COMP_HTTP_QUERY_STRING,
COMP_HTTP_SCHEME,
COMP_HTTP_REQUEST_METHOD,
COMP_HTTP_REQUEST_HEADER,
COMP_LAST_ELEMENT
} comp_key_t;
typedef struct {
comp_key_t comp;
config_cond_t cond;
const buffer *string;
const buffer *comp_tag;
const buffer *comp_key;
const char *op;
} config_cond_info;
__attribute_cold__
void config_get_config_cond_info(server *srv, uint32_t idx, config_cond_info *cfginfo);
/* $HTTP["host"] == "incremental.home.kneschke.de" { ... }
* for print: comp_key op string
* for compare: comp cond string/regex
@ -89,13 +45,12 @@ struct data_config {
array *value;
};
struct cond_cache_t; /* declaration */
__attribute_cold__
data_config *data_config_init(void);
__attribute_cold__
int data_config_pcre_compile(data_config *dc);
/*struct cond_cache_t;*/ /* declaration */ /*(moved to plugin_config.h)*/
/*int data_config_pcre_exec(const data_config *dc, struct cond_cache_t *cache, buffer *b);*/
typedef struct {
@ -107,12 +62,6 @@ typedef struct {
buffer *basedir;
} config_t;
__attribute_cold__
int config_read(server *srv, const char *fn);
__attribute_cold__
int config_set_defaults(server *srv);
__attribute_cold__
void *configparserAlloc(void *(*mallocProc)(size_t));
@ -128,72 +77,4 @@ int config_parse_file(server *srv, config_t *context, const char *fn);
__attribute_cold__
int config_parse_cmd(server *srv, config_t *context, const char *cmd);
__attribute_cold__
void config_init(server *srv);
__attribute_cold__
void config_print(server *srv);
__attribute_cold__
int config_finalize(server *srv, const buffer *default_server_tag);
__attribute_cold__
void config_free(server *srv);
void config_reset_config_bytes_sec(void *p);
void config_reset_config(server *srv, connection *con);
void config_patch_config(server *srv, connection *con);
void config_cond_cache_reset(server *srv, connection *con);
void config_cond_cache_reset_item(server *srv, connection *con, comp_key_t item);
typedef enum { T_CONFIG_UNSET,
T_CONFIG_STRING,
T_CONFIG_SHORT,
T_CONFIG_INT,
T_CONFIG_BOOL,
T_CONFIG_ARRAY,
T_CONFIG_LOCAL,
T_CONFIG_DEPRECATED,
T_CONFIG_UNSUPPORTED
} config_values_type_t;
typedef enum { T_CONFIG_SCOPE_UNSET,
T_CONFIG_SCOPE_SERVER,
T_CONFIG_SCOPE_CONNECTION
} config_scope_type_t;
typedef struct config_plugin_value {
int k_id;
config_values_type_t vtype;
union v_u {
void *v;
const array *a;
const buffer *b;
const char *s;
unsigned int u;
unsigned short int shrt;
double d;
off_t o;
uint32_t u2[2];
} v;
} config_plugin_value_t;
typedef struct {
const char *k;
uint32_t klen;
/*uint32_t k_id;*//*(array index is used for k_id)*/
config_values_type_t ktype;
config_scope_type_t scope;
} config_plugin_keys_t;
__attribute_cold__
int config_plugin_values_init_block(server * const srv, const array * const ca, const config_plugin_keys_t * const cpk, const char * const mname, config_plugin_value_t *cpv);
__attribute_cold__
int config_plugin_values_init(server *srv, void *p_d, const config_plugin_keys_t *cpk, const char *mname);
int config_check_cond(connection *con, int context_ndx);
#endif

1
src/connections.c

@ -9,7 +9,6 @@
#include "fdevent.h"
#include "http_header.h"
#include "configfile.h"
#include "request.h"
#include "response.h"
#include "network.h"

2
src/mod_extforward.c

@ -9,8 +9,6 @@
#include "plugin.h"
#include "configfile.h"
#include <limits.h>
#include <stdlib.h>
#include <string.h>

1
src/mod_webdav.c

@ -208,7 +208,6 @@
#include "response.h" /* http_response_redirect_to_directory() */
#include "stat_cache.h" /* stat_cache_mimetype_by_ext() */
#include "configfile.h"
#include "plugin.h"
#define http_status_get(con) ((con)->http_status)

1
src/network.c

@ -6,7 +6,6 @@
#include "log.h"
#include "connections.h"
#include "plugin.h"
#include "configfile.h"
#include "sock_addr.h"
#include "network_write.h"

2
src/plugin.h

@ -5,7 +5,7 @@
#include "base_decls.h"
#include "buffer.h"
#include "array.h"
#include "configfile.h"
#include "plugin_config.h"
#define SERVER_FUNC(x) \
static handler_t x(server *srv, void *p_d)

128
src/plugin_config.h

@ -0,0 +1,128 @@
#ifndef INCLUDE_PLUGIN_CONFIG_H
#define INCLUDE_PLUGIN_CONFIG_H
#include "first.h"
#include "base_decls.h"
#include "array.h"
#include "buffer.h"
/**
* possible compare ops in the configfile parser
*/
typedef enum {
CONFIG_COND_UNSET,
CONFIG_COND_EQ, /** == */
CONFIG_COND_MATCH, /** =~ */
CONFIG_COND_NE, /** != */
CONFIG_COND_NOMATCH, /** !~ */
CONFIG_COND_ELSE /** (always true if reached) */
} config_cond_t;
/**
* possible fields to match against
*/
typedef enum {
COMP_UNSET,
COMP_SERVER_SOCKET,
COMP_HTTP_URL,
COMP_HTTP_HOST,
COMP_HTTP_REFERER, /*(subsumed by COMP_HTTP_REQUEST_HEADER)*/
COMP_HTTP_USER_AGENT, /*(subsumed by COMP_HTTP_REQUEST_HEADER)*/
COMP_HTTP_LANGUAGE, /*(subsumed by COMP_HTTP_REQUEST_HEADER)*/
COMP_HTTP_COOKIE, /*(subsumed by COMP_HTTP_REQUEST_HEADER)*/
COMP_HTTP_REMOTE_IP,
COMP_HTTP_QUERY_STRING,
COMP_HTTP_SCHEME,
COMP_HTTP_REQUEST_METHOD,
COMP_HTTP_REQUEST_HEADER,
COMP_LAST_ELEMENT
} comp_key_t;
typedef struct {
comp_key_t comp;
config_cond_t cond;
const buffer *string;
const buffer *comp_tag;
const buffer *comp_key;
const char *op;
} config_cond_info;
__attribute_cold__
void config_get_config_cond_info(server *srv, uint32_t idx, config_cond_info *cfginfo);
__attribute_cold__
void config_init(server *srv);
__attribute_cold__
void config_print(server *srv);
__attribute_cold__
int config_read(server *srv, const char *fn);
__attribute_cold__
int config_set_defaults(server *srv);
__attribute_cold__
int config_finalize(server *srv, const buffer *default_server_tag);
__attribute_cold__
void config_free(server *srv);
void config_reset_config_bytes_sec(void *p);
void config_reset_config(server *srv, connection *con);
void config_patch_config(server *srv, connection *con);
void config_cond_cache_reset(server *srv, connection *con);
void config_cond_cache_reset_item(server *srv, connection *con, comp_key_t item);
typedef enum { T_CONFIG_UNSET,
T_CONFIG_STRING,
T_CONFIG_SHORT,
T_CONFIG_INT,
T_CONFIG_BOOL,
T_CONFIG_ARRAY,
T_CONFIG_LOCAL,
T_CONFIG_DEPRECATED,
T_CONFIG_UNSUPPORTED
} config_values_type_t;
typedef enum { T_CONFIG_SCOPE_UNSET,
T_CONFIG_SCOPE_SERVER,
T_CONFIG_SCOPE_CONNECTION
} config_scope_type_t;
typedef struct config_plugin_value {
int k_id;
config_values_type_t vtype;
union v_u {
void *v;
const array *a;
const buffer *b;
const char *s;
unsigned int u;
unsigned short int shrt;
double d;
off_t o;
uint32_t u2[2];
} v;
} config_plugin_value_t;
typedef struct {
const char *k;
uint32_t klen;
/*uint32_t k_id;*//*(array index is used for k_id)*/
config_values_type_t ktype;
config_scope_type_t scope;
} config_plugin_keys_t;
__attribute_cold__
int config_plugin_values_init_block(server * const srv, const array * const ca, const config_plugin_keys_t * const cpk, const char * const mname, config_plugin_value_t *cpv);
__attribute_cold__
int config_plugin_values_init(server *srv, void *p_d, const config_plugin_keys_t *cpk, const char *mname);
int config_check_cond(connection *con, int context_ndx);
#endif

2
src/response.c

@ -10,8 +10,6 @@
#include "stat_cache.h"
#include "chunk.h"
#include "configfile.h"
#include "plugin.h"
#include <sys/types.h>

1
src/server.c

@ -13,7 +13,6 @@
#include "connections.h"
#include "sock_addr.h"
#include "stat_cache.h"
#include "configfile.h"
#include "plugin.h"
#include "network_write.h"

Loading…
Cancel
Save