<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>JayXie&#039;s blog &#187; Apache</title>
	<atom:link href="http://jayxie.com/category/programming/webtech/apache/feed" rel="self" type="application/rss+xml" />
	<link>http://jayxie.com</link>
	<description>Around emacs, linux, etc.</description>
	<lastBuildDate>Sat, 15 May 2010 13:37:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>用CPP做apache的module</title>
		<link>http://jayxie.com/2006/07/15/%e7%94%a8cpp%e5%81%9aapache%e7%9a%84module.html</link>
		<comments>http://jayxie.com/2006/07/15/%e7%94%a8cpp%e5%81%9aapache%e7%9a%84module.html#comments</comments>
		<pubDate>Sat, 15 Jul 2006 07:31:00 +0000</pubDate>
		<dc:creator>Jay Xie</dc:creator>
				<category><![CDATA[Apache]]></category>

		<guid isPermaLink="false">http://blog.jayxie.com/2006/07/15/%e7%94%a8cpp%e5%81%9aapache%e7%9a%84module</guid>
		<description><![CDATA[
有三个地方要改 首先注释掉include/ap_config_auto.h里面的 define AP_HAVE_DESIGNATED_INITIALIZER 1 然后在ap_config.h里面增加这几行 if (defined(__GNUC__) &#038;&#038; !defined(__cplusplus))                   \ &#124;&#124; (defined(__STDC_VERSION) &#038;&#038; __STDC_VERSION__ &#62; 199901L) define AP_HAVE_DESIGNATED_INITIALIZER 1 endif 再到http_config.h里面修改 typedef const char *(*cmd_func) (); 为 if (defined(__GNUC__) &#038;&#038; !defined(__cplusplus))                \ &#124;&#124; (defined(__STDC_VERSION) &#038;&#038; __STDC_VERSION__ &#62; 199901L) typedef const char *(*cmd_func) (); else typedef const char *(*cmd_func) (cmd_parms*, void*, const char*); endif
]]></description>
			<content:encoded><![CDATA[<p>有三个地方要改</p>
<ol>
<li>首先注释掉include/ap_config_auto.h里面的
<ol>
<li>define AP_HAVE_DESIGNATED_INITIALIZER 1</li>
</li>
</ol>
<li>然后在ap_config.h里面增加这几行
<ol>
<li>if (defined(__GNUC__) &#038;&#038; !defined(__cplusplus))                   \
</li>
</ol>
<p>|| (defined(__STDC_VERSION) &#038;&#038; __STDC_VERSION__ &gt; 199901L)</p>
<ol>
<li>define AP_HAVE_DESIGNATED_INITIALIZER 1
</li>
<li>endif</li>
</li>
</ol>
<li>再到http_config.h里面修改<br />
typedef const char *(*cmd_func) ();<br />
为</p>
<ol>
<li>if (defined(__GNUC__) &#038;&#038; !defined(__cplusplus))                \
</li>
</ol>
<p>|| (defined(__STDC_VERSION) &#038;&#038; __STDC_VERSION__ &gt; 199901L)<br />
typedef const char *(*cmd_func) ();</p>
<ol>
<li>else
</li>
</ol>
<p>typedef const char *(*cmd_func) (cmd_parms*, void*, const char*);</p>
<ol>
<li>endif</li>
</li>
</ol>
</ol>
<p><img src="http://blog.csdn.net/Xeroo/aggbug/925512.aspx" width="1" height="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://jayxie.com/2006/07/15/%e7%94%a8cpp%e5%81%9aapache%e7%9a%84module.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>apache module中取post数据</title>
		<link>http://jayxie.com/2006/04/30/apache-module%e4%b8%ad%e5%8f%96post%e6%95%b0%e6%8d%ae.html</link>
		<comments>http://jayxie.com/2006/04/30/apache-module%e4%b8%ad%e5%8f%96post%e6%95%b0%e6%8d%ae.html#comments</comments>
		<pubDate>Sun, 30 Apr 2006 07:37:00 +0000</pubDate>
		<dc:creator>Jay Xie</dc:creator>
				<category><![CDATA[Apache]]></category>

		<guid isPermaLink="false">http://blog.jayxie.com/2006/04/30/apache-module%e4%b8%ad%e5%8f%96post%e6%95%b0%e6%8d%ae</guid>
		<description><![CDATA[
一共使用三个函数 ap_setup_client_block(r, REQUEST_CHUNKED_DECHUNK) Apache里面说Setup the client to allow Apache to read the request body. 差不多意思就是初始化，第二个参数可以取以下三个值。 REQUEST_NO_BODY 意为如果request必须没有body，如果有就发一个413错误 REQUEST_CHUNKED_ERROR 意为request必须不可为chunked，如果有就发一个411错误 REQUEST_CHUNKED_DECHUNK 意思为如果chunked了，则dechunk。 对于我们要读取post的数据，只能取后面两个，而chunked则是对长连接的选项了，使用哪个视情况而定。 ap_should_client_block(r) 检查是否有数据，对于chunked的话会发送一个100 continue的命令让客户端继续发送数据。 ap_get_client_block(r, pBuff, size) 读取数据
]]></description>
			<content:encoded><![CDATA[<p>一共使用三个函数</p>
<ol>
<li>ap_setup_client_block(r, REQUEST_CHUNKED_DECHUNK)<br />
Apache里面说Setup the client to allow Apache to read the request body. 差不多意思就是初始化，第二个参数可以取以下三个值。</p>
<ol>
<li>REQUEST_NO_BODY<br />
意为如果request必须没有body，如果有就发一个413错误</li>
<li>REQUEST_CHUNKED_ERROR<br />
意为request必须不可为chunked，如果有就发一个411错误</li>
<li>REQUEST_CHUNKED_DECHUNK<br />
意思为如果chunked了，则dechunk。</li>
</ol>
<p>对于我们要读取post的数据，只能取后面两个，而chunked则是对长连接的选项了，使用哪个视情况而定。</li>
<li>ap_should_client_block(r)<br />
检查是否有数据，对于chunked的话会发送一个100 continue的命令让客户端继续发送数据。</li>
<li>ap_get_client_block(r, pBuff, size)<br />
读取数据</li>
</ol>
<p><img src="http://blog.csdn.net/Xeroo/aggbug/698675.aspx" width="1" height="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://jayxie.com/2006/04/30/apache-module%e4%b8%ad%e5%8f%96post%e6%95%b0%e6%8d%ae.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>apache及其module的调试</title>
		<link>http://jayxie.com/2006/04/30/apache%e5%8f%8a%e5%85%b6module%e7%9a%84%e8%b0%83%e8%af%95.html</link>
		<comments>http://jayxie.com/2006/04/30/apache%e5%8f%8a%e5%85%b6module%e7%9a%84%e8%b0%83%e8%af%95.html#comments</comments>
		<pubDate>Sun, 30 Apr 2006 07:03:00 +0000</pubDate>
		<dc:creator>Jay Xie</dc:creator>
				<category><![CDATA[Apache]]></category>

		<guid isPermaLink="false">http://blog.jayxie.com/2006/04/30/apache%e5%8f%8a%e5%85%b6module%e7%9a%84%e8%b0%83%e8%af%95</guid>
		<description><![CDATA[
gdb httpd 用gdb加载httpd进程 (gdb) b break-point 设置断点，可以设置函数名、行数等…… (gdb) run -X -d /usr/local/apache 执行httpd，这个是关键的，-X参数会让httpd以debug模式运行，debug模式是单进程的，这样才好调试。-d /usr/local/apache是设置运行的目录。 另外，gdb httpd pid可以attach一个正在运行的httpd来调试。
]]></description>
			<content:encoded><![CDATA[<ol>
<li>gdb httpd<br />
用gdb加载httpd进程</li>
<li>(gdb) b break-point<br />
设置断点，可以设置函数名、行数等……</li>
<li>(gdb) run -X -d /usr/local/apache<br />
执行httpd，这个是关键的，-X参数会让httpd以debug模式运行，debug模式是单进程的，这样才好调试。-d /usr/local/apache是设置运行的目录。</li>
</ol>
<p>另外，gdb httpd pid可以attach一个正在运行的httpd来调试。</p>
<p><img src="http://blog.csdn.net/Xeroo/aggbug/698592.aspx" width="1" height="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://jayxie.com/2006/04/30/apache%e5%8f%8a%e5%85%b6module%e7%9a%84%e8%b0%83%e8%af%95.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>About module struct in Apache</title>
		<link>http://jayxie.com/2006/04/04/about-module-struct-in-apache.html</link>
		<comments>http://jayxie.com/2006/04/04/about-module-struct-in-apache.html#comments</comments>
		<pubDate>Tue, 04 Apr 2006 07:56:00 +0000</pubDate>
		<dc:creator>Jay Xie</dc:creator>
				<category><![CDATA[Apache]]></category>

		<guid isPermaLink="false">http://blog.jayxie.com/2006/04/04/about-module-struct-in-apache</guid>
		<description><![CDATA[
在写apache模块的时候，会用到module这个结构体。module这个结构体实际上是module_struct，后面附上了定义。使用的时候通常都是定义一个这个结构体的变量并赋初值，如： module AP_MODULE_DECLARE_DATA proxy_module = { STANDARD20_MODULE_STUFF, create_proxy_dir_config,    /* create per-directory config structure */ merge_proxy_dir_config,     /* merge per-directory config structures */ create_proxy_config,        /* create per-server config structure */ merge_proxy_config,         /* merge per-server config structures */ proxy_cmds,                 /* command table */ register_hooks }; 其中STANDARD20_MODULE_STUFF这个宏为module_struct中的API version, minor version, module index, name, danamic load handle, next, magic, rewrite_args赋了初值。随后是per-directory configuration structure的初始化、合并函数和per-server configuration structure的初始化、合并函数。command table是command_rec结构的一个数组，依然是宏展开，描述这个模块在配置文件里面的信息。最后的register_hooks指向用于注册hook的函数。 typedef struct module_struct module; /**  Module structures.  Just about everything is dispatched through  these, directly or indirectly (through the command and handler  tables). / struct module_struct { /** API version, *not* module version; check that module is  compatible with this version of the server. / int version; /** API minor version. Provides API feature milestones. Not checked   during module init */ int minor_version; /** Index to this modules structures in config vectors.  */ int module_index; /** The name of the module's C file */ const char *name; /** The handle for the DSO.  Internal use only */ void *dynamic_load_handle; /** A pointer to the next module in the list   @defvar module_struct *next */ struct module_struct *next; <a href="http://jayxie.com/2006/04/04/about-module-struct-in-apache.html" class="more-link">More &#62;</a>
]]></description>
			<content:encoded><![CDATA[<p>在写apache模块的时候，会用到module这个结构体。module这个结构体实际上是module_struct，后面附上了定义。使用的时候通常都是定义一个这个结构体的变量并赋初值，如：</p>
<pre style="font-family: 宋体,simsun,SimSun,Simsun; font-size: 9pt">module AP_MODULE_DECLARE_DATA proxy_module =
{
STANDARD20_MODULE_STUFF,
create_proxy_dir_config,    /* create per-directory config structure */
merge_proxy_dir_config,     /* merge per-directory config structures */
create_proxy_config,        /* create per-server config structure */
merge_proxy_config,         /* merge per-server config structures */
proxy_cmds,                 /* command table */
register_hooks
};</pre>
<p>其中STANDARD20_MODULE_STUFF这个宏为module_struct中的API version, minor version, module index, name, danamic load handle, next, magic, rewrite_args赋了初值。随后是per-directory configuration structure的初始化、合并函数和per-server configuration structure的初始化、合并函数。command table是command_rec结构的一个数组，依然是宏展开，描述这个模块在配置文件里面的信息。最后的register_hooks指向用于注册hook的函数。</p>
<pre style="font-family: 宋体,simsun,SimSun,Simsun; font-size: 9pt">typedef struct module_struct module;
/**
<ul>
<li> Module structures.  Just about everything is dispatched through
</li>
<li> these, directly or indirectly (through the command and handler
</li>
<li> tables).
</li>
<li>/
</li>
</ul>

struct module_struct {
/** API version, *not* module version; check that module is
<ul>
<li> compatible with this version of the server.
</li>
<li>/
</li>
</ul>

int version;
/** API minor version. Provides API feature milestones. Not checked
<ul>
<li>  during module init */
</li>
</ul>

int minor_version;
/** Index to this modules structures in config vectors.  */
int module_index;
/** The name of the module's C file */
const char *name;
/** The handle for the DSO.  Internal use only */
void *dynamic_load_handle;
/** A pointer to the next module in the list
<ul>
<li>  @defvar module_struct *next */
</li>
</ul>

struct module_struct *next;
/** Magic Cookie to identify a module structure;  It's mainly
<ul>
<li>  important for the DSO facility (see also mod_so).  */
</li>
</ul>

unsigned long magic;
/** Function to allow MPMs to re-write command line arguments.  This
<ul>
<li>  hook is only available to MPMs.
</li>
<li>  @param The process that the server is running in.
</li>
<li>/
</li>
</ul>

void (*rewrite_args) (process_rec *process);
/** Function to allow all modules to create per directory configuration
<ul>
<li>  structures.
</li>
<li>  @param p The pool to use for all allocations.
</li>
<li>  @param dir The directory currently being processed.
</li>
<li>  @return The per-directory structure created
</li>
<li>/
</li>
</ul>

void *(*create_dir_config) (apr_pool_t *p, char *dir);
/** Function to allow all modules to merge the per directory configuration
<ul>
<li>  structures for two directories.
</li>
<li>  @param p The pool to use for all allocations.
</li>
<li>  @param base_conf The directory structure created for the parent directory.
</li>
<li>  @param new_conf The directory structure currently being processed.
</li>
<li>  @return The new per-directory structure created
</li>
<li>/
</li>
</ul>

void *(*merge_dir_config) (apr_pool_t *p, void *base_conf, void *new_conf);
/** Function to allow all modules to create per server configuration
<ul>
<li>  structures.
</li>
<li>  @param p The pool to use for all allocations.
</li>
<li>  @param s The server currently being processed.
</li>
<li>  @return The per-server structure created
</li>
<li>/
</li>
</ul>

void *(*create_server_config) (apr_pool_t *p, server_rec *s);
/** Function to allow all modules to merge the per server configuration
<ul>
<li>  structures for two servers.
</li>
<li>  @param p The pool to use for all allocations.
</li>
<li>  @param base_conf The directory structure created for the parent directory.
</li>
<li>  @param new_conf The directory structure currently being processed.
</li>
<li>  @return The new per-directory structure created
</li>
<li>/
</li>
</ul>

void *(*merge_server_config) (apr_pool_t *p, void *base_conf,                                   void *new_conf);
/** A command_rec table that describes all of the directives this module
<ul>
<li> defines. */
</li>
</ul>

const command_rec *cmds;
/** A hook to allow modules to hook other points in the request processing.
<ul>
<li>  In this function, modules should call the ap_hook_*() functions to
</li>
<li>  register an interest in a specific step in processing the current
</li>
<li>  request.
</li>
<li>  @param p the pool to use for all allocations
</li>
<li>/
</li>
</ul>

void (*register_hooks) (apr_pool_t *p);
};</pre>
]]></content:encoded>
			<wfw:commentRss>http://jayxie.com/2006/04/04/about-module-struct-in-apache.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache中的挂钩剖析</title>
		<link>http://jayxie.com/2006/04/04/apache%e4%b8%ad%e7%9a%84%e6%8c%82%e9%92%a9%e5%89%96%e6%9e%90.html</link>
		<comments>http://jayxie.com/2006/04/04/apache%e4%b8%ad%e7%9a%84%e6%8c%82%e9%92%a9%e5%89%96%e6%9e%90.html#comments</comments>
		<pubDate>Tue, 04 Apr 2006 05:56:00 +0000</pubDate>
		<dc:creator>Jay Xie</dc:creator>
				<category><![CDATA[Apache]]></category>

		<guid isPermaLink="false">http://blog.jayxie.com/2006/04/04/apache%e4%b8%ad%e7%9a%84%e6%8c%82%e9%92%a9%e5%89%96%e6%9e%90</guid>
		<description><![CDATA[
From <a href="http://fanqiang.chinaunix.net/app/web/2006-02-21/4009.shtml">http://fanqiang.chinaunix.net/app/web/2006-02-21/4009.shtml</a>，作者：张中庆。
]]></description>
			<content:encoded><![CDATA[<p>From <a href="http://fanqiang.chinaunix.net/app/web/2006-02-21/4009.shtml">http://fanqiang.chinaunix.net/app/web/2006-02-21/4009.shtml</a>，作者：张中庆。<img src="http://blog.csdn.net/Xeroo/aggbug/650220.aspx" width="1" height="1" /></p>
]]></content:encoded>
			<wfw:commentRss>http://jayxie.com/2006/04/04/apache%e4%b8%ad%e7%9a%84%e6%8c%82%e9%92%a9%e5%89%96%e6%9e%90.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
