aboutsummaryrefslogtreecommitdiff
path: root/main/tcp_server.c
diff options
context:
space:
mode:
Diffstat (limited to 'main/tcp_server.c')
-rw-r--r--main/tcp_server.c45
1 files changed, 18 insertions, 27 deletions
diff --git a/main/tcp_server.c b/main/tcp_server.c
index 2ee7e51..8e6b7de 100644
--- a/main/tcp_server.c
+++ b/main/tcp_server.c
@@ -1,9 +1,9 @@
-#include <ctype.h>
-
#include "tcp_server.h"
-#include "sockbuf.h"
+
+#include <ctype.h>
#include "lwip/sockets.h"
+#include "sockbuf.h"
#include "station.h"
static int strcmp_(const char* s1, const char* s2)
@@ -31,8 +31,8 @@ static char* read_token(sockbuf_t* sockbuf, char* into, size_t sz)
while (ch >= 0 && !isspace(ch)) {
if (sz > 1) {
- into[cur++] = (char) ch;
- sz --;
+ into[cur++] = (char)ch;
+ sz--;
}
ch = get_char(sockbuf);
}
@@ -47,10 +47,7 @@ static char* read_token(sockbuf_t* sockbuf, char* into, size_t sz)
return into;
}
-static void handle_int_option(
- const char* attr,
- sockbuf_t* sockbuf,
- int* ptr)
+static void handle_int_option(const char* attr, sockbuf_t* sockbuf, int* ptr)
{
char op_[8];
char buf_[32];
@@ -79,9 +76,7 @@ static void handle_int_option(
}
static void handle_uint8_t_option(
- const char* attr,
- sockbuf_t* sockbuf,
- uint8_t* ptr)
+ const char* attr, sockbuf_t* sockbuf, uint8_t* ptr)
{
int tmp = *ptr;
handle_int_option(attr, sockbuf, &tmp);
@@ -89,19 +84,14 @@ static void handle_uint8_t_option(
}
static void handle_uint32_t_option(
- const char* attr,
- sockbuf_t* sockbuf,
- uint32_t* ptr)
+ const char* attr, sockbuf_t* sockbuf, uint32_t* ptr)
{
int tmp = *ptr;
handle_int_option(attr, sockbuf, &tmp);
*ptr = tmp;
}
-static void handle_bool_option(
- const char* attr,
- sockbuf_t* sockbuf,
- bool* ptr)
+static void handle_bool_option(const char* attr, sockbuf_t* sockbuf, bool* ptr)
{
char buf_[32];
char* op = read_token(sockbuf, buf_, sizeof(buf_));
@@ -128,11 +118,12 @@ static void handle_bool_option(
static void handle_set_cmd(
sockbuf_t* sockbuf, ws_params_t* ws_params, const char* key)
{
- if (false) {}
-
-#define STATE_PARAM(ty, attr, ...) \
- else if (!strcmp_(key, #attr)) { \
- handle_ ## ty ## _option(#attr, sockbuf, &ws_params->state. attr); \
+ if (false) {
+ }
+#define STATE_PARAM(ty, attr, ...) \
+ else if (!strcmp_(key, #attr)) \
+ { \
+ handle_##ty##_option(#attr, sockbuf, &ws_params->state.attr); \
}
#include "state_params.i"
#undef STATE_PARAM
@@ -154,7 +145,7 @@ static void print_uint32_t(sockbuf_t* sockbuf, const char* attr, uint32_t val)
static void print_uint8_t(sockbuf_t* sockbuf, const char* attr, uint8_t val)
{
char buf[128];
- snprintf(buf, sizeof(buf), "%s: %d :: uint8_t\n", attr, (int) val);
+ snprintf(buf, sizeof(buf), "%s: %d :: uint8_t\n", attr, (int)val);
sockbuf_write(sockbuf, buf);
}
@@ -175,7 +166,7 @@ static void print_int(sockbuf_t* sockbuf, const char* attr, int val)
static void handle_print_cmd(sockbuf_t* sockbuf, ws_params_t* ws_params)
{
#define STATE_PARAM(ty, attr, ...) \
- print_ ## ty ( sockbuf, #attr, ws_params->state. attr );
+ print_##ty(sockbuf, #attr, ws_params->state.attr);
#include "state_params.i"
#undef STATE_PARAM
}
@@ -213,7 +204,7 @@ static void run_sockbuf(sockbuf_t* sockbuf, ws_params_t* ws_params)
portTASK_FUNCTION(tcp_server, params)
{
- ws_params_t* ws_params = (ws_params_t*) params;
+ ws_params_t* ws_params = (ws_params_t*)params;
int s = socket(AF_INET, SOCK_STREAM, 0);
struct sockaddr_in addr;