diff --git a/build/httpd b/build/httpd index a05e189..d7ebee3 100755 Binary files a/build/httpd and b/build/httpd differ diff --git a/build/httpd.dSYM/Contents/Resources/DWARF/httpd b/build/httpd.dSYM/Contents/Resources/DWARF/httpd index afb69e2..250bb4b 100644 Binary files a/build/httpd.dSYM/Contents/Resources/DWARF/httpd and b/build/httpd.dSYM/Contents/Resources/DWARF/httpd differ diff --git a/build/plugins/dummy.dylib b/build/plugins/dummy.dylib index 6f36cdd..ae848c9 100755 Binary files a/build/plugins/dummy.dylib and b/build/plugins/dummy.dylib differ diff --git a/build/plugins/fileman.dylib b/build/plugins/fileman.dylib index 02e8dc3..3940074 100755 Binary files a/build/plugins/fileman.dylib and b/build/plugins/fileman.dylib differ diff --git a/build/plugins/nodedaemon.dylib b/build/plugins/nodedaemon.dylib index 8d20978..a23e672 100755 Binary files a/build/plugins/nodedaemon.dylib and b/build/plugins/nodedaemon.dylib differ diff --git a/build/plugins/pluginsman.dylib b/build/plugins/pluginsman.dylib index 294e841..2370580 100755 Binary files a/build/plugins/pluginsman.dylib and b/build/plugins/pluginsman.dylib differ diff --git a/build/plugins/wterm.dylib b/build/plugins/wterm.dylib index 828731b..10ce37c 100755 Binary files a/build/plugins/wterm.dylib and b/build/plugins/wterm.dylib differ diff --git a/plugin_manager.c b/plugin_manager.c index a4a5298..0b4137b 100644 --- a/plugin_manager.c +++ b/plugin_manager.c @@ -487,7 +487,7 @@ int execute_plugin(int client, const char *path, const char *method, const char { char pname[255]; char pfunc[255]; - void (*fn)(int, const char*,dictionary); + void (*fn)(int, const char*,const char*, dictionary); struct plugin_entry *plugin ; int plen = strlen(path); char * rpath = (char*) malloc((plen+1)*sizeof(char)); @@ -499,7 +499,7 @@ int execute_plugin(int client, const char *path, const char *method, const char if(delim == NULL) { strcpy(pname,rpath); - strcpy(pfunc,"execute"); + strcpy(pfunc,"default"); } else { @@ -515,7 +515,7 @@ int execute_plugin(int client, const char *path, const char *method, const char LOG("Path : '%s'\n", rpath); LOG("Method:%s\n", method); LOG("Plugin name '%s'\n",pname); - LOG("Plugin func. '%s'\n", pfunc); + LOG("Query path. '%s'\n", pfunc); LOG("query :%s\n", query_string); //load the plugin @@ -523,14 +523,14 @@ int execute_plugin(int client, const char *path, const char *method, const char if((plugin= plugin_load(pname)) == NULL) return -1; // load the function - fn = (void (*)(int, const char *, dictionary))dlsym(plugin->handle, pfunc); + fn = (void (*)(int, const char *, const char*, dictionary))dlsym(plugin->handle, PLUGIN_HANDLER); if ((error = dlerror()) != NULL) { - LOG("Problem when finding %s method from %s : %s \n", pfunc, pname,error); + LOG("Problem when finding %s method from %s : %s \n", PLUGIN_HANDLER, pname,error); return -1; } dictionary dic = decode_request(client,method,query_string); - (*fn)(client,method,dic); + (*fn)(client,method,pfunc,dic); free(dic); free(rpath); return 1; diff --git a/plugin_manager.h b/plugin_manager.h index 3451284..740ea2c 100644 --- a/plugin_manager.h +++ b/plugin_manager.h @@ -5,7 +5,7 @@ #define FORM_URL_ENCODE "application/x-www-form-urlencoded" #define FORM_MULTI_PART "multipart/form-data" - +#define PLUGIN_HANDLER "handler" struct plugin_entry { struct plugin_entry *next; diff --git a/plugins/cookiex/cookiex.c b/plugins/cookiex/cookiex.c index 26f74aa..5c858e2 100644 --- a/plugins/cookiex/cookiex.c +++ b/plugins/cookiex/cookiex.c @@ -29,4 +29,15 @@ void get(int client,const char* method,dictionary rq) { +} +void handler(int client, const char* method, const char* rqpth, dictionary rq) +{ + if(EQU(rqpth,"default")) + { + execute(client,method,rq); + } + else + { + unknow(client); + } } \ No newline at end of file diff --git a/plugins/dummy/dummy.c b/plugins/dummy/dummy.c index 5d8cd79..79c6fdd 100644 --- a/plugins/dummy/dummy.c +++ b/plugins/dummy/dummy.c @@ -128,3 +128,26 @@ void jsonex(int client,const char* method,dictionary rq) jpeg(client); __f(client,htdocs("images/ex.jpg")); } +void handler(int client, const char* method, const char* rqpth, dictionary rq) +{ + if(EQU(rqpth,"default")) + { + execute(client,method,rq); + } + else if(EQU(rqpth,"delete")) + { + delete(client,method,rq); + } + else if(EQU(rqpth,"update")) + { + execute(client,method,rq); + } + else if(EQU(rqpth,"jsonex")) + { + execute(client,method,rq); + } + else + { + unknow(client); + } +} \ No newline at end of file diff --git a/plugins/fileman/fileman.c b/plugins/fileman/fileman.c index 97a5519..aa6a2d3 100644 --- a/plugins/fileman/fileman.c +++ b/plugins/fileman/fileman.c @@ -189,4 +189,27 @@ void rmfolder(int c, const char* m, dictionary rq) void pexit() { LOG("Exit file manager,plugins\n"); +} +void handler(int client, const char* method, const char* rqpth, dictionary rq) +{ + if(EQU(rqpth,"default")) + { + execute(client,method,rq); + } + else if(EQU(rqpth,"add")) + { + add(client,method,rq); + } + else if(EQU(rqpth,"rmfolder")) + { + rmfolder(client,method,rq); + } + else if(EQU(rqpth,"mkfolder")) + { + mkfolder(client,method,rq); + } + else + { + unknow(client); + } } \ No newline at end of file diff --git a/plugins/fileman/fileman.c.o b/plugins/fileman/fileman.c.o index 8014b39..a998d6d 100644 Binary files a/plugins/fileman/fileman.c.o and b/plugins/fileman/fileman.c.o differ diff --git a/plugins/nodedaemon/nodedaemon.c b/plugins/nodedaemon/nodedaemon.c index 8d46919..497141c 100644 --- a/plugins/nodedaemon/nodedaemon.c +++ b/plugins/nodedaemon/nodedaemon.c @@ -138,8 +138,8 @@ void pexit() { LOG("%s","EXIT daemon"); } -void execute(int c, const char* m, dictionary d) +void handler(int c, const char* m, const char* rqp, dictionary d) { text(c); __t(c,"This is a system plugin. It cant be acessed from the web"); -} \ No newline at end of file +} diff --git a/plugins/plugin.c b/plugins/plugin.c index 6ceb607..af33027 100644 --- a/plugins/plugin.c +++ b/plugins/plugin.c @@ -250,4 +250,9 @@ char* config_dir() if (stat(path, &st) == -1) mkdir(path, 0755); return path; +} +void unknow(int client) +{ + html(client); + __t(client,"404 API not found"); } \ No newline at end of file diff --git a/plugins/plugin.h b/plugins/plugin.h index deafbf3..bcf5a2f 100644 --- a/plugins/plugin.h +++ b/plugins/plugin.h @@ -59,4 +59,5 @@ sqldb getdb(); void set_cookie(int,dictionary); /*Default function for plugin*/ -void execute(int, const char*,dictionary); +void handler(int, const char*,const char*,dictionary); +void unknow(int); diff --git a/plugins/pluginsman/pluginsman.c b/plugins/pluginsman/pluginsman.c index bb9aff0..cdfaf25 100644 --- a/plugins/pluginsman/pluginsman.c +++ b/plugins/pluginsman/pluginsman.c @@ -74,3 +74,18 @@ void install(int c, const char* m, dictionary rq) __t(c,result,0,"This is not a plugin file"); } +void handler(int client, const char* method, const char* rqpth, dictionary rq) +{ + if(EQU(rqpth,"default")) + { + execute(client,method,rq); + } + else if(EQU(rqpth,"install")) + { + install(client,method,rq); + } + else + { + unknow(client); + } +} \ No newline at end of file diff --git a/plugins/pluginsman/pluginsman.c.o b/plugins/pluginsman/pluginsman.c.o index ff9cbab..55efbbb 100644 Binary files a/plugins/pluginsman/pluginsman.c.o and b/plugins/pluginsman/pluginsman.c.o differ diff --git a/plugins/wterm/wterm.c b/plugins/wterm/wterm.c index 2692e03..6a69ba6 100644 --- a/plugins/wterm/wterm.c +++ b/plugins/wterm/wterm.c @@ -37,7 +37,7 @@ int read_buf(int fd, char*buf,int size) buf[i] = '\0'; return i; } -void execute(int client, const char* m, dictionary rq) +void handler(int client, const char* m, const char* rqp, dictionary rq) { textstream(client); int filedes[2];