fix EOL whitespace

This commit is contained in:
Richard Harman
2022-05-29 09:32:47 -04:00
parent fdbf665cfc
commit f156c5fecd
50 changed files with 387 additions and 387 deletions

View File

@ -73,7 +73,7 @@ template_t g_templates [] = {
int g_total_templates = sizeof(g_templates)/sizeof(g_templates[0]);
unsigned char hexdigit( char hex ) {
return (hex <= '9') ? hex - '0' :
return (hex <= '9') ? hex - '0' :
toupper((unsigned char)hex) - 'A' + 10 ;
}
@ -333,7 +333,7 @@ int http_fn_cfg_mqtt(http_request_t *request) {
poststr(request,"<form action=\"/cfg_mqtt_set\">\
<label for=\"host\">Host:</label><br>\
<input type=\"text\" id=\"host\" name=\"host\" value=\"");
poststr(request,CFG_GetMQTTHost());
poststr(request,"\"><br>\
<label for=\"port\">Port:</label><br>\
@ -343,7 +343,7 @@ int http_fn_cfg_mqtt(http_request_t *request) {
poststr(request,"\"><br><br>\
<label for=\"port\">Client:</label><br>\
<input type=\"text\" id=\"client\" name=\"client\" value=\"");
poststr(request,CFG_GetMQTTBrokerName());
poststr(request,"\"><br>\
<label for=\"user\">User:</label><br>\
@ -388,7 +388,7 @@ int http_fn_cfg_mqtt_set(http_request_t *request) {
CFG_Save_SetupTimer();
poststr(request,"Please wait for module to connect... if there is problem, restart it from Index html page...");
poststr(request,"<br>");
poststr(request,"<a href=\"cfg_mqtt\">Return to MQTT settings</a>");
poststr(request,"<br>");
@ -410,7 +410,7 @@ int http_fn_cfg_webapp(http_request_t *request) {
poststr(request,"<h2> Use this to set the URL of the Webapp</h2>");
poststr(request,"<form action=\"/cfg_webapp_set\">\
<label for=\"url\">Url:</label><br>\
<input type=\"text\" id=\"url\" name=\"url\" value=\"");
<input type=\"text\" id=\"url\" name=\"url\" value=\"");
poststr(request,CFG_GetWebappRoot());
poststr(request,"\"><br>\
<input type=\"submit\" value=\"Submit\">\
@ -437,7 +437,7 @@ int http_fn_cfg_webapp_set(http_request_t *request) {
} else {
poststr(request,"Webapp url not set because you didn't specify the argument.");
}
poststr(request,"<br>");
poststr(request,htmlReturnToCfg);
HTTP_AddBuildFooter(request);
@ -502,7 +502,7 @@ int http_fn_cfg_ping(http_request_t *request) {
<input type=\"text\" id=\"host\" name=\"host\" value=\"");
tmp = CFG_GetPingHost();
poststr(request,tmp);
/* poststr(request, "\"><br>\
<label for=\"pass\">Interval (s) between pings:</label><br>\
<input type=\"number\" id=\"interval\" name=\"interval\" value=\"");
@ -514,7 +514,7 @@ int http_fn_cfg_ping(http_request_t *request) {
<input type=\"number\" id=\"disconnectTime\" name=\"disconnectTime\" value=\"");
i = CFG_GetPingDisconnectedSecondsToRestart();
hprintf128(request,"%i",i);
poststr(request,"\"><br><br>\
<input type=\"submit\" value=\"Submit\" onclick=\"return confirm('Are you sure?')\">\
</form> ");
@ -562,7 +562,7 @@ int http_fn_cfg_wifi(http_request_t *request) {
AP_IF_S *ar;
uint32_t num;
bk_printf("Scan begin...\r\n");
tuya_hal_wifi_all_ap_scan(&ar,&num);
bk_printf("Scan returned %i networks\r\n",num);
@ -603,13 +603,13 @@ int http_fn_cfg_wifi(http_request_t *request) {
<input type=\"text\" id=\"ssid\" name=\"ssid\" value=\"");
cur_ssid = CFG_GetWiFiSSID();
poststr(request,cur_ssid);
poststr(request, "\"><br>\
<label for=\"pass\">Pass:</label><br>\
<input type=\"text\" id=\"pass\" name=\"pass\" value=\"");
cur_pass = CFG_GetWiFiPass();
poststr(request,cur_pass);
poststr(request,"\"><br><br>\
<input type=\"submit\" value=\"Submit\" onclick=\"return confirm('Are you sure? Please check SSID and pass twice?')\">\
</form> ");
@ -629,7 +629,7 @@ int http_fn_cfg_name(http_request_t *request) {
http_setup(request, httpMimeTypeHTML);
poststr(request,htmlHeader);
poststr(request,g_header);
poststr(request,"<h2> Change device names for display. </h2> Remember that short name is used by MQTT.<br>");
if(http_getArg(request->url,"shortName",tmpA,sizeof(tmpA))) {
CFG_SetShortDeviceName(tmpA);
@ -643,13 +643,13 @@ int http_fn_cfg_name(http_request_t *request) {
<input type=\"text\" id=\"shortName\" name=\"shortName\" value=\"");
shortName = CFG_GetShortDeviceName();
poststr(request,shortName);
poststr(request, "\"><br>\
<label for=\"name\">Full Name:</label><br>\
<input type=\"text\" id=\"name\" name=\"name\" value=\"");
name = CFG_GetDeviceName();
poststr(request,name);
poststr(request,"\"><br><br>\
<input type=\"submit\" value=\"Submit\" onclick=\"return confirm('Are you sure? Short name might be used by MQTT, so you will have to reconfig some stuff.')\">\
</form> ");
@ -684,14 +684,14 @@ int http_fn_cfg_wifi_set(http_request_t *request) {
poststr(request,"Please wait for module to reset...");
RESET_ScheduleModuleReset(3);
poststr(request,"<br>");
poststr(request,"<a href=\"cfg_wifi\">Return to WiFi settings</a>");
poststr(request,"<br>");
poststr(request,htmlReturnToCfg);
HTTP_AddBuildFooter(request);
poststr(request,htmlEnd);
poststr(request, NULL);
return 0;
}
@ -712,7 +712,7 @@ int http_fn_cfg_loglevel_set(http_request_t *request) {
loglevel = atoi(tmpA);
#endif
poststr(request,"LOG level changed.");
}
}
poststr(request,"<form action=\"/cfg_loglevel_set\">\
<label for=\"loglevel\">loglevel:</label><br>\
<input type=\"text\" id=\"loglevel\" name=\"loglevel\" value=\"");
@ -724,7 +724,7 @@ int http_fn_cfg_loglevel_set(http_request_t *request) {
poststr(request,"\"><br><br>\
<input type=\"submit\" value=\"Submit\" >\
</form> ");
poststr(request,"<br>");
poststr(request,"<a href=\"cfg\">Return to config settings</a>");
poststr(request,"<br>");
@ -848,7 +848,7 @@ int http_fn_flash_read_tool(http_request_t *request) {
poststr(request,"<br>");
}
poststr(request,"<form action=\"/flash_read_tool\">");
poststr(request,"<input type=\"checkbox\" id=\"hex\" name=\"hex\" value=\"1\"");
if(hex){
poststr(request," checked");
@ -935,7 +935,7 @@ int http_fn_startup_command(http_request_t *request) {
cmd = CFG_GetShortStartupCommand();
poststr(request,"<form action=\"/startup_command\">");
poststr(request,"<label for=\"data\">Startup command:</label><br>\
<input type=\"text\" id=\"data\" name=\"data\"");
hprintf128(request," value=\"%s\" size=\"120\"><br>",cmd);
@ -988,7 +988,7 @@ int http_fn_uart_tool(http_request_t *request) {
}
poststr(request,"<form action=\"/uart_tool\">");
poststr(request,"<label for=\"data\">data:</label><br>\
<input type=\"text\" id=\"data\" name=\"data\"");
hprintf128(request," value=\"%s\" size=\"40\"><br>",tmpA);
@ -1029,20 +1029,20 @@ int http_fn_cfg_quick(http_request_t *request) {
poststr(request,htmlHeader);
poststr(request,g_header);
poststr(request,"<h4>Quick Config</h4>");
if(http_getArg(request->url,"dev",tmpA,sizeof(tmpA))) {
j = atoi(tmpA);
hprintf128(request,"<h3>Set dev %i!</h3>",j);
g_templates[j].setter();
}
poststr(request,"<form action=\"cfg_quick\">");
poststr(request,"<form action=\"cfg_quick\">");
poststr(request, "<select name=\"dev\">");
for(j = 0; j < g_total_templates; j++) {
hprintf128(request, "<option value=\"%i\">%s</option>",j,g_templates[j].name);
}
poststr(request,"</select>");
poststr(request,"<input type=\"submit\" value=\"Set\"/></form>");
poststr(request,htmlReturnToCfg);
HTTP_AddBuildFooter(request);
poststr(request,htmlEnd);
@ -1068,7 +1068,7 @@ int http_fn_cfg_ha(http_request_t *request) {
poststr(request,"<h4>Paste this to configuration yaml</h4>");
poststr(request,"<h5>Make sure that you have \"switch:\" keyword only once! Home Assistant doesn't like dup keywords.</h5>");
poststr(request,"<h5>You can also use \"switch MyDeviceName:\" to avoid keyword duplication!</h5>");
poststr(request,"<textarea rows=\"40\" cols=\"50\">");
for(i = 0; i < PLATFORM_GPIO_MAX; i++) {
@ -1139,7 +1139,7 @@ http://<ip>/cm?user=admin&password=joker&cmnd=Power%20Toggle
// System responds with state
int http_fn_cm(http_request_t *request) {
char tmpA[128];
http_setup(request, httpMimeTypeJson);
if( http_getArg(request->url,"cmnd",tmpA,sizeof(tmpA))) {
CMD_ExecuteCommand(tmpA,COMMAND_FLAG_SOURCE_HTTP);
@ -1303,8 +1303,8 @@ int http_fn_cfg_pins(http_request_t *request) {
}
poststr(request, "</select>");
hprintf128(request, "<input name=\"r%i\" type=\"text\" value=\"%i\"/>",i,ch);
if(si == IOR_Button || si == IOR_Button_n)
if(si == IOR_Button || si == IOR_Button_n)
{
// extra param. For button, is relay index to toggle on double click
hprintf128(request, "<input name=\"e%i\" type=\"text\" value=\"%i\"/>",i,ch2);

View File

@ -28,8 +28,8 @@ void HTTPServer_Start()
{
OSStatus err = kNoErr;
err = rtos_create_thread( &g_http_thread, BEKEN_APPLICATION_PRIORITY,
"TCP_server",
err = rtos_create_thread( &g_http_thread, BEKEN_APPLICATION_PRIORITY,
"TCP_server",
(beken_thread_function_t)tcp_server_thread,
0x800,
(beken_thread_arg_t)0 );
@ -51,7 +51,7 @@ static void tcp_client_thread( beken_thread_arg_t arg )
{
OSStatus err = kNoErr;
int fd = (int) arg;
//fd_set readfds, errfds, readfds2;
//fd_set readfds, errfds, readfds2;
char *buf = NULL;
char *reply = NULL;
int replyBufferSize = 10000;
@ -62,7 +62,7 @@ static void tcp_client_thread( beken_thread_arg_t arg )
reply = (char*) os_malloc( replyBufferSize );
buf = (char*) os_malloc( 1026 );
if ( buf == 0 || reply == 0)
{
ADDLOG_ERROR(LOG_FEATURE_HTTP, "TCP Client failed to malloc buffer" );
@ -101,12 +101,12 @@ static void tcp_client_thread( beken_thread_arg_t arg )
rtos_delay_milliseconds(10);
exit:
if ( err != kNoErr )
if ( err != kNoErr )
ADDLOG_ERROR(LOG_FEATURE_HTTP, "TCP client thread exit with err: %d", err );
if ( buf != NULL )
if ( buf != NULL )
os_free( buf );
if ( reply != NULL )
if ( reply != NULL )
os_free( reply );
lwip_close( fd );;
@ -134,9 +134,9 @@ static void tcp_server_thread( beken_thread_arg_t arg )
server_addr.sin_addr.s_addr = INADDR_ANY;/* Accept conenction request on all network interface */
server_addr.sin_port = htons( HTTP_SERVER_PORT );/* Server listen on port: 20000 */
err = bind( tcp_listen_fd, (struct sockaddr *) &server_addr, sizeof(server_addr) );
err = listen( tcp_listen_fd, 0 );
while ( 1 )
{
FD_ZERO( &readfds );
@ -164,7 +164,7 @@ static void tcp_server_thread( beken_thread_arg_t arg )
tcp_client_thread((beken_thread_arg_t)client_fd);
#else
// Create separate thread for client
if ( kNoErr !=
if ( kNoErr !=
#if PLATFORM_XR809
OS_ThreadCreate(&clientThreadUnused,
"HTTP Client",
@ -174,14 +174,14 @@ static void tcp_server_thread( beken_thread_arg_t arg )
0x400)
#else
rtos_create_thread( NULL, BEKEN_APPLICATION_PRIORITY,
rtos_create_thread( NULL, BEKEN_APPLICATION_PRIORITY,
"HTTP Client",
(beken_thread_function_t)tcp_client_thread,
0x800,
0x800,
(beken_thread_arg_t)client_fd )
#endif
)
)
{
ADDLOG_DEBUG(LOG_FEATURE_HTTP, "TCP Client %s:%d thread creation failed! fd: %d", client_ip_str, client_addr.sin_port, client_fd );
lwip_close( client_fd );
@ -191,10 +191,10 @@ static void tcp_server_thread( beken_thread_arg_t arg )
}
}
}
if ( err != kNoErr )
if ( err != kNoErr )
ADDLOG_ERROR(LOG_FEATURE_HTTP, "Server listerner thread exit with err: %d", err );
lwip_close( tcp_listen_fd );
rtos_delete_thread( NULL );

View File

@ -2,7 +2,7 @@
#include "../new_common.h"
#include "../logging/logging.h"
#include "ctype.h"
#include "ctype.h"
#include "new_http.h"
#include "http_fns.h"
#include "../new_pins.h"
@ -86,7 +86,7 @@ int HTTP_RegisterCallback( const char *url, int method, http_callback_fn callbac
strcpy(callbacks[numCallbacks]->url, url);
callbacks[numCallbacks]->callback = callback;
callbacks[numCallbacks]->method = method;
numCallbacks++;
// success
@ -94,7 +94,7 @@ int HTTP_RegisterCallback( const char *url, int method, http_callback_fn callbac
}
int my_strnicmp(char *a, char *b, int len){
int i;
int i;
for (i = 0; i < len; i++){
char x = *a;
char y = *b;
@ -490,7 +490,7 @@ int HTTP_ProcessPacket(http_request_t *request) {
} while(1);
request->bodystart = p;
request->bodylen = request->receivedLen - (p - request->received);
request->bodylen = request->receivedLen - (p - request->received);
// look for a callback with this URL and method, or HTTP_ANY
for (i = 0; i < numCallbacks; i++){
@ -513,7 +513,7 @@ int HTTP_ProcessPacket(http_request_t *request) {
if(http_checkUrlBase(urlStr,"cfg_mqtt_set")) return http_fn_cfg_mqtt_set(request);
if(http_checkUrlBase(urlStr,"cfg_webapp")) return http_fn_cfg_webapp(request);
if(http_checkUrlBase(urlStr,"cfg_webapp_set")) return http_fn_cfg_webapp_set(request);
if(http_checkUrlBase(urlStr,"cfg_webapp_set")) return http_fn_cfg_webapp_set(request);
if(http_checkUrlBase(urlStr,"cfg_wifi")) return http_fn_cfg_wifi(request);
if(http_checkUrlBase(urlStr,"cfg_name")) return http_fn_cfg_name(request);

View File

@ -22,7 +22,7 @@ extern const char *g_build_str;
#define MAX_QUERY 16
#define MAX_QUERY 16
#define MAX_HEADERS 16
typedef struct http_request_tag {
char *received; // partial or whole received data, up to 1024
@ -75,4 +75,4 @@ typedef int (*http_callback_fn)(http_request_t *request);
// urls must be unique (i.e. you can't have /about and /aboutme or /about/me)
int HTTP_RegisterCallback( const char *url, int method, http_callback_fn callback);
#endif
#endif

View File

@ -76,7 +76,7 @@ void init_rest(){
HTTP_RegisterCallback( "/favicon.ico", HTTP_GET, http_favicon);
}
const char *apppage1 =
const char *apppage1 =
"<!DOCTYPE html>"
"<html>"
" <head>"
@ -116,7 +116,7 @@ const char * apppage4 = "startup.js\"></script>"
static int http_rest_get(http_request_t *request){
ADDLOG_DEBUG(LOG_FEATURE_API, "GET of %s", request->url);
if (!strcmp(request->url, "api/channels")){
return http_rest_get_channels(request);
}
@ -164,9 +164,9 @@ static int http_rest_get(http_request_t *request){
if (!strncmp(request->url, "api/testflashvars", 17)){
return http_rest_get_flash_vars_test(request);
}
http_setup(request, httpMimeTypeHTML);
poststr(request, "GET of ");
@ -210,7 +210,7 @@ static int http_rest_post(http_request_t *request){
if (!strcmp(request->url, "api/cmnd")){
return http_rest_post_cmd(request);
}
#ifdef BK_LITTLEFS
if (!strcmp(request->url, "api/fsblock")){
@ -306,7 +306,7 @@ static int http_rest_get_lfs_file(http_request_t *request){
memset(file, 0, sizeof(lfs_file_t));
strcpy(fpath, request->url + strlen("api/lfs/"));
ADDLOG_DEBUG(LOG_FEATURE_API, "LFS read of %s", fpath);
lfsres = lfs_file_open(&lfs, file, fpath, LFS_O_RDONLY);
@ -334,12 +334,12 @@ static int http_rest_get_lfs_file(http_request_t *request){
lfsres = lfs_dir_read(&lfs, dir, &info);
if (lfsres > 0){
if (count) poststr(request, ",");
hprintf128(request, "{\"name\":\"%s\",\"type\":%d,\"size\":%d}",
hprintf128(request, "{\"name\":\"%s\",\"type\":%d,\"size\":%d}",
info.name, info.type, info.size);
} else {
if (lfsres < 0){
if (count) poststr(request, ",");
hprintf128(request, "{\"error\":%d}", lfsres);
hprintf128(request, "{\"error\":%d}", lfsres);
}
}
count++;
@ -456,7 +456,7 @@ static int http_rest_post_lfs_file(http_request_t *request){
towrite = request->contentLength;
}
//ADDLOG_DEBUG(LOG_FEATURE_API, "bodylen %d, contentlen %d", request->bodylen, request->contentLength);
if (writelen < 0){
ADDLOG_DEBUG(LOG_FEATURE_API, "ABORTED: %d bytes to write", writelen);
lfs_file_close(&lfs, file);
@ -807,7 +807,7 @@ static int http_rest_post_flash(http_request_t *request, int startaddr){
if (request->contentLength >= 0){
towrite = request->contentLength;
}
if (writelen < 0 || (startaddr + writelen > 0x200000)){
ADDLOG_DEBUG(LOG_FEATURE_API, "ABORTED: %d bytes to write", writelen);
return http_rest_error(request, -20, "writelen < 0 or end > 0x200000");
@ -847,7 +847,7 @@ static int http_rest_post_reboot(http_request_t *request){
static int http_rest_get_flash_advanced(http_request_t *request){
char *params = request->url + 10;
int startaddr = 0;
int startaddr = 0;
int len = 0;
int sres;
sres = sscanf(params, "%x-%x", &startaddr, &len);
@ -859,7 +859,7 @@ static int http_rest_get_flash_advanced(http_request_t *request){
static int http_rest_post_flash_advanced(http_request_t *request){
char *params = request->url + 10;
int startaddr = 0;
int startaddr = 0;
int sres;
sres = sscanf(params, "%x", &startaddr);
if (sres == 1 && startaddr >= START_ADR_OF_BK_PARTITION_OTA){
@ -913,7 +913,7 @@ static int http_rest_get_dumpconfig(http_request_t *request){
#ifdef TESTCONFIG_ENABLE
#ifdef TESTCONFIG_ENABLE
// added for OpenBK7231T
typedef struct item_new_test_config
{
@ -922,7 +922,7 @@ typedef struct item_new_test_config
}ITEM_NEW_TEST_CONFIG,*ITEM_NEW_TEST_CONFIG_PTR;
ITEM_NEW_TEST_CONFIG testconfig;
#endif
#endif
static int http_rest_get_testconfig(http_request_t *request){
return http_rest_error(request, 400, "unsupported");
@ -937,7 +937,7 @@ static int http_rest_get_flash_vars_test(http_request_t *request){
//#else
//#ifndef DISABLE_FLASH_VARS_VARS
// char *params = request->url + 17;
// int increment = 0;
// int increment = 0;
// int len = 0;
// int sres;
// int i;
@ -962,14 +962,14 @@ static int http_rest_get_flash_vars_test(http_request_t *request){
// }
// }
//
// sprintf(tmp, "offset %d, boot count %d, boot success %d, bootfailures %d",
// flash_vars_offset,
// p->boot_count,
// sprintf(tmp, "offset %d, boot count %d, boot success %d, bootfailures %d",
// flash_vars_offset,
// p->boot_count,
// p->boot_success_count,
// p->boot_count - p->boot_success_count );
//
// return http_rest_error(request, 200, tmp);
//#else
//#else
return http_rest_error(request, 400, "flash test unsupported");
}