Lighttpd基础篇(二):Array.h

//作者:京东瀚览家居官方旗舰店      <--点击关注

//文件名:Array.h

 

#ifndef ARRAY_H
#define ARRAY_H

#include <stdlib.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef HAVE_PCRE_H
# include <pcre.h>
#endif
#include "buffer.h"

#define DATA_IS_STRING(x) (x->type == TYPE_STRING)

typedef enum { TYPE_UNSET, TYPE_STRING, TYPE_COUNT, TYPE_ARRAY, TYPE_INTEGER, TYPE_FASTCGI, TYPE_CONFIG } data_type_t;
#define DATA_UNSET \
	data_type_t type; \
	buffer *key; \
	int is_index_key; /* 1 if key is a array index (autogenerated keys) */ \
	struct data_unset *(*copy)(const struct data_unset *src); \
	void (* free)(struct data_unset *p); \
	void (* reset)(struct data_unset *p); \
	int (*insert_dup)(struct data_unset *dst, struct data_unset *src); \
	void (*print)(const struct data_unset *p, int depth)

typedef struct data_unset {
	DATA_UNSET;
} data_unset;

typedef struct {
	data_unset  **data; /* 存放基础结构数据,*/
	/*二级指针可以当一个数组看待, 其数组元素为data 指针*/

	size_t *sorted; /* 按data 数据的排序顺序保存data 的索引*/

	size_t used;   /* 已经使用的data 数据存储空间*/
	size_t size;    /* 一共拥有的data 数据存储空间*/

	size_t unique_ndx; /* 用于保存唯一索引,初始为0 , 之后递增 */

	size_t next_power_of_2; /* 大于used 的最小2 次幂整数*/

	/*  本数据是否被引用*/
	int is_weakref; /* data is weakref, don't bother the data */
} array;

typedef struct {
	DATA_UNSET;

	int count;
} data_count;

data_count *data_count_init(void);

typedef struct {
	DATA_UNSET;

	buffer *value;
} data_string;

data_string *data_string_init(void);
data_string *data_response_init(void);

typedef struct {
	DATA_UNSET;

	array *value;
} data_array;

data_array *data_array_init(void);

/**
 * 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_t;

/**
 * possible fields to match against
 */
typedef enum {
	COMP_UNSET,
	COMP_SERVER_SOCKET,
	COMP_HTTP_URL,
	COMP_HTTP_HOST,
	COMP_HTTP_REFERER,
	COMP_HTTP_USER_AGENT,
	COMP_HTTP_COOKIE,
	COMP_HTTP_REMOTE_IP,
	COMP_HTTP_QUERY_STRING,
	COMP_HTTP_SCHEME,
	COMP_HTTP_REQUEST_METHOD,

	COMP_LAST_ELEMENT
} comp_key_t;

/* $HTTP["host"] ==    "incremental.home.kneschke.de" { ... }
 * for print:   comp_key      op    string
 * for compare: comp          cond  string/regex
 */

typedef struct _data_config data_config;
struct _data_config {
	DATA_UNSET;

	array *value;

	buffer *comp_key;
	comp_key_t comp;

	config_cond_t cond;
	buffer *op;

	int context_ndx; /* more or less like an id */
	array *childs;
	/* nested */
	data_config *parent;
	/* for chaining only */
	data_config *prev;
	data_config *next;

	buffer *string;
#ifdef HAVE_PCRE_H
	pcre   *regex;
	pcre_extra *regex_study;
#endif
};

data_config *data_config_init(void);

typedef struct {
	DATA_UNSET;

	int value;
} data_integer;

data_integer *data_integer_init(void);

typedef struct {
	DATA_UNSET;

	buffer *host;

	unsigned short port;

	time_t disable_ts;
	int is_disabled;
	size_t balance;

	int usage; /* fair-balancing needs the no. of connections active on this host */
	int last_used_ndx; /* round robin */
} data_fastcgi;

data_fastcgi *data_fastcgi_init(void);

array *array_init(void);
array *array_init_array(array *a);
void array_free(array *a);
void array_reset(array *a);
int array_insert_unique(array *a, data_unset *str);
data_unset *array_pop(array *a);
int array_print(array *a, int depth);
data_unset *array_get_unused_element(array *a, data_type_t t);
data_unset *array_get_element(array *a, const char *key);
data_unset *array_replace(array *a, data_unset *du);
int array_strcasecmp(const char *a, size_t a_len, const char *b, size_t b_len);
void array_print_indent(int depth);
size_t array_get_max_key_length(array *a);

#endif

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这个错误提示意味着你在运行Lighttpd服务器时遇到问题,因为找不到名为libpcre.so.1的共享库文件。这通常发生在系统中缺失了PCRE (Perl Compatible Regular Expressions) 库。以下是解决这个问题的步骤: 1. **检查库是否存在**: 首先,确认libpcre.so.1是否已经安装。打开终端,输入`dpkg -s pcre` 或 `rpm -q pcre` (取决于你的Linux发行版,如果是Debian系则前者,Red Hat系则后者),如果返回版本信息,则说明它存在。 2. **更新包列表**: 如果未找到该库,尝试更新软件包列表并安装所需的库。对于Debian/Ubuntu用户: ``` sudo apt-get update && sudo apt-get install libpcre1-dev ``` 对于CentOS/RHEL用户: ``` sudo yum update && sudo yum install pcre-devel ``` 3. **手动查找库路径**: 确保系统能找到这个库,可以指定其搜索路径。编辑Lighttpd的配置文件(通常是`/etc/lighttpd/lighttpd.conf`),添加行`server.modules += ("mod_fastcgi")`(如果你在寻找fastcgi模块相关的依赖),然后重启lighttpd服务: ``` sudo nano /etc/lighttpd/lighttpd.conf ``` 在相应部分添加`dir-listing-dirs = "/usr/local/lib"`或其他合适的库目录路径,并保存退出,然后执行: ``` sudo service lighttpd restart ``` 4. **检查权限问题**: 检查libpcre.so.1的权限,确保所有者和组都有适当的读取权限。用`sudo chmod -R 755 /path/to/libpcre.so.1` 设置权限。 如果以上步骤仍无法解决问题,可能需要查看特定Linux发行版的文档,或者在网上搜索更详细的解决方案。记得在操作前备份重要数据,以防意外。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值