21 #include <sys/types.h>
31 size_t len = strlen(name);
32 if (len >= 4 && strcmp(name + len - 4,
".zsh") == 0) {
35 if (len >= 12 && strcmp(name + len - 12,
".plugin.zsh") == 0) {
59 size_t nc = v->
cap ? v->
cap * 2 : 32;
74 for (
size_t i = 0; i < v->
size; i++) {
91 static int bb_collect(
char *nam,
const char *root,
const char *sub,
95 snprintf(
path,
sizeof(
path),
"%s/%s", root, sub);
97 snprintf(
path,
sizeof(
path),
"%s", root);
99 DIR *d = opendir(
path);
104 while ((de = readdir(d)) != NULL) {
105 if (de->d_name[0] ==
'.') {
110 snprintf(rel,
sizeof(rel),
"%s/%s", sub, de->d_name);
112 snprintf(rel,
sizeof(rel),
"%s", de->d_name);
115 snprintf(abs,
sizeof(abs),
"%s/%s", root, rel);
117 if (stat(abs, &st) != 0) {
120 if (S_ISDIR(st.st_mode)) {
124 if (!S_ISREG(st.st_mode)) {
130 size_t rlen = strlen(rel) + 1;
131 size_t alen = strlen(abs) + 1;
132 char *rdup = (
char *)
zalloc(rlen);
133 char *adup = (
char *)
zalloc(alen);
134 if (!rdup || !adup) {
144 memcpy(rdup, rel, rlen);
145 memcpy(adup, abs, alen);
150 e.
mtime = st.st_mtime;
165 static int bb_cmp(
const void *a,
const void *b) {
168 return strcmp(ea->
rel, eb->
rel);
static void bb_vec_init(struct bb_vec *v)
static void bb_vec_free(struct bb_vec *v)
static int has_ext(const char *name)
static int bb_vec_push(struct bb_vec *v, struct bb_entry *e)
static int bb_collect(char *nam, const char *root, const char *sub, struct bb_vec *out)
static int bb_cmp(const void *a, const void *b)
Module declaration header (mdh) for zpmod.
Prototype stub for zpmod when building out-of-tree.
Startup bundle builder interface.
void * zalloc(size_t size)
void zfree(void *ptr, size_t size)
void * zrealloc(void *ptr, size_t size)