X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=include%2Fyaz%2Fwrbuf.h;h=1d4f83b90868fbda4f721c28a408f8f67834400b;hp=4db046c94905bf3c98368e11cf7d7b0d5b558725;hb=29644f5396a22ec0d51266011f57741adb2fd171;hpb=473824797f568578dc17d7242551cb2f7ccef46c diff --git a/include/yaz/wrbuf.h b/include/yaz/wrbuf.h index 4db046c..1d4f83b 100644 --- a/include/yaz/wrbuf.h +++ b/include/yaz/wrbuf.h @@ -242,11 +242,20 @@ YAZ_EXPORT int wrbuf_grow(WRBUF b, size_t minsize); #define wrbuf_buf(b) ((b)->buf) /** \brief returns WRBUF content as C-string - \param b WRBUF + \param b WRBUF (may not be NULL) \returns C-string */ YAZ_EXPORT const char *wrbuf_cstr(WRBUF b); +/** \brief returns WRBUF content as C-string or NULL + \param b WRBUF + \returns C-string or NULL + + This function returns NULL if either b is NULL or length of buffer is 0 +*/ +YAZ_EXPORT +const char *wrbuf_cstr_null(WRBUF b); + #define wrbuf_putc(b, c) \ ((void) ((b)->pos >= (b)->size ? wrbuf_grow(b, 1) : 0), \ (b)->buf[(b)->pos++] = (c), 0) @@ -274,6 +283,27 @@ void wrbuf_iconv_json_write(WRBUF b, yaz_iconv_t cd, YAZ_EXPORT void wrbuf_iconv_json_puts(WRBUF b, yaz_iconv_t cd, const char *strz); +/** \brief writes SHA1 text to WRBUF + \param b result + \param cp char buffer + \param sz size of char buffer + \param hexit 1=hex mode; 0=binary + \returns 0 if successful + \returns -1 on error +*/ +YAZ_EXPORT +int wrbuf_sha1_write(WRBUF b, const char *cp, size_t sz, int hexit); + +/** \brief writes SHA1 text to WRBUF + \param b result + \param cp C-string + \param hexit 1=hex mode; 0=binary + \returns 0 if successful + \returns -1 on error +*/ +YAZ_EXPORT +int wrbuf_sha1_puts(WRBUF b, const char *cp, int hexit); + YAZ_END_CDECL #endif