X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fjson.h;h=7643d971364e88df7bf5aff6ae85409806011f9b;hb=e9d1efc1ae29ee86b3c2a42bf56531afac7add6d;hp=385b7c559eba57670a34cd369f2c77c7c3db15e1;hpb=c3c50e894376297209d11d7ce490fd782ba206a4;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/json.h b/src/modules/json.h index 385b7c559..7643d9713 100644 --- a/src/modules/json.h +++ b/src/modules/json.h @@ -18,10 +18,6 @@ #define expect_false(expr) maybe_expect ((expr) != 0, 0) #define expect_true(expr) maybe_expect ((expr) != 0, 1) -static void unreachable_internal (char const *file, int line, char const *function); -static void throw_unless_internal (char const *file, int line, char const *function, char const *condition); -static void throw_msg_unless_internal (char const *file, int line, char const *function, char const *message); - #ifdef __GNUC__ # define CURFUNC __PRETTY_FUNCTION__ #elif defined(__BORLANDC__) @@ -30,10 +26,6 @@ static void throw_msg_unless_internal (char const *file, int line, char const *f # define CURFUNC __FUNCTION__ #endif -#define throw_unreachable unreachable_internal (__FILE__, __LINE__, CURFUNC) -#define throw_unless(condition) if (!expect_false (condition)) throw_unless_internal (__FILE__, __LINE__, CURFUNC, #condition) -#define throw_msg_unless(condition, message) if (!expect_false (condition)) throw_msg_unless_internal (__FILE__, __LINE__, CURFUNC, message) - namespace json { class ValueIterator; @@ -532,9 +524,18 @@ namespace json { namespace rpc { - typedef void (*method) (HTTPRequest *http, Value &request, Value &response); - void init (void); - void add_method (char *name, method mth); + typedef void (Module::*method) (HTTPRequest *http, Value &request, Value &response); + + struct mfp + { + Module const *mod; + method mth; + }; + + typedef std::map method_map; + extern method_map methods; + + void add_method (char *name, Module const *mod, method mth); void service (HTTPRequest *http, Value &request, Value &response); void process (HTTPRequest *http, std::string &response, char const *request); }