Rafal Kupiec před 5 roky
rodič
revize
b0c2270f15
13 změnil soubory, kde provedl 3422 přidání a 4 odebrání
  1. 339
    0
      COPYING
  2. 45
    0
      Makefile
  3. 21
    0
      README
  4. 0
    4
      README.md
  5. 187
    0
      dateparse.c
  6. 27
    0
      dateparse.h
  7. 2279
    0
      kuhttpd.c
  8. 23
    0
      kuhttpd.cnf
  9. 198
    0
      kuhttpd.h
  10. 60
    0
      match.c
  11. 16
    0
      match.h
  12. 20
    0
      mime_enc.h
  13. 207
    0
      mime_typ.h

+ 339
- 0
COPYING Zobrazit soubor

@@ -0,0 +1,339 @@
1
+                    GNU GENERAL PUBLIC LICENSE
2
+                       Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+                            Preamble
10
+
11
+  The licenses for most software are designed to take away your
12
+freedom to share and change it.  By contrast, the GNU General Public
13
+License is intended to guarantee your freedom to share and change free
14
+software--to make sure the software is free for all its users.  This
15
+General Public License applies to most of the Free Software
16
+Foundation's software and to any other program whose authors commit to
17
+using it.  (Some other Free Software Foundation software is covered by
18
+the GNU Lesser General Public License instead.)  You can apply it to
19
+your programs, too.
20
+
21
+  When we speak of free software, we are referring to freedom, not
22
+price.  Our General Public Licenses are designed to make sure that you
23
+have the freedom to distribute copies of free software (and charge for
24
+this service if you wish), that you receive source code or can get it
25
+if you want it, that you can change the software or use pieces of it
26
+in new free programs; and that you know you can do these things.
27
+
28
+  To protect your rights, we need to make restrictions that forbid
29
+anyone to deny you these rights or to ask you to surrender the rights.
30
+These restrictions translate to certain responsibilities for you if you
31
+distribute copies of the software, or if you modify it.
32
+
33
+  For example, if you distribute copies of such a program, whether
34
+gratis or for a fee, you must give the recipients all the rights that
35
+you have.  You must make sure that they, too, receive or can get the
36
+source code.  And you must show them these terms so they know their
37
+rights.
38
+
39
+  We protect your rights with two steps: (1) copyright the software, and
40
+(2) offer you this license which gives you legal permission to copy,
41
+distribute and/or modify the software.
42
+
43
+  Also, for each author's protection and ours, we want to make certain
44
+that everyone understands that there is no warranty for this free
45
+software.  If the software is modified by someone else and passed on, we
46
+want its recipients to know that what they have is not the original, so
47
+that any problems introduced by others will not reflect on the original
48
+authors' reputations.
49
+
50
+  Finally, any free program is threatened constantly by software
51
+patents.  We wish to avoid the danger that redistributors of a free
52
+program will individually obtain patent licenses, in effect making the
53
+program proprietary.  To prevent this, we have made it clear that any
54
+patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+  The precise terms and conditions for copying, distribution and
57
+modification follow.
58
+
59
+                    GNU GENERAL PUBLIC LICENSE
60
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+  0. This License applies to any program or other work which contains
63
+a notice placed by the copyright holder saying it may be distributed
64
+under the terms of this General Public License.  The "Program", below,
65
+refers to any such program or work, and a "work based on the Program"
66
+means either the Program or any derivative work under copyright law:
67
+that is to say, a work containing the Program or a portion of it,
68
+either verbatim or with modifications and/or translated into another
69
+language.  (Hereinafter, translation is included without limitation in
70
+the term "modification".)  Each licensee is addressed as "you".
71
+
72
+Activities other than copying, distribution and modification are not
73
+covered by this License; they are outside its scope.  The act of
74
+running the Program is not restricted, and the output from the Program
75
+is covered only if its contents constitute a work based on the
76
+Program (independent of having been made by running the Program).
77
+Whether that is true depends on what the Program does.
78
+
79
+  1. You may copy and distribute verbatim copies of the Program's
80
+source code as you receive it, in any medium, provided that you
81
+conspicuously and appropriately publish on each copy an appropriate
82
+copyright notice and disclaimer of warranty; keep intact all the
83
+notices that refer to this License and to the absence of any warranty;
84
+and give any other recipients of the Program a copy of this License
85
+along with the Program.
86
+
87
+You may charge a fee for the physical act of transferring a copy, and
88
+you may at your option offer warranty protection in exchange for a fee.
89
+
90
+  2. You may modify your copy or copies of the Program or any portion
91
+of it, thus forming a work based on the Program, and copy and
92
+distribute such modifications or work under the terms of Section 1
93
+above, provided that you also meet all of these conditions:
94
+
95
+    a) You must cause the modified files to carry prominent notices
96
+    stating that you changed the files and the date of any change.
97
+
98
+    b) You must cause any work that you distribute or publish, that in
99
+    whole or in part contains or is derived from the Program or any
100
+    part thereof, to be licensed as a whole at no charge to all third
101
+    parties under the terms of this License.
102
+
103
+    c) If the modified program normally reads commands interactively
104
+    when run, you must cause it, when started running for such
105
+    interactive use in the most ordinary way, to print or display an
106
+    announcement including an appropriate copyright notice and a
107
+    notice that there is no warranty (or else, saying that you provide
108
+    a warranty) and that users may redistribute the program under
109
+    these conditions, and telling the user how to view a copy of this
110
+    License.  (Exception: if the Program itself is interactive but
111
+    does not normally print such an announcement, your work based on
112
+    the Program is not required to print an announcement.)
113
+
114
+These requirements apply to the modified work as a whole.  If
115
+identifiable sections of that work are not derived from the Program,
116
+and can be reasonably considered independent and separate works in
117
+themselves, then this License, and its terms, do not apply to those
118
+sections when you distribute them as separate works.  But when you
119
+distribute the same sections as part of a whole which is a work based
120
+on the Program, the distribution of the whole must be on the terms of
121
+this License, whose permissions for other licensees extend to the
122
+entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+Thus, it is not the intent of this section to claim rights or contest
125
+your rights to work written entirely by you; rather, the intent is to
126
+exercise the right to control the distribution of derivative or
127
+collective works based on the Program.
128
+
129
+In addition, mere aggregation of another work not based on the Program
130
+with the Program (or with a work based on the Program) on a volume of
131
+a storage or distribution medium does not bring the other work under
132
+the scope of this License.
133
+
134
+  3. You may copy and distribute the Program (or a work based on it,
135
+under Section 2) in object code or executable form under the terms of
136
+Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+    a) Accompany it with the complete corresponding machine-readable
139
+    source code, which must be distributed under the terms of Sections
140
+    1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+    b) Accompany it with a written offer, valid for at least three
143
+    years, to give any third party, for a charge no more than your
144
+    cost of physically performing source distribution, a complete
145
+    machine-readable copy of the corresponding source code, to be
146
+    distributed under the terms of Sections 1 and 2 above on a medium
147
+    customarily used for software interchange; or,
148
+
149
+    c) Accompany it with the information you received as to the offer
150
+    to distribute corresponding source code.  (This alternative is
151
+    allowed only for noncommercial distribution and only if you
152
+    received the program in object code or executable form with such
153
+    an offer, in accord with Subsection b above.)
154
+
155
+The source code for a work means the preferred form of the work for
156
+making modifications to it.  For an executable work, complete source
157
+code means all the source code for all modules it contains, plus any
158
+associated interface definition files, plus the scripts used to
159
+control compilation and installation of the executable.  However, as a
160
+special exception, the source code distributed need not include
161
+anything that is normally distributed (in either source or binary
162
+form) with the major components (compiler, kernel, and so on) of the
163
+operating system on which the executable runs, unless that component
164
+itself accompanies the executable.
165
+
166
+If distribution of executable or object code is made by offering
167
+access to copy from a designated place, then offering equivalent
168
+access to copy the source code from the same place counts as
169
+distribution of the source code, even though third parties are not
170
+compelled to copy the source along with the object code.
171
+
172
+  4. You may not copy, modify, sublicense, or distribute the Program
173
+except as expressly provided under this License.  Any attempt
174
+otherwise to copy, modify, sublicense or distribute the Program is
175
+void, and will automatically terminate your rights under this License.
176
+However, parties who have received copies, or rights, from you under
177
+this License will not have their licenses terminated so long as such
178
+parties remain in full compliance.
179
+
180
+  5. You are not required to accept this License, since you have not
181
+signed it.  However, nothing else grants you permission to modify or
182
+distribute the Program or its derivative works.  These actions are
183
+prohibited by law if you do not accept this License.  Therefore, by
184
+modifying or distributing the Program (or any work based on the
185
+Program), you indicate your acceptance of this License to do so, and
186
+all its terms and conditions for copying, distributing or modifying
187
+the Program or works based on it.
188
+
189
+  6. Each time you redistribute the Program (or any work based on the
190
+Program), the recipient automatically receives a license from the
191
+original licensor to copy, distribute or modify the Program subject to
192
+these terms and conditions.  You may not impose any further
193
+restrictions on the recipients' exercise of the rights granted herein.
194
+You are not responsible for enforcing compliance by third parties to
195
+this License.
196
+
197
+  7. If, as a consequence of a court judgment or allegation of patent
198
+infringement or for any other reason (not limited to patent issues),
199
+conditions are imposed on you (whether by court order, agreement or
200
+otherwise) that contradict the conditions of this License, they do not
201
+excuse you from the conditions of this License.  If you cannot
202
+distribute so as to satisfy simultaneously your obligations under this
203
+License and any other pertinent obligations, then as a consequence you
204
+may not distribute the Program at all.  For example, if a patent
205
+license would not permit royalty-free redistribution of the Program by
206
+all those who receive copies directly or indirectly through you, then
207
+the only way you could satisfy both it and this License would be to
208
+refrain entirely from distribution of the Program.
209
+
210
+If any portion of this section is held invalid or unenforceable under
211
+any particular circumstance, the balance of the section is intended to
212
+apply and the section as a whole is intended to apply in other
213
+circumstances.
214
+
215
+It is not the purpose of this section to induce you to infringe any
216
+patents or other property right claims or to contest validity of any
217
+such claims; this section has the sole purpose of protecting the
218
+integrity of the free software distribution system, which is
219
+implemented by public license practices.  Many people have made
220
+generous contributions to the wide range of software distributed
221
+through that system in reliance on consistent application of that
222
+system; it is up to the author/donor to decide if he or she is willing
223
+to distribute software through any other system and a licensee cannot
224
+impose that choice.
225
+
226
+This section is intended to make thoroughly clear what is believed to
227
+be a consequence of the rest of this License.
228
+
229
+  8. If the distribution and/or use of the Program is restricted in
230
+certain countries either by patents or by copyrighted interfaces, the
231
+original copyright holder who places the Program under this License
232
+may add an explicit geographical distribution limitation excluding
233
+those countries, so that distribution is permitted only in or among
234
+countries not thus excluded.  In such case, this License incorporates
235
+the limitation as if written in the body of this License.
236
+
237
+  9. The Free Software Foundation may publish revised and/or new versions
238
+of the General Public License from time to time.  Such new versions will
239
+be similar in spirit to the present version, but may differ in detail to
240
+address new problems or concerns.
241
+
242
+Each version is given a distinguishing version number.  If the Program
243
+specifies a version number of this License which applies to it and "any
244
+later version", you have the option of following the terms and conditions
245
+either of that version or of any later version published by the Free
246
+Software Foundation.  If the Program does not specify a version number of
247
+this License, you may choose any version ever published by the Free Software
248
+Foundation.
249
+
250
+  10. If you wish to incorporate parts of the Program into other free
251
+programs whose distribution conditions are different, write to the author
252
+to ask for permission.  For software which is copyrighted by the Free
253
+Software Foundation, write to the Free Software Foundation; we sometimes
254
+make exceptions for this.  Our decision will be guided by the two goals
255
+of preserving the free status of all derivatives of our free software and
256
+of promoting the sharing and reuse of software generally.
257
+
258
+                            NO WARRANTY
259
+
260
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
262
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
266
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
267
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+REPAIR OR CORRECTION.
269
+
270
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+POSSIBILITY OF SUCH DAMAGES.
279
+
280
+                     END OF TERMS AND CONDITIONS
281
+
282
+            How to Apply These Terms to Your New Programs
283
+
284
+  If you develop a new program, and you want it to be of the greatest
285
+possible use to the public, the best way to achieve this is to make it
286
+free software which everyone can redistribute and change under these terms.
287
+
288
+  To do so, attach the following notices to the program.  It is safest
289
+to attach them to the start of each source file to most effectively
290
+convey the exclusion of warranty; and each file should have at least
291
+the "copyright" line and a pointer to where the full notice is found.
292
+
293
+    <one line to give the program's name and a brief idea of what it does.>
294
+    Copyright (C) <year>  <name of author>
295
+
296
+    This program is free software; you can redistribute it and/or modify
297
+    it under the terms of the GNU General Public License as published by
298
+    the Free Software Foundation; either version 2 of the License, or
299
+    (at your option) any later version.
300
+
301
+    This program is distributed in the hope that it will be useful,
302
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
303
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
304
+    GNU General Public License for more details.
305
+
306
+    You should have received a copy of the GNU General Public License along
307
+    with this program; if not, write to the Free Software Foundation, Inc.,
308
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309
+
310
+Also add information on how to contact you by electronic and paper mail.
311
+
312
+If the program is interactive, make it output a short notice like this
313
+when it starts in an interactive mode:
314
+
315
+    Gnomovision version 69, Copyright (C) year name of author
316
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317
+    This is free software, and you are welcome to redistribute it
318
+    under certain conditions; type `show c' for details.
319
+
320
+The hypothetical commands `show w' and `show c' should show the appropriate
321
+parts of the General Public License.  Of course, the commands you use may
322
+be called something other than `show w' and `show c'; they could even be
323
+mouse-clicks or menu items--whatever suits your program.
324
+
325
+You should also get your employer (if you work as a programmer) or your
326
+school, if any, to sign a "copyright disclaimer" for the program, if
327
+necessary.  Here is a sample; alter the names:
328
+
329
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
+
332
+  <signature of Ty Coon>, 1 April 1989
333
+  Ty Coon, President of Vice
334
+
335
+This General Public License does not permit incorporating your program into
336
+proprietary programs.  If your program is a subroutine library, you may
337
+consider it more useful to permit linking proprietary applications with the
338
+library.  If this is what you want to do, use the GNU Lesser General
339
+Public License instead of this License.

