From 2ff3be7dc16f55858cd8e3f0d4f18a6bb28ffbcc Mon Sep 17 00:00:00 2001 From: Jianhui Zhao Date: Fri, 13 Mar 2020 23:09:48 +0800 Subject: [PATCH] beautify code style Signed-off-by: Jianhui Zhao --- example/example.c | 16 ++++++++-------- src/buffer | 2 +- src/connection.c | 4 ++-- src/connection.h | 8 ++++---- src/log.h | 2 +- src/ssl.c | 6 +++--- src/uhttpd.c | 2 +- src/utils.h | 2 +- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/example/example.c b/example/example.c index 5447cfe..a732492 100644 --- a/example/example.c +++ b/example/example.c @@ -54,9 +54,9 @@ static void signal_cb(struct ev_loop *loop, ev_signal *w, int revents) static void usage(const char *prog) { fprintf(stderr, "Usage: %s [option]\n" - " -p port # Default port is 8080\n" - " -s # SSl on\n" - " -v # verbose\n", prog); + " -p port # Default port is 8080\n" + " -s # SSl on\n" + " -v # verbose\n", prog); exit(1); } @@ -71,11 +71,11 @@ int main(int argc, char **argv) int opt; while ((opt = getopt(argc, argv, "p:sv")) != -1) { - switch (opt) - { + switch (opt) { case 'p': port = atoi(optarg); - break;\ + break; + \ case 's': ssl = true; case 'v': @@ -88,7 +88,7 @@ int main(int argc, char **argv) if (!verbose) uh_log_threshold(LOG_ERR); - + uh_log_info("libuhttpd version: %s\n", UHTTPD_VERSION_STRING); srv = uh_server_new(loop, "0.0.0.0", port); @@ -112,7 +112,7 @@ int main(int argc, char **argv) err: srv->free(srv); free(srv); - + return 0; } diff --git a/src/buffer b/src/buffer index 99adb71..2fb5523 160000 --- a/src/buffer +++ b/src/buffer @@ -1 +1 @@ -Subproject commit 99adb71b0bd8cb2c09fd41e52334a9bcf8831327 +Subproject commit 2fb5523d44eb5cc65eb9473ecbf689727097b3cd diff --git a/src/connection.c b/src/connection.c index 63a1dc1..aa4ec3c 100644 --- a/src/connection.c +++ b/src/connection.c @@ -442,8 +442,8 @@ static void keepalive_cb(struct ev_loop *loop, struct ev_timer *w, int revents) } if (after > 0) { - ev_timer_set (w, after, 0.0); - ev_timer_start (loop, w); + ev_timer_set(w, after, 0.0); + ev_timer_start(loop, w); return; } diff --git a/src/connection.h b/src/connection.h index 2f35b55..47d6873 100644 --- a/src/connection.h +++ b/src/connection.h @@ -45,23 +45,23 @@ struct uh_request { struct { int offset; int len; - }url_info; + } url_info; char *url; struct { int name_offset; int name_len; int value_offset; int value_len; - }headers_info[UHTTPD_MAX_HEADER_NUM]; + } headers_info[UHTTPD_MAX_HEADER_NUM]; int header_num; struct { char *name; char *value; - }headers[UHTTPD_MAX_HEADER_NUM]; + } headers[UHTTPD_MAX_HEADER_NUM]; struct { int offset; int len; - }body; + } body; }; struct uh_connection { diff --git a/src/log.h b/src/log.h index aec83e5..1601454 100644 --- a/src/log.h +++ b/src/log.h @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + #ifndef _UH_LOG_H #define _UH_LOG_H diff --git a/src/ssl.c b/src/ssl.c index a10f48e..9030942 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -56,8 +56,8 @@ void *uh_ssl_ctx_init(const char *cert, const char *key) goto err; } - if(mbedtls_ssl_config_defaults(&ctx->conf, MBEDTLS_SSL_IS_SERVER, - MBEDTLS_SSL_TRANSPORT_STREAM, MBEDTLS_SSL_PRESET_DEFAULT) != 0) { + if (mbedtls_ssl_config_defaults(&ctx->conf, MBEDTLS_SSL_IS_SERVER, + MBEDTLS_SSL_TRANSPORT_STREAM, MBEDTLS_SSL_PRESET_DEFAULT) != 0) { uh_log_err("Failed to init SSL config\n"); goto err; } @@ -67,7 +67,7 @@ void *uh_ssl_ctx_init(const char *cert, const char *key) #if defined(MBEDTLS_SSL_CACHE_C) mbedtls_ssl_conf_session_cache(&ctx->conf, &ctx->cache, - mbedtls_ssl_cache_get, mbedtls_ssl_cache_set); + mbedtls_ssl_cache_get, mbedtls_ssl_cache_set); #endif mbedtls_ssl_conf_ca_chain(&ctx->conf, ctx->cert.next, NULL); diff --git a/src/uhttpd.c b/src/uhttpd.c index 9a342bc..d6795b7 100644 --- a/src/uhttpd.c +++ b/src/uhttpd.c @@ -134,7 +134,7 @@ int uh_server_init(struct uh_server *srv, struct ev_loop *loop, const char *host setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(int)); - if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) <0) { + if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) { close(sock); uh_log_err("bind: %s\n", strerror(errno)); return -1; diff --git a/src/utils.h b/src/utils.h index 769b909..9fc3630 100644 --- a/src/utils.h +++ b/src/utils.h @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ - + #ifndef _UH_UTILS_H #define _UH_UTILS_H