Sun, 13 Nov 2011 13:43:01 +0100
Added some protocol functions
1 | 1 | /* |
2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | |
3 | * | |
4 | * Copyright 2011 Olaf Wintermann. All rights reserved. | |
5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions are met: | |
8 | * | |
9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | |
11 | * | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | |
15 | * | |
16 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
17 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | |
20 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
26 | * POSSIBILITY OF SUCH DAMAGE. | |
27 | */ | |
28 | ||
29 | #include "nsapi.h" | |
30 | ||
31 | #include <stdio.h> | |
32 | #include <stdlib.h> | |
33 | ||
34 | #include "httplistener.h" | |
35 | #include "conf.h" | |
36 | ||
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
37 | #include "vserver.h" |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
38 | |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
39 | VirtualServer *default_vs; |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
40 | |
1 | 41 | void load_init_conf(char *file) { |
42 | printf("load_init_conf\n"); | |
43 | } | |
44 | ||
45 | void load_server_conf(char *file) { | |
46 | printf("load_server_conf\n"); | |
47 | ||
48 | ListenerConfig *conf = malloc(sizeof(ListenerConfig)); | |
49 | conf->port = 8080; | |
50 | conf->nacceptors = 1; | |
51 | conf->name = "default"; | |
52 | ||
53 | http_listener_new(conf); | |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
54 | |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
55 | // virtual server |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
56 | default_vs = vs_new(); |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
57 | default_vs->objset = create_test_objset(); |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
58 | default_vs->default_obj_name = "default"; |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
59 | |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
60 | // begin objset test |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
61 | /* |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
62 | httpd_objset *objset = default_vs->objset; |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
63 | for(int i=0;i<objset->pos;i++) { |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
64 | httpd_object *obj = objset->obj[i]; |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
65 | printf("<object [%s]>\n", obj->name); |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
66 | for(int j=0;j<obj->nd;j++) { |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
67 | dtable *dt; |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
68 | switch(j) { |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
69 | case NSAPIAuthTrans: { |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
70 | printf(" Get AuthTrans Directives\n"); |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
71 | dt = object_get_dtable(obj, NSAPIAuthTrans); |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
72 | break; |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
73 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
74 | case NSAPINameTrans: { |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
75 | printf(" Get NameTrans Directives\n"); |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
76 | dt = object_get_dtable(obj, NSAPINameTrans); |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
77 | break; |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
78 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
79 | case NSAPIPathCheck: { |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
80 | printf(" Get PathCheck Directives\n"); |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
81 | dt = object_get_dtable(obj, NSAPIPathCheck); |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
82 | break; |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
83 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
84 | case NSAPIService: { |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
85 | printf(" Get Service Directives\n"); |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
86 | dt = object_get_dtable(obj, NSAPIService); |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
87 | break; |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
88 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
89 | default: { |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
90 | printf("j: %d\n", j); |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
91 | dt = object_get_dtable(obj, j); |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
92 | break; |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
93 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
94 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
95 | if(dt != NULL) { |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
96 | printf(" dtable[%d].length = %d\n", dt, dt->ndir); |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
97 | } else { |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
98 | continue; |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
99 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
100 | for(int k=0;k<dt->ndir;k++) { |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
101 | directive *d = dt->directive[k]; |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
102 | if(d == NULL) { |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
103 | printf("d is null\n"); |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
104 | } else { |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
105 | printf(" Directive[%d].name = %s\n", d, d->func->name); |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
106 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
107 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
108 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
109 | } |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
110 | */ |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
111 | // end objset test |
1 | 112 | } |
3
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
113 | |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
114 | VirtualServer* conf_get_default_vs() { |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
115 | return default_vs; |
137197831306
minimal request handling
Olaf Wintermann <olaf.wintermann@gmail.com>
parents:
1
diff
changeset
|
116 | } |