commit - 40dc608f1fa19319e07a762a416073d6c9b5e2c2
commit + 13ed2fb63f4915da96fcc7f8022480561a87567e
blob - 5668a4fd8a4d0771d06a5630b9ce59b3f1d7423c
blob + 272a39d3499d0115c4ef3b9d777e29e152bba6db
--- gmid.c
+++ gmid.c
struct vhost hosts[HOSTSLEN];
-int exfd, foreground, goterror;
+int exfd, foreground;
struct conf conf;
}
void
-yyerror(const char *msg)
-{
- goterror = 1;
- fprintf(stderr, "%d: %s\n", yylineno, msg);
-}
-
-int
-parse_portno(const char *p)
-{
- const char *errstr;
- int n;
-
- n = strtonum(p, 0, UINT16_MAX, &errstr);
- if (errstr != NULL)
- errx(1, "port number is %s: %s", errstr, p);
- return n;
-}
-
-void
-parse_conf(const char *path)
-{
- if ((yyin = fopen(path, "r")) == NULL)
- fatal("cannot open config %s", path);
- yyparse();
- fclose(yyin);
-
- if (goterror)
- exit(1);
-}
-
-void
load_vhosts(void)
{
struct vhost *h;
blob - 9e1eac56d82e945e73c31d808b036798188bf323
blob + a2f87942c64d032eb3ac8008b271ea50e3de0a6e
--- gmid.h
+++ gmid.h
void mkdirs(const char*);
char *data_dir(void);
void load_local_cert(const char*, const char*);
-void yyerror(const char*);
-int parse_portno(const char*);
-void parse_conf(const char*);
void load_vhosts(void);
int make_socket(int, int);
void setup_tls(void);
extern int yyparse(void);
extern int yylex(void);
+void yyerror(const char*);
+int parse_portno(const char*);
+void parse_conf(const char*);
+
/* mime.c */
void init_mime(struct mime*);
void add_mime(struct mime*, const char*, const char*);
blob - f7e041d20e78bf48c7a58a601b7b971c85b95495
blob + a2e4bf9dc4c56d491d54fbf72ed83ca3c8c9b566
--- lex.l
+++ lex.l
[ \t]+ ;
-. errx(1, "%d: unexpected character %c", yylineno, *yytext);
+. yyerror("unexpected character"); exit(1);
%%
blob - b626c1b676ead5fe5f4ee6a82f8b64a3142d3f50
blob + 7929e5317f47d66c1de000faec574415f84bcaf5
--- parse.y
+++ parse.y
struct location *loc = &hosts[0].locations[0];
size_t iloc = 0;
-extern void yyerror(const char*);
+int goterror = 0;
+const char *config_path;
+void yyerror(const char*);
+int parse_portno(const char*);
+void parse_conf(const char*);
+
%}
/* for bison: */
}
| TAUTO TINDEX TBOOL { loc->auto_index = $3 ? 1 : -1; }
;
+
+%%
+
+void
+yyerror(const char *msg)
+{
+ goterror = 1;
+ fprintf(stderr, "%s:%d: %s\n", config_path, yylineno, msg);
+}
+
+int
+parse_portno(const char *p)
+{
+ const char *errstr;
+ int n;
+
+ n = strtonum(p, 0, UINT16_MAX, &errstr);
+ if (errstr != NULL)
+ errx(1, "port number is %s: %s", errstr, p);
+ return n;
+}
+
+void
+parse_conf(const char *path)
+{
+ config_path = path;
+ if ((yyin = fopen(path, "r")) == NULL)
+ fatal("cannot open config %s", path);
+ yyparse();
+ fclose(yyin);
+
+ if (goterror)
+ exit(1);
+}