+Tue Nov 6 17:09:42 EET 2007 Pekka Riikonen <priikone@silcnet.org>
+
+ * Added '%@' formatting to silc_snprintf and variants. It
+ can be used to render data and structures. Affected files
+ are lib/silcutil/silcsnprintf.[ch].
+
+Sat Oct 27 18:12:40 EEST 2007 Pekka Riikonen <priikone@silcnet.org>
+
+ * Added silc_net_tcp_create_listener2. Affected files are
+ lib/silcutil/silcnet.h and platform specific implementation.
+
Sat Sep 1 12:09:32 EEST 2007 Pekka Riikonen <priikone@silcnet.org>
* Rewrote parts of the SILC Atomic API to not use volatile
int cflags;
size_t currlen;
va_list args;
+ SilcSnprintfRender render;
silc_va_copy(args, args_in);
/* not supported yet, treat as next char */
ch = *format++;
break;
+ case '@':
+ /* Renderer function */
+ render = va_arg (args, SilcSnprintfRender);
+ if (render) {
+ void *ptr = va_arg (args, void *);
+ if (ptr) {
+ strvalue = render (ptr);
+ if (strvalue) {
+ if (max == -1)
+ max = strlen(strvalue);
+ if (min > 0 && max >= 0 && min > max) max = min;
+ fmtstr (buffer, &currlen, maxlen, strvalue, flags, min, max);
+ silc_free(strvalue);
+ }
+ }
+ }
+ break;
default:
/* Unknown, skip */
break;
#ifndef SILCSNPRINTF_H
#define SILCSNPRINTF_H
+/****f* silcutil/SilcSnprintf/SilcSnprintfRender
+ *
+ * SYNOPSIS
+ *
+ * typedef char *(*SilcSnprintfRender)(void *data);
+ *
+ * DESCRIPTION
+ *
+ * Snprintf rendering function. This function can be used with '%@'
+ * formatting character. The `data' is rendered into a string and
+ * allocated string is returned. If NULL is returned the rendering
+ * is skipped and ignored. If the returned string does not fit to
+ * the destination buffer it may be truncated.
+ *
+ * EXAMPLE
+ *
+ * char *id_render(void *data)
+ * {
+ * ...render...
+ * return id_string;
+ * }
+ *
+ * // Call id_render function to render the 'client_id'.
+ * silc_snprintf(buf, sizeof(buf), "Client ID %@", id_render, client_id);
+ *
+ ***/
+typedef char *(*SilcSnprintfRender)(void *data);
+
/****f* silcutil/SilcSnprintf/silc_snprintf
*
* SYNOPSIS
* snprintf(3) and printf(3) formatting. Returns the number of character
* in `str' or negative value on error.
*
+ * This also supports '%@' formatting to render data and structures
+ * using SilcSnprintfRender.
+ *
***/
int silc_snprintf(char *str, size_t count, const char *fmt, ...);