diff --git a/backend/Makefile b/backend/Makefile index 486c853..3b13c04 100644 --- a/backend/Makefile +++ b/backend/Makefile @@ -37,6 +37,9 @@ target=$(build_dir)/backend all: $(target) +check: + clang-format --dry-run --Werror src/* + $(target): $(sources:%.c=$(obj_dir)/%.o) $(LD) -o $@ $(CFLAGS) $(LDFLAGS) $^ diff --git a/backend/src/main.c b/backend/src/main.c index c4a3833..2501ff5 100644 --- a/backend/src/main.c +++ b/backend/src/main.c @@ -1,63 +1,54 @@ -#include -#include -#include -#include #include #include +#include +#include +#include +#include #define PORT 8888 int print_out_key( - void *cls, - enum MHD_ValueKind kind, - const char *key, - const char *value) + void* cls, enum MHD_ValueKind kind, const char* key, const char* value) { - printf ("%s: %s\n", key, value); - return MHD_YES; + printf("%s: %s\n", key, value); + return MHD_YES; } -int answer_to_connection( - void *cls, - struct MHD_Connection *connection, - const char *url, - const char *method, - const char *version, - const char *upload_data, - size_t *upload_data_size, - void **req_cls) +int answer_to_connection(void* cls, + struct MHD_Connection* connection, + const char* url, + const char* method, + const char* version, + const char* upload_data, + size_t* upload_data_size, + void** req_cls) { - const char *page = "Hello, browser!"; - struct MHD_Response *response; + const char* page = "Hello, browser!"; + struct MHD_Response* response; int ret; - MHD_get_connection_values( - connection, + MHD_get_connection_values(connection, MHD_HEADER_KIND, (MHD_KeyValueIterator)&print_out_key, NULL); - printf ("New %s request for %s using version %s\n", method, url, version); + printf("New %s request for %s using version %s\n", method, url, version); response = MHD_create_response_from_buffer( - strlen(page), - (void*)page, - MHD_RESPMEM_PERSISTENT); + strlen(page), (void*)page, MHD_RESPMEM_PERSISTENT); ret = (int)MHD_queue_response(connection, MHD_HTTP_OK, response); MHD_destroy_response(response); - return ret; + return ret; } - int main(void) { printf("hello\n"); - struct MHD_Daemon *daemon; + struct MHD_Daemon* daemon; - daemon = MHD_start_daemon( - MHD_USE_INTERNAL_POLLING_THREAD, + daemon = MHD_start_daemon(MHD_USE_INTERNAL_POLLING_THREAD, PORT, NULL, NULL, @@ -65,10 +56,10 @@ int main(void) NULL, MHD_OPTION_END); - if (NULL == daemon) return 1; - getchar(); + if (NULL == daemon) + return 1; + getchar(); MHD_stop_daemon(daemon); return 0; } -