Browse Source

please ignore this submit

zhangbo 5 years ago
parent
commit
635bccf1cb
30 changed files with 423 additions and 464 deletions
  1. BIN
      app/bmc/bmc_app
  2. BIN
      app/goahead-3.6.5/build/linux-arm-static/bin/goahead
  3. BIN
      app/goahead-3.6.5/build/linux-arm-static/bin/gopass
  4. BIN
      app/goahead-3.6.5/build/linux-arm-static/bin/libgo.a
  5. BIN
      app/goahead-3.6.5/build/linux-arm-static/bin/libgoahead-mbedtls.a
  6. BIN
      app/goahead-3.6.5/build/linux-arm-static/bin/libmbedtls.a
  7. 2 2
      app/goahead-3.6.5/build/linux-arm-static/inc/cJSON.h
  8. 5 10
      app/goahead-3.6.5/build/linux-arm-static/inc/goahead.h
  9. 2 2
      app/goahead-3.6.5/build/linux-arm-static/inc/libipmi_ChassisDevice.h
  10. 0 1
      app/goahead-3.6.5/build/linux-arm-static/inc/libipmi_StorDevice.h
  11. 2 1
      app/goahead-3.6.5/build/linux-arm-static/inc/libipmi_fru.h
  12. 1 1
      app/goahead-3.6.5/build/linux-arm-static/inc/libipmi_storlead_OEM.h
  13. 2 2
      app/goahead-3.6.5/build/linux-arm-static/inc/libipmi_usermgmt.h
  14. 1 1
      app/goahead-3.6.5/build/linux-arm-static/inc/osdep.h
  15. 1 9
      app/goahead-3.6.5/src/action.c
  16. 2 2
      app/goahead-3.6.5/src/cJSON/cJSON.h
  17. 382 391
      app/goahead-3.6.5/src/goahead.c
  18. 5 10
      app/goahead-3.6.5/src/goahead.h
  19. 2 2
      app/goahead-3.6.5/src/libipmi/inc/libipmi_ChassisDevice.h
  20. 0 1
      app/goahead-3.6.5/src/libipmi/inc/libipmi_StorDevice.h
  21. 2 1
      app/goahead-3.6.5/src/libipmi/inc/libipmi_fru.h
  22. 1 1
      app/goahead-3.6.5/src/libipmi/inc/libipmi_storlead_OEM.h
  23. 2 2
      app/goahead-3.6.5/src/libipmi/inc/libipmi_usermgmt.h
  24. 0 3
      app/goahead-3.6.5/src/libipmi/src/libipmi_session.c
  25. 3 3
      app/goahead-3.6.5/src/libipmi/src/libipmi_uds_session.c
  26. 1 1
      app/goahead-3.6.5/src/osdep/osdep.h
  27. 1 3
      app/goahead-3.6.5/src/route.txt
  28. 1 0
      app/goahead-3.6.5/src/socket.c
  29. 5 15
      app/goahead-3.6.5/src/web_interface/src/dashboard.c
  30. BIN
      app/test_app/test_app

BIN
app/bmc/bmc_app


BIN
app/goahead-3.6.5/build/linux-arm-static/bin/goahead


BIN
app/goahead-3.6.5/build/linux-arm-static/bin/gopass


BIN
app/goahead-3.6.5/build/linux-arm-static/bin/libgo.a


BIN
app/goahead-3.6.5/build/linux-arm-static/bin/libgoahead-mbedtls.a


BIN
app/goahead-3.6.5/build/linux-arm-static/bin/libmbedtls.a


+ 2 - 2
app/goahead-3.6.5/build/linux-arm-static/inc/cJSON.h

@@ -27,7 +27,7 @@
 extern "C"
 {
 #endif
-
+#pragma pack(1)
 /* cJSON Types: */
 #define cJSON_False 0
 #define cJSON_True 1
@@ -143,7 +143,7 @@ extern void cJSON_Minify(char *json);
 /* When assigning an integer value, it needs to be propagated to valuedouble too. */
 #define cJSON_SetIntValue(object,val)			((object)?(object)->valueint=(object)->valuedouble=(val):(val))
 #define cJSON_SetNumberValue(object,val)		((object)?(object)->valueint=(object)->valuedouble=(val):(val))
-
+#pragma pack()
 #ifdef __cplusplus
 }
 #endif

+ 5 - 10
app/goahead-3.6.5/build/linux-arm-static/inc/goahead.h

@@ -24,6 +24,8 @@
 extern "C" {
 #endif
 
+#pragma pack(1)
+
 #if (ME_COM_MBEDTLS + ME_COM_MATRIXSSL + ME_COM_NANOSSL + ME_COM_OPENSSL) > 1
     #error "Cannot have more than one SSL provider configured"
 #endif
@@ -4158,16 +4160,9 @@ PUBLIC int websSetSessionVar(Webs *wp, char *name, char *value);
  #include "customize.h"
 #endif
 
+#pragma pack()
+
 #ifdef __cplusplus
 }
 #endif
-#endif /* _h_GOAHEAD */
-
-/*
-    Copyright (c) Embedthis Software. All Rights Reserved.
-    This software is distributed under commercial and open source licenses.
-    You may use the Embedthis GoAhead open source license or you may acquire
-    a commercial license from Embedthis Software. You agree to be fully bound
-    by the terms of either license. Consult the LICENSE.md distributed with
-    this software for full details and other copyrights.
- */
+#endif /* _h_GOAHEAD */

+ 2 - 2
app/goahead-3.6.5/build/linux-arm-static/inc/libipmi_ChassisDevice.h