+ 45
- 0
Makefile Zobrazit soubor

@@ -0,0 +1,45 @@
1
+CC =		gcc
2
+CFLAGS =	-O2 -s -D_GNU_SOURCE
3
+LDLIBS =	-lcrypt -lcyassl -lm
4
+PREFIX =
5
+BINDIR =	$(PREFIX)/usr/sbin
6
+
7
+ifeq ($(CROSS_BUILD), 1)
8
+	DEFS:=-DCROSS_BUILD
9
+else
10
+	DEFS:=
11
+endif
12
+
13
+all: kuhttpd cert
14
+	@echo "All done!"
15
+
16
+kuhttpd: kuhttpd.o match.o dateparse.o
17
+	$(CC) $(CFLAGS) $(LDLIBS) kuhttpd.o match.o dateparse.o -o kuhttpd
18
+
19
+kuhttpd.o: kuhttpd.c
20
+	$(CC) $(CFLAGS) $(DEFS) -c kuhttpd.c
21
+
22
+match.o: match.c
23
+	$(CC) $(CFLAGS) $(DEFS) -c match.c
24
+
25
+dateparse.o: dateparse.c
26
+	$(CC) $(CFLAGS) $(DEFS) -c dateparse.c
27
+
28
+cert: kuhttpd.pem
29
+kuhttpd.pem: kuhttpd.cnf
30
+	openssl req -batch -new -x509 -days 7500 -nodes -config kuhttpd.cnf -out kuhttpd.pem -keyout kuhttpd.pem
31
+	openssl x509 -subject -dates -fingerprint -noout -in kuhttpd.pem
32
+	chmod 600 kuhttpd.pem
33
+
34
+install:
35
+	mkdir -p $(BINDIR)
36
+	cp kuhttpd $(BINDIR)
37
+	@echo "All done!"
38
+
39
+uninstall:
40
+	@rm -f $(BINDIR)/kuhttpd
41
+	@echo "All done!"
42
+
43
+clean:
44
+	rm -f kuhttpd kuhttpd.pem kuhttpd.rnd *.o
45
+	@echo "All done!"

