diff options
Diffstat (limited to 'src/process.c')
-rw-r--r-- | src/process.c | 66 |
1 files changed, 57 insertions, 9 deletions
diff --git a/src/process.c b/src/process.c index 0d2bf5e..20bfd38 100644 --- a/src/process.c +++ b/src/process.c @@ -33,6 +33,41 @@ register_spool (struct spool *spool) spool_list = sp; } +static int +spool_check_alias (struct spool *spool, const char *name) +{ + int rc = 0; + + if (spool->aliases) + { + gl_list_iterator_t itr = gl_list_iterator (spool->aliases); + const void *p; + + while (gl_list_iterator_next (&itr, &p, NULL)) + if (strcmp (name, p) == 0) + { + rc = 1; + break; + } + gl_list_iterator_free (&itr); + } + return rc; +} + +struct spool * +wydawca_find_spool (const char *name) +{ + struct spool_list *sp; + + for (sp = spool_list; sp; sp = sp->next) + { + if (strcmp (sp->spool.tag, name) == 0 + || spool_check_alias (&sp->spool, name)) + return &sp->spool; + } + return NULL; +} + /* Return true if NAME is a directory. If stat fails, return the error code in EC */ int @@ -100,10 +135,22 @@ parse_file_name (const char *name, struct file_info *finfo) abort (); /* should not happen */ } +int +match_uid_p (uid_t uid, int uc, uid_t *uv) +{ + int i; + if (!uv) + return 1; + for (i = 0; i < uc; i++) + if (uv[i] == uid) + return 1; + return 0; +} + /* Scan upload directory from the DPAIR and register all files found there, forming triplets when possible */ void -scan_spool (struct spool *spool) +scan_spool (const struct spool *spool, int uc, uid_t *uv) { DIR *dir; struct dirent *ent; @@ -127,8 +174,9 @@ scan_spool (struct spool *spool) return; } - timer_start ("directory"); - timer_start (spool->url); + timer_start ("spool"); + /* FIXME: prefix spool tag with something */ + timer_start (spool->tag); while ((ent = readdir (dir))) { struct stat st; @@ -152,7 +200,7 @@ scan_spool (struct spool *spool) continue; } - if (!match_uid_p (st.st_uid)) + if (!match_uid_p (st.st_uid, uc, uv)) { if (debug_level) logmsg (LOG_DEBUG, _("ignoring file: %s/%s"), @@ -164,7 +212,7 @@ scan_spool (struct spool *spool) parse_file_name (ent->d_name, &finfo); if (debug_level) - logmsg (LOG_DEBUG, _("file %s: %s, root %.*s"), ent->d_name, + logmsg (LOG_DEBUG, _("found file %s: %s, stem: %.*s"), ent->d_name, file_type_str (finfo.type), finfo.root_len, finfo.name); register_file (&finfo); @@ -186,8 +234,8 @@ scan_spool (struct spool *spool) } enumerate_triplets (spool); } - timer_stop (spool->url); - timer_stop ("directory"); + timer_stop (spool->tag); + timer_stop ("spool"); } static void @@ -200,7 +248,7 @@ close_methods (struct spool *spool) /* Scan all configured update directories */ void -scan_directories () +scan_directories (int uidc, uid_t *uidv) { struct spool_list *sp; @@ -208,7 +256,7 @@ scan_directories () for (sp = spool_list; sp; sp = sp->next) if (enabled_spool_p (&sp->spool)) - scan_spool (&sp->spool); + scan_spool (&sp->spool, uidc, uidv); for (sp = spool_list; sp; sp = sp->next) close_methods (&sp->spool); |