r8404: small upstream merges of appweb code
authorAndrew Tridgell <tridge@samba.org>
Wed, 13 Jul 2005 00:43:16 +0000 (00:43 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:22:58 +0000 (13:22 -0500)
(This used to be commit 205ff9a82bd51eae3c1400ea0a24fcf2a662e96f)

source4/lib/appweb/esp/esp.c
source4/lib/appweb/esp/espProcs.c
source4/lib/appweb/mpr/miniMpr.h
source4/lib/appweb/mpr/var.h

index ef20557f936b8c843909162b5892fadc555e9ce6..0be7af6c1b33615c309061ce3f9d4e2894640491 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     @file   esp.c
  *     @brief  Embedded Server Pages (ESP) core processing.
 /*
  *     @file   esp.c
  *     @brief  Embedded Server Pages (ESP) core processing.
- *     @overview The ESP handler provides an efficient way to generate 
+ *     @overview Embedded Server Pages provides an efficient way to generate 
  *             dynamic pages using server-side Javascript. This code provides 
  *             core processing, and should be called by an associated web 
  *             server URL handler.
  *             dynamic pages using server-side Javascript. This code provides 
  *             core processing, and should be called by an associated web 
  *             server URL handler.
@@ -166,7 +166,7 @@ EspRequest *espCreateRequest(EspHandle webServerRequestHandle, char *uri,
         *      Define variables as globals. headers[] are prefixed with "HTTP_".
         *      NOTE: MaRequest::setVar does not copy into globals, whereas espSetVar
         *      does if legacy_api is defined. So variables pre-defined by MaRequest 
         *      Define variables as globals. headers[] are prefixed with "HTTP_".
         *      NOTE: MaRequest::setVar does not copy into globals, whereas espSetVar
         *      does if legacy_api is defined. So variables pre-defined by MaRequest 
-        *      must be copied here into globals[].\r
+        *      must be copied here into globals[].
         *
         *      NOTE: if a variable is in session[] and in form[], the form[] will
         *      override being later in the variables[] list. Use mprSetProperty 
         *
         *      NOTE: if a variable is in session[] and in form[], the form[] will
         *      override being later in the variables[] list. Use mprSetProperty 
@@ -301,7 +301,7 @@ int espGetVar(EspRequest *ep, EspEnvType oType, char *var, MprVar *value)
  */
 
 int espProcessRequest(EspRequest *ep, const char *docPath, char *docBuf, 
  */
 
 int espProcessRequest(EspRequest *ep, const char *docPath, char *docBuf, 
-                                         char **errMsg)
+       char **errMsg)
 {
        char    *jsBuf;
 
 {
        char    *jsBuf;
 
@@ -549,7 +549,7 @@ static int getEspToken(int state, EspParse *parse)
                        if (parse->token == 0) {
                                return ESP_TOK_ERR;
                        }
                        if (parse->token == 0) {
                                return ESP_TOK_ERR;
                        }
-                       parse->token[parse->tokLen] = '\0';\r
+                       parse->token[parse->tokLen] = '\0';
                        parse->tokp = &parse->token[parse->tokLen - 1];
                        parse->tokLen += ESP_TOK_INCR;
                        parse->endp = &parse->token[parse->tokLen - 1];
                        parse->tokp = &parse->token[parse->tokLen - 1];
                        parse->tokLen += ESP_TOK_INCR;
                        parse->endp = &parse->token[parse->tokLen - 1];
@@ -774,7 +774,7 @@ static int buildScript(EspRequest *ep, char **jsBuf, char *input, char **errMsg)
                                mprStrcpy(incPath, sizeof(incPath), parse.token);
                        } else {
                                mprGetDirName(dir, sizeof(dir), ep->uri);
                                mprStrcpy(incPath, sizeof(incPath), parse.token);
                        } else {
                                mprGetDirName(dir, sizeof(dir), ep->uri);
-                               mprSprintf(incPath, sizeof(incPath), "%s/%s",
+                               mprSprintf(incPath, sizeof(incPath), "%s/%s", 
                                        dir, parse.token);
                        }
                        if (esp->mapToStorage(ep->requestHandle, path, sizeof(path),
                                        dir, parse.token);
                        }
                        if (esp->mapToStorage(ep->requestHandle, path, sizeof(path),
@@ -812,7 +812,7 @@ static int buildScript(EspRequest *ep, char **jsBuf, char *input, char **errMsg)
        }
        mprFree(parse.token);
        if (len < 0) {
        }
        mprFree(parse.token);
        if (len < 0) {
-               mprAllocSprintf(errMsg, MPR_MAX_STRING,
+               mprAllocSprintf(errMsg, MPR_MAX_STRING, 
                        "Script token is too big in %s.\nConfigured maximum is %d.", 
                        path, maxScriptSize);
                return MPR_ERR_WONT_FIT;
                        "Script token is too big in %s.\nConfigured maximum is %d.", 
                        path, maxScriptSize);
                return MPR_ERR_WONT_FIT;
index 28b69a8a6f1484634279ffc3f8a78f4a02252084..7b5dfe680e8960b692ac28d37e6d8d90892e639c 100644 (file)
@@ -93,8 +93,11 @@ static int includeProc(EspRequest *ep, int argc, char **argv)
                buf[size] = '\0';
 
                extension = strrchr(argv[i], '.');
                buf[size] = '\0';
 
                extension = strrchr(argv[i], '.');
-               /* this makes handling include files in esp scripts much more convenient */
-               if (extension && strcasecmp(extension, ".esp") == 0) {
+
+               /*
+                *      Allow nested inclusion of ESP requests
+                */
+               if (extension && mprStrCmpAnyCase(extension, ".esp") == 0) {
                        if (espProcessRequest(ep, path, buf, &emsg) != 0) {
                                espError(ep, "Cant evaluate script - %s", emsg?emsg:"");
                                mprFree(buf);
                        if (espProcessRequest(ep, path, buf, &emsg) != 0) {
                                espError(ep, "Cant evaluate script - %s", emsg?emsg:"");
                                mprFree(buf);
index a0030b25b5dded144cf3b773dc4214474269b89d..8b28472826cd78bbdb32887060aa0e428170203e 100644 (file)
@@ -273,6 +273,8 @@ extern int          mprMemcpy(char *dest, int destMax, const char *src, int nbytes);
 extern void mprSetCtx(void *ctx);
 extern void *mprMemCtx(void);
 
 extern void mprSetCtx(void *ctx);
 extern void *mprMemCtx(void);
 
+#define mprStrCmpAnyCase(s1, s2) StrCaseCmp(s1, s2)
+
 #ifdef __cplusplus
 }
 #endif
 #ifdef __cplusplus
 }
 #endif
index 8ed13a4995d21982d44935c026bf49afdc9a8099..ef9217b9cf41fea8cc1ff4ac5ffc6f766277e967 100644 (file)
@@ -156,10 +156,6 @@ typedef BLD_FEATURE_NUM_TYPE MprNum;
 #define MPR_MAX_VAR                            512
 #endif
 
 #define MPR_MAX_VAR                            512
 #endif
 
-#ifndef __NO_PACK
-#pragma pack(2)
-#endif /* _NO_PACK */
-
 /*
  *     Function signatures
  */
 /*
  *     Function signatures
  */
@@ -348,11 +344,6 @@ typedef struct MprVar {
 
 typedef BLD_FEATURE_NUM_TYPE MprNumber;
 
 
 typedef BLD_FEATURE_NUM_TYPE MprNumber;
 
-
-#ifndef __NO_PACK
-#pragma pack()
-#endif /* __NO_PACK */
-
 /********************************* Prototypes *********************************/
 /*
  *     Variable constructors and destructors
 /********************************* Prototypes *********************************/
 /*
  *     Variable constructors and destructors