X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;ds=inline;f=vector%2Fstringitem.c;h=d53576dd540f62ff6832af3b265de6271339af94;hb=62e848c28a7083828fd47cbd8a29fbc875cf3ecb;hp=db400cebc8f33c54b5a126277dd7971f17446a2a;hpb=65c1d7e61e1f70fc92214836487dd58f137e2758;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 };