diff --git a/.clang-format b/.clang-format index 0dc2f1e..01acca0 100644 --- a/.clang-format +++ b/.clang-format @@ -101,7 +101,7 @@ IndentCaseBlocks: false IndentGotoLabels: true IndentPPDirectives: None IndentExternBlock: AfterExternBlock -IndentRequires: false +IndentRequiresClause: false IndentWidth: 4 IndentWrappedFunctionNames: false InsertTrailingCommas: None diff --git a/srcs/httpserver/src/haywire/http_request.c b/srcs/httpserver/src/haywire/http_request.c index b8d25bf..29f8deb 100644 --- a/srcs/httpserver/src/haywire/http_request.c +++ b/srcs/httpserver/src/haywire/http_request.c @@ -12,8 +12,6 @@ #include "route_compare_method.h" #include "misc.h" -extern char *uv__strndup(const char *s, size_t n); - #define CRLF "\r\n" static const char response_404[] = "HTTP/1.1 404 Not Found" CRLF "Server: Haywire/master" CRLF "Date: Fri, 26 Aug 2011 00:31:53 GMT" CRLF "Connection: Keep-Alive" CRLF @@ -41,8 +39,8 @@ void hw_print_request_headers(http_request *request) { khash_t(hw_string_hashmap) *h = request->headers; kh_foreach(h, k, v, { - char *key = uv__strndup(k->value, k->length + 1); - char *value = uv__strndup(v->value, v->length + 1); + char *key = strndup(k->value, k->length + 1); + char *value = strndup(v->value, v->length + 1); printf("KEY: %s VALUE: %s\n", key, value); free(key); free(value); @@ -51,7 +49,7 @@ void hw_print_request_headers(http_request *request) { void hw_print_body(http_request *request) { if (request->body->length > 0) { - char *body = uv__strndup(request->body->value, request->body->length); + char *body = strndup(request->body->value, request->body->length); printf("BODY: %s\n", body); free(body); } else { diff --git a/srcs/open_dhcp/query.cpp b/srcs/open_dhcp/query.cpp index 5eb13a8..5a9afc1 100644 --- a/srcs/open_dhcp/query.cpp +++ b/srcs/open_dhcp/query.cpp @@ -377,7 +377,12 @@ static void opendhcp_http_get_alluser(http_request *request, hw_http_response *r } void opendhcp_init_http_server() { - hw_http_add_route("/", opendhcp_http_info, nullptr); - hw_http_add_route("getuser", opendhcp_http_get_userinfo, nullptr); - hw_http_add_route("allusers", opendhcp_http_get_alluser, nullptr); + static int added = FALSE; + + if (!added) { + hw_http_add_route("/", opendhcp_http_info, nullptr); + hw_http_add_route("getuser", opendhcp_http_get_userinfo, nullptr); + hw_http_add_route("allusers", opendhcp_http_get_alluser, nullptr); + added = TRUE; + } }