Add argvJoin() for combining an argv array into a string
This commit is contained in:
parent
8058de50b2
commit
2c0f7b54ad
12
rpmio/argv.c
12
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue