netutils/thttpd/thttpd.c: Appease nxstyle

The following nxstyle errors are intentionally left.
The first one is in the copyright notice.
The others are identifiers like ClientData etc.

netutils/thttpd/thttpd.c:10:81: error: Long line found
netutils/thttpd/thttpd.c:99:2: error: Mixed case identifier found
netutils/thttpd/thttpd.c💯2: error: Mixed case identifier found
netutils/thttpd/thttpd.c:131:17: error: Mixed case identifier found
netutils/thttpd/thttpd.c:131:57: error: Mixed case identifier found
netutils/thttpd/thttpd.c:132:36: error: Mixed case identifier found
netutils/thttpd/thttpd.c:133:52: error: Mixed case identifier found
netutils/thttpd/thttpd.c:134:23: error: Mixed case identifier found
netutils/thttpd/thttpd.c:134:63: error: Mixed case identifier found
netutils/thttpd/thttpd.c:527:2: error: Mixed case identifier found
netutils/thttpd/thttpd.c:597:17: error: Mixed case identifier found
netutils/thttpd/thttpd.c:597:57: error: Mixed case identifier found
netutils/thttpd/thttpd.c:608:14: error: Mixed case identifier found
netutils/thttpd/thttpd.c:615:38: error: Mixed case identifier found
netutils/thttpd/thttpd.c:620:14: error: Mixed case identifier found
netutils/thttpd/thttpd.c:625:37: error: Mixed case identifier found
netutils/thttpd/thttpd.c:632:36: error: Mixed case identifier found
netutils/thttpd/thttpd.c:633:52: error: Mixed case identifier found
netutils/thttpd/thttpd.c:643:23: error: Mixed case identifier found
netutils/thttpd/thttpd.c:643:63: error: Mixed case identifier found
netutils/thttpd/thttpd.c:730:35: error: Mixed case identifier found
netutils/thttpd/thttpd.c:739:29: error: Mixed case identifier found
This commit is contained in:
YAMAMOTO Takashi 2020-11-26 19:58:33 +09:00 committed by Xiang Xiao
parent 92843ede9d
commit c04f59cb2e

View File