+ 21
- 0
README Zobrazit soubor

@@ -0,0 +1,21 @@
1
+Kagera Micro HTTP Daemon
2
+========================
3
+
4
+KUHTTP Daemon is a micro HTTP server optimised for size and low and medium
5
+traffic sites. It is dedicated to serve configuration sites on Linux-based
6
+routers as well as some additional pages like Captive Portals. It implements
7
+all the basic features of an HTTP server, including:
8
+
9
+  * GET, HEAD, and POST methods
10
+  * CGI process communication
11
+  * Multilanguage CGI
12
+  * Basic authentication
13
+  * IPv6 and SSL/HTTPS communication
14
+  * Directory listings
15
+  * The common MIME types
16
+  * Trailing-slash redirection
17
+  * Security against ".." filename snooping
18
+  * Standard logging
19
+
20
+
21
+KUHTTP Daemon is based on mini_httpd: <http://acme.com/software/mini_httpd/>.

+ 0
- 4
README.md Zobrazit soubor

@@ -1,4 +0,0 @@
1
-kuhttpd
2
-=======
3
-
4
-Kagera uHTTP Daemon

+ 187
- 0
dateparse.c Zobrazit soubor

@@ -0,0 +1,187 @@
1
+/**
2
+ * @PROJECT			Kagera uHTTP Daemon
3
+ * @COPYRIGHT		See COPYING in the top level directory
4
+ * @FILE			dateparse.c
5
+ * @PURPOSE			Parses string dates into internal form
6
+ * @DEVELOPERS		Rafal Kupiec <belliash@asiotec.eu.org>
7
+ *					Jef Poskanzer <jef@acme.com>
8
+ */
9
+
10
+#include <sys/types.h>
11
+#include <ctype.h>
12
+#include <stdio.h>
13
+#include <stdlib.h>
14
+#include <string.h>
15
+#include <time.h>
16
+
17
+#include "dateparse.h"
18
+
19
+time_t dateparse(char* str) {
20
+	struct tm tm;
21
+	char* cp;
22
+	char str_mon[500], str_wday[500];
23
+	int tm_sec, tm_min, tm_hour, tm_mday, tm_year;
24
+	long tm_mon, tm_wday;
25
+
26
+	(void) memset((char*) &tm, 0, sizeof(struct tm));
27
+	for(cp = str; *cp == ' ' || *cp == '\t'; ++cp) {
28
+		continue;
29
+	}
30
+	if(sscanf(cp, "%d-%400[a-zA-Z]-%d %d:%d:%d GMT", &tm_mday, str_mon, &tm_year, &tm_hour, &tm_min, &tm_sec) == 6 && scan_mon(str_mon, &tm_mon)) {
31
+		tm.tm_mday = tm_mday;
32
+		tm.tm_mon = tm_mon;
33
+		tm.tm_year = tm_year;
34
+		tm.tm_hour = tm_hour;
35
+		tm.tm_min = tm_min;
36
+		tm.tm_sec = tm_sec;
37
+	} else if(sscanf(cp, "%d %400[a-zA-Z] %d %d:%d:%d GMT", &tm_mday, str_mon, &tm_year, &tm_hour, &tm_min, &tm_sec) == 6 && scan_mon(str_mon, &tm_mon)) {
38
+		tm.tm_mday = tm_mday;
39
+		tm.tm_mon = tm_mon;
40
+		tm.tm_year = tm_year;
41
+		tm.tm_hour = tm_hour;
42
+		tm.tm_min = tm_min;
43
+		tm.tm_sec = tm_sec;
44
+	} else if(sscanf(cp, "%d:%d:%d GMT %d-%400[a-zA-Z]-%d", &tm_hour, &tm_min, &tm_sec, &tm_mday, str_mon, &tm_year) == 6 && scan_mon(str_mon, &tm_mon)) {
45
+		tm.tm_hour = tm_hour;
46
+		tm.tm_min = tm_min;
47
+		tm.tm_sec = tm_sec;
48
+		tm.tm_mday = tm_mday;
49
+		tm.tm_mon = tm_mon;
50
+		tm.tm_year = tm_year;
51
+	} else if(sscanf(cp, "%d:%d:%d GMT %d %400[a-zA-Z] %d", &tm_hour, &tm_min, &tm_sec, &tm_mday, str_mon, &tm_year) == 6 && scan_mon(str_mon, &tm_mon)) {
52
+		tm.tm_hour = tm_hour;
53
+		tm.tm_min = tm_min;
54
+		tm.tm_sec = tm_sec;
55
+		tm.tm_mday = tm_mday;
56
+		tm.tm_mon = tm_mon;
57
+		tm.tm_year = tm_year;
58
+	} else if(sscanf(cp, "%400[a-zA-Z], %d-%400[a-zA-Z]-%d %d:%d:%d GMT", str_wday, &tm_mday, str_mon, &tm_year, &tm_hour, &tm_min, &tm_sec) == 7 && scan_wday(str_wday, &tm_wday) && scan_mon(str_mon, &tm_mon)) {
59
+		tm.tm_wday = tm_wday;
60
+		tm.tm_mday = tm_mday;
61
+		tm.tm_mon = tm_mon;
62
+		tm.tm_year = tm_year;
63
+		tm.tm_hour = tm_hour;
64
+		tm.tm_min = tm_min;
65
+		tm.tm_sec = tm_sec;
66
+	} else if(sscanf(cp, "%400[a-zA-Z], %d %400[a-zA-Z] %d %d:%d:%d GMT", str_wday, &tm_mday, str_mon, &tm_year, &tm_hour, &tm_min, &tm_sec) == 7 && scan_wday(str_wday, &tm_wday) && scan_mon(str_mon, &tm_mon)) {
67
+		tm.tm_wday = tm_wday;
68
+		tm.tm_mday = tm_mday;
69
+		tm.tm_mon = tm_mon;
70
+		tm.tm_year = tm_year;
71
+		tm.tm_hour = tm_hour;
72
+		tm.tm_min = tm_min;
73
+		tm.tm_sec = tm_sec;
74
+	} else if(sscanf(cp, "%400[a-zA-Z] %400[a-zA-Z] %d %d:%d:%d GMT %d", str_wday, str_mon, &tm_mday, &tm_hour, &tm_min, &tm_sec, &tm_year) == 7 && scan_wday(str_wday, &tm_wday) && scan_mon(str_mon, &tm_mon)) {
75
+		tm.tm_wday = tm_wday;
76
+		tm.tm_mon = tm_mon;
77
+		tm.tm_mday = tm_mday;
78
+		tm.tm_hour = tm_hour;
79
+		tm.tm_min = tm_min;
80
+		tm.tm_sec = tm_sec;
81
+		tm.tm_year = tm_year;
82
+	} else {
83
+		return (time_t) -1;
84
+	}
85
+	if(tm.tm_year > 1900) {
86
+		tm.tm_year -= 1900;
87
+	} else if(tm.tm_year < 70) {
88
+		tm.tm_year += 100;
89
+	}
90
+	return tm_to_time(&tm);
91
+}
92
+
93
+static int is_leap(int year) {
94
+	return year % 400? (year % 100 ? (year % 4 ? 0 : 1) : 0) : 1;
95
+}
96
+
97
+static void pound_case(char* str) {
98
+	for(; *str != '\0'; ++str) {
99
+		if(isupper((int) *str)) {
100
+			*str = tolower((int) *str);
101
+		}
102
+	}
103
+}
104
+
105
+static int scan_mon(char* str_mon, long* tm_monP) {
106
+	static struct strlong mon_tab[] = {
107
+		{ "jan", 0 }, { "january", 0 },
108
+		{ "feb", 1 }, { "february", 1 },
109
+		{ "mar", 2 }, { "march", 2 },
110
+		{ "apr", 3 }, { "april", 3 },
111
+		{ "may", 4 },
112
+		{ "jun", 5 }, { "june", 5 },
113
+		{ "jul", 6 }, { "july", 6 },
114
+		{ "aug", 7 }, { "august", 7 },
115
+		{ "sep", 8 }, { "september", 8 },
116
+		{ "oct", 9 }, { "october", 9 },
117
+		{ "nov", 10 }, { "november", 10 },
118
+		{ "dec", 11 }, { "december", 11 },
119
+	};
120
+	static int sorted = 0;
121
+	if(!sorted) {
122
+		(void) qsort(mon_tab, sizeof(mon_tab) / sizeof(struct strlong), sizeof(struct strlong), (int(*)(const void*, const void*)) strlong_compare);
123
+		sorted = 1;
124
+	}
125
+	pound_case(str_mon);
126
+	return strlong_search(str_mon, mon_tab, sizeof(mon_tab) / sizeof(struct strlong), tm_monP);
127
+}
128
+
129
+static int scan_wday(char* str_wday, long* tm_wdayP) {
130
+	static struct strlong wday_tab[] = {
131
+		{ "sun", 0 }, { "sunday", 0 },
132
+		{ "mon", 1 }, { "monday", 1 },
133
+		{ "tue", 2 }, { "tuesday", 2 },
134
+		{ "wed", 3 }, { "wednesday", 3 },
135
+		{ "thu", 4 }, { "thursday", 4 },
136
+		{ "fri", 5 }, { "friday", 5 },
137
+		{ "sat", 6 }, { "saturday", 6 },
138
+	};
139
+	static int sorted = 0;
140
+	if(!sorted) {
141
+		(void) qsort(wday_tab, sizeof(wday_tab) / sizeof(struct strlong), sizeof(struct strlong), (int(*)(const void*, const void*)) strlong_compare);
142
+		sorted = 1;
143
+	}
144
+	pound_case(str_wday);
145
+	return strlong_search(str_wday, wday_tab, sizeof(wday_tab) / sizeof(struct strlong), tm_wdayP);
146
+}
147
+
148
+static int strlong_compare(char *v1, char *v2) {
149
+	return strcmp(((struct strlong*) v1)->s, ((struct strlong*) v2)->s);
150
+}
151
+
152
+static int strlong_search(char* str, struct strlong* tab, int n, long* lP) {
153
+	int i, h, l, r;
154
+	l = 0;
155
+	h = n - 1;
156
+	for(;;) {
157
+		i = (h + l) / 2;
158
+		r = strcmp(str, tab[i].s);
159
+		if(r < 0) {
160
+			h = i - 1;
161
+		} else if(r > 0) {
162
+			l = i + 1;
163
+		} else {
164
+			*lP = tab[i].l;
165
+			return 1;
166
+		}
167
+		if(h < l) {
168
+			return 0;
169
+		}
170
+	}
171
+}
172
+
173
+static time_t tm_to_time(struct tm* tmP) {
174
+	time_t t;
175
+	static int monthtab[12] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
176
+	t = (tmP->tm_year - 70) * 365;
177
+	t += (tmP->tm_year - 69) / 4;
178
+	t += monthtab[tmP->tm_mon];
179
+	if(tmP->tm_mon >= 2 && is_leap(tmP->tm_year + 1900)) {
180
+		++t;
181
+	}
182
+	t += tmP->tm_mday - 1;
183
+	t = t * 24 + tmP->tm_hour;
184
+	t = t * 60 + tmP->tm_min;
185
+	t = t * 60 + tmP->tm_sec;
186
+	return t;
187
+}

