1
0
Fork 0
forked from fte/fteqw

Fixed http server on linux.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5176 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2017-12-02 22:30:08 +00:00
parent 65e58c3595
commit fbf5069a38
2 changed files with 22 additions and 17 deletions

View file

@ -1839,7 +1839,7 @@ m-dbg:
m-profile: m-profile:
@$(MAKE) m-tmp TYPE=_clsv-profile OUT_DIR="$(PROFILE_DIR)/$(NCDIRPREFIX)$(MB_DIR)" @$(MAKE) m-tmp TYPE=_clsv-profile OUT_DIR="$(PROFILE_DIR)/$(NCDIRPREFIX)$(MB_DIR)"
.PHONY: m-tmp mcl-tmp mingl-tmp glcl-tmp gl-tmp sv-tmp _clsv-dbg _clsv-rel _cl-dbg _cl-rel _out-rel _out-dbg reldir debugdir makelibs wel-rel web-dbg .PHONY: m-tmp mcl-tmp mingl-tmp glcl-tmp gl-tmp sv-tmp _clsv-dbg _clsv-rel _cl-dbg _cl-rel _out-rel _out-dbg reldir debugdir makelibs wel-rel web-dbg httpserver
_qcc-tmp: $(REQDIR) _qcc-tmp: $(REQDIR)
@ -2159,9 +2159,9 @@ libs-$(ARCH)/libopus.a:
makelibs: libs-$(ARCH)/libjpeg.a libs-$(ARCH)/libz.a libs-$(ARCH)/libpng.a libs-$(ARCH)/libogg.a libs-$(ARCH)/libvorbis.a libs-$(ARCH)/libopus.a makelibs: libs-$(ARCH)/libjpeg.a libs-$(ARCH)/libz.a libs-$(ARCH)/libpng.a libs-$(ARCH)/libogg.a libs-$(ARCH)/libvorbis.a libs-$(ARCH)/libopus.a
HTTP_OBJECTS=http/httpserver.c http/iwebiface.c common/fs_stdio.c HTTP_OBJECTS=http/httpserver.c http/iwebiface.c common/fs_stdio.c http/ftpserver.c
$(RELEASE_DIR)/httpserver$(BITS): $(HTTP_OBJECTS) $(RELEASE_DIR)/httpserver$(BITS): $(HTTP_OBJECTS)
$(CC) -o $(RELEASE_DIR)/httpserver$(BITS) $(HTTP_OBJECTS) -Icommon -Iclient -Iqclib -Igl -Iserver -DWEBSVONLY -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -DNO_PNG $(CC) -o $(RELEASE_DIR)/httpserver$(BITS) -Icommon -Iclient -Iqclib -Igl -Iserver -DWEBSERVER -DWEBSVONLY -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -DNO_PNG $(HTTP_OBJECTS)
httpserver: $(RELEASE_DIR)/httpserver$(BITS) httpserver: $(RELEASE_DIR)/httpserver$(BITS)
IQM_OBJECTS=../iqm/iqm.cpp IQM_OBJECTS=../iqm/iqm.cpp

View file

