浏览代码

test submit

lusa 5 年之前
父节点
当前提交
991e56180f
共有 3 个文件被更改,包括 73 次插入38 次删除
  1. 3 0
      app/goahead-5.1.0/README.md
  2. 1 0
      app/goahead-5.1.0/src/cgi.c
  3. 69 38
      app/goahead-5.1.0/src/goahead.c

+ 3 - 0
app/goahead-5.1.0/README.md

@@ -140,3 +140,6 @@ Resources
   - [GoAhead web site](https://www.embedthis.com/goahead/)
   - [Embedthis web site](https://www.embedthis.com/)
   - [GoAhead GitHub repository](http://github.com/embedthis/goahead)
+
+
+hello

+ 1 - 0
app/goahead-5.1.0/src/cgi.c

@@ -281,6 +281,7 @@ static void writeCgiHeaders(Webs *wp, int status, ssize contentLength, char *loc
     if (contentType) {
         websWriteHeader(wp, "Content-Type", contentType);
     }
+    printf(">>>>>>>>>>>")
 }
 
 

+ 69 - 38
app/goahead-5.1.0/src/goahead.c

@@ -17,11 +17,7 @@
 /********************************* Includes ***********************************/
 
 #include    "goahead.h"
-#include	"cJSON.h"
-#include    "libipmi_session.h"
-#include	<stdio.h>
-#include    "com_IPMI_App.h"
-#include    "com_IPMIDefs.h"
+
 /********************************* Defines ************************************/
 
 static int finished = 0;
@@ -42,49 +38,69 @@ static LRESULT CALLBACK websWindProc(HWND hwnd, UINT msg, UINT wp, LPARAM lp);
 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;
-
-    route = "route.txt";
-    auth = "auth.txt";
-
-
-//static void buy(Webs *wp);
-//static void actionTest(Webs *wp);
+static void buy(Webs *wp);
+static void actionTest(Webs *wp);
 // static void personInfoAction(Webs *wp);
 
 
-    /********************** jimbo test code ******************************/
-	//jimboTestcJson();
-    IPMI20_SESSION_T TestSession;
-    uint8_t resBuf[100];
-    uint32_t resLen;
-
-    LIBIPMI_CreateSession(&TestSession, 10);
-
-    LIBIPMI_Send_RAW_IPMI2_0_Command(&TestSession,
-        NETFN_APP, CMD_GET_DEV_ID,
-        NULL, 0,
-        resBuf, &resLen,
-            10);
-
-    LIBIPMI_CloseSession( &TestSession );
-
-
-
+static void buy(Webs *wp)
+{
+    char    *name, *age;
+    name = websGetVar(wp, "name", NULL);
+    age = websGetVar(wp, "age", NULL);
+     logmsg(2, "---------------------------------------------");
+    logmsg(2, "name value is : %s", name );
+     logmsg(2, "age value is : %s", age );
+    websSetStatus(wp, 200);
+    websWriteHeaders(wp, 0, 0);
+    websWriteEndHeaders(wp);
+    printf("aa");
+    websWrite(wp, "Name %s", name); 
+    websWrite(wp,  "Age %s", age);
+    websFlush(wp, 0);
+    websDone(wp);
+}
 
-    /********************** test end ************************************/
 
 
+/*
+    Implement /action/actionTest. Parse the form variables: name, address and echo back.
+ */
+static void actionTest(Webs *wp)
+{
+    cchar   *name, *address;
+
+    name = websGetVar(wp, "name", NULL);
+    address = websGetVar(wp, "address", NULL);
+    websSetStatus(wp, 200);
+    websWriteHeaders(wp, -1, 0);
+    websWriteEndHeaders(wp);
+    websWrite(wp, "<html><body><h2>name: %s, address: %s</h2></body></html>\n", name, address);
+    websFlush(wp, 0);
+    websDone(wp);
+}
 
+/*********************************** Code *************************************/
 
+MAIN(goahead, int argc, char **argv, char **envp)
+{
+   
+    char    *argp, *home, *documents, *endpoints, *endpoint, *route, *auth, *tok, *lspec;
+    int     argind;
+	logmsg(2, "---> log1\n");
+	error("---> log1\n");
+#if WINDOWS
+    if (windowsInit() < 0) {
+        return 0;
+    }
+#endif
+    route = "route.txt";
+    auth = "auth.txt";
 
+	error("---> main enter, argc = %d\n", argc);
     for (argind = 1; argind < argc; argind++) {
         argp = argv[argind];
+		error("---> argp = %s\n", argp);
         if (*argp != '-') {
             break;
 
@@ -107,12 +123,14 @@ MAIN(goahead, int argc, char **argv, char **envp)
                 error("Cannot change directory to %s", home);
                 exit(-1);
             }
+			error("---> get home\n");
         } 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");
+			error( "---> get -v\n");
         } else if (smatch(argp, "--route") || smatch(argp, "-r")) {
             route = argv[++argind];
 
@@ -133,18 +151,21 @@ MAIN(goahead, int argc, char **argv, char **envp)
     if (argc > argind) {
         documents = argv[argind++];
     }
+	error("---> initPlatform\n");
     initPlatform();
     if (websOpen(documents, route) < 0) {
         error("Cannot initialize server. Exiting.");
         return -1;
     }
 #if ME_GOAHEAD_AUTH
+	error("---> ME_GOAHEAD_AUTH: %d\n", ME_GOAHEAD_AUTH);
     if (websLoad(auth) < 0) {
         error("Cannot load %s", auth);
         return -1;
     }
 #endif
     logHeader();
+	error("---> argind = %d, argc = %d\n", argind, argc);
     if (argind < argc) {
         while (argind < argc) {
             endpoint = argv[argind++];
@@ -173,6 +194,13 @@ MAIN(goahead, int argc, char **argv, char **envp)
      */
     websAddRoute("/", "file", 0);
 #endif
+
+//add by lusa start 
+        websDefineAction("buy", buy);
+        websDefineAction("test", actionTest);
+        websDefineAction("person", personInfoAction);
+        
+// add by lusa end 
 #ifdef GOAHEAD_INIT
     /*
         Define your init function in main.me goahead.init, or
@@ -197,6 +225,7 @@ MAIN(goahead, int argc, char **argv, char **envp)
         }
     }
 #endif
+	error( "---> websServiceEvents\n");
     websServiceEvents(&finished);
     logmsg(1, "Instructed to exit");
     websClose();
@@ -225,7 +254,6 @@ static void logHeader(void)
     logmsg(2, "---------------------------------------------");
 }
 
-
 static void usage(void) {
     fprintf(stderr, "\n%s Usage:\n\n"
         "  %s [options] [documents] [[IPaddress][:port] ...]\n\n"
@@ -250,12 +278,15 @@ static void usage(void) {
 static void initPlatform(void)
 {
 #if ME_UNIX_LIKE
+	error("---> initPlatform, ME_OS: %s\n", ME_OS);
     signal(SIGTERM, sigHandler);
     #ifdef SIGPIPE
+		error("---> define SIGPIPE\n");
         signal(SIGPIPE, SIG_IGN);
     #endif
 #elif ME_WIN_LIKE
     _fmode=_O_BINARY;
+    printf("%s\n", "fff");
 #endif
 }