X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=vector%2Fstringitem.c;h=d53576dd540f62ff6832af3b265de6271339af94;hb=1598c2a362fec3de547616cb8020a315631a4c15;hp=db400cebc8f33c54b5a126277dd7971f17446a2a;hpb=e7cfb732dbf345432b0832c32b99b17a1741b206;p=rrq%2Frrqmisc.git diff --git a/vector/stringitem.c b/vector/stringitem.c index db400ce..d53576d 100644 --- a/vector/stringitem.c +++ b/vector/stringitem.c @@ -38,9 +38,21 @@ static void *stringitem_itemkey(void *this,void *item) { static void stringitem_releasekey(void *this,void *key) { } +/** + * This callback function writes a representation of an item into + * a character buffer. + */ +static int stringitem_tostring(void *this,void *item,char *buffer,int limit) { + if ( item ) { + return snprintf( buffer, limit, "\"%s\"", (char*) item ); + } + return snprintf( buffer, limit, "(null)" ); +} + itemkeyfun stringitem = { .hashcode = stringitem_hashcode, .haskey = stringitem_haskey, .itemkey = stringitem_itemkey, - .releasekey = stringitem_releasekey + .releasekey = stringitem_releasekey, + .tostring = stringitem_tostring };