From 085f6d54dbcb93a93fbcd7b503cf3ac1aee96a1c Mon Sep 17 00:00:00 2001 From: Shuanglei Tao Date: Wed, 21 Dec 2016 22:50:23 +0800 Subject: [PATCH] Reformat C source files --- src/http.c | 10 +++++----- src/protocol.c | 2 +- src/server.c | 40 ++++++++++++++++++++-------------------- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/http.c b/src/http.c index 2502651..4b92bb8 100644 --- a/src/http.c +++ b/src/http.c @@ -82,7 +82,7 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason, void *user, voi p = buffer + LWS_PRE; end = p + sizeof(buffer) - LWS_PRE; - if (!strncmp((const char *)in, "/auth_token.js", 14)) { + if (!strncmp((const char *) in, "/auth_token.js", 14)) { size_t n = server->credential != NULL ? sprintf(buf, "var tty_auth_token = '%s';", server->credential) : 0; if (lws_add_http_header_status(wsi, HTTP_STATUS_OK, &p, end)) @@ -128,10 +128,10 @@ callback_http(struct lws *wsi, enum lws_callback_reasons reason, void *user, voi return 1; goto try_to_reuse; case LWS_CALLBACK_OPENSSL_PERFORM_CLIENT_CERT_VERIFICATION: - if (!len || (SSL_get_verify_result((SSL*)in) != X509_V_OK)) { - int err = X509_STORE_CTX_get_error((X509_STORE_CTX*)user); - int depth = X509_STORE_CTX_get_error_depth((X509_STORE_CTX*)user); - const char* msg = X509_verify_cert_error_string(err); + if (!len || (SSL_get_verify_result((SSL *) in) != X509_V_OK)) { + int err = X509_STORE_CTX_get_error((X509_STORE_CTX *) user); + int depth = X509_STORE_CTX_get_error_depth((X509_STORE_CTX *) user); + const char *msg = X509_verify_cert_error_string(err); lwsl_err("client certificate verification error: %s (%d), depth: %d\n", msg, err, depth); return 1; } diff --git a/src/protocol.c b/src/protocol.c index d3ef925..e8e1637 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -255,7 +255,7 @@ callback_tty(struct lws *wsi, enum lws_callback_reasons reason, t_free(frame->data); t_free(frame); - if(lws_partial_buffered(wsi)){ + if (lws_partial_buffered(wsi)) { lws_callback_on_writable(wsi); break; } diff --git a/src/server.c b/src/server.c index dd97455..8c215cb 100644 --- a/src/server.c +++ b/src/server.c @@ -22,24 +22,24 @@ static const struct lws_extension extensions[] = { // command line options static const struct option options[] = { - {"port", required_argument, NULL, 'p'}, - {"interface", required_argument, NULL, 'i'}, - {"credential", required_argument, NULL, 'c'}, - {"uid", required_argument, NULL, 'u'}, - {"gid", required_argument, NULL, 'g'}, - {"signal", required_argument, NULL, 's'}, - {"reconnect", required_argument, NULL, 'r'}, - {"ssl", no_argument, NULL, 'S'}, - {"ssl-cert", required_argument, NULL, 'C'}, - {"ssl-key", required_argument, NULL, 'K'}, - {"ssl-ca", required_argument, NULL, 'A'}, - {"readonly", no_argument, NULL, 'R'}, - {"check-origin", no_argument, NULL, 'O'}, - {"once", no_argument, NULL, 'o'}, - {"debug", required_argument, NULL, 'd'}, - {"version", no_argument, NULL, 'v'}, - {"help", no_argument, NULL, 'h'}, - {NULL, 0, 0, 0} + {"port", required_argument, NULL, 'p'}, + {"interface", required_argument, NULL, 'i'}, + {"credential", required_argument, NULL, 'c'}, + {"uid", required_argument, NULL, 'u'}, + {"gid", required_argument, NULL, 'g'}, + {"signal", required_argument, NULL, 's'}, + {"reconnect", required_argument, NULL, 'r'}, + {"ssl", no_argument, NULL, 'S'}, + {"ssl-cert", required_argument, NULL, 'C'}, + {"ssl-key", required_argument, NULL, 'K'}, + {"ssl-ca", required_argument, NULL, 'A'}, + {"readonly", no_argument, NULL, 'R'}, + {"check-origin", no_argument, NULL, 'O'}, + {"once", no_argument, NULL, 'o'}, + {"debug", required_argument, NULL, 'd'}, + {"version", no_argument, NULL, 'v'}, + {"help", no_argument, NULL, 'h'}, + {NULL, 0, 0, 0} }; static const char *opt_string = "p:i:c:u:g:s:r:aSC:K:A:Rt:Ood:vh"; @@ -279,8 +279,8 @@ main(int argc, char **argv) { break; case 't': optind--; - for(;optind < start && *argv[optind] != '-'; optind++){ - char *option =strdup(optarg); + for (; optind < start && *argv[optind] != '-'; optind++) { + char *option = strdup(optarg); char *key = strsep(&option, "="); if (key == NULL) { fprintf(stderr, "ttyd: invalid client option: %s, format: key=value\n", optarg); -- 2.43.4