From 19fb2763b48d73c87bf6852d29e84353fd941842 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Sun, 18 Oct 2015 20:14:47 +0200 Subject: [PATCH] - Add new function for demo printing hashes - make vcard param const. --- libcitadel/lib/hash.c | 4 ++++ libcitadel/lib/libcitadel.h | 5 +++-- libcitadel/lib/vcard.c | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/libcitadel/lib/hash.c b/libcitadel/lib/hash.c index ab7eec189..c1e8d4d42 100644 --- a/libcitadel/lib/hash.c +++ b/libcitadel/lib/hash.c @@ -162,6 +162,10 @@ int PrintHash(HashList *Hash, TransitionFunc Trans, PrintHashDataFunc PrintEntry return i; } +const char *dbg_PrintStrBufPayload(const char *Key, void *Item, int Odd) +{ + return ChrPtr((StrBuf*)Item); +} /** * @ingroup HashListDebug diff --git a/libcitadel/lib/libcitadel.h b/libcitadel/lib/libcitadel.h index 31c8394a5..d8f246da4 100644 --- a/libcitadel/lib/libcitadel.h +++ b/libcitadel/lib/libcitadel.h @@ -483,7 +483,7 @@ struct vCard { struct vCard *vcard_new(void); -void vcard_add_prop(struct vCard *v, char *propname, char *propvalue); +void vcard_add_prop(struct vCard *v, const char *propname, const char *propvalue); struct vCard *vcard_load(char *vtext); struct vCard *VCardLoad(StrBuf *vbtext); @@ -512,7 +512,7 @@ typedef const char *(*PrintHashContent)(void * Data); typedef int (*CompareFunc)(const void* Item1, const void*Item2); typedef long (*HashFunc)(const char *Str, long Len); typedef void (*TransitionFunc) (void *Item1, void *Item2, int Odd); -typedef void (*PrintHashDataFunc) (const char *Key, void *Item, int Odd); +typedef const char* (*PrintHashDataFunc) (const char *Key, void *Item, int Odd); long Flathash(const char *str, long len); long lFlathash(const char *str, long len); @@ -529,6 +529,7 @@ int GetHash(HashList *Hash, const char *HKey, long HKLen, void **Data); void Put(HashList *Hash, const char *HKey, long HKLen, void *Data, DeleteHashDataFunc DeleteIt); int GetKey(HashList *Hash, char *HKey, long HKLen, void **Data); int GetHashKeys(HashList *Hash, char ***List); +const char *dbg_PrintStrBufPayload(const char *Key, void *Item, int Odd); int dbg_PrintHash(HashList *Hash, PrintHashContent first, PrintHashContent Second); int PrintHash(HashList *Hash, TransitionFunc Trans, PrintHashDataFunc PrintEntry); HashPos *GetNewHashPos(const HashList *Hash, int StepWidth); diff --git a/libcitadel/lib/vcard.c b/libcitadel/lib/vcard.c index 3264774d7..f12a4efb5 100644 --- a/libcitadel/lib/vcard.c +++ b/libcitadel/lib/vcard.c @@ -93,7 +93,7 @@ void remove_charset_attribute(char *strbuf) * propname name of new property * propvalue value of new property */ -void vcard_add_prop(struct vCard *v, char *propname, char *propvalue) { +void vcard_add_prop(struct vCard *v, const char *propname, const char *propvalue) { ++v->numprops; v->prop = realloc(v->prop, (v->numprops * sizeof(struct vCardProp)) ); -- 2.30.2