]> git.ipfire.org Git - people/ms/strongswan.git/blame - src/libstrongswan/utils/utils.h
string: Move string related utility functions to separate files
[people/ms/strongswan.git] / src / libstrongswan / utils / utils.h
CommitLineData
552cc11b 1/*
766141bc 2 * Copyright (C) 2008-2014 Tobias Brunner
552cc11b
MW
3 * Copyright (C) 2008 Martin Willi
4 * Hochschule fuer Technik Rapperswil
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
552cc11b
MW
15 */
16
17/**
bca34c37
TB
18 * @defgroup utils_i utils
19 * @{ @ingroup utils
552cc11b
MW
20 */
21
22#ifndef UTILS_H_
23#define UTILS_H_
24
25#include <sys/types.h>
26#include <stdlib.h>
27#include <stddef.h>
3f310c0d 28#include <sys/time.h>
0be12e35 29#include <string.h>
552cc11b 30
922ee2c5 31#ifdef WIN32
89f19ef8 32# include "compat/windows.h"
922ee2c5
MW
33#else
34# define _GNU_SOURCE
35# include <arpa/inet.h>
36# include <sys/socket.h>
37# include <netdb.h>
38# include <netinet/in.h>
266ee0a1 39# include <sched.h>
fc829ec9 40# include <poll.h>
922ee2c5
MW
41#endif
42
eab241fb
AS
43/**
44 * strongSwan program return codes
45 */
46#define SS_RC_LIBSTRONGSWAN_INTEGRITY 64
47#define SS_RC_DAEMON_INTEGRITY 65
3646c8a1 48#define SS_RC_INITIALIZATION_FAILED 66
eab241fb 49
5d8306de
AS
50#define SS_RC_FIRST SS_RC_LIBSTRONGSWAN_INTEGRITY
51#define SS_RC_LAST SS_RC_INITIALIZATION_FAILED
52
552cc11b
MW
53/**
54 * Number of bits in a byte
55 */
56#define BITS_PER_BYTE 8
57
58/**
59 * Default length for various auxiliary text buffers
60 */
61#define BUF_LEN 512
62
bb6be261
MW
63/**
64 * Build assertion macro for integer expressions, evaluates to 0
65 */
66#define BUILD_ASSERT(x) (sizeof(char[(x) ? 0 : -1]))
67
68/**
69 * Build time check to assert a is an array, evaluates to 0
70 *
71 * The address of an array element has a pointer type, which is not compatible
72 * to the array type.
73 */
74#define BUILD_ASSERT_ARRAY(a) \
75 BUILD_ASSERT(!__builtin_types_compatible_p(typeof(a), typeof(&(a)[0])))
76
95726f76 77#include "utils/types.h"
9ee8b3b4 78#include "enum.h"
717313c5 79#include "utils/atomics.h"
03cf8882 80#include "utils/byteorder.h"
bbfe7a80 81#include "utils/string.h"
9ee8b3b4 82#include "utils/strerror.h"
f65779dd
MW
83#ifdef __APPLE__
84# include "compat/apple.h"
85#endif
9ee8b3b4 86
a43f1e56
MW
87/**
88 * Directory separator character in paths on this platform
89 */
90#ifdef WIN32
91# define DIRECTORY_SEPARATOR "\\"
92#else
93# define DIRECTORY_SEPARATOR "/"
94#endif
95
87a79e6a
MW
96/**
97 * Initialize utility functions
98 */
99void utils_init();
100
101/**
102 * Deinitialize utility functions
103 */
104void utils_deinit();
105
552cc11b 106/**
985dcab1 107 * Helper function that compares two binary blobs for equality
552cc11b 108 */
985dcab1
TB
109static inline bool memeq(const void *x, const void *y, size_t len)
110{
111 return memcmp(x, y, len) == 0;
112}
552cc11b 113
b8339632
MW
114/**
115 * Same as memeq(), but with a constant runtime, safe for cryptographic use.
116 */
117bool memeq_const(const void *x, const void *y, size_t len);
118
6d4654b9
TB
119/**
120 * Calling memcpy() with NULL pointers, even with n == 0, results in undefined
121 * behavior according to the C standard. This version is guaranteed to not
122 * access the pointers if n is 0.
123 */
124static inline void *memcpy_noop(void *dst, const void *src, size_t n)
125{
126 return n ? memcpy(dst, src, n) : dst;
127}
920d466f
MW
128#ifdef memcpy
129# undef memcpy
130#endif
6d4654b9
TB
131#define memcpy(d,s,n) memcpy_noop(d,s,n)
132
133/**
134 * Calling memmove() with NULL pointers, even with n == 0, results in undefined
135 * behavior according to the C standard. This version is guaranteed to not
136 * access the pointers if n is 0.
137 */
138static inline void *memmove_noop(void *dst, const void *src, size_t n)
139{
140 return n ? memmove(dst, src, n) : dst;
141}
920d466f
MW
142#ifdef memmove
143# undef memmove
144#endif
6d4654b9
TB
145#define memmove(d,s,n) memmove_noop(d,s,n)
146
147/**
148 * Calling memset() with a NULL pointer, even with n == 0, results in undefined
149 * behavior according to the C standard. This version is guaranteed to not
150 * access the pointer if n is 0.
151 */
152static inline void *memset_noop(void *s, int c, size_t n)
153{
154 return n ? memset(s, c, n) : s;
155}
920d466f
MW
156#ifdef memset
157# undef memset
158#endif
6d4654b9
TB
159#define memset(s,c,n) memset_noop(s,c,n)
160
552cc11b
MW
161/**
162 * Macro gives back larger of two values.
163 */
e822fc57
TB
164#define max(x,y) ({ \
165 typeof(x) _x = (x); \
166 typeof(y) _y = (y); \
167 _x > _y ? _x : _y; })
168
552cc11b
MW
169/**
170 * Macro gives back smaller of two values.
171 */
e822fc57
TB
172#define min(x,y) ({ \
173 typeof(x) _x = (x); \
174 typeof(y) _y = (y); \
175 _x < _y ? _x : _y; })
552cc11b
MW
176
177/**
178 * Call destructor of an object, if object != NULL
179 */
180#define DESTROY_IF(obj) if (obj) (obj)->destroy(obj)
181
182/**
183 * Call offset destructor of an object, if object != NULL
184 */
185#define DESTROY_OFFSET_IF(obj, offset) if (obj) obj->destroy_offset(obj, offset);
186
187/**
188 * Call function destructor of an object, if object != NULL
189 */
190#define DESTROY_FUNCTION_IF(obj, fn) if (obj) obj->destroy_function(obj, fn);
191
192/**
193 * Debug macro to follow control flow
194 */
195#define POS printf("%s, line %d\n", __FILE__, __LINE__)
196
74eed73a
MW
197/**
198 * Object allocation/initialization macro, using designated initializer.
199 */
2e1f4a46
MW
200#define INIT(this, ...) { (this) = malloc(sizeof(*(this))); \
201 *(this) = (typeof(*(this))){ __VA_ARGS__ }; }
74eed73a 202
0c832258
MW
203/**
204 * Aligning version of INIT().
205 *
206 * The returned pointer must be freed using free_align(), not free().
207 *
208 * @param this object to allocate/initialize
209 * @param align alignment for allocation, in bytes
210 * @param ... initializer
211 */
212#define INIT_ALIGN(this, align, ...) { \
213 (this) = malloc_align(sizeof(*(this)), align); \
214 *(this) = (typeof(*(this))){ __VA_ARGS__ }; }
215
1ef6c0ef
MW
216/**
217 * Object allocation/initialization macro, with extra allocated bytes at tail.
218 *
219 * The extra space gets zero-initialized.
220 *
221 * @param this pointer to object to allocate memory for
222 * @param extra number of bytes to allocate at end of this
223 * @param ... initializer
224 */
225#define INIT_EXTRA(this, extra, ...) { \
226 typeof(extra) _extra = (extra); \
227 (this) = malloc(sizeof(*(this)) + _extra); \
228 *(this) = (typeof(*(this))){ __VA_ARGS__ }; \
229 memset((this) + 1, 0, _extra); }
230
0c832258
MW
231/**
232 * Aligning version of INIT_EXTRA().
233 *
234 * The returned pointer must be freed using free_align(), not free().
235 *
236 * @param this object to allocate/initialize
237 * @param extra number of bytes to allocate at end of this
238 * @param align alignment for allocation, in bytes
239 * @param ... initializer
240 */
241#define INIT_EXTRA_ALIGN(this, extra, align, ...) { \
242 typeof(extra) _extra = (extra); \
243 (this) = malloc_align(sizeof(*(this)) + _extra, align); \
244 *(this) = (typeof(*(this))){ __VA_ARGS__ }; \
245 memset((this) + 1, 0, _extra); }
246
1a1ff9d1
MW
247/**
248 * Method declaration/definition macro, providing private and public interface.
249 *
250 * Defines a method name with this as first parameter and a return value ret,
251 * and an alias for this method with a _ prefix, having the this argument
252 * safely casted to the public interface iface.
253 * _name is provided a function pointer, but will get optimized out by GCC.
254 */
255#define METHOD(iface, name, ret, this, ...) \
23d2bf84
MW
256 static ret name(union {iface *_public; this;} \
257 __attribute__((transparent_union)), ##__VA_ARGS__); \
d185b6ac 258 static typeof(name) *_##name = (typeof(name)*)name; \
23d2bf84
MW
259 static ret name(this, ##__VA_ARGS__)
260
261/**
262 * Same as METHOD(), but is defined for two public interfaces.
263 */
264#define METHOD2(iface1, iface2, name, ret, this, ...) \
265 static ret name(union {iface1 *_public1; iface2 *_public2; this;} \
266 __attribute__((transparent_union)), ##__VA_ARGS__); \
d185b6ac 267 static typeof(name) *_##name = (typeof(name)*)name; \
1a1ff9d1
MW
268 static ret name(this, ##__VA_ARGS__)
269
9e932513
MW
270/**
271 * Callback declaration/definition macro, allowing casted first parameter.
272 *
273 * This is very similar to METHOD, but instead of casting the first parameter
274 * to a public interface, it uses a void*. This allows type safe definition
275 * of a callback function, while using the real type for the first parameter.
276 */
277#define CALLBACK(name, ret, param1, ...) \
278 static ret _cb_##name(union {void *_generic; param1;} \
279 __attribute__((transparent_union)), ##__VA_ARGS__); \
280 static typeof(_cb_##name) *name = (typeof(_cb_##name)*)_cb_##name; \
281 static ret _cb_##name(param1, ##__VA_ARGS__)
282
e79dbda3
TB
283/**
284 * This macro allows counting the number of arguments passed to a macro.
285 * Combined with the VA_ARGS_DISPATCH() macro this can be used to implement
286 * macro overloading based on the number of arguments.
287 * 0 to 10 arguments are currently supported.
288 */
289#define VA_ARGS_NUM(...) _VA_ARGS_NUM(0,##__VA_ARGS__,10,9,8,7,6,5,4,3,2,1,0)
290#define _VA_ARGS_NUM(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NUM,...) NUM
291
292/**
293 * This macro can be used to dispatch a macro call based on the number of given
294 * arguments, for instance:
295 *
296 * @code
297 * #define MY_MACRO(...) VA_ARGS_DISPATCH(MY_MACRO, __VA_ARGS__)(__VA_ARGS__)
298 * #define MY_MACRO1(arg) one_arg(arg)
299 * #define MY_MACRO2(arg1,arg2) two_args(arg1,arg2)
300 * @endcode
301 *
302 * MY_MACRO() can now be called with either one or two arguments, which will
303 * resolve to one_arg(arg) or two_args(arg1,arg2), respectively.
304 */
305#define VA_ARGS_DISPATCH(func, ...) _VA_ARGS_DISPATCH(func, VA_ARGS_NUM(__VA_ARGS__))
306#define _VA_ARGS_DISPATCH(func, num) __VA_ARGS_DISPATCH(func, num)
307#define __VA_ARGS_DISPATCH(func, num) func ## num
308
552cc11b
MW
309/**
310 * Macro to allocate a sized type.
311 */
312#define malloc_thing(thing) ((thing*)malloc(sizeof(thing)))
313
fca4d3ee
MW
314/**
315 * Get the number of elements in an array
316 */
11bf11c1
MW
317#define countof(array) (sizeof(array)/sizeof((array)[0]) \
318 + BUILD_ASSERT_ARRAY(array))
fca4d3ee 319
479f2950
MW
320/**
321 * Ignore result of functions tagged with warn_unused_result attributes
322 */
d0230850 323#define ignore_result(call) { if(call){}; }
479f2950 324
552cc11b
MW
325/**
326 * Assign a function as a class method
327 */
328#define ASSIGN(method, function) (method = (typeof(method))function)
329
330/**
331 * time_t not defined
332 */
333#define UNDEFINED_TIME 0
334
9f0327e6
AS
335/**
336 * Maximum time since epoch causing wrap-around on Jan 19 03:14:07 UTC 2038
337 */
338#define TIME_32_BIT_SIGNED_MAX 0x7fffffff
339
552cc11b
MW
340typedef enum status_t status_t;
341
342/**
343 * Return values of function calls.
344 */
345enum status_t {
346 /**
347 * Call succeeded.
348 */
349 SUCCESS,
7daf5226 350
552cc11b
MW
351 /**
352 * Call failed.
353 */
354 FAILED,
7daf5226 355
552cc11b
MW
356 /**
357 * Out of resources.
358 */
359 OUT_OF_RES,
7daf5226 360
552cc11b
MW
361 /**
362 * The suggested operation is already done
363 */
364 ALREADY_DONE,
7daf5226 365
552cc11b
MW
366 /**
367 * Not supported.
368 */
369 NOT_SUPPORTED,
7daf5226 370
552cc11b
MW
371 /**
372 * One of the arguments is invalid.
373 */
374 INVALID_ARG,
7daf5226 375
552cc11b
MW
376 /**
377 * Something could not be found.
378 */
379 NOT_FOUND,
7daf5226 380
552cc11b
MW
381 /**
382 * Error while parsing.
383 */
384 PARSE_ERROR,
7daf5226 385
552cc11b
MW
386 /**
387 * Error while verifying.
388 */
389 VERIFY_ERROR,
7daf5226 390
552cc11b
MW
391 /**
392 * Object in invalid state.
393 */
394 INVALID_STATE,
7daf5226 395
552cc11b
MW
396 /**
397 * Destroy object which called method belongs to.
398 */
399 DESTROY_ME,
7daf5226 400
552cc11b
MW
401 /**
402 * Another call to the method is required.
403 */
404 NEED_MORE,
405};
406
407/**
408 * enum_names for type status_t.
409 */
410extern enum_name_t *status_names;
411
4d174272
MW
412typedef enum tty_escape_t tty_escape_t;
413
414/**
415 * Excape codes for tty colors
416 */
417enum tty_escape_t {
418 /** text properties */
419 TTY_RESET,
420 TTY_BOLD,
421 TTY_UNDERLINE,
422 TTY_BLINKING,
423
424 /** foreground colors */
425 TTY_FG_BLACK,
426 TTY_FG_RED,
427 TTY_FG_GREEN,
428 TTY_FG_YELLOW,
429 TTY_FG_BLUE,
430 TTY_FG_MAGENTA,
431 TTY_FG_CYAN,
432 TTY_FG_WHITE,
433 TTY_FG_DEF,
434
435 /** background colors */
436 TTY_BG_BLACK,
437 TTY_BG_RED,
438 TTY_BG_GREEN,
439 TTY_BG_YELLOW,
440 TTY_BG_BLUE,
441 TTY_BG_MAGENTA,
442 TTY_BG_CYAN,
443 TTY_BG_WHITE,
444 TTY_BG_DEF,
445};
446
447/**
448 * Get the escape string for a given TTY color, empty string on non-tty fd
449 */
450char* tty_escape_get(int fd, tty_escape_t escape);
451
552cc11b
MW
452/**
453 * Handle struct timeval like an own type.
454 */
455typedef struct timeval timeval_t;
456
457/**
458 * Handle struct timespec like an own type.
459 */
460typedef struct timespec timespec_t;
461
f206bb74
MW
462/**
463 * malloc(), but returns aligned memory.
464 *
465 * The returned pointer must be freed using free_align(), not free().
466 *
467 * @param size size of allocated data
468 * @param align alignment, up to 255 bytes, usually a power of 2
469 * @return allocated hunk, aligned to align bytes
470 */
471void* malloc_align(size_t size, u_int8_t align);
472
473/**
474 * Free a hunk allocated by malloc_align().
475 *
476 * @param ptr hunk to free
477 */
478void free_align(void *ptr);
479
552cc11b
MW
480/**
481 * Same as memcpy, but XORs src into dst instead of copy
482 */
483void memxor(u_int8_t dest[], u_int8_t src[], size_t n);
484
ed678b52
MW
485/**
486 * Safely overwrite n bytes of memory at ptr with zero, non-inlining variant.
487 */
488void memwipe_noinline(void *ptr, size_t n);
489
490/**
491 * Safely overwrite n bytes of memory at ptr with zero, inlining variant.
492 */
493static inline void memwipe_inline(void *ptr, size_t n)
494{
495 volatile char *c = (volatile char*)ptr;
d45b242b 496 size_t m, i;
ed678b52
MW
497
498 /* byte wise until long aligned */
d45b242b 499 for (i = 0; (uintptr_t)&c[i] % sizeof(long) && i < n; i++)
ed678b52
MW
500 {
501 c[i] = 0;
502 }
d45b242b
MW
503 /* word wise */
504 if (n >= sizeof(long))
ed678b52 505 {
d45b242b
MW
506 for (m = n - sizeof(long); i <= m; i += sizeof(long))
507 {
508 *(volatile long*)&c[i] = 0;
509 }
ed678b52
MW
510 }
511 /* byte wise of the rest */
512 for (; i < n; i++)
513 {
514 c[i] = 0;
515 }
516}
517
518/**
519 * Safely overwrite n bytes of memory at ptr with zero, auto-inlining variant.
520 */
521static inline void memwipe(void *ptr, size_t n)
522{
c480b5f4
TB
523 if (!ptr)
524 {
525 return;
526 }
ed678b52
MW
527 if (__builtin_constant_p(n))
528 {
529 memwipe_inline(ptr, n);
530 }
531 else
532 {
533 memwipe_noinline(ptr, n);
534 }
535}
536
81736d7d
TB
537/**
538 * A variant of strstr with the characteristics of memchr, where haystack is not
539 * a null-terminated string but simply a memory area of length n.
540 */
541void *memstr(const void *haystack, const char *needle, size_t n);
542
2ed241ae
TB
543/**
544 * Replacement for memrchr(3) if it is not provided by the C library.
545 *
546 * @param s start of the memory area to search
547 * @param c character to search
548 * @param n length of memory area to search
549 * @return pointer to the found character or NULL
550 */
551void *utils_memrchr(const void *s, int c, size_t n);
552
553#ifndef HAVE_MEMRCHR
554#define memrchr(s,c,n) utils_memrchr(s,c,n)
555#endif
556
66c0801d
MW
557/**
558 * Portable function to wait for SIGINT/SIGTERM (or equivalent).
559 */
560void wait_sigint();
561
766141bc
TB
562/**
563 * Like dirname(3) returns the directory part of the given null-terminated
564 * pathname, up to but not including the final '/' (or '.' if no '/' is found).
565 * Trailing '/' are not counted as part of the pathname.
566 *
567 * The difference is that it does this in a thread-safe manner (i.e. it does not
568 * use static buffers) and does not modify the original path.
569 *
570 * @param path original pathname
571 * @return allocated directory component
572 */
573char *path_dirname(const char *path);
574
575/**
576 * Like basename(3) returns the filename part of the given null-terminated path,
577 * i.e. the part following the final '/' (or '.' if path is empty or NULL).
578 * Trailing '/' are not counted as part of the pathname.
579 *
580 * The difference is that it does this in a thread-safe manner (i.e. it does not
581 * use static buffers) and does not modify the original path.
582 *
583 * @param path original pathname
584 * @return allocated filename component
585 */
586char *path_basename(const char *path);
587
67b3bcd1
MW
588/**
589 * Check if a given path is absolute.
590 *
591 * @param path path to check
592 * @return TRUE if absolute, FALSE if relative
593 */
594bool path_absolute(const char *path);
595
6c20579a 596/**
7daf5226 597 * Creates a directory and all required parent directories.
6c20579a 598 *
3f310c0d 599 * @param path path to the new directory
7daf5226 600 * @param mode permissions of the new directory/directories
6c20579a
TB
601 * @return TRUE on success
602 */
603bool mkdir_p(const char *path, mode_t mode);
604
9a8fdc15
TB
605#ifndef HAVE_CLOSEFROM
606/**
607 * Close open file descriptors greater than or equal to lowfd.
608 *
4ab38d98 609 * @param lowfd start closing file descriptors from here
9a8fdc15
TB
610 */
611void closefrom(int lowfd);
612#endif
613
3f310c0d
MW
614/**
615 * Get a timestamp from a monotonic time source.
616 *
617 * While the time()/gettimeofday() functions are affected by leap seconds
618 * and system time changes, this function returns ever increasing monotonic
619 * time stamps.
620 *
621 * @param tv timeval struct receiving monotonic timestamps, or NULL
622 * @return monotonic timestamp in seconds
623 */
624time_t time_monotonic(timeval_t *tv);
625
eecd41e3
TB
626/**
627 * Add the given number of milliseconds to the given timeval struct
628 *
629 * @param tv timeval struct to modify
630 * @param ms number of milliseconds
631 */
632static inline void timeval_add_ms(timeval_t *tv, u_int ms)
633{
634 tv->tv_usec += ms * 1000;
819c02db 635 while (tv->tv_usec >= 1000000 /* 1s */)
eecd41e3
TB
636 {
637 tv->tv_usec -= 1000000;
638 tv->tv_sec++;
639 }
640}
641
081ae2eb
MW
642/**
643 * returns null
644 */
645void *return_null();
646
233b853d
MW
647/**
648 * No-Operation function
649 */
650void nop();
651
da17b016
MW
652/**
653 * returns TRUE
654 */
655bool return_true();
656
657/**
658 * returns FALSE
659 */
660bool return_false();
661
502edf42
MW
662/**
663 * returns FAILED
664 */
665status_t return_failed();
666
4755ab50
MW
667/**
668 * returns SUCCESS
669 */
670status_t return_success();
671
84044f9c 672/**
812ae898 673 * Get the padding required to make size a multiple of alignment
84044f9c 674 */
812ae898 675static inline size_t pad_len(size_t size, size_t alignment)
84044f9c 676{
812ae898 677 size_t remainder;
84044f9c 678
812ae898
TB
679 remainder = size % alignment;
680 return remainder ? alignment - remainder : 0;
681}
682
683/**
684 * Round up size to be multiple of alignment
685 */
686static inline size_t round_up(size_t size, size_t alignment)
687{
688 return size + pad_len(size, alignment);
84044f9c
MW
689}
690
691/**
812ae898 692 * Round down size to be a multiple of alignment
84044f9c 693 */
812ae898 694static inline size_t round_down(size_t size, size_t alignment)
84044f9c 695{
812ae898 696 return size - (size % alignment);
84044f9c
MW
697}
698
2077d996
MW
699#ifndef HAVE_FMEMOPEN
700# ifdef HAVE_FUNOPEN
9df621d2
MW
701# define HAVE_FMEMOPEN
702# define HAVE_FMEMOPEN_FALLBACK
5ac29360 703# include <stdio.h>
2077d996
MW
704/**
705 * fmemopen(3) fallback using BSD funopen.
706 *
707 * We could also provide one using fopencookie(), but should we have it we
708 * most likely have fmemopen().
709 *
710 * fseek() is currently not supported.
711 */
712FILE *fmemopen(void *buf, size_t size, const char *mode);
713# endif /* FUNOPEN */
714#endif /* FMEMOPEN */
715
552cc11b 716/**
d25ce370 717 * printf hook for time_t.
552cc11b 718 *
7daf5226 719 * Arguments are:
323f9f99 720 * time_t* time, bool utc
552cc11b 721 */
1b40b74d 722int time_printf_hook(printf_hook_data_t *data, printf_hook_spec_t *spec,
d25ce370 723 const void *const *args);
552cc11b
MW
724
725/**
d25ce370 726 * printf hook for time_t deltas.
552cc11b 727 *
7daf5226 728 * Arguments are:
323f9f99 729 * time_t* begin, time_t* end
552cc11b 730 */
1b40b74d 731int time_delta_printf_hook(printf_hook_data_t *data, printf_hook_spec_t *spec,
d25ce370 732 const void *const *args);
552cc11b
MW
733
734/**
d25ce370 735 * printf hook for memory areas.
552cc11b 736 *
7daf5226 737 * Arguments are:
817ab8a8 738 * u_char *ptr, u_int len
552cc11b 739 */
1b40b74d 740int mem_printf_hook(printf_hook_data_t *data, printf_hook_spec_t *spec,
d25ce370 741 const void *const *args);
552cc11b 742
1490ff4d 743#endif /** UTILS_H_ @}*/