@@ -17,7 +17,7 @@
 extern "C" {
 #endif
 
-
+#pragma pack(1)
 
 
 /*---------- LIBIPMI Higher level routines -----------*/
@@ -149,7 +149,7 @@ typedef enum tag_FORCE_CHASSIS_ID
 uint16_t	LIBIPMI_HL_GetSystemBootOptions_BootFlags( IPMI20_UDS_SESSION_T *pUDSSession, BootFlags_T* pBootFlags,int timeout);
 uint16_t	LIBIPMI_HL_SetSystemBootOptions_BootFlags( IPMI20_UDS_SESSION_T *pUDSSession, BootFlags_T* pBootFlags,int timeout);
 
-    
+#pragma pack()
 
 #ifdef  __cplusplus
 }

+ 0 - 1
app/goahead-3.6.5/build/linux-arm-static/inc/libipmi_StorDevice.h

@@ -100,7 +100,6 @@ typedef struct _SELEventRecordWithSensorName
 #define MAX_FRU_DEVICES	32
 #endif
 
-#pragma pack(1)
 typedef struct _SDRHeader
 {
     /** The ID of this SDR, LSB first */

+ 2 - 1
app/goahead-3.6.5/build/linux-arm-static/inc/libipmi_fru.h

@@ -21,6 +21,7 @@
 
 #define _LIBIPMI_FRU_
 
+#pragma pack(1)
 
 #include "libipmi_session.h"
 #include "libipmi_errorcodes.h"
@@ -90,5 +91,5 @@ typedef struct fru_t
 
 void LIBIPMI_HL_FreeFRUData(FRUData_T* fru_data);
 
-
+#pragma pack()
 #endif

+ 1 - 1
app/goahead-3.6.5/build/linux-arm-static/inc/libipmi_storlead_OEM.h

@@ -84,7 +84,6 @@ typedef struct{
 	uint8_t supportHistory;
 	
 } OemWebFlags_T;
-#pragma pack()
 
 typedef struct 
 {
@@ -121,5 +120,6 @@ uint16_t LIBIPMI_HL_GetSysInfo( IPMI20_UDS_SESSION_T *pUDSSession, SysInfo_T *pS
 //int LIBIPMI_HL_GetSensorHistoryEn(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t* SensorHistoryEnable, int timeout);
 //int LIBIPMI_HL_SetSensorHistoryEn(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t sensorNum, uint8_t SensorHistoryEnable, int timeout);
 
+#pragma pack()
 #endif /* __LIBIPMI_STORLEAD_OEM_H__ */
 

+ 2 - 2
app/goahead-3.6.5/build/linux-arm-static/inc/libipmi_usermgmt.h

@@ -1,7 +1,7 @@
 #ifndef __LIBIPMI_USER_MANAGEMENT_H__
 #define __LIBIPMI_USER_MANAGEMENT_H__
 
-#define PACK __attribute__ ((packed))
+#pragma pack(1)
 
 typedef struct {
 	uint8_t		byUserID;
@@ -13,7 +13,7 @@ typedef struct {
 	char		szUserName[16];
 } GetUser_T;
 
-#undef PACK
+#pragma pack()
 
 
 #endif

+ 1 - 1
app/goahead-3.6.5/build/linux-arm-static/inc/osdep.h

@@ -1395,4 +1395,4 @@ extern "C" {
 /*
     Copyright (c) Michael O'Brien. All Rights Reserved.
     This is proprietary software and requires a commercial license from the author.
- */
+ */

+ 1 - 9
app/goahead-3.6.5/src/action.c

@@ -57,6 +57,7 @@ static bool actionHandler(Webs *wp)
             (*((WebsProc) fn))((void*) wp, actionName, wp->query);
 #else
             (*fn)((void*) wp);
+            printf("---> actionHandler call action execute over\n");
 #endif
         }
     }
@@ -118,12 +119,3 @@ PUBLIC void websFooter(Webs *wp)
     websWrite(wp, "</html>\n");
 }
 #endif
-
-/*
-    Copyright (c) Embedthis Software. All Rights Reserved.
-    This software is distributed under commercial and open source licenses.
-    You may use the Embedthis GoAhead open source license or you may acquire
-    a commercial license from Embedthis Software. You agree to be fully bound
-    by the terms of either license. Consult the LICENSE.md distributed with
-    this software for full details and other copyrights.
- */

+ 2 - 2
app/goahead-3.6.5/src/cJSON/cJSON.h

@@ -27,7 +27,7 @@
 extern "C"
 {
 #endif
-
+#pragma pack(1)
 /* cJSON Types: */
 #define cJSON_False 0
 #define cJSON_True 1
@@ -143,7 +143,7 @@ extern void cJSON_Minify(char *json);
 /* When assigning an integer value, it needs to be propagated to valuedouble too. */
 #define cJSON_SetIntValue(object,val)			((object)?(object)->valueint=(object)->valuedouble=(val):(val))
 #define cJSON_SetNumberValue(object,val)		((object)?(object)->valueint=(object)->valuedouble=(val):(val))
-
+#pragma pack()
 #ifdef __cplusplus
 }
 #endif

+ 382 - 391
app/goahead-3.6.5/src/goahead.c

@@ -1,391 +1,382 @@
-/*
-    goahead.c -- Main program for GoAhead
-
-    Usage: goahead [options] [documents] [IP][:port] ...
-        Options:
-        --auth authFile        # User and role configuration
-        --background           # Run as a Linux daemon
-        --home directory       # Change to directory to run
-        --log logFile:level    # Log to file file at verbosity level
-        --route routeFile      # Route configuration file
-        --verbose              # Same as --log stdout:2
-        --version              # Output version information
-
-    Copyright (c) All Rights Reserved. See details at the end of the file.
- */
-
-/********************************* Includes ***********************************/
-
-#include    "goahead.h"
-#include    "dashboard.h"
-#include    "cJSON.h"
-
-/********************************* Defines ************************************/
-
-static int finished = 0;
-
-/********************************* Forwards ***********************************/
-
-static void initPlatform();
-static void logHeader();
-static void usage();
-
-#if WINDOWS
-static void windowsClose();
-static int windowsInit();
-static LRESULT CALLBACK websWindProc(HWND hwnd, UINT msg, UINT wp, LPARAM lp);
-#endif
-
-#if ME_UNIX_LIKE
-static void sigHandler(int signo);
-#endif
-
-/*********************************** Code *************************************/
-
-MAIN(goahead, int argc, char **argv, char **envp)
-{
-    char    *argp, *home, *documents, *endpoints, *endpoint, *route, *auth, *tok, *lspec;
-    int     argind;
-
-#if WINDOWS
-    if (windowsInit() < 0) {
-        return 0;
-    }
-#endif
-    route = "route.txt";
-    auth = "auth.txt";
-
-/**************** user code before goahead ************************/   
-cJSON_Hooks hooks;
-hooks.malloc_fn = (void *(*)(size_t))walloc;
-hooks.free_fn = (void (*)(void *))wfree;
-cJSON_InitHooks(&hooks);
-
-/**************** user code before goahead end************************/
-    for (argind = 1; argind < argc; argind++) {
-        argp = argv[argind];
-        if (*argp != '-') {
-            break;
-
-        } else if (smatch(argp, "--auth") || smatch(argp, "-a")) {
-            if (argind >= argc) usage();
-            auth = argv[++argind];
-
-#if ME_UNIX_LIKE && !MACOSX
-        } else if (smatch(argp, "--background") || smatch(argp, "-b")) {
-            websSetBackground(1);
-#endif
-
-        } else if (smatch(argp, "--debugger") || smatch(argp, "-d") || smatch(argp, "-D")) {
-            websSetDebug(1);
-
-        } else if (smatch(argp, "--home")) {
-            if (argind >= argc) usage();
-            home = argv[++argind];
-            if (chdir(home) < 0) {
-                error("Cannot change directory to %s", home);
-                exit(-1);
-            }
-        } else if (smatch(argp, "--log") || smatch(argp, "-l")) {
-            if (argind >= argc) usage();
-            logSetPath(argv[++argind]);
-
-        } else if (smatch(argp, "--verbose") || smatch(argp, "-v")) {
-            logSetPath("stdout:2");
-
-        } else if (smatch(argp, "--route") || smatch(argp, "-r")) {
-            route = argv[++argind];
-
-        } else if (smatch(argp, "--version") || smatch(argp, "-V")) {
-            printf("%s\n", ME_VERSION);
-            exit(0);
-
-        } else if (*argp == '-' && isdigit((uchar) argp[1])) {
-            lspec = sfmt("stdout:%s", &argp[1]);
-            logSetPath(lspec);
-            wfree(lspec);
-
-        } else {
-            usage();
-        }
-    }
-    documents = ME_GOAHEAD_DOCUMENTS;
-    if (argc > argind) {
-        documents = argv[argind++];
-    }
-    printf("---> initPlatform\n");
-    initPlatform();
-    printf("---> websOpen\n");
-    if (websOpen(documents, route) < 0) {
-        error("Cannot initialize server. Exiting.");
-        return -1;
-    }
-#if ME_GOAHEAD_AUTH
-    printf("---> websLoad\n");
-    if (websLoad(auth) < 0) {
-        error("Cannot load %s", auth);
-        return -1;
-    }
-#endif
-    logHeader();
-    if (argind < argc) {
-        while (argind < argc) {
-            endpoint = argv[argind++];
-            printf("---> websListen log1\n");
-            if (websListen(endpoint) < 0) {
-                return -1;
-            }
-        }
-    } else {
-        endpoints = sclone(ME_GOAHEAD_LISTEN);
-        for (endpoint = stok(endpoints, ", \t", &tok); endpoint; endpoint = stok(NULL, ", \t,", &tok)) {
-#if !ME_COM_SSL
-            if (strstr(endpoint, "https")) continue;
-#endif
-            printf("---> websListen log2\n");
-            if (websListen(endpoint) < 0) {
-                wfree(endpoints);
-                return -1;
-            }
-        }
-        wfree(endpoints);
-    }
-#if ME_ROM && KEEP
-    /*
-        If not using a route/auth config files, then manually create the routes like this:
-        If custom matching is required, use websSetRouteMatch. If authentication is required, use websSetRouteAuth.
-     */
-    websAddRoute("/", "file", 0);
-#endif
-
-/**************** user code after goahead ************************/   
-websDefineAction("test", actionTest);
-websDefineAction("buy", buy);
-
-websDefineAction("getDeviceInfo", getDeviceInfo);
-websDefineAction("getSysInfo", getSysInfo);
-websDefineAction("getCardInfo", getCardInfo);
-websDefineAction("getSensorInfo", getSensorInfo);
- 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-/**************** user code after goahead end************************/
-
-#if ME_UNIX_LIKE && !MACOSX
-    /*
-        Service events till terminated
-     */
-    if (websGetBackground()) {
-        printf("---> daemon\n");
-        if (daemon(0, 0) < 0) {
-            error("Cannot run as daemon");
-            return -1;
-        }
-    }
-#endif
-    printf("---> websServiceEvents\n");
-    websServiceEvents(&finished);
-    logmsg(1, "Instructed to exit");
-    printf("---> websClose\n");
-    websClose();
-#if WINDOWS
-    windowsClose();
-#endif
-    return 0;
-}
-
-
-static void logHeader()
-{
-    char    home[ME_GOAHEAD_LIMIT_STRING];
-
-    getcwd(home, sizeof(home));
-    logmsg(2, "Configuration for %s", ME_TITLE);
-    logmsg(2, "---------------------------------------------");
-    logmsg(2, "Version:            %s", ME_VERSION);
-    logmsg(2, "BuildType:          %s", ME_DEBUG ? "Debug" : "Release");
-    logmsg(2, "CPU:                %s", ME_CPU);
-    logmsg(2, "OS:                 %s", ME_OS);
-    logmsg(2, "Host:               %s", websGetServer());
-    logmsg(2, "Directory:          %s", home);
-    logmsg(2, "Documents:          %s", websGetDocuments());
-    logmsg(2, "Configure:          %s", ME_CONFIG_CMD);
-    logmsg(2, "---------------------------------------------");
-}
-
-
-static void usage() {
-    fprintf(stderr, "\n%s Usage:\n\n"
-        "  %s [options] [documents] [[IPaddress][:port] ...]\n\n"
-        "  Options:\n"
-#if ME_GOAHEAD_AUTH
-        "    --auth authFile        # User and role configuration\n"
-#endif
-#if ME_UNIX_LIKE && !MACOSX
-        "    --background           # Run as a Unix daemon\n"
-#endif
-        "    --debugger             # Run in debug mode\n"
-        "    --home directory       # Change to directory to run\n"
-        "    --log logFile:level    # Log to file file at verbosity level\n"
-        "    --route routeFile      # Route configuration file\n"
-        "    --verbose              # Same as --log stdout:2\n"
-        "    --version              # Output version information\n\n",
-        ME_TITLE, ME_NAME);
-    exit(-1);
-}
-
-
-static void initPlatform()
-{
-#if ME_UNIX_LIKE
-    signal(SIGTERM, sigHandler);
-    #ifdef SIGPIPE
-        signal(SIGPIPE, SIG_IGN);
-    #endif
-#elif ME_WIN_LIKE
-    _fmode=_O_BINARY;
-#endif
-}
-
-
-#if ME_UNIX_LIKE
-static void sigHandler(int signo)
-{
-    finished = 1;
-}
-#endif
-
-
-#if WINDOWS
-/*
-    Create a taskbar entry. Register the window class and create a window
- */
-static int windowsInit()
-{
-    HINSTANCE   inst;
-    WNDCLASS    wc;                     /* Window class */
-    HMENU       hSysMenu;
-    HWND        hwnd;
-
-    inst = websGetInst();
-    wc.style         = CS_HREDRAW | CS_VREDRAW;
-    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
-    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
-    wc.cbClsExtra    = 0;
-    wc.cbWndExtra    = 0;
-    wc.hInstance     = inst;
-    wc.hIcon         = NULL;
-    wc.lpfnWndProc   = (WNDPROC) websWindProc;
-    wc.lpszMenuName  = wc.lpszClassName = ME_NAME;
-    if (! RegisterClass(&wc)) {
-        return -1;
-    }
-    /*
-        Create a window just so we can have a taskbar to close this web server
-     */
-    hwnd = CreateWindow(ME_NAME, ME_TITLE, WS_MINIMIZE | WS_POPUPWINDOW, CW_USEDEFAULT,
-        0, 0, 0, NULL, NULL, inst, NULL);
-    if (hwnd == NULL) {
-        return -1;
-    }
-
-    /*
-        Add the about box menu item to the system menu
-     */
-    hSysMenu = GetSystemMenu(hwnd, FALSE);
-    if (hSysMenu != NULL) {
-        AppendMenu(hSysMenu, MF_SEPARATOR, 0, NULL);
-    }
-    ShowWindow(hwnd, SW_SHOWNORMAL);
-    UpdateWindow(hwnd);
-    return 0;
-}
-
-
-static void windowsClose()
-{
-    HINSTANCE   inst;
-
-    inst = websGetInst();
-    UnregisterClass(ME_NAME, inst);
-}
-
-
-/*
-    Main menu window message handler.
- */
-static LRESULT CALLBACK websWindProc(HWND hwnd, UINT msg, UINT wp, LPARAM lp)
-{
-    switch (msg) {
-        case WM_DESTROY:
-            PostQuitMessage(0);
-            finished++;
-            return 0;
-
-        case WM_SYSCOMMAND:
-            break;
-    }
-    return DefWindowProc(hwnd, msg, wp, lp);
-}
-
-
-/*
-    Check for Windows Messages
- */
-WPARAM checkWindowsMsgLoop()
-{
-    MSG     msg;
-
-    if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
-        if (!GetMessage(&msg, NULL, 0, 0) || msg.message == WM_QUIT) {
-            return msg.wParam;
-        }
-        TranslateMessage(&msg);
-        DispatchMessage(&msg);
-    }
-    return 0;
-}
-
-
-/*
-    Windows message handler
- */
-static LRESULT CALLBACK websAboutProc(HWND hwndDlg, uint msg, uint wp, long lp)
-{
-    LRESULT    lResult;
-
-    lResult = DefWindowProc(hwndDlg, msg, wp, lp);
-
-    switch (msg) {
-        case WM_CREATE:
-            break;
-        case WM_DESTROY:
-            break;
-        case WM_COMMAND:
-            break;
-    }
-    return lResult;
-}
-
-#endif
-
-/*
-    Copyright (c) Embedthis Software. All Rights Reserved.
-    This software is distributed under commercial and open source licenses.
-    You may use the Embedthis GoAhead open source license or you may acquire
-    a commercial license from Embedthis Software. You agree to be fully bound
-    by the terms of either license. Consult the LICENSE.md distributed with
-    this software for full details and other copyrights.
- */
+/*
+    goahead.c -- Main program for GoAhead
+
+    Usage: goahead [options] [documents] [IP][:port] ...
+        Options:
+        --auth authFile        # User and role configuration
+        --background           # Run as a Linux daemon
+        --home directory       # Change to directory to run
+        --log logFile:level    # Log to file file at verbosity level
+        --route routeFile      # Route configuration file
+        --verbose              # Same as --log stdout:2
+        --version              # Output version information
+
+    Copyright (c) All Rights Reserved. See details at the end of the file.
+ */
+
+/********************************* Includes ***********************************/
+
+#include    "goahead.h"
+#include    "dashboard.h"
+#include    "cJSON.h"
+
+/********************************* Defines ************************************/
+
+static int finished = 0;
+
+/********************************* Forwards ***********************************/
+
+static void initPlatform();
+static void logHeader();
+static void usage();
+
+#if WINDOWS
+static void windowsClose();
+static int windowsInit();
+static LRESULT CALLBACK websWindProc(HWND hwnd, UINT msg, UINT wp, LPARAM lp);
+#endif
+
+#if ME_UNIX_LIKE
+static void sigHandler(int signo);
+#endif
+
+/*********************************** Code *************************************/
+
+MAIN(goahead, int argc, char **argv, char **envp)
+{
+    char    *argp, *home, *documents, *endpoints, *endpoint, *route, *auth, *tok, *lspec;
+    int     argind;
+
+#if WINDOWS
+    if (windowsInit() < 0) {
+        return 0;
+    }
+#endif
+    route = "route.txt";
+    auth = "auth.txt";
+
+/**************** user code before goahead ************************/   
+cJSON_Hooks hooks;
+hooks.malloc_fn = (void *(*)(size_t))walloc;
+hooks.free_fn = (void (*)(void *))wfree;
+cJSON_InitHooks(&hooks);
+
+/**************** user code before goahead end************************/
+    for (argind = 1; argind < argc; argind++) {
+        argp = argv[argind];
+        if (*argp != '-') {
+            break;
+
+        } else if (smatch(argp, "--auth") || smatch(argp, "-a")) {
+            if (argind >= argc) usage();
+            auth = argv[++argind];
+
+#if ME_UNIX_LIKE && !MACOSX
+        } else if (smatch(argp, "--background") || smatch(argp, "-b")) {
+            websSetBackground(1);
+#endif
+
+        } else if (smatch(argp, "--debugger") || smatch(argp, "-d") || smatch(argp, "-D")) {
+            websSetDebug(1);
+
+        } else if (smatch(argp, "--home")) {
+            if (argind >= argc) usage();
+            home = argv[++argind];
+            if (chdir(home) < 0) {
+                error("Cannot change directory to %s", home);
+                exit(-1);
+            }
+        } else if (smatch(argp, "--log") || smatch(argp, "-l")) {
+            if (argind >= argc) usage();
+            logSetPath(argv[++argind]);
+
+        } else if (smatch(argp, "--verbose") || smatch(argp, "-v")) {
+            logSetPath("stdout:2");
+
+        } else if (smatch(argp, "--route") || smatch(argp, "-r")) {
+            route = argv[++argind];
+
+        } else if (smatch(argp, "--version") || smatch(argp, "-V")) {
+            printf("%s\n", ME_VERSION);
+            exit(0);
+
+        } else if (*argp == '-' && isdigit((uchar) argp[1])) {
+            lspec = sfmt("stdout:%s", &argp[1]);
+            logSetPath(lspec);
+            wfree(lspec);
+
+        } else {
+            usage();
+        }
+    }
+    documents = ME_GOAHEAD_DOCUMENTS;
+    if (argc > argind) {
+        documents = argv[argind++];
+    }
+    printf("---> initPlatform\n");
+    initPlatform();
+    printf("---> websOpen\n");
+    if (websOpen(documents, route) < 0) {
+        error("Cannot initialize server. Exiting.");
+        return -1;
+    }
+#if ME_GOAHEAD_AUTH
+    printf("---> websLoad\n");
+    if (websLoad(auth) < 0) {
+        error("Cannot load %s", auth);
+        return -1;
+    }
+#endif
+    logHeader();
+    if (argind < argc) {
+        while (argind < argc) {
+            endpoint = argv[argind++];
+            printf("---> websListen log1\n");
+            if (websListen(endpoint) < 0) {
+                return -1;
+            }
+        }
+    } else {
+        endpoints = sclone(ME_GOAHEAD_LISTEN);
+        for (endpoint = stok(endpoints, ", \t", &tok); endpoint; endpoint = stok(NULL, ", \t,", &tok)) {
+#if !ME_COM_SSL
+            if (strstr(endpoint, "https")) continue;
+#endif
+            printf("---> websListen log2\n");
+            if (websListen(endpoint) < 0) {
+                wfree(endpoints);
+                return -1;
+            }
+        }
+        wfree(endpoints);
+    }
+#if ME_ROM && KEEP
+    /*
+        If not using a route/auth config files, then manually create the routes like this:
+        If custom matching is required, use websSetRouteMatch. If authentication is required, use websSetRouteAuth.
+     */
+    websAddRoute("/", "file", 0);
+#endif
+
+/**************** user code after goahead ************************/   
+websDefineAction("test", actionTest);
+websDefineAction("buy", buy);
+
+websDefineAction("getDeviceInfo", getDeviceInfo);
+websDefineAction("getSysInfo", getSysInfo);
+websDefineAction("getCardInfo", getCardInfo);
+websDefineAction("getSensorInfo", getSensorInfo);
+ 
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/**************** user code after goahead end************************/
+
+#if ME_UNIX_LIKE && !MACOSX
+    /*
+        Service events till terminated
+     */
+    if (websGetBackground()) {
+        printf("---> daemon\n");
+        if (daemon(0, 0) < 0) {
+            error("Cannot run as daemon");
+            return -1;
+        }
+    }
+#endif
+    printf("---> websServiceEvents\n");
+    websServiceEvents(&finished);
+    logmsg(1, "Instructed to exit");
+    printf("---> websClose\n");
+    websClose();
+#if WINDOWS
+    windowsClose();
+#endif
+    return 0;
+}
+
+
+static void logHeader()
+{
+    char    home[ME_GOAHEAD_LIMIT_STRING];
+
+    getcwd(home, sizeof(home));
+    logmsg(2, "Configuration for %s", ME_TITLE);
+    logmsg(2, "---------------------------------------------");
+    logmsg(2, "Version:            %s", ME_VERSION);
+    logmsg(2, "BuildType:          %s", ME_DEBUG ? "Debug" : "Release");
+    logmsg(2, "CPU:                %s", ME_CPU);
+    logmsg(2, "OS:                 %s", ME_OS);
+    logmsg(2, "Host:               %s", websGetServer());
+    logmsg(2, "Directory:          %s", home);
+    logmsg(2, "Documents:          %s", websGetDocuments());
+    logmsg(2, "Configure:          %s", ME_CONFIG_CMD);
+    logmsg(2, "---------------------------------------------");
+}
+
+
+static void usage() {
+    fprintf(stderr, "\n%s Usage:\n\n"
+        "  %s [options] [documents] [[IPaddress][:port] ...]\n\n"
+        "  Options:\n"
+#if ME_GOAHEAD_AUTH
+        "    --auth authFile        # User and role configuration\n"
+#endif
+#if ME_UNIX_LIKE && !MACOSX
+        "    --background           # Run as a Unix daemon\n"
+#endif
+        "    --debugger             # Run in debug mode\n"
+        "    --home directory       # Change to directory to run\n"
+        "    --log logFile:level    # Log to file file at verbosity level\n"
+        "    --route routeFile      # Route configuration file\n"
+        "    --verbose              # Same as --log stdout:2\n"
+        "    --version              # Output version information\n\n",
+        ME_TITLE, ME_NAME);
+    exit(-1);
+}
+
+
+static void initPlatform()
+{
+#if ME_UNIX_LIKE
+    signal(SIGTERM, sigHandler);
+    #ifdef SIGPIPE
+        signal(SIGPIPE, SIG_IGN);
+    #endif
+#elif ME_WIN_LIKE
+    _fmode=_O_BINARY;
+#endif
+}
+
+
+#if ME_UNIX_LIKE
+static void sigHandler(int signo)
+{
+    finished = 1;
+}
+#endif
+
+
+#if WINDOWS
+/*
+    Create a taskbar entry. Register the window class and create a window
+ */
+static int windowsInit()
+{
+    HINSTANCE   inst;
+    WNDCLASS    wc;                     /* Window class */
+    HMENU       hSysMenu;
+    HWND        hwnd;
+
+    inst = websGetInst();
+    wc.style         = CS_HREDRAW | CS_VREDRAW;
+    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
+    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
+    wc.cbClsExtra    = 0;
+    wc.cbWndExtra    = 0;
+    wc.hInstance     = inst;
+    wc.hIcon         = NULL;
+    wc.lpfnWndProc   = (WNDPROC) websWindProc;
+    wc.lpszMenuName  = wc.lpszClassName = ME_NAME;
+    if (! RegisterClass(&wc)) {
+        return -1;
+    }
+    /*
+        Create a window just so we can have a taskbar to close this web server
+     */
+    hwnd = CreateWindow(ME_NAME, ME_TITLE, WS_MINIMIZE | WS_POPUPWINDOW, CW_USEDEFAULT,
+        0, 0, 0, NULL, NULL, inst, NULL);
+    if (hwnd == NULL) {
+        return -1;
+    }
+
+    /*
+        Add the about box menu item to the system menu
+     */
+    hSysMenu = GetSystemMenu(hwnd, FALSE);
+    if (hSysMenu != NULL) {
+        AppendMenu(hSysMenu, MF_SEPARATOR, 0, NULL);
+    }
+    ShowWindow(hwnd, SW_SHOWNORMAL);
+    UpdateWindow(hwnd);
+    return 0;
+}
+
+
+static void windowsClose()
+{
+    HINSTANCE   inst;
+
+    inst = websGetInst();
+    UnregisterClass(ME_NAME, inst);
+}
+
+
+/*
+    Main menu window message handler.
+ */
+static LRESULT CALLBACK websWindProc(HWND hwnd, UINT msg, UINT wp, LPARAM lp)
+{
+    switch (msg) {
+        case WM_DESTROY:
+            PostQuitMessage(0);
+            finished++;
+            return 0;
+
+        case WM_SYSCOMMAND:
+            break;
+    }
+    return DefWindowProc(hwnd, msg, wp, lp);
+}
+
+
+/*
+    Check for Windows Messages
+ */
+WPARAM checkWindowsMsgLoop()
+{
+    MSG     msg;
+
+    if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
+        if (!GetMessage(&msg, NULL, 0, 0) || msg.message == WM_QUIT) {
+            return msg.wParam;
+        }
+        TranslateMessage(&msg);
+        DispatchMessage(&msg);
+    }
+    return 0;
+}
+
+
+/*
+    Windows message handler
+ */
+static LRESULT CALLBACK websAboutProc(HWND hwndDlg, uint msg, uint wp, long lp)
+{
+    LRESULT    lResult;
+
+    lResult = DefWindowProc(hwndDlg, msg, wp, lp);
+
+    switch (msg) {
+        case WM_CREATE:
+            break;
+        case WM_DESTROY:
+            break;
+        case WM_COMMAND:
+            break;
+    }
+    return lResult;
+}
+
+#endif

