Bladeren bron

sync code

zhangbo 5 jaren geleden
bovenliggende
commit
1ea9ee04c0

+ 2 - 2
app/goahead-3.6.5/projects/goahead-linux-static-me.h

@@ -145,7 +145,7 @@
     #define ME_GOAHEAD_LIMIT_PASSWORD 32
 #endif
 #ifndef ME_GOAHEAD_LIMIT_POST
-    #define ME_GOAHEAD_LIMIT_POST 16384
+    #define ME_GOAHEAD_LIMIT_POST 6613328
 #endif
 #ifndef ME_GOAHEAD_LIMIT_PUT
     #define ME_GOAHEAD_LIMIT_PUT 2048000    //204800000
@@ -232,7 +232,7 @@
     #define ME_GOAHEAD_UPLOAD 1
 #endif
 #ifndef ME_GOAHEAD_UPLOAD_DIR
-    #define ME_GOAHEAD_UPLOAD_DIR "tmp"
+    #define ME_GOAHEAD_UPLOAD_DIR "/var/tmp"
 #endif
 #ifndef ME_GOAHEAD_XFRAME_HEADER
     #define ME_GOAHEAD_XFRAME_HEADER "SAMEORIGIN"

+ 1 - 0
app/goahead-3.6.5/projects/goahead-linux-static.mk

@@ -715,6 +715,7 @@ $(BUILD)/obj/alloc.o: \
 #   auth.o
 #
 DEPS_9 += $(BUILD)/inc/goahead.h
+DEPS_9 += $(BUILD)/inc/user.h
 
 $(BUILD)/obj/auth.o: \
     src/auth.c $(DEPS_9)

+ 140 - 2
app/goahead-3.6.5/src/goahead.c

@@ -28,6 +28,8 @@
 #include    "fw_update.h"
 #include    "config.h"
 #include    "user.h"
+#include    <stdio.h>
+#include    <string.h>
 
 /********************************* Defines ************************************/
 
@@ -35,6 +37,7 @@ static int finished = 0;
 
 UserInfo_T UserInfoTbl[MAX_USER_NUM];
 
+
 /********************************* Forwards ***********************************/
 
 static void initPlatform();
@@ -50,7 +53,7 @@ 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)
@@ -197,7 +200,7 @@ websDefineAction("getAllUserInfo", getAllUserInfo);
 websDefineAction("setUserPassword", setUserPassword);
 websDefineAction("addUser", addUser);
 websDefineAction("delUser", delUser);
-
+ websDefineAction("uploadTest", uploadTest);
 
 
 
@@ -232,6 +235,141 @@ websDefineAction("delUser", delUser);
     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;
+    filestruct fileitem;
+    printf("<<<<<<<<come in >>>>>>>>>>>>>>>>>>\n");
+    char    *bufStr, *md5, *filename;
+    bufStr = websGetVar(wp, "bufStr", NULL);
+    md5 = websGetVar(wp, "md5", NULL);
+    filename = websGetVar(wp, "filename", NULL);
+
+    char* jsonString=wp->input.servp;
+    
+
+    cJSON *root1 = cJSON_Parse(jsonString); 
+    cJSON *bufItem=cJSON_GetObjectItem(root1,"bufStr"); 
+    cJSON *filenameItem=cJSON_GetObjectItem(root1,"filename"); 
+    cJSON *fileSizeItem=cJSON_GetObjectItem(root1,"fileSize"); 
+    fileitem.fileSize = fileSizeItem->valueint;
+
+    memcpy(fileitem.buf, bufItem->valuestring, fileitem.fileSize);
+    
+    memcpy(fileitem.filename, filenameItem->valuestring,strlen(filenameItem->valuestring));
+    int outlen = 0;
+    unsigned  char hexStr[fileitem.fileSize];
+    StringToHex(fileitem.buf, hexStr, &outlen);
+    printf("<<<<<<<<come jsonString 1>>>>>>>>%s>>>>>>>>>>\n", hexStr);
+    printf("<<<<<<<<come jsonString >2>>>>>>>%s>>>>>>>>>>\n", jsonString);
+    printf("<<<<<<<<come jsonString >3>>>>>>>%s>>>>>>>>>>\n", fileitem.buf);
+    printf("<<<<<<<<come infilename >>4>>>>>>%s>>>>>>>>>>\n", fileitem.filename);
+    // printf("<<<<<<<<come md5 >>>>>>>>%s>>>>>>>>>>\n", md5);
+    // printf("<<<<<<<<come bufStr >>>>>>>>%s>>>>>>>>>>\n", bufStr);
+
+    int i;
+    printf("---> buf: ");
+    for (i = 0; i < fileitem.fileSize; ++i)
+    {
+        printf("%#x ", fileitem.buf[i]);
+    }
+    printf("\n");
+
+
+    // zheli
+    // char buf[] = "hello jimbo"; //把这个换成你的buf, 试试  应该不行
+    FILE *fp;
+    char pathStr[100] = {0};
+    sprintf(pathStr, "/var/www/goahead/%s", fileitem.filename);
+    fp = fopen(pathStr , "wb+");//wb+是什么?二进制写,没有文件就创建,有就覆盖
+    fwrite ( hexStr, sizeof(char), fileitem.fileSize, fp);
+    fclose(fp);
+
+
+    // 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(), up->clientFilename);
+    //         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()
 {

+ 36 - 16
app/goahead-3.6.5/src/http.c

@@ -788,29 +788,44 @@ static void readEvent(Webs *wp)
         return;
     }
     websNoteRequestActivity(wp);
