src/server/config/objconf.h

Sat, 25 Jan 2020 15:34:30 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sat, 25 Jan 2020 15:34:30 +0100
branch
webdav
changeset 240
cd74667f6c85
parent 95
74a81d9e19d0
child 415
d938228c382e
permissions
-rw-r--r--

add proppatch interface

16
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
1 /*
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
3 *
44
3da1f7b6847f added some error messages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 17
diff changeset
4 * Copyright 2013 Olaf Wintermann. All rights reserved.
16
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
5 *
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
6 * Redistribution and use in source and binary forms, with or without
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
7 * modification, are permitted provided that the following conditions are met:
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
8 *
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
9 * 1. Redistributions of source code must retain the above copyright
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
10 * notice, this list of conditions and the following disclaimer.
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
11 *
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
12 * 2. Redistributions in binary form must reproduce the above copyright
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer in the
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
14 * documentation and/or other materials provided with the distribution.
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
15 *
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
26 * POSSIBILITY OF SUCH DAMAGE.
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
27 */
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
28
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
29 #ifndef OBJCONF_H
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
30 #define OBJCONF_H
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
31
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
32 #include "conf.h"
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
33
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
34 #ifdef __cplusplus
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
35 extern "C" {
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
36 #endif
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
37
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
38 typedef struct _conf_object {
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
39 ConfigLine *begin;
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
40 ConfigLine *end;
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
41
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
42 sstr_t name;
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
43 sstr_t ppath;
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
44 // directives
95
74a81d9e19d0 added error directive for custom error pages
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 91
diff changeset
45 UcxList *directives[7];
16
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
46 } ConfigObject;
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
47
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
48 /*
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
49 * representing a xml like level in the obj.conf tree
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
50 */
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
51 typedef struct _conf_parser_level {
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
52 ConfigTag *iftag; // last if tag
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
53 ConfigTag *tag; // root of this level
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
54 int levelnum;
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
55 } ConfigParserLevel;
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
56
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
57 typedef struct _obj_conf {
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
58 ConfigParser parser;
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
59 char *file;
79
f48cea237ec3 fixed some memory leaks
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 44
diff changeset
60 //UcxDlist *lines;
91
fac51f87def0 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
61 UcxList *conditions;
fac51f87def0 ucx update
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 83
diff changeset
62 UcxList *objects;
16
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
63
83
28433f06d5ee added minimal nsapi conditions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 79
diff changeset
64 // private parser temp var
16
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
65 ConfigObject *obj; // add directives to this object
83
28433f06d5ee added minimal nsapi conditions
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 79
diff changeset
66 // private parser temp var
16
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
67 UcxList *levels; // tree levels (stack)
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
68
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
69 } ObjectConfig;
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
70
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
71 ObjectConfig *load_object_config(char *file);
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
72
17
d2a97bbeb57d Added init.conf parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
73 void free_object_config(ObjectConfig *conf);
d2a97bbeb57d Added init.conf parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents: 16
diff changeset
74
16
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
75 int objconf_parse(void *p, ConfigLine *begin, ConfigLine *end, sstr_t line);
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
76
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
77 int objconf_on_begin_tag(ObjectConfig *conf, ConfigTag *tag);
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
78
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
79 int objconf_on_end_tag(ObjectConfig *conf, sstr_t tagname);
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
80
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
81 int objconf_on_directive(ObjectConfig *conf, ConfigDirective *dir);
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
82
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
83
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
84 #ifdef __cplusplus
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
85 }
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
86 #endif
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
87
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
88 #endif /* OBJCONF_H */
a9bbd82d2dce New configuration file parser
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
diff changeset
89

mercurial