+ 27
- 0
dateparse.h Zobrazit soubor

@@ -0,0 +1,27 @@
1
+/**
2
+ * @PROJECT			Kagera uHTTP Daemon
3
+ * @COPYRIGHT		See COPYING in the top level directory
4
+ * @FILE			dateparse.h
5
+ * @PURPOSE			Parses string dates into internal form
6
+ * @DEVELOPERS		Rafal Kupiec <belliash@asiotec.eu.org>
7
+ *					Jef Poskanzer <jef@acme.com>
8
+ */
9
+
10
+#ifndef __DATEPARSE_H
11
+#define __DATEPARSE_H
12
+
13
+struct strlong {
14
+	char* s;
15
+	long l;
16
+};
17
+
18
+extern time_t dateparse(char* str);
19
+static int is_leap(int year);
20
+static void pound_case(char* str);
21
+static int scan_mon(char* str_mon, long* tm_monP);
22
+static int scan_wday(char* str_wday, long* tm_wdayP);
23
+static int strlong_compare(char *v1, char *v2);
24
+static int strlong_search(char* str, struct strlong* tab, int n, long* lP);
25
+static time_t tm_to_time(struct tm* tmP);
26
+
27
+#endif

+ 2279
- 0
kuhttpd.c
Diff nebyl zobrazen, protože je příliš veliký
Zobrazit soubor


