Mercurial > ecos-v3_0-branch
annotate packages/net/athttpd/current/src/handler.c @ 2863:7d8c61e6225c default tip
* Added execute permissions to files missed in conversion from CVS
| author | alexs |
|---|---|
| date | Thu, 26 Mar 2009 20:39:18 +0000 |
| parents | 74dbf4c3f2e1 |
| children |
| rev | line source |
|---|---|
| 2250 | 1 /* ================================================================= |
| 2 * | |
| 3 * handler.c | |
| 4 * | |
| 5 * C callbacks as well as directory listings. | |
| 6 * | |
| 7 * ================================================================= | |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
8 * ####ECOSGPLCOPYRIGHTBEGIN#### |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
9 * ------------------------------------------- |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
10 * This file is part of eCos, the Embedded Configurable Operating System. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
11 * Copyright (C) 2005 Free Software Foundation, Inc. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
12 * |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
13 * eCos is free software; you can redistribute it and/or modify it under |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
14 * the terms of the GNU General Public License as published by the Free |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
15 * Software Foundation; either version 2 or (at your option) any later |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
16 * version. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
17 * |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
18 * eCos is distributed in the hope that it will be useful, but WITHOUT |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
19 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
20 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
21 * for more details. |
| 2250 | 22 * |
|
2729
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
23 * You should have received a copy of the GNU General Public License |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
24 * along with eCos; if not, write to the Free Software Foundation, Inc., |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
26 * |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
27 * As a special exception, if other files instantiate templates or use |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
28 * macros or inline functions from this file, or you compile this file |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
29 * and link it with other works to produce a work based on this file, |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
30 * this file does not by itself cause the resulting work to be covered by |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
31 * the GNU General Public License. However the source code for this file |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
32 * must still be made available in accordance with section (3) of the GNU |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
33 * General Public License v2. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
34 * |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
35 * This exception does not invalidate any other reasons why a work based |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
36 * on this file might be covered by the GNU General Public License. |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
37 * ------------------------------------------- |
|
74dbf4c3f2e1
Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents:
2485
diff
changeset
|
38 * ####ECOSGPLCOPYRIGHTEND#### |
| 2250 | 39 * ================================================================= |
| 40 * #####DESCRIPTIONBEGIN#### | |
| 41 * | |
| 42 * Author(s): Anthony Tonizzo (atonizzo@gmail.com) | |
| 43 * Contributors: | |
| 44 * Date: 2006-06-12 | |
| 45 * Purpose: | |
| 46 * Description: | |
| 47 * | |
| 48 * ####DESCRIPTIONEND#### | |
| 49 * | |
| 50 * ================================================================= | |
| 51 */ | |
| 52 #include <pkgconf/hal.h> | |
| 53 #include <pkgconf/kernel.h> | |
| 54 #include <cyg/hal/hal_tables.h> | |
| 55 #include <cyg/fileio/fileio.h> | |
| 56 #include <dirent.h> | |
| 57 #include <network.h> | |
| 58 | |
| 59 #include <string.h> | |
| 60 #include <stdio.h> // sprintf(). | |
| 61 | |
| 62 #include <cyg/athttpd/http.h> | |
| 63 #include <cyg/athttpd/socket.h> | |
| 64 #include <cyg/athttpd/handler.h> | |
| 65 #include <cyg/athttpd/forms.h> | |
| 66 | |
| 67 #ifdef CYGOPT_NET_ATHTTPD_USE_DIRLIST | |
|
2485
0e9d1d1df4a0
* src/jim-aio.c (JimAioHandlerCommand): GCC 4.3.1 pointed out a
asl
parents:
2326
diff
changeset
|
68 static char folder_gif[] = { |
| 2250 | 69 0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x12, 0x00, |
| 70 0x12, 0x00, 0xd5, 0x00, 0x00, 0xfb, 0xfb, 0xfb, | |
| 71 0xef, 0xef, 0xef, 0xdb, 0xb7, 0x52, 0xcc, 0x99, | |
| 72 0x34, 0xe4, 0xe4, 0xe4, 0xc1, 0xc1, 0xc1, 0xa3, | |
| 73 0x71, 0x0b, 0xc2, 0x8f, 0x2a, 0xb7, 0xb7, 0xb7, | |
| 74 0x9e, 0x6c, 0x06, 0xba, 0x87, 0x22, 0x9c, 0x6a, | |
| 75 0x04, 0xc9, 0x96, 0x31, 0xbd, 0x8a, 0x25, 0xb3, | |
| 76 0x81, 0x1b, 0x99, 0x67, 0x01, 0xdb, 0xb7, 0x71, | |
| 77 0xb5, 0x82, 0x1d, 0xa0, 0x6e, 0x08, 0xcb, 0x98, | |
| 78 0x33, 0xff, 0xff, 0xba, 0xb0, 0x7e, 0x18, 0xc5, | |
| 79 0x92, 0x2d, 0xa7, 0x75, 0x0f, 0xc7, 0x94, 0x2f, | |
| 80 0xa6, 0xa6, 0xa6, 0xa5, 0x73, 0x0d, 0xb7, 0x84, | |
| 81 0x1f, 0xab, 0x79, 0x13, 0xc8, 0x95, 0x30, 0xc0, | |
| 82 0x8d, 0x28, 0xc6, 0xc6, 0xc6, 0xae, 0x7c, 0x16, | |
| 83 0x9a, 0x68, 0x02, 0xa8, 0x76, 0x10, 0xac, 0x7a, | |
| 84 0x14, 0xff, 0xd4, 0x6f, 0xff, 0xf8, 0x93, 0xeb, | |
| 85 0xeb, 0xeb, 0xff, 0xff, 0x9c, 0xff, 0xdb, 0x75, | |
| 86 0xff, 0xe4, 0x7f, 0xff, 0xef, 0x89, 0xb6, 0xb6, | |
| 87 0xb6, 0xff, 0xff, 0xff, 0xff, 0xff, 0x99, 0x00, | |
| 88 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 89 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 90 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 91 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 92 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 93 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 94 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0xf9, 0x04, | |
| 95 0x01, 0x00, 0x00, 0x2e, 0x00, 0x2c, 0x00, 0x00, | |
| 96 0x00, 0x00, 0x12, 0x00, 0x12, 0x00, 0x00, 0x06, | |
| 97 0x91, 0x40, 0x97, 0x70, 0x48, 0x2c, 0x1a, 0x8f, | |
| 98 0xc8, 0xa4, 0xd2, 0x35, 0x18, 0x4c, 0x18, 0x9d, | |
| 99 0x00, 0x40, 0x39, 0x60, 0x59, 0x29, 0x94, 0x03, | |
| 100 0x61, 0x7a, 0x1c, 0x40, 0x04, 0x60, 0x30, 0xa4, | |
| 101 0xa1, 0xd8, 0x44, 0x1c, 0x95, 0xc0, 0x70, 0x62, | |
| 102 0x6d, 0xbb, 0xdb, 0xa3, 0xcf, 0x90, 0xd1, 0x3a, | |
| 103 0xd9, 0xef, 0xf8, 0xd6, 0x05, 0x31, 0xc4, 0xb4, | |
| 104 0xfe, 0x80, 0x81, 0x7f, 0x06, 0x2b, 0x43, 0x16, | |
| 105 0x2d, 0x25, 0x89, 0x8a, 0x8b, 0x2d, 0x12, 0x85, | |
| 106 0x42, 0x07, 0x2d, 0x2a, 0x93, 0x94, 0x95, 0x2d, | |
| 107 0x09, 0x8f, 0x2e, 0x1e, 0x2d, 0x29, 0x9d, 0x9e, | |
| 108 0x9f, 0x2d, 0x0b, 0x99, 0x0d, 0x2d, 0x28, 0xa6, | |
| 109 0xa7, 0xa8, 0x2d, 0x21, 0x99, 0x0a, 0x2d, 0x24, | |
| 110 0xaf, 0xb0, 0xb1, 0x2d, 0x0f, 0x7c, 0x42, 0x01, | |
| 111 0x67, 0x15, 0x20, 0x1c, 0x22, 0x1a, 0x06, 0x12, | |
| 112 0x09, 0x0b, 0x0f, 0x19, 0x05, 0x43, 0x00, 0x04, | |
| 113 0x05, 0x2b, 0xc9, 0xca, 0xcb, 0x05, 0x04, 0x44, | |
| 114 0x00, 0x01, 0x26, 0xd2, 0xd3, 0xd4, 0x52, 0x4b, | |
| 115 0x4a, 0x41, 0x00, 0x3b | |
| 116 }; | |
| 117 | |
|
2485
0e9d1d1df4a0
* src/jim-aio.c (JimAioHandlerCommand): GCC 4.3.1 pointed out a
asl
parents:
2326
diff
changeset
|
118 static char doc_gif[] = { |
| 2250 | 119 0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x12, 0x00, |
| 120 0x12, 0x00, 0xe6, 0x00, 0x00, 0xfb, 0xfb, 0xfb, | |
| 121 0xef, 0xef, 0xef, 0xf8, 0xfb, 0xff, 0xed, 0xf6, | |
| 122 0xff, 0xc1, 0xc1, 0xc1, 0xe4, 0xe4, 0xe4, 0xfd, | |
| 123 0xfd, 0xfd, 0xd8, 0xeb, 0xff, 0xc0, 0xdf, 0xff, | |
| 124 0xfe, 0xff, 0xff, 0xf3, 0xf9, 0xff, 0xc3, 0xe1, | |
| 125 0xff, 0xf4, 0xf4, 0xf5, 0xf9, 0xf9, 0xf9, 0x81, | |
| 126 0x95, 0xc3, 0x6b, 0x74, 0xa5, 0xce, 0xe7, 0xff, | |
| 127 0x5e, 0x61, 0x90, 0x55, 0xa7, 0xed, 0x93, 0xaa, | |
| 128 0xd2, 0x7a, 0x83, 0xb0, 0xc0, 0xc0, 0xff, 0xd9, | |
| 129 0xe1, 0xed, 0x84, 0x9b, 0xca, 0x8a, 0xa8, 0xd9, | |
| 130 0xe4, 0xf1, 0xff, 0x91, 0xb8, 0xea, 0x92, 0xbc, | |
| 131 0xef, 0x73, 0x7e, 0xb0, 0xf5, 0xfa, 0xff, 0xf7, | |
| 132 0xf7, 0xf7, 0x90, 0xa3, 0xcb, 0xcd, 0xe6, 0xff, | |
| 133 0xba, 0xdd, 0xff, 0xd8, 0xe5, 0xf6, 0x6d, 0x77, | |
| 134 0xa8, 0x65, 0x6a, 0x9a, 0x87, 0xa1, 0xd2, 0x7f, | |
| 135 0x8e, 0xbc, 0x8f, 0xb3, 0xe5, 0x8c, 0xae, 0xdf, | |
| 136 0xce, 0xd3, 0xff, 0xf6, 0xfa, 0xff, 0x67, 0x6d, | |
| 137 0x9e, 0xfc, 0xfd, 0xff, 0x7d, 0x89, 0xb6, 0x94, | |
| 138 0xbf, 0xf2, 0xc6, 0xc6, 0xc6, 0xfe, 0xfe, 0xfe, | |
| 139 0xdb, 0xe7, 0xf7, 0x69, 0x70, 0xa2, 0x6f, 0x7a, | |
| 140 0xac, 0x72, 0x7c, 0xae, 0x74, 0x80, 0xb2, 0x87, | |
| 141 0xa9, 0xdc, 0xd1, 0xe9, 0xff, 0xc9, 0xe4, 0xff, | |
| 142 0xb7, 0xb7, 0xb7, 0xeb, 0xeb, 0xeb, 0xb6, 0xb6, | |
| 143 0xb6, 0xe9, 0xf5, 0xff, 0x75, 0x78, 0xa3, 0xe1, | |
| 144 0xf0, 0xff, 0xdb, 0xed, 0xff, 0xff, 0xff, 0xff, | |
| 145 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 146 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 147 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 148 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 149 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 150 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 151 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 152 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 153 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 154 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 155 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 156 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 157 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 158 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 159 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 160 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 161 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 162 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 163 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 164 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 165 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 166 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 167 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 168 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0xf9, 0x04, | |
| 169 0x01, 0x00, 0x00, 0x41, 0x00, 0x2c, 0x00, 0x00, | |
| 170 0x00, 0x00, 0x12, 0x00, 0x12, 0x00, 0x00, 0x07, | |
| 171 0xa3, 0x80, 0x41, 0x82, 0x83, 0x84, 0x85, 0x86, | |
| 172 0x87, 0x88, 0x2e, 0x36, 0x8b, 0x8c, 0x36, 0x35, | |
| 173 0x01, 0x00, 0x87, 0x1b, 0x40, 0x06, 0x00, 0x0d, | |
| 174 0x1e, 0x0c, 0x16, 0x35, 0x13, 0x90, 0x86, 0x1a, | |
| 175 0x30, 0x40, 0xa1, 0x09, 0x02, 0x31, 0x35, 0x12, | |
| 176 0x1f, 0x01, 0x86, 0x27, 0x06, 0xa2, 0x02, 0x1d, | |
| 177 0x22, 0x35, 0xb1, 0x2f, 0x86, 0x28, 0xa1, 0x02, | |
| 178 0x02, 0x03, 0x3c, 0x3c, 0x29, 0x15, 0x1c, 0x39, | |
| 179 0x86, 0x18, 0x2c, 0xb8, 0xb9, 0x3c, 0x3f, 0x3f, | |
| 180 0x07, 0x34, 0xbf, 0x85, 0x25, 0x2a, 0x0a, 0xb9, | |
| 181 0x3e, 0x3e, 0xc7, 0x37, 0x33, 0xca, 0x84, 0x17, | |
| 182 0xce, 0x3c, 0xd0, 0xc6, 0x37, 0x20, 0x23, 0xd5, | |
| 183 0x83, 0x0e, 0xba, 0xda, 0x3f, 0x37, 0x38, 0x38, | |
| 184 0x0f, 0xdf, 0x82, 0x26, 0xd9, 0xd1, 0xe4, 0xe6, | |
| 185 0x0b, 0x32, 0xe9, 0x41, 0x2d, 0x19, 0xed, 0x37, | |
| 186 0xe5, 0x0b, 0x08, 0x2b, 0xf2, 0x14, 0xf6, 0x10, | |
| 187 0xe6, 0x08, 0x42, 0x90, 0x90, 0xd7, 0xa3, 0xa0, | |
| 188 0xc1, 0x83, 0x11, 0x08, 0x18, 0x2a, 0x40, 0x60, | |
| 189 0x87, 0xc3, 0x87, 0x0e, 0x09, 0x14, 0x30, 0x04, | |
| 190 0x20, 0x80, 0x8e, 0x8b, 0x18, 0x2f, 0x76, 0x42, | |
| 191 0xc4, 0xd1, 0x50, 0x20, 0x00, 0x3b | |
| 192 }; | |
| 193 | |
|
2485
0e9d1d1df4a0
* src/jim-aio.c (JimAioHandlerCommand): GCC 4.3.1 pointed out a
asl
parents:
2326
diff
changeset
|
194 static char back_gif[] = { |
| 2250 | 195 0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x0a, 0x00, |
| 196 0x09, 0x00, 0xf7, 0x00, 0x00, 0xf8, 0xfa, 0xfb, | |
| 197 0x3a, 0x6b, 0x9d, 0xe5, 0xeb, 0xf2, 0x87, 0xa5, | |
| 198 0xc3, 0x9d, 0xb5, 0xce, 0xd0, 0xdc, 0xe7, 0xa9, | |
| 199 0xbe, 0xd4, 0x74, 0x97, 0xb9, 0x65, 0x8c, 0xb2, | |
| 200 0xd9, 0xe2, 0xec, 0xf1, 0xf4, 0xf8, 0xe7, 0xed, | |
| 201 0xf3, 0x55, 0x7f, 0xaa, 0xc8, 0xd6, 0xe3, 0xcc, | |
| 202 0xcc, 0xcc, 0x91, 0xac, 0xc8, 0x3f, 0x6f, 0x9f, | |
| 203 0xfd, 0xfd, 0xfe, 0x4d, 0x7a, 0xa6, 0xac, 0xc1, | |
| 204 0xd5, 0x4b, 0x78, 0xa5, 0x33, 0x66, 0x99, 0xff, | |
| 205 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 206 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 207 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 208 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 209 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 210 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 211 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 212 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 213 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 214 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 215 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 216 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 217 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 218 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 219 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 220 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 221 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 222 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 223 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 224 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 225 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 226 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 227 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 228 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 229 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 230 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 231 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 232 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 233 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 234 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 235 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 236 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 237 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 238 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 239 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 240 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 241 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 242 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 243 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 244 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 245 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 246 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 247 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 248 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 249 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 250 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 251 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 252 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 253 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 254 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 255 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 256 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 257 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 258 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 259 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 260 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 261 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 262 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 263 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 264 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 265 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 266 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 267 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 268 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 269 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 270 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 271 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 272 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 273 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 274 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 275 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 276 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 277 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 278 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 279 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 280 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 281 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 282 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 283 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 284 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 285 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 286 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 287 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 288 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 289 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 290 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 291 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
| 292 0x00, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, | |
| 293 0x00, 0x00, 0x0a, 0x00, 0x09, 0x00, 0x00, 0x08, | |
| 294 0x3b, 0x00, 0x2d, 0x08, 0x1c, 0x68, 0x61, 0xc1, | |
| 295 0x83, 0x02, 0x04, 0x2d, 0x00, 0x20, 0x10, 0x80, | |
| 296 0xc2, 0x04, 0x82, 0x13, 0x28, 0x54, 0xa8, 0xe0, | |
| 297 0x50, 0x60, 0x02, 0x04, 0x13, 0x27, 0x56, 0x04, | |
| 298 0x70, 0x20, 0xa3, 0xc6, 0x87, 0x02, 0x1b, 0x30, | |
| 299 0xc8, 0x58, 0x71, 0x60, 0x04, 0x03, 0x10, 0x28, | |
| 300 0x82, 0x24, 0xa8, 0x60, 0x80, 0x84, 0x95, 0x09, | |
| 301 0x05, 0x38, 0x08, 0x08, 0x00, 0x3b | |
| 302 }; | |
| 303 #endif | |
| 304 | |
| 305 // ============================================================================= | |
| 306 // Internal resources | |
| 307 // ============================================================================= | |
| 308 CYG_HAL_TABLE_BEGIN(cyg_httpd_ires_table, httpd_ires_table); | |
| 309 CYG_HAL_TABLE_END(cyg_httpd_ires_table_end, httpd_ires_table); | |
| 310 __externC cyg_httpd_ires_table_entry cyg_httpd_ires_table[]; | |
| 311 __externC cyg_httpd_ires_table_entry cyg_httpd_ires_table_end[]; | |
| 312 | |
| 313 #ifdef CYGOPT_NET_ATHTTPD_USE_DIRLIST | |
| 314 // These threes internal resources are used for the directory listing. | |
| 315 CYG_HTTPD_IRES_TABLE_ENTRY(cyg_httpd_ires_folder, \ | |
| 316 "/___folder__gif.gif", \ | |
| 317 folder_gif, \ | |
| 318 sizeof(folder_gif)); | |
| 319 CYG_HTTPD_IRES_TABLE_ENTRY(cyg_httpd_ires_doc, \ | |
| 320 "/___doc__gif.gif", \ | |
| 321 doc_gif, \ | |
| 322 sizeof(doc_gif)); | |
| 323 CYG_HTTPD_IRES_TABLE_ENTRY(cyg_httpd_ires_back, \ | |
| 324 "/___back__gif.gif", \ | |
| 325 back_gif, \ | |
| 326 sizeof(back_gif)); | |
| 327 #endif | |
| 328 | |
| 329 cyg_httpd_ires_table_entry * | |
| 330 cyg_httpd_find_ires(char *path_name) | |
| 331 { | |
| 332 cyg_httpd_ires_table_entry *entry = cyg_httpd_ires_table; | |
| 333 | |
| 334 while (entry != cyg_httpd_ires_table_end) | |
| 335 { | |
| 336 if (!strcasecmp((char*)path_name, entry->f_pname)) | |
| 337 return entry; | |
| 338 entry++; | |
| 339 } | |
| 340 | |
| 341 return (cyg_httpd_ires_table_entry*)NULL; | |
| 342 } | |
| 343 | |
| 344 void | |
| 345 cyg_httpd_send_ires(cyg_httpd_ires_table_entry *entry) | |
| 346 { | |
| 347 httpstate.status_code = CYG_HTTPD_STATUS_OK; | |
| 348 | |
| 349 // Here we'll look for extension to the file. Consider the case where | |
| 350 // there might be more than one dot in the file name. We'll look for | |
| 351 // the last dot, then we'll check the extension. | |
| 352 char *extension = rindex(entry->f_pname, '.'); | |
| 353 if (extension == NULL) | |
| 354 // No extension in the file name. | |
| 355 httpstate.mime_type = 0; | |
| 356 else | |
| 357 httpstate.mime_type = cyg_httpd_find_mime_string(++extension); | |
| 358 | |
| 359 httpstate.payload_len = entry->f_size; | |
| 360 cyg_int32 header_length = cyg_httpd_format_header(); | |
| 361 | |
| 362 // As always, the header is always sent out. | |
| 363 send(httpstate.sockets[httpstate.client_index].descriptor, | |
| 364 httpstate.outbuffer, | |
| 365 header_length, | |
| 366 0); | |
| 2326 | 367 if (httpstate.mode & CYG_HTTPD_MODE_SEND_HEADER_ONLY) |
| 2250 | 368 return; |
| 369 cyg_httpd_write(entry->f_ptr, entry->f_size); | |
| 370 } | |
| 371 | |
| 372 // ============================================================================= | |
| 373 // C callbacks | |
| 374 // ============================================================================= | |
| 375 CYG_HAL_TABLE_BEGIN(cyg_httpd_handler_table, httpd_handler_table); | |
| 376 CYG_HAL_TABLE_END(cyg_httpd_handler_table_end, httpd_handler_table); | |
| 377 | |
| 378 __externC cyg_httpd_handler_table_entry cyg_httpd_handler_table[]; | |
| 379 __externC cyg_httpd_handler_table_entry cyg_httpd_handler_table_end[]; | |
| 380 | |
| 381 handler | |
| 382 cyg_httpd_find_handler(void) | |
| 383 { | |
| 384 cyg_httpd_handler_table_entry *entry = cyg_httpd_handler_table; | |
| 385 while (entry != cyg_httpd_handler_table_end) | |
| 386 { | |
| 2326 | 387 if (strcmp((const char*)httpstate.url, entry->path) == 0) |
| 2250 | 388 return entry->h; |
| 389 entry++; | |
| 390 } | |
| 391 | |
| 392 return (handler)NULL; | |
| 393 } | |
| 394 | |
| 395 // ============================================================================= | |
| 396 // Directory listing | |
| 397 // ============================================================================= | |
| 398 #ifdef CYGOPT_NET_ATHTTPD_USE_DIRLIST | |
| 399 void | |
| 400 cyg_httpd_print_directory_entry(char *path_name, | |
| 401 struct stat *s, | |
| 402 struct dirent *de) | |
| 403 { | |
| 404 char fname[CYG_HTTPD_MAXPATH]; | |
| 405 char time_str[32]; | |
| 406 time_t last_mod = s->st_mtime; | |
| 407 | |
| 408 struct tm *mod_time = gmtime(&last_mod); | |
| 409 sprintf(time_str, | |
| 410 "%02d-%s-%04d %02d:%02d", | |
| 411 mod_time->tm_mday, | |
| 412 month_of_year[mod_time->tm_mon], | |
| 413 mod_time->tm_year + 1900, | |
| 414 mod_time->tm_hour, | |
| 415 mod_time->tm_min); | |
| 416 | |
| 417 if (S_ISREG(s->st_mode)) | |
| 418 { | |
| 419 strcpy(fname, path_name); | |
| 420 if (fname[strlen(fname)-1] != '/') | |
| 421 strcat(fname, "/"); | |
| 422 strcat(fname, de->d_name); | |
| 423 cyg_httpd_cleanup_filename(fname); | |
| 424 sprintf(httpstate.outbuffer, | |
| 425 "<tr><td><img src='/___doc__gif.gif'></td>" | |
| 426 "<td><a href='%s'>%s</a></td>" | |
| 427 "<td>           </td>" | |
| 428 "<td>%s </td>" | |
| 429 "<td style='color:black'>%d</td></tr>", | |
| 430 fname, | |
| 431 de->d_name, | |
| 432 time_str, | |
| 433 (int)s->st_size); | |
| 434 } | |
| 435 else | |
| 436 { | |
| 437 strcpy(fname, "/"); | |
| 438 strcat(fname, path_name); | |
| 439 if (fname[strlen(fname)-1] != '/') | |
| 440 strcat(fname, "/"); | |
| 441 strcat(fname, de->d_name); | |
| 442 cyg_httpd_cleanup_filename(fname); | |
| 443 sprintf(httpstate.outbuffer, | |
| 444 "<tr><td><img src='/___folder__gif.gif'></td>" | |
| 445 "<td><a href='%s/'>%s</a></td>" | |
| 446 "<td>           </td>" | |
| 447 "<td>%s </td>" | |
| 448 "<td style='color:black'></td></tr>", | |
| 449 fname, | |
| 450 de->d_name, | |
| 451 time_str); | |
| 452 } | |
| 453 cyg_httpd_write_chunked(httpstate.outbuffer, strlen(httpstate.outbuffer)); | |
| 454 } | |
| 455 | |
| 456 void | |
| 457 cyg_httpd_send_directory_listing(char *path_name) | |
| 458 { | |
| 459 struct dirent next_file; | |
| 460 struct dirent last_printed; | |
| 461 struct stat s; | |
| 462 char fname[CYG_HTTPD_MAXPATH]; | |
| 463 | |
| 464 cyg_httpd_start_chunked("html"); | |
| 465 sprintf(httpstate.outbuffer, | |
| 466 "<html><body><h3>Index of %s</h3><p></p>" | |
| 467 "<table style='font-family:courier'>", | |
| 468 path_name); | |
| 469 cyg_httpd_write_chunked(httpstate.outbuffer, strlen(httpstate.outbuffer)); | |
| 470 | |
| 471 sprintf(httpstate.outbuffer, | |
| 472 "<tr><td></td><td align='center' style='border-style:none none" | |
| 473 " solid none;border-width:thin'>Name</td>" | |
| 474 "<td style='border-style:none none solid none; border-width:thin'>" | |
| 475 "           </td>" | |
| 476 "<td align='center' style='border-style:none none solid none;" | |
| 477 " border-width:thin'>Last Modified</td>" | |
| 478 "<td style='border-style:none none solid none; border-width:thin'>" | |
| 479 "Size</td></tr>"); | |
| 480 cyg_httpd_write_chunked(httpstate.outbuffer, strlen(httpstate.outbuffer)); | |
| 481 | |
| 482 // Provide a pointer to the parent directory. | |
| 483 strcpy(fname, path_name); | |
| 484 if (fname[strlen(fname)-1] == '/') | |
| 485 fname[strlen(fname)-1] = '\0'; | |
| 486 char *slash = rindex(fname, '/'); | |
| 487 slash[1] = '\0'; | |
| 488 sprintf(httpstate.outbuffer, | |
| 489 "<tr><td><img src='/___back__gif.gif'></td></td>" | |
| 490 "<td><a href='%s' style='color:red'>Parent " | |
| 491 "Directory</a></td>" | |
| 492 "<td>           </td>" | |
| 493 "<td>           </td>" | |
| 494 "<td style='color:black'>-</td></tr>", | |
| 495 fname); | |
| 496 cyg_httpd_write_chunked(httpstate.outbuffer, strlen(httpstate.outbuffer)); | |
| 497 | |
| 498 strcpy(fname, CYGDAT_NET_ATHTTPD_SERVEROPT_ROOTDIR); | |
| 499 if (fname[strlen(fname)-1] != '/') | |
| 500 strcat(fname, "/"); | |
| 501 strcat(fname, path_name); | |
| 502 if (fname[strlen(fname)-1] != '/') | |
| 503 strcat(fname, "/"); | |
| 504 cyg_httpd_cleanup_filename(fname); | |
| 505 int abs_path_len = strlen(fname); | |
| 506 | |
| 507 DIR* pdir = opendir(fname); | |
| 508 struct dirent *dirent = readdir(pdir); | |
| 509 | |
| 510 // First time for the directories. | |
| 511 rewinddir(pdir); | |
| 512 memset((void*)&last_printed, 0, sizeof(struct dirent)); | |
| 513 dirent = readdir(pdir); | |
| 514 int new_entry = 1; | |
| 515 while (1) | |
| 516 { | |
| 517 memset((void*)&next_file, 0, sizeof(struct dirent)); | |
| 518 new_entry = 0; | |
| 519 while(dirent) | |
| 520 { | |
| 521 if (strcmp(dirent->d_name, "..") && | |
| 522 strcmp(dirent->d_name, ".")) | |
| 523 if ((next_file.d_name[0] == '\0') || | |
| 524 (strcmp(next_file.d_name, dirent->d_name) > 0)) | |
| 525 if ((last_printed.d_name[0] == '\0') || | |
| 526 (strcmp(last_printed.d_name, dirent->d_name) < 0)) | |
| 527 { | |
| 528 fname[abs_path_len] = '\0'; | |
| 529 strcat(fname, dirent->d_name); | |
| 530 struct stat sp; | |
| 531 stat(fname, &sp); | |
| 532 if (S_ISDIR(sp.st_mode)) | |
| 533 { | |
| 534 memcpy(&next_file, dirent, sizeof(struct dirent)); | |
| 535 memcpy(&s, &sp, sizeof(struct stat)); | |
| 536 new_entry = 1; | |
| 537 } | |
| 538 } | |
| 539 dirent = readdir(pdir); | |
| 540 } | |
| 541 if (new_entry == 0) | |
| 542 break; | |
| 543 cyg_httpd_print_directory_entry(path_name, &s, &next_file); | |
| 544 memcpy(&last_printed, &next_file, sizeof(struct dirent)); | |
| 545 rewinddir(pdir); | |
| 546 dirent = readdir(pdir); | |
| 547 } | |
| 548 | |
| 549 // A second time for the files. | |
| 550 rewinddir(pdir); | |
| 551 memset((void*)&last_printed, 0, sizeof(struct dirent)); | |
| 552 dirent = readdir(pdir); | |
| 553 new_entry = 1; | |
| 554 while (1) | |
| 555 { | |
| 556 memset((void*)&next_file, 0, sizeof(struct dirent)); | |
| 557 new_entry = 0; | |
| 558 while(dirent) | |
| 559 { | |
| 560 if (strcmp(dirent->d_name, "..") && | |
| 561 strcmp(dirent->d_name, ".")) | |
| 562 if ((next_file.d_name[0] == '\0') || | |
| 563 (strcmp(next_file.d_name, dirent->d_name) > 0)) | |
| 564 if ((last_printed.d_name[0] == '\0') || | |
| 565 (strcmp(last_printed.d_name, dirent->d_name) < 0)) | |
| 566 { | |
| 567 fname[abs_path_len] = '\0'; | |
| 568 strcat(fname, dirent->d_name); | |
| 569 struct stat sp; | |
| 570 stat(fname, &sp); | |
| 571 if (S_ISREG(sp.st_mode)) | |
| 572 { | |
| 573 memcpy(&next_file, dirent, sizeof(struct dirent)); | |
| 574 memcpy(&s, &sp, sizeof(struct stat)); | |
| 575 new_entry = 1; | |
| 576 } | |
| 577 } | |
| 578 dirent = readdir(pdir); | |
| 579 } | |
| 580 if (new_entry == 0) | |
| 581 break; | |
| 582 cyg_httpd_print_directory_entry(path_name, &s, &next_file); | |
| 583 memcpy(&last_printed, &next_file, sizeof(struct dirent)); | |
| 584 rewinddir(pdir); | |
| 585 dirent = readdir(pdir); | |
| 586 } | |
| 587 | |
| 588 strcpy(httpstate.outbuffer, "</table><html><body>"); | |
| 589 cyg_httpd_write_chunked(httpstate.outbuffer, strlen(httpstate.outbuffer)); | |
| 590 cyg_httpd_end_chunked(); | |
| 591 closedir(pdir); | |
| 592 } | |
| 593 #endif |
