添加头文件

master
brisk 2014-03-24 16:35:23 +08:00
parent a0497b2dda
commit ec05d62431
2 changed files with 78 additions and 0 deletions

44
src/conf.h Normal file
View File

@ -0,0 +1,44 @@
/* conf-c一个基于c语言的轻量级读取/创建配置文件的库函数。
* 使MIT使/
*
*/
#ifndef _CONF_H
#define _CONF_H
/*配置文件中健/值以hash的方式存储在内存中*/
#include "hash/hash.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
//打开并初始化path为配置文件的路经返回CONF数据
CONF *conf_open(const char *path);
//解析配置文件解析正确返回0出错返回小于0的错误代码
int conf_parse(CONF *conf);
//获取当前配置文件中键值对个数
int conf_count(CONF *conf);
//创建一个配置文件path为配置文件的路经
CONF *conf_creater_new(const char *path);
/* 添加一个配置键/值对,key为键
* value
* note
* #
* :
* 0
* 0
*/
int conf_insert(CONF *conf,const char *key,CONF_VALUE *value,const char *note);
//保存配置文件,正确时返回0错误时返回小于0的错误代码
int conf_save(CONF *conf);
//释放内存
void conf_free(CONF *conf);
#endif

34
src/hash/hash.h Normal file
View File

@ -0,0 +1,34 @@
//哈希函数库头文件
#ifndef _HASH_H
#define _HASH_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* conf-c的数据结构
* fpFILE
* len/
* conf/hash
*/
typedef struct
{
FILE *fp;
int len;
conf_hash *conf;
}CONF;
/*值链表数据结构*/
typedef struct node
{
char *value;
struct node *next;
}CONF_VALUE;
//插入数据,key为键value为值
int conf_value_insert(const char *key,CONF_VALUE *value);
//根据一个键查找数据
int conf_value_get(CONF *conf,const char *key);
#endif