lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | |
| 2 | #ifndef _h_WEBS_INTERNAL |
| 3 | #define _h_WEBS_INTERNAL 1 |
| 4 | |
| 5 | |
| 6 | #include <ctype.h> |
| 7 | #include <stdlib.h> |
| 8 | #include <string.h> |
| 9 | #include <stdarg.h> |
| 10 | |
| 11 | #ifdef NETWARE |
| 12 | #include <fcntl.h> |
| 13 | #include <sys/stat.h> |
| 14 | #include <signal.h> |
| 15 | #include <io.h> |
| 16 | #endif |
| 17 | |
| 18 | #ifdef WIN |
| 19 | #include <fcntl.h> |
| 20 | #include <sys/stat.h> |
| 21 | #include <io.h> |
| 22 | #endif |
| 23 | |
| 24 | #ifdef CE |
| 25 | #ifndef UEMF |
| 26 | #include <io.h> |
| 27 | #endif |
| 28 | #endif |
| 29 | |
| 30 | #ifdef NW |
| 31 | #include <fcntl.h> |
| 32 | #include <sys/stat.h> |
| 33 | #endif |
| 34 | |
| 35 | #ifdef SCOV5 |
| 36 | #include <fcntl.h> |
| 37 | #include <sys/stat.h> |
| 38 | #include <signal.h> |
| 39 | #include <unistd.h> |
| 40 | #endif |
| 41 | |
| 42 | #ifdef LYNX |
| 43 | #include <fcntl.h> |
| 44 | #include <sys/stat.h> |
| 45 | #include <signal.h> |
| 46 | #include <unistd.h> |
| 47 | #endif |
| 48 | |
| 49 | #ifdef UNIX |
| 50 | #include <fcntl.h> |
| 51 | #include <sys/stat.h> |
| 52 | #include <signal.h> |
| 53 | #include <unistd.h> |
| 54 | #endif |
| 55 | |
| 56 | #ifdef QNX4 |
| 57 | #include <fcntl.h> |
| 58 | #include <sys/stat.h> |
| 59 | #include <signal.h> |
| 60 | #include <unistd.h> |
| 61 | #include <unix.h> |
| 62 | #endif |
| 63 | |
| 64 | #ifdef SOLARIS |
| 65 | #include <macros.h> |
| 66 | #include <fcntl.h> |
| 67 | #include <sys/stat.h> |
| 68 | #endif |
| 69 | |
| 70 | #ifdef VXWORKS |
| 71 | #include <vxWorks.h> |
| 72 | #include <fcntl.h> |
| 73 | #include <sys/stat.h> |
| 74 | #endif |
| 75 | |
| 76 | #ifdef UW |
| 77 | #include <fcntl.h> |
| 78 | #include <sys/stat.h> |
| 79 | #endif |
| 80 | |
| 81 | #ifdef UEMF |
| 82 | #include "uemf.h" |
| 83 | #include "ejIntrn.h" |
| 84 | #else |
| 85 | #include "emf/emfInternal.h" |
| 86 | #include "ej/ejIntrn.h" |
| 87 | #endif |
| 88 | |
| 89 | #include "webs.h" |
| 90 | |
| 91 | |
| 92 | #define WEBS_BEGIN 0x1 |
| 93 | #define WEBS_HEADER 0x2 |
| 94 | #define WEBS_POST 0x4 |
| 95 | #define WEBS_POST_CLEN 0x8 |
| 96 | #define WEBS_PROCESSING 0x10 |
| 97 | #define WEBS_KEEP_TIMEOUT 15000 |
| 98 | #define WEBS_TIMEOUT 60000 |
| 99 | |
| 100 | #define PAGE_READ_BUFSIZE 512 |
| 101 | #define MAX_PORT_LEN 10 |
| 102 | #define WEBS_SYM_INIT 64 |
| 103 | |
| 104 | |
| 105 | typedef struct { |
| 106 | int (*handler)(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg, |
| 107 | char_t *url, char_t *path, |
| 108 | char_t *query); |
| 109 | char_t *webDir; |
| 110 | char_t *urlPrefix; |
| 111 | int len; |
| 112 | int arg; |
| 113 | int flags; |
| 114 | } websUrlHandlerType; |
| 115 | |
| 116 | |
| 117 | typedef struct { |
| 118 | long errors; |
| 119 | long redirects; |
| 120 | long net_requests; |
| 121 | long activeNetRequests; |
| 122 | long activeBrowserRequests; |
| 123 | long timeouts; |
| 124 | long access; |
| 125 | long localHits; |
| 126 | long remoteHits; |
| 127 | long formHits; |
| 128 | long cgiHits; |
| 129 | long handlerHits; |
| 130 | } websStatsType; |
| 131 | |
| 132 | extern websStatsType websStats; |
| 133 | |
| 134 | typedef struct { |
| 135 | int code; |
| 136 | char_t *msg; |
| 137 | } websErrorType; |
| 138 | |
| 139 | |
| 140 | typedef struct { |
| 141 | char_t *type; |
| 142 | char_t *ext; |
| 143 | } websMimeType; |
| 144 | |
| 145 | |
| 146 | typedef struct { |
| 147 | unsigned long size; |
| 148 | int isDir; |
| 149 | time_t mtime; |
| 150 | } websStatType; |
| 151 | |
| 152 | |
| 153 | typedef struct { |
| 154 | char_t *path; |
| 155 | unsigned char *page; |
| 156 | int size; |
| 157 | int pos; |
| 158 | } websRomPageIndexType; |
| 159 | |
| 160 | |
| 161 | #ifndef CE |
| 162 | #define SOCKET_RDONLY O_RDONLY |
| 163 | #define SOCKET_BINARY O_BINARY |
| 164 | #else /* CE */ |
| 165 | #define SOCKET_RDONLY 0x1 |
| 166 | #define SOCKET_BINARY 0x2 |
| 167 | #endif /* CE */ |
| 168 | |
| 169 | //#define DOWNLOAD_INTERVAL 1048576 //4194304 |
| 170 | extern int zte_process_cgi_end(webs_t wp); |
| 171 | extern int zte_check_downloading_file(); |
| 172 | extern int websCgiDownLoadHandler(webs_t wp, char_t *urlPrefix, |
| 173 | char_t *webDir, int arg, char_t *url, char_t *path, |
| 174 | char_t *query); |
| 175 | |
| 176 | #define DOWNLOAD_INTERVAL 1048576 //4194304 |
| 177 | #define UPLOAD_INTERVAL 65536 |
| 178 | |
| 179 | #ifdef FEATURE_ZTE_WEB_TCARD |
| 180 | //added by guo shoupeng 10124224 for http share 20111001 start |
| 181 | #define UPLOAD_INTERVAL 65536 |
| 182 | #define DOWNLOAD_INTERVAL 1048576 //4194304 |
| 183 | #define PATH_SD_CARD "/mmc2" |
| 184 | #define PATH_SD_MNT "/mnt" |
| 185 | |
| 186 | extern int sd_card_isExist(); |
| 187 | extern int sd_card_isClose (webs_t wp); |
| 188 | extern int zte_process_cgi(webs_t wp); |
| 189 | extern int zte_process_cgi_end(webs_t wp); |
| 190 | extern int websGetState(webs_t wp); |
| 191 | extern int websGetlen(webs_t wp); |
| 192 | extern char_t * websGetURL(webs_t wp); |
| 193 | extern int zte_efs_write(webs_t wp); |
| 194 | |
| 195 | extern int zte_http_share_process_flagfile_exist(const char *i_filename ); |
| 196 | extern int websCgiDownLoadHandler(webs_t wp, char_t *urlPrefix, |
| 197 | char_t *webDir, int arg, char_t *url, char_t *path, |
| 198 | char_t *query); |
| 199 | |
| 200 | //added by guo shoupeng 10124224 for http share 20111001 end |
| 201 | #endif |
| 202 | extern websRomPageIndexType websRomPageIndex[]; |
| 203 | extern websMimeType websMimeList[]; |
| 204 | extern sym_fd_t websMime; |
| 205 | extern webs_t* webs; |
| 206 | extern int websMax; |
| 207 | extern char_t websHost[64]; |
| 208 | extern char_t websIpaddr[64]; |
| 209 | extern char_t *websHostUrl; |
| 210 | extern char_t *websIpaddrUrl; |
| 211 | extern int websPort; |
| 212 | |
| 213 | extern char_t* websGetDateString(websStatType* sbuf); |
| 214 | |
| 215 | extern int strcmpci(char_t* s1, char_t* s2); |
| 216 | |
| 217 | extern int websAspOpen(); |
| 218 | extern void websAspClose(); |
| 219 | |
| 220 | extern int websAspWrite(int ejid, webs_t wp, int argc, char_t **argv); |
| 221 | |
| 222 | extern void websFormOpen(); |
| 223 | extern void websFormClose(); |
| 224 | |
| 225 | extern int websCgiHandler(webs_t wp, char_t *urlPrefix, char_t *webDir, |
| 226 | int arg, char_t *url, char_t *path, char_t *query); |
| 227 | extern void websCgiCleanup(); |
| 228 | extern int websCheckCgiProc(int handle, int *status); |
| 229 | extern char_t *websGetCgiCommName(); |
| 230 | |
| 231 | extern int websLaunchCgiProc(char_t *cgiPath, char_t **argp, |
| 232 | char_t **envp, char_t *stdIn, char_t *stdOut); |
| 233 | |
| 234 | extern void websDefaultClose(); |
| 235 | |
| 236 | extern void websUrlHandlerClose(); |
| 237 | extern int websUrlHandlerOpen(); |
| 238 | |
| 239 | extern int websDefaultHandler(webs_t wp, char_t *urlPrefix, |
| 240 | char_t *webDir, int arg, char_t *url, char_t *path, |
| 241 | char_t *query); |
| 242 | extern int websFormHandler(webs_t wp, char_t *urlPrefix, char_t *webDir, |
| 243 | int arg, char_t *url, char_t *path, char_t *query); |
| 244 | |
| 245 | extern int websOpen(int sid); |
| 246 | extern void websResponse(webs_t wp, int code, char_t *msg, |
| 247 | char_t *redirect); |
| 248 | extern int websJavaScriptEval(webs_t wp, char_t *script); |
| 249 | extern int websPageReadData(webs_t wp, char *buf, int nBytes); |
| 250 | |
| 251 | extern void websPageSeek(webs_t wp, long offset); |
| 252 | extern int websPageStat(webs_t wp, char_t *lpath, char_t *path, |
| 253 | websStatType *sbuf); |
| 254 | extern int websPageIsDirectory(char_t *lpath); |
| 255 | |
| 256 | extern int websPageOpen(webs_t wp, char_t *lpath, char_t *path, int mode, |
| 257 | int perm); |
| 258 | extern void websPageClose(webs_t wp); |
| 259 | |
| 260 | |
| 261 | extern int websRomPageOpen(webs_t wp, char_t *path, int mode, int perm); |
| 262 | extern void websRomPageClose(int fd); |
| 263 | extern int websRomPageReadData(webs_t wp, char *buf, int len); |
| 264 | extern int websRomPageStat(char_t *path, websStatType *sbuf); |
| 265 | extern long websRomPageSeek(webs_t wp, long offset, int origin); |
| 266 | |
| 267 | extern int websRomOpen(); |
| 268 | extern void websRomClose(); |
| 269 | |
| 270 | extern void websSetRequestSocketHandler(webs_t wp, int mask, |
| 271 | void (*fn)(webs_t wp)); |
| 272 | extern int websSolutionHandler(webs_t wp, char_t *urlPrefix, |
| 273 | char_t *webDir, int arg, char_t *url, char_t *path, |
| 274 | char_t *query); |
| 275 | |
| 276 | extern int websOpenServer(int port, int retries); |
| 277 | extern void websCloseServer(); |
| 278 | |
| 279 | #ifdef CE |
| 280 | extern int writeUniToAsc(int fid, void *buf, unsigned int len); |
| 281 | extern int readAscToUni(int fid, void **buf, unsigned int len); |
| 282 | #endif |
| 283 | |
| 284 | #ifdef EMF |
| 285 | extern int websEmfOpen(); |
| 286 | extern void websSetEmfEnvironment(webs_t wp); |
| 287 | extern void websEmfClose(); |
| 288 | #endif |
| 289 | |
| 290 | |
| 291 | #endif /* _h_WEBS_INTERNAL */ |
| 292 | |