Browse Source

upload file

zhangbo 5 years ago
parent
commit
3dcb04c41f

+ 0 - 14
app/bmc/AuthChip/CM_TEST.c

@@ -613,7 +613,6 @@ uint8_t test_cryptomem(void)
 	for(i=0;i<writeLen;i++) 
 	{
 		writeData[i] = '6' + i;
-		printf("%#x \n", writeData[i]);
 	}
 	printf("\n");
 	
@@ -633,19 +632,6 @@ uint8_t test_cryptomem(void)
 		return FAILED;
 	}
 
-	printf("Read: \n");
-	for (i = 0; i < readLen; ++i)
-	{
-		printf("%#x \n", readData[i]);
-	}
-	printf("\n");
-
-	if(0 != memcmp(writeData, readData, writeLen))
-	{
-		printf("Read data isn't same as write data!\n");
-		return FAILED;
-	}
-
 	return SUCCESS;
 }
 

BIN
app/bmc/bmc_app


+ 25 - 25
app/bmc/main.c

@@ -38,31 +38,31 @@ uint8_t		gThreadIndex = 0;
 
 void main(void)
 {
-	printf("---> log1\n");
-	if(0 != cm_Auth_Encrp_Init(1, 1, TRUE))
-	{
-		printf("Initialize AT88SC0104C failed!\n");
-		sleep(1);
-		return;
-	}
-
-	printf("---> log2\n");
-	if(0 != cm_Auth_Encrp_Personal(1, 1))
-	{
-		printf("Personal AT88SC0104C failed!\n");
-		sleep(1);
-		return ;
-	}
-
-	printf("---> log3\n");
-	if(0 != test_cryptomem())
-	{
-		while(1)
-		{
-			printf("Illegal Board!\n");
-			sleep(3);
-		}
-	}
+	// printf("---> log1\n");
+	// if(0 != cm_Auth_Encrp_Init(1, 1, TRUE))
+	// {
+	// 	printf("Initialize AT88SC0104C failed!\n");
+	// 	sleep(1);
+	// 	return;
+	// }
+
+	// printf("---> log2\n");
+	// if(0 != cm_Auth_Encrp_Personal(1, 1))
+	// {
+	// 	printf("Personal AT88SC0104C failed!\n");
+	// 	sleep(1);
+	// 	return ;
+	// }
+
+	// printf("---> log3\n");
+	// if(0 != test_cryptomem())
+	// {
+	// 	while(1)
+	// 	{
+	// 		printf("Illegal Board!\n");
+	// 		sleep(3);
+	// 	}
+	// }
 
 	
 

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

@@ -121,7 +121,7 @@
     #define ME_GOAHEAD_LEGACY 0
 #endif
 #ifndef ME_GOAHEAD_LIMIT_BUFFER
-    #define ME_GOAHEAD_LIMIT_BUFFER 1024
+    #define ME_GOAHEAD_LIMIT_BUFFER 10240   //10k
 #endif
 #ifndef ME_GOAHEAD_LIMIT_FILENAME
     #define ME_GOAHEAD_LIMIT_FILENAME 256
@@ -145,7 +145,7 @@
     #define ME_GOAHEAD_LIMIT_PASSWORD 32
 #endif
 #ifndef ME_GOAHEAD_LIMIT_POST
-    #define ME_GOAHEAD_LIMIT_POST 6613328
+    #define ME_GOAHEAD_LIMIT_POST 16384
 #endif
 #ifndef ME_GOAHEAD_LIMIT_PUT
     #define ME_GOAHEAD_LIMIT_PUT 2048000    //204800000
@@ -163,7 +163,7 @@
     #define ME_GOAHEAD_LIMIT_TIMEOUT 60
 #endif
 #ifndef ME_GOAHEAD_LIMIT_UPLOAD
-    #define ME_GOAHEAD_LIMIT_UPLOAD 2048000     //204800000
+    #define ME_GOAHEAD_LIMIT_UPLOAD 20480000     //204800000
 #endif
 #ifndef ME_GOAHEAD_LIMIT_URI
     #define ME_GOAHEAD_LIMIT_URI 2048
@@ -205,7 +205,7 @@
     #define ME_GOAHEAD_SSL_KEY "/etc/goahead/self.key"  //jimbo
 #endif
 #ifndef ME_GOAHEAD_SSL_LOG_LEVEL
-    #define ME_GOAHEAD_SSL_LOG_LEVEL 5
+    #define ME_GOAHEAD_SSL_LOG_LEVEL 9 //5
 #endif
 #ifndef ME_GOAHEAD_SSL_REVOKE
     #define ME_GOAHEAD_SSL_REVOKE ""
@@ -232,7 +232,7 @@
     #define ME_GOAHEAD_UPLOAD 1
 #endif
 #ifndef ME_GOAHEAD_UPLOAD_DIR
-    #define ME_GOAHEAD_UPLOAD_DIR "/var/tmp"
+    #define ME_GOAHEAD_UPLOAD_DIR "tmp"
 #endif
 #ifndef ME_GOAHEAD_XFRAME_HEADER
     #define ME_GOAHEAD_XFRAME_HEADER "SAMEORIGIN"

+ 8 - 8
app/goahead-3.6.5/src/file.c

@@ -32,7 +32,7 @@ static bool fileHandler(Webs *wp)
     assert(websValid(wp));
     assert(wp->method);
     assert(wp->filename && wp->filename[0]);
-    printf(">>>>>>>>>>>>>>>>>>>>>>>>>>1.1>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
+//    printf(">>>>>>>>>>>>>>>>>>>>>>>>>>1.1>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
 #if !ME_ROM
     if (smatch(wp->method, "DELETE")) {
         if (unlink(wp->filename) < 0) {
@@ -48,7 +48,7 @@ static bool fileHandler(Webs *wp)
     } else
 #endif /* !ME_ROM */
     {
-        printf(">>>>>>>>>>>>>>>>>>>>>>>>>>1.2>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
+//        printf(">>>>>>>>>>>>>>>>>>>>>>>>>>1.2>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
         /*
             If the file is a directory, redirect using the nominated default page
          */
@@ -64,7 +64,7 @@ static bool fileHandler(Webs *wp)
             printf("---> fileHandler return 1\n");
             return 1;
         }
-        printf(">>>>>>>>>>>>>>>>>>>>>>>>>>1.3>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
+//        printf(">>>>>>>>>>>>>>>>>>>>>>>>>>1.3>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
         if (websPageOpen(wp, O_RDONLY | O_BINARY, 0666) < 0) {
 #if ME_DEBUG
             if (wp->referrer) {
@@ -74,16 +74,16 @@ static bool fileHandler(Webs *wp)
             websError(wp, HTTP_CODE_NOT_FOUND, "Cannot open document for: %s", wp->path);
             return 1;
         }
-        printf(">>>>>>>>>>>>>>>>>>>>>>>>>>1.4>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
+ //       printf(">>>>>>>>>>>>>>>>>>>>>>>>>>1.4>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
         if (websPageStat(wp, &info) < 0) {
             websError(wp, HTTP_CODE_NOT_FOUND, "Cannot stat page for URL");
             return 1;
         }
         code = 200;
 
-        printf(">>>>>>>>>>>>>>>>>>>>>>>>>>4.3>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
+//        printf(">>>>>>>>>>>>>>>>>>>>>>>>>>4.3>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
         if (wp->since && info.mtime <= wp->since) {//应该是这个判定的问题   正常来说 应该是 code=304
-            printf(">>>>>>>>>>>>>>>>>>>>>>>>>>4.6>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
+ //           printf(">>>>>>>>>>>>>>>>>>>>>>>>>>4.6>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n");
             code = 304;
             info.size = 0;
         }
@@ -186,7 +186,7 @@ static void fileClose()
 
 PUBLIC void websFileOpen()
 {
-    printf(">>>>>>>>>>>>>>>>>>>>>>>>>>333>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
+//    printf(">>>>>>>>>>>>>>>>>>>>>>>>>>333>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
     websIndex = sclone("index.html");
     websDefineHandler("file", 0, fileHandler, fileClose, 0);
 }
@@ -197,7 +197,7 @@ PUBLIC void websFileOpen()
  */
 PUBLIC char *websGetIndex()
 {
-    printf(">>>>>>>>>>>>>>>>>>>>>>>>is here ???>>>>>>>>>>>>>>>>>>>>>>");
+//    printf(">>>>>>>>>>>>>>>>>>>>>>>>is here ???>>>>>>>>>>>>>>>>>>>>>>");
     return websIndex;
 }
 

+ 89 - 88
app/goahead-3.6.5/src/goahead.c

@@ -105,7 +105,7 @@ MAIN(goahead, int argc, char **argv, char **envp)
             logSetPath(argv[++argind]);
 
         } else if (smatch(argp, "--verbose") || smatch(argp, "-v")) {
-            logSetPath("stdout:2");
+            logSetPath("stdout:2"); //2
 
         } else if (smatch(argp, "--route") || smatch(argp, "-r")) {
             route = argv[++argind];
@@ -130,7 +130,7 @@ MAIN(goahead, int argc, char **argv, char **envp)
     printf("---> initPlatform\n");
     initPlatform();
     printf("---> websOpen\n");
-    printf(">>>>>>>>>>>>>>>>>>>>>>>>>>2>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
+//    printf(">>>>>>>>>>>>>>>>>>>>>>>>>>2>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
     if (websOpen(documents, route) < 0) {
         error("Cannot initialize server. Exiting.");
         return -1;
@@ -267,106 +267,107 @@ int StringToHex(char *str, unsigned char *out, unsigned int *outlen)
 
 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;
+    WebsKey         *s;
+    WebsUpload      *up;
+    char            *upfile;
+   
+    printf("---> Enter uploadTest\n");
+    // filestruct fileitem;
+    // 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;
+    // 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.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");
+    // 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);
+    // // 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);
-    //     // }
-    // }
+    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("---> uploadTest, upfile: %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);
+    //  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);
+    // 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);
+    // 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);
 }

+ 10 - 10
app/goahead-3.6.5/src/http.c

@@ -789,7 +789,7 @@ static void readEvent(Webs *wp)
     }
     websNoteRequestActivity(wp);
     rxbuf = &wp->rxbuf; //存储的是请求包中的所有数据 18432 //缓冲区的数据结构
-    printf("%d>>>>>>>>0000>>>>%d>>>\n",rxbuf->buflen, bufRoom(rxbuf));
+//    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");
@@ -799,25 +799,25 @@ static void readEvent(Webs *wp)
     }
 
 
-    printf("%s>>>>>>>>rxbuf->endp>>>>>>>\n",rxbuf->endp);
+//    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);//一次读了多少字节
+    if ((nbytes = websRead(wp, (char*) rxbuf->endp, ME_GOAHEAD_LIMIT_BUFFER)) > 0) {//调用socketRead,读HTTP请求.rxbuf->endp是上一次的数据尾,每次读之后接上
+ //       printf("%d>>>>>>>>2222>>>>>>>\n",nbytes);//一次读了多少字节
         wp->lastRead = nbytes;//读了多少字节,数据的尾指针就加多少字节
 
-         printf("%d>>>>>>>>bp->buflen>>>>>>>\n",rxbuf->buflen);
+//        printf("---> websRead return %d\n",nBytes);
         bufAdjustEnd(rxbuf, nbytes);//写字符串结束符
         bufAddNull(rxbuf);
     }
-    printf("%d>>>>>>>>56565656>>>>>>>\n",nbytes);
+ //   printf("%d>>>>>>>>56565656>>>>>>>\n",nbytes);
     if (nbytes > 0 || wp->state > WEBS_BEGIN) { //读到数据了,进来处理
-        printf("%d>>>>>>>>2222>>>>>>>\n",nbytes);
+ //       printf("%d>>>>>>>>2222>>>>>>>\n",nbytes);
         websPump(wp);
     }
     //到这一步nbytes值是-1  为什么??
-    printf("%d>>>>>>>>>nbytes>>>>>>>>>>>\n",nbytes);
+//    printf("%d>>>>>>>>>nbytes>>>>>>>>>>>\n",nbytes);
 
-    printf("%d>>>>>>>>>wp->sid>>>>>>>>>>>\n",wp->sid);
+//    printf("%d>>>>>>>>>wp->sid>>>>>>>>>>>\n",wp->sid);
     if (wp->flags & WEBS_CLOSED) {
         return;//通过websPump处理完请求,需要关闭连接,return返回readEvent.数据结构依然保留。
     } else if (nbytes < 0 && socketEof(wp->sid)) {
@@ -1120,7 +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);
+//            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")) {

+ 4 - 1
app/goahead-3.6.5/src/runtime.c

@@ -286,7 +286,7 @@ int websRunEvents()
     WebsTime    now;
     int         i, delay, nextEvent;
 
-    printf("---> websRunEvents\n");
+//    printf("---> websRunEvents\n");
     nextEvent = (MAXINT / 1000);
     now = time(0);
 
@@ -1663,6 +1663,7 @@ PUBLIC ssize bufGetBlk(WebsBuf *bp, char *buf, ssize size)
 {
     ssize   this, bytes_read;
 
+   // printf("---> bufGetBlk, size: %d, buflen: %d, endbuf: %p, buf: %p\n", bp->buflen, bp->endbuf, bp->buf);
     assert(bp);
     assert(bp->buflen == (bp->endbuf - bp->buf));
     assert(buf);
@@ -1733,6 +1734,7 @@ PUBLIC ssize bufGetBlkMax(WebsBuf *bp)
  */
 PUBLIC void bufAdjustEnd(WebsBuf *bp, ssize size)
 {
+   // printf("---> bufAdjustEnd, size: %d, buflen: %d, endbuf: %p, buf: %p\n", size, bp->buflen, bp->endbuf, bp->buf);
     assert(bp);
     assert(bp->buflen == (bp->endbuf - bp->buf));
     assert(0 <= size && size < bp->buflen);
@@ -1756,6 +1758,7 @@ PUBLIC void bufAdjustEnd(WebsBuf *bp, ssize size)
  */
 PUBLIC void bufAdjustStart(WebsBuf *bp, ssize size)
 {
+    //printf("---> bufAdjustStart, size: %d, buflen: %d, endbuf: %p, buf: %p\n", size, bp->buflen, bp->endbuf, bp->buf);
     assert(bp);
     assert(bp->buflen == (bp->endbuf - bp->buf));
     assert(0 <= size && size < bp->buflen);

+ 1 - 1
app/goahead-3.6.5/src/socket.c

@@ -618,7 +618,7 @@ PUBLIC void socketProcess()
 {
     WebsSocket    *sp;
     int         sid;
-    printf("---> socketProcess\n");
+//    printf("---> socketProcess\n");
     for (sid = 0; sid < socketMax; sid++) {
         if ((sp = socketList[sid]) != NULL) {
             if (sp->currentEvents & sp->handlerMask) {

+ 13 - 15
app/goahead-3.6.5/src/upload.c

@@ -156,7 +156,6 @@ PUBLIC bool websProcessUploadData(Webs *wp)
             break;
         }
     }
-    printf(">>>>>>66666666>>>>>>>>>>>>>\n");
     bufCompact(&wp->input);
     return canProceed;
 }
@@ -192,7 +191,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.
@@ -207,7 +206,6 @@ static void processUploadHeader(Webs *wp, char *line)
             File data
             ---boundary
          */
-        printf(">>>>>>>>>>>>>>>>>2222>>>>>lllLLL>>>>>>>\n");
         key = rest;
         wfree(wp->uploadVar);
         wfree(wp->clientFilename);
@@ -240,20 +238,16 @@ static void processUploadHeader(Webs *wp, char *line)
                 wp->clientFilename = value;
 
                 /*
-                    Create the file to hold the uploaded data /var/tmp
+                    Create the file to hold the uploaded data
                  */
                 wfree(wp->uploadTmp);
-                 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;
                 }
-                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);
+                trace(5, "File upload of: %s stored as %s", wp->clientFilename, wp->uploadTmp);
+
                 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;
@@ -306,6 +300,8 @@ static int writeToFile(Webs *wp, char *data, ssize len)
 
     file = wp->currentFile;
 
+    //printf("===file->size %d >>>len %d >> ME_GOAHEAD_LIMIT_UPLOAD %d ====\n", file->size, len, ME_GOAHEAD_LIMIT_UPLOAD);
+    printf("- %d\n", file->size);
     if ((file->size + len) > ME_GOAHEAD_LIMIT_UPLOAD) {
         websError(wp, HTTP_CODE_REQUEST_TOO_LARGE, "Uploaded file exceeds maximum %d", (int) ME_GOAHEAD_LIMIT_UPLOAD);
         return -1;
@@ -334,16 +330,17 @@ static bool processContentData(Webs *wp)
 
     content = &wp->input;
     file = wp->currentFile;
-   
+
+//    printf("---> filename: %s, clientFilename: %s, contentType: %s, size: %d\n", 
+//        file->filename, file->clientFilename, file->contentType, size);
+
+//    printf("---> buf: %p, servp: %p, endp: %p, endbuf: %p, buflen: %d, maxsize: %d\n", 
+//        content->buf, content->servp, content->endp, content->endbuf, content->buflen, content->maxsize);
     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) {
@@ -354,6 +351,7 @@ static bool processContentData(Webs *wp)
             nbytes = ((int) (content->endp - data)) - (wp->boundaryLen - 1);
             if (writeToFile(wp, content->servp, nbytes) < 0) {
                 /* Proceed to handle error */
+                printf("write >>>>>>>>>>>>>hander error\n");
                 return 1;
             }
             websConsumeInput(wp, nbytes);

+ 3 - 3
local/rc

@@ -34,7 +34,7 @@ mknod /dev/gpio c 103 0
 #mknod /dev/gpio_i2c c 106 0
 ################### run app ####################
 #/bin/telnetd
-#/usr/bin/bmc_app & 
-#sleep 3
+/usr/bin/bmc_app & 
+sleep 3
 #/usr/bin/test_app 
-#/usr/bin/goahead-3.6.5 -v --home /etc/goahead &
+/usr/bin/goahead-3.6.5 -v --home /etc/goahead &