Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
kehengzhong authored Sep 4, 2021
1 parent abeabf9 commit e9bdc2f
Show file tree
Hide file tree
Showing 16 changed files with 65 additions and 65 deletions.
20 changes: 10 additions & 10 deletions src/http_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ static char * cache_info_file (char * cafile, int cafnlen)
p = kalloc(len);

if (pathlen <= 0) {
#ifdef _WIN32
#if defined(_WIN32) || defined(_WIN64)
strcpy(p, ".\\");
#else
strcpy(p, "./");
Expand All @@ -162,7 +162,7 @@ static char * cache_info_file (char * cafile, int cafnlen)
str_secpy(p, len-1, cafile, pathlen);
}

#ifdef _WIN32
#if defined(_WIN32) || defined(_WIN64)
str_secpy(p + strlen(p), len - 1 - strlen(p), ".cacheinfo\\", 11);
#else
str_secpy(p + strlen(p), len - 1 - strlen(p), ".cacheinfo/", 11);
Expand Down Expand Up @@ -226,11 +226,11 @@ int cache_info_read (void * vcacinfo)

memcpy(cacinfo->etag, buf+iter, 32); iter += 32;

if (cacinfo->body_length > 0)
frag_pack_set_length(cacinfo->frag, cacinfo->body_length);

frag_pack_read(cacinfo->frag, cacinfo->hinfo, 96);

if (cacinfo->body_length > 0 && frag_pack_length(cacinfo->frag) <= 0)
frag_pack_set_length(cacinfo->frag, cacinfo->body_length);

return 0;
}

Expand Down Expand Up @@ -610,7 +610,7 @@ int http_request_cache_init (void * vmsg)

if (msg->req_file_handle) return 0;

#ifdef _WIN32
#if defined(_WIN32) || defined(_WIN64)
snprintf(path, sizeof(path) - 1, "%s\\ucache", msg->GetRootPath(msg));
#else
snprintf(path, sizeof(path) - 1, "%s/ucache", msg->GetRootPath(msg));
Expand All @@ -619,7 +619,7 @@ int http_request_cache_init (void * vmsg)
hash = generic_hash(msg->docuri->path, msg->docuri->pathlen, 0);
hash = hash % 307;

#ifdef _WIN32
#if defined(_WIN32) || defined(_WIN64)
sprintf(path+strlen(path), "\\%lu\\", hash);
#else
sprintf(path+strlen(path), "/%lu/", hash);
Expand Down Expand Up @@ -701,7 +701,7 @@ int http_response_cache_init (void * vmsg)
if (buf[ret] == ':') { //ignore the colon in drive of path D:\prj\src\disk.txt
if (ret > 1) buf[ret] = '_';
} else if (buf[ret] == '?') buf[ret] = '_';
#ifdef _WIN32
#if defined(_WIN32) || defined(_WIN64)
else if (buf[ret] == '/') buf[ret] = '\\';
#endif
}
Expand Down Expand Up @@ -854,7 +854,7 @@ int http_proxy_cache_open (void * vmsg)
if (buf[ret] == ':') { //ignore the colon in drive of path D:\prj\src\disk.txt
if (ret > 1) buf[ret] = '_';
} else if (buf[ret] == '?') buf[ret] = '_';
#ifdef _WIN32
#if defined(_WIN32) || defined(_WIN64)
else if (buf[ret] == '/') buf[ret] = '\\';
#endif
}
Expand Down Expand Up @@ -1173,7 +1173,7 @@ int http_cache_response_header (void * vmsg, void * vcacinfo)
climsg->res_body_length = length;
http_header_append_int64(climsg, 1, "Content-Length", 14, length);

#ifdef _WIN32
#if defined(_WIN32) || defined(_WIN64)
sprintf(buf, "bytes %I64d-%I64d/%I64d", start, end, cacinfo->body_length);
#else
sprintf(buf, "bytes %lld-%lld/%lld", start, end, cacinfo->body_length);
Expand Down
8 changes: 4 additions & 4 deletions src/http_cgi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1929,7 +1929,7 @@ int AddResFile (void * vmsg, char * filename, int64 startpos, int64 len)

ret = chunk_add_file(msg->res_body_chunk, filename, part->start, part->length, 1);

