mirror of
https://github.com/nzp-team/fteqw.git
synced 2024-11-24 21:02:26 +00:00
There. Happy now?
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@3017 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
4dfdca03f5
commit
64c9a31e6b
1 changed files with 73 additions and 6 deletions
|
@ -48,6 +48,7 @@ static void HTMLprintf(char *outb, int outl, char *fmt, ...)
|
||||||
va_list val;
|
va_list val;
|
||||||
char qfmt[8192*4];
|
char qfmt[8192*4];
|
||||||
char *inb = qfmt;
|
char *inb = qfmt;
|
||||||
|
unsigned char inchar;
|
||||||
|
|
||||||
va_start(val, fmt);
|
va_start(val, fmt);
|
||||||
vsnprintf(qfmt, sizeof(qfmt), fmt, val);
|
vsnprintf(qfmt, sizeof(qfmt), fmt, val);
|
||||||
|
@ -58,7 +59,8 @@ static void HTMLprintf(char *outb, int outl, char *fmt, ...)
|
||||||
outl -= 5;
|
outl -= 5;
|
||||||
while (outl > 0 && *inb)
|
while (outl > 0 && *inb)
|
||||||
{
|
{
|
||||||
if (*inb == '<')
|
inchar = qfont_table[*(unsigned char*)inb];
|
||||||
|
if (inchar == '<')
|
||||||
{
|
{
|
||||||
*outb++ = '&';
|
*outb++ = '&';
|
||||||
*outb++ = 'l';
|
*outb++ = 'l';
|
||||||
|
@ -66,7 +68,7 @@ static void HTMLprintf(char *outb, int outl, char *fmt, ...)
|
||||||
*outb++ = ';';
|
*outb++ = ';';
|
||||||
outl -= 4;
|
outl -= 4;
|
||||||
}
|
}
|
||||||
else if (*inb == '>')
|
else if (inchar == '>')
|
||||||
{
|
{
|
||||||
*outb++ = '&';
|
*outb++ = '&';
|
||||||
*outb++ = 'g';
|
*outb++ = 'g';
|
||||||
|
@ -74,7 +76,7 @@ static void HTMLprintf(char *outb, int outl, char *fmt, ...)
|
||||||
*outb++ = ';';
|
*outb++ = ';';
|
||||||
outl -= 4;
|
outl -= 4;
|
||||||
}
|
}
|
||||||
else if (*inb == '\n')
|
else if (inchar == '\n')
|
||||||
{
|
{
|
||||||
*outb++ = '<';
|
*outb++ = '<';
|
||||||
*outb++ = 'b';
|
*outb++ = 'b';
|
||||||
|
@ -83,7 +85,7 @@ static void HTMLprintf(char *outb, int outl, char *fmt, ...)
|
||||||
*outb++ = '>';
|
*outb++ = '>';
|
||||||
outl -= 5;
|
outl -= 5;
|
||||||
}
|
}
|
||||||
else if (*inb == '&')
|
else if (inchar == '&')
|
||||||
{
|
{
|
||||||
*outb++ = '&';
|
*outb++ = '&';
|
||||||
*outb++ = 'a';
|
*outb++ = 'a';
|
||||||
|
@ -94,7 +96,7 @@ static void HTMLprintf(char *outb, int outl, char *fmt, ...)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*outb++ = qfont_table[*(unsigned char*)inb];
|
*outb++ = inchar;
|
||||||
outl -= 1;
|
outl -= 1;
|
||||||
}
|
}
|
||||||
inb++;
|
inb++;
|
||||||
|
@ -258,6 +260,7 @@ static qboolean HTTPSV_GetHeaderField(char *s, char *field, char *buffer, int bu
|
||||||
{
|
{
|
||||||
*e = '\0';
|
*e = '\0';
|
||||||
colon = strchr(s, ':');
|
colon = strchr(s, ':');
|
||||||
|
*e = '\n';
|
||||||
if (!colon)
|
if (!colon)
|
||||||
{
|
{
|
||||||
if (!strncmp(field, s, fieldnamelen))
|
if (!strncmp(field, s, fieldnamelen))
|
||||||
|
@ -279,7 +282,7 @@ static qboolean HTTPSV_GetHeaderField(char *s, char *field, char *buffer, int bu
|
||||||
colon++;
|
colon++;
|
||||||
while (buffersize > 2)
|
while (buffersize > 2)
|
||||||
{
|
{
|
||||||
if (*colon == '\r' || *colon == '\n')
|
if (!*colon || *colon == '\r' || *colon == '\n')
|
||||||
break;
|
break;
|
||||||
*buffer++ = *colon++;
|
*buffer++ = *colon++;
|
||||||
buffersize--;
|
buffersize--;
|
||||||
|
@ -380,6 +383,62 @@ static void HTTPSV_GenerateQTVStub(cluster_t *cluster, oproxy_t *dest, char *str
|
||||||
Net_ProxySend(cluster, dest, buffer, strlen(buffer));
|
Net_ProxySend(cluster, dest, buffer, strlen(buffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void HTTPSV_GenerateQWSVStub(cluster_t *cluster, oproxy_t *dest, char *method, char *streamid)
|
||||||
|
{
|
||||||
|
char *s;
|
||||||
|
char buffer[1024];
|
||||||
|
|
||||||
|
|
||||||
|
char fname[256];
|
||||||
|
s = fname;
|
||||||
|
while (*streamid > ' ')
|
||||||
|
{
|
||||||
|
if (s > fname + sizeof(fname)-4) //4 cos I'm too lazy to work out what the actual number should be
|
||||||
|
break;
|
||||||
|
if (*streamid == '%')
|
||||||
|
{
|
||||||
|
*s = 0;
|
||||||
|
streamid++;
|
||||||
|
if (*streamid <= ' ')
|
||||||
|
break;
|
||||||
|
else if (*streamid >= 'a' && *streamid <= 'f')
|
||||||
|
*s += 10 + *streamid-'a';
|
||||||
|
else if (*streamid >= 'A' && *streamid <= 'F')
|
||||||
|
*s += 10 + *streamid-'A';
|
||||||
|
else if (*streamid >= '0' && *streamid <= '9')
|
||||||
|
*s += *streamid-'0';
|
||||||
|
|
||||||
|
*s <<= 4;
|
||||||
|
|
||||||
|
streamid++;
|
||||||
|
if (*streamid <= ' ')
|
||||||
|
break;
|
||||||
|
else if (*streamid >= 'a' && *streamid <= 'f')
|
||||||
|
*s += 10 + *streamid-'a';
|
||||||
|
else if (*streamid >= 'A' && *streamid <= 'F')
|
||||||
|
*s += 10 + *streamid-'A';
|
||||||
|
else if (*streamid >= '0' && *streamid <= '9')
|
||||||
|
*s += *streamid-'0';
|
||||||
|
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
*s++ = *streamid++;
|
||||||
|
}
|
||||||
|
*s = 0;
|
||||||
|
streamid = fname;
|
||||||
|
|
||||||
|
HTTPSV_SendHTTPHeader(cluster, dest, "200", "text/x-quaketvident", false);
|
||||||
|
|
||||||
|
snprintf(buffer, sizeof(buffer), "[QTV]\r\n"
|
||||||
|
"%s: %s\r\n"
|
||||||
|
"",
|
||||||
|
method, streamid);
|
||||||
|
|
||||||
|
|
||||||
|
Net_ProxySend(cluster, dest, buffer, strlen(buffer));
|
||||||
|
}
|
||||||
|
|
||||||
static char *HTTPSV_ParsePOST(char *post, char *buffer, int buffersize)
|
static char *HTTPSV_ParsePOST(char *post, char *buffer, int buffersize)
|
||||||
{
|
{
|
||||||
while(*post && *post != '&')
|
while(*post && *post != '&')
|
||||||
|
@ -747,6 +806,14 @@ void HTTPSV_GetMethod(cluster_t *cluster, oproxy_t *pend)
|
||||||
{
|
{
|
||||||
HTTPSV_GenerateQTVStub(cluster, pend, "file:", (char*)pend->inbuffer+20);
|
HTTPSV_GenerateQTVStub(cluster, pend, "file:", (char*)pend->inbuffer+20);
|
||||||
}
|
}
|
||||||
|
else if (!strncmp((char*)pend->inbuffer+4, "/watch.qtv?join=", 16))
|
||||||
|
{
|
||||||
|
HTTPSV_GenerateQWSVStub(cluster, pend, "Join", (char*)pend->inbuffer+16);
|
||||||
|
}
|
||||||
|
else if (!strncmp((char*)pend->inbuffer+4, "/watch.qtv?obsv=", 16))
|
||||||
|
{
|
||||||
|
HTTPSV_GenerateQWSVStub(cluster, pend, "Observe", (char*)pend->inbuffer+16);
|
||||||
|
}
|
||||||
// else if (!strncmp((char*)pend->inbuffer+4, "/demo/", 6))
|
// else if (!strncmp((char*)pend->inbuffer+4, "/demo/", 6))
|
||||||
// { //fixme: make this send the demo as an http download
|
// { //fixme: make this send the demo as an http download
|
||||||
// HTTPSV_GenerateQTVStub(cluster, pend, "file:", (char*)pend->inbuffer+10);
|
// HTTPSV_GenerateQTVStub(cluster, pend, "file:", (char*)pend->inbuffer+10);
|
||||||
|
|
Loading…
Reference in a new issue