|
@@ -53,7 +53,6 @@ static LRESULT CALLBACK websWindProc(HWND hwnd, UINT msg, UINT wp, LPARAM lp);
|
|
|
#if ME_UNIX_LIKE
|
|
|
static void sigHandler(int signo);
|
|
|
#endif
|
|
|
-static void uploadTest(Webs *wp);
|
|
|
/*********************************** Code *************************************/
|
|
|
|
|
|
MAIN(goahead, int argc, char **argv, char **envp)
|
|
@@ -202,21 +201,12 @@ websDefineAction("addUser", addUser);
|
|
|
websDefineAction("delUser", delUser);
|
|
|
|
|
|
//update firmware
|
|
|
-websDefineAction("uploadTest", uploadTest);
|
|
|
+// websDefineAction("uploadTest", uploadTest);
|
|
|
websDefineAction("prepareDevice", prepareDevice);
|
|
|
websDefineAction("uploadFirmware", uploadFirmware);
|
|
|
websDefineAction("updateFlash", updateFlash);
|
|
|
websDefineAction("getUpdateProgress", getUpdateProgress);
|
|
|
websDefineAction("resetBmc", resetBmc);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
/**************** user code after goahead end************************/
|
|
|
|
|
|
#if ME_UNIX_LIKE && !MACOSX
|
|
@@ -242,93 +232,6 @@ websDefineAction("resetBmc", resetBmc);
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-// typedef struct{
|
|
|
-// char buf[1024*1000];
|
|
|
-// char filename[32];
|
|
|
-// int fileSize;
|
|
|
-// } filestruct;
|
|
|
-
|
|
|
-// //这个函数是把16进制字符串转换成16进制
|
|
|
-
|
|
|
-// int StringToHex(char *str, unsigned char *out, unsigned int *outlen)
|
|
|
-// {
|
|
|
-// char *p = str;
|
|
|
-// char high = 0, low = 0;
|
|
|
-// int tmplen = strlen(p), cnt = 0;
|
|
|
-// tmplen = strlen(p);
|
|
|
-// while(cnt < (tmplen / 2))
|
|
|
-// {
|
|
|
-// high = ((*p > '9') && ((*p <= 'F') || (*p <= 'f'))) ? *p - 48 - 7 : *p - 48;
|
|
|
-// low = (*(++ p) > '9' && ((*p <= 'F') || (*p <= 'f'))) ? *(p) - 48 - 7 : *(p) - 48;
|
|
|
-// out[cnt] = ((high & 0x0f) << 4 | (low & 0x0f));
|
|
|
-// p ++;
|
|
|
-// cnt ++;
|
|
|
-// }
|
|
|
-// if(tmplen % 2 != 0) out[cnt] = ((*p > '9') && ((*p <= 'F') || (*p <= 'f'))) ? *p - 48 - 7 : *p - 48;
|
|
|
-
|
|
|
-// if(outlen != NULL) *outlen = tmplen / 2 + tmplen % 2;
|
|
|
-// return tmplen / 2 + tmplen % 2;
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-static void uploadTest(Webs *wp)
|
|
|
-{
|
|
|
- WebsKey *s;
|
|
|
- WebsUpload *up;
|
|
|
- char *upfile;
|
|
|
- websSetStatus(wp, 200);
|
|
|
- websWriteHeaders(wp, -1, 0);
|
|
|
- websWriteHeader(wp, "Content-Type", "text/plain");
|
|
|
- websWriteEndHeaders(wp);
|
|
|
- if (scaselessmatch(wp->method, "POST")) {
|
|
|
- for (s = hashFirst(wp->files); s; s = hashNext(wp->files, s)) {
|
|
|
- up = s->content.value.symbol;
|
|
|
- websWrite(wp, "FILE: %s\r\n", s->name.value.string);
|
|
|
- websWrite(wp, "FILENAME=%s\r\n", up->filename);
|
|
|
- websWrite(wp, "CLIENT=%s\r\n", up->clientFilename);
|
|
|
- websWrite(wp, "TYPE=%s\r\n", up->contentType);
|
|
|
- websWrite(wp, "SIZE=%d\r\n", up->size);
|
|
|
- upfile = sfmt("%s/tmp/%s", websGetDocuments(), "gd32450i-eval.uImage");
|
|
|
- printf("<<<<<<<<<<<%s>>>>>>>>>>\n", upfile);
|
|
|
- if (rename(up->filename, upfile) < 0) {
|
|
|
- error("Cannot rename uploaded file: %s to %s, errno %d", up->filename, upfile, errno);
|
|
|
- }
|
|
|
- wfree(upfile);
|
|
|
- }
|
|
|
- websWrite(wp, "\r\nVARS:\r\n");
|
|
|
- for (s = hashFirst(wp->vars); s; s = hashNext(wp->vars, s)) {
|
|
|
- websWrite(wp, "%s=%s\r\n", s->name.value.string, s->content.value.string);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- char *pStr;
|
|
|
- cJSON * root = cJSON_CreateObject();
|
|
|
- cJSON * data = cJSON_CreateObject();
|
|
|
- cJSON_AddItemToObject(root, "data", data);//根节点下添加
|
|
|
- cJSON_AddStringToObject(root, "msg", "");
|
|
|
- cJSON_AddNumberToObject(root, "code", 200);
|
|
|
-
|
|
|
-
|
|
|
- pStr = cJSON_PrintUnformatted(root);
|
|
|
-
|
|
|
- printf("---> cJSON Str:\n%s\n", pStr);
|
|
|
- websSetStatus(wp, 200);
|
|
|
- websWriteHeaders(wp, -1, 0);
|
|
|
- websWriteEndHeaders(wp);
|
|
|
- websWrite(wp,"%s", pStr);
|
|
|
- websFlush(wp, 0);
|
|
|
- // websDone(wp);
|
|
|
-
|
|
|
- if(pStr)
|
|
|
- wfree(pStr);
|
|
|
- if(root)
|
|
|
- cJSON_Delete(root);
|
|
|
-
|
|
|
- websDone(wp);
|
|
|
-}
|
|
|
|
|
|
static void logHeader()
|
|
|
{
|