aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Kropf <josh@slashdev.ca>2007-08-02 15:05:07 (GMT)
committerJosh Kropf <josh@slashdev.ca>2007-08-02 15:05:07 (GMT)
commita9064e2310f8fc358ddc83f604464b9f7c3007c4 (patch)
tree751c4541e925b8e573e88beda7ae5d6fc851d200
parent824668425ee62aa09a126f63cd44962eeeb25a28 (diff)
downloadecho-server-a9064e2310f8fc358ddc83f604464b9f7c3007c4.zip
echo-server-a9064e2310f8fc358ddc83f604464b9f7c3007c4.tar.gz
echo-server-a9064e2310f8fc358ddc83f604464b9f7c3007c4.tar.bz2
Fixed bug in action mapping function macros... "should" work now
-rw-r--r--action/action.cpp6
-rw-r--r--action/action.h34
-rw-r--r--fcgi/dispatcher.cpp1
3 files changed, 21 insertions, 20 deletions
diff --git a/action/action.cpp b/action/action.cpp
index e1c4277..61ba329 100644
--- a/action/action.cpp
+++ b/action/action.cpp
@@ -9,8 +9,6 @@ using namespace action;
ActionFactory::ActionFactory()
{
void* handle;
- typedef int (*count_func_t)();
- typedef void (*mapping_func_t)(int, char*, create_t, destroy_t);
Config config;
vector<string> v = config.modules();
@@ -32,10 +30,10 @@ ActionFactory::ActionFactory()
// for each action, call the mapping function
for (int i=0; i<count; i++) {
- char* key; // action key string
+ const char* key; // action key string
factory f; // create/destroy function pointers
- mapping_f(i, key, f.create, f.destroy);
+ mapping_f(i, &key, &f.create, &f.destroy);
_factory_map[key] = f;
}
diff --git a/action/action.h b/action/action.h
index 3119b16..135f42e 100644
--- a/action/action.h
+++ b/action/action.h
@@ -8,21 +8,6 @@
#ifndef _ACTION_H_
#define _ACTION_H_
-/**
- * These macros must be used by action modules to define the auto-mapping
- * functions. These functions are called by the action factory class to
- * discover the
- */
-
-// function name that returns number of actions in the module
-#define COUNT_FUNC "__action_count"
-
-// function name that return action key and create/destroy functions
-#define MAPPING_FUNC "__action_mapping"
-
-#define BEGIN_MAPPING_FUNC extern "C" void __action_mapping(int i, char* key, create_t create, destroy_t destroy) {
-#define BEGIN_COUNT_FUNC extern "C" int __action_count() {
-#define END_FUNC }
namespace action {
@@ -51,6 +36,25 @@ typedef Action* (*create_t)();
typedef void (*destroy_t)(Action*);
/**
+ * In order for dynamic modules to inform the action factory class of the
+ * available actions, two required functions must be defined. These macros
+ * must be used by each action module to define the functions.
+ */
+
+// This function should return the number of actions in the module
+#define COUNT_FUNC "__action_count"
+#define BEGIN_COUNT_FUNC extern "C" int __action_count() {
+typedef int (*count_func_t)();
+
+// This function will be called to obtain the action key and create/destroy function pointers
+#define MAPPING_FUNC "__action_mapping"
+#define BEGIN_MAPPING_FUNC extern "C" void __action_mapping(int i, const char** key, create_t* create, destroy_t* destroy) {
+typedef void (*mapping_func_t)(int, const char**, create_t*, destroy_t*);
+
+// End function macro
+#define END_FUNC }
+
+/**
* Registry of action mapping.
*/
class ActionFactory {
diff --git a/fcgi/dispatcher.cpp b/fcgi/dispatcher.cpp
index b441c2a..dd326d3 100644
--- a/fcgi/dispatcher.cpp
+++ b/fcgi/dispatcher.cpp
@@ -45,7 +45,6 @@ int main (void)
}
}
-cerr << "***DEBUG*** " << (action == NULL) << endl;
if (action != NULL) {
action->execute(cgi, io);