zhangbo 4 жил өмнө
parent
commit
d75ded3dad

+ 11 - 11
app/goahead-3.6.5/paks/goahead-mbedtls/goahead-mbedtls.c

@@ -61,7 +61,7 @@ PUBLIC int sslOpen()
     mbedtls_ssl_config  *conf;
     int                 rc;
 
-    trace(7, "Initializing MbedTLS SSL"); 
+    printf( "Initializing MbedTLS SSL"); 
 
     mbedtls_entropy_init(&cfg.entropy);
 
@@ -184,11 +184,11 @@ PUBLIC int sslOpen()
     if (websGetLogLevel() >= 5) {
         char    cipher[80];
         cint    *cp;
-        trace(5, "mbedtls: Supported Ciphers");
+        printf( "mbedtls: Supported Ciphers");
         for (cp = mbedtls_ssl_list_ciphersuites(); *cp; cp++) {
             scopy(cipher, sizeof(cipher), (char*) mbedtls_ssl_get_ciphersuite_name(*cp));
             replaceHyphen(cipher, '-', '_');
-            trace(5, "mbedtls: %s (0x%04X)", cipher, *cp);
+            printf( "mbedtls: %s (0x%04X)", cipher, *cp);
         }
     }
     return 0;
@@ -367,20 +367,20 @@ PUBLIC ssize sslRead(Webs *wp, void *buf, ssize len)
     }
     while (1) {
         rc = mbedtls_ssl_read(&mb->ctx, buf, (int) len);
-        trace(5, "mbedtls: mbedtls_ssl_read %d", rc);
+        printf( "mbedtls: mbedtls_ssl_read %d", rc);
         if (rc < 0) {
             if (rc == MBEDTLS_ERR_SSL_WANT_READ || rc == MBEDTLS_ERR_SSL_WANT_WRITE)  {
                 continue;
             } else if (rc == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) {
-                trace(5, "mbedtls: connection was closed gracefully");
+                printf( "mbedtls: connection was closed gracefully");
                 sp->flags |= SOCKET_EOF;
                 return -1;
             } else if (rc == MBEDTLS_ERR_NET_CONN_RESET) {
-                trace(5, "mbedtls: connection reset");
+                printf( "mbedtls: connection reset");
                 sp->flags |= SOCKET_EOF;
                 return -1;
             } else {
-                trace(4, "mbedtls: read error -0x%", -rc);
+                printf( "mbedtls: read error -0x%", -rc);
                 sp->flags |= SOCKET_EOF;
                 return -1; 
             }
@@ -414,17 +414,17 @@ PUBLIC ssize sslWrite(Webs *wp, void *buf, ssize len)
     totalWritten = 0;
     do {
         rc = mbedtls_ssl_write(&mb->ctx, (uchar*) buf, (int) len);
-        trace(7, "mbedtls write: wrote %d of %zd", rc, len);
+        printf( "mbedtls write: wrote %d of %zd", rc, len);
         if (rc <= 0) {
             if (rc == MBEDTLS_ERR_SSL_WANT_READ || rc == MBEDTLS_ERR_SSL_WANT_WRITE) {
                 socketSetError(EAGAIN);
                 return -1;
             }
             if (rc == MBEDTLS_ERR_NET_CONN_RESET) {
-                trace(4, "mbedtls_ssl_write peer closed");
+                printf( "mbedtls_ssl_write peer closed");
                 return -1;
             } else {
-                trace(4, "mbedtls_ssl_write failed rc %d", rc);
+                printf( "mbedtls_ssl_write failed rc %d", rc);
                 return -1;
             }
         } else {
@@ -552,7 +552,7 @@ static void traceMbed(void *context, int level, cchar *file, int line, cchar *st
     if (level <= websGetLogLevel()) {
         buf = sclone((char*) str);
         buf[slen(buf) - 1] = '\0';
-        trace(level, "%s", buf);
+        pirntf( "%s", buf);
         wfree(buf);
     }
 }

+ 14 - 14
app/goahead-3.6.5/src/auth.c

@@ -392,12 +392,12 @@ static void computeUserAbilities(WebsUser *user)
 #if ME_DEBUG
     {
         WebsKey *key;
-        trace(5 | WEBS_RAW_MSG, "User \"%s\" has abilities: ", user->name);
+        printf("User \"%s\" has abilities: ", user->name);
         for (key = hashFirst(user->abilities); key; key = hashNext(user->abilities, key)) {
-            trace(5 | WEBS_RAW_MSG, "%s ", key->name.value.string);
+            printf("%s ", key->name.value.string);
             ability = key->name.value.string;
         }
-        trace(5, "");
+        printf("");
     }
 #endif
     wfree(roles);
@@ -609,7 +609,7 @@ PUBLIC bool websVerifyPasswordFromFile(Webs *wp)
 
     assert(wp);
     if (!wp->user && (wp->user = websLookupUser(wp->username)) == 0) {
-        trace(5, "verifyUser: Unknown user \"%s\"", wp->username);
+        printf("verifyUser: Unknown user \"%s\"", wp->username);
         return 0;
     }
     /*
@@ -631,9 +631,9 @@ PUBLIC bool websVerifyPasswordFromFile(Webs *wp)
         printf("---> password: %s, user->password: %s\n", wp->password, wp->user->password);
     }
     if (success) {
-        trace(5, "User \"%s\" authenticated", wp->username);
+        printf( "User \"%s\" authenticated", wp->username);
     } else {
-        trace(5, "Password for user \"%s\" failed to authenticate", wp->username);
+        printf( "Password for user \"%s\" failed to authenticate", wp->username);
     }
     return success;
 }
@@ -665,11 +665,11 @@ PUBLIC bool websVerifyPasswordFromPam(Webs *wp)
     }
     if ((res = pam_authenticate(pamh, PAM_DISALLOW_NULL_AUTHTOK)) != PAM_SUCCESS) {
         pam_end(pamh, PAM_SUCCESS);
-        trace(5, "httpPamVerifyUser failed to verify %s", wp->username);
+        printf( "httpPamVerifyUser failed to verify %s", wp->username);
         return 0;
     }
     pam_end(pamh, PAM_SUCCESS);
-    trace(5, "httpPamVerifyUser verified %s", wp->username);
+    printf( "httpPamVerifyUser verified %s", wp->username);
 
     if (!wp->user) {
         wp->user = websLookupUser(wp->username);
@@ -690,7 +690,7 @@ PUBLIC bool websVerifyPasswordFromPam(Webs *wp)
                 }
             }
             bufAddNull(&abilities);
-            trace(5, "Create temp user \"%s\" with abilities: %s", wp->username, abilities.servp);
+            printf( "Create temp user \"%s\" with abilities: %s", wp->username, abilities.servp);
             if ((wp->user = websAddUser(wp->username, 0, abilities.servp)) == 0) {
                 return 0;
             }
@@ -969,25 +969,25 @@ static bool parseDigestDetails(Webs *wp)
     when = 0; secret = 0; realm = 0;
     decoded = parseDigestNonce(wp->nonce, &secret, &realm, &when);
     if (!smatch(masterSecret, secret)) {
-        trace(2, "Access denied: Nonce mismatch");
+        printf( "Access denied: Nonce mismatch");
         wfree(decoded);
         return 0;
     } else if (!smatch(realm, ME_GOAHEAD_REALM)) {
-        trace(2, "Access denied: Realm mismatch");
+        printf( "Access denied: Realm mismatch");
         wfree(decoded);
         return 0;
     } else if (!smatch(wp->qop, "auth")) {
-        trace(2, "Access denied: Bad qop");
+        printf("Access denied: Bad qop");
         wfree(decoded);
         return 0;
     } else if ((when + (5 * 60)) < time(0)) {
-        trace(2, "Access denied: Nonce is stale");
+        printf( "Access denied: Nonce is stale");
         wfree(decoded);
         return 0;
     }
     if (!wp->user) {
         if ((wp->user = websLookupUser(wp->username)) == 0) {
-            trace(2, "Access denied: user is unknown");
+            printf("Access denied: user is unknown");
             wfree(decoded);
             return 0;
         }

+ 13 - 13
app/goahead-3.6.5/src/cgi.c

@@ -139,7 +139,7 @@ PUBLIC bool cgiHandler(Webs *wp)
         websDecodeUrl(query, query, strlen(query));
         for (cp = stok(query, " ", &tok); cp != NULL; ) {
             *(argp+n) = cp;
-            trace(5, "ARG[%d] %s", n, argp[n-1]);
+            printf("ARG[%d] %s", n, argp[n-1]);
             n++;
             if (n >= argpsize) {
                 argpsize *= 2;
@@ -176,7 +176,7 @@ PUBLIC bool cgiHandler(Webs *wp)
             } else {
                 envp[n++] = sfmt("%s=%s", s->name.value.string, s->content.value.string);
             }
-            trace(0, "Env[%d] %s", n, envp[n-1]);
+            printf( "Env[%d] %s", n, envp[n-1]);
             if (n >= envpsize) {
                 envpsize *= 2;
                 envp = wrealloc(envp, envpsize * sizeof(char *));
@@ -250,11 +250,11 @@ PUBLIC bool websProcessCgiData(Webs *wp)
     ssize   nbytes;
 
     nbytes = bufLen(&wp->input);
-    trace(5, "cgi: write %d bytes to CGI program", nbytes);
+    printf( "cgi: write %d bytes to CGI program", nbytes);
     if (write(wp->cgifd, wp->input.servp, (int) nbytes) != nbytes) {
         websError(wp, HTTP_CODE_INTERNAL_SERVER_ERROR| WEBS_CLOSE, "Cannot write to CGI gateway");
     } else {
-        trace(5, "cgi: write %d bytes to CGI program", nbytes);
+        printf( "cgi: write %d bytes to CGI program", nbytes);
     }
     websConsumeInput(wp, nbytes);
     return 1;
@@ -263,7 +263,7 @@ PUBLIC bool websProcessCgiData(Webs *wp)
 
 static void writeCgiHeaders(Webs *wp, int status, ssize contentLength, char *location, char *contentType)
 {
-    trace(5, "cgi: Start response headers");
+    printf( "cgi: Start response headers");
     websSetStatus(wp, status);
     websWriteHeaders(wp, contentLength, location);
     websWriteHeader(wp, "Pragma", "no-cache");
@@ -328,7 +328,7 @@ static ssize parseCgiHeaders(Webs *wp, char *buf)
             if (key && value && !strspn(key, "%<>/\\")) {
                 websWriteHeader(wp, key, "%s", value);
             } else {
-                trace(5, "cgi: bad response http header: \"%s\": \"%s\"", key, value);
+                printf( "cgi: bad response http header: \"%s\": \"%s\"", key, value);
             }
         }
         stok(value, "\r\n", &cp);
@@ -367,21 +367,21 @@ PUBLIC void websCgiGatherOutput(Cgi *cgip)
                 if (!(wp->flags & WEBS_HEADERS_CREATED)) {
                     if ((skip = parseCgiHeaders(wp, buf)) == 0) {
                         if (cgip->handle && sbuf.st_size < ME_GOAHEAD_LIMIT_HEADERS) {
-                            trace(5, "cgi: waiting for http headers");
+                            printf( "cgi: waiting for http headers");
                             break;
                         } else {
-                            trace(5, "cgi: missing http headers - create default headers");
+                            printf( "cgi: missing http headers - create default headers");
                             writeCgiHeaders(wp, HTTP_CODE_OK, -1, 0, 0);
                         }
                     }
                 }
-                trace(5, "cgi: write %d bytes to client", nbytes - skip);
+                printf( "cgi: write %d bytes to client", nbytes - skip);
                 websWriteBlock(wp, &buf[skip], nbytes - skip);
                 cgip->fplacemark += (off_t) nbytes;
             }
             close(fdout);
         } else {
-            trace(5, "cgi: open failed");
+            printf( "cgi: open failed");
         }
     }
 }
@@ -426,7 +426,7 @@ int websCgiPoll()
                 if (cgip->fplacemark == 0) {
                     websError(wp, HTTP_CODE_INTERNAL_SERVER_ERROR, "CGI generated no output");
                 } else {
-                    trace(5, "cgi: Request complete - calling websDone");
+                    printf( "cgi: Request complete - calling websDone");
                     websDone(wp);
                 }
                 /*
@@ -546,7 +546,7 @@ static CgiPid launchCgi(char *cgiPath, char **argp, char **envp, char *stdIn, ch
 {
     int     fdin, fdout, pid;
 
-    trace(5, "cgi: run %s", cgiPath);
+    printf( "cgi: run %s", cgiPath);
 
     if ((fdin = open(stdIn, O_RDWR | O_CREAT | O_BINARY, 0666)) < 0) {
         error("Cannot open CGI stdin: ", cgiPath);
@@ -599,7 +599,7 @@ static int checkCgi(CgiPid handle)
         Check to see if the CGI child process has terminated or not yet.
      */
     if ((pid = waitpid((CgiPid) handle, NULL, WNOHANG)) == handle) {
-        trace(5, "cgi: waited for pid %d", pid);
+        printf( "cgi: waited for pid %d", pid);
         return 0;
     } else {
         return 1;

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

@@ -68,7 +68,7 @@ static bool fileHandler(Webs *wp)
         if (websPageOpen(wp, O_RDONLY | O_BINARY, 0666) < 0) {
 #if ME_DEBUG
             if (wp->referrer) {
-                trace(1, "From %s", wp->referrer);
+                printf( "From %s", wp->referrer);
             }
 #endif
             websError(wp, HTTP_CODE_NOT_FOUND, "Cannot open document for: %s", wp->path);

+ 21 - 21
app/goahead-3.6.5/src/goahead-mbedtls/goahead-mbedtls.c

@@ -61,7 +61,7 @@ PUBLIC int sslOpen()
     mbedtls_ssl_config  *conf;
     int                 rc;
 
-    trace(7, "Initializing MbedTLS SSL"); 
+    printf( "Initializing MbedTLS SSL"); 
 
     mbedtls_entropy_init(&cfg.entropy);
 
@@ -184,11 +184,11 @@ PUBLIC int sslOpen()
     if (websGetLogLevel() >= 5) {
         char    cipher[80];
         cint    *cp;
-        trace(5, "mbedtls: Supported Ciphers");
+        printf( "mbedtls: Supported Ciphers");
         for (cp = mbedtls_ssl_list_ciphersuites(); *cp; cp++) {
             scopy(cipher, sizeof(cipher), (char*) mbedtls_ssl_get_ciphersuite_name(*cp));
             replaceHyphen(cipher, '-', '_');
-            trace(5, "mbedtls: %s (0x%04X)", cipher, *cp);
+            printf( "mbedtls: %s (0x%04X)", cipher, *cp);
         }
     }
     return 0;
@@ -296,22 +296,22 @@ static int mbedHandshake(Webs *wp)
 
     } else if ((vrc = mbedtls_ssl_get_verify_result(&mb->ctx)) != 0) {
         if (vrc & MBEDTLS_X509_BADCERT_MISSING) {
-            logmsg(2, "Certificate missing");
+            printf( "Certificate missing");
 
         } else if (vrc & MBEDTLS_X509_BADCERT_EXPIRED) {
-            logmsg(2, "Certificate expired");
+            printf( "Certificate expired");
 
         } else if (vrc & MBEDTLS_X509_BADCERT_REVOKED) {
-            logmsg(2, "Certificate revoked");
+            printf( "Certificate revoked");
 
         } else if (vrc & MBEDTLS_X509_BADCERT_CN_MISMATCH) {
-            logmsg(2, "Certificate common name mismatch");
+            printf( "Certificate common name mismatch");
 
         } else if (vrc & MBEDTLS_X509_BADCERT_KEY_USAGE || vrc & MBEDTLS_X509_BADCERT_EXT_KEY_USAGE) {
-            logmsg(2, "Unauthorized key use in certificate");
+            printf( "Unauthorized key use in certificate");
 
         } else if (vrc & MBEDTLS_X509_BADCERT_NOT_TRUSTED) {
-            logmsg(2, "Certificate not trusted");
+            printf( "Certificate not trusted");
             if (!ME_GOAHEAD_SSL_VERIFY_ISSUER) {
                 vrc = 0;
             }
@@ -324,18 +324,18 @@ static int mbedHandshake(Webs *wp)
 
         } else {
             if (mb->ctx.client_auth && !*ME_GOAHEAD_SSL_CERTIFICATE) {
-                logmsg(2, "Server requires a client certificate");
+                printf( "Server requires a client certificate");
 
             } else if (rc == MBEDTLS_ERR_NET_CONN_RESET) {
-                logmsg(2, "Peer disconnected");
+                printf( "Peer disconnected");
 
             } else {
-                logmsg(2, "Cannot handshake: error -0x%x", -rc);
+                printf( "Cannot handshake: error -0x%x", -rc);
             }
         }
         if (vrc != 0 && ME_GOAHEAD_SSL_VERIFY_PEER) {
             if (mbedtls_ssl_get_peer_cert(&mb->ctx) == 0) {
-                logmsg(2, "Peer did not provide a certificate");
+                printf( "Peer did not provide a certificate");
             }
             sp->flags |= SOCKET_EOF;
             errno = EPROTO;
@@ -367,20 +367,20 @@ PUBLIC ssize sslRead(Webs *wp, void *buf, ssize len)
     }
     while (1) {
         rc = mbedtls_ssl_read(&mb->ctx, buf, (int) len);
-        trace(5, "mbedtls: mbedtls_ssl_read %d", rc);
+        printf( "mbedtls: mbedtls_ssl_read %d", rc);
         if (rc < 0) {
             if (rc == MBEDTLS_ERR_SSL_WANT_READ || rc == MBEDTLS_ERR_SSL_WANT_WRITE)  {
                 continue;
             } else if (rc == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) {
-                trace(5, "mbedtls: connection was closed gracefully");
+                printf( "mbedtls: connection was closed gracefully");
                 sp->flags |= SOCKET_EOF;
                 return -1;
             } else if (rc == MBEDTLS_ERR_NET_CONN_RESET) {
-                trace(5, "mbedtls: connection reset");
+                printf( "mbedtls: connection reset");
                 sp->flags |= SOCKET_EOF;
                 return -1;
             } else {
-                trace(4, "mbedtls: read error -0x%", -rc);
+                printf( "mbedtls: read error -0x%", -rc);
                 sp->flags |= SOCKET_EOF;
                 return -1; 
             }
@@ -414,17 +414,17 @@ PUBLIC ssize sslWrite(Webs *wp, void *buf, ssize len)
     totalWritten = 0;
     do {
         rc = mbedtls_ssl_write(&mb->ctx, (uchar*) buf, (int) len);
-        trace(7, "mbedtls write: wrote %d of %zd", rc, len);
+        printf( "mbedtls write: wrote %d of %zd", rc, len);
         if (rc <= 0) {
             if (rc == MBEDTLS_ERR_SSL_WANT_READ || rc == MBEDTLS_ERR_SSL_WANT_WRITE) {
                 socketSetError(EAGAIN);
                 return -1;
             }
             if (rc == MBEDTLS_ERR_NET_CONN_RESET) {
-                trace(4, "mbedtls_ssl_write peer closed");
+                printf( "mbedtls_ssl_write peer closed");
                 return -1;
             } else {
-                trace(4, "mbedtls_ssl_write failed rc %d", rc);
+                printf( "mbedtls_ssl_write failed rc %d", rc);
                 return -1;
             }
         } else {
@@ -552,7 +552,7 @@ static void traceMbed(void *context, int level, cchar *file, int line, cchar *st
     if (level <= websGetLogLevel()) {
         buf = sclone((char*) str);
         buf[slen(buf) - 1] = '\0';
-        trace(level, "%s", buf);
+        printf( "%s", buf);
         wfree(buf);
     }
 }

+ 4 - 4
app/goahead-3.6.5/src/goahead-openssl/goahead-openssl.c

@@ -738,14 +738,14 @@ static int verifyClientCertificate(int ok, X509_STORE_CTX *xContext)
     case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT:
     case X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN:
         if (ME_GOAHEAD_SSL_VERIFY_ISSUER) {
-            logmsg(3, "Self-signed certificate");
+            printf( "Self-signed certificate");
             ok = 0;
         }
 
     case X509_V_ERR_CERT_UNTRUSTED:
     case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY:
         if (ME_GOAHEAD_SSL_VERIFY_ISSUER) {
-            logmsg(3, "Certificate not trusted");
+            printf( "Certificate not trusted");
             ok = 0;
         }
         break;
@@ -753,7 +753,7 @@ static int verifyClientCertificate(int ok, X509_STORE_CTX *xContext)
     case X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT:
     case X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE:
         if (ME_GOAHEAD_SSL_VERIFY_ISSUER) {
-            logmsg(3, "Certificate not trusted");
+            printf( "Certificate not trusted");
             ok = 0;
         }
         break;
@@ -767,7 +767,7 @@ static int verifyClientCertificate(int ok, X509_STORE_CTX *xContext)
     case X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD:
     case X509_V_ERR_INVALID_CA:
     default:
-        logmsg(3, "Certificate verification error %d", error);
+        printf( "Certificate verification error %d", error);
         ok = 0;
         break;
     }

+ 14 - 14
app/goahead-3.6.5/src/goahead.c

@@ -250,10 +250,10 @@ websDefineAction("web_RestoreConfig", web_RestoreConfig);
         }
     }
 #endif
-    printf("---> websServiceEvents\n");
+    //printf("---> websServiceEvents\n");
     websServiceEvents(&finished);
-    logmsg(1, "Instructed to exit");
-    printf("---> websClose\n");
+    printf("Instructed to exit");
+    //printf("---> websClose\n");
     websClose();
 #if WINDOWS
     windowsClose();
@@ -267,17 +267,17 @@ 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, "---------------------------------------------");
+    printf( "Configuration for %s", ME_TITLE);
+    printf( "---------------------------------------------");
+    printf( "Version:            %s", ME_VERSION);
+    printf( "BuildType:          %s", ME_DEBUG ? "Debug" : "Release");
+    printf( "CPU:                %s", ME_CPU);
+    printf( "OS:                 %s", ME_OS);
+    printf( "Host:               %s", websGetServer());
+    printf( "Directory:          %s", home);
+    printf( "Documents:          %s", websGetDocuments());
+    printf( "Configure:          %s", ME_CONFIG_CMD);
+    printf( "---------------------------------------------");
 }
 
 

+ 37 - 37
app/goahead-3.6.5/src/goahead.h

@@ -171,43 +171,43 @@ PUBLIC_DATA int logLevel;
 #define WEBS_TRACE_MSG      0x400       /**< Originated from trace */
 
 
-#if ME_GOAHEAD_TRACING && ME_GOAHEAD_LOGGING
-    #if ME_COMPILER_HAS_MACRO_VARARGS
-      #define trace(l, ...) if (((l) & WEBS_LEVEL_MASK) <= websGetLogLevel()) { traceProc(l, __VA_ARGS__); } else {}
-    #else
-        inline void trace(int level, cchar *fmt, ...) {
-            WebsLogHandler logHandler = logGetHandler();
-            if ((level & WEBS_LEVEL_MASK) <= logLevel && logHandler) {
-                va_list args; va_start(args, fmt);
-                char *message = sfmtv((char*) fmt, args);
-                logHandler(level | WEBS_TRACE_MSG, message);
-                wfree(message);
-                va_end(args);
-            }
-        }
-    #endif
-#else
-    #define trace(l, ...) if (1) ; else {}
-#endif
-
-#if ME_GOAHEAD_LOGGING
-    #if ME_COMPILER_HAS_MACRO_VARARGS
-        #define logmsg(l, ...) if ((l) <= logLevel) { logmsgProc(l, __VA_ARGS__); } else {}
-    #else
-        inline void logmsg(int level, cchar *fmt, ...) {
-            WebsLogHandler logHandler = logGetHandler();
-            if ((level & WEBS_LEVEL_MASK) <= logLevel && logHandler) {
-                va_list args; va_start(args, fmt);
-                char *message = sfmtv((char*) fmt, args);
-                logHandler(level | WEBS_TRACE_MSG, message);
-                wfree(message);
-                va_end(args);
-            }
-        }
-    #endif
-#else
-    #define logmsg(l, ...) if (1) ; else {}
-#endif
+// #if ME_GOAHEAD_TRACING && ME_GOAHEAD_LOGGING
+//     #if ME_COMPILER_HAS_MACRO_VARARGS
+//       #define trace(l, ...) if (((l) & WEBS_LEVEL_MASK) <= websGetLogLevel()) { traceProc(l, __VA_ARGS__); } else {}
+//     #else
+//         inline void trace(int level, cchar *fmt, ...) {
+//             WebsLogHandler logHandler = logGetHandler();
+//             if ((level & WEBS_LEVEL_MASK) <= logLevel && logHandler) {
+//                 va_list args; va_start(args, fmt);
+//                 char *message = sfmtv((char*) fmt, args);
+//                 logHandler(level | WEBS_TRACE_MSG, message);
+//                 wfree(message);
+//                 va_end(args);
+//             }
+//         }
+//     #endif
+// #else
+//     #define trace(l, ...) if (1) ; else {}
+// #endif
+
+// #if ME_GOAHEAD_LOGGING
+//     #if ME_COMPILER_HAS_MACRO_VARARGS
+//         #define logmsg(l, ...) if ((l) <= logLevel) { logmsgProc(l, __VA_ARGS__); } else {}
+//     #else
+//         inline void logmsg(int level, cchar *fmt, ...) {
+//             WebsLogHandler logHandler = logGetHandler();
+//             if ((level & WEBS_LEVEL_MASK) <= logLevel && logHandler) {
+//                 va_list args; va_start(args, fmt);
+//                 char *message = sfmtv((char*) fmt, args);
+//                 logHandler(level | WEBS_TRACE_MSG, message);
+//                 wfree(message);
+//                 va_end(args);
+//             }
+//         }
+//     #endif
+// #else
+//     #define logmsg(l, ...) if (1) ; else {}
+// #endif
 
 
 #if DOXYGEN

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

@@ -579,7 +579,7 @@ PUBLIC void websDone(Webs *wp)
     logRequest(wp, wp->code);
 #endif
     if (!(wp->flags & WEBS_RESPONSE_TRACED)) {
-        trace(3 | WEBS_RAW_MSG, "Request complete: code %d", wp->code);
+        printf("Request complete: code %d", wp->code);
     }
 }
 
@@ -593,10 +593,10 @@ static int complete(Webs *wp, int reuse)
     if (reuse && wp->flags & WEBS_KEEP_ALIVE && wp->rxRemaining == 0) {
         reuseConn(wp);
         socketCreateHandler(wp->sid, SOCKET_READABLE, socketEvent, wp);
-        trace(5, "Keep connection alive");
+        printf( "Keep connection alive");
         return 1;
     }
-    trace(5, "Close connection");
+    printf("Close connection");
     wp->state = WEBS_BEGIN;
     wp->flags |= WEBS_CLOSED;
     return 0;
@@ -707,12 +707,12 @@ PUBLIC int websAccept(int sid, char *ipaddr, int port, int listenSid)
         Arrange for socketEvent to be called when read data is available
      */
     lp = socketPtr(listenSid);
-    trace(4, "New connection from %s:%d to %s:%d", ipaddr, port, wp->ifaddr, lp->port);
+    printf( "New connection from %s:%d to %s:%d", ipaddr, port, wp->ifaddr, lp->port);
 
 #if ME_COM_SSL
     if (lp->secure) {
         wp->flags |= WEBS_SECURE;
-        trace(4, "Upgrade connection to TLS");
+        printf( "Upgrade connection to TLS");
         if (sslUpgrade(wp) < 0) {
             error("Cannot upgrade to TLS");
             return -1;
@@ -896,10 +896,10 @@ static bool parseIncoming(Webs *wp)
         }
         return 0;
     }
-    trace(3 | WEBS_RAW_MSG, "\n<<< Request\n");
+    printf("\n<<< Request\n");
     c = *end;
     *end = '\0';
-    trace(3 | WEBS_RAW_MSG, "%s\n", wp->rxbuf.servp);
+    printf( "%s\n", wp->rxbuf.servp);
     *end = c;
 
     /*
@@ -981,7 +981,7 @@ static void parseFirstLine(Webs *wp)
     }
     protoVer = getToken(wp, "\r\n");
     if (websGetLogLevel() == 2) {
-        trace(2, "%s %s %s", wp->method, url, protoVer);
+        printf("%s %s %s", wp->method, url, protoVer);
     }
 
     /*
@@ -1324,7 +1324,7 @@ static bool filterChunkData(Webs *wp)
                 wp->eof = 1;
                 return 1;
             }
-            trace(7, "chunkFilter: start incoming chunk of %d bytes", chunkSize);
+            printf( "chunkFilter: start incoming chunk of %d bytes", chunkSize);
             wp->rxChunkState = WEBS_CHUNK_DATA;
             break;
 
@@ -1796,7 +1796,7 @@ PUBLIC int websWriteHeader(Webs *wp, char *key, char *fmt, ...)
 
     if (!(wp->flags & WEBS_RESPONSE_TRACED)) {
         wp->flags |= WEBS_RESPONSE_TRACED;
-        trace(3 | WEBS_RAW_MSG, "\n>>> Response\n");
+        printf( "\n>>> Response\n");
     }
     if (key) {
         if (websWriteBlock(wp, key, strlen(key)) < 0) {
@@ -1805,7 +1805,7 @@ PUBLIC int websWriteHeader(Webs *wp, char *key, char *fmt, ...)
         if (websWriteBlock(wp, ": ", 2) < 0) {
             return -1;
         }
-        trace(3 | WEBS_RAW_MSG, "%s: ", key);
+        printf("%s: ", key);
     }
     if (fmt) {
         va_start(vargs, fmt);
@@ -1815,7 +1815,7 @@ PUBLIC int websWriteHeader(Webs *wp, char *key, char *fmt, ...)
         }
         va_end(vargs);
         assert(strstr(buf, "UNION") == 0);
-        trace(3 | WEBS_RAW_MSG, "%s", buf);
+        printf("%s", buf);
         if (websWriteBlock(wp, buf, strlen(buf)) < 0) {
             return -1;
         }
@@ -1824,7 +1824,7 @@ PUBLIC int websWriteHeader(Webs *wp, char *key, char *fmt, ...)
             return -1;
         }
     }
-    trace(3 | WEBS_RAW_MSG, "\r\n");
+    printf("\r\n");
     return 0;
 }
 
@@ -2079,15 +2079,15 @@ PUBLIC int websFlush(Webs *wp, bool block)
     }
     op = &wp->output;
     if (wp->flags & WEBS_CHUNKING) {
-        trace(6, "websFlush chunking finalized %d", wp->finalized);
+        printf("websFlush chunking finalized %d", wp->finalized);
         if (flushChunkData(wp) && wp->finalized) {
-            trace(6, "websFlush: write chunk trailer");
+            printf("websFlush: write chunk trailer");
             bufPutStr(op, "\r\n0\r\n\r\n");
             bufAddNull(op);
             wp->flags &= ~WEBS_CHUNKING;
         }
     }
-    trace(6, "websFlush: buflen %d", bufLen(op));
+    printf( "websFlush: buflen %d", bufLen(op));
     written = 0;
     while ((nbytes = bufLen(op)) > 0) {
         if ((written = websWriteSocket(wp, op->servp, nbytes)) < 0) {
@@ -2107,7 +2107,7 @@ PUBLIC int websFlush(Webs *wp, bool block)
         } else if (written == 0) {
             break;
         }
-        trace(6, "websFlush: wrote %d to socket", written);
+        printf( "websFlush: wrote %d to socket", written);
         bufAdjustStart(op, written);
         bufCompact(op);
         nbytes = bufLen(op);
@@ -3218,7 +3218,7 @@ static void pruneSessions()
             }
         }
         if (oldCount != sessionCount || sessionCount) {
-            trace(4, "Prune %d sessions. Remaining: %d", oldCount - sessionCount, sessionCount);
+            printf("Prune %d sessions. Remaining: %d", oldCount - sessionCount, sessionCount);
         }
     }
     websRestartEvent(pruneId, WEBS_SESSION_PRUNE);
@@ -3299,7 +3299,7 @@ static void setFileLimits()
         }
     }
     getrlimit(RLIMIT_NOFILE, &r);
-    trace(6, "Max files soft %d, max %d", r.rlim_cur, r.rlim_max);
+    printf("Max files soft %d, max %d", (int)r.rlim_cur, (int)r.rlim_max);
 #endif
 }
 
@@ -3338,7 +3338,7 @@ PUBLIC void websError(Webs *wp, int code, char *fmt, ...)
             va_start(args, fmt);
             msg = sfmtv(fmt, args);
             va_end(args);
-            trace(2, "%s", msg);
+            printf( "%s", msg);
             wfree(msg);
         }
         buf = sfmt("\

+ 6 - 6
app/goahead-3.6.5/src/route.c

@@ -79,7 +79,7 @@ PUBLIC void websRouteRequest(Webs *wp)
 
         if (plen < route->prefixLen) continue;
         len = min(route->prefixLen, plen);
-        trace(5, "Examine route %s", route->prefix);
+        printf( "Examine route %s", route->prefix);
         /*
             Match route
          */
@@ -87,19 +87,19 @@ PUBLIC void websRouteRequest(Webs *wp)
             continue;
         }
         if (route->protocol && !smatch(route->protocol, wp->protocol)) {
-            trace(5, "Route %s does not match protocol %s", route->prefix, wp->protocol);
+            printf( "Route %s does not match protocol %s", route->prefix, wp->protocol);
             continue;
         }
         if (route->methods >= 0) {
             if (!hashLookup(route->methods, wp->method)) {
-                trace(5, "Route %s does not match method %s", route->prefix, wp->method);
+                printf( "Route %s does not match method %s", route->prefix, wp->method);
                 continue;
             }
         } else if (!safeMethod) {
             continue;
         }
         if (route->extensions >= 0 && (wp->ext == 0 || !hashLookup(route->extensions, &wp->ext[1]))) {
-            trace(5, "Route %s doesn match extension %s", route->prefix, wp->ext ? wp->ext : "");
+            printf( "Route %s doesn match extension %s", route->prefix, wp->ext ? wp->ext : "");
             continue;
         }
 
@@ -168,7 +168,7 @@ PUBLIC bool websRunRequest(Webs *wp)
         wp->flags |= WEBS_VARS_ADDED;
     }
     wp->state = WEBS_RUNNING;
-    trace(5, "Route %s calls handler %s", route->prefix, route->handler->name);
+    printf( "Route %s calls handler %s", route->prefix, route->handler->name);
 
 #if ME_GOAHEAD_LEGACY
     if (route->handler->flags & WEBS_LEGACY_HANDLER) {
@@ -261,7 +261,7 @@ PUBLIC bool websCanString(Webs *wp, char *abilities)
             return 0;
         }
         if ((user = websLookupUser(wp->username)) == 0) {
-            trace(2, "Cannot find user %s", wp->username);
+            printf( "Cannot find user %s", wp->username);
             return 0;
         }
     }

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

@@ -972,7 +972,7 @@ PUBLIC void socketFree(int sid)
  */
 WebsSocket *socketPtr(int sid)
 {
-    printf("---> socketPtr(): sid = %d, socketMax = %d\n", sid, socketMax);
+    //printf("---> socketPtr(): sid = %d, socketMax = %d\n", sid, socketMax);
     if (sid < 0 || sid >= socketMax || socketList[sid] == NULL) {
         assert(NULL);
         errno = EBADF;

+ 7 - 7
app/goahead-3.6.5/src/upload.c

@@ -188,7 +188,7 @@ static void processUploadHeader(Webs *wp, char *line)
         wp->uploadState = UPLOAD_CONTENT_DATA;
         return;
     }
-    trace(7, "Header line: %s", line);
+    printf( "Header line: %s", line);
 
     headerTok = line;
     stok(line, ": ", &rest);
@@ -250,7 +250,7 @@ static void processUploadHeader(Webs *wp, char *line)
                     return;
                 }
 
-                trace(5, "File upload of: %s stored as %s", wp->clientFilename, wp->uploadTmp);
+                printf( "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);
@@ -270,7 +270,7 @@ static void processUploadHeader(Webs *wp, char *line)
 
     } else if (scaselesscmp(headerTok, "Content-Type") == 0) {
         if (wp->clientFilename) {
-            trace(5, "Set files[%s][CONTENT_TYPE] = %s", wp->uploadVar, rest);
+            printf( "Set files[%s][CONTENT_TYPE] = %s", wp->uploadVar, rest);
             wp->currentFile->contentType = sclone(rest);
         }
     }
@@ -318,7 +318,7 @@ static int writeToFile(Webs *wp, char *data, ssize len)
             return -1;
         }
         file->size += len;
