#include <libguile.h>
#endif
-struct userFunctionsStruct {
- String name;
- void (*function)(ServerConnection *, Person *, String, String);
- int minLevel;
- bool needsChannelName;
-};
+#include <map>
+#include <string>
+
+// struct userFunctionsStruct {
+// // String name;
+// void (*function)(ServerConnection *, Person *, String, String);
+// int minLevel;
+// bool needsChannelName;
+// };
class userFunction {
public:
- String name;
void (*function)(ServerConnection *, Person *, String, String);
int minLevel;
bool needsChannelName;
SCM scmFunc;
#endif
- userFunction(String na,
- void (*f)(ServerConnection *, Person *,
- String, String),
- int m, bool n
+ userFunction(void (*f)(ServerConnection *, Person *,
+ String, String) = 0,
+ int m = 0 , bool n = false
#ifdef USESCRIPTS
, int a = -1, SCM scm_f = 0
#endif
)
- : name(na), function(f), minLevel(m), needsChannelName(n)
+ : function(f), minLevel(m), needsChannelName(n)
#ifdef USESCRIPTS
,argsCount(a), scmFunc(scm_f)
#endif
{
#ifdef USESCRIPTS
-// scm_protect_object(scm_f);
+ if (scmFunc)
+ scm_gc_protect_object(scmFunc);
#endif
}
#ifdef USESCRIPTS
-// ~userFunction()
-// { scm_unprotect_object(scmFunc); };
+ ~userFunction()
+ {
+ if (scmFunc)
+ scm_gc_unprotect_object(scmFunc);
+ }
#endif
};
class Parser {
public:
+ static void init ();
static void parseLine(ServerConnection *, String);
static void parse001(ServerConnection *, Person *, String);
#endif
static void sendNotice(Person *, String);
+private:
+
+ typedef void (*fptr)(ServerConnection *, Person *, String);
+ static std::map<std::string, fptr, std::less<std::string> > functions;
+
};
#endif