Better management of firstconfigtag and configtag global variables
This commit is contained in:
parent
d220dd75b0
commit
7c5076198f
@ -112,6 +112,8 @@ PROGRAMNAME " version " PROGRAMVERSION,
|
||||
(char *)0
|
||||
};
|
||||
|
||||
static struct configTag *firstconfigtag = NULL, *configtag = NULL;
|
||||
|
||||
unsigned int quietmode = 0;
|
||||
unsigned int genheader_mode = GENHEADER_BASE + GENHEADER_REQUIREMENTS;
|
||||
unsigned int mode = 0;
|
||||
@ -1070,12 +1072,14 @@ main(int argc, char *argv[])
|
||||
strcpy(configfile, DEFAULT_CONFIGFILE);
|
||||
}
|
||||
|
||||
if (read_configuration(configfile, repository_tag)) {
|
||||
firstconfigtag = read_configuration(configfile);
|
||||
if (!firstconfigtag) {
|
||||
fprintf(stderr,
|
||||
"Fatal error while parsing config file %s; aborting.\n",configfile);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
configtag = findRepositoryByTag(repository_tag);
|
||||
if (!configtag) {
|
||||
fprintf(stderr,
|
||||
"Fatal error: configuration missing for given tag\n");
|
||||
|
@ -74,6 +74,8 @@
|
||||
#include "changelog.h"
|
||||
|
||||
static int debug_log = 0;
|
||||
static struct configDefaults configdefaults;
|
||||
static struct configTag *firstconfigtag = NULL;
|
||||
|
||||
struct configTag* findRepositoryByTag(const char *tag)
|
||||
{
|
||||
@ -84,7 +86,7 @@ struct configTag* findRepositoryByTag(const char *tag)
|
||||
if (ct) return ct; else return NULL;
|
||||
}
|
||||
|
||||
int read_configuration(const char *confFile, const char *tag)
|
||||
struct configTag* read_configuration(const char *confFile)
|
||||
{
|
||||
FILE *fin;
|
||||
|
||||
@ -97,7 +99,7 @@ int read_configuration(const char *confFile, const char *tag)
|
||||
struct Packager *currmaintainer;
|
||||
|
||||
if ((fin = fopen(confFile, "r")) == NULL) {
|
||||
return 1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
unsigned int configsection = 0;
|
||||
@ -134,7 +136,7 @@ int read_configuration(const char *confFile, const char *tag)
|
||||
newconfigtag = malloc(sizeof(struct configTag));
|
||||
if (!newconfigtag) {
|
||||
fprintf(stderr, "The system is out of memory\n");
|
||||
return 1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
newconfigtag->tag =
|
||||
@ -164,10 +166,6 @@ int read_configuration(const char *confFile, const char *tag)
|
||||
newconfigtag->html_dir = (char *) strdup(buf);
|
||||
}
|
||||
|
||||
if ((!tag) || (!strcmp(newconfigtag->tag, tag))) {
|
||||
configtag = newconfigtag;
|
||||
}
|
||||
|
||||
if (!currconfigtag) {
|
||||
firstconfigtag = newconfigtag;
|
||||
} else {
|
||||
@ -218,13 +216,13 @@ int read_configuration(const char *confFile, const char *tag)
|
||||
if (vartok) {
|
||||
fprintf(stderr,
|
||||
"Error: exceeding number of archs defined; maximum is %d.",ARCHS_MAX);
|
||||
return 1;
|
||||
return NULL;
|
||||
} else {
|
||||
currconfigtag->arch[i] = NULL;
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "Undefined token: %s\n", vartok);
|
||||
return 1;
|
||||
return NULL;
|
||||
}
|
||||
} else if (configsection == CONF_DEFAULTS_SECTION) {
|
||||
/* we are in the default section */
|
||||
@ -259,13 +257,13 @@ int read_configuration(const char *confFile, const char *tag)
|
||||
if (vartok) {
|
||||
fprintf(stderr,
|
||||
"Error: exceeding number of archs defined; maximum is %d.",ARCHS_MAX);
|
||||
return 1;
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"Invalid token for `defaults' tag: %s\n",
|
||||
vartok);
|
||||
return 1;
|
||||
return NULL;
|
||||
}
|
||||
} else if (configsection == CONF_MAINTAINERS_SECTION) {
|
||||
|
||||
@ -275,7 +273,7 @@ int read_configuration(const char *confFile, const char *tag)
|
||||
if (!currmaintainer) {
|
||||
fprintf(stderr,
|
||||
"Error: cannot create maintainers; aborting.");
|
||||
return 1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
currmaintainer->role |= PACKAGER_ROLE_MAINTAINER;
|
||||
@ -294,7 +292,7 @@ int read_configuration(const char *confFile, const char *tag)
|
||||
if (vartok) {
|
||||
fprintf(stderr,
|
||||
"Error: exceeding number of aliases defined for maintainer %s.",currmaintainer->name);
|
||||
return 1;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -306,7 +304,7 @@ int read_configuration(const char *confFile, const char *tag)
|
||||
fprintf(stderr,
|
||||
"REPOSITORY_DIR not given for tag %s\n",
|
||||
currconfigtag->tag);
|
||||
return 1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!currconfigtag->repository_source_dir) {
|
||||
@ -332,7 +330,7 @@ int read_configuration(const char *confFile, const char *tag)
|
||||
|
||||
fclose(fin);
|
||||
|
||||
return 0;
|
||||
return firstconfigtag;
|
||||
}
|
||||
|
||||
char **
|
||||
|
@ -19,7 +19,6 @@ struct configDefaults {
|
||||
char *url_dir;
|
||||
char *arch[ARCHS_MAX];
|
||||
};
|
||||
static struct configDefaults configdefaults;
|
||||
|
||||
struct configTag {
|
||||
struct configDefaults *configdefaults;
|
||||
@ -41,6 +40,5 @@ struct configTag {
|
||||
struct headerStats stats;
|
||||
struct configTag *next;
|
||||
};
|
||||
static struct configTag *firstconfigtag = NULL, *configtag = NULL;
|
||||
|
||||
#endif
|
||||
|
@ -20,7 +20,7 @@ typedef char sizeString[SSSIZE];
|
||||
#define LOG_DEBUG 4
|
||||
#define LOG_MARK 8
|
||||
|
||||
int read_configuration(const char *confFile, const char *tag);
|
||||
struct configTag* read_configuration(const char *confFile);
|
||||
struct configTag* findRepositoryByTag(const char *tag);
|
||||
|
||||
char **dupnargv(char **argv, int count);
|
||||
|
Loading…
Reference in New Issue
Block a user