diff options
author | default <nobody@localhost> | 2022-10-03 11:18:49 +0200 |
---|---|---|
committer | default <nobody@localhost> | 2022-10-03 11:18:49 +0200 |
commit | e8c421c51dea128a890d62bd091473aa61f3a357 (patch) | |
tree | ccb979c924513f39684f7d0c4e0835e6c269cd19 /data.c | |
parent | 7414b000ee273e40a335d868e27dd05b7de5e80e (diff) |
Backport from xs.
Diffstat (limited to 'data.c')
-rw-r--r-- | data.c | 41 |
1 files changed, 1 insertions, 40 deletions
@@ -5,6 +5,7 @@ #include "xs_io.h" #include "xs_json.h" #include "xs_openssl.h" +#include "xs_glob.h" #include "snac.h" @@ -144,46 +145,6 @@ int user_open(snac *snac, char *uid) } -d_char *xs_glob_n(const char *spec, int basename, int reverse, int max) -/* does a globbing and returns the found files */ -{ - glob_t globbuf; - d_char *list = xs_list_new(); - - if (glob(spec, 0, NULL, &globbuf) == 0) { - int n; - - if (max > globbuf.gl_pathc) - max = globbuf.gl_pathc; - - for (n = 0; n < max; n++) { - char *p; - - if (reverse) - p = globbuf.gl_pathv[globbuf.gl_pathc - n - 1]; - else - p = globbuf.gl_pathv[n]; - - if (p != NULL) { - if (basename) { - if ((p = strrchr(p, '/')) == NULL) - continue; - - p++; - } - - list = xs_list_append(list, p); - } - } - } - - globfree(&globbuf); - - return list; -} -#define xs_glob(spec, basename, reverse) xs_glob_n(spec, basename, reverse, 0xfffffff) - - d_char *user_list(void) /* returns the list of user ids */ { |