@ -129,7 +129,8 @@ static void finish_connection(struct connect_s *conn, struct timeval *tv);
static void clear_connection(struct connect_s *conn, struct timeval *tv); static void clear_connection(struct connect_s *conn, struct timeval *tv);
static void really_clear_connection(struct connect_s *conn); static void really_clear_connection(struct connect_s *conn);
static void idle(ClientData client_data, struct timeval *nowP); static void idle(ClientData client_data, struct timeval *nowP);
static void linger_clear_connection(ClientData client_data, struct timeval *nowP); static void linger_clear_connection(ClientData client_data,
struct timeval *nowP);
static void occasional(ClientData client_data, struct timeval *nowP); static void occasional(ClientData client_data, struct timeval *nowP);
/**************************************************************************** /****************************************************************************
@ -163,6 +164,7 @@ static void shut_down(void)
{ {
fdwatch_del_fd(fw, ths->listen_fd); fdwatch_del_fd(fw, ths->listen_fd);
} }
httpd_terminate(ths); httpd_terminate(ths);
} }
@ -179,7 +181,7 @@ static int handle_newconnect(FAR struct timeval *tv, int listen_fd)
*/ */
ninfo("New connection(s) on listen_fd %d\n", listen_fd); ninfo("New connection(s) on listen_fd %d\n", listen_fd);
for (;;) for (; ; )
{ {
/* Get the next free connection from the free list */ /* Get the next free connection from the free list */
@ -269,12 +271,15 @@ static void handle_read(struct connect_s *conn, struct timeval *tv)
BADREQUEST("MAXREALLOC"); BADREQUEST("MAXREALLOC");
goto errout_with_400; goto errout_with_400;
} }
httpd_realloc_str(&hc->read_buf, &hc->read_size, hc->read_size + CONFIG_THTTPD_REALLOCINCR);
httpd_realloc_str(&hc->read_buf, &hc->read_size,
hc->read_size + CONFIG_THTTPD_REALLOCINCR);
} }
/* Read some more bytes */ /* Read some more bytes */
sz = read(hc->conn_fd, &(hc->read_buf[hc->read_idx]), hc->read_size - hc->read_idx); sz = read(hc->conn_fd, &(hc->read_buf[hc->read_idx]),
hc->read_size - hc->read_idx);
if (sz == 0) if (sz == 0)
{ {
BADREQUEST("EOF"); BADREQUEST("EOF");
@ -414,6 +419,7 @@ static inline int read_buffer(struct connect_s *conn)
hc->buflen += nread; hc->buflen += nread;
} }
} }
return nread; return nread;
} }
@ -438,6 +444,7 @@ static void handle_send(struct connect_s *conn, struct timeval *tv)
nerr("ERROR: File read error: %d\n", errno); nerr("ERROR: File read error: %d\n", errno);
goto errout_clear_connection; goto errout_clear_connection;
} }
ninfo("Read %d bytes, buflen %d\n", nread, hc->buflen); ninfo("Read %d bytes, buflen %d\n", nread, hc->buflen);
/* Send the buffer */ /* Send the buffer */
@ -552,7 +559,8 @@ static void clear_connection(struct connect_s *conn, struct timeval *tv)
fdwatch_add_fd(fw, conn->hc->conn_fd, conn); fdwatch_add_fd(fw, conn->hc->conn_fd, conn);
client_data.p = conn; client_data.p = conn;
conn->linger_timer = tmr_create(tv, linger_clear_connection, client_data, conn->linger_timer = tmr_create(tv, linger_clear_connection,
client_data,
CONFIG_THTTPD_LINGER_MSEC, 0); CONFIG_THTTPD_LINGER_MSEC, 0);
if (conn->linger_timer != NULL) if (conn->linger_timer != NULL)
{ {
@ -562,7 +570,9 @@ static void clear_connection(struct connect_s *conn, struct timeval *tv)
nerr("ERROR: tmr_create(linger_clear_connection) failed\n"); nerr("ERROR: tmr_create(linger_clear_connection) failed\n");
} }
/* Either we are done lingering, we shouldn't linger, or we failed to setup the linger */ /* Either we are done lingering, we shouldn't linger, or we failed to
* setup the linger
*/
really_clear_connection(conn); really_clear_connection(conn);
} }
@ -595,7 +605,8 @@ static void idle(ClientData client_data, struct timeval *nowP)
switch (conn->conn_state) switch (conn->conn_state)
{ {
case CNST_READING: case CNST_READING:
if (nowP->tv_sec - conn->active_at >= CONFIG_THTTPD_IDLE_READ_LIMIT_SEC) if (nowP->tv_sec - conn->active_at >=
CONFIG_THTTPD_IDLE_READ_LIMIT_SEC)
{ {
nerr("ERROR: %s connection timed out reading\n", nerr("ERROR: %s connection timed out reading\n",
httpd_ntoa(&conn->hc->client_addr)); httpd_ntoa(&conn->hc->client_addr));
@ -606,7 +617,8 @@ static void idle(ClientData client_data, struct timeval *nowP)
break; break;
case CNST_SENDING: case CNST_SENDING:
if (nowP->tv_sec - conn->active_at >= CONFIG_THTTPD_IDLE_SEND_LIMIT_SEC) if (nowP->tv_sec - conn->active_at >=
CONFIG_THTTPD_IDLE_SEND_LIMIT_SEC)
{ {
nerr("ERROR: %s connection timed out sending\n", nerr("ERROR: %s connection timed out sending\n",
httpd_ntoa(&conn->hc->client_addr)); httpd_ntoa(&conn->hc->client_addr));
@ -617,7 +629,8 @@ static void idle(ClientData client_data, struct timeval *nowP)
} }
} }
static void linger_clear_connection(ClientData client_data, struct timeval *nowP) static void linger_clear_connection(ClientData client_data,
struct timeval *nowP)
{ {
struct connect_s *conn; struct connect_s *conn;
@ -714,7 +727,8 @@ int thttpd_main(int argc, char **argv)
/* Set up the occasional timer */ /* Set up the occasional timer */
if (tmr_create(NULL, occasional, JunkClientData, CONFIG_THTTPD_OCCASIONAL_MSEC * 1000L, 1) == NULL) if (tmr_create(NULL, occasional, JunkClientData,
CONFIG_THTTPD_OCCASIONAL_MSEC * 1000L, 1) == NULL)
{ {
nerr("ERROR: tmr_create(occasional) failed\n"); nerr("ERROR: tmr_create(occasional) failed\n");
exit(1); exit(1);
@ -726,7 +740,6 @@ int thttpd_main(int argc, char **argv)
{ {
nerr("ERROR: tmr_create(idle) failed\n"); nerr("ERROR: tmr_create(idle) failed\n");
exit(1); exit(1);
} }
/* Initialize our connections table */ /* Initialize our connections table */
@ -745,7 +758,7 @@ int thttpd_main(int argc, char **argv)
connects[cnum].hc = NULL; connects[cnum].hc = NULL;
} }
connects[AVAILABLE_FDS-1].next = NULL; /* End of link list */ connects[AVAILABLE_FDS - 1].next = NULL; /* End of link list */
free_connections = connects; /* Beginning of the link list */ free_connections = connects; /* Beginning of the link list */
if (hs != NULL) if (hs != NULL)
@ -760,7 +773,7 @@ int thttpd_main(int argc, char **argv)
ninfo("Entering the main loop\n"); ninfo("Entering the main loop\n");
gettimeofday(&tv, NULL); gettimeofday(&tv, NULL);
for (;;) for (; ; )
{ {
/* Do the fd watch */ /* Do the fd watch */
@ -805,7 +818,8 @@ int thttpd_main(int argc, char **argv)
/* Find the connections that need servicing */ /* Find the connections that need servicing */
while ((conn = (struct connect_s*)fdwatch_get_next_client_data(fw)) != (struct connect_s*)-1) while ((conn = (struct connect_s *)fdwatch_get_next_client_data(fw))
!= (struct connect_s *)-1)
{ {
if (conn) if (conn)
{ {
@ -819,8 +833,9 @@ int thttpd_main(int argc, char **argv)
{ {
handle_read(conn, &tv); handle_read(conn, &tv);
/* If a GET request was received and a file is ready to /* If a GET request was received and a file is
* be sent, then fall through to send the file. * ready to be sent, then fall through to send
* the file.
*/ */
if (conn->conn_state != CNST_SENDING) if (conn->conn_state != CNST_SENDING)
@ -831,9 +846,9 @@ int thttpd_main(int argc, char **argv)
case CNST_SENDING: case CNST_SENDING:
{ {
/* Send a file -- this really should be performed on a /* Send a file -- this really should be performed
* separate thread to keep the serve from locking up during * on a separate thread to keep the serve from
* the write. * locking up during the write.
*/ */
handle_send(conn, &tv); handle_send(conn, &tv);
@ -851,6 +866,7 @@ int thttpd_main(int argc, char **argv)
} }
} }
} }
tmr_run(&tv); tmr_run(&tv);
} }