-        trace(7, "uploadFilter: Wrote %d bytes to %s", len, wp->uploadTmp);
+        printf( "uploadFilter: Wrote %d bytes to %s", len, wp->uploadTmp);
     }
     return 0;
 }
@@ -345,7 +345,7 @@ static bool processContentData(Webs *wp)
         return 0;
     }
     if ((bp = getBoundary(wp, content->servp, size)) == 0) {
-        trace(7, "uploadFilter: Got boundary filename %x", wp->clientFilename);
+        printf( "uploadFilter: Got boundary filename %x", wp->clientFilename);
         if (wp->clientFilename) {
             /*
                 No signature found yet. probably more data to come. Must handle split boundaries.
@@ -389,7 +389,7 @@ static bool processContentData(Webs *wp)
                 Normal string form data variables
              */
             data[nbytes] = '\0';
-            trace(5, "uploadFilter: form[%s] = %s", wp->uploadVar, data);
+            printf( "uploadFilter: form[%s] = %s", wp->uploadVar, data);
             websDecodeUrl(wp->uploadVar, wp->uploadVar, -1);
             websDecodeUrl(data, data, -1);
             websSetVar(wp, wp->uploadVar, data);
@@ -472,7 +472,7 @@ PUBLIC void websUploadOpen()
         uploadDir = "/tmp";
 #endif
     }
-    trace(4, "Upload directory is %s", uploadDir);
+    printf( "Upload directory is %s", uploadDir);
     websDefineHandler("upload", 0, uploadHandler, 0, 0);
 }
 

