int main(void) { onion *o = onion_new(O_POOL); onion_url *root = onion_root_url(o); onion_url_add_handler(root, "^wd", onion_handler_webdav(".", NULL)); onion_listen(o); return 0; }
int main(int argc, char **argv){ //onion_log=onion_log_syslog; char *port="8080"; char *hostname="::"; const char *dirname="."; #ifdef HAVE_WEBDAV int withwebdav=1; #endif int i; for (i=1;i<argc;i++){ if ((strcmp(argv[i],"--port")==0) || (strcmp(argv[i],"-p")==0)){ port=argv[++i]; ONION_INFO("Listening at port %s",port); } if ((strcmp(argv[i],"--listen")==0) || (strcmp(argv[i],"-l")==0)){ hostname=argv[++i]; ONION_INFO("Listening at hostname %s",hostname); } else if (strcmp(argv[i],"--help")==0 || strcmp(argv[i],"-h")==0){ return show_help(); } #ifdef HAVE_WEBDAV else if (strcmp(argv[i],"--no-webdav")==0){ ONION_INFO("WebDAV support disabled"); withwebdav=0; } #endif else{ dirname=argv[i]; ONION_INFO("Exporting directory %s", dirname); } } onion_handler *root=onion_handler_new((onion_handler_handler)fileserver_page, (void *)dirname, NULL); #ifdef HAVE_WEBDAV if (withwebdav) onion_handler_add(root, onion_handler_webdav(dirname, NULL)); // fallback. else #endif onion_handler_add(root, onion_handler_export_local_new(dirname)); // This is the root directory where the translations are. #define W "." setenv("LANGUAGE","locale",1); // Remove LANGUAGE env var, set it to the locale name, setlocale(LC_ALL,""); bindtextdomain("locale", W); // This is necesary because of the fake name bindtextdomain("es", W); // One per language supported. bindtextdomain("zh", W); bindtextdomain("fr", W); bindtextdomain("pl", W); textdomain("C"); // Default language // All is configured now, now in hands of dgettext(LANG, txt); o=onion_new(O_POOL); onion_set_root_handler(o, root); onion_set_port(o, port); onion_set_hostname(o, hostname); signal(SIGINT, free_onion); int error=onion_listen(o); if (error){ perror("Cant create the server"); } onion_free(o); return 0; }