wificfg: quieten some compile type warnings.
This commit is contained in:
parent
61f23d0cf4
commit
876f24556d
2 changed files with 31 additions and 34 deletions
|
|
@ -76,7 +76,7 @@ static int read_crlf_line(int s, char *buf, size_t len)
|
||||||
|
|
||||||
do {
|
do {
|
||||||
char c;
|
char c;
|
||||||
int r = read(s, &c, 1);
|
ssize_t r = read(s, &c, 1);
|
||||||
|
|
||||||
/* Expecting a known terminator so fail on EOF. */
|
/* Expecting a known terminator so fail on EOF. */
|
||||||
if (r <= 0)
|
if (r <= 0)
|
||||||
|
|
@ -101,7 +101,7 @@ static int read_crlf_line(int s, char *buf, size_t len)
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wificfg_form_name_value(int s, bool *valp, size_t *rem, char *buf, size_t len)
|
ssize_t wificfg_form_name_value(int s, bool *valp, size_t *rem, char *buf, size_t len)
|
||||||
{
|
{
|
||||||
size_t num = 0;
|
size_t num = 0;
|
||||||
|
|
||||||
|
|
@ -110,7 +110,7 @@ int wificfg_form_name_value(int s, bool *valp, size_t *rem, char *buf, size_t le
|
||||||
break;
|
break;
|
||||||
|
|
||||||
char c;
|
char c;
|
||||||
int r = read(s, &c, 1);
|
ssize_t r = read(s, &c, 1);
|
||||||
|
|
||||||
/* Expecting a known number of characters so fail on EOF. */
|
/* Expecting a known number of characters so fail on EOF. */
|
||||||
if (r <= 0) return -1;
|
if (r <= 0) return -1;
|
||||||
|
|
@ -243,7 +243,7 @@ static const struct {
|
||||||
|
|
||||||
static wificfg_method intern_http_method(char *str)
|
static wificfg_method intern_http_method(char *str)
|
||||||
{
|
{
|
||||||
int i;
|
size_t i;
|
||||||
for (i = 0; i < sizeof(method_table) / sizeof(method_table[0]); i++) {
|
for (i = 0; i < sizeof(method_table) / sizeof(method_table[0]); i++) {
|
||||||
if (!strcmp(str, method_table[i].str))
|
if (!strcmp(str, method_table[i].str))
|
||||||
return method_table[i].method;
|
return method_table[i].method;
|
||||||
|
|
@ -274,7 +274,7 @@ static const struct {
|
||||||
|
|
||||||
static http_header intern_http_header(char *str)
|
static http_header intern_http_header(char *str)
|
||||||
{
|
{
|
||||||
int i;
|
size_t i;
|
||||||
for (i = 0; i < sizeof(http_header_table) / sizeof(http_header_table[0]); i++) {
|
for (i = 0; i < sizeof(http_header_table) / sizeof(http_header_table[0]); i++) {
|
||||||
if (!strcmp(str, http_header_table[i].str))
|
if (!strcmp(str, http_header_table[i].str))
|
||||||
return http_header_table[i].name;
|
return http_header_table[i].name;
|
||||||
|
|
@ -292,7 +292,7 @@ static const struct {
|
||||||
|
|
||||||
static wificfg_content_type intern_http_content_type(char *str)
|
static wificfg_content_type intern_http_content_type(char *str)
|
||||||
{
|
{
|
||||||
int i;
|
size_t i;
|
||||||
for (i = 0; i < sizeof(content_type_table) / sizeof(content_type_table[0]); i++) {
|
for (i = 0; i < sizeof(content_type_table) / sizeof(content_type_table[0]); i++) {
|
||||||
if (!strcmp(str, content_type_table[i].str))
|
if (!strcmp(str, content_type_table[i].str))
|
||||||
return content_type_table[i].type;
|
return content_type_table[i].type;
|
||||||
|
|
@ -318,13 +318,13 @@ static char *skip_to_whitespace(char *string)
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wificfg_write_string(int s, const char *str)
|
ssize_t wificfg_write_string(int s, const char *str)
|
||||||
{
|
{
|
||||||
int res = write(s, str, strlen(str));
|
ssize_t res = write(s, str, strlen(str));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wificfg_write_string_chunk(int s, const char *str, char *buf, size_t len)
|
ssize_t wificfg_write_string_chunk(int s, const char *str, char *buf, size_t len)
|
||||||
{
|
{
|
||||||
size_t str_len = strlen(str);
|
size_t str_len = strlen(str);
|
||||||
|
|
||||||
|
|
@ -366,7 +366,7 @@ int wificfg_write_string_chunk(int s, const char *str, char *buf, size_t len)
|
||||||
/* Else too big for the buffer. */
|
/* Else too big for the buffer. */
|
||||||
char size_buf[8];
|
char size_buf[8];
|
||||||
size_t size_len = snprintf(size_buf, sizeof(size_buf), "%x\r\n", str_len);
|
size_t size_len = snprintf(size_buf, sizeof(size_buf), "%x\r\n", str_len);
|
||||||
int res = write(s, size_buf, size_len);
|
ssize_t res = write(s, size_buf, size_len);
|
||||||
if (res != size_len) {
|
if (res != size_len) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
@ -377,7 +377,7 @@ int wificfg_write_string_chunk(int s, const char *str, char *buf, size_t len)
|
||||||
return write(s, size_buf + size_len - 2, 2);
|
return write(s, size_buf + size_len - 2, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
int wificfg_write_chunk_end(int s)
|
ssize_t wificfg_write_chunk_end(int s)
|
||||||
{
|
{
|
||||||
return wificfg_write_string(s, "0\r\n\r\n");
|
return wificfg_write_string(s, "0\r\n\r\n");
|
||||||
}
|
}
|
||||||
|
|
@ -448,12 +448,12 @@ static const struct {
|
||||||
|
|
||||||
static form_name intern_form_name(char *str)
|
static form_name intern_form_name(char *str)
|
||||||
{
|
{
|
||||||
int i;
|
size_t i;
|
||||||
for (i = 0; i < sizeof(form_name_table) / sizeof(form_name_table[0]); i++) {
|
for (i = 0; i < sizeof(form_name_table) / sizeof(form_name_table[0]); i++) {
|
||||||
if (!strcmp(str, form_name_table[i].str))
|
if (!strcmp(str, form_name_table[i].str))
|
||||||
return form_name_table[i].name;
|
return form_name_table[i].name;
|
||||||
}
|
}
|
||||||
return FORM_NAME_NONE;
|
return FORM_NAME_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -838,7 +838,7 @@ static int handle_wificfg_index_post(int s, wificfg_method method,
|
||||||
bool valp = false;
|
bool valp = false;
|
||||||
|
|
||||||
while (rem > 0) {
|
while (rem > 0) {
|
||||||
int r = wificfg_form_name_value(s, &valp, &rem, buf, len);
|
ssize_t r = wificfg_form_name_value(s, &valp, &rem, buf, len);
|
||||||
|
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
break;
|
break;
|
||||||
|
|
@ -849,7 +849,7 @@ static int handle_wificfg_index_post(int s, wificfg_method method,
|
||||||
form_name name = intern_form_name(buf);
|
form_name name = intern_form_name(buf);
|
||||||
|
|
||||||
if (valp) {
|
if (valp) {
|
||||||
int r = wificfg_form_name_value(s, NULL, &rem, buf, len);
|
ssize_t r = wificfg_form_name_value(s, NULL, &rem, buf, len);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -1230,7 +1230,7 @@ static int handle_wifi_ap_post(int s, wificfg_method method,
|
||||||
uint8_t dns_enable = 0;
|
uint8_t dns_enable = 0;
|
||||||
|
|
||||||
while (rem > 0) {
|
while (rem > 0) {
|
||||||
int r = wificfg_form_name_value(s, &valp, &rem, buf, len);
|
ssize_t r = wificfg_form_name_value(s, &valp, &rem, buf, len);
|
||||||
|
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
break;
|
break;
|
||||||
|
|
@ -1241,7 +1241,7 @@ static int handle_wifi_ap_post(int s, wificfg_method method,
|
||||||
form_name name = intern_form_name(buf);
|
form_name name = intern_form_name(buf);
|
||||||
|
|
||||||
if (valp) {
|
if (valp) {
|
||||||
int r = wificfg_form_name_value(s, NULL, &rem, buf, len);
|
ssize_t r = wificfg_form_name_value(s, NULL, &rem, buf, len);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -1281,19 +1281,19 @@ static int handle_wifi_ap_post(int s, wificfg_method method,
|
||||||
}
|
}
|
||||||
case FORM_NAME_AP_AUTHMODE: {
|
case FORM_NAME_AP_AUTHMODE: {
|
||||||
uint32_t mode = strtoul(buf, NULL, 10);
|
uint32_t mode = strtoul(buf, NULL, 10);
|
||||||
if (mode >= 0 && mode <= 5)
|
if (mode <= 5)
|
||||||
sysparam_set_int8("wifi_ap_authmode", mode);
|
sysparam_set_int8("wifi_ap_authmode", mode);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FORM_NAME_AP_MAX_CONN: {
|
case FORM_NAME_AP_MAX_CONN: {
|
||||||
uint32_t max_conn = strtoul(buf, NULL, 10);
|
uint32_t max_conn = strtoul(buf, NULL, 10);
|
||||||
if (max_conn >= 0 && max_conn <= 8)
|
if (max_conn <= 8)
|
||||||
sysparam_set_int8("wifi_ap_max_conn", max_conn);
|
sysparam_set_int8("wifi_ap_max_conn", max_conn);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FORM_NAME_AP_BEACON_INTERVAL: {
|
case FORM_NAME_AP_BEACON_INTERVAL: {
|
||||||
uint32_t interval = strtoul(buf, NULL, 10);
|
uint32_t interval = strtoul(buf, NULL, 10);
|
||||||
if (interval >= 0 && interval <= 10000)
|
if (interval <= 10000)
|
||||||
sysparam_set_int32("wifi_ap_beacon_interval", interval);
|
sysparam_set_int32("wifi_ap_beacon_interval", interval);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -1305,7 +1305,7 @@ static int handle_wifi_ap_post(int s, wificfg_method method,
|
||||||
break;
|
break;
|
||||||
case FORM_NAME_AP_DHCP_LEASES: {
|
case FORM_NAME_AP_DHCP_LEASES: {
|
||||||
uint32_t leases = strtoul(buf, NULL, 10);
|
uint32_t leases = strtoul(buf, NULL, 10);
|
||||||
if (leases >= 0 && leases <= 16)
|
if (leases <= 16)
|
||||||
sysparam_set_int8("wifi_ap_dhcp_leases", leases);
|
sysparam_set_int8("wifi_ap_dhcp_leases", leases);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -1851,7 +1851,7 @@ static void server_task(void *pvParameters)
|
||||||
size_t len;
|
size_t len;
|
||||||
for (len = 0; len < 4096; len++) {
|
for (len = 0; len < 4096; len++) {
|
||||||
char c;
|
char c;
|
||||||
int res = read(s, &c, 1);
|
ssize_t res = read(s, &c, 1);
|
||||||
if (res != 1) break;
|
if (res != 1) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1912,7 +1912,7 @@ static void dns_task(void *pvParameters)
|
||||||
char buffer[96];
|
char buffer[96];
|
||||||
struct sockaddr_storage src_addr;
|
struct sockaddr_storage src_addr;
|
||||||
socklen_t src_addr_len = sizeof(src_addr);
|
socklen_t src_addr_len = sizeof(src_addr);
|
||||||
size_t count = recvfrom(fd, buffer, sizeof(buffer), 0, (struct sockaddr*)&src_addr, &src_addr_len);
|
ssize_t count = recvfrom(fd, buffer, sizeof(buffer), 0, (struct sockaddr*)&src_addr, &src_addr_len);
|
||||||
|
|
||||||
/* Drop messages that are too large to send a response in the buffer */
|
/* Drop messages that are too large to send a response in the buffer */
|
||||||
if (count > 0 && count <= sizeof(buffer) - 16) {
|
if (count > 0 && count <= sizeof(buffer) - 16) {
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,7 @@ void wificfg_init(uint32_t port, const wificfg_dispatch *dispatch);
|
||||||
* is truncated to the buffer length. The number of characters read is limited
|
* is truncated to the buffer length. The number of characters read is limited
|
||||||
* to the remainder which is updated. The 'valp' flag is set if a value follows.
|
* to the remainder which is updated. The 'valp' flag is set if a value follows.
|
||||||
*/
|
*/
|
||||||
int wificfg_form_name_value(int s, bool *valp, size_t *rem, char *buf, size_t len);
|
ssize_t wificfg_form_name_value(int s, bool *valp, size_t *rem, char *buf, size_t len);
|
||||||
|
|
||||||
/* Support for form url-encoding decoder. */
|
/* Support for form url-encoding decoder. */
|
||||||
void wificfg_form_url_decode(char *string);
|
void wificfg_form_url_decode(char *string);
|
||||||
|
|
@ -106,20 +106,17 @@ void wificfg_form_url_decode(char *string);
|
||||||
void wificfg_html_escape(char *string, char *buf, size_t len);
|
void wificfg_html_escape(char *string, char *buf, size_t len);
|
||||||
|
|
||||||
/* Support for writing a string in a response. */
|
/* Support for writing a string in a response. */
|
||||||
int wificfg_write_string(int s, const char *str);
|
ssize_t wificfg_write_string(int s, const char *str);
|
||||||
|
|
||||||
/* Support for writing a string in a response, with chunk transfer encoding.
|
/* Support for writing a string in a response, with chunk transfer encoding.
|
||||||
* An optional buffer may be supplied to use to construct a chunk with the
|
* An optional buffer may be supplied to use to construct a chunk with the
|
||||||
* header and trailer, reducing the number of write() calls, and the str may be
|
* header and trailer, reducing the number of write() calls, and the str may be
|
||||||
* at the start of this buffer.
|
* at the start of this buffer.
|
||||||
*/
|
*/
|
||||||
int wificfg_write_string_chunk(int s, const char *str, char *buf, size_t len);
|
ssize_t wificfg_write_string_chunk(int s, const char *str, char *buf, size_t len);
|
||||||
|
|
||||||
/* Write a chunk transfer encoding end marker. */
|
/* Write a chunk transfer encoding end marker. */
|
||||||
int wificfg_write_chunk_end(int s);
|
ssize_t wificfg_write_chunk_end(int s);
|
||||||
|
|
||||||
/* Write a chunk offset 4 bytes into the buffer. */
|
|
||||||
int wificfg_write_buffer_chunk(int s, char *buf);
|
|
||||||
|
|
||||||
/* Write a html title meta data, using the hostname or AP SSI. */
|
/* Write a html title meta data, using the hostname or AP SSI. */
|
||||||
int wificfg_write_html_title(int s, char *buf, size_t len, const char *str);
|
int wificfg_write_html_title(int s, char *buf, size_t len, const char *str);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue