diff options
author | Zbigniew Chyla <zbigniew.chyla@nsn.com> | 2015-01-16 15:46:59 +0100 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2015-01-21 10:47:26 -0500 |
commit | 4abdcf1ac9a891a5010f238214150adbc2073b38 (patch) | |
tree | ccd55b9a74504246569a0d84d7853370541cad34 /strfuncs.h | |
parent | b500289f7af867ee5d5c236247f8f8a2a48ad342 (diff) | |
download | gpsd-4abdcf1ac9a891a5010f238214150adbc2073b38.tar.gz |
Add str_{,v}appendf, use it everywhere.
This change doesn't affect generated binary code.
Diffstat (limited to 'strfuncs.h')
-rw-r--r-- | strfuncs.h | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -7,9 +7,16 @@ #ifndef _GPSD_STRFUNCS_H_ #define _GPSD_STRFUNCS_H_ +#include <stdarg.h> +#include <stdio.h> #include <string.h> #define str_starts_with(str, prefix) \ (strncmp((str), (prefix), strlen(prefix)) == 0) +#define str_appendf(str, alloc_size, format, ...) \ + ((void) snprintf((str) + strlen(str), (alloc_size) - strlen(str), (format), ##__VA_ARGS__)) +#define str_vappendf(str, alloc_size, format, ap) \ + ((void) vsnprintf((str) + strlen(str), (alloc_size) - strlen(str), (format), (ap))) + #endif /* _GPSD_STRFUNCS_H_ */ |