summaryrefslogtreecommitdiff
path: root/source4/lib/appweb/esp/espProcs.c
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2008-09-16 18:05:53 +0200
committerJelmer Vernooij <jelmer@samba.org>2008-09-16 18:05:53 +0200
commit197870a731f18dd9759e9cc97dfd298fda773251 (patch)
tree7d6ff05bc404d07d02bab47e59429986d47c842c /source4/lib/appweb/esp/espProcs.c
parentc2eb4e5f8e0275003f9cffe1feeee6e34b7e578e (diff)
downloadsamba-197870a731f18dd9759e9cc97dfd298fda773251.tar.gz
samba-197870a731f18dd9759e9cc97dfd298fda773251.tar.bz2
samba-197870a731f18dd9759e9cc97dfd298fda773251.zip
Remove remaining embedded JavaScript support.
Diffstat (limited to 'source4/lib/appweb/esp/espProcs.c')
-rw-r--r--source4/lib/appweb/esp/espProcs.c249
1 files changed, 0 insertions, 249 deletions
diff --git a/source4/lib/appweb/esp/espProcs.c b/source4/lib/appweb/esp/espProcs.c
deleted file mode 100644
index 7b5dfe680e..0000000000
--- a/source4/lib/appweb/esp/espProcs.c
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * @file espProcs.c
- * @brief Embedded Server Pages (ESP) Procedures.
- * @overview These ESP procedures can be used in ESP pages for common tasks.
- */
-/********************************* Copyright **********************************/
-/*
- * @copy default
- *
- * Copyright (c) Mbedthis Software LLC, 2003-2005. All Rights Reserved.
- *
- * This software is distributed under commercial and open source licenses.
- * You may use the GPL open source license described below or you may acquire
- * a commercial license from Mbedthis Software. You agree to be fully bound
- * by the terms of either license. Consult the LICENSE.TXT distributed with
- * this software for full details.
- *
- * This software is open source; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version. See the GNU General Public License for more
- * details at: http://www.mbedthis.com/downloads/gplLicense.html
- *
- * This program is distributed WITHOUT ANY WARRANTY; without even the
- * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * This GPL license does NOT permit incorporating this software into
- * proprietary programs. If you are unable to comply with the GPL, you must
- * acquire a commercial license to use this software. Commercial licenses
- * for this software and support services are available from Mbedthis
- * Software at http://www.mbedthis.com
- *
- * @end
- */
-/********************************** Includes **********************************/
-
-#include "esp.h"
-
-/************************************ Code ************************************/
-#if BLD_FEATURE_ESP_MODULE
-#if BLD_FEATURE_SESSION
-/*
- * destroySession
- */
-
-static int destroySessionProc(EspRequest *ep, int argc, char **argv)
-{
- ep->esp->destroySession(ep->requestHandle);
- return 0;
-}
-
-#endif /* BLD_FEATURE_SESSION */
-
-/******************************************************************************/
-/*
- * include
- *
- * This includes javascript libraries. For example:
- *
- * <% include("file", ...); %>
- *
- * Don't confuse with ESP includes:
- *
- * <% include file.esp %>
- *
- * Filenames are relative to the base document including the file.
- * FUTURE -- move back to EJS. Only here now because we need ep->readFile.
- */
-
-static int includeProc(EspRequest *ep, int argc, char **argv)
-{
- const Esp *esp;
- char path[MPR_MAX_FNAME], dir[MPR_MAX_FNAME];
- char *emsg=NULL, *buf;
- int size, i;
-
- esp = ep->esp;
- mprAssert(argv);
- for (i = 0; i < argc; i++) {
- const char *extension;
-
- if (argv[i][0] != '/') {
- mprGetDirName(dir, sizeof(dir), ep->docPath);
- mprSprintf(path, sizeof(path), "%s/%s", dir, argv[i]);
- } else {
- mprSprintf(path, sizeof(path), "%s", argv[i]);
- }
-
- if (esp->readFile(ep->requestHandle, &buf, &size, path) < 0) {
- espError(ep, "Can't read include file: %s", path);
- return MPR_ERR_CANT_ACCESS;
- }
- buf[size] = '\0';
-
- extension = strrchr(argv[i], '.');
-
- /*
- * 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);
- return -1;
- }
- } else {
- if (ejsEvalScript(espGetScriptHandle(ep), buf, 0, &emsg) < 0) {
- espError(ep, "Cant evaluate script - %s", emsg?emsg:"");
- mprFree(buf);
- return -1;
- }
- }
- mprFree(buf);
- }
- return 0;
-}
-
-/******************************************************************************/
-/*
- * redirect
- *
- * This implemements <% redirect(url, code); %> command. The redirection
- * code is optional.
- */
-
-static int redirectProc(EspRequest *ep, int argc, char **argv)
-{
- char *url;
- int code;
-
- if (argc < 1) {
- espError(ep, "Bad args");
- return MPR_ERR_BAD_ARGS;
- }
- url = argv[0];
- if (argc == 2) {
- code = atoi(argv[1]);
- } else {
- code = 302;
- }
- espRedirect(ep, code, url);
- return 0;
-}
-
-/******************************************************************************/
-#if BLD_FEATURE_SESSION
-/*
- * useSession
- */
-
-static int useSessionProc(EspRequest *ep, int argc, char **argv)
-{
- int timeout;
-
- if (argc > 1) {
- espError(ep, "Bad args");
- return MPR_ERR_BAD_ARGS;
-
- } else if (argc == 1) {
- timeout = atoi(argv[0]);
- } else {
- timeout = 0;
- }
-
- ep->esp->createSession(ep->requestHandle, timeout);
- espSetReturnString(ep, ep->esp->getSessionId(ep->requestHandle));
- return 0;
-}
-
-#endif /* BLD_FEATURE_SESSION */
-/******************************************************************************/
-/*
- * setHeader
- *
- * This implemements <% setHeader("key: value", allowMultiple); %> command.
- */
-
-static int setHeaderProc(EspRequest *ep, int argc, char **argv)
-{
- mprAssert(argv);
- if (argc != 2) {
- espError(ep, "Bad args");
- return MPR_ERR_BAD_ARGS;
- }
- ep->esp->setHeader(ep->requestHandle, argv[0], atoi(argv[1]));
- return 0;
-}
-
-/******************************************************************************/
-/*
- * write
- *
- * This implemements <% write("text"); %> command.
- */
-
-static int writeProc(EspRequest *ep, int argc, char **argv)
-{
- char *s;
- int i, len;
-
- mprAssert(argv);
- for (i = 0; i < argc; i++) {
- s = argv[i];
- len = strlen(s);
- if (len > 0) {
- if (espWrite(ep, s, len) != len) {
- espError(ep, "Can't write to client");
- return -1;
- }
- }
- }
- return 0;
-}
-
-/******************************************************************************/
-
-void espRegisterProcs()
-{
- espDefineStringCFunction(0, "write", writeProc, 0);
- espDefineStringCFunction(0, "setHeader", setHeaderProc, 0);
- espDefineStringCFunction(0, "redirect", redirectProc, 0);
- espDefineStringCFunction(0, "include", includeProc, 0);
-
-#if BLD_FEATURE_SESSION
- /*
- * Create and use are synonomous
- */
- espDefineStringCFunction(0, "useSession", useSessionProc, 0);
- espDefineStringCFunction(0, "createSession", useSessionProc, 0);
- espDefineStringCFunction(0, "destroySession", destroySessionProc, 0);
-#endif
-}
-
-/******************************************************************************/
-
-#else
-void mprEspControlsDummy() {}
-
-#endif /* BLD_FEATURE_ESP_MODULE */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim:tw=78
- * vim600: sw=4 ts=4 fdm=marker
- * vim<600: sw=4 ts=4
- */