X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=daemon%2Fdaemon.h;h=69097c34f957c4124f3916fdef9dd631bcba0f1a;hb=655f8037def7742a608fb272004eec51424ac31d;hp=6ed68fd8dd7b54d639cad398544def7b52390f39;hpb=9c299b64bb24cefafa582fe425bb65b78373d205;p=libguestfs.git diff --git a/daemon/daemon.h b/daemon/daemon.h index 6ed68fd..69097c3 100644 --- a/daemon/daemon.h +++ b/daemon/daemon.h @@ -47,6 +47,7 @@ extern int xwrite (int sock, const void *buf, size_t len) extern int xread (int sock, void *buf, size_t len) __attribute__((__warn_unused_result__)); +extern int add_string_nodup (char ***argv, int *size, int *alloc, char *str); extern int add_string (char ***argv, int *size, int *alloc, const char *str); extern size_t count_strings (char *const *argv); extern void sort_strings (char **argv, int len); @@ -212,6 +213,18 @@ is_zero (const char *buffer, size_t size) return 1; } +/* Helper for building up short lists of arguments. Your code has to + * define MAX_ARGS to a suitable value. + */ +#define ADD_ARG(argv,i,v) \ + do { \ + if ((i) >= MAX_ARGS) { \ + fprintf (stderr, "%s: %d: internal error: exceeded MAX_ARGS (%zu) when constructing the command line\n", __FILE__, __LINE__, (size_t) MAX_ARGS); \ + abort (); \ + } \ + (argv)[(i)++] = (v); \ + } while (0) + /* Helper for functions that need a root filesystem mounted. * NB. Cannot be used for FileIn functions. */