Use useragent for version, fix URl encoding
This commit is contained in:
parent
038da72c61
commit
f86091d421
18
src/Config.h
18
src/Config.h
@ -22,6 +22,24 @@
|
|||||||
#define BUILD_NUM 133
|
#define BUILD_NUM 133
|
||||||
//VersionInfoEnd
|
//VersionInfoEnd
|
||||||
|
|
||||||
|
#ifdef BETA
|
||||||
|
#define IDENT_RELTYPE "B"
|
||||||
|
#else
|
||||||
|
#define IDENT_RELTYPE "S"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#define IDENT_PLATFORM "WIN32"
|
||||||
|
#elif defined(MACOSX)
|
||||||
|
#define IDENT_PLATFORM "MACOSX"
|
||||||
|
#elif defined(LIN32)
|
||||||
|
#define IDENT_PLATFORM "LIN32"
|
||||||
|
#elif defined(LIN64)
|
||||||
|
#define IDENT_PLATFORM "LIN64"
|
||||||
|
#else
|
||||||
|
#define IDENT_PLATFORM "UNKNOWN"
|
||||||
|
#endif
|
||||||
|
|
||||||
#define IDENT_VERSION "G" //Change this if you're not Simon! It should be a single letter
|
#define IDENT_VERSION "G" //Change this if you're not Simon! It should be a single letter
|
||||||
|
|
||||||
#define MTOS_EXPAND(str) #str
|
#define MTOS_EXPAND(str) #str
|
||||||
|
29
src/Misc.cpp
29
src/Misc.cpp
@ -205,6 +205,35 @@ void strcaturl(char *dst, char *src)
|
|||||||
*d = 0;
|
*d = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string URLEscape(std::string source)
|
||||||
|
{
|
||||||
|
char * src = (char *)source.c_str();
|
||||||
|
char * dst = (char *)calloc((source.length()*3)+2, 1);
|
||||||
|
char *d;
|
||||||
|
unsigned char *s;
|
||||||
|
|
||||||
|
for (d=dst; *d; d++) ;
|
||||||
|
|
||||||
|
for (s=(unsigned char *)src; *s; s++)
|
||||||
|
{
|
||||||
|
if ((*s>='0' && *s<='9') ||
|
||||||
|
(*s>='a' && *s<='z') ||
|
||||||
|
(*s>='A' && *s<='Z'))
|
||||||
|
*(d++) = *s;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*(d++) = '%';
|
||||||
|
*(d++) = hex[*s>>4];
|
||||||
|
*(d++) = hex[*s&15];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*d = 0;
|
||||||
|
|
||||||
|
std::string finalString(dst);
|
||||||
|
free(dst);
|
||||||
|
return finalString;
|
||||||
|
}
|
||||||
|
|
||||||
void strappend(char *dst, char *src)
|
void strappend(char *dst, char *src)
|
||||||
{
|
{
|
||||||
char *d;
|
char *d;
|
||||||
|
@ -69,6 +69,8 @@ int load_string(FILE *f, char *str, int max);
|
|||||||
|
|
||||||
void strcaturl(char *dst, char *src);
|
void strcaturl(char *dst, char *src);
|
||||||
|
|
||||||
|
std::string URLEscape(std::string source);
|
||||||
|
|
||||||
void strappend(char *dst, char *src);
|
void strappend(char *dst, char *src);
|
||||||
|
|
||||||
void *file_load(char *fn, int *size);
|
void *file_load(char *fn, int *size);
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "Client.h"
|
#include "Client.h"
|
||||||
#include "MD5.h"
|
#include "MD5.h"
|
||||||
#include "Graphics.h"
|
#include "Graphics.h"
|
||||||
|
#include "Misc.h"
|
||||||
|
|
||||||
#include "interface/Point.h"
|
#include "interface/Point.h"
|
||||||
|
|
||||||
@ -434,12 +435,12 @@ std::vector<Save*> * Client::SearchSaves(int start, int count, string query, str
|
|||||||
{
|
{
|
||||||
urlStream << "&Search_Query=";
|
urlStream << "&Search_Query=";
|
||||||
if(query.length())
|
if(query.length())
|
||||||
urlStream << query;
|
urlStream << URLEscape(query);
|
||||||
if(sort == "date")
|
if(sort == "date")
|
||||||
{
|
{
|
||||||
if(query.length())
|
if(query.length())
|
||||||
urlStream << " ";
|
urlStream << URLEscape(" ");
|
||||||
urlStream << "sort:" << sort;
|
urlStream << URLEscape("sort:") << URLEscape(sort);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -464,7 +464,7 @@ int http_async_req_status(void *ctx)
|
|||||||
if (cx->txdl)
|
if (cx->txdl)
|
||||||
{
|
{
|
||||||
// generate POST
|
// generate POST
|
||||||
cx->tbuf = (char *)malloc(strlen(cx->host) + strlen(cx->path) + 121 + cx->txdl + cx->thlen);
|
cx->tbuf = (char *)malloc(strlen(cx->host) + strlen(cx->path) + 121 + 128 + cx->txdl + cx->thlen);
|
||||||
cx->tptr = 0;
|
cx->tptr = 0;
|
||||||
cx->tlen = 0;
|
cx->tlen = 0;
|
||||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "POST %s HTTP/1.1\n", cx->path);
|
cx->tlen += sprintf(cx->tbuf+cx->tlen, "POST %s HTTP/1.1\n", cx->path);
|
||||||
@ -480,11 +480,12 @@ int http_async_req_status(void *ctx)
|
|||||||
cx->thlen = 0;
|
cx->thlen = 0;
|
||||||
}
|
}
|
||||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "Content-Length: %d\n", cx->txdl);
|
cx->tlen += sprintf(cx->tbuf+cx->tlen, "Content-Length: %d\n", cx->txdl);
|
||||||
#ifdef BETA
|
cx->tlen += sprintf(cx->tbuf+cx->tlen, "User-Agent: PowderToy/%d.%d (%s; M%d) TPTPP/%s%d.%d.%d%s\n", SAVE_VERSION, MINOR_VERSION, IDENT_PLATFORM, 0, IDENT_VERSION, SAVE_VERSION, MINOR_VERSION, BUILD_NUM, IDENT_RELTYPE);
|
||||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "X-Powder-Version: %s%dB%d\n", IDENT_VERSION, SAVE_VERSION, MINOR_VERSION);
|
//#ifdef BETA
|
||||||
#else
|
// cx->tlen += sprintf(cx->tbuf+cx->tlen, "X-Powder-Version: %s%dB%d\n", IDENT_VERSION, SAVE_VERSION, MINOR_VERSION);
|
||||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "X-Powder-Version: %s%dS%d\n", IDENT_VERSION, SAVE_VERSION, MINOR_VERSION);
|
//#else
|
||||||
#endif
|
// cx->tlen += sprintf(cx->tbuf+cx->tlen, "X-Powder-Version: %s%dS%d\n", IDENT_VERSION, SAVE_VERSION, MINOR_VERSION);
|
||||||
|
//#endif
|
||||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "\n");
|
cx->tlen += sprintf(cx->tbuf+cx->tlen, "\n");
|
||||||
memcpy(cx->tbuf+cx->tlen, cx->txd, cx->txdl);
|
memcpy(cx->tbuf+cx->tlen, cx->txd, cx->txdl);
|
||||||
cx->tlen += cx->txdl;
|
cx->tlen += cx->txdl;
|
||||||
@ -495,7 +496,7 @@ int http_async_req_status(void *ctx)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// generate GET
|
// generate GET
|
||||||
cx->tbuf = (char *)malloc(strlen(cx->host) + strlen(cx->path) + 89 + cx->thlen);
|
cx->tbuf = (char *)malloc(strlen(cx->host) + strlen(cx->path) + 89 + 128 + cx->thlen);
|
||||||
cx->tptr = 0;
|
cx->tptr = 0;
|
||||||
cx->tlen = 0;
|
cx->tlen = 0;
|
||||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "GET %s HTTP/1.1\n", cx->path);
|
cx->tlen += sprintf(cx->tbuf+cx->tlen, "GET %s HTTP/1.1\n", cx->path);
|
||||||
@ -510,11 +511,13 @@ int http_async_req_status(void *ctx)
|
|||||||
}
|
}
|
||||||
if (!cx->keep)
|
if (!cx->keep)
|
||||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "Connection: close\n");
|
cx->tlen += sprintf(cx->tbuf+cx->tlen, "Connection: close\n");
|
||||||
#ifdef BETA
|
cx->tlen += sprintf(cx->tbuf+cx->tlen, "User-Agent: PowderToy/%d.%d (%s; M%d) TPTPP/%s%d.%d.%d%s\n", SAVE_VERSION, MINOR_VERSION, IDENT_PLATFORM, 0, IDENT_VERSION, SAVE_VERSION, MINOR_VERSION, BUILD_NUM, IDENT_RELTYPE);
|
||||||
|
|
||||||
|
/*#ifdef BETA
|
||||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "X-Powder-Version: %s%dB%d\n", IDENT_VERSION, SAVE_VERSION, MINOR_VERSION);
|
cx->tlen += sprintf(cx->tbuf+cx->tlen, "X-Powder-Version: %s%dB%d\n", IDENT_VERSION, SAVE_VERSION, MINOR_VERSION);
|
||||||
#else
|
#else
|
||||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "X-Powder-Version: %s%dS%d\n", IDENT_VERSION, SAVE_VERSION, MINOR_VERSION);
|
cx->tlen += sprintf(cx->tbuf+cx->tlen, "X-Powder-Version: %s%dS%d\n", IDENT_VERSION, SAVE_VERSION, MINOR_VERSION);
|
||||||
#endif
|
#endif*/
|
||||||
cx->tlen += sprintf(cx->tbuf+cx->tlen, "\n");
|
cx->tlen += sprintf(cx->tbuf+cx->tlen, "\n");
|
||||||
}
|
}
|
||||||
cx->state = HTS_XMIT;
|
cx->state = HTS_XMIT;
|
||||||
|
@ -33,6 +33,10 @@ GameModel::GameModel():
|
|||||||
menuList[sim->ptypes[i].menusection]->AddTool(tempTool);
|
menuList[sim->ptypes[i].menusection]->AddTool(tempTool);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Build menu for GOL types
|
||||||
|
//for(int i = 0; i < GOL_)
|
||||||
|
|
||||||
//Build other menus from wall data
|
//Build other menus from wall data
|
||||||
for(int i = 0; i < UI_WALLCOUNT; i++)
|
for(int i = 0; i < UI_WALLCOUNT; i++)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user