Annotation of embedaddon/lighttpd/src/array.h, revision 1.1
1.1 ! misho 1: #ifndef ARRAY_H
! 2: #define ARRAY_H
! 3:
! 4: #ifdef HAVE_CONFIG_H
! 5: # include "config.h"
! 6: #endif
! 7:
! 8: #ifdef HAVE_PCRE_H
! 9: # include <pcre.h>
! 10: #endif
! 11:
! 12: #include "buffer.h"
! 13:
! 14: #include <stdlib.h>
! 15:
! 16: #define DATA_IS_STRING(x) (x->type == TYPE_STRING)
! 17:
! 18: typedef enum { TYPE_UNSET, TYPE_STRING, TYPE_COUNT, TYPE_ARRAY, TYPE_INTEGER, TYPE_FASTCGI, TYPE_CONFIG } data_type_t;
! 19: #define DATA_UNSET \
! 20: data_type_t type; \
! 21: buffer *key; \
! 22: int is_index_key; /* 1 if key is a array index (autogenerated keys) */ \
! 23: struct data_unset *(*copy)(const struct data_unset *src); \
! 24: void (* free)(struct data_unset *p); \
! 25: void (* reset)(struct data_unset *p); \
! 26: int (*insert_dup)(struct data_unset *dst, struct data_unset *src); \
! 27: void (*print)(const struct data_unset *p, int depth)
! 28:
! 29: typedef struct data_unset {
! 30: DATA_UNSET;
! 31: } data_unset;
! 32:
! 33: typedef struct {
! 34: data_unset **data;
! 35:
! 36: size_t *sorted;
! 37:
! 38: size_t used;
! 39: size_t size;
! 40:
! 41: size_t unique_ndx;
! 42:
! 43: size_t next_power_of_2;
! 44: int is_weakref; /* data is weakref, don't bother the data */
! 45: } array;
! 46:
! 47: typedef struct {
! 48: DATA_UNSET;
! 49:
! 50: int count;
! 51: } data_count;
! 52:
! 53: data_count *data_count_init(void);
! 54:
! 55: typedef struct {
! 56: DATA_UNSET;
! 57:
! 58: buffer *value;
! 59: } data_string;
! 60:
! 61: data_string *data_string_init(void);
! 62: data_string *data_response_init(void);
! 63:
! 64: typedef struct {
! 65: DATA_UNSET;
! 66:
! 67: array *value;
! 68: } data_array;
! 69:
! 70: data_array *data_array_init(void);
! 71:
! 72: /**
! 73: * possible compare ops in the configfile parser
! 74: */
! 75: typedef enum {
! 76: CONFIG_COND_UNSET,
! 77: CONFIG_COND_EQ, /** == */
! 78: CONFIG_COND_MATCH, /** =~ */
! 79: CONFIG_COND_NE, /** != */
! 80: CONFIG_COND_NOMATCH /** !~ */
! 81: } config_cond_t;
! 82:
! 83: /**
! 84: * possible fields to match against
! 85: */
! 86: typedef enum {
! 87: COMP_UNSET,
! 88: COMP_SERVER_SOCKET,
! 89: COMP_HTTP_URL,
! 90: COMP_HTTP_HOST,
! 91: COMP_HTTP_REFERER,
! 92: COMP_HTTP_USER_AGENT,
! 93: COMP_HTTP_LANGUAGE,
! 94: COMP_HTTP_COOKIE,
! 95: COMP_HTTP_REMOTE_IP,
! 96: COMP_HTTP_QUERY_STRING,
! 97: COMP_HTTP_SCHEME,
! 98: COMP_HTTP_REQUEST_METHOD,
! 99:
! 100: COMP_LAST_ELEMENT
! 101: } comp_key_t;
! 102:
! 103: /* $HTTP["host"] == "incremental.home.kneschke.de" { ... }
! 104: * for print: comp_key op string
! 105: * for compare: comp cond string/regex
! 106: */
! 107:
! 108: typedef struct _data_config data_config;
! 109: struct _data_config {
! 110: DATA_UNSET;
! 111:
! 112: array *value;
! 113:
! 114: buffer *comp_key;
! 115: comp_key_t comp;
! 116:
! 117: config_cond_t cond;
! 118: buffer *op;
! 119:
! 120: int context_ndx; /* more or less like an id */
! 121: array *childs;
! 122: /* nested */
! 123: data_config *parent;
! 124: /* for chaining only */
! 125: data_config *prev;
! 126: data_config *next;
! 127:
! 128: buffer *string;
! 129: #ifdef HAVE_PCRE_H
! 130: pcre *regex;
! 131: pcre_extra *regex_study;
! 132: #endif
! 133: };
! 134:
! 135: data_config *data_config_init(void);
! 136:
! 137: typedef struct {
! 138: DATA_UNSET;
! 139:
! 140: int value;
! 141: } data_integer;
! 142:
! 143: data_integer *data_integer_init(void);
! 144:
! 145: typedef struct {
! 146: DATA_UNSET;
! 147:
! 148: buffer *host;
! 149:
! 150: unsigned short port;
! 151:
! 152: time_t disable_ts;
! 153: int is_disabled;
! 154: size_t balance;
! 155:
! 156: int usage; /* fair-balancing needs the no. of connections active on this host */
! 157: int last_used_ndx; /* round robin */
! 158: } data_fastcgi;
! 159:
! 160: data_fastcgi *data_fastcgi_init(void);
! 161:
! 162: array *array_init(void);
! 163: array *array_init_array(array *a);
! 164: void array_free(array *a);
! 165: void array_reset(array *a);
! 166: int array_insert_unique(array *a, data_unset *str);
! 167: data_unset *array_pop(array *a);
! 168: int array_print(array *a, int depth);
! 169: data_unset *array_get_unused_element(array *a, data_type_t t);
! 170: data_unset *array_get_element(array *a, const char *key);
! 171: void array_set_key_value(array *hdrs, const char *key, size_t key_len, const char *value, size_t val_len);
! 172: data_unset *array_replace(array *a, data_unset *du);
! 173: int array_strcasecmp(const char *a, size_t a_len, const char *b, size_t b_len);
! 174: void array_print_indent(int depth);
! 175: size_t array_get_max_key_length(array *a);
! 176:
! 177: #endif
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>