apparently Ximon hates const; a lot;
added a bunch of const everywhere, had to modify a few functions to be const-compliant
This commit is contained in:
parent
67c82ee283
commit
9183fa1755
10
src/Misc.cpp
10
src/Misc.cpp
@ -119,7 +119,7 @@ TPT_NO_INLINE float restrict_flt(float f, float min, float max) //TODO Inline or
|
|||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *mystrdup(char *s)
|
char *mystrdup(const char *s)
|
||||||
{
|
{
|
||||||
char *x;
|
char *x;
|
||||||
if (s)
|
if (s)
|
||||||
@ -128,7 +128,7 @@ char *mystrdup(char *s)
|
|||||||
strcpy(x, s);
|
strcpy(x, s);
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
return s;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void strlist_add(struct strlist **list, char *str)
|
void strlist_add(struct strlist **list, char *str)
|
||||||
@ -221,7 +221,7 @@ void strcaturl(char *dst, char *src)
|
|||||||
*d = 0;
|
*d = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void strappend(char *dst, char *src)
|
void strappend(char *dst, const char *src)
|
||||||
{
|
{
|
||||||
char *d;
|
char *d;
|
||||||
unsigned char *s;
|
unsigned char *s;
|
||||||
@ -465,7 +465,7 @@ int register_extension()
|
|||||||
#elif defined(LIN)
|
#elif defined(LIN)
|
||||||
char *currentfilename = exe_name();
|
char *currentfilename = exe_name();
|
||||||
FILE *f;
|
FILE *f;
|
||||||
char *mimedata =
|
const char *mimedata =
|
||||||
"<?xml version=\"1.0\"?>\n"
|
"<?xml version=\"1.0\"?>\n"
|
||||||
" <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>\n"
|
" <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>\n"
|
||||||
" <mime-type type=\"application/vnd.powdertoy.save\">\n"
|
" <mime-type type=\"application/vnd.powdertoy.save\">\n"
|
||||||
@ -480,7 +480,7 @@ int register_extension()
|
|||||||
fwrite(mimedata, 1, strlen(mimedata), f);
|
fwrite(mimedata, 1, strlen(mimedata), f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
char *desktopfiledata_tmp =
|
const char *desktopfiledata_tmp =
|
||||||
"[Desktop Entry]\n"
|
"[Desktop Entry]\n"
|
||||||
"Type=Application\n"
|
"Type=Application\n"
|
||||||
"Name=Powder Toy\n"
|
"Name=Powder Toy\n"
|
||||||
|
@ -40,7 +40,7 @@ unsigned clamp_flt(float f, float min, float max);
|
|||||||
|
|
||||||
float restrict_flt(float f, float min, float max);
|
float restrict_flt(float f, float min, float max);
|
||||||
|
|
||||||
char *mystrdup(char *s);
|
char *mystrdup(const char *s);
|
||||||
|
|
||||||
struct strlist
|
struct strlist
|
||||||
{
|
{
|
||||||
@ -64,11 +64,11 @@ void save_string(FILE *f, char *str);
|
|||||||
|
|
||||||
int load_string(FILE *f, char *str, int max);
|
int load_string(FILE *f, char *str, int max);
|
||||||
|
|
||||||
void strcaturl(char *dst, char *src);
|
void strcaturl(char *dst, const char *src);
|
||||||
|
|
||||||
std::string URLEscape(std::string source);
|
std::string URLEscape(std::string source);
|
||||||
|
|
||||||
void strappend(char *dst, char *src);
|
void strappend(char *dst, const char *src);
|
||||||
|
|
||||||
void *file_load(char *fn, int *size);
|
void *file_load(char *fn, int *size);
|
||||||
|
|
||||||
|
@ -687,7 +687,7 @@ bool SaveWindowPosition()
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void BlueScreen(char * detailMessage){
|
void BlueScreen(const char * detailMessage){
|
||||||
ui::Engine * engine = &ui::Engine::Ref();
|
ui::Engine * engine = &ui::Engine::Ref();
|
||||||
engine->g->fillrect(0, 0, engine->GetWidth(), engine->GetHeight(), 17, 114, 169, 210);
|
engine->g->fillrect(0, 0, engine->GetWidth(), engine->GetHeight(), 17, 114, 169, 210);
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ static int ( *oid_inc_func )( void ) = NULL;
|
|||||||
------------------------------ */
|
------------------------------ */
|
||||||
|
|
||||||
bson *bson_empty( bson *obj ) {
|
bson *bson_empty( bson *obj ) {
|
||||||
static char *data = "\005\0\0\0\0";
|
static char data[] = "\005\0\0\0\0";
|
||||||
bson_init_data( obj, data );
|
bson_init_data( obj, data );
|
||||||
obj->finished = 1;
|
obj->finished = 1;
|
||||||
obj->err = 0;
|
obj->err = 0;
|
||||||
|
@ -650,7 +650,7 @@ int luacon_step(int mx, int my, std::string selectl, std::string selectr, std::s
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int luacon_eval(char *command){
|
int luacon_eval(const char *command){
|
||||||
ui::Engine::Ref().LastTick(clock());
|
ui::Engine::Ref().LastTick(clock());
|
||||||
return luaL_dostring (luacon_ci->l, command);
|
return luaL_dostring (luacon_ci->l, command);
|
||||||
}
|
}
|
||||||
@ -1927,7 +1927,7 @@ int luatpt_getscript(lua_State* l)
|
|||||||
run_script = luaL_optint(l, 3, 0);
|
run_script = luaL_optint(l, 3, 0);
|
||||||
if(!fileauthor.length() || !fileid.length())
|
if(!fileauthor.length() || !fileid.length())
|
||||||
{
|
{
|
||||||
lastError = "Script Author or ID not given";
|
lastError = mystrdup("Script Author or ID not given");
|
||||||
goto fin;
|
goto fin;
|
||||||
}
|
}
|
||||||
if(!ConfirmPrompt::Blocking("Do you want to install script?", fileid, "Install"))
|
if(!ConfirmPrompt::Blocking("Do you want to install script?", fileid, "Install"))
|
||||||
@ -1941,12 +1941,12 @@ int luatpt_getscript(lua_State* l)
|
|||||||
|
|
||||||
if(len <= 0 || !filedata)
|
if(len <= 0 || !filedata)
|
||||||
{
|
{
|
||||||
lastError = "Server did not return data.";
|
strcpy(lastError, "Server did not return data.");
|
||||||
goto fin;
|
goto fin;
|
||||||
}
|
}
|
||||||
if(ret != 200)
|
if(ret != 200)
|
||||||
{
|
{
|
||||||
lastError = http_ret_text(ret);
|
lastError = mystrdup(http_ret_text(ret));
|
||||||
goto fin;
|
goto fin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1976,7 +1976,7 @@ int luatpt_getscript(lua_State* l)
|
|||||||
|
|
||||||
if(!outputfile)
|
if(!outputfile)
|
||||||
{
|
{
|
||||||
lastError = "Unable to write to file";
|
lastError = mystrdup("Unable to write to file");
|
||||||
goto fin;
|
goto fin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1998,7 +1998,11 @@ fin:
|
|||||||
if(luacommand) delete[] luacommand;
|
if(luacommand) delete[] luacommand;
|
||||||
luacommand = NULL;
|
luacommand = NULL;
|
||||||
|
|
||||||
if(lastError) return luaL_error(l, lastError);
|
if(lastError)
|
||||||
|
{
|
||||||
|
return luaL_error(l, lastError);
|
||||||
|
free(lastError);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ void luacon_hook(lua_State *L, lua_Debug *ar);
|
|||||||
int luacon_step(int mx, int my, std::string , std::string selectr, std::string selectedalt, int bsx, int bsy);
|
int luacon_step(int mx, int my, std::string , std::string selectr, std::string selectedalt, int bsx, int bsy);
|
||||||
int luacon_mouseevent(int mx, int my, int mb, int event, int mouse_wheel);
|
int luacon_mouseevent(int mx, int my, int mb, int event, int mouse_wheel);
|
||||||
int luacon_keyevent(int key, int modifier, int event);
|
int luacon_keyevent(int key, int modifier, int event);
|
||||||
int luacon_eval(char *command);
|
int luacon_eval(const char *command);
|
||||||
char *luacon_geterror();
|
char *luacon_geterror();
|
||||||
void luacon_close();
|
void luacon_close();
|
||||||
int luacon_partsread(lua_State* l);
|
int luacon_partsread(lua_State* l);
|
||||||
|
@ -333,7 +333,7 @@ bool Client::DoInstallation()
|
|||||||
|
|
||||||
char *currentfilename = exe_name();
|
char *currentfilename = exe_name();
|
||||||
FILE *f;
|
FILE *f;
|
||||||
char *mimedata =
|
const char *mimedata =
|
||||||
"<?xml version=\"1.0\"?>\n"
|
"<?xml version=\"1.0\"?>\n"
|
||||||
" <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>\n"
|
" <mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>\n"
|
||||||
" <mime-type type=\"application/vnd.powdertoy.save\">\n"
|
" <mime-type type=\"application/vnd.powdertoy.save\">\n"
|
||||||
@ -348,7 +348,7 @@ bool Client::DoInstallation()
|
|||||||
fwrite(mimedata, 1, strlen(mimedata), f);
|
fwrite(mimedata, 1, strlen(mimedata), f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
char *protocolfiledata_tmp =
|
const char *protocolfiledata_tmp =
|
||||||
"[Desktop Entry]\n"
|
"[Desktop Entry]\n"
|
||||||
"Type=Application\n"
|
"Type=Application\n"
|
||||||
"Name=Powder Toy\n"
|
"Name=Powder Toy\n"
|
||||||
@ -367,7 +367,7 @@ bool Client::DoInstallation()
|
|||||||
fclose(f);
|
fclose(f);
|
||||||
system("xdg-desktop-menu install powdertoy-tpt-ptsave.desktop");
|
system("xdg-desktop-menu install powdertoy-tpt-ptsave.desktop");
|
||||||
|
|
||||||
char *desktopfiledata_tmp =
|
const char *desktopfiledata_tmp =
|
||||||
"[Desktop Entry]\n"
|
"[Desktop Entry]\n"
|
||||||
"Type=Application\n"
|
"Type=Application\n"
|
||||||
"Name=Powder Toy\n"
|
"Name=Powder Toy\n"
|
||||||
@ -893,8 +893,8 @@ RequestStatus Client::UploadSave(SaveInfo & save)
|
|||||||
char *session = new char[authUser.SessionID.length() + 1];
|
char *session = new char[authUser.SessionID.length() + 1];
|
||||||
std::strcpy (session, authUser.SessionID.c_str());
|
std::strcpy (session, authUser.SessionID.c_str());
|
||||||
|
|
||||||
char * postNames[] = { "Name", "Description", "Data:save.bin", "Publish", NULL };
|
const char *const postNames[] = { "Name", "Description", "Data:save.bin", "Publish", NULL };
|
||||||
char * postDatas[] = { saveName, saveDescription, gameData, (char *)(save.GetPublished()?"Public":"Private") };
|
const char *const postDatas[] = { saveName, saveDescription, gameData, (char *)(save.GetPublished()?"Public":"Private") };
|
||||||
int postLengths[] = { save.GetName().length(), save.GetDescription().length(), gameDataLength, save.GetPublished()?6:7 };
|
int postLengths[] = { save.GetName().length(), save.GetDescription().length(), gameDataLength, save.GetPublished()?6:7 };
|
||||||
//std::cout << postNames[0] << " " << postDatas[0] << " " << postLengths[0] << std::endl;
|
//std::cout << postNames[0] << " " << postDatas[0] << " " << postLengths[0] << std::endl;
|
||||||
data = http_multipart_post("http://" SERVER "/Save.api", postNames, postDatas, postLengths, userid, NULL, session, &dataStatus, &dataLength);
|
data = http_multipart_post("http://" SERVER "/Save.api", postNames, postDatas, postLengths, userid, NULL, session, &dataStatus, &dataLength);
|
||||||
@ -1120,8 +1120,8 @@ RequestStatus Client::ExecVote(int saveID, int direction)
|
|||||||
char *session = new char[authUser.SessionID.length() + 1];
|
char *session = new char[authUser.SessionID.length() + 1];
|
||||||
std::strcpy (session, authUser.SessionID.c_str());
|
std::strcpy (session, authUser.SessionID.c_str());
|
||||||
|
|
||||||
char * postNames[] = { "ID", "Action", NULL };
|
const char *const postNames[] = { "ID", "Action", NULL };
|
||||||
char * postDatas[] = { id, directionText };
|
const char *const postDatas[] = { id, directionText };
|
||||||
int postLengths[] = { saveIDText.length(), strlen(directionText) };
|
int postLengths[] = { saveIDText.length(), strlen(directionText) };
|
||||||
//std::cout << postNames[0] << " " << postDatas[0] << " " << postLengths[0] << std::endl;
|
//std::cout << postNames[0] << " " << postDatas[0] << " " << postLengths[0] << std::endl;
|
||||||
data = http_multipart_post("http://" SERVER "/Vote.api", postNames, postDatas, postLengths, userid, NULL, session, &dataStatus, &dataLength);
|
data = http_multipart_post("http://" SERVER "/Vote.api", postNames, postDatas, postLengths, userid, NULL, session, &dataStatus, &dataLength);
|
||||||
@ -1303,8 +1303,8 @@ LoginStatus Client::Login(std::string username, std::string password, User & use
|
|||||||
|
|
||||||
char * data;
|
char * data;
|
||||||
int dataStatus, dataLength;
|
int dataStatus, dataLength;
|
||||||
char * postNames[] = { "Username", "Hash", NULL };
|
const char *const postNames[] = { "Username", "Hash", NULL };
|
||||||
char * postDatas[] = { (char*)username.c_str(), totalHash };
|
const char *const postDatas[] = { (char*)username.c_str(), totalHash };
|
||||||
int postLengths[] = { username.length(), 32 };
|
int postLengths[] = { username.length(), 32 };
|
||||||
data = http_multipart_post("http://" SERVER "/Login.json", postNames, postDatas, postLengths, NULL, NULL, NULL, &dataStatus, &dataLength);
|
data = http_multipart_post("http://" SERVER "/Login.json", postNames, postDatas, postLengths, NULL, NULL, NULL, &dataStatus, &dataLength);
|
||||||
if(dataStatus == 200 && data)
|
if(dataStatus == 200 && data)
|
||||||
@ -1432,8 +1432,8 @@ RequestStatus Client::AddComment(int saveID, std::string comment)
|
|||||||
std::stringstream userIDStream;
|
std::stringstream userIDStream;
|
||||||
userIDStream << authUser.ID;
|
userIDStream << authUser.ID;
|
||||||
|
|
||||||
char * postNames[] = { "Comment", NULL };
|
const char *const postNames[] = { "Comment", NULL };
|
||||||
char * postDatas[] = { (char*)(comment.c_str()) };
|
const char *const postDatas[] = { (char*)(comment.c_str()) };
|
||||||
int postLengths[] = { comment.length() };
|
int postLengths[] = { comment.length() };
|
||||||
data = http_multipart_post((char *)urlStream.str().c_str(), postNames, postDatas, postLengths, (char *)(userIDStream.str().c_str()), NULL, (char *)(authUser.SessionID.c_str()), &dataStatus, &dataLength);
|
data = http_multipart_post((char *)urlStream.str().c_str(), postNames, postDatas, postLengths, (char *)(userIDStream.str().c_str()), NULL, (char *)(authUser.SessionID.c_str()), &dataStatus, &dataLength);
|
||||||
}
|
}
|
||||||
@ -1548,8 +1548,8 @@ RequestStatus Client::ReportSave(int saveID, std::string message)
|
|||||||
std::stringstream userIDStream;
|
std::stringstream userIDStream;
|
||||||
userIDStream << authUser.ID;
|
userIDStream << authUser.ID;
|
||||||
|
|
||||||
char * postNames[] = { "Reason", NULL };
|
const char *const postNames[] = { "Reason", NULL };
|
||||||
char * postDatas[] = { (char*)(message.c_str()) };
|
const char *const postDatas[] = { (char*)(message.c_str()) };
|
||||||
int postLengths[] = { message.length() };
|
int postLengths[] = { message.length() };
|
||||||
data = http_multipart_post((char *)urlStream.str().c_str(), postNames, postDatas, postLengths, (char *)(userIDStream.str().c_str()), NULL, (char *)(authUser.SessionID.c_str()), &dataStatus, &dataLength);
|
data = http_multipart_post((char *)urlStream.str().c_str(), postNames, postDatas, postLengths, (char *)(userIDStream.str().c_str()), NULL, (char *)(authUser.SessionID.c_str()), &dataStatus, &dataLength);
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
#include "Misc.h"
|
||||||
#include "HTTP.h"
|
#include "HTTP.h"
|
||||||
#include "MD5.h"
|
#include "MD5.h"
|
||||||
|
|
||||||
@ -87,34 +88,25 @@ static char * eatwhitespace(char * s)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *mystrdup(char *s)
|
static int splituri(const char *uri, char **host, char **path)
|
||||||
{
|
{
|
||||||
char *x;
|
const char *q;
|
||||||
if (s)
|
char *x,*y;
|
||||||
{
|
if (!strncmp(uri, "http://", 7))
|
||||||
x = (char *)malloc(strlen(s)+1);
|
uri += 7;
|
||||||
strcpy(x, s);
|
q = strchr(uri, '/');
|
||||||
return x;
|
|
||||||
}
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int splituri(char *uri, char **host, char **path)
|
|
||||||
{
|
|
||||||
char *p=uri,*q,*x,*y;
|
|
||||||
if (!strncmp(p, "http://", 7))
|
|
||||||
p += 7;
|
|
||||||
q = strchr(p, '/');
|
|
||||||
if (!q)
|
if (!q)
|
||||||
q = p + strlen(p);
|
q = uri + strlen(uri);
|
||||||
x = (char *)malloc(q-p+1);
|
x = (char *)malloc(q-uri+1);
|
||||||
if (*q)
|
if (*q)
|
||||||
y = mystrdup(q);
|
y = mystrdup(q);
|
||||||
else
|
else
|
||||||
|
{
|
||||||
y = mystrdup("/");
|
y = mystrdup("/");
|
||||||
strncpy(x, p, q-p);
|
}
|
||||||
x[q-p] = 0;
|
strncpy(x, uri, q-uri);
|
||||||
if (q==p || x[q-p-1]==':')
|
x[q-uri] = 0;
|
||||||
|
if (q==uri || x[q-uri-1]==':')
|
||||||
{
|
{
|
||||||
free(x);
|
free(x);
|
||||||
free(y);
|
free(y);
|
||||||
@ -244,7 +236,7 @@ struct http_ctx
|
|||||||
int fd;
|
int fd;
|
||||||
char *fdhost;
|
char *fdhost;
|
||||||
};
|
};
|
||||||
void *http_async_req_start(void *ctx, char *uri, char *data, int dlen, int keep)
|
void *http_async_req_start(void *ctx, const char *uri, const char *data, int dlen, int keep)
|
||||||
{
|
{
|
||||||
struct http_ctx *cx = (http_ctx *)ctx;
|
struct http_ctx *cx = (http_ctx *)ctx;
|
||||||
if (!ctx)
|
if (!ctx)
|
||||||
@ -319,7 +311,7 @@ void *http_async_req_start(void *ctx, char *uri, char *data, int dlen, int keep)
|
|||||||
return ctx;
|
return ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
void http_async_add_header(void *ctx, char *name, char *data)
|
void http_async_add_header(void *ctx, const char *name, const char *data)
|
||||||
{
|
{
|
||||||
struct http_ctx *cx = (http_ctx *)ctx;
|
struct http_ctx *cx = (http_ctx *)ctx;
|
||||||
cx->thdr = (char *)realloc(cx->thdr, cx->thlen + strlen(name) + strlen(data) + 5);
|
cx->thdr = (char *)realloc(cx->thdr, cx->thlen + strlen(name) + strlen(data) + 5);
|
||||||
@ -694,7 +686,7 @@ void http_async_req_close(void *ctx)
|
|||||||
free(ctx);
|
free(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *http_simple_get(char *uri, int *ret, int *len)
|
char *http_simple_get(const char *uri, int *ret, int *len)
|
||||||
{
|
{
|
||||||
void *ctx = http_async_req_start(NULL, uri, NULL, 0, 0);
|
void *ctx = http_async_req_start(NULL, uri, NULL, 0, 0);
|
||||||
if (!ctx)
|
if (!ctx)
|
||||||
@ -707,7 +699,7 @@ char *http_simple_get(char *uri, int *ret, int *len)
|
|||||||
}
|
}
|
||||||
return http_async_req_stop(ctx, ret, len);
|
return http_async_req_stop(ctx, ret, len);
|
||||||
}
|
}
|
||||||
void http_auth_headers(void *ctx, char *user, char *pass, char *session_id)
|
void http_auth_headers(void *ctx, const char *user, const char *pass, const char *session_id)
|
||||||
{
|
{
|
||||||
char *tmp;
|
char *tmp;
|
||||||
int i;
|
int i;
|
||||||
@ -747,7 +739,7 @@ void http_auth_headers(void *ctx, char *user, char *pass, char *session_id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
char *http_auth_get(char *uri, char *user, char *pass, char *session_id, int *ret, int *len)
|
char *http_auth_get(const char *uri, const char *user, const char *pass, const char *session_id, int *ret, int *len)
|
||||||
{
|
{
|
||||||
void *ctx = http_async_req_start(NULL, uri, NULL, 0, 0);
|
void *ctx = http_async_req_start(NULL, uri, NULL, 0, 0);
|
||||||
|
|
||||||
@ -763,7 +755,7 @@ char *http_auth_get(char *uri, char *user, char *pass, char *session_id, int *re
|
|||||||
return http_async_req_stop(ctx, ret, len);
|
return http_async_req_stop(ctx, ret, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *http_simple_post(char *uri, char *data, int dlen, int *ret, int *len)
|
char *http_simple_post(const char *uri, const char *data, int dlen, int *ret, int *len)
|
||||||
{
|
{
|
||||||
void *ctx = http_async_req_start(NULL, uri, data, dlen, 0);
|
void *ctx = http_async_req_start(NULL, uri, data, dlen, 0);
|
||||||
if (!ctx)
|
if (!ctx)
|
||||||
@ -777,7 +769,7 @@ char *http_simple_post(char *uri, char *data, int dlen, int *ret, int *len)
|
|||||||
return http_async_req_stop(ctx, ret, len);
|
return http_async_req_stop(ctx, ret, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *http_ret_text(int ret)
|
const char *http_ret_text(int ret)
|
||||||
{
|
{
|
||||||
switch (ret)
|
switch (ret)
|
||||||
{
|
{
|
||||||
@ -914,10 +906,10 @@ char *http_ret_text(int ret)
|
|||||||
return "Unknown Status Code";
|
return "Unknown Status Code";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
char *http_multipart_post(char *uri, char **names, char **parts, int *plens, char *user, char *pass, char *session_id, int *ret, int *len)
|
char *http_multipart_post(const char *uri, const char *const *names, const char *const *parts, int *plens, const char *user, const char *pass, const char *session_id, int *ret, int *len)
|
||||||
{
|
{
|
||||||
void *ctx;
|
void *ctx;
|
||||||
char *data = NULL, *tmp, *p;
|
char *data = NULL, *tmp;
|
||||||
int dlen = 0, i, j;
|
int dlen = 0, i, j;
|
||||||
unsigned char hash[16];
|
unsigned char hash[16];
|
||||||
unsigned char boundary[32], ch;
|
unsigned char boundary[32], ch;
|
||||||
@ -987,12 +979,11 @@ retry:
|
|||||||
if (strchr(names[i], ':'))
|
if (strchr(names[i], ':'))
|
||||||
{
|
{
|
||||||
tmp = mystrdup(names[i]);
|
tmp = mystrdup(names[i]);
|
||||||
p = strchr(tmp, ':');
|
char *p = strchr(tmp, ':');
|
||||||
*p = 0;
|
*p = 0;
|
||||||
dlen += sprintf(data+dlen, "content-disposition: form-data; name=\"%s\"; ", tmp);
|
dlen += sprintf(data+dlen, "content-disposition: form-data; name=\"%s\"; ", tmp);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
p = strchr(names[i], ':');
|
dlen += sprintf(data+dlen, "filename=\"%s\"\r\n\r\n", strchr(names[i], ':')+1);
|
||||||
dlen += sprintf(data+dlen, "filename=\"%s\"\r\n\r\n", p+1);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
dlen += sprintf(data+dlen, "content-disposition: form-data; name=\"%s\"\r\n\r\n", names[i]);
|
dlen += sprintf(data+dlen, "content-disposition: form-data; name=\"%s\"\r\n\r\n", names[i]);
|
||||||
@ -1022,7 +1013,7 @@ retry:
|
|||||||
{
|
{
|
||||||
//md5_update(&md5, (unsigned char *)parts[i], plens[i]); //WHY?
|
//md5_update(&md5, (unsigned char *)parts[i], plens[i]); //WHY?
|
||||||
//md5_update(&md5, (unsigned char *)"-", 1);
|
//md5_update(&md5, (unsigned char *)"-", 1);
|
||||||
p = strchr(names[i], ':');
|
const char *p = strchr(names[i], ':');
|
||||||
if (p)
|
if (p)
|
||||||
m += (p - names[i]) + 1;
|
m += (p - names[i]) + 1;
|
||||||
else
|
else
|
||||||
@ -1033,7 +1024,7 @@ retry:
|
|||||||
m = 0;
|
m = 0;
|
||||||
for (i=0; names[i]; i++)
|
for (i=0; names[i]; i++)
|
||||||
{
|
{
|
||||||
p = strchr(names[i], ':');
|
const char *p = strchr(names[i], ':');
|
||||||
if (m)
|
if (m)
|
||||||
{
|
{
|
||||||
tmp[m] = ' ';
|
tmp[m] = ' ';
|
||||||
@ -1104,10 +1095,10 @@ fail:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void *http_multipart_post_async(char *uri, char **names, char **parts, int *plens, char *user, char *pass, char *session_id)
|
void *http_multipart_post_async(const char *uri, const char *const *names, const char *const *parts, int *plens, const char *user, const char *pass, const char *session_id)
|
||||||
{
|
{
|
||||||
void *ctx;
|
void *ctx;
|
||||||
char *data = NULL, *tmp, *p;
|
char *data = NULL, *tmp;
|
||||||
int dlen = 0, i, j;
|
int dlen = 0, i, j;
|
||||||
unsigned char hash[16];
|
unsigned char hash[16];
|
||||||
unsigned char boundary[32], ch;
|
unsigned char boundary[32], ch;
|
||||||
@ -1177,12 +1168,11 @@ retry:
|
|||||||
if (strchr(names[i], ':'))
|
if (strchr(names[i], ':'))
|
||||||
{
|
{
|
||||||
tmp = mystrdup(names[i]);
|
tmp = mystrdup(names[i]);
|
||||||
p = strchr(tmp, ':');
|
char *p = strchr(tmp, ':');
|
||||||
*p = 0;
|
*p = 0;
|
||||||
dlen += sprintf(data+dlen, "content-disposition: form-data; name=\"%s\"; ", tmp);
|
dlen += sprintf(data+dlen, "content-disposition: form-data; name=\"%s\"; ", tmp);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
p = strchr(names[i], ':');
|
dlen += sprintf(data+dlen, "filename=\"%s\"\r\n\r\n", strchr(names[i], ':')+1);
|
||||||
dlen += sprintf(data+dlen, "filename=\"%s\"\r\n\r\n", p+1);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
dlen += sprintf(data+dlen, "content-disposition: form-data; name=\"%s\"\r\n\r\n", names[i]);
|
dlen += sprintf(data+dlen, "content-disposition: form-data; name=\"%s\"\r\n\r\n", names[i]);
|
||||||
@ -1212,7 +1202,7 @@ retry:
|
|||||||
{
|
{
|
||||||
//md5_update(&md5, (unsigned char *)parts[i], plens[i]); //WHY?
|
//md5_update(&md5, (unsigned char *)parts[i], plens[i]); //WHY?
|
||||||
//md5_update(&md5, (unsigned char *)"-", 1);
|
//md5_update(&md5, (unsigned char *)"-", 1);
|
||||||
p = strchr(names[i], ':');
|
const char *p = strchr(names[i], ':');
|
||||||
if (p)
|
if (p)
|
||||||
m += (p - names[i]) + 1;
|
m += (p - names[i]) + 1;
|
||||||
else
|
else
|
||||||
@ -1223,7 +1213,7 @@ retry:
|
|||||||
m = 0;
|
m = 0;
|
||||||
for (i=0; names[i]; i++)
|
for (i=0; names[i]; i++)
|
||||||
{
|
{
|
||||||
p = strchr(names[i], ':');
|
const char *p = strchr(names[i], ':');
|
||||||
if (m)
|
if (m)
|
||||||
{
|
{
|
||||||
tmp[m] = ' ';
|
tmp[m] = ' ';
|
||||||
|
@ -25,22 +25,22 @@ static char hexChars[] = "0123456789abcdef";
|
|||||||
void http_init(char *proxy);
|
void http_init(char *proxy);
|
||||||
void http_done(void);
|
void http_done(void);
|
||||||
|
|
||||||
char *http_simple_get(char *uri, int *ret, int *len);
|
char *http_simple_get(const char *uri, int *ret, int *len);
|
||||||
char *http_auth_get(char *uri, char *user, char *pass, char * session_id, int *ret, int *len);
|
char *http_auth_get(const char *uri, const char *user, const char *pass, const char *session_id, int *ret, int *len);
|
||||||
char *http_simple_post(char *uri, char *data, int dlen, int *ret, int *len);
|
char *http_simple_post(const char *uri, const char *data, int dlen, int *ret, int *len);
|
||||||
|
|
||||||
void http_auth_headers(void *ctx, char *user, char *pass, char * session_id);
|
void http_auth_headers(void *ctx, const char *user, const char *pass, const char *session_id);
|
||||||
|
|
||||||
void *http_async_req_start(void *ctx, char *uri, char *data, int dlen, int keep);
|
void *http_async_req_start(void *ctx, const char *uri, const char *data, int dlen, int keep);
|
||||||
void http_async_add_header(void *ctx, char *name, char *data);
|
void http_async_add_header(void *ctx, const char *name, const char *data);
|
||||||
int http_async_req_status(void *ctx);
|
int http_async_req_status(void *ctx);
|
||||||
void http_async_get_length(void *ctx, int *total, int *done);
|
void http_async_get_length(void *ctx, int *total, int *done);
|
||||||
char *http_async_req_stop(void *ctx, int *ret, int *len);
|
char *http_async_req_stop(void *ctx, int *ret, int *len);
|
||||||
void http_async_req_close(void *ctx);
|
void http_async_req_close(void *ctx);
|
||||||
|
|
||||||
char *http_multipart_post(char *uri, char **names, char **parts, int *plens, char *user, char *pass, char * session_id, int *ret, int *len);
|
char *http_multipart_post(const char *uri, const char *const *names, const char *const *parts, int *plens, const char *user, const char *pass, const char * session_id, int *ret, int *len);
|
||||||
void *http_multipart_post_async(char *uri, char **names, char **parts, int *plens, char *user, char *pass, char * session_id);
|
void *http_multipart_post_async(const char *uri, const char *const *names, const char *const *parts, int *plens, const char *user, const char *pass, const char *session_id);
|
||||||
|
|
||||||
char *http_ret_text(int ret);
|
const char *http_ret_text(int ret);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
struct menu_section
|
struct menu_section
|
||||||
{
|
{
|
||||||
char *icon;
|
const char *icon;
|
||||||
const char *name;
|
const char *name;
|
||||||
int itemcount;
|
int itemcount;
|
||||||
int doshow;
|
int doshow;
|
||||||
|
@ -12,8 +12,8 @@ struct Particle;
|
|||||||
class Element
|
class Element
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
char *Identifier;
|
const char *Identifier;
|
||||||
char *Name;
|
const char *Name;
|
||||||
pixel Colour;
|
pixel Colour;
|
||||||
float Advection;
|
float Advection;
|
||||||
float AirDrag;
|
float AirDrag;
|
||||||
@ -34,7 +34,7 @@ public:
|
|||||||
int MenuSection;
|
int MenuSection;
|
||||||
float Temperature;
|
float Temperature;
|
||||||
unsigned char HeatConduct;
|
unsigned char HeatConduct;
|
||||||
char *Description;
|
const char *Description;
|
||||||
char State;
|
char State;
|
||||||
unsigned int Properties;
|
unsigned int Properties;
|
||||||
int (*Update) (UPDATE_FUNC_ARGS);
|
int (*Update) (UPDATE_FUNC_ARGS);
|
||||||
|
@ -10,10 +10,10 @@ struct Particle;
|
|||||||
class SimTool
|
class SimTool
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
char *Identifier;
|
const char *Identifier;
|
||||||
char *Name;
|
const char *Name;
|
||||||
pixel Colour;
|
pixel Colour;
|
||||||
char *Description;
|
const char *Description;
|
||||||
|
|
||||||
SimTool();
|
SimTool();
|
||||||
virtual ~SimTool() {}
|
virtual ~SimTool() {}
|
||||||
|
Loading…
Reference in New Issue
Block a user