+ 5 - 10
app/goahead-3.6.5/src/goahead.h

@@ -24,6 +24,8 @@
 extern "C" {
 #endif
 
+#pragma pack(1)
+
 #if (ME_COM_MBEDTLS + ME_COM_MATRIXSSL + ME_COM_NANOSSL + ME_COM_OPENSSL) > 1
     #error "Cannot have more than one SSL provider configured"
 #endif
@@ -4158,16 +4160,9 @@ PUBLIC int websSetSessionVar(Webs *wp, char *name, char *value);
  #include "customize.h"
 #endif
 
+#pragma pack()
+
 #ifdef __cplusplus
 }
 #endif
-#endif /* _h_GOAHEAD */
-
-/*
-    Copyright (c) Embedthis Software. All Rights Reserved.
-    This software is distributed under commercial and open source licenses.
-    You may use the Embedthis GoAhead open source license or you may acquire
-    a commercial license from Embedthis Software. You agree to be fully bound
-    by the terms of either license. Consult the LICENSE.md distributed with
-    this software for full details and other copyrights.
- */
+#endif /* _h_GOAHEAD */

+ 2 - 2
app/goahead-3.6.5/src/libipmi/inc/libipmi_ChassisDevice.h

@@ -17,7 +17,7 @@
 extern "C" {
 #endif
 
-
+#pragma pack(1)
 
 
 /*---------- LIBIPMI Higher level routines -----------*/
@@ -149,7 +149,7 @@ typedef enum tag_FORCE_CHASSIS_ID
 uint16_t	LIBIPMI_HL_GetSystemBootOptions_BootFlags( IPMI20_UDS_SESSION_T *pUDSSession, BootFlags_T* pBootFlags,int timeout);
 uint16_t	LIBIPMI_HL_SetSystemBootOptions_BootFlags( IPMI20_UDS_SESSION_T *pUDSSession, BootFlags_T* pBootFlags,int timeout);
 
-    
+#pragma pack()
 
 #ifdef  __cplusplus
 }

