lib/path: add path_strdup()

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2014-01-06 16:48:13 +01:00
parent 5500c81742
commit dd3bc51a53
2 changed files with 15 additions and 0 deletions

View File

@ -4,6 +4,8 @@
#include <stdio.h>
#include <stdint.h>
extern char *path_strdup(const char *path, ...)
__attribute__ ((__format__ (__printf__, 1, 2)));
extern FILE *path_fopen(const char *mode, int exit_on_err, const char *path, ...)
__attribute__ ((__format__ (__printf__, 3, 4)));
extern void path_read_str(char *result, size_t len, const char *path, ...)

View File

@ -49,6 +49,19 @@ path_vcreate(const char *path, va_list ap)
return pathbuf;
}
char *
path_strdup(const char *path, ...)
{
const char *p;
va_list ap;
va_start(ap, path);
p = path_vcreate(path, ap);
va_end(ap);
return p ? strdup(p) : NULL;
}
static FILE *
path_vfopen(const char *mode, int exit_on_error, const char *path, va_list ap)
{