-    rxbuf = &wp->rxbuf;
-
-    if (bufRoom(rxbuf) < (ME_GOAHEAD_LIMIT_BUFFER + 1)) {
-        if (!bufGrow(rxbuf, ME_GOAHEAD_LIMIT_BUFFER + 1)) {
+    rxbuf = &wp->rxbuf; //存储的是请求包中的所有数据 18432 //缓冲区的数据结构
+    printf("%d>>>>>>>>0000>>>>%d>>>\n",rxbuf->buflen, bufRoom(rxbuf));
+    if (bufRoom(rxbuf) < (ME_GOAHEAD_LIMIT_BUFFER+1)) { //缓冲区不够了增加缓冲区的大小
+        if (!bufGrow(rxbuf, (ME_GOAHEAD_LIMIT_BUFFER+1))) {
             websError(wp, HTTP_CODE_INTERNAL_SERVER_ERROR, "Cannot grow rxbuf");
             websPump(wp);
             return;
         }
     }
-    if ((nbytes = websRead(wp, (char*) rxbuf->endp, ME_GOAHEAD_LIMIT_BUFFER)) > 0) {
-        wp->lastRead = nbytes;
-        bufAdjustEnd(rxbuf, nbytes);
+
+
+    printf("%s>>>>>>>>rxbuf->endp>>>>>>>\n",rxbuf->endp);
+    // ME_GOAHEAD_LIMIT_BUFFER
+    if ((nbytes = websRead(wp, (char*) rxbuf->endp, ME_GOAHEAD_LIMIT_BUFFER*10)) > 0) {//调用socketRead,读HTTP请求.rxbuf->endp是上一次的数据尾,每次读之后接上
+        printf("%d>>>>>>>>2222>>>>>>>\n",nbytes);//一次读了多少字节
+        wp->lastRead = nbytes;//读了多少字节,数据的尾指针就加多少字节
+
+         printf("%d>>>>>>>>bp->buflen>>>>>>>\n",rxbuf->buflen);
+        bufAdjustEnd(rxbuf, nbytes);//写字符串结束符
         bufAddNull(rxbuf);
     }
-    if (nbytes > 0 || wp->state > WEBS_BEGIN) {
+    printf("%d>>>>>>>>56565656>>>>>>>\n",nbytes);
+    if (nbytes > 0 || wp->state > WEBS_BEGIN) { //读到数据了,进来处理
+        printf("%d>>>>>>>>2222>>>>>>>\n",nbytes);
         websPump(wp);
     }
+    //到这一步nbytes值是-1  为什么??
+    printf("%d>>>>>>>>>nbytes>>>>>>>>>>>\n",nbytes);
+
+    printf("%d>>>>>>>>>wp->sid>>>>>>>>>>>\n",wp->sid);
     if (wp->flags & WEBS_CLOSED) {
-        return;
+        return;//通过websPump处理完请求,需要关闭连接,return返回readEvent.数据结构依然保留。
     } else if (nbytes < 0 && socketEof(wp->sid)) {
         /* EOF or error. Allow running requests to continue. */
-        if (wp->state < WEBS_READY) {
-            if (wp->state > WEBS_BEGIN) {
+        // printf("%d>>>>>>>>>state>>>>>>>>>>>\n", wp->state);
+        //state 值是1
+        if (wp->state < WEBS_READY) {//ready 2
+            if (wp->state > WEBS_BEGIN) {//begin 0
                 websError(wp, HTTP_CODE_COMMS_ERROR, "Read error: connection lost");
                 websPump(wp);
             } else {
@@ -819,7 +834,7 @@ static void readEvent(Webs *wp)
         } else {
             socketDeleteHandler(wp->sid);
         }
-    } else if (wp->state < WEBS_READY) {
+    } else if (wp->state < WEBS_READY) {//如果是keep alive的请求,继续监听。
         sp = socketPtr(wp->sid);
         socketCreateHandler(wp->sid, sp->handlerMask | SOCKET_READABLE, socketEvent, wp);
     }
@@ -840,6 +855,7 @@ PUBLIC void websPump(Webs *wp)
             break;
         case WEBS_READY:
             if (!websRunRequest(wp)) {
+                // printf("%d<<<<<<<<<<<<>>>>>>>>>*******\n", WEBS_READY);
                 /* Reroute if the handler re-wrote the request */
                 websRouteRequest(wp);
                 wp->state = WEBS_READY;
@@ -1092,10 +1108,10 @@ static void parseHeaders(Webs *wp)
                     return;
                 }
             } else {
-                if (wp->rxLen > ME_GOAHEAD_LIMIT_POST) {
-                    websError(wp, HTTP_CODE_REQUEST_TOO_LARGE | WEBS_CLOSE, "Too big");
-                    return;
-                }
+                // if (wp->rxLen > ME_GOAHEAD_LIMIT_POST) {
+                //     websError(wp, HTTP_CODE_REQUEST_TOO_LARGE | WEBS_CLOSE, "Too big");
+                //     return;
+                // }
             }
             if (wp->rxLen > 0 && !smatch(wp->method, "HEAD")) {
                 wp->rxRemaining = wp->rxLen;
@@ -1104,6 +1120,7 @@ static void parseHeaders(Webs *wp)
         } else if (strcmp(key, "content-type") == 0) {
             wfree(wp->contentType);
             wp->contentType = sclone(value);
+            printf("%s>>>>>>>>>>>>>>>wp->contentType>>>>>\n", wp->contentType);
             if (strstr(value, "application/x-www-form-urlencoded")) {
                 wp->flags |= WEBS_FORM;
             } else if (strstr(value, "application/json")) {
@@ -1151,6 +1168,7 @@ static void parseHeaders(Webs *wp)
             }
         }
     }
+
     if (!wp->rxChunkState) {
         /*
             Step over "\r\n" after headers.
@@ -1173,6 +1191,7 @@ static bool processContent(Webs *wp)
     }
 #if ME_GOAHEAD_UPLOAD
     if (wp->flags & WEBS_UPLOAD) {
+        // printf("<>>>>>>>>>tttttttttttt>>>>>>>>>\n");
         canProceed = websProcessUploadData(wp);
         if (!canProceed || wp->finalized) {
             return canProceed;
@@ -1311,6 +1330,7 @@ static bool filterChunkData(Webs *wp)
             nbytes = min(bufRoom(&wp->input), len);
 //            printf("---> bufPutBlk2 len = %d\n", len);
             if (len > 0 && (nbytes = bufPutBlk(&wp->input, rxbuf->servp, nbytes)) == 0) {
+                printf("<<<<<<<<<<<<<<>>42222>>>>>>>>>>>>\n" );
                 websError(wp, HTTP_CODE_REQUEST_TOO_LARGE | WEBS_CLOSE, "Too big");
                 return 1;
             }

+ 16 - 6
app/goahead-3.6.5/src/upload.c

@@ -156,6 +156,7 @@ PUBLIC bool websProcessUploadData(Webs *wp)
             break;
         }
     }
+    printf(">>>>>>66666666>>>>>>>>>>>>>\n");
     bufCompact(&wp->input);
     return canProceed;
 }
@@ -191,7 +192,7 @@ static void processUploadHeader(Webs *wp, char *line)
 
     headerTok = line;
     stok(line, ": ", &rest);
-
+    // printf(">>>>>>>>>>>>>>>>>3333>>>>>lllLLL>>>>>>>\n");
     if (scaselesscmp(headerTok, "Content-Disposition") == 0) {
         /*
             The content disposition header describes either a form variable or an uploaded file.
@@ -206,6 +207,7 @@ static void processUploadHeader(Webs *wp, char *line)
             File data
             ---boundary
          */
+        printf(">>>>>>>>>>>>>>>>>2222>>>>>lllLLL>>>>>>>\n");
         key = rest;
         wfree(wp->uploadVar);
         wfree(wp->clientFilename);
@@ -238,16 +240,20 @@ static void processUploadHeader(Webs *wp, char *line)
                 wp->clientFilename = value;
 
                 /*
-                    Create the file to hold the uploaded data
+                    Create the file to hold the uploaded data /var/tmp
                  */
                 wfree(wp->uploadTmp);
-                if ((wp->uploadTmp = websTempFile(uploadDir, "tmp")) == 0) {
+                 printf(">>>>>>>>>>>>>>>>>0000>>>>>%s>>>>>>>\n", uploadDir);
+                // if ((wp->uploadTmp = websTempFile(uploadDir, "tmp")) == 0) {
+                if ((wp->uploadTmp = websTempFile("/var/tmp", "tmp")) == 0) {
+
                     websError(wp, HTTP_CODE_INTERNAL_SERVER_ERROR,
                         "Cannot create upload temp file %s. Check upload temp dir %s", wp->uploadTmp, uploadDir);
                     return;
                 }
-                trace(5, "File upload of: %s stored as %s", wp->clientFilename, wp->uploadTmp);
-
+                printf("File upload of: %s stored as %s\n", wp->clientFilename, wp->uploadTmp);
+                    //  1 
+                // printf(">>>>>%d>>>>>>%d>>>>>>%d>>>>>%d>>>>>>>\n", O_WRONLY , O_CREAT , O_TRUNC , O_BINARY);
                 if ((wp->upfd = open(wp->uploadTmp, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0600)) < 0) {
                     websError(wp, HTTP_CODE_INTERNAL_SERVER_ERROR, "Cannot open upload temp file %s", wp->uploadTmp);
                     return;
@@ -328,12 +334,16 @@ static bool processContentData(Webs *wp)
 
     content = &wp->input;
     file = wp->currentFile;
-
+   
     size = bufLen(content);
+    printf("%d>>>>>>>>>>>>>>>:%d\n", size,  wp->boundaryLen);
     if (size < wp->boundaryLen) {
+        printf("come here >>>>>>>>>>>>>>>>>>>>>\n");
         /*  Incomplete boundary. Return and get more data */
         return 0;
     }
+
+    printf("**************>>>>>>>>>>>>>>>>>>>>>\n");
     if ((bp = getBoundary(wp, content->servp, size)) == 0) {
         trace(7, "uploadFilter: Got boundary filename %x", wp->clientFilename);
         if (wp->clientFilename) {

+ 30 - 7
app/goahead-3.6.5/src/web_interface/src/sel.c

@@ -65,6 +65,7 @@ void GetAllSELEntriesSorted(Webs *wp)
 	uint8 *pStartBuff = NULL;
 	uint16 nMaxEntries = 0;
 	IPMI20_UDS_SESSION_T    UDSSession;
+	
 
 	char *pStr;
     int code = 200;
@@ -107,9 +108,25 @@ void GetAllSELEntriesSorted(Webs *wp)
 		pSELBuff = (SELEventRecordWithSensorName_T *) walloc(nMaxEntries * sizeof(SELEventRecordWithSensorName_T));
 		if(pSELBuff == NULL)
 		{
-			printf("Error allocating memory for SEL entries!!\n");
-			wRet = -1;
-			goto error_out;
+			char *pStr;
+		    int code = 200;
+		    cJSON *root =  cJSON_CreateObject();
+		    cJSON  *pJsonArry,*pJsonsub;
+		    pJsonArry=cJSON_CreateArray();   /*创建数组*/
+		    cJSON_AddItemToObject(root, "data", pJsonArry);
+		    pStr = cJSON_PrintUnformatted(root);
+		    printf("---> pStr %d: %s\n", strlen(pStr), pStr);
+
+		    websSetStatus(wp, 200);
+		    websWriteHeaders(wp, -1, 0);
+		    websWriteEndHeaders(wp); 
+		    websWrite(wp, pStr);
+		    websDone(wp);
+
+			// printf("Error allocating memory for SEL entries!!\n");
+			// wRet = -1;
+			// goto error_out;
+			return;
 		}
 		pStartBuff = (uint8 *)pSELBuff;
 
@@ -121,7 +138,6 @@ void GetAllSELEntriesSorted(Webs *wp)
 
 		if(wRet == 0)
 		{
-			
 			/* Write entries here */
 			while(nEntries)
 			{
@@ -158,9 +174,7 @@ void GetAllSELEntriesSorted(Webs *wp)
 		        cJSON_Delete(root);
 		    if(pStr)
 		    	wfree(pStr);
-		}
-		else
-		{
+		} else {
 			printf("Error reading All SEL entries\n");
 		}
 		wfree(pStartBuff);
@@ -174,6 +188,15 @@ error_out:
 	//Close session
     LIBIPMI_CloseSession(&UDSSession );
 	websError(wp, 404, "Get SEL error!");
+	// cJSON_AddItemToObject(root, "data", pJsonArry);
+ //    pStr = cJSON_PrintUnformatted(root);
+ //    printf("---> pStr %d: %s\n", strlen(pStr), pStr);
+
+ //    websSetStatus(wp, 200);
+ //    websWriteHeaders(wp, -1, 0);
+ //    websWriteEndHeaders(wp); 
+ //    websWrite(wp, pStr);
+ //    websDone(wp);
 
 }
 

+ 30 - 14
app/goahead-3.6.5/src/web_interface/src/user.c

@@ -86,27 +86,27 @@ void setUserPassword(Webs *wp){
     int wRet;
     IPMI20_UDS_SESSION_T    UDSSession;
     char *username = websGetVar(wp, "username", NULL);
-    char *oldpassword = websGetVar(wp, "oldpassword", NULL);
+    //char *oldpassword = websGetVar(wp, "oldpassword", NULL);
     char *password = websGetVar(wp, "password", NULL);
     char *useridstr = websGetVar(wp, "userid", NULL);
     uint8_t userid = atoi(useridstr);
 
-    printf("---> setUserPassword, userid: %d, username: %s, oldpassword: %s, password: %s\n",\
-    	userid, username, oldpassword, password);
+    printf("---> setUserPassword, userid: %d, username: %s,  password: %s\n",\
+    	userid, username, password);
     //Create session
     LIBIPMI_CreateSession(&UDSSession, DEFAULT_TIMEOUT);
 
-    //verify old password
-    if(LIBIPMI_AuthorVerify(&UDSSession, username, oldpassword, DEFAULT_TIMEOUT) != TRUE)
-    {
-    	printf("Verify oldpassword error!\n" );
-    	//Close session
-    	LIBIPMI_CloseSession(&UDSSession );
-    	websError(wp, 404, "Verify oldpassword error!");
-    	return;
-    }
+    // //verify old password
+    // if(LIBIPMI_AuthorVerify(&UDSSession, username, oldpassword, DEFAULT_TIMEOUT) != TRUE)
+    // {
+    // 	printf("Verify oldpassword error!\n" );
+    // 	//Close session
+    // 	LIBIPMI_CloseSession(&UDSSession );
+    // 	websError(wp, 404, "Verify oldpassword error!");
+    // 	return;
+    // }
 
-    printf("Verify oldpassword success!\n" );
+    //printf("Verify oldpassword success!\n" );
     //set new password
     if(0 != LIBIPMI_SetPassword(&UDSSession, userid, password, DEFAULT_TIMEOUT))
     {
@@ -121,12 +121,28 @@ void setUserPassword(Webs *wp){
     //Close session
     LIBIPMI_CloseSession(&UDSSession );
 
+    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);
+    websWrite(wp,"%s", pStr);
     websFlush(wp, 0);
     websDone(wp);
+
+    if(pStr)
+        wfree(pStr);
+    if(root)
+        cJSON_Delete(root);
 }
 
 void addUser(Webs *wp){

+ 1 - 1
app/goahead-3.6.5/test/test.c

@@ -382,7 +382,7 @@ static void uploadTest(Webs *wp)
     WebsKey         *s;
     WebsUpload      *up;
     char            *upfile;
-
+    printf("<>>>>>>>>>>come in >>>>>>>>>>>\n");
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);
     websWriteHeader(wp, "Content-Type", "text/plain");

+ 64 - 63
gd32450i-eval.initramfs

@@ -125,66 +125,67 @@ file /usr/bin/spi.ko ${INSTALL_ROOT}/projects/${SAMPLE}/app/driver/SPI/spi.ko 75
 #
 file /usr/bin/test_app ${INSTALL_ROOT}/projects/${SAMPLE}/app/test_app/test_app 755 0 0
 file /usr/bin/bmc_app ${INSTALL_ROOT}/projects/${SAMPLE}/app/bmc/bmc_app 755 0 0
-#file /usr/bin/ipmitool ${INSTALL_ROOT}/projects/${SAMPLE}/app/ipmitool-1.8.18/ipmitool 755 0 0
-#file /usr/bin/goahead-3.6.5 ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/build/linux-arm-static/bin/goahead 755 0 0
-#
-#dir /etc/goahead 755 0 0 
-#dir /var/www 755 0 0
-#dir /var/www/goahead 755 0 0
-#dir /var/www/goahead/static 755 0 0
-#dir /var/www/goahead/static/css 755 0 0
-#dir /var/www/goahead/static/img 755 0 0
-#dir /var/www/goahead/static/js 755 0 0 
-#dir /var/www/goahead/static/fonts 755 0 0
-#file /etc/goahead/self.crt ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/self.crt 755 0 0
-#file /etc/goahead/self.key ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/self.key 755 0 0
-#file /etc/goahead/auth.txt ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/auth.txt 755 0 0
-#file /etc/goahead/route.txt ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/route.txt 755 0 0
-#file /var/www/goahead/favicon.ico ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/favicon.ico 755 0 0
-#file /var/www/goahead/index.html ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/index.html 755 0 0
-#
-#
-#
-#file /var/www/goahead/favicon.ico ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/favicon.ico 755 0 0
-#file /var/www/goahead/index.html ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/index.html 755 0 0
-#file /var/www/goahead/static/css/app.css ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/css/app.css 755 0 0
-#file /var/www/goahead/static/css/chunk-vendors.css ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/css/chunk-vendors.css 755 0 0
-#file /var/www/goahead/static/css/dashbord.css ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/css/dashbord.css 755 0 0
-#file /var/www/goahead/static/css/fan.css ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/css/fan.css 755 0 0
-#file /var/www/goahead/static/css/index.css ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/css/index.css 755 0 0
-#file /var/www/goahead/static/css/login.css ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/css/login.css 755 0 0
-#file /var/www/goahead/static/css/sensor_history.css ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/css/sensor_history.css 755 0 0
-#file /var/www/goahead/static/css/set_proctrol.css ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/css/set_proctrol.css 755 0 0
-#file /var/www/goahead/static/css/system_logs.css ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/css/system_logs.css 755 0 0
-#file /var/www/goahead/static/fonts/ionicons.ttf ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/fonts/ionicons.ttf 755 0 0
-#file /var/www/goahead/static/fonts/ionicons.woff ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/fonts/ionicons.woff 755 0 0
-#file /var/www/goahead/static/fonts/ionicons.woff2 ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/fonts/ionicons.woff2 755 0 0
-#file /var/www/goahead/static/img/active.png ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/active.png 755 0 0
-#file /var/www/goahead/static/img/bg1.png ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/bg1.png 755 0 0
-#file /var/www/goahead/static/img/cart.png ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/cart.png 755 0 0
-#file /var/www/goahead/static/img/cart_active.png ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/cart_active.png 755 0 0
-#file /var/www/goahead/static/img/checked-card.png ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/checked-card.png 755 0 0
-#file /var/www/goahead/static/img/crit.png ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/crit.png 755 0 0
-#file /var/www/goahead/static/img/helpicon.png ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/helpicon.png 755 0 0
-#file /var/www/goahead/static/img/icon_right.png ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/icon_right.png 755 0 0
-#file /var/www/goahead/static/img/ionicons.svg ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/ionicons.svg 755 0 0
-#file /var/www/goahead/static/img/logo.png ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/logo.png 755 0 0
-#file /var/www/goahead/static/img/logout_1.png ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/logout_1.png 755 0 0
-#file /var/www/goahead/static/img/ok.png ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/ok.png 755 0 0
-#file /var/www/goahead/static/img/print_1.png ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/print_1.png 755 0 0
-#file /var/www/goahead/static/img/refresh.png ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/refresh.png 755 0 0
-#file /var/www/goahead/static/img/sortup.gif ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/sortup.gif 755 0 0
-#file /var/www/goahead/static/img/status_critical.png ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/status_critical.png 755 0 0
-#file /var/www/goahead/static/img/user.png ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/user.png 755 0 0
-#file /var/www/goahead/static/img/view.png ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/view.png 755 0 0
-#file /var/www/goahead/static/js/app.js ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/js/app.js 755 0 0
-#file /var/www/goahead/static/js/BSODScreen.js ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/js/BSODScreen.js 755 0 0
-#file /var/www/goahead/static/js/chunk-vendors.js ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/js/chunk-vendors.js 755 0 0
-#file /var/www/goahead/static/js/dashbord.js ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/js/dashbord.js 755 0 0
-#file /var/www/goahead/static/js/event_logs.js ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/js/event_logs.js 755 0 0
-#file /var/www/goahead/static/js/fan.js ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/js/fan.js 755 0 0
-#file /var/www/goahead/static/js/index.js ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/js/index.js 755 0 0
-#file /var/www/goahead/static/js/login.js ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/js/login.js 755 0 0
-#file /var/www/goahead/static/js/sensor_history.js ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/js/sensor_history.js 755 0 0
-#file /var/www/goahead/static/js/set_proctrol.js ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/js/set_proctrol.js 755 0 0
-#file /var/www/goahead/static/js/system_logs.js ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/js/system_logs.js 755 0 0
+file /usr/bin/ipmitool ${INSTALL_ROOT}/projects/${SAMPLE}/app/ipmitool-1.8.18/ipmitool 755 0 0
+file /usr/bin/goahead-3.6.5 ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/build/linux-arm-static/bin/goahead 755 0 0
+
+dir /etc/goahead 755 0 0 
+dir /var/www 755 0 0
+dir /var/www/goahead 755 0 0
+dir /var/www/goahead/tmp 755 0 0
+dir /var/www/goahead/static 755 0 0
+dir /var/www/goahead/static/css 755 0 0
+dir /var/www/goahead/static/img 755 0 0
+dir /var/www/goahead/static/js 755 0 0 
+dir /var/www/goahead/static/fonts 755 0 0
+file /etc/goahead/self.crt ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/self.crt 755 0 0
+file /etc/goahead/self.key ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/self.key 755 0 0
+file /etc/goahead/auth.txt ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/auth.txt 755 0 0
+file /etc/goahead/route.txt ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/route.txt 755 0 0
+file /var/www/goahead/favicon.ico ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/favicon.ico 755 0 0
+file /var/www/goahead/index.html ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/index.html 755 0 0
+
+
+
+file /var/www/goahead/favicon.ico ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/favicon.ico 755 0 0
+file /var/www/goahead/index.html ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/index.html 755 0 0
+file /var/www/goahead/static/css/app.css ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/css/app.css 755 0 0
+file /var/www/goahead/static/css/chunk-vendors.css ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/css/chunk-vendors.css 755 0 0
+file /var/www/goahead/static/css/dashbord.css ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/css/dashbord.css 755 0 0
+file /var/www/goahead/static/css/fan.css ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/css/fan.css 755 0 0
+file /var/www/goahead/static/css/index.css ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/css/index.css 755 0 0
+file /var/www/goahead/static/css/login.css ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/css/login.css 755 0 0
+file /var/www/goahead/static/css/sensor_history.css ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/css/sensor_history.css 755 0 0
+file /var/www/goahead/static/css/set_proctrol.css ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/css/set_proctrol.css 755 0 0
+file /var/www/goahead/static/css/system_logs.css ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/css/system_logs.css 755 0 0
+file /var/www/goahead/static/fonts/ionicons.ttf ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/fonts/ionicons.ttf 755 0 0
+file /var/www/goahead/static/fonts/ionicons.woff ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/fonts/ionicons.woff 755 0 0
+file /var/www/goahead/static/fonts/ionicons.woff2 ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/fonts/ionicons.woff2 755 0 0
+file /var/www/goahead/static/img/active.png ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/active.png 755 0 0
+file /var/www/goahead/static/img/bg1.png ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/bg1.png 755 0 0
+file /var/www/goahead/static/img/cart.png ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/cart.png 755 0 0
+file /var/www/goahead/static/img/cart_active.png ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/cart_active.png 755 0 0
+file /var/www/goahead/static/img/checked-card.png ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/checked-card.png 755 0 0
+file /var/www/goahead/static/img/crit.png ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/crit.png 755 0 0
+file /var/www/goahead/static/img/helpicon.png ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/helpicon.png 755 0 0
+file /var/www/goahead/static/img/icon_right.png ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/icon_right.png 755 0 0
+file /var/www/goahead/static/img/ionicons.svg ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/ionicons.svg 755 0 0
+file /var/www/goahead/static/img/logo.png ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/logo.png 755 0 0
+file /var/www/goahead/static/img/logout_1.png ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/logout_1.png 755 0 0
+file /var/www/goahead/static/img/ok.png ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/ok.png 755 0 0
+file /var/www/goahead/static/img/print_1.png ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/print_1.png 755 0 0
+file /var/www/goahead/static/img/refresh.png ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/refresh.png 755 0 0
+file /var/www/goahead/static/img/sortup.gif ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/sortup.gif 755 0 0
+file /var/www/goahead/static/img/status_critical.png ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/status_critical.png 755 0 0
+file /var/www/goahead/static/img/user.png ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/user.png 755 0 0
+file /var/www/goahead/static/img/view.png ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/img/view.png 755 0 0
+file /var/www/goahead/static/js/app.js ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/js/app.js 755 0 0
+file /var/www/goahead/static/js/BSODScreen.js ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/js/BSODScreen.js 755 0 0
+file /var/www/goahead/static/js/chunk-vendors.js ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/js/chunk-vendors.js 755 0 0
+file /var/www/goahead/static/js/dashbord.js ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/js/dashbord.js 755 0 0
+file /var/www/goahead/static/js/event_logs.js ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/js/event_logs.js 755 0 0
+file /var/www/goahead/static/js/fan.js ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/js/fan.js 755 0 0
+file /var/www/goahead/static/js/index.js ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/js/index.js 755 0 0
+file /var/www/goahead/static/js/login.js ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/js/login.js 755 0 0
+file /var/www/goahead/static/js/sensor_history.js ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/js/sensor_history.js 755 0 0
+file /var/www/goahead/static/js/set_proctrol.js ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/js/set_proctrol.js 755 0 0
+file /var/www/goahead/static/js/system_logs.js ${INSTALL_ROOT}/projects/${SAMPLE}/app/goahead-3.6.5/src/web/static/js/system_logs.js 755 0 0