move print_conf and make it take the config as argument

This commit is contained in:
Omar Polo 2023-06-09 17:29:52 +00:00
parent 792f302ace
commit 5af19830c3
3 changed files with 29 additions and 29 deletions

30
gmid.c
View File

@ -44,6 +44,7 @@ static void main_sig_handler(int, short, void *);
static int main_dispatch_server(int, struct privsep_proc *, struct imsg *);
static int main_dispatch_logger(int, struct privsep_proc *, struct imsg *);
static void __dead main_shutdown(struct conf *);
static void main_print_conf(struct conf *);
static struct privsep_proc procs[] = {
{ "server", PROC_SERVER, main_dispatch_server, server },
@ -238,7 +239,7 @@ main(int argc, char **argv)
if (conftest) {
fprintf(stderr, "config OK\n");
if (conftest > 1)
print_conf();
main_print_conf(conf);
return 0;
}
@ -433,3 +434,30 @@ main_shutdown(struct conf *conf)
exit(0);
}
static void
main_print_conf(struct conf *conf)
{
struct vhost *h;
/* struct location *l; */
/* struct envlist *e; */
/* struct alist *a; */
if (*conf->chroot != '\0')
printf("chroot \"%s\"\n", conf->chroot);
printf("ipv6 %s\n", conf->ipv6 ? "on" : "off");
/* XXX: defined mimes? */
printf("port %d\n", conf->port);
printf("prefork %d\n", conf->prefork);
/* XXX: protocols? */
if (*conf->user != '\0')
printf("user \"%s\"\n", conf->user);
TAILQ_FOREACH(h, &conf->hosts, vhosts) {
printf("\nserver \"%s\" {\n", h->domain);
printf(" cert \"%s\"\n", h->cert);
printf(" key \"%s\"\n", h->key);
/* TODO: print locations... */
printf("}\n");
}
}

1
gmid.h
View File

@ -347,7 +347,6 @@ int config_recv(struct conf *, struct imsg *);
/* parse.y */
void yyerror(const char*, ...);
int parse_conf(struct conf *, const char*);
void print_conf(void);
int cmdline_symset(char *);
/* mime.c */

27
parse.y
View File

@ -940,33 +940,6 @@ parse_conf(struct conf *c, const char *filename)
return 0;
}
void
print_conf(void)
{
struct vhost *h;
/* struct location *l; */
/* struct envlist *e; */
/* struct alist *a; */
if (*conf->chroot != '\0')
printf("chroot \"%s\"\n", conf->chroot);
printf("ipv6 %s\n", conf->ipv6 ? "on" : "off");
/* XXX: defined mimes? */
printf("port %d\n", conf->port);
printf("prefork %d\n", conf->prefork);
/* XXX: protocols? */
if (*conf->user != '\0')
printf("user \"%s\"\n", conf->user);
TAILQ_FOREACH(h, &conf->hosts, vhosts) {
printf("\nserver \"%s\" {\n", h->domain);
printf(" cert \"%s\"\n", h->cert);
printf(" key \"%s\"\n", h->key);
/* TODO: print locations... */
printf("}\n");
}
}
int
symset(const char *name, const char *val, int persist)
{