diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2008-04-18 12:36:02 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2008-04-18 14:59:03 +0300 |
commit | 2c0f7b54ad8e820ec357c2cad08b8d31fa601ead (patch) | |
tree | a9a3d4a4644d8346291bedcdbe39cd69cf3bc445 /rpmio | |
parent | 8058de50b24f548df74df0943cb3a29c77fbde61 (diff) | |
download | rpm-2c0f7b54ad8e820ec357c2cad08b8d31fa601ead.tar.gz rpm-2c0f7b54ad8e820ec357c2cad08b8d31fa601ead.tar.bz2 rpm-2c0f7b54ad8e820ec357c2cad08b8d31fa601ead.zip |
Add argvJoin() for combining an argv array into a string
Diffstat (limited to 'rpmio')
-rw-r--r-- | rpmio/argv.c | 12 | ||||
-rw-r--r-- | rpmio/argv.h | 8 |
2 files changed, 20 insertions, 0 deletions
diff --git a/rpmio/argv.c b/rpmio/argv.c index 0ff05acf0..ff11f5c4a 100644 --- a/rpmio/argv.c +++ b/rpmio/argv.c @@ -197,3 +197,15 @@ int argvSplit(ARGV_t * argvp, const char * str, const char * seps) *argvp = argv; return 0; } + +char *argvJoin(ARGV_const_t argv, const char *sep) +{ + char *dest = NULL; + char * const *arg; + + for (arg = argv; *arg; arg++) { + rstrscat(&dest, *arg, *(arg+1) ? sep : "", NULL); + } + return dest; +} + diff --git a/rpmio/argv.h b/rpmio/argv.h index 043275236..6a6fc7f14 100644 --- a/rpmio/argv.h +++ b/rpmio/argv.h @@ -147,6 +147,14 @@ int argvAppend(ARGV_t * argvp, ARGV_const_t av); */ int argvSplit(ARGV_t * argvp, const char * str, const char * seps); +/** \ingroup rpmargv + * Join an argv array into a string. + * @param *argv argv array to join + * @param sep seperator string to use + * @return malloc'ed string + */ +char *argvJoin(ARGV_const_t argv, const char *sep); + #ifdef __cplusplus } #endif |