+ 0 - 1
app/goahead-3.6.5/src/libipmi/inc/libipmi_StorDevice.h

@@ -100,7 +100,6 @@ typedef struct _SELEventRecordWithSensorName
 #define MAX_FRU_DEVICES	32
 #endif
 
-#pragma pack(1)
 typedef struct _SDRHeader
 {
     /** The ID of this SDR, LSB first */

+ 2 - 1
app/goahead-3.6.5/src/libipmi/inc/libipmi_fru.h

@@ -21,6 +21,7 @@
 
 #define _LIBIPMI_FRU_
 
+#pragma pack(1)
 
 #include "libipmi_session.h"
 #include "libipmi_errorcodes.h"
@@ -90,5 +91,5 @@ typedef struct fru_t
 
 void LIBIPMI_HL_FreeFRUData(FRUData_T* fru_data);
 
-
+#pragma pack()
 #endif

+ 1 - 1
app/goahead-3.6.5/src/libipmi/inc/libipmi_storlead_OEM.h

@@ -84,7 +84,6 @@ typedef struct{
 	uint8_t supportHistory;
 	
 } OemWebFlags_T;
-#pragma pack()
 
 typedef struct 
 {
@@ -121,5 +120,6 @@ uint16_t LIBIPMI_HL_GetSysInfo( IPMI20_UDS_SESSION_T *pUDSSession, SysInfo_T *pS
 //int LIBIPMI_HL_GetSensorHistoryEn(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t* SensorHistoryEnable, int timeout);
 //int LIBIPMI_HL_SetSensorHistoryEn(IPMI20_UDS_SESSION_T *pUDSSession, uint8_t sensorNum, uint8_t SensorHistoryEnable, int timeout);
 
+#pragma pack()
 #endif /* __LIBIPMI_STORLEAD_OEM_H__ */
 

+ 2 - 2
app/goahead-3.6.5/src/libipmi/inc/libipmi_usermgmt.h

@@ -1,7 +1,7 @@
 #ifndef __LIBIPMI_USER_MANAGEMENT_H__
 #define __LIBIPMI_USER_MANAGEMENT_H__
 
-#define PACK __attribute__ ((packed))
+#pragma pack(1)
 
 typedef struct {
 	uint8_t		byUserID;
@@ -13,7 +13,7 @@ typedef struct {
 	char		szUserName[16];
 } GetUser_T;
 
-#undef PACK
+#pragma pack()
 
 
 #endif

+ 0 - 3
app/goahead-3.6.5/src/libipmi/src/libipmi_session.c

@@ -90,9 +90,6 @@ uint16_t LIBIPMI_Send_RAW_IPMI2_0_Command(IPMI20_UDS_SESSION_T *pUDSSession,		//
    	uint8_t pbyIPMIUDSResData[MAX_RESPONSE_SIZE];
    	uint32_t retlen=0,byretval=0;
 
-   	memset(pbyIPMIUDSMsgReq,0,MAX_REQUEST_SIZE);
-   	memset(pbyIPMIUDSResData,0,MAX_RESPONSE_SIZE);
-
    	retlen = FillUDSMessagePacket(pUDSSession,pbyIPMIUDSMsgReq,byNetFnLUN,byCommand,pszReqData,dwReqDataLen);
 
     if(retlen <= 0 )

+ 3 - 3
app/goahead-3.6.5/src/libipmi/src/libipmi_uds_session.c

@@ -121,7 +121,7 @@ uint8_t UDS_ReceiveData( UDS_CHANNEL_T *UDSInfo, char *szBuffer, uint32_t* pdwSi
 
         /* socket is ready to receive data */
         if(FD_ISSET(UDSInfo->hSocket,&rdfs))
-        {
+         {
             nBytesRecvd = recv(UDSInfo->hSocket,szBuffer+totalrecvd,MAX_RESPONSE_SIZE,0);
             if(nBytesRecvd == 0)
             {
@@ -169,7 +169,7 @@ int UDS_SendData(UDS_CHANNEL_T *UDSInfo,char *szBuffer,uint32_t dwsize,int timeo
     struct timeval wait_time, *pwait_time;
     fd_set wdfs;
     int ret;
-    int nDes;
+   int nDes;
 
     /* Wait for the socket to get ready */
     if(timeout >= 0)
@@ -211,7 +211,7 @@ TCPSendUDSDataSelect:
         return LIBIPMI_MEDIUM_E_TIMED_OUT_ON_SEND;
     }
 
-    if(FD_ISSET(UDSInfo->hSocket,&wdfs))
+   if(FD_ISSET(UDSInfo->hSocket,&wdfs))
     {
         /* socket is ready to send data */
         nTotalBytesSent = 0;

+ 1 - 1
app/goahead-3.6.5/src/osdep/osdep.h

@@ -1395,4 +1395,4 @@ extern "C" {
 /*
     Copyright (c) Michael O'Brien. All Rights Reserved.
     This is proprietary software and requires a commercial license from the author.
- */
+ */

+ 1 - 3
app/goahead-3.6.5/src/route.txt

@@ -31,7 +31,7 @@
 #
 #   Standard routes
 #
-#route uri=/cgi-bin dir=cgi-bin handler=cgi
+# route uri=/cgi-bin dir=cgi-bin handler=cgi
 route uri=/action handler=action
 route uri=/ extensions=jst handler=jst
 route uri=/ methods=OPTIONS|TRACE handler=options
@@ -44,5 +44,3 @@ route uri=/goform handler=action
 #
 route uri=/
 
-############## BMC web page #####################
-route uri=/index.html

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

@@ -924,6 +924,7 @@ PUBLIC void socketFree(int sid)
     char        buf[256];
     int         i;
 
+    printf("---> socketFree\n");
     if ((sp = socketPtr(sid)) == NULL) {
         return;
     }

+ 5 - 15
app/goahead-3.6.5/src/web_interface/src/dashboard.c

@@ -93,7 +93,6 @@ void getDeviceInfo(Webs *wp){
     pStr = cJSON_Print(root);
 
     printf("---> cJSON Str:\n%s\n", pStr);
-    
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);
     websWriteEndHeaders(wp);
@@ -106,7 +105,6 @@ void getDeviceInfo(Webs *wp){
     if(root)
         cJSON_Delete(root);
 
-    
 }
 
 
@@ -477,25 +475,18 @@ void actionTest(Webs *wp)
 
 
 
-
-
-
     char *pStr;
 
     char *testStr;
     testStr = walloc(500); 
     //sprintf(testStr, "{data: {\"Version\": \"%s\", \"MAC\": \"%s\", \"IP\": \"%s\"}, \"msg\":\"\"}", FwVersion, MacAddr, IpAddr);
 
-    sprintf(testStr, "{\"data\": {\"buildTime\":\"%s\",\"fwVersion\":\"%s\",\"macAddr\":\"%s\",\"ipAddr\":\"%s\"},\"msg\":\"\",\"code\": %d}", \
+    sprintf(testStr, "{\n\t\"data\": {\n\t\t\"buildTime\":\"%s\",\n\t\t\"fwVersion\":\"%s\",\n\t\t\"macAddr\":\"%s\",\n\t\t\"ipAddr\":\"%s\"\n\t},\n\t\"msg\":\"\",\n\t\"code\": %d\n}", \
         BuildTime, FwVersion, MacAddr, IpAddr, 200);
-
-
-    //sprintf(testStr, "jimbo and lusa are very confused, please git me some tips, my god!");
-
      pStr = testStr;
 
-    cJSON * root =  cJSON_CreateObject();
-    cJSON * data =  cJSON_CreateObject();
+    // cJSON * root =  cJSON_CreateObject();
+    // cJSON * data =  cJSON_CreateObject();
     printf("log1\n");
     // cJSON_AddItemToObject(root, "data", data);//根节点下添加
     // cJSON_AddItemToObject(root, "msg", cJSON_CreateString(""));
@@ -515,7 +506,6 @@ void actionTest(Webs *wp)
  //    pStr = cJSON_Print(root);     //include malloc
     
     printf("%s\n", pStr);
-
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);
     websWriteEndHeaders(wp);
@@ -526,8 +516,8 @@ void actionTest(Webs *wp)
     if(pStr)
         wfree(pStr);
 
-    cJSON_Delete(root);
-    cJSON_Delete(data);
+    // cJSON_Delete(root);
+    // cJSON_Delete(data);
 
     
 }

BIN
app/test_app/test_app