parent
abf645c4c5
commit
b2a60737a1
6
Makefile
6
Makefile
|
|
@ -7,13 +7,13 @@ libconf.a:conf.o stack.o hash.o
|
|||
cp libconf.a lib/
|
||||
|
||||
conf.o:src/conf.h src/conf.c
|
||||
gcc -c src/conf.c
|
||||
gcc -c src/conf.c -O2 -Wall
|
||||
|
||||
stack.o:src/stack/stack.h src/stack/stack.c
|
||||
gcc -c src/stack/stack.c
|
||||
gcc -c src/stack/stack.c -O2 -Wall
|
||||
|
||||
hash.o:src/hash/hash.h src/hash/hash.c
|
||||
gcc -c src/hash/hash.c
|
||||
gcc -c src/hash/hash.c -O2 -Wall
|
||||
|
||||
clean:
|
||||
rm -rfv include lib *.o *.a
|
||||
|
|
|
|||
12
src/conf.c
12
src/conf.c
|
|
@ -2,6 +2,10 @@
|
|||
#include "stack/stack.h"
|
||||
#include <ctype.h>
|
||||
|
||||
extern unsigned int conf_hash_func1(const char *key);
|
||||
extern unsigned int conf_hash_func2(const char *key);
|
||||
extern int conf_hash_search(CONF_ARG *arg,char *key,CONF_VALUE **value);
|
||||
|
||||
//解析过程的各状态
|
||||
enum conf_stat
|
||||
{
|
||||
|
|
@ -172,6 +176,8 @@ CONF_CREATER *conf_creater_new(const char *path)
|
|||
creater->value=NULL;
|
||||
creater->note=NULL;
|
||||
creater->next=NULL;
|
||||
|
||||
return creater;
|
||||
}
|
||||
|
||||
//插入一个参数到内存
|
||||
|
|
@ -236,7 +242,7 @@ int conf_save(CONF_CREATER *creater)
|
|||
void conf_free(CONF *conf)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
//int j;
|
||||
|
||||
for(i=0;i != conf->size;++i)
|
||||
{
|
||||
|
|
@ -697,12 +703,12 @@ CONF_VALUE *conf_value_get(CONF *conf,const char *key)
|
|||
* 否则使用第二个哈希函数计算值并比对key
|
||||
* 如果都未能匹配,则返回NULL */
|
||||
hash=conf_hash_func1(key)%conf->size;
|
||||
if(conf_hash_search(&conf->hash_data[hash],key,&value))
|
||||
if(conf_hash_search(&conf->hash_data[hash],(char *)key,&value))
|
||||
return value;
|
||||
else
|
||||
{
|
||||
hash=conf_hash_func2(key)%conf->size;
|
||||
if(conf_hash_search(&conf->hash_data[hash],key,&value))
|
||||
if(conf_hash_search(&conf->hash_data[hash],(char *)key,&value))
|
||||
return value;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
//#include "stack/stack.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
//定义错误代码
|
||||
|
|
|
|||
Loading…
Reference in New Issue