Merge pull request #36 from Gottox/master

lib/initend.c: include now supports file globbing.
This commit is contained in:
Juan RP 2014-05-06 02:01:30 +02:00
commit a71b10ed70

View File

@ -35,6 +35,7 @@
#include <stdarg.h> #include <stdarg.h>
#include <dirent.h> #include <dirent.h>
#include <ctype.h> #include <ctype.h>
#include <glob.h>
#include "xbps_api_impl.h" #include "xbps_api_impl.h"
@ -153,6 +154,24 @@ parse_option(char *buf, char **k, char **v)
return true; return true;
} }
static int
parse_file(struct xbps_handle *xhp, const char *path, bool nested, bool vpkgconf);
static int
parse_files_glob(struct xbps_handle *xhp, const char *path, bool nested, bool vpkgconf) {
glob_t globbuf = { 0 };
int i, rv = 0;
glob(path, 0, NULL, &globbuf);
for(i = 0; globbuf.gl_pathv[i]; i++) {
if((rv = parse_file(xhp, globbuf.gl_pathv[i], nested, vpkgconf)) != 0)
break;
}
globfree(&globbuf);
return rv;
}
static int static int
parse_file(struct xbps_handle *xhp, const char *path, bool nested, bool vpkgconf) parse_file(struct xbps_handle *xhp, const char *path, bool nested, bool vpkgconf)
{ {
@ -218,8 +237,9 @@ parse_file(struct xbps_handle *xhp, const char *path, bool nested, bool vpkgconf
if (strcmp(k, "include")) if (strcmp(k, "include"))
continue; continue;
if ((rv = parse_file(xhp, v, true, false)) != 0) if ((rv = parse_files_glob(xhp, v, true, false)) != 0)
break; break;
} }
free(line); free(line);
fclose(fp); fclose(fp);