Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add code to initsub to pull in a SQL module if the DIR/sql file exists.

  • Loading branch information...
commit 78f68bb3f1f446647df8511693993ef9c094148d 1 parent 8731f13
@bruceg authored
View
2  conf-ld
@@ -1,3 +1,3 @@
-cc -s -rdynamic
+cc -s
This will be used to link .o files into an executable.
View
1  ezmlm-gate=x
@@ -1 +1,2 @@
-lezmlm
+dl.lib
View
1  ezmlm-get=x
@@ -1 +1,2 @@
-lezmlm
+dl.lib
View
1  ezmlm-issubn=x
@@ -1 +1,2 @@
-lezmlm
+dl.lib
View
1  ezmlm-list=x
@@ -1 +1,2 @@
-lezmlm
+dl.lib
View
1  ezmlm-manage=x
@@ -1 +1,2 @@
-lezmlm
+dl.lib
View
1  ezmlm-request=x
@@ -1 +1,2 @@
-lezmlm
+dl.lib
View
1  ezmlm-return=x
@@ -1 +1,2 @@
-lezmlm
+dl.lib
View
1  ezmlm-send=x
@@ -1 +1,2 @@
-lezmlm
+dl.lib
View
1  ezmlm-store=x
@@ -1 +1,2 @@
-lezmlm
+dl.lib
View
1  ezmlm-sub=x
@@ -1,2 +1,3 @@
ezmlm-subunsub.o
-lezmlm
+dl.lib
View
1  ezmlm-unsub=x
@@ -1,2 +1,3 @@
ezmlm-subunsub.o
-lezmlm
+dl.lib
View
1  ezmlm-warn=x
@@ -1 +1,2 @@
-lezmlm
+dl.lib
View
51 initsub.c
@@ -1,7 +1,13 @@
/*$Id$*/
-#include "subscribe.h"
+#include <dlfcn.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include "die.h"
+#include "strerr.h"
#include "sub_std.h"
+#include "subscribe.h"
+#include "auto_lib.h"
checktag_fn checktag = 0;
closesub_fn closesub = 0;
@@ -66,15 +72,40 @@ static int wrap_subscribe(const char *dir,
(void)flagmysql;
}
+static stralloc path;
+
void initsub(const char *dir)
{
- checktag = wrap_checktag;
- closesub = no_closesub;
- issub = std_issub;
- logmsg = (logmsg_fn)no_logmsg;
- putsubs = wrap_putsubs;
- tagmsg = wrap_tagmsg;
- searchlog = std_searchlog;
- subscribe = wrap_subscribe;
- (void)dir;
+ struct stat st;
+ void *handle;
+ struct sub_plugin *plugin;
+
+ std_makepath(&path,dir,0,"/sql",0);
+ if (stat(path.s,&st) == 0) {
+ std_makepath(&path,auto_lib,0,"/sub-sql.so",0);
+ if ((handle = dlopen(path.s, RTLD_NOW | RTLD_LOCAL)) == 0)
+ strerr_die3x(111,FATAL,"Could not load SQL plugin: ",dlerror());
+ else if ((plugin = dlsym(handle,"sub_plugin")) == 0)
+ strerr_die3x(111,FATAL,"SQL plugin is missing symbols: ",dlerror());
+ else {
+ checktag = plugin->checktag;
+ closesub = plugin->closesub;
+ issub = plugin->issub;
+ logmsg = plugin->logmsg;
+ putsubs = plugin->putsubs;
+ tagmsg = plugin->tagmsg;
+ searchlog = plugin->searchlog;
+ subscribe = plugin->subscribe;
+ }
+ }
+ else {
+ checktag = wrap_checktag;
+ closesub = no_closesub;
+ issub = std_issub;
+ logmsg = (logmsg_fn)no_logmsg;
+ putsubs = wrap_putsubs;
+ tagmsg = wrap_tagmsg;
+ searchlog = std_searchlog;
+ subscribe = wrap_subscribe;
+ }
}
View
14 subscribe.h
@@ -68,4 +68,18 @@ extern tagmsg_fn tagmsg;
extern searchlog_fn searchlog;
extern subscribe_fn subscribe;
+#define SUB_PLUGIN_VERSION 1
+struct sub_plugin
+{
+ int version;
+ checktag_fn checktag;
+ closesub_fn closesub;
+ issub_fn issub;
+ logmsg_fn logmsg;
+ putsubs_fn putsubs;
+ tagmsg_fn tagmsg;
+ searchlog_fn searchlog;
+ subscribe_fn subscribe;
+};
+
#endif
Please sign in to comment.
Something went wrong with that request. Please try again.