Mod Cplusplus CVS committal
Author : gr84b8
Project : mod_cplusplus
Module : src
Dir : mod_cplusplus/src
Modified Files:
apache_filters.cpp apache_handler.cpp apache_output_buffer.cpp
apache_protocol.cpp cpp_request.cpp cpp_server.cpp
env_value.cpp mod_cplusplus.c request_env.cpp
Log Message:
fix up a bunch of things to allow for proper win32 builds. first: export all symbols properly, second: match types to eliminate compiler barfs, third: complete move to using apr for dso loading
===================================================================
RCS file: /cvsroot/modcplusplus/mod_cplusplus/src/apache_filters.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -3 -r1.7 -r1.8
--- apache_filters.cpp 7 Mar 2002 20:14:06 -0000 1.7
+++ apache_filters.cpp 19 Jun 2002 14:11:07 -0000 1.8
@@ -1,3 +1,5 @@
+#define EXPORT_MODCPP
+
#include "apache_filters.h"
extern "C" {
===================================================================
RCS file: /cvsroot/modcplusplus/mod_cplusplus/src/apache_handler.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -3 -r1.11 -r1.12
--- apache_handler.cpp 6 May 2002 16:31:31 -0000 1.11
+++ apache_handler.cpp 19 Jun 2002 14:11:07 -0000 1.12
@@ -1,6 +1,8 @@
+#define EXPORT_MODCPP
+
+#include "apr_dso.h"
#include "apache_handler.h"
#include "apache_protocol.h"
-#include "apr_dso.h"
extern "C" {
@@ -92,36 +94,41 @@
CALL_REQ_FUNCTION(logger);
}
- char *load_cpp_module(apr_pool_t *pool,
- cpp_server_rec *server_rec, const char *name,
- const char *path)
- {
- apr_dso_handle_t *res_handle;
- apr_status_t load_status;
- apr_dso_handle_sym_t ressym;
- cpp_factory_t *cur_handler;
+ char *load_cpp_module( apr_pool_t *pool, cpp_server_rec *server_rec,
+ const char *name, const char *path)
+ {
+ apr_dso_handle_t *sohandle;
+ apr_dso_handle_sym_t sosymbol;
- load_status = apr_dso_load(&res_handle, path, pool);
- if( load_status != APR_SUCCESS ) {
- char load_error[100];
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, NULL,
- "couldn't load so: %s",
- apr_dso_error(res_handle, load_error,
- sizeof(load_error)));
- return "Couldn't Load CPP SO";
+ cpp_factory_t *cur_handler;
+ if ( apr_dso_load(&sohandle, path, pool) != APR_SUCCESS ) {
+ char my_error[256];
+ return apr_pstrcat(
+ pool, "Error Loading CPP SO ", path, " into server: ",
+ apr_dso_error( sohandle, my_error, sizeof(my_error)),
+ NULL);
}
- load_status = apr_dso_sym(&ressym,
- res_handle,
- name);
- if( load_status != APR_SUCCESS ) {
- char load_error[100];
- ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_ERR, 0, NULL,
- "couldn't load so: %s",
- apr_dso_error(res_handle, load_error,
- sizeof(load_error)));
- return "Couldn't Find CPP Symbol";
+
+ printf ("Loaded CPP SO: %s", path);
+
+ /* Log the event */
+ ap_log_perror( APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO,
+ 0, pool,
+ "loaded CPP so: %s", name);
+
+ if ( apr_dso_sym ( &sosymbol, sohandle, name) != APR_SUCCESS) {
+ char my_error[256];
+ return apr_pstrcat(
+ pool, "Can't locate cpp_factory_t `",
+ name, "' in file ", path, ": ",
+ apr_dso_error(sohandle, my_error, sizeof(my_error)),
+ NULL);
}
- cur_handler = (cpp_factory_t *)ressym;
+
+ /* symbol should now be ref the factory structure with
+ * the handler, input, output and protocol filters
+ */
+ cur_handler = (cpp_factory_t *) sosymbol;
ApacheHandler *handler = cur_handler->handler_func ?
cur_handler->handler_func() : NULL;
@@ -133,7 +140,8 @@
cur_handler->protocol_func() : NULL;
if( handler != NULL )
- apr_hash_set(server_rec->handler_hash, name, strlen(name), handler);
+ apr_hash_set(server_rec->handler_hash,
+ name, strlen(name), handler);
if( input_filter != NULL )
apr_hash_set(server_rec->input_filter_hash,
name, strlen(name), input_filter);
===================================================================
RCS file: /cvsroot/modcplusplus/mod_cplusplus/src/apache_output_buffer.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- apache_output_buffer.cpp 26 Apr 2002 18:57:00 -0000 1.1
+++ apache_output_buffer.cpp 19 Jun 2002 14:11:07 -0000 1.2
@@ -1,3 +1,5 @@
+#define EXPORT_MODCPP
+
#include "apache_output_buffer.h"
#include "http_log.h"
@@ -45,8 +47,9 @@
int
apache_output_buffer::overflow(int c) {
- // belive it or not, it's quicker to just ouput every char here,
- // rather than buffer and output on class destruct
+ /* believe it or not, it's quicker to just ouput every char here,
+ * rather than buffer and output on class destruct
+ */
if (buffer_) {
memory += static_cast<char>(c);
} else {
===================================================================
RCS file: /cvsroot/modcplusplus/mod_cplusplus/src/apache_protocol.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- apache_protocol.cpp 4 Jun 2001 00:40:35 -0000 1.1
+++ apache_protocol.cpp 19 Jun 2002 14:11:07 -0000 1.2
@@ -1,3 +1,5 @@
+#define EXPORT_MODCPP
+
#include "apache_protocol.h"
extern "C" {
===================================================================
RCS file: /cvsroot/modcplusplus/mod_cplusplus/src/cpp_request.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- cpp_request.cpp 12 Nov 2001 16:06:48 -0000 1.3
+++ cpp_request.cpp 19 Jun 2002 14:11:07 -0000 1.4
@@ -1,3 +1,5 @@
+#define EXPORT_MODCPP
+
#include "cpp_request.h"
ApacheRequestRec::ApacheRequestRec(request_rec *r, ApacheRequestRec *pPrev,
@@ -67,6 +69,7 @@
i++;
}
}
+
void *ApacheRequestRec::get_dir_config(module *m)
{
return ap_get_module_config(mRequest->per_dir_config, m);
@@ -80,7 +83,8 @@
int ApacheRequestRec::rputs(const char *str)
{
return ap_rputs(str, mRequest);
-}
+}
+
int ApacheRequestRec::rputc(int c)
{
return ap_rputc(c, mRequest);
===================================================================
RCS file: /cvsroot/modcplusplus/mod_cplusplus/src/cpp_server.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- cpp_server.cpp 21 May 2001 18:10:56 -0000 1.1
+++ cpp_server.cpp 19 Jun 2002 14:11:07 -0000 1.2
@@ -1,3 +1,5 @@
+#define EXPORT_MODCPP
+
#include "cpp_server.h"
ApacheServerRec::ApacheServerRec(server_rec *s)
===================================================================
RCS file: /cvsroot/modcplusplus/mod_cplusplus/src/env_value.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- env_value.cpp 26 Apr 2002 18:57:00 -0000 1.1
+++ env_value.cpp 19 Jun 2002 14:11:07 -0000 1.2
@@ -1,3 +1,5 @@
+#define EXPORT_MODCPP
+
#include "env_value.h"
env_value::env_value() {
===================================================================
RCS file: /cvsroot/modcplusplus/mod_cplusplus/src/mod_cplusplus.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -3 -r1.16 -r1.17
--- mod_cplusplus.c 6 May 2002 16:31:31 -0000 1.16
+++ mod_cplusplus.c 19 Jun 2002 14:11:07 -0000 1.17
@@ -12,21 +12,15 @@
static void register_hooks(apr_pool_t * p)
{
ap_hook_handler(cpp_call_handler, NULL, NULL, APR_HOOK_MIDDLE);
- ap_hook_access_checker(cpp_call_access_checker,
- NULL, NULL, APR_HOOK_MIDDLE);
+ ap_hook_access_checker(cpp_call_access_checker, NULL, NULL, APR_HOOK_MIDDLE);
ap_hook_check_user_id(cpp_call_check_user_id, NULL, NULL, APR_HOOK_FIRST);
ap_hook_auth_checker(cpp_call_auth_checker, NULL, NULL, APR_HOOK_MIDDLE);
ap_hook_type_checker(cpp_call_type_checker, NULL, NULL, APR_HOOK_MIDDLE);
ap_hook_fixups(cpp_call_fixups, NULL, NULL, APR_HOOK_MIDDLE);
- ap_hook_log_transaction(cpp_call_logger, NULL, NULL, APR_HOOK_MIDDLE);
-
- ap_hook_pre_connection(cpp_insert_connection_filters,
- NULL, NULL, APR_HOOK_FIRST);
- ap_hook_insert_filter(cpp_insert_request_filters, NULL, NULL,
- APR_HOOK_MIDDLE);
-
- ap_hook_process_connection(cpp_call_process_connection, NULL, NULL,
- APR_HOOK_MIDDLE);
+ ap_hook_log_transaction(cpp_call_logger, NULL, NULL, APR_HOOK_MIDDLE);
+ ap_hook_pre_connection(cpp_insert_connection_filters, NULL, NULL, APR_HOOK_FIRST);
+ ap_hook_insert_filter(cpp_insert_request_filters, NULL, NULL, APR_HOOK_MIDDLE);
+ ap_hook_process_connection(cpp_call_process_connection, NULL, NULL, APR_HOOK_MIDDLE);
}
static void *merge_cpp_config(apr_pool_t *pool, void *base, void *overrides)
@@ -89,8 +83,6 @@
return NULL;
}
-
-
static const char *add_dir_handler(cmd_parms *cmd, void *config,
char *name)
{
@@ -209,7 +201,7 @@
static const command_rec cpp_cmds[] =
{
AP_INIT_TAKE2("LoadCPPHandler", add_handler, NULL, RSRC_CONF,
- "cpp initializer"),
+ "cpp initializer"),
AP_INIT_TAKE1("AddCPPHandler", add_dir_handler, NULL, OR_FILEINFO,
"add handler"),
AP_INIT_TAKE1("AddCPPInputFilter", add_dir_input_filter, NULL, OR_FILEINFO,
===================================================================
RCS file: /cvsroot/modcplusplus/mod_cplusplus/src/request_env.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- request_env.cpp 26 Apr 2002 18:57:00 -0000 1.1
+++ request_env.cpp 19 Jun 2002 14:11:07 -0000 1.2
@@ -1,3 +1,5 @@
+#define EXPORT_MODCPP
+
#include "request_env.h"
#define ENV_READ_LEN 1024
@@ -23,8 +25,9 @@
}
request_env::request_env( request_rec *r, bool buffer = false ) :
- // seems silly/dangerous to to do this, as output_buffer
- // isn't defined yet, but is needed to keep gcc 3.x happy
+ /* seems silly/dangerous to to do this, as output_buffer
+ * isn't defined yet, but is needed to keep gcc 3.x happy
+ */
std::ostream( &output_buffer_ ) ,
output_buffer_( r,buffer ) , r_(r)
{
@@ -54,13 +57,16 @@
void
request_env::decode( char *ch, env_value *pPtr, std::string& pStr ){
- // basic steps in alogorith taken from: http://www.papillion.ne.us/~sthomas/cgi_in_c.html
- // I like this better than the examples given on chap 11 of the eagle book, as using that method
- // requires parsing the string more than once.
+ /* basic steps in alogorith taken from:
+ * http://www.papillion.ne.us/~sthomas/cgi_in_c.html
+ * I like this better than the examples given on chap 11 of the eagle book,
+ * as using that method
+ * requires parsing the string more than once.
+ */
size_t ch_len = strlen(ch);
for (size_t i = 0 ; i < ch_len; i++ ){
-
+
switch ( ch[i] ) {
/* test for end of string */
@@ -80,7 +86,9 @@
}
break;
- /* have we reached the end of the value, and are switching to a new name? */
+ /* have we reached the end of the value,
+ * and are switching to a new name?
+ */
case '&':
if ( ( ! pStr.empty() ) && pPtr) {
pPtr->add_value( pStr );
@@ -163,8 +171,8 @@
(*this) << "I recieved: " << env_.size() << " elements\n";
- for ( hash_type::const_iterator it = env_.begin();
- it != env_.end(); it++ ) {
+ for( hash_type::const_iterator it = env_.begin();
+ it != env_.end(); it++ ) {
(*this) << (*it).first << " has " << (*it).second->num_vals() << " values\n";
for ( int i = 0; i < (*it).second->num_vals() ; i++ ){
|