move some new_* functions from parse.y to utils.c

This commit is contained in:
Omar Polo 2023-06-08 15:59:53 +00:00
parent e69e1151f6
commit fc9cc497e0
3 changed files with 37 additions and 37 deletions

6
gmid.h
View File

@ -340,9 +340,6 @@ void yyerror(const char*, ...);
void parse_conf(const char*);
void print_conf(void);
int cmdline_symset(char *);
struct vhost *new_vhost(void);
struct location *new_location(void);
struct proxy *new_proxy(void);
/* mime.c */
void init_mime(struct mime*);
@ -421,5 +418,8 @@ void *xcalloc(size_t, size_t);
void gen_certificate(const char*, const char*, const char*);
X509_STORE *load_ca(const char*);
int validate_against_ca(X509_STORE*, const uint8_t*, size_t);
struct vhost *new_vhost(void);
struct location *new_location(void);
struct proxy *new_proxy(void);
#endif

34
parse.y
View File

@ -1035,40 +1035,6 @@ symget(const char *nam)
return NULL;
}
struct vhost *
new_vhost(void)
{
struct vhost *h;
h = xcalloc(1, sizeof(*h));
TAILQ_INIT(&h->locations);
TAILQ_INIT(&h->params);
TAILQ_INIT(&h->aliases);
TAILQ_INIT(&h->proxies);
return h;
}
struct location *
new_location(void)
{
struct location *l;
l = xcalloc(1, sizeof(*l));
l->dirfd = -1;
l->fcgi = -1;
return l;
}
struct proxy *
new_proxy(void)
{
struct proxy *p;
p = xcalloc(1, sizeof(*p));
p->protocols = TLS_PROTOCOLS_DEFAULT;
return p;
}
char *
ensure_absolute_path(char *path)
{

34
utils.c
View File

@ -241,3 +241,37 @@ end:
X509_STORE_CTX_free(ctx);
return ret;
}
struct vhost *
new_vhost(void)
{
struct vhost *h;
h = xcalloc(1, sizeof(*h));
TAILQ_INIT(&h->locations);
TAILQ_INIT(&h->params);
TAILQ_INIT(&h->aliases);
TAILQ_INIT(&h->proxies);
return h;
}
struct location *
new_location(void)
{
struct location *l;
l = xcalloc(1, sizeof(*l));
l->dirfd = -1;
l->fcgi = -1;
return l;
}
struct proxy *
new_proxy(void)
{
struct proxy *p;
p = xcalloc(1, sizeof(*p));
p->protocols = TLS_PROTOCOLS_DEFAULT;
return p;
}