+ 23
- 0
kuhttpd.cnf Zobrazit soubor

@@ -0,0 +1,23 @@
1
+RANDFILE = kuhttpd.rnd
2
+
3
+[req]
4
+default_bits = 1024
5
+encrypt_key = yes
6
+distinguished_name = req_dn
7
+x509_extensions = cert_type
8
+
9
+[req_dn]
10
+countryName = Country Name (2 letter code)
11
+countryName_default             = EU
12
+countryName_min                 = 2
13
+countryName_max                 = 2
14
+stateOrProvinceName             = State or Province Name (full name)
15
+stateOrProvinceName_default     = European Union
16
+localityName                    = European Union
17
+organizationName                = Organization Name (eg, company)
18
+organizationName_default        = Asio Software Technologies
19
+commonName                      = Common Name (FQDN of your server)
20
+commonName_default              = Kagera Router Management Utility
21
+
22
+[cert_type]
23
+nsCertType = server

+ 198
- 0
kuhttpd.h Zobrazit soubor

@@ -0,0 +1,198 @@
1
+/**
2
+ * @PROJECT			Kagera uHTTP Daemon
3
+ * @COPYRIGHT		See COPYING in the top level directory
4
+ * @FILE			kuhttpd.h
5
+ * @PURPOSE			HTTP Server
6
+ * @DEVELOPERS		Rafal Kupiec <belliash@asiotec.eu.org>
7
+ *					Jef Poskanzer <jef@acme.com>
8
+ */
9
+
10
+#ifndef __KUHTTPD_H
11
+#define __KUHTTPD_H
12
+
13
+#define STDIN_FILENO 0
14
+#define STDOUT_FILENO 1
15
+#define STDERR_FILENO 2
16
+#define SIZE_T_MAX 2147483647L
17
+
18
+#define ERR_DIR "errors"
19
+#define DEFAULT_HTTP_PORT 80
20
+#define DEFAULT_HTTPS_PORT 443
21
+#define DEFAULT_CERTFILE "kuhttpd.pem"
22
+#define DEFAULT_CHARSET "UTF-8"
23
+#define DEFAULT_LANGUAGE "english"
24
+#define DEFAULT_CGI_PATTERN "cgi-bin/**|**.cgi|**.sh"
25
+#define DEFAULT_USER "nobody"
26
+#define CGI_NICE 10
27
+#define CGI_PATH "/usr/local/bin:/usr/ucb:/bin:/usr/bin:/usr/local/sbin:/sbin:/usr/sbin"
28
+#define CGI_LD_LIBRARY_PATH "/usr/local/lib:/usr/lib:/lib"
29
+#define AUTH_FILE ".htpasswd"
30
+#define READ_TIMEOUT 60
31
+#define WRITE_TIMEOUT 300
32
+
33
+#define METHOD_UNKNOWN 0
34
+#define METHOD_GET 1
35
+#define METHOD_HEAD 2
36
+#define METHOD_POST 3
37
+
38
+#define SERVER_SOFTWARE "Kagera uHTTP Daemon 1.4"
39
+
40
+struct mime_entry {
41
+	char* ext;
42
+	size_t ext_len;
43
+	char* val;
44
+	size_t val_len;
45
+};
46
+
47
+typedef union {
48
+	struct sockaddr sa;
49
+	struct sockaddr_in sa_in;
50
+	struct sockaddr_in6 sa_in6;
51
+	struct sockaddr_storage sa_stor;
52
+} usockaddr;
53
+
54
+static int b64_decode_table[256] = {
55
+	-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
56
+	-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
57
+	-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,
58
+	52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1,
59
+	-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,
60
+	15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,
61
+	-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,
62
+	41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1,
63
+	-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
64
+	-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
65
+	-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
66
+	-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
67
+	-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
68
+	-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
69
+	-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
70
+	-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
71
+};
72
+
73
+static unsigned char allowDirectoryListing;
74
+static char* argv0;
75
+static char* data_dir;
76
+static char* certfile;
77
+static char* cgi_pattern;
78
+static char* charset;
79
+static char* language;
80
+static char* cipher;
81
+static char cwd[MAXPATHLEN];
82
+static int debug;
83
+static char* defaultPageFile;
84
+static char* defaultRealmName;
85
+static char* defaultRealmPasswordFile;
86
+static char* dir;
87
+static int do_ssl;
88
+static int got_hup;
89
+static char* hostname;
90
+static char hostname_buf[500];
91
+static int listen4_fd, listen6_fd;
92
+static int listen4s_fd, listen6s_fd;
93
+static char* local_pattern;
94
+static char* logfile;
95
+static FILE* logfp;
96
+static int max_age;
97
+static int no_empty_referers;
98
+static char* p3p;
99
+static char* pageNotFoundFile;
100
+static char* pidfile;
101
+static unsigned short port;
102
+static SSL_CTX* ssl_ctx;
103
+static unsigned short sslPort; 
104
+static char* url_pattern;
105
+static char* user;
106
+
107
+static off_t bytes;
108
+static usockaddr client_addr;
109
+static int conn_fd;
110
+static char* file;
111
+static int method;
112
+static char* path;
113
+static char* pathinfo;
114
+static char* protocol;
115
+static char* query;
116
+static char* request;
117
+static size_t request_size, request_len, request_idx;
118
+struct stat sb;
119
+static SSL* ssl;
120
+static int status;
121
+
122
+static char* authorization;
123
+static size_t content_length;
124
+static char* content_type;
125
+static char* cookie;
126
+static char* host;
127
+static time_t if_modified_since;
128
+static char* referer;
129
+static char* remoteuser;
130
+static char* response;
131
+static size_t response_size, response_len;
132
+static char* useragent;
133
+
134
+static void add_headers(int s, char* title, char* extra_header, char* me, char* mt, off_t b, time_t mod);
135
+static void add_to_buf(char** bufP, size_t* bufsizeP, size_t* buflenP, char* str, size_t len);
136
+static void add_to_request(char* str, size_t len);
137
+static void add_to_response(char* str, size_t len);
138
+static void auth_check(char* dirname, int is_ssl);
139
+static int b64_decode(const char* str, unsigned char* space, int size);
140
+static char* build_env(char* fmt, char* arg);
141
+static void cgi_interpose_input(int wfd, int is_ssl);
142
+static void cgi_interpose_output(int rfd, int parse_headers, int is_ssl);
143
+static void check_referer(int is_ssl);
144
+static void clear_ndelay(int fd);
145
+extern char* crypt(const char* key, const char* setting);
146
+static void de_dotdot(char* file);
147
+static void do_cgi(int is_ssl, unsigned short port);
148
+static void do_dir(int is_ssl);
149
+static void do_file(int is_ssl, unsigned short conn_port);
150
+static void* e_malloc(size_t size);
151
+static void* e_realloc(void* optr, size_t size);
152
+static char* e_strdup(char* ostr);
153
+static const char* figure_mime(char* name, char* me, size_t me_size);
154
+static char* file_details(const char* dir, const char* name);
155
+static char* get_method_str(int m);
156
+static int get_pathinfo(void);
157
+static char* get_request_line(void);
158
+static void handle_read_timeout(int sig, int is_ssl);
159
+static void handle_read_timeout_sig(int sig);
160
+static void handle_request(int is_ssl, unsigned short conn_port);
161
+static void handle_sigchld(int sig);
162
+static void handle_sighup(int sig);
163
+static void handle_sigterm(int sig);
164
+static void handle_write_timeout(int sig);
165
+static int hexit(char c);
166
+static void init_mime(void);
167
+static int initialize_listen_socket(usockaddr* usaP);
168
+static void lookup_hostname(usockaddr* usa4P, usockaddr* usa4sP, size_t sa4_len, int* gotv4P, int* gotv4sP, usockaddr* usa6P, usockaddr* usa6sP, size_t sa6_len, int* gotv6P, int* gotv6sP);
169
+static char** make_argp(void);
170
+static char** make_envp(int is_sl, unsigned short port);
171
+static void make_log_entry(void);
172
+static char* ntoa(usockaddr* usaP);
173
+static ssize_t my_read(char* buf, size_t size, int is_ssl);
174
+static ssize_t my_write(char* buf, size_t size, int is_ssl);
175
+static void no_value_required(char* name, char* value);
176
+static void post_post_garbage_hack(int is_ssl);
177
+static void read_config(char* filename);
178
+static int really_check_referer(void);
179
+static void reopen_logfile(void);
180
+static void send_authenticate(char* realm, int is_ssl);
181
+static void send_error(int s, char* title, char* extra_header, char* text, int is_ssl);
182
+static void send_error_body(int s, char* title, char* text);
183
+static int send_error_file(char* filename);
184
+static void send_error_tail(void);
185
+static void send_redirect(char* extra_header, char* hostname, char* new_location, int is_ssl);
186
+static void send_response(int is_ssl);
187
+static void send_via_write(int fd, off_t size, int is_ssl);
188
+static void set_ndelay(int fd);
189
+static int sockaddr_check(usockaddr* usaP);
190
+static size_t sockaddr_len(usockaddr* usaP);
191
+static void start_request(void);
192
+static void start_response(void);
193
+static void strdecode(char* to, char* from);
194
+static void strencode(char* to, size_t tosize, const char* from);
195
+static void usage(void);
196
+static void value_required(char* name, char* value);
197
+
198
+#endif

