Commit e49f2bb1 authored by Johny Mattsson's avatar Johny Mattsson
Browse files

Remove conflicting libc, rename c_xx and os_xx to xx.

c_strtod and c_getenv are kept since strtod doesn't appear in the SDK's libc,
and we want our own c_getenv to initialize the Lua main anyway.
parent 3a3e9ee0
......@@ -53,6 +53,7 @@ tmr.softwd(int)
#include "platform.h"
#include "c_types.h"
#include "user_interface.h"
#include "rom.h"
#define TIMER_MODE_OFF 3
#define TIMER_MODE_SINGLE 0
......
......@@ -5,7 +5,7 @@
#include "platform.h"
#include "esp_misc.h"
#include "c_stdlib.h"
#include <stdlib.h>
#include "u8g.h"
......
......@@ -5,7 +5,7 @@
#include "platform.h"
#include "c_types.h"
#include "c_string.h"
#include <string.h>
#include "rom.h"
static lua_State *gL = NULL;
......@@ -67,7 +67,7 @@ static int uart_on( lua_State* L )
} else {
lua_pushnil(L);
}
if(sl == 4 && c_strcmp(method, "data") == 0){
if(sl == 4 && strcmp(method, "data") == 0){
run_input = true;
if(uart_receive_rf != LUA_NOREF){
luaL_unref(L, LUA_REGISTRYINDEX, uart_receive_rf);
......
......@@ -5,7 +5,7 @@
#include "platform.h"
#include "esp_misc.h"
#include "c_stdlib.h"
#include <stdlib.h>
#include "ucg.h"
......
......@@ -4,14 +4,15 @@
#include "lauxlib.h"
#include "platform.h"
#include "c_string.h"
#include "c_stdlib.h"
#include "ctype.h"
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include "c_types.h"
#include "user_interface.h"
#include "wifi_common.h"
#include "rom.h"
#ifdef WIFI_SMART_ENABLE
#include "smart.h"
......@@ -101,18 +102,18 @@ static void wifi_scan_done(void *arg, STATUS status)
while (bss_link != NULL)
{
c_memset(ssid, 0, 33);
if (c_strlen(bss_link->ssid) <= 32)
memset(ssid, 0, 33);
if (strlen(bss_link->ssid) <= 32)
{
c_memcpy(ssid, bss_link->ssid, c_strlen(bss_link->ssid));
memcpy(ssid, bss_link->ssid, strlen(bss_link->ssid));
}
else
{
c_memcpy(ssid, bss_link->ssid, 32);
memcpy(ssid, bss_link->ssid, 32);
}
if(getap_output_format==1) //use new format(BSSID : SSID, RSSI, Authmode, Channel)
{
c_sprintf(temp,MACSTR, MAC2STR(bss_link->bssid));
sprintf(temp,MACSTR, MAC2STR(bss_link->bssid));
wifi_add_sprintf_field(L, temp, "%s,%d,%d,%d",
ssid, bss_link->rssi, bss_link->authmode, bss_link->channel);
NODE_DBG(MACSTR" : %s\n",MAC2STR(bss_link->bssid) , temp);//00 00 00 00 00 00
......@@ -378,7 +379,7 @@ static int wifi_getmac( lua_State* L, uint8_t mode )
char temp[64];
uint8_t mac[6];
wifi_get_macaddr(mode, mac);
c_sprintf(temp, MACSTR, MAC2STR(mac));
sprintf(temp, MACSTR, MAC2STR(mac));
lua_pushstring( L, temp );
return 1;
}
......@@ -405,11 +406,11 @@ static int wifi_getip( lua_State* L, uint8_t mode )
lua_pushnil(L);
return 1;
} else {
c_sprintf(temp, "%d.%d.%d.%d", IP2STR(&pTempIp.ip) );
sprintf(temp, "%d.%d.%d.%d", IP2STR(&pTempIp.ip) );
lua_pushstring( L, temp );
c_sprintf(temp, "%d.%d.%d.%d", IP2STR(&pTempIp.netmask) );
sprintf(temp, "%d.%d.%d.%d", IP2STR(&pTempIp.netmask) );
lua_pushstring( L, temp );
c_sprintf(temp, "%d.%d.%d.%d", IP2STR(&pTempIp.gw) );
sprintf(temp, "%d.%d.%d.%d", IP2STR(&pTempIp.gw) );
lua_pushstring( L, temp );
return 3;
}
......@@ -432,7 +433,7 @@ static int wifi_getbroadcast( lua_State* L, uint8_t mode )
uint32 broadcast_address32 = ~pTempIp.netmask.addr | subnet_mask32;
broadcast_address.addr = broadcast_address32;
c_sprintf(temp, "%d.%d.%d.%d", IP2STR(&broadcast_address) );
sprintf(temp, "%d.%d.%d.%d", IP2STR(&broadcast_address) );
lua_pushstring( L, temp );
return 1;
......@@ -559,7 +560,7 @@ static int wifi_station_getconfig( lua_State* L )
lua_pushstring( L, sta_conf.ssid );
lua_pushstring( L, sta_conf.password );
lua_pushinteger( L, sta_conf.bssid_set);
c_sprintf(bssid, MACSTR, MAC2STR(sta_conf.bssid));
sprintf(bssid, MACSTR, MAC2STR(sta_conf.bssid));
lua_pushstring( L, bssid);
return 4;
}
......@@ -638,7 +639,7 @@ static int wifi_station_config( lua_State* L )
if(lua_isnumber(L, 4))
{
sta_conf.bssid_set = 0;
c_memset(sta_conf.bssid, 0, 6);
memset(sta_conf.bssid, 0, 6);
}
else
{
......@@ -646,21 +647,21 @@ static int wifi_station_config( lua_State* L )
{
const char *macaddr = luaL_checklstring( L, 4, &ml );
luaL_argcheck(L, ml==17, 1, INVALID_MAC_STR);
c_memset(sta_conf.bssid, 0, 6);
memset(sta_conf.bssid, 0, 6);
ets_str2macaddr(sta_conf.bssid, macaddr);
sta_conf.bssid_set = 1;
}
else
{
sta_conf.bssid_set = 0;
c_memset(sta_conf.bssid, 0, 6);
memset(sta_conf.bssid, 0, 6);
}
}
c_memset(sta_conf.ssid, 0, 32);
c_memset(sta_conf.password, 0, 64);
c_memcpy(sta_conf.ssid, ssid, sl);
c_memcpy(sta_conf.password, password, pl);
memset(sta_conf.ssid, 0, 32);
memset(sta_conf.password, 0, 64);
memcpy(sta_conf.ssid, ssid, sl);
memcpy(sta_conf.password, password, pl);
NODE_DBG(sta_conf.ssid);
NODE_DBG(" %d\n", sl);
......@@ -773,8 +774,8 @@ static int wifi_station_listap( lua_State* L )
const char *ssidstr = luaL_checklstring( L, -1, &len );
if(len>32)
return luaL_error( L, "ssid:<32" );
c_memset(ssid, 0, 32);
c_memcpy(ssid, ssidstr, len);
memset(ssid, 0, 32);
memcpy(ssid, ssidstr, len);
scan_cfg.ssid=ssid;
NODE_DBG(scan_cfg.ssid);
NODE_DBG("\n");
......@@ -791,7 +792,7 @@ static int wifi_station_listap( lua_State* L )
{
const char *macaddr = luaL_checklstring( L, -1, &len );
luaL_argcheck(L, len==17, 1, INVALID_MAC_STR);
c_memset(bssid, 0, 6);
memset(bssid, 0, 6);
ets_str2macaddr(bssid, macaddr);
scan_cfg.bssid=bssid;
NODE_DBG(MACSTR, MAC2STR(scan_cfg.bssid));
......@@ -969,7 +970,7 @@ static int wifi_ap_deauth( lua_State* L )
}
else
{
c_memset(&mac, 0xFF, sizeof(mac));
memset(&mac, 0xFF, sizeof(mac));
}
lua_pushboolean(L,wifi_softap_deauth(mac));
return 1;
......@@ -1031,8 +1032,8 @@ static int wifi_ap_config( lua_State* L )
const char *ssid = luaL_checklstring( L, -1, &len );
if(len<1 || len>32 || ssid == NULL)
return luaL_error( L, "ssid:1~32" );
c_memset(config.ssid, 0, 32);
c_memcpy(config.ssid, ssid, len);
memset(config.ssid, 0, 32);
memcpy(config.ssid, ssid, len);
NODE_DBG(config.ssid);
NODE_DBG("\n");
config.ssid_len = len;
......@@ -1051,8 +1052,8 @@ static int wifi_ap_config( lua_State* L )
const char *pwd = luaL_checklstring( L, -1, &len );
if(len<8 || len>64 || pwd == NULL)
return luaL_error( L, "pwd:8~64" );
c_memset(config.password, 0, 64);
c_memcpy(config.password, pwd, len);
memset(config.password, 0, 64);
memcpy(config.password, pwd, len);
NODE_DBG(config.password);
NODE_DBG("\n");
config.authmode = AUTH_WPA_WPA2_PSK;
......@@ -1153,10 +1154,10 @@ static int wifi_ap_listclient( lua_State* L )
struct station_info * next_station;
while (station != NULL)
{
c_sprintf(temp, MACSTR, MAC2STR(station->bssid));
sprintf(temp, MACSTR, MAC2STR(station->bssid));
wifi_add_sprintf_field(L, temp, IPSTR, IP2STR(&station->ip));
next_station = STAILQ_NEXT(station, next);
c_free(station);
free(station);
station = next_station;
}
......@@ -1187,9 +1188,9 @@ static int wifi_ap_dhcp_config( lua_State* L )
ip4_addr4(&lease.end_ip) += config.max_connection - 1;
char temp[64];
c_sprintf(temp, IPSTR, IP2STR(&lease.start_ip));
sprintf(temp, IPSTR, IP2STR(&lease.start_ip));
lua_pushstring(L, temp);
c_sprintf(temp, IPSTR, IP2STR(&lease.end_ip));
sprintf(temp, IPSTR, IP2STR(&lease.end_ip));
lua_pushstring(L, temp);
// note: DHCP max range = 101 from start_ip to end_ip
......@@ -1315,7 +1316,7 @@ static void wifi_change_default_host_name(task_param_t param, task_prio_t priori
char temp[32];
uint8_t mac[6];
wifi_get_macaddr(STATION_IF, mac);
c_sprintf(temp, "NODE-%X%X%X", (mac)[3], (mac)[4], (mac)[5]);
sprintf(temp, "NODE-%X%X%X", (mac)[3], (mac)[4], (mac)[5]);
wifi_sta_sethostname((const char*)temp, strlen(temp));
#elif defined(WIFI_STA_HOSTNAME) && !defined(WIFI_STA_HOSTNAME_APPEND_MAC)
......@@ -1324,7 +1325,7 @@ static void wifi_change_default_host_name(task_param_t param, task_prio_t priori
char temp[32];
uint8_t mac[6];
wifi_get_macaddr(STATION_IF, mac);
c_sprintf(temp, "NODE-%X%X%X", (mac)[3], (mac)[4], (mac)[5]);
sprintf(temp, "NODE-%X%X%X", (mac)[3], (mac)[4], (mac)[5]);
wifi_sta_sethostname((const char*)temp, strlen(temp));
}
......@@ -1332,10 +1333,10 @@ static void wifi_change_default_host_name(task_param_t param, task_prio_t priori
char temp[32];
uint8_t mac[6];
wifi_get_macaddr(STATION_IF, mac);
c_sprintf(temp, "%s%X%X%X", WIFI_STA_HOSTNAME, (mac)[3], (mac)[4], (mac)[5]);
sprintf(temp, "%s%X%X%X", WIFI_STA_HOSTNAME, (mac)[3], (mac)[4], (mac)[5]);
if(!wifi_sta_sethostname(temp, strlen(temp)))
{
c_sprintf(temp, "NODE-%X%X%X", (mac)[3], (mac)[4], (mac)[5]);
sprintf(temp, "NODE-%X%X%X", (mac)[3], (mac)[4], (mac)[5]);
wifi_sta_sethostname((const char*)temp, strlen(temp));
}
#endif
......
......@@ -10,7 +10,7 @@ void wifi_add_sprintf_field(lua_State* L, char* name, char* string, ...)
char buffer[256];
va_list arglist;
va_start( arglist, string );
c_vsprintf( buffer, string, arglist );
vsprintf( buffer, string, arglist );
va_end( arglist );
lua_pushstring(L, buffer);
lua_setfield(L, -2, name);
......
......@@ -5,12 +5,12 @@
#include "lauxlib.h"
#include "platform.h"
#include "c_string.h"
#include "c_stdlib.h"
#include <string.h>
#include <stdlib.h>
#include "c_types.h"
#include "user_interface.h"
#include "user_config.h"
#include "c_stdio.h"
#include <stdio.h>
#include "task/task.h"
void wifi_add_sprintf_field(lua_State* L, char* name, char* string, ...);
......@@ -36,9 +36,9 @@ static inline void unregister_lua_cb(lua_State* L, int* cb_ref)
}
#ifdef NODE_DEBUG
#define EVENT_DBG(...) c_printf(__VA_ARGS__)
#define EVENT_DBG(...) printf(__VA_ARGS__)
#else
#define EVENT_DBG(...) //c_printf(__VA_ARGS__)
#define EVENT_DBG(...) //printf(__VA_ARGS__)
#endif
#ifdef WIFI_SDK_EVENT_MONITOR_ENABLE
......
......@@ -4,8 +4,8 @@
#include "lauxlib.h"
#include "platform.h"
#include "c_string.h"
#include "c_stdlib.h"
#include <string.h>
#include <stdlib.h>
#include "c_types.h"
#include "user_interface.h"
......@@ -158,14 +158,14 @@ static void wifi_event_monitor_handle_event_cb(System_Event_t *evt)
evt->event == EVENT_STAMODE_DHCP_TIMEOUT||evt->event==EVENT_SOFTAPMODE_STACONNECTED ||
evt->event == EVENT_SOFTAPMODE_STADISCONNECTED||evt->event==EVENT_SOFTAPMODE_PROBEREQRECVED)))
{
evt_queue_t *temp = (evt_queue_t*)c_malloc(sizeof(evt_queue_t)); //allocate memory for new queue item
temp->evt = (System_Event_t*)c_malloc(sizeof(System_Event_t)); //allocate memory to hold event structure
evt_queue_t *temp = (evt_queue_t*)malloc(sizeof(evt_queue_t)); //allocate memory for new queue item
temp->evt = (System_Event_t*)malloc(sizeof(System_Event_t)); //allocate memory to hold event structure
if(!temp || !temp->evt)
{
luaL_error(lua_getstate(), "wifi.eventmon malloc: out of memory");
return;
}
c_memcpy(temp->evt, evt, sizeof(System_Event_t)); //copy event data to new struct
memcpy(temp->evt, evt, sizeof(System_Event_t)); //copy event data to new struct
if(wifi_event_queue_head == NULL && wifi_event_queue_tail == NULL)// if queue is empty add item to queue
{
......@@ -299,8 +299,8 @@ static void wifi_event_monitor_process_event_queue(task_param_t param, task_prio
task_post_low(wifi_event_monitor_task_id, false); //post task to process next item in queue
}
c_free(evt); //free memory used by event structure
c_free(temp); //free memory used by queue structure
free(evt); //free memory used by event structure
free(temp); //free memory used by queue structure
}
#ifdef WIFI_EVENT_MONITOR_DISCONNECT_REASON_LIST_ENABLE
......
#include "module.h"
#include "lauxlib.h"
#include "platform.h"
#include "c_stdlib.h"
#include "c_string.h"
#include <stdlib.h>
#include <string.h>
#include "esp_misc.h"
#include "rom.h"
/**
* Code is based on https://github.com/CHERTS/esp8266-devkit/blob/master/Espressif/examples/EspLightNode/user/ws2801.c
......
......@@ -2,8 +2,8 @@
#include "lauxlib.h"
#include "lmem.h"
#include "platform.h"
#include "c_stdlib.h"
#include "c_string.h"
#include <stdlib.h>
#include <string.h>
#include "user_interface.h"
#include "driver/uart.h"
......@@ -215,7 +215,7 @@ static int ws2812_buffer_set(lua_State* L) {
return luaL_error(L, "string size will exceed strip length");
}
c_memcpy(&buffer->values[buffer->colorsPerLed*led], buf, len);
memcpy(&buffer->values[buffer->colorsPerLed*led], buf, len);
}
else
{
......
......@@ -29,7 +29,7 @@
*
*/
#include "c_string.h"
#include <string.h>
#include "mqtt_msg.h"
#define MQTT_MAX_FIXED_HEADER_SIZE 3
......@@ -61,7 +61,7 @@ static int append_string(mqtt_connection_t* connection, const char* string, int
connection->buffer[connection->message.length++] = len >> 8;
connection->buffer[connection->message.length++] = len & 0xff;
c_memcpy(connection->buffer + connection->message.length, string, len);
memcpy(connection->buffer + connection->message.length, string, len);
connection->message.length += len;
return len + 2;
......@@ -121,7 +121,7 @@ static mqtt_message_t* fini_message(mqtt_connection_t* connection, int type, int
void mqtt_msg_init(mqtt_connection_t* connection, uint8_t* buffer, uint16_t buffer_length)
{
c_memset(connection, 0, sizeof(connection));
memset(connection, 0, sizeof(connection));
connection->buffer = buffer;
connection->buffer_length = buffer_length;
}
......@@ -294,7 +294,7 @@ mqtt_message_t* mqtt_msg_connect(mqtt_connection_t* connection, mqtt_connect_inf
variable_header->lengthMsb = 0;
variable_header->lengthLsb = 4;
c_memcpy(variable_header->magic, "MQTT", 4);
memcpy(variable_header->magic, "MQTT", 4);
variable_header->version = 4;
variable_header->flags = 0;
variable_header->keepaliveMsb = info->keepalive >> 8;
......@@ -305,7 +305,7 @@ mqtt_message_t* mqtt_msg_connect(mqtt_connection_t* connection, mqtt_connect_inf
if(info->client_id != NULL && info->client_id[0] != '\0')
{
if(append_string(connection, info->client_id, c_strlen(info->client_id)) < 0)
if(append_string(connection, info->client_id, strlen(info->client_id)) < 0)
return fail_message(connection);
}
else
......@@ -313,10 +313,10 @@ mqtt_message_t* mqtt_msg_connect(mqtt_connection_t* connection, mqtt_connect_inf
if(info->will_topic != NULL && info->will_topic[0] != '\0')
{
if(append_string(connection, info->will_topic, c_strlen(info->will_topic)) < 0)
if(append_string(connection, info->will_topic, strlen(info->will_topic)) < 0)
return fail_message(connection);
if(append_string(connection, info->will_message, c_strlen(info->will_message)) < 0)
if(append_string(connection, info->will_message, strlen(info->will_message)) < 0)
return fail_message(connection);
variable_header->flags |= MQTT_CONNECT_FLAG_WILL;
......@@ -327,7 +327,7 @@ mqtt_message_t* mqtt_msg_connect(mqtt_connection_t* connection, mqtt_connect_inf
if(info->username != NULL && info->username[0] != '\0')
{
if(append_string(connection, info->username, c_strlen(info->username)) < 0)
if(append_string(connection, info->username, strlen(info->username)) < 0)
return fail_message(connection);
variable_header->flags |= MQTT_CONNECT_FLAG_USERNAME;
......@@ -335,7 +335,7 @@ mqtt_message_t* mqtt_msg_connect(mqtt_connection_t* connection, mqtt_connect_inf
if(info->password != NULL && info->password[0] != '\0')
{
if(append_string(connection, info->password, c_strlen(info->password)) < 0)
if(append_string(connection, info->password, strlen(info->password)) < 0)
return fail_message(connection);
variable_header->flags |= MQTT_CONNECT_FLAG_PASSWORD;
......@@ -351,7 +351,7 @@ mqtt_message_t* mqtt_msg_publish(mqtt_connection_t* connection, const char* topi
if(topic == NULL || topic[0] == '\0')
return fail_message(connection);
if(append_string(connection, topic, c_strlen(topic)) < 0)
if(append_string(connection, topic, strlen(topic)) < 0)
return fail_message(connection);
if(qos > 0)
......@@ -364,7 +364,7 @@ mqtt_message_t* mqtt_msg_publish(mqtt_connection_t* connection, const char* topi
if(connection->message.length + data_length > connection->buffer_length)
return fail_message(connection);
c_memcpy(connection->buffer + connection->message.length, data, data_length);
memcpy(connection->buffer + connection->message.length, data, data_length);
connection->message.length += data_length;
return fini_message(connection, MQTT_MSG_TYPE_PUBLISH, 0, qos, retain);
......@@ -417,7 +417,7 @@ mqtt_message_t* mqtt_msg_subscribe_topic(mqtt_connection_t* connection, const ch
if(topic == NULL || topic[0] == '\0')
return fail_message(connection);
if(append_string(connection, topic, c_strlen(topic)) < 0)
if(append_string(connection, topic, strlen(topic)) < 0)
return fail_message(connection);
if(connection->message.length + 1 > connection->buffer_length)
......@@ -457,7 +457,7 @@ mqtt_message_t* mqtt_msg_unsubscribe_topic(mqtt_connection_t* connection, const
if(topic == NULL || topic[0] == '\0')
return fail_message(connection);
if(append_string(connection, topic, c_strlen(topic)) < 0)
if(append_string(connection, topic, strlen(topic)) < 0)
return fail_message(connection);
return &connection->message;
......
#include "c_string.h"
#include "c_stdlib.h"
#include "c_stdio.h"
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "msg_queue.h"
#include "user_config.h"
#include "esp_libc.h"
msg_queue_t *msg_enqueue(msg_queue_t **head, mqtt_message_t *msg, uint16_t msg_id, int msg_type, int publish_qos){
if(!head){
......@@ -11,19 +13,19 @@ msg_queue_t *msg_enqueue(msg_queue_t **head, mqtt_message_t *msg, uint16_t msg_i
NODE_DBG("empty message\n");
return NULL;
}
msg_queue_t *node = (msg_queue_t *)c_zalloc(sizeof(msg_queue_t));
msg_queue_t *node = (msg_queue_t *)zalloc(sizeof(msg_queue_t));
if(!node){
NODE_DBG("not enough memory\n");
return NULL;
}
node->msg.data = (uint8_t *)c_zalloc(msg->length);
node->msg.data = (uint8_t *)zalloc(msg->length);
if(!node->msg.data){
NODE_DBG("not enough memory\n");
c_free(node);
free(node);
return NULL;
}
c_memcpy(node->msg.data, msg->data, msg->length);
memcpy(node->msg.data, msg->data, msg->length);
node->msg.length = msg->length;
node->next = NULL;
node->msg_id = msg_id;
......@@ -43,10 +45,10 @@ msg_queue_t *msg_enqueue(msg_queue_t **head, mqtt_message_t *msg, uint16_t msg_i
void msg_destroy(msg_queue_t *node){
if(!node) return;
if(node->msg.data){
c_free(node->msg.data);
free(node->msg.data);
node->msg.data = NULL;
}
c_free(node);
free(node);
}
msg_queue_t * msg_dequeue(msg_queue_t **head){
......
......@@ -48,7 +48,7 @@
#include "osapi.h"
#include "os_type.h"
#include "user_interface.h"
#include "c_string.h"
#include <string.h>
#include "nodemcu_mdns.h"
#if 0
......@@ -973,7 +973,7 @@ memerr1:
static void
mdns_free_info(struct nodemcu_mdns_info *info) {
os_free((void *) info);
free((void *) info);
}
/**
......@@ -988,7 +988,7 @@ nodemcu_mdns_close(void)
udp_remove(mdns_pcb);
}
if (mdns_payload) {
os_free(mdns_payload);
free(mdns_payload);
}
mdns_payload = NULL;
mdns_pcb = NULL;
......@@ -1001,7 +1001,7 @@ mdns_set_servicename(const char *name) {
char tmpBuf[128];
os_sprintf(tmpBuf, "_%s._tcp.local", name);
if (service_name_with_suffix) {
os_free(service_name_with_suffix);
free(service_name_with_suffix);
}
service_name_with_suffix = c_strdup(tmpBuf);
}
......@@ -1029,17 +1029,17 @@ mdns_dup_info(const struct nodemcu_mdns_info *info) {
// calculate length
int len = sizeof(struct nodemcu_mdns_info);
len += c_strlen(info->host_name) + 1;
len += c_strlen(info->host_desc) + 1;
len += c_strlen(info->service_name) + 1;
len += strlen(info->host_name) + 1;
len += strlen(info->host_desc) + 1;
len += strlen(info->service_name) + 1;
int i;
for (i = 0; i < sizeof(info->txt_data) / sizeof(info->txt_data[0]) && info->txt_data[i]; i++) {
len += c_strlen(info->txt_data[i]) + 1;
len += strlen(info->txt_data[i]) + 1;
}
#define COPY_OVER(dest, src, p) len = c_strlen(src) + 1; memcpy(p, src, len); dest = p; p += len
#define COPY_OVER(dest, src, p) len = strlen(src) + 1; memcpy(p, src, len); dest = p; p += len
result = (struct nodemcu_mdns_info *) os_zalloc(len);
result = (struct nodemcu_mdns_info *) zalloc(len);
if (result) {
char *p = (char *) (result + 1);
result->service_port = info->service_port;
......@@ -1075,9 +1075,9 @@ nodemcu_mdns_init(struct nodemcu_mdns_info *info) {
}
if (mdns_payload) {
os_free(mdns_payload);
free(mdns_payload);
}
mdns_payload = (u8_t *) os_malloc(DNS_MSG_SIZE);
mdns_payload = (u8_t *) malloc(DNS_MSG_SIZE);
if (!mdns_payload) {
MDNS_DBG("Alloc fail\n");
return FALSE;
......
......@@ -2,8 +2,8 @@
#include "platform.h"
#include "common.h"
#include "c_string.h"
#include "c_stdio.h"
#include <string.h>
#include <stdio.h>
void cmn_platform_init(void)
{
......@@ -102,7 +102,7 @@ uint32_t platform_flash_write( const void *from, uint32_t toaddr, uint32_t size
{
rest = toaddr & blkmask;
temp = toaddr & ~blkmask; // this is the actual aligned address
// c_memcpy( tmpdata, ( const void* )temp, blksize );
// memcpy( tmpdata, ( const void* )temp, blksize );
platform_s_flash_read( tmpdata, temp, blksize );
for( i = rest; size && ( i < blksize ); i ++, size --, pfrom ++ )
tmpdata[ i ] = *pfrom;
......@@ -125,7 +125,7 @@ uint32_t platform_flash_write( const void *from, uint32_t toaddr, uint32_t size
// And the final part of a block if needed
if( rest )
{
// c_memcpy( tmpdata, ( const void* )toaddr, blksize );
// memcpy( tmpdata, ( const void* )toaddr, blksize );
platform_s_flash_read( tmpdata, toaddr, blksize );
for( i = 0; size && ( i < rest ); i ++, size --, pfrom ++ )
tmpdata[ i ] = *pfrom;
......
......@@ -6,7 +6,7 @@
#include "user_config.h"
#include "flash_api.h"
#include "spi_flash.h"
#include "c_stdio.h"
#include <stdio.h>
uint32_t flash_detect_size_byte(void)
{
......@@ -19,7 +19,7 @@ uint32_t flash_detect_size_byte(void)
dummy_size = FLASH_SIZE_256KBYTE;
while ((dummy_size < FLASH_SIZE_16MBYTE) &&
(SPI_FLASH_RESULT_OK == flash_safe_read(dummy_size, (uint32 *)data_new, FLASH_BUFFER_SIZE_DETECT)) &&
(0 != os_memcmp(data_orig, data_new, FLASH_BUFFER_SIZE_DETECT))
(0 != memcmp(data_orig, data_new, FLASH_BUFFER_SIZE_DETECT))
)
{
dummy_size *= 2;
......@@ -208,7 +208,7 @@ uint16_t flash_rom_get_sec_num(void)
{
//static uint16_t sec_num = 0;
// return flash_rom_get_size_byte() / (SPI_FLASH_SEC_SIZE);
// c_printf("\nflash_rom_get_size_byte()=%d\n", ( flash_rom_get_size_byte() / (SPI_FLASH_SEC_SIZE) ));
// printf("\nflash_rom_get_size_byte()=%d\n", ( flash_rom_get_size_byte() / (SPI_FLASH_SEC_SIZE) ));
// if( sec_num == 0 )
//{
// sec_num = 4 * 1024 * 1024 / (SPI_FLASH_SEC_SIZE);
......@@ -335,14 +335,14 @@ uint16_t word_of_aligned_array(const uint16_t *aligned_array, uint32_t index)
// // uint8_t buffer[64] = {0};
// // spi_flash_read(address, (uint32 *) buffer, 64);
// // uint8_t i = 0;
// // c_printf("\nBEGIN DUMP\n");
// // printf("\nBEGIN DUMP\n");
// // for (i = 0; i < 64; i++)
// // {
// // c_printf("%02x," , buffer[i]);
// // printf("%02x," , buffer[i]);
// // }
// // i = (address + 0x10) & 0x10 - 1;
// // c_printf("\nSIZE:%d CHECK SUM:%02x\n", spi_flash_info.segment_size, buffer[i]);
// // c_printf("\nEND DUMP\n");
// // printf("\nSIZE:%d CHECK SUM:%02x\n", spi_flash_info.segment_size, buffer[i]);
// // printf("\nEND DUMP\n");
// // return buffer[0];
// return 0;
// }
......
#include "flash_fs.h"
#include "c_string.h"
#include <string.h>
#include "spiffs.h"
int fs_mode2flag(const char *mode){
if(c_strlen(mode)==1){
if(c_strcmp(mode,"w")==0)
if(strlen(mode)==1){
if(strcmp(mode,"w")==0)
return FS_WRONLY|FS_CREAT|FS_TRUNC;
else if(c_strcmp(mode, "r")==0)
else if(strcmp(mode, "r")==0)
return FS_RDONLY;
else if(c_strcmp(mode, "a")==0)
else if(strcmp(mode, "a")==0)
return FS_WRONLY|FS_CREAT|FS_APPEND;
else
return FS_RDONLY;
} else if (c_strlen(mode)==2){
if(c_strcmp(mode,"r+")==0)
} else if (strlen(mode)==2){
if(strcmp(mode,"r+")==0)
return FS_RDWR;
else if(c_strcmp(mode, "w+")==0)
else if(strcmp(mode, "w+")==0)
return FS_RDWR|FS_CREAT|FS_TRUNC;
else if(c_strcmp(mode, "a+")==0)
else if(strcmp(mode, "a+")==0)
return FS_RDWR|FS_CREAT|FS_APPEND;
else
return FS_RDONLY;
......
......@@ -2,9 +2,9 @@
#include "platform.h"
#include "common.h"
#include "c_stdio.h"
#include "c_string.h"
#include "c_stdlib.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "llimits.h"
#include "gpio.h"
#include "user_interface.h"
......@@ -276,7 +276,7 @@ int platform_gpio_register_intr_hook(uint32_t bits, platform_hook_function hook)
}
// These return NULL if the count = 0 so only error check if > 0)
nh.entry = c_malloc( nh.count * sizeof(*(nh.entry)) );
nh.entry = malloc( nh.count * sizeof(*(nh.entry)) );
if (nh.count && !(nh.entry)) {
return 0; // Allocation failure
}
......@@ -301,7 +301,7 @@ int platform_gpio_register_intr_hook(uint32_t bits, platform_hook_function hook)
platform_gpio_hook = nh;
ETS_GPIO_INTR_ENABLE();
c_free(oh.entry);
free(oh.entry);
return 1;
}
#endif // GPIO_INTERRUPT_HOOK_ENABLE
......@@ -745,15 +745,15 @@ uint32_t platform_s_flash_write( const void *from, uint32_t toaddr, uint32_t siz
uint32_t *apbuf = NULL;
uint32_t fromaddr = (uint32_t)from;
if( (fromaddr & blkmask ) || (fromaddr >= INTERNAL_FLASH_MAPPED_ADDRESS)) {
apbuf = (uint32_t *)c_malloc(size);
apbuf = (uint32_t *)malloc(size);
if(!apbuf)
return 0;
c_memcpy(apbuf, from, size);
memcpy(apbuf, from, size);
}
system_soft_wdt_feed ();
r = flash_write(toaddr, apbuf?(uint32 *)apbuf:(uint32 *)from, size);
if(apbuf)
c_free(apbuf);
free(apbuf);
if(SPI_FLASH_RESULT_OK == r)
return size;
else{
......@@ -783,7 +783,7 @@ uint32_t platform_s_flash_read( void *to, uint32_t fromaddr, uint32_t size )
r = flash_read(fromaddr, to2, size2);
if(SPI_FLASH_RESULT_OK == r)
{
os_memmove(to,to2,size2);
memmove(to,to2,size2);
char back[ INTERNAL_FLASH_READ_UNIT_SIZE ] __attribute__ ((aligned(INTERNAL_FLASH_READ_UNIT_SIZE)));
r=flash_read(fromaddr+size2,(uint32*)back,INTERNAL_FLASH_READ_UNIT_SIZE);
os_memcpy((uint8_t*)to+size2,back,INTERNAL_FLASH_READ_UNIT_SIZE);
......
#include "c_stdio.h"
#include "c_stdlib.h"
#include "c_string.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "user_interface.h"
#include "smart.h"
#include "esp_wifi.h"
......@@ -39,7 +39,7 @@ int smart_check(uint8_t *nibble, uint16_t len, uint8_t *dst, uint8_t *got){
uint16_t dst_len = len/NIBBLE_PER_BYTE;
uint16_t byte_num = 0, bit_num = 0;
int i = 0, res = 1; // assume ok.
c_memset(dst,0,dst_len);
memset(dst,0,dst_len);
if(NIBBLE_PER_BYTE==1){
for(i=0;i<len;i++){
......@@ -161,7 +161,7 @@ void detect(uint8 *arg, uint16 len){
if ( len - am[i]->base_len == am[i]->flag[0]) // store new source-dest adress pair to the map until flag[0] is got
{
// BSSID, SA, DA, store the SA, DA
c_memcpy(am[i]->addr, &buf[ADDR_MATCH_START], ADDR_MATCH_LENGTH);
memcpy(am[i]->addr, &buf[ADDR_MATCH_START], ADDR_MATCH_LENGTH);
am[i]->flag_match_num++; // =1
am[i]->cur_base_seq = seq; // assume the first seq is found
am[i]->base_seq_valid = 1;
......@@ -169,7 +169,7 @@ void detect(uint8 *arg, uint16 len){
}
break; // break any way for the next packet to come
}
else if(0 == c_memcmp(am[i]->addr, &buf[ADDR_MATCH_START], ADDR_MATCH_LENGTH)){ // source-dest adress pair match
else if(0 == memcmp(am[i]->addr, &buf[ADDR_MATCH_START], ADDR_MATCH_LENGTH)){ // source-dest adress pair match
if(am[i]->base_seq_valid == 0){
if ( len - am[i]->base_len == am[i]->flag[0]) { // found the new flag[0]
// here flag_match_num is already = 1
......@@ -236,7 +236,7 @@ void detect(uint8 *arg, uint16 len){
// break out, or loop done.
goto end;
} else { // cur_base_seq is ref to SSID_FLAG when patern is alread found
if(0 != c_memcmp(matched->addr, &buf[ADDR_MATCH_START], ADDR_MATCH_LENGTH)){ // source-dest adress pair not match, ignore it
if(0 != memcmp(matched->addr, &buf[ADDR_MATCH_START], ADDR_MATCH_LENGTH)){ // source-dest adress pair not match, ignore it
return;
}
if (matched->base_seq_valid == 0){ // SSID_FLAG seq invalid, need to find the next valid seq number
......@@ -455,7 +455,7 @@ void reset_map(smart_addr_map **am, size_t num){
am[i]->base_seq_valid = 0;
am[i]->ssid_len = 0;
am[i]->pwd_len = 0;
c_memset(am[i]->addr, 0, ADDR_MATCH_LENGTH);
memset(am[i]->addr, 0, ADDR_MATCH_LENGTH);
if(SEP_1_INDEX==0){
am[i]->flag[0] = SEP_1;
am[i]->flag[1] = SEP_2;
......@@ -508,34 +508,34 @@ void smart_end(){
for (i = 0; i < ADDR_MAP_NUM; ++i)
{
if(am[i]){
c_free(am[i]);
free(am[i]);
am[i] = NULL;
}
matched = NULL;
}
if(sta_conf){
c_free(sta_conf);
free(sta_conf);
sta_conf = NULL;
}
if(got_password){
c_free(got_password);
free(got_password);
got_password = NULL;
}
if(got_ssid){
c_free(got_ssid);
free(got_ssid);
got_ssid = NULL;
}
if(password_nibble){
c_free(password_nibble);
free(password_nibble);
password_nibble = NULL;
}
if(ssid_nibble){
c_free(ssid_nibble);
free(ssid_nibble);
ssid_nibble = NULL;
}
// system_restart(); // restart to enable the mode
......@@ -580,14 +580,14 @@ void smart_next_channel(){
NODE_ERR("switch to channel %d\n", cur_channel);
wifi_set_channel(cur_channel);
reset_map(am, ADDR_MAP_NUM);
c_memset(sta_conf->ssid, 0, sizeof(sta_conf->ssid));
c_memset(sta_conf->password, 0, sizeof(sta_conf->password));
memset(sta_conf->ssid, 0, sizeof(sta_conf->ssid));
memset(sta_conf->password, 0, sizeof(sta_conf->password));
c_memset(got_ssid, 0, SSID_BIT_MAX);
c_memset(got_password, 0, PWD_BIT_MAX);
memset(got_ssid, 0, SSID_BIT_MAX);
memset(got_password, 0, PWD_BIT_MAX);
c_memset(ssid_nibble, 0, SSID_NIBBLE_MAX);
c_memset(password_nibble, 0, PWD_NIBBLE_MAX);
memset(ssid_nibble, 0, SSID_NIBBLE_MAX);
memset(password_nibble, 0, PWD_NIBBLE_MAX);
os_timer_disarm(&smart_timer);
os_timer_arm(&smart_timer, TIME_OUT_PER_CHANNEL, 0); // no repeat
......@@ -601,7 +601,7 @@ void smart_begin(int chnl, smart_succeed s, void *arg){
for (i = 0; i < ADDR_MAP_NUM; ++i)
{
if(!am[i]){
am[i] = (smart_addr_map*)c_zalloc(sizeof(smart_addr_map));
am[i] = (smart_addr_map*)zalloc(sizeof(smart_addr_map));
if(!am[i]){
NODE_DBG("smart_begin map no memory\n");
smart_end();
......@@ -610,7 +610,7 @@ void smart_begin(int chnl, smart_succeed s, void *arg){
}
}
if(!sta_conf){
sta_conf = (struct station_config *)c_zalloc(sizeof(struct station_config));
sta_conf = (struct station_config *)zalloc(sizeof(struct station_config));
if(!sta_conf){
NODE_DBG("smart_begin sta_conf no memory\n");
smart_end();
......@@ -619,7 +619,7 @@ void smart_begin(int chnl, smart_succeed s, void *arg){
}
if(!ssid_nibble){
ssid_nibble = (uint8_t *)c_zalloc(SSID_NIBBLE_MAX);
ssid_nibble = (uint8_t *)zalloc(SSID_NIBBLE_MAX);
if(!ssid_nibble){
NODE_DBG("smart_begin sta_conf no memory\n");
smart_end();
......@@ -628,7 +628,7 @@ void smart_begin(int chnl, smart_succeed s, void *arg){
}
if(!password_nibble){
password_nibble = (uint8_t *)c_zalloc(PWD_NIBBLE_MAX);
password_nibble = (uint8_t *)zalloc(PWD_NIBBLE_MAX);
if(!password_nibble){
NODE_DBG("smart_begin sta_conf no memory\n");
smart_end();
......@@ -637,7 +637,7 @@ void smart_begin(int chnl, smart_succeed s, void *arg){
}
if(!got_ssid){
got_ssid = (uint8_t *)c_zalloc(SSID_BIT_MAX);
got_ssid = (uint8_t *)zalloc(SSID_BIT_MAX);
if(!got_ssid){
NODE_DBG("smart_begin sta_conf no memory\n");
smart_end();
......@@ -646,7 +646,7 @@ void smart_begin(int chnl, smart_succeed s, void *arg){
}
if(!got_password){
got_password = (uint8_t *)c_zalloc(PWD_BIT_MAX);
got_password = (uint8_t *)zalloc(PWD_BIT_MAX);
if(!got_password){
NODE_DBG("smart_begin sta_conf no memory\n");
smart_end();
......@@ -654,14 +654,14 @@ void smart_begin(int chnl, smart_succeed s, void *arg){
}
}
reset_map(am, ADDR_MAP_NUM);
// c_memset(sta_conf->ssid, 0, sizeof(sta_conf->ssid));
// c_memset(sta_conf->password, 0, sizeof(sta_conf->password));
// memset(sta_conf->ssid, 0, sizeof(sta_conf->ssid));
// memset(sta_conf->password, 0, sizeof(sta_conf->password));
// c_memset(got_ssid, 0, SSID_BIT_MAX);
// c_memset(got_password, 0, PWD_BIT_MAX);
// memset(got_ssid, 0, SSID_BIT_MAX);
// memset(got_password, 0, PWD_BIT_MAX);
// c_memset(ssid_nibble, 0, SSID_NIBBLE_MAX);
// c_memset(password_nibble, 0, PWD_NIBBLE_MAX);
// memset(ssid_nibble, 0, SSID_NIBBLE_MAX);
// memset(password_nibble, 0, PWD_NIBBLE_MAX);
mode = wifi_get_opmode();
if( (STATION_MODE == mode) || (mode == STATIONAP_MODE) ){
wifi_station_set_auto_connect(false);
......
#include "c_stdio.h"
#include <stdio.h>
#include "platform.h"
#include "spiffs.h"
......
......@@ -161,7 +161,7 @@ s32_t spiffs_phys_rd(
}
}
u8_t *mem = spiffs_get_cache_page(fs, cache, cp->ix);
c_memcpy(dst, &mem[SPIFFS_PADDR_TO_PAGE_OFFSET(fs, addr)], len);
memcpy(dst, &mem[SPIFFS_PADDR_TO_PAGE_OFFSET(fs, addr)], len);
return res;
}
......@@ -190,7 +190,7 @@ s32_t spiffs_phys_wr(
}
u8_t *mem = spiffs_get_cache_page(fs, cache, cp->ix);
c_memcpy(&mem[SPIFFS_PADDR_TO_PAGE_OFFSET(fs, addr)], src, len);
memcpy(&mem[SPIFFS_PADDR_TO_PAGE_OFFSET(fs, addr)], src, len);
cache->last_access++;
cp->last_access = cache->last_access;
......@@ -282,17 +282,17 @@ void spiffs_cache_init(spiffs *fs) {
}
spiffs_cache cache;
c_memset(&cache, 0, sizeof(spiffs_cache));
memset(&cache, 0, sizeof(spiffs_cache));
cache.cpage_count = cache_entries;
cache.cpages = (u8_t *)((u8_t *)fs->cache + sizeof(spiffs_cache));
cache.cpage_use_map = 0xffffffff;
cache.cpage_use_mask = cache_mask;
c_memcpy(fs->cache, &cache, sizeof(spiffs_cache));
memcpy(fs->cache, &cache, sizeof(spiffs_cache));
spiffs_cache *c = spiffs_get_cache(fs);
c_memset(c->cpages, 0, c->cpage_count * SPIFFS_CACHE_PAGE_SIZE(fs));
memset(c->cpages, 0, c->cpage_count * SPIFFS_CACHE_PAGE_SIZE(fs));
c->cpage_use_map &= ~(c->cpage_use_mask);
for (i = 0; i < cache.cpage_count; i++) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment