Palm: deprecate plugin. Its not you, its me.
authorEduardo Silva <edsiper@gmail.com>
Sat, 16 Feb 2013 19:45:20 +0000 (13:45 -0600)
committerEduardo Silva <edsiper@gmail.com>
Sat, 16 Feb 2013 19:45:20 +0000 (13:45 -0600)
Signed-off-by: Eduardo Silva <edsiper@gmail.com>

13 files changed:
plugins/palm/ABOUT [deleted file]
plugins/palm/Makefile.in [deleted file]
plugins/palm/OPTIONAL [deleted file]
plugins/palm/README [deleted file]
plugins/palm/cgi.c [deleted file]
plugins/palm/cgi.h [deleted file]
plugins/palm/conf/palm.conf [deleted file]
plugins/palm/palm.c [deleted file]
plugins/palm/palm.h [deleted file]
plugins/palm/protocol.c [deleted file]
plugins/palm/protocol.h [deleted file]
plugins/palm/request.c [deleted file]
plugins/palm/request.h [deleted file]

diff --git a/plugins/palm/ABOUT b/plugins/palm/ABOUT
deleted file mode 100644 (file)
index cba4829..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-Palm Client Plugin
-==================
-Palm is a Monkey protocol designed to provide a simple and 
-flexible server applications. This plugin provides the client
-side.
diff --git a/plugins/palm/Makefile.in b/plugins/palm/Makefile.in
deleted file mode 100644 (file)
index da8a1db..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-all: monkey-palm.so
-include ../Make.common
-
-CC     = @echo "  CC   $(_PATH)/$@"; $CC
-CC_QUIET= @echo -n; $CC
-CFLAGS = $CFLAGS
-LDFLAGS = $LDFLAGS
-DEFS    = $DEFS
-SOURCES = palm.c protocol.c cgi.c request.c
-OBJECTS = palm.o protocol.o cgi.o request.o
-
--include $(OBJECTS:.o=.d)
-
-monkey-palm.so: $(OBJECTS)
-       $(CC) $(CFLAGS) $(LDFLAGS) $(DEFS) -shared -o $@ $^ -lc
diff --git a/plugins/palm/OPTIONAL b/plugins/palm/OPTIONAL
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/plugins/palm/README b/plugins/palm/README
deleted file mode 100644 (file)
index b580ce0..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-Palm Plugin
-===========
-
-This plugin is a Palm protocol client.
-
diff --git a/plugins/palm/cgi.c b/plugins/palm/cgi.c
deleted file mode 100644 (file)
index 10dc634..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/*  Monkey HTTP Daemon
- *  ------------------
- *  Copyright (C) 2001-2012, Eduardo Silva P. <edsiper@gmail.com>
- *
- *  This program is free software; 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.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU Library General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "palm.h"
-#include "cgi.h"
-#include "mk_plugin.h"
-
-void mk_cgi_env()
-{
-    
-    /* Document Root */
-    mk_api->pointer_set(&mk_cgi_document_root, MK_CGI_DOCUMENT_ROOT);
-
-    /* CONTENT_ */
-    mk_api->pointer_set(&mk_cgi_content_length, MK_CGI_CONTENT_LENGTH);
-    mk_api->pointer_set(&mk_cgi_content_type, MK_CGI_CONTENT_TYPE);
-
-    /* SERVER_ */
-    mk_api->pointer_set(&mk_cgi_server_addr, MK_CGI_SERVER_ADDR);
-    mk_api->pointer_set(&mk_cgi_server_port, MK_CGI_SERVER_PORT);
-    mk_api->pointer_set(&mk_cgi_server_name, MK_CGI_SERVER_NAME);
-    mk_api->pointer_set(&mk_cgi_server_protocol, MK_CGI_SERVER_PROTOCOL);
-    mk_api->pointer_set(&mk_cgi_server_software, MK_CGI_SERVER_SOFTWARE);
-    mk_api->pointer_set(&mk_cgi_server_signature, MK_CGI_SERVER_SIGNATURE);
-
-    /* HTTP_ */
-    mk_api->pointer_set(&mk_cgi_http_user_agent, MK_CGI_HTTP_USER_AGENT);
-    mk_api->pointer_set(&mk_cgi_http_accept, MK_CGI_HTTP_ACCEPT);
-
-    mk_api->pointer_set(&mk_cgi_http_accept_charset,
-                        MK_CGI_HTTP_ACCEPT_CHARSET);
-    mk_api->pointer_set(&mk_cgi_http_accept_encoding,
-                        MK_CGI_HTTP_ACCEPT_ENCODING);
-    mk_api->pointer_set(&mk_cgi_http_accept_language,
-                        MK_CGI_HTTP_ACCEPT_LANGUAGE);
-    mk_api->pointer_set(&mk_cgi_http_host, MK_CGI_HTTP_HOST);
-    mk_api->pointer_set(&mk_cgi_http_cookie, MK_CGI_HTTP_COOKIE);
-    mk_api->pointer_set(&mk_cgi_http_referer, MK_CGI_HTTP_REFERER);
-
-    mk_api->pointer_set(&mk_cgi_cgi_version, MK_CGI_CGI_VERSION);
-    mk_api->pointer_set(&mk_cgi_gateway_interface, MK_CGI_GATEWAY_INTERFACE);
-    mk_api->pointer_set(&mk_cgi_remote_addr, MK_CGI_REMOTE_ADDR);
-
-    /* REQUEST_ */
-    mk_api->pointer_set(&mk_cgi_request_uri, MK_CGI_REQUEST_URI);
-    mk_api->pointer_set(&mk_cgi_request_method, MK_CGI_REQUEST_METHOD);
-    mk_api->pointer_set(&mk_cgi_script_name, MK_CGI_SCRIPT_NAME);
-    mk_api->pointer_set(&mk_cgi_script_filename, MK_CGI_SCRIPT_FILENAME);
-    mk_api->pointer_set(&mk_cgi_remote_port, MK_CGI_REMOTE_PORT);
-    mk_api->pointer_set(&mk_cgi_query_string, MK_CGI_QUERY_STRING);
-    mk_api->pointer_set(&mk_cgi_post_vars, MK_CGI_POST_VARS);
-    mk_api->pointer_set(&mk_cgi_version, MK_CGI_VERSION);
-}
diff --git a/plugins/palm/cgi.h b/plugins/palm/cgi.h
deleted file mode 100644 (file)
index 64f82e5..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/*  Monkey HTTP Daemon
- *  ------------------
- *  Copyright (C) 2001-2009, Eduardo Silva P.
- *
- *  This program is free software; 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.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU Library General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-/* cgi.c */
-#include "memory.h"
-
-#define MK_CGI_DOCUMENT_ROOT "DOCUMENT_ROOT"
-#define MK_CGI_CONTENT_LENGTH "CONTENT_LENGTH"
-#define MK_CGI_CONTENT_TYPE "CONTENT_TYPE"
-#define MK_CGI_SERVER_ADDR "SERVER_ADDR"
-#define MK_CGI_SERVER_PORT "SERVER_PORT"
-#define MK_CGI_SERVER_NAME "SERVER_NAME"
-#define MK_CGI_SERVER_PROTOCOL "SERVER_PROTOCOL"
-#define MK_CGI_SERVER_SOFTWARE "SERVER_SOFTWARE"
-#define MK_CGI_SERVER_SIGNATURE "SERVER_SIGNATURE"
-
-
-#define MK_CGI_HTTP_USER_AGENT "HTTP_USER_AGENT"
-#define MK_CGI_HTTP_ACCEPT "HTTP_ACCEPT"
-#define MK_CGI_HTTP_ACCEPT_CHARSET "HTTP_ACCEPT_CHARSET"
-#define MK_CGI_HTTP_ACCEPT_ENCODING "HTTP_ACCEPT_ENCODING"
-#define MK_CGI_HTTP_ACCEPT_LANGUAGE "HTTP_ACCEPT_LANGUAGE"
-#define MK_CGI_HTTP_HOST "HTTP_HOST"
-#define MK_CGI_HTTP_COOKIE "HTTP_COOKIE"
-#define MK_CGI_HTTP_REFERER "HTTP_REFERER"
-
-#define MK_CGI_CGI_VERSION "CGI_VERSION"
-#define MK_CGI_GATEWAY_INTERFACE "GATEWAY_INTERFACE"
-#define MK_CGI_REMOTE_ADDR "REMOTE_ADDR"
-#define MK_CGI_REMOTE_PORT "REMOTE_PORT"
-#define MK_CGI_REQUEST_URI "REQUEST_URI"
-#define MK_CGI_REQUEST_METHOD "REQUEST_METHOD"
-#define MK_CGI_SCRIPT_NAME "SCRIPT_NAME"
-#define MK_CGI_SCRIPT_FILENAME "SCRIPT_FILENAME"
-#define MK_CGI_QUERY_STRING "QUERY_STRING"
-#define MK_CGI_POST_VARS "POST_VARS"
-
-mk_pointer mk_cgi_document_root;
-
-/* CONTENT_ */
-mk_pointer mk_cgi_content_length;
-mk_pointer mk_cgi_content_type;
-
-/* SERVER_ */
-mk_pointer mk_cgi_server_addr;
-mk_pointer mk_cgi_server_port;
-mk_pointer mk_cgi_server_name;
-mk_pointer mk_cgi_server_protocol;
-mk_pointer mk_cgi_server_software;
-mk_pointer mk_cgi_server_signature;
-
-/* HTTP_ */
-mk_pointer mk_cgi_http_user_agent;
-mk_pointer mk_cgi_http_accept;
-mk_pointer mk_cgi_http_accept_charset;
-mk_pointer mk_cgi_http_accept_encoding;
-mk_pointer mk_cgi_http_accept_language;
-mk_pointer mk_cgi_http_host;
-mk_pointer mk_cgi_http_cookie;
-mk_pointer mk_cgi_http_referer;
-
-mk_pointer mk_cgi_cgi_version;
-mk_pointer mk_cgi_gateway_interface;
-mk_pointer mk_cgi_remote_addr;
-mk_pointer mk_cgi_request_uri;
-mk_pointer mk_cgi_request_method;
-mk_pointer mk_cgi_script_name;
-mk_pointer mk_cgi_script_filename;
-mk_pointer mk_cgi_remote_port;
-mk_pointer mk_cgi_query_string;
-mk_pointer mk_cgi_post_vars;
-
-#define MK_CGI_VERSION "CGI/1.1"
-mk_pointer mk_cgi_version;
-
-struct mk_cgi_environment
-{
-    mk_pointer p;
-    struct mk_cgi_environment *next;
-};
-
-void mk_cgi_env();
diff --git a/plugins/palm/conf/palm.conf b/plugins/palm/conf/palm.conf
deleted file mode 100644 (file)
index 7413376..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-# Palm configuration
-# ==================
-# In order to use Palm client plugin, you must define each palm
-# available. You can add N palms as you want.
-
-[PALM]
-    Extension  php 
-    Mimetype   application/x-httpd-php 
-    ServerAddr 127.0.0.1
-    ServerPort 2010
-
-[PALM]
-    Extension  pl
-    Mimetype   application/x-perl
-    ServerAddr 127.0.0.1
-    ServerPort 2011
diff --git a/plugins/palm/palm.c b/plugins/palm/palm.c
deleted file mode 100644 (file)
index aa46495..0000000
+++ /dev/null
@@ -1,642 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/*  Monkey HTTP Daemon
- *  ------------------
- *  Copyright (C) 2001-2012, Eduardo Silva P. <edsiper@gmail.com>
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public
- *  License as published by the Free Software Foundation; either
- *  version 2.1 of the License, or (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this library; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- *  MA 02110-1301  USA
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <unistd.h>
-
-#include "MKPlugin.h"
-
-#include "cgi.h"
-#include "palm.h"
-#include "request.h"
-#include "protocol.h"
-
-MONKEY_PLUGIN("palm",              /* shortname */
-              "Palm Client",       /* name */
-              VERSION,            /* version */
-              MK_PLUGIN_CORE_THCTX | MK_PLUGIN_STAGE_30); /* hooks */
-
-const mk_pointer mk_iov_equal = mk_pointer_init(MK_IOV_EQUAL);
-const mk_pointer mk_iov_none = mk_pointer_init("");
-const mk_pointer mk_iov_crlf = mk_pointer_init(MK_IOV_CRLF);
-const mk_pointer mk_iov_empty = mk_pointer_init(MK_IOV_NONE);
-const mk_pointer mk_iov_crlfcrlf = mk_pointer_init(MK_IOV_CRLFCRLF);
-
-/* Read database configuration parameters */
-static int mk_palm_conf(char *confdir)
-{
-    int ret = 0;
-    unsigned long len;
-    char *conf_path = NULL;
-    struct mk_palm *new, *r;
-    struct mk_config_section *section;
-    struct mk_list *head;
-
-    /* Read palm configuration file */
-    mk_api->str_build(&conf_path, &len, "%s/palm.conf", confdir);
-    conf = mk_api->config_create(conf_path);
-
-    mk_list_foreach(head, &conf->sections) {
-        section = mk_list_entry(head, struct mk_config_section, _head);
-        /* Just read PALM sections */
-        if (strcasecmp(section->name, "PALM") != 0) {
-            continue;
-        }
-
-        /* Alloc node */
-        new = mk_api->mem_alloc(sizeof(struct mk_palm));
-
-        /* Palm file extensions */
-        new->extension = mk_api->config_section_getval(section, "Extension",
-                                                       MK_CONFIG_VAL_STR);
-        /* Palm mime type */
-        new->mimetype = mk_api->config_section_getval(section, "Mimetype",
-                                                      MK_CONFIG_VAL_STR);
-        /* Palm server address */
-        new->server_addr = mk_api->config_section_getval(section, "ServerAddr",
-                                                         MK_CONFIG_VAL_STR);
-        /* Palm server TCP port */
-        new->server_port = (size_t) mk_api->config_section_getval(section, "ServerPort",
-                                                                  MK_CONFIG_VAL_NUM);
-
-        PLUGIN_TRACE("RegPalm '%s|%s|%s|%i'", new->extension, new->mimetype,
-                     new->server_addr, new->server_port);
-        new->next = NULL;
-
-        /* Linking node */
-        if (!palms) {
-            palms = new;
-        }
-        else {
-            r = palms;
-            while (r->next) {
-                r = r->next;
-            }
-            r->next = new;
-        }
-    }
-
-    mk_api->mem_free(conf_path);
-    return ret;
-}
-
-static struct mk_palm *mk_palm_get_handler(mk_pointer * file)
-{
-    struct mk_palm *p;
-    int j, len, extlen;
-
-    j = len = file->len;
-
-    /* looking for extension */
-    while (file->data[j] != '.' && j >= 0) {
-        j--;
-    }
-
-    extlen = file->len - j - 1;
-    if (j == 0) {
-        return NULL;
-    }
-
-    p = palms;
-    while (p) {
-        if (strncasecmp(file->data + j + 1, p->extension, extlen) == 0) {
-            return p;
-        }
-        p = p->next;
-    }
-
-    return NULL;
-}
-
-static int mk_palm_send_headers(struct mk_palm_request *pr)
-{
-    int n;
-    struct client_session *cs = pr->cs;
-    struct session_request *sr = pr->sr;
-
-    if (sr->headers.status == 0) {
-        sr->headers.status = MK_HTTP_OK;
-    }
-
-    sr->headers.cgi = SH_CGI;
-
-    /*
-     * Chunked transfer encoding: just on HTTP/1.1 and when there's no
-     * redirection
-     */
-    if (sr->protocol >= HTTP_PROTOCOL_11 &&
-        (sr->headers.status < MK_REDIR_MULTIPLE ||
-         sr->headers.status > MK_REDIR_USE_PROXY))
-        {
-            sr->headers.transfer_encoding = MK_HEADER_TE_TYPE_CHUNKED;
-            pr->is_te_chunked = MK_TRUE;
-        }
-
-    /* Send just headers from buffer */
-    PLUGIN_TRACE("[CLIENT_FD %i] Sending headers", cs->socket);
-
-    n = (int) mk_api->header_send(cs->socket, cs, sr);
-
-    /*
-     * Monkey core send_headers set TCP_CORK_ON, we need to get
-     * back the status to OFF
-     */
-    mk_api->socket_cork_flag(cs->socket, TCP_CORK_OFF);
-
-    PLUGIN_TRACE("[CLIENT_FD %i] Send headers returned %i", cs->socket, n);
-    return n;
-}
-
-int _mkp_core_prctx(struct server_config *config)
-{
-    /*
-     * Server Address Lookup
-     * ---------------------
-     *
-     * this variable specify the server IP address ,this lookup needs to be
-     * performed in the process context hook as is at this point where the
-     * server socket is already binded. We do not trust in the Listen configuration
-     * key so we do our own lookup.
-     */
-    int len;
-    (void) config;
-       struct sockaddr_in sin;
-       struct in_addr in;
-
-       len = sizeof(sin);
-       if (getsockname(mk_api->config->server_fd,
-                    (struct sockaddr *)&sin, (socklen_t *)&len) == -1) {
-        mk_err("Palm: Could not determinate local address");
-        exit(EXIT_FAILURE);
-    }
-       memset(&in,0,sizeof(in));
-       in.s_addr = sin.sin_addr.s_addr;
-
-    mk_server_address.data = inet_ntoa(in);
-    mk_server_address.len = strlen(mk_server_address.data);
-
-    PLUGIN_TRACE("Server Address Lookup '%s'", mk_server_address.data);
-    return 0;
-}
-
-void _mkp_core_thctx()
-{
-    /* Init request list */
-    mk_palm_request_init();
-
-    /* Init prototol template */
-    mk_palm_protocol_thread_init();
-}
-
-int _mkp_init(struct plugin_api **api, char *confdir)
-{
-    mk_api = *api;
-    palms = 0;
-
-    /* init thread keys */
-    pthread_key_create(&iov_protocol_request, NULL);
-    pthread_key_create(&iov_protocol_request_idx, NULL);
-    pthread_key_create(&cache_ip_str, NULL);
-
-    /* set pointers */
-    mk_api->pointer_set(&mk_server_protocol, HTTP_PROTOCOL_11_STR);
-
-    /* server port */
-    mk_server_port.data = mk_api->mem_alloc(6);
-    mk_api->str_itop(mk_api->config->serverport, &mk_server_port);
-    mk_server_port.len -= 2;
-
-    /* Read configuration */
-    mk_palm_conf(confdir);
-
-    /* Init CGI memory buffers */
-    mk_cgi_env();
-
-    return 0;
-}
-
-void _mkp_exit()
-{
-}
-
-/*
- * Request handler: when the request arrives, this hook is invoked so Palm plugin
- * start it's job checking if it should handle or not this request
- */
-int _mkp_stage_30(struct plugin *plugin, struct client_session *cs,
-                  struct session_request *sr)
-{
-    struct mk_palm *palm;
-    struct mk_palm_request *pr;
-
-    /* Check if this connection already have a palm_request */
-    pr = mk_palm_request_get_by_http(cs->socket);
-    if (pr) {
-        PLUGIN_TRACE("[FD %i] Palm request already exists, RET_CONTINUE", cs->socket);
-        return MK_PLUGIN_RET_CONTINUE;
-    }
-
-    PLUGIN_TRACE("PALM STAGE 30, requesting '%s'", sr->real_path.data);
-
-    /* Get Palm handler */
-    palm = mk_palm_get_handler(&sr->real_path);
-    if (!palm || sr->file_info.size == -1) {
-        PLUGIN_TRACE("[FD %i] Not handled by me", cs->socket);
-        return MK_PLUGIN_RET_NOT_ME;
-    }
-
-    /* Connect to Palm server */
-    pr = mk_palm_connect(palm, cs, sr);
-    if (!pr) {
-        PLUGIN_TRACE("return %i (MK_PLUGIN_RET_CLOSE_CONX)", MK_PLUGIN_RET_CLOSE_CONX);
-        return MK_PLUGIN_RET_CLOSE_CONX;
-    }
-
-    /* Register palm_request object with the thread list */
-    mk_palm_request_add(pr);
-
-    /*
-     * Register socket with thread Epoll interface
-     * -------------------------------------------
-     * For each Monkey worker thread exists a epoll() loop used to handle
-     * events on sockets, plugins can use the same epoll loop and register
-     * events. Here we register the connected FD to palm server and wait for
-     * such events.
-     */
-    mk_api->event_add(pr->palm_fd, MK_EPOLL_READ, plugin, MK_EPOLL_LEVEL_TRIGGERED);
-    PLUGIN_TRACE("[PALM_FD %i] Socket registered in epoll events", pr->palm_fd);
-
-    /* Send request to Palm server */
-    mk_palm_send_request(cs, sr);
-
-    PLUGIN_TRACE("[PALM_FD %i] return MK_PLUGIN_RET_CONTINUE (%i)",
-                 pr->palm_fd, MK_PLUGIN_RET_CONTINUE);
-
-    /*
-     * We need to set the remote client socket event to READ, right now the socket
-     * is in write mode and it will be joining this function every time until some
-     * data is send.
-
-    mk_api->event_socket_change_mode(cs->socket, MK_EPOLL_READ, MK_EPOLL_LEVEL_TRIGGERED);
-    */
-    return MK_PLUGIN_RET_CONTINUE;
-}
-
-/*
- * Establish a TCP connection to the Palm Server
- */
-struct mk_palm_request *mk_palm_connect(struct mk_palm *palm,
-                                        struct client_session *cs,
-                                        struct session_request *sr)
-{
-    int palm_socket;
-
-    /* Connecting to Palm Server */
-    palm_socket = mk_api->socket_connect(palm->server_addr, palm->server_port);
-
-    if (palm_socket < 0) {
-        mk_warn("Palm: Could not connect to %s:%i", palm->server_addr, palm->server_port);
-        mk_api->header_set_http_status(sr, MK_SERVER_INTERNAL_ERROR);
-        return NULL;
-    }
-
-    /* Return instance */
-    return mk_palm_request_create(cs->socket, palm_socket, cs, sr, palm);
-}
-
-int mk_palm_send_request(struct client_session *cs, struct session_request *sr)
-{
-
-    ssize_t bytes_iov=-1;
-    struct mk_iov *iov;
-    struct mk_palm_request *pr;
-
-    pr = mk_palm_request_get_by_http(cs->socket);
-    PLUGIN_TRACE("[FD %i] Sending request to Palm Server", pr->palm_fd);
-
-    if (!pr) return -1;
-
-    if (pr->bytes_sent == 0) {
-        PLUGIN_TRACE("Palm request: '%s'", sr->real_path.data);
-
-        /* Create protocol request  */
-        iov = mk_palm_protocol_request_new(cs, sr);
-
-        /* Write protocol request to palm server */
-        bytes_iov = (ssize_t ) mk_api->iov_send(pr->palm_fd, iov);
-        PLUGIN_TRACE("[PALM_FD %i] written: %i", pr->palm_fd, bytes_iov);
-
-        if (bytes_iov >= 0){
-            pr->bytes_sent += bytes_iov;
-        }
-    }
-
-    PLUGIN_TRACE("Bytes sent to PALM SERVER: %i", pr->bytes_sent);
-    return pr->bytes_sent;
-}
-
-static int mk_palm_write(int socket, char *buffer, int len, int is_chunked)
-{
-    int n;
-    int chunk_len;
-    int chunk_size = 16;
-    char chunk_header[chunk_size];
-
-    if  (len <=0){
-        return 0;
-    }
-
-
-    mk_bug(len <= 0);
-
-    if (is_chunked == MK_TRUE) {
-        mk_api->socket_cork_flag(socket, TCP_CORK_ON);
-        chunk_len = snprintf(chunk_header, chunk_size - 1, "%x%s", len, MK_CRLF);
-        mk_api->socket_send(socket, chunk_header, chunk_len);
-    }
-
-    n = mk_api->socket_send(socket, buffer, len);
-
-    if (is_chunked == MK_TRUE) {
-        mk_api->socket_send(socket, MK_CRLF, 2);
-        mk_api->socket_cork_flag(socket, TCP_CORK_OFF);
-    }
-
-    return n;
-}
-
-static int mk_palm_send_end_chunk(int socket, struct mk_palm_request *pr)
-{
-    int n=0;
-
-    if (pr->is_te_chunked == MK_TRUE) {
-        n = mk_api->socket_send(socket, "0\r\n\r\n", 5);
-    }
-    return n;
-}
-
-/* Check if the CGI field 'Status: XYZ Some message' is
- * present, if so, it modifies the header struct response
- * and return the offset position
- */
-static int mk_palm_cgi_status(char *data, struct session_request *sr)
-{
-    int status;
-    const int status_len = 3;
-    int offset = 0;
-    const int field_len = 8;
-    char buffer[4];
-    const char field[] = "Status: ";
-
-    if (strlen(data) <= (field_len + status_len)) {
-        return 0;
-    }
-
-    if (strncmp(data, field, field_len) == 0) {
-        /* Read HTTP status string */
-        strncpy(buffer, data + field_len, status_len);
-        buffer[3] = '\0';
-
-        /* Convert string status to int */
-        status = atoi(buffer);
-        if (status == 0) {
-            return 0;
-        }
-
-        /* Search breakline */
-        offset = mk_api->str_search(data, MK_IOV_CRLF, MK_STR_SENSITIVE);
-        if (offset > 0) {
-            offset += 2;
-        }
-        else {
-            offset = mk_api->str_search(data, MK_IOV_LF, MK_STR_SENSITIVE);
-            if (offset > 0) {
-                offset += 1;
-            }
-            else {
-                return 0;
-            }
-        }
-
-        sr->headers.status = status;
-        return offset;
-    }
-
-    return 0;
-}
-
-/* sockfd = palm_fd */
-int hangup(int sockfd)
-{
-    struct mk_palm_request *pr;
-
-    PLUGIN_TRACE("[FD %i] hangup", sockfd);
-
-    /* Detect who owns this FD, client or palm */
-    pr = mk_palm_request_get(sockfd);
-    if (pr) { /* palm */
-        PLUGIN_TRACE(" cleaning up palm node | request_end (%i)", pr->client_fd);
-
-        mk_api->event_del(pr->palm_fd);
-
-        /*
-         * We must be careful when invoking http_request_end(), as this
-         * function can raise an event close and this same function
-         * hangup() can be invoked before continue, in the second loop
-         * can get into the client condition (else {..}) so the palm_request
-         * object can not be longer valid.
-         */
-        mk_api->http_request_end(pr->client_fd);
-
-        mk_api->socket_close(sockfd);
-        mk_palm_request_delete(sockfd);
-    }
-    else { /* client */
-        PLUGIN_TRACE("[FD %i] this FD is not a Palm Request", sockfd);
-
-        /* Check if the FD belongs to the client */
-        pr = mk_palm_request_get_by_http(sockfd);
-        if (pr) {
-            PLUGIN_TRACE("[FD %i] but the client is associated to FD %i",
-                         sockfd, pr->palm_fd);
-            mk_api->socket_close(pr->palm_fd);
-            mk_palm_request_delete(pr->palm_fd);
-        }
-    }
-    return MK_PLUGIN_RET_EVENT_CONTINUE;
-}
-
-/* _MKP_EVENTs */
-int _mkp_event_write(int sockfd)
-{
-    int n;
-    struct mk_palm_request *pr;
-
-    pr = mk_palm_request_get_by_http(sockfd);
-    if (!pr) {
-        PLUGIN_TRACE("[FD %i] Not an involved Palm event", sockfd);
-        return MK_PLUGIN_RET_EVENT_CONTINUE;
-    }
-
-    /*
-     * Write when data exists and the plugin already processed the
-     * response HTTP headers
-     */
-    PLUGIN_TRACE("pr->in_len: %i", pr->in_len);
-
-    if (pr->in_len > 0 && pr->headers_sent == MK_TRUE) {
-        n = mk_palm_write(sockfd, pr->in_buffer + pr->in_offset,
-                          pr->in_len - pr->in_offset, pr->is_te_chunked);
-
-        PLUGIN_TRACE("WRITTEN TO CLIENT: %i/%i", n, pr->in_len);
-
-        if (n >= 0 && n < (pr->in_len - pr->in_offset)) {
-            PLUGIN_TRACE("SAVING TO OUT_BUFFER!!!!!!!!!!!!!!!!");
-            strncpy(pr->out_buffer, pr->in_buffer, pr->in_len - n);
-            pr->out_len = pr->in_len - n;
-        }
-        pr->in_len = 0;
-        pr->in_offset = 0;
-    }
-
-    PLUGIN_TRACE("[FD %i] EVENT WRITE", sockfd);
-    return MK_PLUGIN_RET_EVENT_OWNED;
-}
-
-/* _MKP_EVENTs */
-int _mkp_event_read(int sockfd)
-{
-    int n;
-    int headers_end = -1;
-    int offset;
-    struct mk_palm_request *pr;
-
-    pr = mk_palm_request_get(sockfd);
-
-    if (!pr){
-        PLUGIN_TRACE("[FD %i] this FD is not a Palm Request", sockfd);
-        return MK_PLUGIN_RET_EVENT_NEXT;
-    }
-
-    /* Read incoming data from Palm socket */
-    n = mk_api->socket_read(pr->palm_fd, pr->in_buffer + pr->in_len,
-                            (MK_PALM_BUFFER_SIZE - pr->in_len));
-
-#ifdef TRACE
-    PLUGIN_TRACE("[FD %i | CLIENT_FD %i | PALM_FD %i]", sockfd, pr->client_fd, pr->palm_fd);
-    PLUGIN_TRACE(" just readed  : %i", n);
-    if (pr->headers_sent == MK_TRUE) {
-        PLUGIN_TRACE(" headers sent : YES");
-    }
-    else {
-        PLUGIN_TRACE(" headers sent : NO");
-    }
-#endif
-
-    if (n <= 0) {
-        PLUGIN_TRACE(" ending connection: read() = %i", n);
-
-        if (pr->sr->protocol >= HTTP_PROTOCOL_11) {
-            mk_palm_send_end_chunk(pr->client_fd, pr);
-        }
-
-        return MK_PLUGIN_RET_EVENT_CLOSE;
-    }
-
-    /* Increase buffer data length counter */
-    pr->in_len += n;
-
-    /* If response headers + PHP headers has NOT been sent back to client... */
-    if (pr->headers_sent == MK_FALSE) {
-        PLUGIN_TRACE("No headers sent, searching CRLFCRLF...");
-
-        headers_end = mk_api->str_search(pr->in_buffer,
-                                         MK_IOV_CRLFCRLF, MK_STR_SENSITIVE);
-
-        //mk_info("headers_end: %i", headers_end);
-
-        if (headers_end <= 0)  {
-            headers_end = mk_api->str_search(pr->in_buffer,
-                                             MK_IOV_LFLFLFLF, MK_STR_SENSITIVE);
-        }
-
-        if (headers_end <= 0) {
-            PLUGIN_TRACE("No headers found, returning until next loop");
-            return MK_PLUGIN_RET_EVENT_OWNED;
-        }
-
-        PLUGIN_TRACE("Palm header ends in buffer pos %i", headers_end);
-
-        /* Add bytes length for two break lines */
-        headers_end += 4;
-
-        /*
-         * Check if some 'Status:' field was sent in the first line, update the
-         * response HTTP status and return the offset of the content
-         */
-        offset = mk_palm_cgi_status(pr->in_buffer, pr->sr);
-
-        /* Send HTTP response headers */
-        mk_palm_send_headers(pr);
-
-        /*
-         * Send remaining Palm HTTP headers, we cannot send all in the same block
-         * as the response body can need a chunked transfer encoding type for the
-         * next reads from Palm server
-         */
-        n = mk_palm_write(pr->client_fd, pr->in_buffer + offset,
-                          headers_end - offset, MK_FALSE);
-
-        PLUGIN_TRACE("[CLIENT_FD %i] Headers sent to HTTP client: %i", pr->client_fd, n);
-
-        if (n < 0) {
-            return MK_PLUGIN_RET_EVENT_CLOSE;
-        }
-
-        /* Enable headers flag */
-        pr->headers_sent = MK_TRUE;
-        pr->in_offset = headers_end + offset;
-        //mk_info("off: %i, len: %i", pr->in_offset, pr->in_len);
-    }
-
-    /* Update thread node info */
-    mk_palm_request_update(sockfd, pr);
-
-    return MK_PLUGIN_RET_EVENT_OWNED;
-}
-
-int _mkp_event_close(int sockfd)
-{
-    PLUGIN_TRACE("[FD %i] event close", sockfd);
-    return hangup(sockfd);
-}
-
-int _mkp_event_error(int sockfd)
-{
-    PLUGIN_TRACE("[FD %i] event error", sockfd);
-    return hangup(sockfd);
-}
diff --git a/plugins/palm/palm.h b/plugins/palm/palm.h
deleted file mode 100644 (file)
index 5319315..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/*  Monkey HTTP Daemon
- *  ------------------
- *  Copyright (C) 2001-2009, Eduardo Silva P.
- *
- *  This program is free software; 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.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU Library General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-/* palm.c */
-#ifndef MK_PALM_H
-#define MK_PALM_H
-
-#define MK_PALM_BUFFER_SIZE 32768 /* 32KB */
-
-#include "request.h"
-
-#define MK_PALM_ERROR_LINE "\nPalm Error: invalid configuration on palm.conf\n %s\n\n"
-
-struct mk_palm
-{
-    char *extension;
-    char *mimetype;
-    char *server_addr;
-    int server_port;
-    struct mk_palm *next;
-};
-
-pthread_key_t cache_ip_str;
-
-struct plugin_api *mk_api;
-struct mk_config *conf;
-
-#include "mk_iov.h"
-
-mk_pointer mk_server_protocol;
-mk_pointer mk_server_port;
-mk_pointer mk_server_address;
-
-extern const mk_pointer mk_iov_empty;
-extern const mk_pointer mk_iov_crlfcrlf;
-
-struct mk_palm *palms;
-
-struct mk_palm_request *mk_palm_connect(struct mk_palm *palm,
-                                        struct client_session *cs,
-                                        struct session_request *sr);
-int mk_palm_send_request(struct client_session *cs, struct session_request *sr);
-int hangup(int sockfd);
-
-#endif
diff --git a/plugins/palm/protocol.c b/plugins/palm/protocol.c
deleted file mode 100644 (file)
index 6465906..0000000
+++ /dev/null
@@ -1,307 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/*  Monkey HTTP Daemon
- *  ------------------
- *  Copyright (C) 2001-2012, Eduardo Silva P. <edsiper@gmail.com>
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Lesser General Public
- *  License as published by the Free Software Foundation; either
- *  version 2.1 of the License, or (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Lesser General Public License for more details.
- *
- *  You should have received a copy of the GNU Lesser General Public
- *  License along with this library; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- *  MA 02110-1301  USA
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
-#include "MKPlugin.h"
-#include "palm.h"
-#include "protocol.h"
-#include "cgi.h"
-
-static void prot_add_header(struct mk_iov *iov, mk_pointer header, mk_pointer value)
-{
-    mk_api->iov_add_entry(iov, header.data, header.len,
-                          mk_iov_equal, MK_IOV_NOT_FREE_BUF);
-    mk_api->iov_add_entry(iov, value.data, value.len,
-                          mk_iov_crlf, MK_IOV_NOT_FREE_BUF);
-}
-
-static struct mk_iov *prot_template()
-{
-    struct mk_iov *iov;
-
-    /* Use cached iov_request */
-    iov = pthread_getspecific(iov_protocol_request);
-
-    /* Remove any previous data used */
-    mk_api->iov_free_marked(iov);
-    iov->iov_idx = 0;
-    iov->buf_idx = 0;
-    iov->total_len = 0;
-
-    return iov;
-}
-
-/*
- * Convert a request HTTP header into HTTP_ CGI style, e.g:
- *
- *   Accept-Charset:  ->  HTTP_ACCEPT_CHARSET
- */
-static int prot_header2cgi(const char *buf, int len, char **dest)
-{
-    int i;
-    int offset = 0;
-    int prefix_len = 5;
-    char *p;
-    const char *prefix = "HTTP_";
-
-    /*
-     * There're two exception when the prefix HTTP_ must not
-     * be added: Content-Type and Content-Length headers,
-     * i cannot find the reason for that so this belongs to a
-     * stupid way to work.
-     */
-    if (strncasecmp(buf, "Content-", 8) == 0 ||
-        strncasecmp(buf, "Cookie-", 7) == 0) {
-        offset = 0;
-    }
-    else {
-        memcpy(*dest, prefix, prefix_len);
-        offset = prefix_len;
-    }
-
-    p = *dest + offset;
-    for (i=0; i < len; i++) {
-        if (buf[i] == ':') {
-            *p++ = '\0';
-            break;
-        }
-
-        if (buf[i] == '-') {
-            *p++ = '_';
-        }
-        else {
-            *p++ = toupper(buf[i]);
-        }
-    }
-
-    /* Return the new buffer length */
-    i += offset;
-    return i;
-}
-
-static int get_port_by_socket(int fd)
-{
-    socklen_t len = sizeof(struct sockaddr_in);
-    struct sockaddr_in m_addr;
-
-    int ret = getpeername(fd, (struct sockaddr *) &m_addr, &len);
-    if (ret < 0)
-        return ret;
-    return (int) m_addr.sin_port;
-}
-
-/*
- * Returns an 'iov' palm request array with the CGI data
- */
-struct mk_iov *mk_palm_protocol_request_new(struct client_session *cs,
-                                            struct session_request *sr)
-{
-    int i, ret;
-    int row_len;
-    char *ip_str;
-    unsigned long ip_len;
-    char *row_buf;
-
-    mk_pointer iov_temp;
-    struct mk_iov *iov;
-    struct header_toc_row *row;
-
-    /* Use cached iov_request */
-    iov = prot_template();
-    iov->iov_idx = 0;
-
-    /* DOCUMENT_ROOT */
-    prot_add_header(iov, mk_cgi_document_root, sr->host_conf->documentroot);
-
-    /* CONTENT_XYZ */
-    //mk_api->pointer_reset(&iov_temp);
-    if (sr->method == HTTP_METHOD_POST && sr->content_length >= 0) {
-        iov_temp.data = mk_api->mem_alloc(32);
-        mk_api->str_itop(sr->content_length, &iov_temp);
-
-        iov_temp.len -= 2;
-        prot_add_header(iov, mk_cgi_content_length, iov_temp);
-    }
-    if (sr->headers.content_type.len > 0) {
-        prot_add_header(iov, mk_cgi_content_type, sr->headers.content_type);
-    }
-
-    /* SERVER_ADDR */
-    //prot_add_header(iov, mk_cgi_server_addr, mk_server_address);
-
-    /* SERVER_PORT */
-    prot_add_header(iov, mk_cgi_server_port, mk_server_port);
-
-    /*
-     * SERVER_NAME
-     * -----------
-     *
-     * Server name belongs to the value specified in the conf/sites/XYZ vhost file
-     * under key 'ServerName'.
-     */
-    iov_temp.data = sr->host_alias->name;
-    iov_temp.len = sr->host_alias->len;
-    prot_add_header(iov, mk_cgi_server_name, iov_temp);
-
-    /* SERVER_PROTOCOL */
-    prot_add_header(iov, mk_cgi_server_protocol, mk_server_protocol);
-
-    /*
-     * SERVER_SIGNATURE
-     * ----------------
-     * we use an offset of 8 bytes as each host signature is composed in
-     * the following way:
-     *
-     *   server: Monkey/x.y.x
-     *
-     * so the 8 bytes do the offset for 'server: ' which is not useful for
-     * the CGI environment variable.
-     */
-    iov_temp.data = sr->host_conf->header_host_signature.data + 8;
-    iov_temp.len = sr->host_conf->header_host_signature.len - 8;
-    prot_add_header(iov, mk_cgi_server_signature, iov_temp);
-
-    /*
-     * HTTP_*
-     * --------
-     *
-     * CGI spec specify that incomming HTTP headers by the client must be
-     * converted to uppercase, replace '-' by '_' and prefix the 'HTTP_'
-     * string. e.g:
-     *
-     *   Accept-Encoding: -> HTTP_ACCEPT_ENCODING
-     */
-    short int len;
-    short int offset;
-    short int prefix_len = 5;
-
-    for (i=0; i < sr->headers_toc.length; i++) {
-        row = &sr->headers_toc.rows[i];
-        /* let's match common CGI HTTP_ headers */
-        len = row->end - row->init;
-        row_buf = mk_api->mem_alloc(len + 1);
-        row_len = prot_header2cgi(row->init, len, &row_buf);
-
-        /* Row key */
-        mk_api->iov_add_entry(iov, row_buf, row_len,
-                              mk_iov_equal, MK_IOV_FREE_BUF);
-
-        /* Just prefixed HEADERS requires the offset */
-        if (strncmp(row_buf, "HTTP_", 5) == 0) {
-            offset = prefix_len;
-        }
-        else {
-            offset = 0;
-        }
-
-        /* Row value */
-        mk_api->iov_add_entry(iov, row->init + (row_len - offset) + 2,
-                              len - (row_len - offset) - 2,
-                              mk_iov_crlf, MK_IOV_NOT_FREE_BUF);
-    }
-
-    /* REMOTE_ADDR */
-    ip_str = pthread_getspecific(cache_ip_str);
-    ret = mk_api->socket_ip_str(cs->socket, (char **) &ip_str, INET6_ADDRSTRLEN + 1, &ip_len);
-    if (ret < 0) {
-        PLUGIN_TRACE("[FD %i] Error formatting IP address", cs->socket);
-        return NULL;
-    }
-
-    iov_temp.len = ip_len;
-    iov_temp.data = ip_str;
-
-    prot_add_header(iov, mk_cgi_remote_addr, iov_temp);
-
-    /* REMOTE_PORT */
-    iov_temp.data = mk_api->mem_alloc(8);
-    mk_api->str_itop(get_port_by_socket(cs->socket), &iov_temp);
-    iov_temp.len -=2;
-    mk_api->iov_add_entry(iov, mk_cgi_remote_port.data, mk_cgi_remote_port.len,
-                          mk_iov_equal, MK_IOV_NOT_FREE_BUF);
-    mk_api->iov_add_entry(iov, iov_temp.data, iov_temp.len,
-                          mk_iov_crlf, MK_IOV_FREE_BUF);
-
-    /* Miscellaneus CGI headers */
-    prot_add_header(iov, mk_cgi_gateway_interface, mk_cgi_version);
-
-    /*
-     * REQUEST_URI
-     *
-     * if the request URI contains a query string, we must re-compose the full
-     * string as Monkey splits URI from query string
-     */
-    iov_temp.data = sr->uri.data;
-    if (sr->query_string.len > 0) {
-        iov_temp.len = sr->uri.len + sr->query_string.len + 1;
-    }
-    else {
-        iov_temp.len = sr->uri.len;
-    }
-    prot_add_header(iov, mk_cgi_request_uri, iov_temp);
-
-    /* REQUEST_METHOD */
-    prot_add_header(iov, mk_cgi_request_method, sr->method_p);
-    prot_add_header(iov, mk_cgi_script_name, sr->uri);
-    prot_add_header(iov, mk_cgi_script_filename, sr->real_path);
-
-    /* QUERY_STRING */
-    if (sr->query_string.len > 0) {
-        prot_add_header(iov, mk_cgi_query_string, sr->query_string);
-    }
-
-    /*
-     * POST_VARIABLES
-     * --------------
-     * non-standard field of CGI, it just used by Palm protocol
-     */
-    if (sr->content_length > 0 && sr->data.len > 0) {
-        prot_add_header(iov, mk_cgi_post_vars, sr->data);
-    }
-
-    /* Ending CRLFCRLF (\r\n\r\n) */
-    mk_api->iov_add_entry(iov,
-                          mk_iov_crlfcrlf.data, mk_iov_crlfcrlf.len,
-                          mk_iov_none, MK_IOV_NOT_FREE_BUF);
-#ifdef TRACE
-    PLUGIN_TRACE("Palm protocol request");
-    mk_api->iov_send(0, iov);
-#endif
-
-    return iov;
-}
-
-void mk_palm_protocol_thread_init()
-{
-    char *ip_str;
-    struct mk_iov *iov;
-
-    iov = mk_api->iov_create(128,0);
-    pthread_setspecific(iov_protocol_request, iov);
-
-    ip_str = mk_api->mem_alloc(INET6_ADDRSTRLEN + 1);
-    pthread_setspecific(cache_ip_str, ip_str);
-}
diff --git a/plugins/palm/protocol.h b/plugins/palm/protocol.h
deleted file mode 100644 (file)
index f8df1be..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-pthread_key_t iov_protocol_request;
-pthread_key_t iov_protocol_request_idx;
-
-struct request_reset {
-    int *idx;
-    int len;
-};
-
-void mk_palm_protocol_thread_init();
-void mk_palm_protocol_request_reset();
-struct mk_iov *mk_palm_protocol_request_new(struct client_session *cs,
-                                            struct session_request *sr);
diff --git a/plugins/palm/request.c b/plugins/palm/request.c
deleted file mode 100644 (file)
index b274fee..0000000
+++ /dev/null
@@ -1,189 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/*  Monkey HTTP Daemon
- *  ------------------
- *  Copyright (C) 2001-2012, Eduardo Silva P. <edsiper@gmail.com>
- *
- *  This program is free software; 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.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU Library General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#include <pthread.h>
-#include <stdio.h>
-
-#include "MKPlugin.h"
-#include "palm.h"
-
-/* Create a palm_request node */
-struct mk_palm_request *mk_palm_request_create(int client_fd,
-                                               int palm_fd,
-                                               struct client_session *cs,
-                                               struct session_request *sr,
-                                               struct mk_palm *palm)
-{
-    struct mk_palm_request *new;
-
-    new = mk_api->mem_alloc_z(sizeof(struct mk_palm_request));
-    new->client_fd = client_fd;
-    new->palm_fd = palm_fd;
-    new->palm = palm;
-    new->headers_sent = MK_FALSE;
-    new->is_te_chunked = MK_FALSE;
-    new->cs = cs;
-    new->sr = sr;
-
-    new->in_len = 0;
-    new->in_offset = 0;
-    new->out_len = 0;
-    new->pending_end_chunk = MK_FALSE;
-    return new;
-}
-
-void mk_palm_request_add(struct mk_palm_request *pr)
-{
-    /* palm request list (thread context) */
-    struct mk_list *pr_list;
-
-    /* Get thread data */
-    pr_list = (struct mk_list *) pthread_getspecific(_mkp_data);
-
-    /* Add node to list */
-    mk_list_add(&pr->_head, pr_list);
-
-    /* Update thread key */
-    pthread_setspecific(_mkp_data, pr_list);
-}
-
-/* 
- * It register the request and connection data, if it doesn't
- * exists it will be create it, otherwise will return the pointer
- * to the mk_palm_request struct node
- */
-struct mk_palm_request *mk_palm_request_get(int palm_fd)
-{
-    struct mk_palm_request *pr_node;
-    struct mk_list *pr_list, *pr_head;
-
-    /* Get thread data */
-    pr_list = pthread_getspecific(_mkp_data);
-
-    /* No connection previously was found */
-    if(mk_list_is_empty(pr_list) == 0) {
-        return NULL;
-    }
-
-    mk_list_foreach(pr_head, pr_list) {
-        pr_node = mk_list_entry(pr_head, struct mk_palm_request, _head);
-        if(pr_node->palm_fd == palm_fd){
-            return pr_node;
-        }
-    }
-
-    return NULL;
-}
-
-/*
- * Return a palm_request using as search criteria the socket
- * connected to the client (user/browser)
- */
-struct mk_palm_request *mk_palm_request_get_by_http(int socket)
-{
-    struct mk_palm_request *pr_node;
-    struct mk_list *pr_list, *pr_head;
-
-    /* Get thread data */
-    pr_list = pthread_getspecific(_mkp_data);
-
-    /* No connection previously was found */
-    if(mk_list_is_empty(pr_list) == 0) {
-        return NULL;
-    }
-
-    /* Look for node */
-    mk_list_foreach(pr_head, pr_list) {
-        pr_node = mk_list_entry(pr_head, struct mk_palm_request, _head);
-        if(pr_node->client_fd == socket){
-            return pr_node;
-        }
-    }
-
-    return NULL;
-}
-
-void mk_palm_request_update(int socket, struct mk_palm_request  *pr)
-{
-    struct mk_palm_request *pr_node;
-    struct mk_list *pr_list, *pr_head;
-
-    pr_list = pthread_getspecific(_mkp_data);
-    if (mk_list_is_empty(pr_list) == 0) {
-        return;
-    }
-
-    mk_list_foreach(pr_head, pr_list) {
-        pr_node = mk_list_entry(pr_head, struct mk_palm_request, _head);
-        if (pr_node->palm_fd == socket) {
-            pr_node->bytes_sent = pr->bytes_sent;
-            pr_node->bytes_read = pr->bytes_read;
-            pr_node->headers_sent = pr->headers_sent;
-
-            /* Update data */
-            pthread_setspecific(_mkp_data, pr_list);
-            return;
-            }
-    }
-}
-
-/* 
- * Remove a palm_request from the main list, return 0 on success or -1
- * when for some reason the request was not found
- */
-int mk_palm_request_delete(int socket)
-{
-    struct mk_palm_request *pr_node;
-    struct mk_list *pr_list, *pr_temp, *pr_head;
-
-    PLUGIN_TRACE("[FD %i] remove request from list", socket);
-
-    pr_list = pthread_getspecific(_mkp_data);
-    if (mk_list_is_empty(pr_list) == 0) {
-        return -1;
-    }
-
-    mk_list_foreach_safe(pr_head, pr_temp, pr_list) {
-        pr_node = mk_list_entry(pr_head, struct mk_palm_request, _head);
-        
-        if (pr_node->palm_fd == socket) {
-            mk_list_del(pr_head);
-            mk_api->mem_free(pr_node);
-            pthread_setspecific(_mkp_data, pr_list);
-            return 0;
-        }
-    }
-
-    return -1;
-}
-
-/*
- * Initialize the index list for palm_request and then set the
- * list HEAD to the thread key _mkp_data.
- */
-void mk_palm_request_init()
-{
-    struct mk_list *palm_request_list;
-
-    palm_request_list = mk_api->mem_alloc(sizeof(struct mk_list));
-    mk_list_init(palm_request_list);
-    pthread_setspecific(_mkp_data, palm_request_list);
-}
diff --git a/plugins/palm/request.h b/plugins/palm/request.h
deleted file mode 100644 (file)
index 6561ded..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-
-/*  Monkey HTTP Daemon
- *  ------------------
- *  Copyright (C) 2001-2012, Eduardo Silva P. <edsiper@gmail.com>
- *
- *  This program is free software; 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.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU Library General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
-#ifndef MK_PALM_REQUEST_H
-#define MK_PALM_REQUEST_H
-
-#include "palm.h"
-#include "mk_list.h"
-
-struct mk_palm_request
-{
-    int client_fd;
-    int palm_fd;
-
-    /* Incomming data from Palm Server */
-    char in_buffer[MK_PALM_BUFFER_SIZE];
-
-    /* 
-     * Outgoing data, after write to the client from 
-     * in_buffer, any data that could not be sent on that
-     * write is copied to out_buffer, then in_buffer is set
-     * to zero
-     */
-    char out_buffer[MK_PALM_BUFFER_SIZE];
-
-    /* Data length in in_buffer */
-    int in_len;
-
-    /* Data length in out_buffer */
-    int out_len;
-
-    /* 
-     * Used to send remaining data from the firt amount received
-     * from Palm server, in case to add some headers...
-     */
-    int in_offset;
-
-    /* Traffic bytes between plugin and Palm server */
-    unsigned long bytes_sent;
-    unsigned long bytes_read;
-    int headers_sent;
-    int is_te_chunked;
-    int pending_end_chunk;
-
-    struct mk_palm *palm;
-
-    /* Client request data */
-    struct client_session *cs;
-    struct session_request *sr;
-
-    struct mk_list _head;
-};
-
-void mk_palm_request_init();
-struct mk_palm_request *mk_palm_request_create(int client_fd,
-                                               int palm_fd,
-                                               struct client_session *cs,
-                                               struct session_request *sr,
-                                               struct mk_palm *palm);
-void mk_palm_request_add(struct mk_palm_request *pr);
-struct mk_palm_request *mk_palm_request_get(int socket);
-struct mk_palm_request *mk_palm_request_get_by_http(int socket);
-void mk_palm_request_update(int socket, struct mk_palm_request  *pr);
-int mk_palm_request_delete(int socket);
-void mk_palm_free_request(int sockfd);
-
-#endif