os.c revision b99dbaab171d91e1b664397cc40e039d0c087c65
2058N/A/* ====================================================================
2058N/A * The Apache Software License, Version 1.1
2058N/A *
2058N/A * Copyright (c) 2000-2001 The Apache Software Foundation. All rights
2058N/A * reserved.
2058N/A *
2058N/A * Redistribution and use in source and binary forms, with or without
2058N/A * modification, are permitted provided that the following conditions
2058N/A * are met:
2058N/A *
2058N/A * 1. Redistributions of source code must retain the above copyright
2058N/A * notice, this list of conditions and the following disclaimer.
2058N/A *
2058N/A * 2. Redistributions in binary form must reproduce the above copyright
2058N/A * notice, this list of conditions and the following disclaimer in
2058N/A * the documentation and/or other materials provided with the
2058N/A * distribution.
2058N/A *
2058N/A * 3. The end-user documentation included with the redistribution,
2058N/A * if any, must include the following acknowledgment:
2058N/A * "This product includes software developed by the
2058N/A * Apache Software Foundation (http://www.apache.org/)."
2058N/A * Alternately, this acknowledgment may appear in the software itself,
2058N/A * if and wherever such third-party acknowledgments normally appear.
2058N/A *
2058N/A * 4. The names "Apache" and "Apache Software Foundation" must
2058N/A * not be used to endorse or promote products derived from this
2058N/A * software without prior written permission. For written
2058N/A * permission, please contact apache@apache.org.
2058N/A *
2058N/A * 5. Products derived from this software may not be called "Apache",
2058N/A * nor may "Apache" appear in their name, without prior written
2058N/A * permission of the Apache Software Foundation.
2058N/A *
2058N/A * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
2058N/A * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
2058N/A * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
2058N/A * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
2058N/A * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2058N/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2058N/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
2058N/A * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
2058N/A * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2058N/A * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
2058N/A * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2058N/A * SUCH DAMAGE.
2058N/A * ====================================================================
2058N/A *
2058N/A * This software consists of voluntary contributions made by many
2058N/A * individuals on behalf of the Apache Software Foundation. For more
2058N/A * information on the Apache Software Foundation, please see
2058N/A * <http://www.apache.org/>.
2058N/A *
* Portions of this software are based upon public domain software
* originally written at the National Center for Supercomputing Applications,
* University of Illinois, Urbana-Champaign.
*/
/*
* This file will include OS specific functions which are not inlineable.
* Any inlineable functions should be defined in os-inline.c instead.
*/
#include "httpd.h"
#include "http_core.h"
#include "os.h"
#include "httpd.h"
/* Check the Content-Type to decide if conversion is needed */
int ap_checkconv(struct request_rec *r)
{
int convert_to_ascii;
const char *type;
/* To make serving of "raw ASCII text" files easy (they serve faster
* since they don't have to be converted from EBCDIC), a new
* "magic" type prefix was invented: text/x-ascii-{plain,html,...}
* If we detect one of these content types here, we simply correct
* the type to the real text/{plain,html,...} type. Otherwise, we
* set a flag that translation is required later on.
*/
type = (r->content_type == NULL) ? ap_default_type(r) : r->content_type;
/* If no content type is set then treat it as (ebcdic) text/plain */
convert_to_ascii = (type == NULL);
/* Conversion is applied to text/ files only, if ever. */
if (type && (strncasecmp(type, "text/", 5) == 0 ||
strncasecmp(type, "message/", 8) == 0)) {
if (strncasecmp(type, ASCIITEXT_MAGIC_TYPE_PREFIX,
sizeof(ASCIITEXT_MAGIC_TYPE_PREFIX)-1) == 0)
r->content_type = apr_pstrcat(r->pool, "text/",
type+sizeof(ASCIITEXT_MAGIC_TYPE_PREFIX)-1,
NULL);
else
/* translate EBCDIC to ASCII */
convert_to_ascii = 1;
}
/* Enable conversion if it's a text document */
ap_bsetflag(r->connection->client, B_EBCDIC2ASCII, convert_to_ascii);
return convert_to_ascii;
}
AP_DECLARE(apr_status_t) ap_os_create_privileged_process(
const request_rec *r,
apr_proc_t *newproc, const char *progname,
const char * const *args,
const char * const *env,
apr_procattr_t *attr, apr_pool_t *p)
{
return apr_proc_create(newproc, progname, args, env, attr, p);
}