📄 gkvlist.h
字号:
/*
* $Id: kvlist.h,v 1.20 1999/08/20 19:14:24 epi Exp $
*/
#ifndef _KVLIST_H
#define _KVLIST_H
typedef enum {
KVTypeString,
KVTypeInt,
KVTypeBinary,
KVTypeList,
KVTypeIncorrect = -1 /* used for error indication only */
} TKVType;
struct _kv_pair {
TKVType type;
char *key;
int length;
union {
char *_string_value;
int _int_value;
unsigned char *_binary_value;
struct kv_list *_list_value;
} _value;
#define string_value _value._string_value
#define int_value _value._int_value
#define binary_value _value._binary_value
#define list_value _value._list_value
struct _kv_pair *kv_next;
struct _kv_pair *kv_prev;
};
typedef struct _kv_pair TKVPair;
struct kv_list {
struct _kv_pair *list;
struct _kv_pair *current;
struct _kv_pair *tail;
};
typedef struct kv_list TKVList;
typedef enum {
KVResultError = -1,
KVResultNotFound,
KVResultSuccessful
} TKVResult;
#ifdef __cplusplus
extern "C" {
#endif
TKVList *TKVListCreate(void);
TKVResult TKVListFree(
TKVList *list
);
TKVList *TKVListDup(
TKVList *list
);
TKVResult TKVListAddString(
TKVList *list,
char *key,
char *value
);
TKVResult TKVListAddInt(
TKVList *list,
char *key,
int value
);
TKVResult TKVListAddBinary(
TKVList *list,
char *key,
unsigned char *val,
int length
);
TKVResult TKVListAddList(
TKVList *list,
char *key,
TKVList *data
);
TKVResult TKVListInsertList(
TKVList *udata,
char *key,
TKVList *data
);
TKVResult TKVListDeletePair(
TKVList *list,
char *key
);
TKVResult TKVListDeleteAll(
TKVList *list
);
TKVResult TKVListInitScanLoop(
TKVList *list
);
TKVPair *TKVListNextPair(
TKVList *list
);
TKVType TKVListType(
TKVPair *pair
);
char *TKVListKey(
TKVPair *pair
);
int TKVListIntValue(
TKVPair *pair
);
char *TKVListStringValue(
TKVPair *pair
);
TKVList *TKVListListValue(
TKVPair *pair
);
unsigned char *TKVListBinaryValue(
TKVPair *pair
);
int TKVListGetIntValue(
TKVList *list,
char *key,
TKVResult *result
);
char *TKVListGetStringValue(
TKVList *list,
char *key,
TKVResult *result
);
unsigned char *TKVListGetBinaryValue(
TKVList *list,
char *key,
TKVResult *result
);
TKVList *TKVListGetListValue(
TKVList *list,
char *key,
TKVResult *result
);
void TKVListPrint(
void *f,
TKVList *list,
char *header
);
int TKVListBinaryLength(
TKVPair *pair
);
TKVPair *TKVListGetPair(
TKVList *kvl,
char *key,
TKVResult *result
);
#ifdef __cplusplus
}
#endif
#endif /* _KVLIST_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -