mod_charset_lite.c revision 10342d5ae27e127c9941a344bda04581d2ccdf4b
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
*
* Portions of this software are based upon public domain software
* originally written at the National Center for Supercomputing Applications,
* University of Illinois, Urbana-Champaign.
*/
/*
* simple hokey charset recoding configuration module
*
* See mod_ebcdic and mod_charset for more thought-out examples. This
* one is just so Jeff can learn how a module works and experiment with
* basic character set recoding configuration.
*
* !!!This is an extremely cheap ripoff of mod_charset.c from Russian Apache!!!
*/
#include <errno.h>
#include <stdio.h>
#include "httpd.h"
#include "http_config.h"
#include "http_core.h"
#include "http_log.h"
#include "http_main.h"
#include "http_protocol.h"
#include "http_request.h"
#include "util_charset.h"
#ifndef APACHE_XLATE
#endif
typedef struct charset_dir_t {
means uninitialized */
const char *charset_source; /* source encoding */
const char *charset_default; /* how to ship on wire */
{
return ap_pcalloc(p,sizeof(charset_dir_t));
}
{
/* If it is defined in the current container, use it. Otherwise, use the one
* from the enclosing container.
*/
a->debug =
a->charset_default =
a->charset_source =
return a;
}
/* CharsetSourceEnc charset
*/
char *name)
{
return NULL;
}
/* CharsetDefault charset
*/
char *name)
{
return NULL;
}
/* CharsetDefault charset
*/
{
if (arg) {
}
else {
}
return NULL;
}
/* find_code_page() is a fixup hook that decides if translation should be
* enabled
*/
static int find_code_page(request_rec *r)
{
const char *mime_type;
if (debug) {
"Entering handler, URI: %s FILENAME: %s ARGS: %s PATH_INFO: %s "
"MIMETYPE: %s FLAGS: %d SUBREQ: %s, REDIR: %s, PROXY: %s",
r->rrx ? 1 : 0,
}
/* catch proxy requests */
/* mod_rewrite indicators */
/* If we don't have a full directory configuration, bail out.
*/
if (debug) {
"incomplete configuration: src %s, dst %s",
}
return DECLINED;
}
/* If this is a subrequest, bail out. We don't want to be setting up
* translation just because something like mod_autoindex wants to find the
* mime type for directory objects.
* (I won't swear that there aren't cases where we need to process
* subrequests :) ).
*/
if (r->main) {
if (debug) {
"skipping subrequest");
}
return DECLINED;
}
/* If mime type isn't text or message, bail out.
*/
if (debug) {
"mime type is %s; no translation selected",
}
return DECLINED;
}
if (debug) {
"dc: %X charset_source: %s charset_default: %s",
(unsigned)dc,
}
if (rv != APR_SUCCESS) {
"can't open translation %s->%s, error %d\n",
return HTTP_INTERNAL_SERVER_ERROR;
}
if (rv != APR_SUCCESS) {
"can't set content translation, error %d\n", rv);
return HTTP_INTERNAL_SERVER_ERROR;
}
if (rv != APR_SUCCESS) {
"can't set translation; BO_WXLATE->%d\n", rv);
return HTTP_INTERNAL_SERVER_ERROR;
}
return DECLINED;
}
static const command_rec cmds[] =
{
{
"CharsetSourceEnc",
NULL,
"source (html,cgi,ssi) file charset"
},
{
"CharsetDefault",
NULL,
"name of default charset"
},
{
"CharsetDebug",
NULL,
FLAG,
"mod_charset_lite debug flag"
},
{NULL}
};
static void register_hooks(void)
{
}
{
NULL,
NULL,
cmds,
NULL,
};