+ 60
- 0
match.c Zobrazit soubor

@@ -0,0 +1,60 @@
1
+/**
2
+ * @PROJECT			Kagera uHTTP Daemon
3
+ * @COPYRIGHT		See COPYING in the top level directory
4
+ * @FILE			match.c
5
+ * @PURPOSE			Simple shell-style filename matcher
6
+ * @DEVELOPERS		Rafal Kupiec <belliash@asiotec.eu.org>
7
+ *					Jef Poskanzer <jef@acme.com>
8
+ */
9
+
10
+#include <string.h>
11
+
12
+#include "match.h"
13
+
14
+int match(const char* pattern, const char* string) {
15
+	const char* or;
16
+
17
+	for(;;) {
18
+		or = strchr( pattern, '|' );
19
+		if(or == (char*) 0) {
20
+			return match_one(pattern, strlen(pattern), string);
21
+		}
22
+		if(match_one( pattern, or - pattern, string)) {
23
+			return 1;
24
+		}
25
+		pattern = or + 1;
26
+	}
27
+}
28
+
29
+static int match_one(const char* pattern, int patternlen, const char* string) {
30
+	const char* p;
31
+	for(p = pattern; p - pattern < patternlen; ++p, ++string) {
32
+		if(*p == '?' && *string != '\0') {
33
+			continue;
34
+		}
35
+		if(*p == '*') {
36
+			int i, pl;
37
+			++p;
38
+			if(*p == '*') {
39
+				++p;
40
+				i = strlen(string);
41
+			} else {
42
+				i = strcspn(string, "/");
43
+			}
44
+			pl = patternlen - (p - pattern);
45
+			for(; i >= 0; --i) {
46
+				if(match_one(p, pl, &(string[i]))) {
47
+					return 1;
48
+				}
49
+			}
50
+			return 0;
51
+		}
52
+		if(*p != *string) {
53
+			return 0;
54
+		}
55
+	}
56
+	if(*string == '\0') {
57
+		return 1;
58
+	}
59
+	return 0;
60
+}

+ 16
- 0
match.h Zobrazit soubor

@@ -0,0 +1,16 @@
1
+/**
2
+ * @PROJECT			Kagera uHTTP Daemon
3
+ * @COPYRIGHT		See COPYING in the top level directory
4
+ * @FILE			match.h
5
+ * @PURPOSE			Simple shell-style filename matcher
6
+ * @DEVELOPERS		Rafal Kupiec <belliash@asiotec.eu.org>
7
+ *					Jef Poskanzer <jef@acme.com>
8
+ */
9
+
10
+#ifndef __MATCH_H
11
+#define __MATCH_H
12
+
13
+extern int match(const char* pattern, const char* string);
14
+static int match_one(const char* pattern, int patternlen, const char* string);
15
+
16
+#endif

+ 20
- 0
mime_enc.h Zobrazit soubor

@@ -0,0 +1,20 @@
1
+/**
2
+ * @PROJECT			Kagera uHTTP Daemon
3
+ * @COPYRIGHT		See COPYING in the top level directory
4
+ * @FILE			mime_enc.h
5
+ * @PURPOSE			MIME encodings list
6
+ * @DEVELOPERS		Rafal Kupiec <belliash@asiotec.eu.org>
7
+ */
8
+
9
+#ifndef __MIME_ENC_H
10
+#define __MIME_ENC_H
11
+
12
+static struct mime_entry enc_tab[] = {
13
+	{ "Z", 0, "compress", 0 },
14
+	{ "gz", 0, "gzip", 0 },
15
+	{ "uu", 0, "x-uuencode", 0 },
16
+};
17
+
18
+static const int n_enc_tab = sizeof(enc_tab) / sizeof(*enc_tab);
19
+
20
+#endif

+ 207
- 0
mime_typ.h Zobrazit soubor

