Apache Server for Windows Little Black Book:The Apache API
function GetCookie (name)
{
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen)
{
var j = i + alen;
if (document.cookie.substring(i, j) == arg) {
var end = document.cookie.indexOf (";", j);
if (end == -1)
end = document.cookie.length;
return unescape(document.cookie.substring(j, end));
}
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
var m1='';
var gifstr=GetCookie("UsrType");
if((gifstr!=0 ) && (gifstr!=null)) { m2=gifstr; }
document.write(m1+m2+m3);
Keyword
Title
Author
ISBN
Publisher
Imprint
Brief
Full
Advanced Search
Search Tips
Please Select
-----------
Components
Content Mgt
Certification
Databases
Enterprise Mgt
Fun/Games
Groupware
Hardware
IBM Redbooks
Intranet Dev
Middleware
Multimedia
Networks
OS
Prod Apps
Programming
Security
UI
Web Services
Webmaster
Y2K
-----------
New Titles
-----------
Free Archive
To access the contents, click the chapter and section titles.
Apache Server for Windows Little Black Book
(Publisher: The Coriolis Group)
Author(s): Greg Holden with Matthew Keller
ISBN: 1576103919
Publication Date: 01/01/99
function isIE4()
{
return( navigator.appName.indexOf("Microsoft") != -1 && (navigator.appVersion.charAt(0)=='4') );
}
function bookMarkit()
{
var url="http://www.itknowledge.com/PSUser/EWBookMarks.html?url="+window.location+"&isbn=0";
parent.location.href=url;
//var win = window.open(url,"myitk");
//if(!isIE4())
// win.focus();
}
Search this book:
Previous
Table of Contents
Next
Other parts of the request_rec structure contain information about the request (the_request), information about the server itself (server), and any internal redirect information (main/next/prev).
How Modules Use Resources
Modules use resource pools to deal with resource allocation. Pools allow a module (and Apache) to easily keep track of the memory and files it is using and clean the files up as necessary.
Memory is allocated by calling the ap_palloc or ap_pcalloc functions, which take as arguments a pointer to a pool structure and the amount of memory to be allocated.
Files are opened by calling the ap_pfopen function, which takes a pointer to a pool structure, a string with the path to the file, and a string containing access permissions to the file.
All resources are freed when their parent pool is cleared.
Immediate Solutions
Viewing Module Structure
The best way to structure a module for Apache is to follow the structure of one of the modules that is compiled into Apache by default. To view the structure, you need to download the source code. You can do that by following these steps:
1. Go to the Apache download area at www.apache.org/dist.
2. Click on the link for a Gzip version of the current release and download the file to your computer.
3. Open the file you just downloaded with WinZip or a similar application.
TIP: Youll need to rename the source file you downloaded in order to open it with WinZip. Change the name so that it has a double file extension (for example, apache_1_3_3_tar.tar.gz) instead of just a .tar extension (for example, apache_1_3_3_tar.tar).
4. Extract any files you want to view. This example examines the mod_alias.c, the source code for the mod_alias module.
5. Open the mod_alias.c or other file in a text editor such as Note-pad and view the contents.
6. Scroll past the licensing and copyright information and view the module code. The Apache module structure is defined in http_config and, therefore, all modules should start with the following lines:
#include "httpd.h"
#include "http_config.h"
These lines establish a link between the apache core and the modules core.
7. The convention is to conclude each module by declaring the module structure. Scroll to the end of the source code and youll see the structure as follows:
module MODULE_VAR_EXPORT alias_module =
{
STANDARD_MODULE_STUFF,
NULL, /* initializer */
create_alias_dir_config, /* dir config creater */
merge_alias_dir_config, /* dir merger default
is to override */
create_alias_config, /* server config */
merge_alias_config, /* merge server configs */
alias_cmds, /* command table */
NULL, /* handlers */
translate_alias_redir, /* filename translation */
NULL, /* check_user_id */
NULL, /* check auth */
NULL, /* check access */
NULL, /* type_checker */
fixup_redir, /* fixups */
NULL, /* logger */
NULL, /* header parser */
NULL, /* child_init */
NULL, /* child_exit */
NULL /* post read-request */
};
The STANDARD_MODULE_STUFF line must appear in all module structures. It initializes important structural elements that the core uses to implement modules.
Using Common API Functions
All of the public functions and variables included as part of the Apache API are preceded by the prefix ap_. If you write your own modules, its important to use this prefix. The naming system was devised to prevent conflicts between function names in Apache and functions in third-party libraries linked via modules.
Many of the most commonly used functions are presented in Table 15.1.
Table 15.1 Common Apache API Functions.
Function
Purpose
ap_call_exec
Signifies a shell to an external program
ap_clear_pool
Clears a pool without destroying the pool itself
ap_clear_table
Clears a table
ap_copy_table
Returns a copy of a table
ap_destroy_pool
Destroys a pool and all of its subpools, releasing their memory
ap_internal_redirect
Forces Apache to redirect to a specified URL
ap_log_error
Writes to the error log
ap_make_array
Allocates an array of arbitrarily sized elements
ap_make_table
Creates a table in a resource pool
ap_make_sub_pool
Returns a pool that is the child of the pool passed to it
ap_no2slash
Removes // from a path
ap_palloc
Allocates memory for a resource pool
ap_pcalloc
Allocates memory for a resource pool, clearing it first
ap_pfclose
Closes an open file in a resource pool
ap_pfopen
Opens a file within a resource pool
ap_rprintf
Prints a formatted string
ap_rputs
Prints a string
ap_rputc
Prints a character
ap_run_cleanup
Executes the Apache cleanup routine
ap_send_http_header
Sends response header to the client
ap_start_restart
Restarts the Apache server, forcing the configuration files to be reread
ap_start_shutdown
Performs a clean shutdown of the server
ap_table_add
Places a new key/value pair in a table
ap_table_get
Determines the value in a table
ap_table_set
Replaces or creates a new table entry
ap_pstrcat
Concatenates the NULL-terminated list of strings in a new block of memory
ap_uudecode
Decodes an UUEncoded string
Previous
Table of Contents
Next
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited.
Wyszukiwarka
Podobne podstrony:
304 30713 (304)301 1116 (304)304 34więcej podobnych podstron