| Hi!
Below is a patch (agains the TEST1 tarball) that adds the
ability to give arguments to wrapper functions. It's small
and backwards compatible. It's used by adding args after
the function name when specifying the wrapper, separating
function name and args with a comma. Then "wrapper_init" is
called on the dynamic library, if present, with function
name and args as arguments.
This could be done in a gazillion other ways, but I didn't
feel like making the widespread changes that would be
necessary for most other implementations.
-Lars
diff -u -r httrack-3.30.91/src/htsmodules.c
httrack-working/src/htsmodules.c
--- httrack-3.30.91/src/htsmodules.c 2003-11-22
12:10:07.000000000 +0100
+++ httrack-working/src/htsmodules.c 2003-12-01
14:57:44.000000000 +0100
@@ -144,6 +144,8 @@
return -1;
}
+typedef void (*WrapperInit)(char *fn, char *args);
+
/* NOTE: handled NOT closed */
void* getFunctionPtr(char* file_, char* fncname) {
char file[1024];
@@ -164,6 +166,17 @@
}
#endif
if (handle) {
+ /* If given arguments, call "wrapper_init" */
+ char *comma;
+ if ((comma = strchr(fncname, ',')) != NULL) {
+ WrapperInit initfunction;
+ fncname[comma-fncname] = '\0';
+ comma++;
+ initfunction = (WrapperInit)DynamicGet(handle,
"wrapper_init");
+ if (initfunction != NULL) {
+ initfunction(fncname, comma);
+ }
+ }
userfunction = (void*) DynamicGet(handle, fncname);
if (userfunction == NULL) {
#ifdef _WIN32
| |