@@ -0,0 +1,207 @@
1
+/**
2
+ * @PROJECT			Kagera uHTTP Daemon
3
+ * @COPYRIGHT		See COPYING in the top level directory
4
+ * @FILE			mime_typ.h
5
+ * @PURPOSE			MIME types list
6
+ * @DEVELOPERS		Rafal Kupiec <belliash@asiotec.eu.org>
7
+ */
8
+
9
+#ifndef __MIME_TYP_H
10
+#define __MIME_TYP_H
11
+
12
+static struct mime_entry typ_tab[] = {
13
+	{ "a", 0, "application/octet-stream", 0 },
14
+	{ "aab", 0, "application/x-authorware-bin", 0 },
15
+	{ "aam", 0, "application/x-authorware-map", 0 },
16
+	{ "aas", 0, "application/x-authorware-seg", 0 },
17
+	{ "ai", 0, "application/postscript", 0 },
18
+	{ "aif", 0, "audio/x-aiff", 0 },
19
+	{ "aifc", 0, "audio/x-aiff", 0 },
20
+	{ "aiff", 0, "audio/x-aiff", 0 },
21
+	{ "asc", 0, "text/plain", 0 },
22
+	{ "asf", 0, "video/x-ms-asf", 0 },
23
+	{ "asx", 0, "video/x-ms-asf", 0 },
24
+	{ "au", 0, "audio/basic", 0 },
25
+	{ "avi", 0, "video/x-msvideo", 0 },
26
+	{ "bcpio", 0, "application/x-bcpio", 0 },
27
+	{ "bin", 0, "application/octet-stream", 0 },
28
+	{ "bmp", 0, "image/bmp", 0 },
29
+	{ "cdf", 0, "application/x-netcdf", 0 },
30
+	{ "class", 0, "application/x-java-vm", 0 },
31
+	{ "cpio", 0, "application/x-cpio", 0 },
32
+	{ "cpt", 0, "application/mac-compactpro", 0 },
33
+	{ "crl", 0, "application/x-pkcs7-crl", 0 },
34
+	{ "crt", 0, "application/x-x509-ca-cert", 0 },
35
+	{ "csh", 0, "application/x-csh", 0 },
36
+	{ "css", 0, "text/css", 0 },
37
+	{ "dcr", 0, "application/x-director", 0 },
38
+	{ "dir", 0, "application/x-director", 0 },
39
+	{ "djv", 0, "image/vnd.djvu", 0 },
40
+	{ "djvu", 0, "image/vnd.djvu", 0 },
41
+	{ "dll", 0, "application/octet-stream", 0 },
42
+	{ "dms", 0, "application/octet-stream", 0 },
43
+	{ "doc", 0, "application/msword", 0 },
44
+	{ "dtd", 0, "text/xml", 0 },
45
+	{ "dump", 0, "application/octet-stream", 0 },
46
+	{ "dvi", 0, "application/x-dvi", 0 },
47
+	{ "dxr", 0, "application/x-director", 0 },
48
+	{ "eps", 0, "application/postscript", 0 },
49
+	{ "etx", 0, "text/x-setext", 0 },
50
+	{ "exe", 0, "application/octet-stream", 0 },
51
+	{ "ez", 0, "application/andrew-inset", 0 },
52
+	{ "fgd", 0, "application/x-director", 0 },
53
+	{ "fh", 0, "image/x-freehand", 0 },
54
+	{ "fh4", 0, "image/x-freehand", 0 },
55
+	{ "fh5", 0, "image/x-freehand", 0 },
56
+	{ "fh7", 0, "image/x-freehand", 0 },
57
+	{ "fhc", 0, "image/x-freehand", 0 },
58
+	{ "gif", 0, "image/gif", 0 },
59
+	{ "gtar", 0, "application/x-gtar", 0 },
60
+	{ "hdf", 0, "application/x-hdf", 0 },
61
+	{ "hqx", 0, "application/mac-binhex40", 0 },
62
+	{ "htm", 0, "text/html; charset=%s", 0 },
63
+	{ "html", 0, "text/html; charset=%s", 0 },
64
+	{ "ice", 0, "x-conference/x-cooltalk", 0 },
65
+	{ "ief", 0, "image/ief", 0 },
66
+	{ "iges", 0, "model/iges", 0 },
67
+	{ "igs", 0, "model/iges", 0 },
68
+	{ "iv", 0, "application/x-inventor", 0 },
69
+	{ "jar", 0, "application/x-java-archive", 0 },
70
+	{ "jfif", 0, "image/jpeg", 0 },
71
+	{ "jpe", 0, "image/jpeg", 0 },
72
+	{ "jpeg", 0, "image/jpeg", 0 },
73
+	{ "jpg", 0, "image/jpeg", 0 },
74
+	{ "js", 0, "application/x-javascript", 0 },
75
+	{ "kar", 0, "audio/midi", 0 },
76
+	{ "latex", 0, "application/x-latex", 0 },
77
+	{ "lha", 0, "application/octet-stream", 0 },
78
+	{ "lzh", 0, "application/octet-stream", 0 },
79
+	{ "m3u", 0, "audio/x-mpegurl", 0 },
80
+	{ "man", 0, "application/x-troff-man", 0 },
81
+	{ "mathml", 0, "application/mathml+xml", 0 },
82
+	{ "me", 0, "application/x-troff-me", 0 },
83
+	{ "mesh", 0, "model/mesh", 0 },
84
+	{ "mid", 0, "audio/midi", 0 },
85
+	{ "midi", 0, "audio/midi", 0 },
86
+	{ "mif", 0, "application/vnd.mif", 0 },
87
+	{ "mime", 0, "message/rfc822", 0 },
88
+	{ "mml", 0, "application/mathml+xml", 0 },
89
+	{ "mov", 0, "video/quicktime", 0 },
90
+	{ "movie", 0, "video/x-sgi-movie", 0 },
91
+	{ "mp2", 0, "audio/mpeg", 0 },
92
+	{ "mp3", 0, "audio/mpeg", 0 },
93
+	{ "mp4", 0, "video/mp4", 0 },
94
+	{ "mpe", 0, "video/mpeg", 0 },
95
+	{ "mpeg", 0, "video/mpeg", 0 },
96
+	{ "mpg", 0, "video/mpeg", 0 },
97
+	{ "mpga", 0, "audio/mpeg", 0 },
98
+	{ "ms", 0, "application/x-troff-ms", 0 },
99
+	{ "msh", 0, "model/mesh", 0 },
100
+	{ "mv", 0, "video/x-sgi-movie", 0 },
101
+	{ "mxu", 0, "video/vnd.mpegurl", 0 },
102
+	{ "nc", 0, "application/x-netcdf", 0 },
103
+	{ "o", 0, "application/octet-stream", 0 },
104
+	{ "oda", 0, "application/oda", 0 },
105
+	{ "ogg", 0, "application/x-ogg", 0 },
106
+	{ "pac", 0, "application/x-ns-proxy-autoconfig", 0 },
107
+	{ "pbm", 0, "image/x-portable-bitmap", 0 },
108
+	{ "pdb", 0, "chemical/x-pdb", 0 },
109
+	{ "pdf", 0, "application/pdf", 0 },
110
+	{ "pgm", 0, "image/x-portable-graymap", 0 },
111
+	{ "pgn", 0, "application/x-chess-pgn", 0 },
112
+	{ "png", 0, "image/png", 0 },
113
+	{ "pnm", 0, "image/x-portable-anymap", 0 },
114
+	{ "ppm", 0, "image/x-portable-pixmap", 0 },
115
+	{ "ppt", 0, "application/vnd.ms-powerpoint", 0 },
116
+	{ "ps", 0, "application/postscript", 0 },
117
+	{ "qt", 0, "video/quicktime", 0 },
118
+	{ "ra", 0, "audio/x-realaudio", 0 },
119
+	{ "ram", 0, "audio/x-pn-realaudio", 0 },
120
+	{ "ras", 0, "image/x-cmu-raster", 0 },
121
+	{ "rdf", 0, "application/rdf+xml", 0 },
122
+	{ "rgb", 0, "image/x-rgb", 0 },
123
+	{ "rm", 0, "audio/x-pn-realaudio", 0 },
124
+	{ "roff", 0, "application/x-troff", 0 },
125
+	{ "rpm", 0, "audio/x-pn-realaudio-plugin", 0 },
126
+	{ "rss", 0, "application/rss+xml", 0 },
127
+	{ "rtf", 0, "text/rtf", 0 },
128
+	{ "rtx", 0, "text/richtext", 0 },
129
+	{ "sgm", 0, "text/sgml", 0 },
130
+	{ "sgml", 0, "text/sgml", 0 },
131
+	{ "sh", 0, "application/x-sh", 0 },
132
+	{ "shar", 0, "application/x-shar", 0 },
133
+	{ "silo", 0, "model/mesh", 0 },
134
+	{ "sit", 0, "application/x-stuffit", 0 },
135
+	{ "skd", 0, "application/x-koan", 0 },
136
+	{ "skm", 0, "application/x-koan", 0 },
137
+	{ "skp", 0, "application/x-koan", 0 },
138
+	{ "skt", 0, "application/x-koan", 0 },
139
+	{ "smi", 0, "application/smil", 0 },
140
+	{ "smil", 0, "application/smil", 0 },
141
+	{ "snd", 0, "audio/basic", 0 },
142
+	{ "so", 0, "application/octet-stream", 0 },
143
+	{ "spl", 0, "application/x-futuresplash", 0 },
144
+	{ "src", 0, "application/x-wais-source", 0 },
145
+	{ "stc", 0, "application/vnd.sun.xml.calc.template", 0 },
146
+	{ "std", 0, "application/vnd.sun.xml.draw.template", 0 },
147
+	{ "sti", 0, "application/vnd.sun.xml.impress.template", 0 },
148
+	{ "stw", 0, "application/vnd.sun.xml.writer.template", 0 },
149
+	{ "sv4cpio", 0, "application/x-sv4cpio", 0 },
150
+	{ "sv4crc", 0, "application/x-sv4crc", 0 },
151
+	{ "svg", 0, "image/svg+xml", 0 },
152
+	{ "svgz", 0, "image/svg+xml", 0 },
153
+	{ "swf", 0, "application/x-shockwave-flash", 0 },
154
+	{ "sxc", 0, "application/vnd.sun.xml.calc", 0 },
155
+	{ "sxd", 0, "application/vnd.sun.xml.draw", 0 },
156
+	{ "sxg", 0, "application/vnd.sun.xml.writer.global", 0 },
157
+	{ "sxi", 0, "application/vnd.sun.xml.impress", 0 },
158
+	{ "sxm", 0, "application/vnd.sun.xml.math", 0 },
159
+	{ "sxw", 0, "application/vnd.sun.xml.writer", 0 },
160
+	{ "t", 0, "application/x-troff", 0 },
161
+	{ "tar", 0, "application/x-tar", 0 },
162
+	{ "tcl", 0, "application/x-tcl", 0 },
163
+	{ "tex", 0, "application/x-tex", 0 },
164
+	{ "texi", 0, "application/x-texinfo", 0 },
165
+	{ "texinfo", 0, "application/x-texinfo", 0 },
166
+	{ "tif", 0, "image/tiff", 0 },
167
+	{ "tiff", 0, "image/tiff", 0 },
168
+	{ "tr", 0, "application/x-troff", 0 },
169
+	{ "tsp", 0, "application/dsptype", 0 },
170
+	{ "tsv", 0, "text/tab-separated-values", 0 },
171
+	{ "txt", 0, "text/plain; charset=%s", 0 },
172
+	{ "ustar", 0, "application/x-ustar", 0 },
173
+	{ "vcd", 0, "application/x-cdlink", 0 },
174
+	{ "vrml", 0, "model/vrml", 0 },
175
+	{ "vx", 0, "video/x-rad-screenplay", 0 },
176
+	{ "wav", 0, "audio/x-wav", 0 },
177
+	{ "wax", 0, "audio/x-ms-wax", 0 },
178
+	{ "wbmp", 0, "image/vnd.wap.wbmp", 0 },
179
+	{ "wbxml", 0, "application/vnd.wap.wbxml", 0 },
180
+	{ "wm", 0, "video/x-ms-wm", 0 },
181
+	{ "wma", 0, "audio/x-ms-wma", 0 },
182
+	{ "wmd", 0, "application/x-ms-wmd", 0 },
183
+	{ "wml", 0, "text/vnd.wap.wml", 0 },
184
+	{ "wmlc", 0, "application/vnd.wap.wmlc", 0 },
185
+	{ "wmls", 0, "text/vnd.wap.wmlscript", 0 },
186
+	{ "wmlsc", 0, "application/vnd.wap.wmlscriptc", 0 },
187
+	{ "wmv", 0, "video/x-ms-wmv", 0 },
188
+	{ "wmx", 0, "video/x-ms-wmx", 0 },
189
+	{ "wmz", 0, "application/x-ms-wmz", 0 },
190
+	{ "wrl", 0, "model/vrml", 0 },
191
+	{ "wsrc", 0, "application/x-wais-source", 0 },
192
+	{ "wvx", 0, "video/x-ms-wvx", 0 },
193
+	{ "xbm", 0, "image/x-xbitmap", 0 },
194
+	{ "xht", 0, "application/xhtml+xml", 0 },
195
+	{ "xhtml", 0, "application/xhtml+xml", 0 },
196
+	{ "xls", 0, "application/vnd.ms-excel", 0 },
197
+	{ "xml", 0, "text/xml", 0 },
198
+	{ "xpm", 0, "image/x-xpixmap", 0 },
199
+	{ "xsl", 0, "text/xml", 0 },
200
+	{ "xwd", 0, "image/x-xwindowdump", 0 },
201
+	{ "xyz", 0, "chemical/x-xyz", 0 },
202
+	{ "zip", 0, "application/zip", 0 },
203
+};
204
+
205
+static const int n_typ_tab = sizeof(typ_tab) / sizeof(*typ_tab);
206
+
207
+#endif

Loading…
Zrušit
Uložit