X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=include%2Futils.h;h=1c634d81529f4bf382f1e7a4ce5834de7b45f7c0;hb=1c6850c00d38de5d4b4d4f013633c73456b0e683;hp=8cb40dd3d4b98929bd5e524120db6d2229fda5a9;hpb=4344b8c8987cb5627f9ada36ae7a6e19d95ada33;p=doldaconnect.git diff --git a/include/utils.h b/include/utils.h index 8cb40dd..1c634d8 100644 --- a/include/utils.h +++ b/include/utils.h @@ -1,6 +1,6 @@ /* * Dolda Connect - Modular multiuser Direct Connect-style client - * Copyright (C) 2004 Fredrik Tolf (fredrik@dolda2000.com) + * Copyright (C) 2004 Fredrik Tolf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,6 +31,11 @@ struct wcspair { wchar_t *val; }; +struct strpair { + struct strpair *next; + char *key; + char *val; +}; /* "Safe" functions */ #ifdef DAEMON @@ -101,6 +106,9 @@ char *base32decode(char *data, size_t *datalen); void _freeparr(void **arr); int _parrlen(void **arr); char *findfile(char *name, char *homedir, int filldef); +struct strpair *newstrpair(char *key, char *val, struct strpair **list); +void freestrpair(struct strpair *pair, struct strpair **list); +char *spfind(struct strpair *list, char *key); struct wcspair *newwcspair(wchar_t *key, wchar_t *val, struct wcspair **list); void freewcspair(struct wcspair *pair, struct wcspair **list); wchar_t *wpfind(struct wcspair *list, wchar_t *key); @@ -120,6 +128,13 @@ do { \ memcpy((d) + (d ## data), (s), sizeof(*(d)) * __bufcat_size__); \ (d ## data) += __bufcat_size__; \ } while (0) +#define bprintf(b, fmt...) \ + do { \ + char *__bprintf_dest__; \ + __bprintf_dest__ = sprintf2(fmt); \ + bufcat(b, __bprintf_dest__, strlen(__bprintf_dest__)); \ + free(__bprintf_dest__); \ + } while(0) #define freeparr(parr) _freeparr((void **)(parr)) #define parrlen(parr) _parrlen((void **)(parr))