diff --git a/examples/MSP432/ccs/MG_hello/Board.h b/examples/MSP432/ccs/MG_hello/Board.h index 312526897ec20baf4adf98b3cfdcf5b3080759c2..fb086c1842c4e69490bbd3c9a87bcffa7042b105 100644 --- a/examples/MSP432/ccs/MG_hello/Board.h +++ b/examples/MSP432/ccs/MG_hello/Board.h @@ -1,3 +1,4 @@ +/* clang-format off */ /* * Copyright (c) 2015, Texas Instruments Incorporated * All rights reserved. diff --git a/examples/MSP432/ccs/MG_hello/MSP_EXP432P401R.c b/examples/MSP432/ccs/MG_hello/MSP_EXP432P401R.c index 80e15c1e02aa10acff1b1526046aaa96c107e6fd..60b5bc7de48b0486874f52c33efa59d93a94adac 100644 --- a/examples/MSP432/ccs/MG_hello/MSP_EXP432P401R.c +++ b/examples/MSP432/ccs/MG_hello/MSP_EXP432P401R.c @@ -1,3 +1,4 @@ +/* clang-format off */ /* * Copyright (c) 2015-2016, Texas Instruments Incorporated * All rights reserved. diff --git a/examples/MSP432/ccs/MG_hello/MSP_EXP432P401R.h b/examples/MSP432/ccs/MG_hello/MSP_EXP432P401R.h index 1738f49e2032a448401871c8cbcf6b2b1faed3fe..7e3d9048abe07208daca12ff5fe2de46cfb03e2c 100644 --- a/examples/MSP432/ccs/MG_hello/MSP_EXP432P401R.h +++ b/examples/MSP432/ccs/MG_hello/MSP_EXP432P401R.h @@ -1,3 +1,4 @@ +/* clang-format off */ /* * Copyright (c) 2015, Texas Instruments Incorporated * All rights reserved. diff --git a/examples/MSP432/ccs/MG_hello/main.c b/examples/MSP432/ccs/MG_hello/main.c index 171ef7151a56df6e25f44a168903cd7f0a714499..7ab423d0d876ad0beca80c14eb3a0ee9a50365fc 100644 --- a/examples/MSP432/ccs/MG_hello/main.c +++ b/examples/MSP432/ccs/MG_hello/main.c @@ -37,7 +37,8 @@ #include "wifi.h" -static const char *upload_form = "\ +static const char *upload_form = + "\ <h1>Upload file</h1> \ <form action='/upload' method='POST' enctype='multipart/form-data'> \ <input type='file' name='file'> \ @@ -75,8 +76,7 @@ void mg_ev_handler(struct mg_connection *nc, int ev, void *ev_data) { ("HTTP request from %s: %.*s %.*s", addr, (int) hm->method.len, hm->method.p, (int) hm->uri.len, hm->uri.p)); if (mg_vcmp(&hm->uri, "/upload") == 0 || - (mg_vcmp(&hm->uri, "/") == 0 && - mg_stat("SL:index.html", &st) != 0)) { + (mg_vcmp(&hm->uri, "/") == 0 && mg_stat("SL:index.html", &st) != 0)) { mg_send(nc, upload_form, strlen(upload_form)); nc->flags |= MG_F_SEND_AND_CLOSE; break; @@ -107,8 +107,8 @@ void mg_ev_handler(struct mg_connection *nc, int ev, void *ev_data) { } static void mg_init(struct mg_mgr *mgr) { - WiFi_Params wifiParams; - WiFi_Handle handle; + WiFi_Params wifiParams; + WiFi_Handle handle; LOG(LL_INFO, ("MG task running")); @@ -153,23 +153,23 @@ static void mg_init(struct mg_mgr *mgr) { } int main(void) { - Board_initGeneral(); - Board_initGPIO(); - Board_initWiFi(); - - setvbuf(stdout, NULL, _IOLBF, 0); - setvbuf(stderr, NULL, _IOLBF, 0); - cs_log_set_level(LL_INFO); - cs_log_set_file(stdout); - - if (!mg_start_task(MG_TASK_PRIORITY, MG_TASK_STACK_SIZE, mg_init)) { - LOG(LL_ERROR, ("Error starting Mongoose task")); - return 1; - } + Board_initGeneral(); + Board_initGPIO(); + Board_initWiFi(); + + setvbuf(stdout, NULL, _IOLBF, 0); + setvbuf(stderr, NULL, _IOLBF, 0); + cs_log_set_level(LL_INFO); + cs_log_set_file(stdout); + + if (!mg_start_task(MG_TASK_PRIORITY, MG_TASK_STACK_SIZE, mg_init)) { + LOG(LL_ERROR, ("Error starting Mongoose task")); + return 1; + } - osi_start(); + osi_start(); - return 0; + return 0; } void SimpleLinkHttpServerCallback(SlHttpServerEvent_t *e, diff --git a/examples/MSP432/ccs/MG_hello/wifi.c b/examples/MSP432/ccs/MG_hello/wifi.c index 6a509eef1990cc5f45a682c732aad6520013c715..d55b9c427b7ee79ddfd1cb7b835c3ba89dcdd875 100644 --- a/examples/MSP432/ccs/MG_hello/wifi.c +++ b/examples/MSP432/ccs/MG_hello/wifi.c @@ -88,8 +88,8 @@ bool wifi_setup_ap(const char *ssid, const char *pass, int channel) { sl_Stop(0); int role = sl_Start(NULL, NULL, NULL); if (role != ROLE_AP) { - LOG(LL_ERROR, ("Expected ROLE_AP (%d), got %d", ROLE_AP, role)); - return false; + LOG(LL_ERROR, ("Expected ROLE_AP (%d), got %d", ROLE_AP, role)); + return false; } if (sl_NetAppStart(SL_NET_APP_DHCP_SERVER_ID) != 0) { LOG(LL_ERROR, ("DHCP server failed to start")); diff --git a/examples/big_upload/big_upload.c b/examples/big_upload/big_upload.c index 2530df3f28a1dd05398264539442042f66fd4399..8bd3cc5a519c3ee7e3d6b6f442747a0582745a26 100644 --- a/examples/big_upload/big_upload.c +++ b/examples/big_upload/big_upload.c @@ -34,7 +34,7 @@ static void handle_request(struct mg_connection *nc) { static void handle_upload(struct mg_connection *nc, int ev, void *p) { struct file_writer_data *data = (struct file_writer_data *) nc->user_data; - struct mg_http_multipart_part *mp = (struct mg_http_multipart_part*)p; + struct mg_http_multipart_part *mp = (struct mg_http_multipart_part *) p; switch (ev) { case MG_EV_HTTP_PART_BEGIN: { diff --git a/examples/connected_device_2/server.c b/examples/connected_device_2/server.c index d96b1ce3736c2e2de649619965e42a8ff9b6a02c..37281c5bf8f8f81c514baaf8d3ec8b8c0ac2d15f 100644 --- a/examples/connected_device_2/server.c +++ b/examples/connected_device_2/server.c @@ -10,7 +10,7 @@ struct device_settings { static const char *s_http_port = "8000"; static struct mg_serve_http_opts s_http_server_opts; -static struct device_settings s_settings = { "value1", "value2" }; +static struct device_settings s_settings = {"value1", "value2"}; static void handle_save(struct mg_connection *nc, struct http_message *hm) { // Get form variables and store settings values diff --git a/examples/connected_device_3/server.c b/examples/connected_device_3/server.c index ecfdbd6f3997c76bf6bf839935874cac8aa357a2..fc9f907db7cd1ceeb34c481d00332aa54814770a 100644 --- a/examples/connected_device_3/server.c +++ b/examples/connected_device_3/server.c @@ -10,7 +10,7 @@ struct device_settings { static const char *s_http_port = "8000"; static struct mg_serve_http_opts s_http_server_opts; -static struct device_settings s_settings = { "value1", "value2" }; +static struct device_settings s_settings = {"value1", "value2"}; static void handle_save(struct mg_connection *nc, struct http_message *hm) { // Get form variables and store settings values diff --git a/examples/connected_device_4/server.c b/examples/connected_device_4/server.c index 35a7ff567db4078062682a821ee358c7082781dc..f836203d4316e0298c656c7abe5f28966a115a24 100644 --- a/examples/connected_device_4/server.c +++ b/examples/connected_device_4/server.c @@ -10,7 +10,7 @@ struct device_settings { static const char *s_http_port = "8000"; static struct mg_serve_http_opts s_http_server_opts; -static struct device_settings s_settings = { "value1", "value2" }; +static struct device_settings s_settings = {"value1", "value2"}; static void handle_save(struct mg_connection *nc, struct http_message *hm) { // Get form variables and store settings values diff --git a/examples/cookie_authentication/cookie_auth.c b/examples/cookie_authentication/cookie_auth.c index 35b662b03f203dae6cde4082c71ecc08e9cd26f7..f532f12ed28ca24fa8f4af63d10d14f1125adcc4 100644 --- a/examples/cookie_authentication/cookie_auth.c +++ b/examples/cookie_authentication/cookie_auth.c @@ -11,16 +11,11 @@ static struct mg_serve_http_opts s_http_server_opts; static const char *s_login_uri = "/login.html"; static const char *s_secret = ":-)"; // Must be known only to server - static void generate_ssid(const char *user_name, const char *expiration_date, char *ssid, size_t ssid_size) { char hash[33]; - cs_md5(hash, - user_name, strlen(user_name), - ":", (size_t) 1, - expiration_date, strlen(expiration_date), - ":", (size_t) 1, - s_secret, strlen(s_secret), + cs_md5(hash, user_name, strlen(user_name), ":", (size_t) 1, expiration_date, + strlen(expiration_date), ":", (size_t) 1, s_secret, strlen(s_secret), NULL); snprintf(ssid, ssid_size, "%s|%s|%s", user_name, expiration_date, hash); } @@ -36,8 +31,8 @@ static int check_auth(struct http_message *hm) { // Look for session ID in the Cookie. // That session ID can be validated against the database that stores // current active sessions. - mg_http_parse_header( - mg_get_http_header(hm, "Cookie"), "ssid", ssid, sizeof(ssid)); + mg_http_parse_header(mg_get_http_header(hm, "Cookie"), "ssid", ssid, + sizeof(ssid)); if (sscanf(ssid, "%[^|]|%[^|]|", name, expire) == 2) { generate_ssid(name, expire, calculated_ssid, sizeof(calculated_ssid)); if (strcmp(ssid, calculated_ssid) == 0) { @@ -59,7 +54,6 @@ static void check_login_form_submission(struct mg_connection *c, // A real authentication mechanism should be employed here. // Also, the whole site should be served through HTTPS. if (strcmp(name, "Joe") == 0 && strcmp(password, "Doe") == 0) { - // Generate expiry date time_t t = time(NULL) + 3600; // Valid for 1 hour snprintf(expire_epoch, sizeof(expire_epoch), "%lu", (unsigned long) t); @@ -73,7 +67,7 @@ static void check_login_form_submission(struct mg_connection *c, "Location: /\r\n\r\n", ssid, expire); } else { - mg_printf(c, "%s", "HTTP/1.1 302 Moved\r\nLocation: /\r\n\r\n"); + mg_printf(c, "%s", "HTTP/1.1 302 Moved\r\nLocation: /\r\n\r\n"); } } diff --git a/examples/http_client/http_client.c b/examples/http_client/http_client.c index 5017d8b11404b59f0a9fe40d3dacefe074aef6ea..f65073b12b5530837da239741ad075cf100e45fd 100644 --- a/examples/http_client/http_client.c +++ b/examples/http_client/http_client.c @@ -16,8 +16,8 @@ static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) { switch (ev) { case MG_EV_CONNECT: - if (* (int *) ev_data != 0) { - fprintf(stderr, "connect() failed: %s\n", strerror(* (int *) ev_data)); + if (*(int *) ev_data != 0) { + fprintf(stderr, "connect() failed: %s\n", strerror(*(int *) ev_data)); s_exit_flag = 1; } break; @@ -54,8 +54,8 @@ int main(int argc, char *argv[]) { } if (i + 1 != argc) { - fprintf(stderr, "Usage: %s [%s] [--hexdump <file>] <URL>\n", - argv[0], s_show_headers_opt); + fprintf(stderr, "Usage: %s [%s] [--hexdump <file>] <URL>\n", argv[0], + s_show_headers_opt); exit(EXIT_FAILURE); } diff --git a/examples/json_rpc_server/json_rpc_server.c b/examples/json_rpc_server/json_rpc_server.c index 9df455276b18f84c94a503b8d151198f6fef3aa8..81e43801b9024f71302ce5b335d5a5ac9224b2dc 100644 --- a/examples/json_rpc_server/json_rpc_server.c +++ b/examples/json_rpc_server/json_rpc_server.c @@ -31,15 +31,16 @@ static int rpc_sum(char *buf, int len, struct mg_rpc_request *req) { static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) { struct http_message *hm = (struct http_message *) ev_data; - static const char *methods[] = { "sum", NULL }; - static mg_rpc_handler_t handlers[] = { rpc_sum, NULL }; + static const char *methods[] = {"sum", NULL}; + static mg_rpc_handler_t handlers[] = {rpc_sum, NULL}; char buf[100]; switch (ev) { case MG_EV_HTTP_REQUEST: - mg_rpc_dispatch(hm->body.p, hm->body.len, buf, sizeof(buf), - methods, handlers); - mg_printf(nc, "HTTP/1.0 200 OK\r\nContent-Length: %d\r\n" + mg_rpc_dispatch(hm->body.p, hm->body.len, buf, sizeof(buf), methods, + handlers); + mg_printf(nc, + "HTTP/1.0 200 OK\r\nContent-Length: %d\r\n" "Content-Type: application/json\r\n\r\n%s", (int) strlen(buf), buf); nc->flags |= MG_F_SEND_AND_CLOSE; diff --git a/examples/mqtt_broker/mqtt_broker.c b/examples/mqtt_broker/mqtt_broker.c index 2bf8225199faa4e76058589994b5cb5b4d217491..8cb465e9fbb653a3dbfdeda2809d234a3fb90f03 100644 --- a/examples/mqtt_broker/mqtt_broker.c +++ b/examples/mqtt_broker/mqtt_broker.c @@ -37,7 +37,7 @@ int main(void) { * and subscriptions */ - for(;;) { + for (;;) { mg_mgr_poll(&mgr, 1000); } } diff --git a/examples/multithreaded_restful_server/multithreaded_restful_server.c b/examples/multithreaded_restful_server/multithreaded_restful_server.c index 8287888f6837e9206d305b39116e6f1836b386b7..373e730f1b166c9117daab788632eec82e87fafc 100644 --- a/examples/multithreaded_restful_server/multithreaded_restful_server.c +++ b/examples/multithreaded_restful_server/multithreaded_restful_server.c @@ -20,9 +20,10 @@ static void ev_handler(struct mg_connection *c, int ev, void *p) { sleep(3); /* Send the reply */ - snprintf(reply, sizeof(reply), "{ \"uri\": \"%.*s\" }\n", - (int) hm->uri.len, hm->uri.p); - mg_printf(c, "HTTP/1.1 200 OK\r\n" + snprintf(reply, sizeof(reply), "{ \"uri\": \"%.*s\" }\n", (int) hm->uri.len, + hm->uri.p); + mg_printf(c, + "HTTP/1.1 200 OK\r\n" "Content-Type: application/json\r\n" "Content-Length: %d\r\n" "\r\n" diff --git a/examples/netcat/nc.c b/examples/netcat/nc.c index e4bbaf5fe73d8f33931ae91bd09dc06fa87383e6..d43bf285b65b7062f79cff3afe6d164279146d74 100644 --- a/examples/netcat/nc.c +++ b/examples/netcat/nc.c @@ -30,7 +30,8 @@ static void signal_handler(int sig_num) { static void show_usage_and_exit(const char *prog_name) { fprintf(stderr, "%s\n", "Copyright (c) 2014 CESANTA SOFTWARE"); fprintf(stderr, "%s\n", "Usage:"); - fprintf(stderr, " %s\n [-d debug_file] [-l] [tcp|ssl]://[ip:]port[:cert][:ca_cert]", + fprintf(stderr, + " %s\n [-d debug_file] [-l] [tcp|ssl]://[ip:]port[:cert][:ca_cert]", prog_name); fprintf(stderr, "%s\n", "Examples:"); fprintf(stderr, " %s\n -d hexdump.txt ssl://google.com:443", prog_name); @@ -40,7 +41,7 @@ static void show_usage_and_exit(const char *prog_name) { } static void on_stdin_read(struct mg_connection *nc, int ev, void *p) { - int ch = * (int *) p; + int ch = *(int *) p; (void) ev; diff --git a/examples/publish_subscribe/publish_subscribe.c b/examples/publish_subscribe/publish_subscribe.c index 3f6012491ddb0553d3f0477b252fa8b983b41672..25868255cab387dadb8f159de0df018041d3f526 100644 --- a/examples/publish_subscribe/publish_subscribe.c +++ b/examples/publish_subscribe/publish_subscribe.c @@ -19,7 +19,7 @@ #include "mongoose.h" static void *stdin_thread(void *param) { - int ch, sock = * (int *) param; + int ch, sock = *(int *) param; while ((ch = getchar()) != EOF) { unsigned char c = (unsigned char) ch; send(sock, &c, 1, 0); // Forward all types characters to the socketpair @@ -93,7 +93,7 @@ int main(int argc, char *argv[]) { // The other end of a pair goes inside the server ioconn = mg_add_sock(&mgr, fds[0], client_handler); - ioconn->flags |= MG_F_USER_1; // Mark this so we know this is a stdin + ioconn->flags |= MG_F_USER_1; // Mark this so we know this is a stdin ioconn->user_data = server_conn; } else { diff --git a/examples/raspberry_pi_mjpeg_led/cloud_side.c b/examples/raspberry_pi_mjpeg_led/cloud_side.c index 987cb9be3b4917d8809abb720932f0acd88ceac6..92c28ba52b2689aa776d7cfa82f33984615e1190 100644 --- a/examples/raspberry_pi_mjpeg_led/cloud_side.c +++ b/examples/raspberry_pi_mjpeg_led/cloud_side.c @@ -34,8 +34,10 @@ static void push_frame_to_clients(struct mg_mgr *mgr, for (nc = mg_next(mgr, NULL); nc != NULL; nc = mg_next(mgr, nc)) { if (!(nc->flags & MG_F_USER_2)) continue; // Ignore un-marked requests - mg_printf(nc, "--w00t\r\nContent-Type: image/jpeg\r\n" - "Content-Length: %lu\r\n\r\n", (unsigned long) wm->size); + mg_printf(nc, + "--w00t\r\nContent-Type: image/jpeg\r\n" + "Content-Length: %lu\r\n\r\n", + (unsigned long) wm->size); mg_send(nc, wm->data, wm->size); mg_send(nc, "\r\n", 2); printf("Image pushed to %p\n", nc); @@ -50,7 +52,8 @@ static void send_command_to_the_device(struct mg_mgr *mgr, const struct mg_str *cmd) { struct mg_connection *nc; for (nc = mg_next(mgr, NULL); nc != NULL; nc = mg_next(mgr, nc)) { - if (!(nc->flags & MG_F_IS_WEBSOCKET)) continue; // Ignore non-websocket requests + if (!(nc->flags & MG_F_IS_WEBSOCKET)) + continue; // Ignore non-websocket requests mg_send_websocket_frame(nc, WEBSOCKET_OP_TEXT, cmd->p, cmd->len); printf("Sent API command [%.*s] to %p\n", (int) cmd->len, cmd->p, nc); @@ -75,15 +78,15 @@ static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) { switch (ev) { case MG_EV_HTTP_REQUEST: if (mg_vcmp(&hm->uri, "/mjpg") == 0) { - nc->flags |= MG_F_USER_2; /* Set a mark on image requests */ + nc->flags |= MG_F_USER_2; /* Set a mark on image requests */ mg_printf(nc, "%s", - "HTTP/1.0 200 OK\r\n" - "Cache-Control: no-cache\r\n" - "Pragma: no-cache\r\n" - "Expires: Thu, 01 Dec 1994 16:00:00 GMT\r\n" - "Connection: close\r\n" - "Content-Type: multipart/x-mixed-replace; " - "boundary=--w00t\r\n\r\n"); + "HTTP/1.0 200 OK\r\n" + "Cache-Control: no-cache\r\n" + "Pragma: no-cache\r\n" + "Expires: Thu, 01 Dec 1994 16:00:00 GMT\r\n" + "Connection: close\r\n" + "Content-Type: multipart/x-mixed-replace; " + "boundary=--w00t\r\n\r\n"); } else if (mg_vcmp(&hm->uri, "/api") == 0 && hm->body.len > 0) { /* * RESTful API call. HTTP message body should be a JSON message. @@ -129,13 +132,13 @@ int main(int argc, char *argv[]) { exit(EXIT_FAILURE); } mg_set_protocol_http_websocket(nc); - web_root_opts.document_root = "./web_root"; + web_root_opts.document_root = "./web_root"; /* * We explicitly hand over control to the Mongoose manager * in this event loop and we can easily multiplex other activities. */ - for(;;) { + for (;;) { mg_mgr_poll(&mgr, 1000); } diff --git a/examples/raspberry_pi_mjpeg_led/device_side.c b/examples/raspberry_pi_mjpeg_led/device_side.c index fbca755977255b6beb995ef4b1e3a40df94dda74..4263628018a382c36f5ef852ee16ffe1ebc3e9c3 100644 --- a/examples/raspberry_pi_mjpeg_led/device_side.c +++ b/examples/raspberry_pi_mjpeg_led/device_side.c @@ -53,7 +53,8 @@ static void send_mjpg_frame(struct mg_connection *nc, const char *file_path) { /* Send those buffer through the websocket connection */ mg_send_websocket_frame(nc, WEBSOCKET_OP_BINARY, buf, sizeof(buf)); - printf("Sent mjpg frame, %lu bytes after skippping %d frames\n", (unsigned long) sizeof(buf), skipped_frames); + printf("Sent mjpg frame, %lu bytes after skippping %d frames\n", + (unsigned long) sizeof(buf), skipped_frames); skipped_frames = 0; } } @@ -64,8 +65,10 @@ static void send_mjpg_frame(struct mg_connection *nc, const char *file_path) { */ static void set_led(int v) { char cmd[512]; - snprintf(cmd, sizeof(cmd), "for i in 22 23 24; do" - " echo %d >/sys/class/gpio/gpio$i/value; done", v); + snprintf(cmd, sizeof(cmd), + "for i in 22 23 24; do" + " echo %d >/sys/class/gpio/gpio$i/value; done", + v); system(cmd); } @@ -73,7 +76,7 @@ static void set_led(int v) { * Parse control JSON and perform command: * for now only LED on/off is supported. */ -static void perform_control_command(const char* data, size_t len) { +static void perform_control_command(const char *data, size_t len) { struct json_token toks[200], *onoff; parse_json(data, len, toks, sizeof(toks)); onoff = find_json_token(toks, "onoff"); @@ -86,16 +89,16 @@ static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) { switch (ev) { case MG_EV_CONNECT: - printf("Reconnect: %s\n", * (int *) ev_data == 0 ? "ok" : "failed"); - if (* (int *) ev_data == 0) { + printf("Reconnect: %s\n", *(int *) ev_data == 0 ? "ok" : "failed"); + if (*(int *) ev_data == 0) { /* * Tune the tcp send buffer size, so that we can skip frames * when the connection is congested. This helps maintaining a * reasonable latency. */ int sndbuf_size = 512; - if(setsockopt(nc->sock, SOL_SOCKET, SO_SNDBUF, - (void *) &sndbuf_size, sizeof(int)) == -1) { + if (setsockopt(nc->sock, SOL_SOCKET, SO_SNDBUF, (void *) &sndbuf_size, + sizeof(int)) == -1) { perror("failed to tune TCP send buffer size\n"); } @@ -111,7 +114,7 @@ static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) { break; case MG_EV_WEBSOCKET_FRAME: printf("Got control command: [%.*s]\n", (int) wm->size, wm->data); - perform_control_command((const char*)wm->data, wm->size); + perform_control_command((const char *) wm->data, wm->size); break; } } @@ -124,11 +127,13 @@ static void *generate_mjpg_data_thread_func(void *param) { char cmd[400]; (void) param; - snprintf(cmd, sizeof(cmd), "raspistill -w %d -h %d -n -q 100 -tl %d " - "-t 999999999 -v %s -o %s >/dev/null 2>&1", s_width, s_height, - s_still_period, s_vertical_flip ? "-vf" : "", s_mjpg_file); + snprintf(cmd, sizeof(cmd), + "raspistill -w %d -h %d -n -q 100 -tl %d " + "-t 999999999 -v %s -o %s >/dev/null 2>&1", + s_width, s_height, s_still_period, s_vertical_flip ? "-vf" : "", + s_mjpg_file); - for(;;) { + for (;;) { int ret = system(cmd); if (WIFSIGNALED(ret)) exit(1); sleep(1); @@ -152,7 +157,7 @@ int main(int argc, char *argv[]) { mg_mgr_init(&mgr, NULL); - for(;;) { + for (;;) { mg_mgr_poll(&mgr, s_poll_interval_ms); /* Reconnect if disconnected */ diff --git a/examples/settings_panel_for_a_device/settings_panel.c b/examples/settings_panel_for_a_device/settings_panel.c index 26206e246d94a882d448fe7cca703be9c97f7536..3c40d5b088607ea248604b12627b8565e055c6bc 100644 --- a/examples/settings_panel_for_a_device/settings_panel.c +++ b/examples/settings_panel_for_a_device/settings_panel.c @@ -12,7 +12,7 @@ struct device_settings { static const char *s_http_port = "8000"; static struct mg_serve_http_opts s_http_server_opts; -static struct device_settings s_settings = { "value1", "value2" }; +static struct device_settings s_settings = {"value1", "value2"}; static void handle_save(struct mg_connection *nc, struct http_message *hm) { /* Get form variables and store settings values */ @@ -40,9 +40,9 @@ static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) { switch (ev) { case MG_EV_HTTP_REQUEST: if (mg_vcmp(&hm->uri, "/save") == 0) { - handle_save(nc, hm); /* Handle RESTful call */ + handle_save(nc, hm); /* Handle RESTful call */ } else { - mg_serve_http(nc, hm, s_http_server_opts); /* Serve static content */ + mg_serve_http(nc, hm, s_http_server_opts); /* Serve static content */ } break; case MG_EV_SSI_CALL: @@ -63,11 +63,11 @@ int main(int argc, char *argv[]) { mg_set_protocol_http_websocket(nc); s_http_server_opts.document_root = "./web_root"; s_http_server_opts.auth_domain = "example.com"; - //mgr.hexdump_file = "/dev/stdout"; + // mgr.hexdump_file = "/dev/stdout"; /* If our current directory */ if (argc > 0 && (p = strrchr(argv[0], '/'))) { - snprintf(path, sizeof(path), "%.*s/web_root", (int)(p - argv[0]), argv[0]); + snprintf(path, sizeof(path), "%.*s/web_root", (int) (p - argv[0]), argv[0]); s_http_server_opts.document_root = path; } diff --git a/examples/simplest_web_server/simplest_web_server.c b/examples/simplest_web_server/simplest_web_server.c index 73388112ada316424eb93351bf814d46b63e98fb..3a29d1b6d42b619a1a055b1d17e6274ee0142a07 100644 --- a/examples/simplest_web_server/simplest_web_server.c +++ b/examples/simplest_web_server/simplest_web_server.c @@ -21,7 +21,7 @@ int main(void) { // Set up HTTP server parameters mg_set_protocol_http_websocket(nc); - s_http_server_opts.document_root = "."; // Serve current directory + s_http_server_opts.document_root = "."; // Serve current directory s_http_server_opts.dav_document_root = "."; // Allow access via WebDav s_http_server_opts.enable_directory_listing = "yes"; diff --git a/examples/tcp_echo_server/echo_server.c b/examples/tcp_echo_server/echo_server.c index ad16a311d7d7148cb626a06f5e44af863a74d5ff..25098ec9a75173a7316934ffe3ad83782db91882 100644 --- a/examples/tcp_echo_server/echo_server.c +++ b/examples/tcp_echo_server/echo_server.c @@ -25,7 +25,7 @@ static void ev_handler(struct mg_connection *nc, int ev, void *p) { switch (ev) { case MG_EV_RECV: mg_send(nc, io->buf, io->len); // Echo message back - mbuf_remove(io, io->len); // Discard message from recv buffer + mbuf_remove(io, io->len); // Discard message from recv buffer break; default: break; diff --git a/examples/udp_echo_server/echo_server.c b/examples/udp_echo_server/echo_server.c index ddbdd4249fe0d6851fbb2c434e67209c02b76d7d..2cd30b37d2100fa23b170b72ea849e9f16cf3570 100644 --- a/examples/udp_echo_server/echo_server.c +++ b/examples/udp_echo_server/echo_server.c @@ -22,8 +22,8 @@ static void ev_handler(struct mg_connection *nc, int ev, void *p) { (void) p; switch (ev) { case MG_EV_RECV: - mg_send(nc, io->buf, io->len); // Echo message back - mbuf_remove(io, io->len); // Discard message from recv buffer + mg_send(nc, io->buf, io->len); // Echo message back + mbuf_remove(io, io->len); // Discard message from recv buffer // In case of UDP, Mongoose creates new virtual connection for // incoming messages // We can keep it (and it will be reused for another messages from