mirror of https://github.com/omar-polo/gmid.git
add type { ... } block to define mime types mapping
The `map' rule is powerful but quite annoying to use if you have/need lots of entries (and clutters the configuration file too.) The `type' block is blatantly stolen from httpd(8) and allows for a way more nice usage: type { include "/usr/share/misc/mime.types" } or even type { text/markdown md markdown text/x-perl pl pm # ... }
This commit is contained in:
parent
88971f9a4e
commit
ee219d702e
43
parse.y
43
parse.y
|
@ -99,6 +99,7 @@ void add_param(char *, char *, int);
|
|||
static struct vhost *host;
|
||||
static struct location *loc;
|
||||
static struct proxy *proxy;
|
||||
static char *current_media;
|
||||
static int errors;
|
||||
|
||||
typedef struct {
|
||||
|
@ -128,7 +129,7 @@ typedef struct {
|
|||
%token PARAM PORT PREFORK PROTO PROTOCOLS PROXY
|
||||
%token RELAY_TO REQUIRE RETURN ROOT
|
||||
%token SERVER SNI SPAWN STRIP
|
||||
%token TCP TOEXT TYPE
|
||||
%token TCP TOEXT TYPE TYPES
|
||||
%token USE_TLS USER
|
||||
%token VERIFYNAME
|
||||
|
||||
|
@ -138,7 +139,7 @@ typedef struct {
|
|||
%token <v.number> NUM
|
||||
|
||||
%type <v.number> bool
|
||||
%type <v.string> string
|
||||
%type <v.string> string numberstring
|
||||
|
||||
%%
|
||||
|
||||
|
@ -148,6 +149,7 @@ conf : /* empty */
|
|||
| conf varset '\n'
|
||||
| conf option '\n'
|
||||
| conf vhost '\n'
|
||||
| conf types '\n'
|
||||
| conf error '\n' { file->errors++; }
|
||||
;
|
||||
|
||||
|
@ -183,6 +185,17 @@ string : string STRING {
|
|||
| STRING
|
||||
;
|
||||
|
||||
numberstring : NUM {
|
||||
char *s;
|
||||
if (asprintf(&s, "%d", $1) == -1) {
|
||||
yyerror("asprintf: number");
|
||||
YYERROR;
|
||||
}
|
||||
$$ = s;
|
||||
}
|
||||
| STRING
|
||||
;
|
||||
|
||||
varset : STRING '=' string {
|
||||
char *s = $1;
|
||||
while (*s++) {
|
||||
|
@ -455,11 +468,36 @@ fastcgi : SPAWN string {
|
|||
}
|
||||
;
|
||||
|
||||
types : TYPES '{' optnl mediaopts_l '}'
|
||||
;
|
||||
|
||||
mediaopts_l : mediaopts_l mediaoptsl nl
|
||||
| mediaoptsl nl
|
||||
;
|
||||
|
||||
mediaoptsl : STRING { current_media = $1; } medianames_l optsemicolon
|
||||
| include
|
||||
;
|
||||
|
||||
medianames_l : medianames_l medianamesl
|
||||
| medianamesl
|
||||
;
|
||||
|
||||
medianamesl : numberstring { add_mime(&conf.mime, current_media, $1); }
|
||||
;
|
||||
|
||||
nl : '\n' optnl
|
||||
;
|
||||
|
||||
optnl : '\n' optnl /* zero or more newlines */
|
||||
| ';' optnl /* semicolons too */
|
||||
| /*empty*/
|
||||
;
|
||||
|
||||
optsemicolon : ';'
|
||||
|
|
||||
;
|
||||
|
||||
%%
|
||||
|
||||
static struct keyword {
|
||||
|
@ -509,6 +547,7 @@ static struct keyword {
|
|||
{"tcp", TCP},
|
||||
{"to-ext", TOEXT},
|
||||
{"type", TYPE},
|
||||
{"types", TYPES},
|
||||
{"use-tls", USE_TLS},
|
||||
{"user", USER},
|
||||
{"verifyname", VERIFYNAME},
|
||||
|
|
Loading…
Reference in New Issue