+ 4 - 4
app/goahead-3.6.5/src/utils/mine/ResultUtils.c

@@ -39,7 +39,7 @@ static void commResult(Webs *wp, int msgCode, int httpStatus, int isSuccess) {
     
 
     // memcpy(cjson_str, pStr, strlen(pStr));
-    logmsg(2, "-----------------------jso1n----------------------%s", pStr);
+    printf( "-----------------------jso1n----------------------%s", pStr);
     websResponse(wp, httpStatus, pStr);
     cJSON_Delete(root);//free memery
     wfree(pStr);
@@ -52,7 +52,7 @@ static void commResult(Webs *wp, int msgCode, int httpStatus, int isSuccess) {
 //add by lusa 
 void getErrorJson(char *cjson_str, int cjson_code)
 {
-    logmsg(2, "-----------------------json----------------------");
+    printf( "-----------------------json----------------------");
     char *pStr;
     cJSON * root =  cJSON_CreateObject();
     cJSON * data =  cJSON_CreateObject();
@@ -64,11 +64,11 @@ void getErrorJson(char *cjson_str, int cjson_code)
     
 
     pStr = cJSON_Print(root);
-     logmsg(2, "-----------------------jso1n----------------------%s", pStr);
+     printf( "-----------------------jso1n----------------------%s", pStr);
     //cjson_str = sfmt("%s", pStr);
     // printf("---> pStr: %s\n", pStr);
     
     memcpy(cjson_str, pStr, strlen(pStr));
-    logmsg(2, "-----------------------json-2------ %d ---------------%s", strlen(pStr), cjson_str);
+    printf( "-----------------------json-2------ %d ---------------%s", strlen(pStr), cjson_str);
 
 }

+ 2 - 2
app/goahead-3.6.5/src/web_interface/src/dashboard.c

@@ -416,8 +416,8 @@ void buy(Webs *wp)
     char    *name, *age;
     name = websGetVar(wp, "name", NULL);
     age = websGetVar(wp, "age", NULL);
-    logmsg(2, "name value is : %s", name );
-     logmsg(2, "age value is : %s", age );
+    printf( "name value is : %s", name );
+     printf( "age value is : %s", age );
     websSetStatus(wp, 200);
     websWriteHeaders(wp, -1, 0);
     websWriteEndHeaders(wp);