--- np2/common/profile.h 2004/03/31 11:59:17 1.5 +++ np2/common/profile.h 2005/03/20 06:09:16 1.9 @@ -1,12 +1,15 @@ +#if !defined(NP2_PROFILE_H__) +#define NP2_PROFILE_H__ + #ifdef __cplusplus extern "C" { #endif -BOOL profile_enum(const char *filename, void *arg, - BOOL (*proc)(void *arg, const char *para, - const char *key, const char *data)); -const char *profile_getarg(const char *str, char *buf, UINT leng); +BOOL profile_enum(const OEMCHAR *filename, void *arg, + BOOL (*proc)(void *arg, const OEMCHAR *para, + const OEMCHAR *key, const OEMCHAR *data)); +const OEMCHAR *profile_getarg(const OEMCHAR *str, OEMCHAR *buf, UINT leng); @@ -19,27 +22,28 @@ enum { }; typedef struct { - BYTE *buffer; + OEMCHAR *buffer; UINT buffers; UINT size; + UINT8 hdr[4]; + UINT hdrsize; UINT flag; - char path[MAX_PATH]; + OEMCHAR path[MAX_PATH]; } _PFILEH, *PFILEH; -PFILEH profile_open(const char *filename, UINT flag); +PFILEH profile_open(const OEMCHAR *filename, UINT flag); void profile_close(PFILEH hdl); -BOOL profile_read(const char *app, const char *key, const char *def, - char *ret, UINT size, PFILEH hdl); -BOOL profile_write(const char *app, const char *key, - const char *data, PFILEH hdl); +BRESULT profile_read(const OEMCHAR *app, const OEMCHAR *key, + const OEMCHAR *def, OEMCHAR *ret, UINT size, PFILEH hdl); +BRESULT profile_write(const OEMCHAR *app, const OEMCHAR *key, + const OEMCHAR *data, PFILEH hdl); enum { PFTYPE_STR = 0, PFTYPE_BOOL, PFTYPE_BITMAP, - PFTYPE_ARGS16, - PFTYPE_ARGH8, + PFTYPE_BIN, PFTYPE_SINT8, PFTYPE_SINT16, PFTYPE_SINT32, @@ -49,10 +53,8 @@ enum { PFTYPE_HEX8, PFTYPE_HEX16, PFTYPE_HEX32, - PFTYPE_BYTE3, - PFTYPE_KB, PFTYPE_USER, - PFITYPE_MASK = 0xff, + PFTYPE_MASK = 0xff, PFFLAG_RO = 0x0100, PFFLAG_MAX = 0x0200, @@ -60,18 +62,29 @@ enum { }; typedef struct { - char item[10]; - UINT16 itemtype; + OEMCHAR item[12]; + UINT itemtype; void *value; UINT32 arg; } PFTBL; -void profile_iniread(const char *path, const char *app, - const PFTBL *tbl, UINT count); -void profile_iniwrite(const char *path, const char *app, - const PFTBL *tbl, UINT count); +#define PFSTR(k, f, a) {OEMTEXT(k), f, a, NELEMENTS(a)} +#define PFVAL(k, f, a) {OEMTEXT(k), f, a, 0} +#define PFMAX(k, f, a, v) {OEMTEXT(k), f | PFFLAG_MAX, a, v} +#define PFAND(k, f, a, v) {OEMTEXT(k), f | PFFLAG_AND, a, v} +#define PFEXT(k, f, a, v) {OEMTEXT(k), f, a, v} + +typedef void (*PFREAD)(const PFTBL *item, const OEMCHAR *string); +typedef OEMCHAR *(*PFWRITE)(const PFTBL *item, OEMCHAR *string, UINT size); + +void profile_iniread(const OEMCHAR *path, const OEMCHAR *app, + const PFTBL *tbl, UINT count, PFREAD cb); +void profile_iniwrite(const OEMCHAR *path, const OEMCHAR *app, + const PFTBL *tbl, UINT count, PFWRITE cb); #ifdef __cplusplus } #endif +#endif // defined(NP2_PROFILE_H__) +