[rrd-developers] [PATCH] Suggestion for API extension (rrd_dump)

Benny Baumann BenBE at geshi.org
Mon Aug 17 21:49:22 CEST 2009


Hi,

Am 17.08.2009 11:44, schrieb Florian Forster:
> What about this:
> -- 8< --
>  #define CBPUTS(cb_func, user, str) \
>    (*(cb_func)) (str, strlen (str), (user))
>  #define CBPRINTF(cb_func, user, ...) do { \
>    char buffer[256]; \
>    snprintf (buffer, sizeof (buffer), __VA_ARGS__); \
>    buffer[sizeof (buffer) - 1] = 0; \
>    CBPUTS (cb_func, user, buffer); \
>  } while (0)
> -- >8 --
I did a minor modification to those macros as the callback name is
always cb and it always gets the user parameter so I can leave this from
the macro definition.

Integrating those two macros into the source leads to the following
patch (on top of the second patch from me)
> If you follow up with something like
>  $ sed -i -e 's/fprintf\s*(out_file,/CBPRINTF (cb, user,/'
> I bet 80% of the work is done.
Not that easy, But since manual work does the job quite well and even
allows for some optimizations, skipping sed on this helps with getting
real nice source.
> The code will then look somewhat like this:
> -- 8< --
>  CBPRINTF (cb, user, "\t<step> %lu </step> <!-- Seconds -->\n",
>      rrd.stat_head->pdp_step);
> -- >8 --
Well, that's
-- 8< --
 CB_FMTS ("\t<step> %lu </step> <!-- Seconds -->\n",
     rrd.stat_head->pdp_step);
-- >8 --
with my attached patch ...
> Regards,
> -octo
>   
Regards,
BenBE.

P.S.: Please dos2unix the patch first if necessary ;-)

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: rrd_dump.c.diff
Url: http://lists.oetiker.ch/pipermail/rrd-developers/attachments/20090817/b243e548/attachment-0001.txt 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
Url : http://lists.oetiker.ch/pipermail/rrd-developers/attachments/20090817/b243e548/attachment-0001.pgp 


More information about the rrd-developers mailing list