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