#ifdef _WIN32
#if defined(_WIN32) || defined(_WIN64)
sprintf(buf, "bytes %I64d-%I64d/%I64d", part->start, part->end, part->fsize);
#else
sprintf(buf, "bytes %lld-%lld/%lld", part->start, part->end, part->fsize);
Expand All @@ -1954,7 +1954,7 @@ int AddResFile (void * vmsg, char * filename, int64 startpos, int64 len)

AdjustPartial(part, st.st_size);

#ifdef _WIN32
#if defined(_WIN32) || defined(_WIN64)
sprintf(buf, "--%s\r\nCotent-Type: %s\r\n"
"Content-Range: bytes %I64d-%I64d/%I64d\r\n\r\n",
boundary, mime, part->start, part->end, part->fsize);
Expand Down Expand Up @@ -1988,7 +1988,7 @@ int AddResFile (void * vmsg, char * filename, int64 startpos, int64 len)
if (len < st.st_size) {
SetStatus(msg, 206, "Partial Content");

#ifdef _WIN32
#if defined(_WIN32) || defined(_WIN64)
sprintf(buf, "bytes %I64d-%I64d/%ld", startpos, startpos + len - 1, st.st_size);
#else
sprintf(buf, "bytes %lld-%lld/%ld", startpos, startpos + len - 1, st.st_size);
Expand Down Expand Up @@ -2060,7 +2060,7 @@ int Check304Resp (void * vmsg, uint64 mediasize, time_t mtime, uint32 inode)

} else if (mtime > 0 && mediasize > 0) {
memset(etag, 0, sizeof(etag));
#ifdef _WIN32
#if defined(_WIN32) || defined(_WIN64)
sprintf(etag, "%I64x-%I64x", mediasize, mtime);
#else
sprintf(etag, "%x-%llx-%lx", inode, mediasize, mtime);
Expand Down
4 changes: 2 additions & 2 deletions src/http_cli_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ int http_cli_send (void * vcon)

err = 0;
if (iovec.vectype == 2) { //sendfile
#ifdef _WIN32
#if defined(_WIN32) || defined(_WIN64)
ret = http_con_sendfile(pcon, (int)iovec.filefd, iovec.fpos, iovec.size , &num, &err);
#else
ret = http_con_sendfile(pcon, iovec.filefd, iovec.fpos, iovec.size , &num, &err);
Expand Down Expand Up @@ -786,7 +786,7 @@ int http_cli_send (void * vcon)

#ifdef UNIX
if (err == EINTR || err == EAGAIN || err == EWOULDBLOCK) { //EAGAIN
#elif defined _WIN32
#elif defined(_WIN32) || defined(_WIN64)
if (err == WSAEWOULDBLOCK) {
#else
if (num == 0) {
Expand Down
10 changes: 5 additions & 5 deletions src/http_dispdir.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,14 @@ static int read_dir_list (char * path, char * curpath, frame_p frame)
frame_appendf(frame, "\">%s</A><br>", item->name);
}
}
frame_appendf(frame, " 目录总数: %d &nbsp;&nbsp;文件总数: %d<br>", dirtotal, filetotal);
frame_appendf(frame, " 目录总数: %d &nbsp;&nbsp;文件总数: %d<br>", dirtotal, filetotal);

arr_pop_kfree(itemlist);
return 0;
}
#endif

#ifdef _WIN32
#if defined(_WIN32) || defined(_WIN64)
static int read_dir_list (char * path, char * curpath, frame_p frame)
{
WIN32_FIND_DATA filest;
Expand Down Expand Up @@ -295,7 +295,7 @@ static int read_dir_list (char * path, char * curpath, frame_p frame)
} while(FindNextFile(hFind, &filest));

FindClose(hFind);
frame_appendf(frame, " 目录总数: %d &nbsp;&nbsp;文件总数: %d<br>", dirtotal, filetotal);
frame_appendf(frame, " 目录总数: %d &nbsp;&nbsp;文件总数: %d<br>", dirtotal, filetotal);
return 0;
}
#endif
Expand Down Expand Up @@ -361,7 +361,7 @@ int DisplayDirectory (void * vmsg)
chdir(path);
getcwd(realpath, sizeof(realpath)-1);
chdir(curpath);
#elif defined _WIN32
#elif defined(_WIN32) || defined(_WIN64)
GetCurrentDirectory(sizeof(curpath)-1, curpath);
SetCurrentDirectory(path);
GetCurrentDirectory(sizeof(realpath)-1, realpath);
Expand All @@ -379,7 +379,7 @@ int DisplayDirectory (void * vmsg)
chdir(path);
getcwd(realpath, sizeof(realpath)-1);
chdir(curpath);
#elif defined _WIN32
#elif defined(_WIN32) || defined(_WIN64)
GetCurrentDirectory(sizeof(curpath)-1, curpath);
SetCurrentDirectory(path);
GetCurrentDirectory(sizeof(realpath)-1, realpath);
Expand Down
2 changes: 1 addition & 1 deletion src/http_fcgi_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ int http_fcgi_send (void * vcon)

#ifdef UNIX
if (err == EINTR || err == EAGAIN || err == EWOULDBLOCK) { //EAGAIN
#elif defined _WIN32
#elif defined(_WIN32) || defined(_WIN64)
if (err == WSAEWOULDBLOCK) {
#else
if (num == 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/http_fcgi_msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ void fcgi_predefined_param_encode (frame_p frm, HTTPMsg * httpmsg)
buf[0] = '\0';
valuelen = 0;
} else {
#ifdef _WIN32
#if defined(_WIN32) || defined(_WIN64)
sprintf(buf, "%I64d", httpmsg->req_body_length);
#else
sprintf(buf, "%lld", httpmsg->req_body_length);
Expand Down
4 changes: 2 additions & 2 deletions src/http_header.c
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ int http_header_append_int64 (void * vmsg, int type, char * name, int namelen, i

memset(value, 0, sizeof(value));

#ifdef _WIN32
#if defined(_WIN32) || defined(_WIN64)
sprintf(value, "%I64d", ival);
#else
sprintf(value, "%lld", ival);
Expand All @@ -683,7 +683,7 @@ int http_header_append_uint64 (void * vmsg, int type, char * name, int namelen,

memset(value, 0, sizeof(value));

#ifdef _WIN32
#if defined(_WIN32) || defined(_WIN64)
sprintf(value, "%I64u", ival);
#else
sprintf(value, "%llu", ival);
Expand Down
26 changes: 13 additions & 13 deletions src/http_listen.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <regex.h>
#endif

#ifdef _WIN32
#if defined(_WIN32) || defined(_WIN64)
#define PCRE_STATIC 1
#include "pcre.h"
#endif
Expand Down Expand Up @@ -167,7 +167,7 @@ int http_loc_build (void * vhost, void * jhost)
#ifdef UNIX
regex_t * preg = NULL;
#endif
#ifdef _WIN32
#if defined(_WIN32) || defined(_WIN64)
char * errstr = NULL;
int erroff = 0;
pcre * preg = NULL;
Expand Down Expand Up @@ -309,7 +309,7 @@ int http_loc_build (void * vhost, void * jhost)
regcomp(preg, ploc->path, REG_EXTENDED | REG_ICASE);
}
#endif
#ifdef _WIN32
#if defined(_WIN32) || defined(_WIN64)
if (ploc->matchtype == MATCH_REGEX_CASE) { //case censitive
preg = pcre_compile(ploc->path, 0, &errstr, &erroff, NULL);

Expand Down Expand Up @@ -441,7 +441,7 @@ void http_host_free (void * vhost)
#ifdef UNIX
regex_t * preg = NULL;
#endif
#ifdef _WIN32
#if defined(_WIN32) || defined(_WIN64)
pcre * preg = NULL;
#endif

Expand Down Expand Up @@ -486,7 +486,7 @@ void http_host_free (void * vhost)
regfree(preg);
kfree(preg);
#endif
#ifdef _WIN32
#if defined(_WIN32) || defined(_WIN64)
pcre_free(preg);
#endif
}
Expand Down Expand Up @@ -821,7 +821,7 @@ void http_listen_free (void * vhl)
#ifdef UNIX
dlclose(hl->cbhandle);
#endif
#ifdef _WIN32
#if defined(_WIN32) || defined(_WIN64)
FreeLibrary(hl->cbhandle);
#endif
hl->cbhandle = NULL;
Expand Down Expand Up @@ -904,7 +904,7 @@ int http_listen_cblibfile_set (void * vhl, char * cblibfile)
#ifdef UNIX
dlclose(hl->cbhandle);
#endif
#ifdef _WIN32
#if defined(_WIN32) || defined(_WIN64)
FreeLibrary(hl->cbhandle);
#endif

Expand Down Expand Up @@ -966,7 +966,7 @@ int http_listen_cblibfile_set (void * vhl, char * cblibfile)
}
#endif

#ifdef _WIN32
#if defined(_WIN32) || defined(_WIN64)
hl->cbhandle = LoadLibrary(hl->cbargv[0]);
if (!hl->cbhandle) {
tolog(1, "eJet - HTTP Listen <%s:%d%s> Loading DynLib <%s> error! errcode=%ld\n",
Expand Down Expand Up @@ -1521,7 +1521,7 @@ void * http_loc_instance (void * vmsg)
#ifdef UNIX
regmatch_t pmat[16];
#endif
#ifdef _WIN32
#if defined(_WIN32) || defined(_WIN64)
int ovec[36];
#endif

Expand Down Expand Up @@ -1587,7 +1587,7 @@ void * http_loc_instance (void * vmsg)
ret = regexec(arr_value(host->regex_list, i), buf, 16, pmat, 0);
if (ret == 0) {
#endif
#ifdef _WIN32
#if defined(_WIN32) || defined(_WIN64)
ret = pcre_exec(arr_value(host->regex_list, i), NULL, buf, strlen(buf), 0, 0, ovec, 36);
if (ret > 0) {
#endif
Expand All @@ -1607,7 +1607,7 @@ void * http_loc_instance (void * vmsg)
break;
}
#endif
#ifdef _WIN32
#if defined(_WIN32) || defined(_WIN64)
for (j = 0; j < ret; j++) {
msg->matchstr[msg->matchnum].p = msg->docuri->path + ovec[2 * j];
msg->matchstr[msg->matchnum].len = ovec[2 * j + 1] - ovec[2 * j];
Expand Down Expand Up @@ -1938,7 +1938,7 @@ void * http_regex_loc (void * vhl, char * hostn, int hostlen, char * matstr, int
#ifdef UNIX
regex_t * preg = NULL;
#endif
#ifdef _WIN32
#if defined(_WIN32) || defined(_WIN64)
pcre * preg = NULL;
char * errstr = NULL;
int erroff = 0;
Expand Down Expand Up @@ -1988,7 +1988,7 @@ void * http_regex_loc (void * vhl, char * hostn, int hostlen, char * matstr, int
regcomp(preg, ploc->path, REG_EXTENDED | REG_ICASE);
}
#endif
#ifdef _WIN32
#if defined(_WIN32) || defined(_WIN64)
if (ploc->matchtype == MATCH_REGEX_CASE) { //case censitive
preg = pcre_compile(ploc->path, 0, &errstr, &erroff, NULL);

Expand Down
2 changes: 1 addition & 1 deletion src/http_mgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ void * http_mgmt_alloc (void * pcore, char * confname, int extsize, int msgextsi

#ifdef UNIX
chdir(mgmt->root_path);
#elif defined (_WIN32)
#elif defined(_WIN32) || defined(_WIN64)
SetCurrentDirectory(mgmt->root_path);
#endif

Expand Down
6 changes: 3 additions & 3 deletions src/http_pagetpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ int http_pagetpl_parse (void * vmsg, char * tplfile, void * vbyte, int bytelen,

void * hfile = NULL;
int64 fsize = 0;
#ifdef _WIN32
#if defined(_WIN32) || defined(_WIN64)
HANDLE hmap;
void * pmap = NULL;
int64 maplen = 0;
Expand Down Expand Up @@ -101,7 +101,7 @@ int http_pagetpl_parse (void * vmsg, char * tplfile, void * vbyte, int bytelen,

#ifdef UNIX
pbyte = mmap(NULL, fsize, PROT_READ | PROT_WRITE, MAP_PRIVATE, native_file_fd(hfile), 0);
#elif defined (_WIN32)
#elif defined(_WIN32) || defined(_WIN64)
pbyte = file_mmap (NULL, native_file_handle(hfile), 0, fsize, NULL, &hmap, &pmap, &maplen, &mapoff);
#endif
if (!pbyte) {
Expand Down Expand Up @@ -260,7 +260,7 @@ int http_pagetpl_parse (void * vmsg, char * tplfile, void * vbyte, int bytelen,
if (tplfile && hfile != NULL) {
#ifdef UNIX
munmap(pbyte, fsize);
#elif defined (_WIN32)
#elif defined(_WIN32) || defined(_WIN64)
file_munmap(hmap, pmap);
#endif
native_file_close(hfile);
Expand Down
Loading

0 comments on commit e9bdc2f

Please sign in to comment.