repo

List, download and sync packs with remote repositories
Log | Files | Refs

commit c9a46b26415259bce16fe70e56f262674c2c3f14
parent f041e2995a070bdc5a4c72b757ec8d2649e1ba70
Author: z3bra <contactatz3bradotorg>
Date:   Fri Dec 16 20:19:38 +0100

Expose local repository to the config file

Diffstat:
parse.y | 12+++++++++---
repo.c | 11++++++-----
repo.h | 3+--
3 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/parse.y b/parse.y @@ -49,6 +49,7 @@ static int lungetc(int); static int findeol(void); static struct repos *repos = NULL; +static char *local = NULL; typedef struct { union { @@ -59,7 +60,7 @@ typedef struct { } YYSTYPE; %} -%token REPO ERROR +%token REPO LOCAL ERROR %token <v.string> STRING %token <v.number> NUMBER %% @@ -75,6 +76,9 @@ grammar : /* empty */ main : REPO STRING { addrepo(repos, $2); } + | LOCAL STRING { + strncpy(local, $2, PATH_MAX); + } ; %% @@ -109,7 +113,8 @@ lookup(char *s) { /* this has to be sorted always */ static const struct keywords keywords[] = { - { "repo", REPO } + { "local", LOCAL }, + { "repo", REPO } }; const struct keywords *p; @@ -370,7 +375,7 @@ popfile(void) } int -parseconf(struct repos *rlist, const char *filename) +parseconf(struct repos *rlist, char *localrepo, const char *filename) { int errors = 0; @@ -381,6 +386,7 @@ parseconf(struct repos *rlist, const char *filename) topfile = file; repos = rlist; + local = localrepo; yyparse(); errors = file->errors; diff --git a/repo.c b/repo.c @@ -141,7 +141,8 @@ main (int argc, char *argv[]) { int fflag, lflag, sflag; char *argv0, *n; - char cfgfile[PATH_MAX] = DEFCFGFILE; + char cfgfile[PATH_MAX] = DEFCFGFILE; + char localrepo[PATH_MAX] = DEFLOCALREPO; char fn[PATH_MAX], url[PATH_MAX]; FILE *fd; struct stat sb; @@ -179,10 +180,10 @@ main (int argc, char *argv[]) }ARGEND; if (!stat(cfgfile, &sb)) - parseconf(&rlist, cfgfile); + parseconf(&rlist, localrepo, cfgfile); if (sflag) { - snprintf(fn, PATH_MAX, "%s/%s", DEFLOCALREPO, DEFLISTFILE); + snprintf(fn, PATH_MAX, "%s/%s", localrepo, DEFLISTFILE); fd = fopen(fn, "w"); if (!fd) { perror(fn); @@ -195,7 +196,7 @@ main (int argc, char *argv[]) fclose(fd); } - repolist(&plist, DEFLOCALREPO); + repolist(&plist, localrepo); if (lflag) { TAILQ_FOREACH(p, &plist, entries) { @@ -207,7 +208,7 @@ main (int argc, char *argv[]) while ((n = *(argv++))) { TAILQ_FOREACH(p, &plist, entries) { if (!strncmp(p->name, n, PATH_MAX)) { - snprintf(fn, PATH_MAX, "%s/%s", DEFLOCALREPO, basename(p->url)); + snprintf(fn, PATH_MAX, "%s/%s", localrepo, basename(p->url)); if (!stat(fn, &sb) && !fflag) { puts(fn); continue; diff --git a/repo.h b/repo.h @@ -19,8 +19,7 @@ struct repo { }; TAILQ_HEAD(repos, repo); - struct pack *addpack(struct packs *, char *, char *, char *); struct repo *addrepo(struct repos *, char *); int repolist(struct packs *, char *); -int parseconf(struct repos *, const char *); +int parseconf(struct repos *, char *, const char *);