@ -15,28 +15,28 @@ char *NET_SockadrToString(char *s, int slen, struct sockaddr_qstorage *addr)
Q_snprintfz(s, slen, "%s:%u", inet_ntoa(((struct sockaddr_in*)addr)->sin_addr), ntohs(((struct sockaddr_in*)addr)->sin_port)); Q_snprintfz(s, slen, "%s:%u", inet_ntoa(((struct sockaddr_in*)addr)->sin_addr), ntohs(((struct sockaddr_in*)addr)->sin_port));
break; break;
case AF_INET6: case AF_INET6:
if (!memcmp(((struct sockaddr_in6*)addr)->sin6_addr.s6_bytes, "\0\0\0\0\0\0\0\0\0\0\xff\xff", 12)) if (!memcmp(((struct sockaddr_in6*)addr)->sin6_addr.s6_addr, "\0\0\0\0\0\0\0\0\0\0\xff\xff", 12))
{ //ipv4-mapped { //ipv4-mapped
Q_snprintfz(s, slen, "[::ffff:%u.%u.%u.%u]:%u", Q_snprintfz(s, slen, "[::ffff:%u.%u.%u.%u]:%u",
((struct sockaddr_in6*)addr)->sin6_addr.s6_bytes[12], ((struct sockaddr_in6*)addr)->sin6_addr.s6_addr[12],
((struct sockaddr_in6*)addr)->sin6_addr.s6_bytes[13], ((struct sockaddr_in6*)addr)->sin6_addr.s6_addr[13],
((struct sockaddr_in6*)addr)->sin6_addr.s6_bytes[14], ((struct sockaddr_in6*)addr)->sin6_addr.s6_addr[14],
((struct sockaddr_in6*)addr)->sin6_addr.s6_bytes[15], ((struct sockaddr_in6*)addr)->sin6_addr.s6_addr[15],
ntohs(((struct sockaddr_in6*)addr)->sin6_port)); ntohs(((struct sockaddr_in6*)addr)->sin6_port));
} }
else else
{ {
Q_snprintfz(s, slen, "[%x:%x:%x:%x:%x:%x:%x:%x]:%u", Q_snprintfz(s, slen, "[%x:%x:%x:%x:%x:%x:%x:%x]:%u",
ntohs(((struct sockaddr_in6*)addr)->sin6_addr.s6_words[0]), ntohs(((unsigned short*)((struct sockaddr_in6*)addr)->sin6_addr.s6_addr)[0]),
ntohs(((struct sockaddr_in6*)addr)->sin6_addr.s6_words[1]), ntohs(((unsigned short*)((struct sockaddr_in6*)addr)->sin6_addr.s6_addr)[1]),
ntohs(((struct sockaddr_in6*)addr)->sin6_addr.s6_words[2]), ntohs(((unsigned short*)((struct sockaddr_in6*)addr)->sin6_addr.s6_addr)[2]),
ntohs(((struct sockaddr_in6*)addr)->sin6_addr.s6_words[3]), ntohs(((unsigned short*)((struct sockaddr_in6*)addr)->sin6_addr.s6_addr)[3]),
ntohs(((struct sockaddr_in6*)addr)->sin6_addr.s6_words[4]), ntohs(((unsigned short*)((struct sockaddr_in6*)addr)->sin6_addr.s6_addr)[4]),
ntohs(((struct sockaddr_in6*)addr)->sin6_addr.s6_words[5]), ntohs(((unsigned short*)((struct sockaddr_in6*)addr)->sin6_addr.s6_addr)[5]),
ntohs(((struct sockaddr_in6*)addr)->sin6_addr.s6_words[6]), ntohs(((unsigned short*)((struct sockaddr_in6*)addr)->sin6_addr.s6_addr)[6]),
ntohs(((struct sockaddr_in6*)addr)->sin6_addr.s6_words[7]), ntohs(((unsigned short*)((struct sockaddr_in6*)addr)->sin6_addr.s6_addr)[7]),
ntohs(((struct sockaddr_in6*)addr)->sin6_port)); ntohs(((struct sockaddr_in6*)addr)->sin6_port));
} }
@ -181,7 +181,7 @@ int main(int argc, char **argv)
printf(" -user <name> specifies the username that has full access. if not supplied noone can write.\n"); printf(" -user <name> specifies the username that has full access. if not supplied noone can write.\n");
printf(" -pass <pass> specifies the password to go with that username\n"); printf(" -pass <pass> specifies the password to go with that username\n");
printf(" -noanon will refuse to serve files to anyone but the authed user\n"); printf(" -noanon will refuse to serve files to anyone but the authed user\n");
return; return 0;
} }
else if (!strcmp(a, "port") || !strcmp(a, "p")) else if (!strcmp(a, "port") || !strcmp(a, "p"))
{ {
@ -312,6 +312,11 @@ void COM_EnumerateFiles (const char *match, int (*func)(const char *, qofs_t, ti
while(FindNextFileA(r, &fd) && go); while(FindNextFileA(r, &fd) && go);
FindClose(r); FindClose(r);
} }
#else
void COM_EnumerateFiles (const char *match, int (*func)(const char *, qofs_t, time_t mtime, void *, searchpathfuncs_t *f), void *parm)
{
//No implementation on unix etc
}
#endif #endif
char *COM_ParseType (const char *data, char *out, int outlen, com_tokentype_t *toktype) char *COM_ParseType (const char *data, char *out, int outlen, com_tokentype_t *toktype)