void raop_destroy(raop_t *raop) { if (raop) { raop_stop(raop); httpd_destroy(raop->httpd); rsakey_destroy(raop->rsakey); logger_destroy(raop->logger); free(raop); /* Cleanup the network */ netutils_cleanup(); } }
int main (int argc, const char * argv[]) { #ifdef WIN32 WSADATA data; WSAStartup(MAKEWORD(2,2),&data); #endif printf("server runs on http://localhost:8080/\n(default port 80 requires admin rights)\n"); Httpd* srv = httpd_create(8080, http_handler, 0); if (srv) { while (1) { // httpd_process can be used in polling or waiting mode httpd_process(srv, true); } httpd_destroy(srv); } return 0; }
int main(int argc, char **argv) { herror_t status; nanohttp_log_set_loglevel(NANOHTTP_LOG_INFO); if (httpd_init(argc, argv)) { fprintf(stderr, "Cannot init httpd\n"); exit(1); } if ((status = httpd_register("/", root_service)) != H_OK) { fprintf(stderr, "Cannot register service (%s)\n", herror_message(status)); herror_release(status); httpd_destroy(); exit(1); } if ((status = httpd_register_secure("/secure", secure_service, simple_authenticator)) != H_OK) { fprintf(stderr, "Cannot register secure service (%s)\n", herror_message(status)); herror_release(status); httpd_destroy(); exit(1); } if ((status = httpd_register("/headers", headers_service)) != H_OK) { fprintf(stderr, "Cannot register headers service (%s)\n", herror_message(status)); herror_release(status); httpd_destroy(); exit(1); } if ((status = httpd_register("/mime", mime_service)) != H_OK) { fprintf(stderr, "Cannot register MIME service (%s)\n", herror_message(status)); herror_release(status); httpd_destroy(); exit(1); } if ((status = httpd_register("/post", post_service)) != H_OK) { fprintf(stderr, "Cannot register POST service (%s)\n", herror_message(status)); herror_release(status); httpd_destroy(); exit(1); } if ((status = httpd_register_default("/error", default_service)) != H_OK) { fprintf(stderr, "Cannot register default service (%s)\n", herror_message(status)); herror_release(status); httpd_destroy(); exit(1); } if ((status = httpd_run()) != H_OK) { fprintf(stderr, "Cannot run httpd (%s)\n", herror_message(status)); herror_release(status); httpd_destroy(); exit(1); } httpd_destroy(); return 0; }