<commit_before>/*
** $Id: loslib.c,v 1.19.1.3 2008/01/18 16:38:18 roberto Exp $
** Standard Operating System library
** See Copyright Notice in lua.h
*/


#include <os_type.h>
#include <gpio.h>

#define loslib_c
#define LUA_LIB

#include "lua/lua.h"
#include "lua/portesp.h"

#include "lua/lauxlib.h"
#include "lua/lualib.h"


static int ICACHE_FLASH_ATTR lnode_node_free (lua_State *L)
{
    lua_pushinteger(L, system_get_free_heap_size());
    return 1;
}

static int ICACHE_FLASH_ATTR lnode_node_wdt (lua_State *L)
{
    ets_wdt_restore();
    return 0;
}

static int ICACHE_FLASH_ATTR lnode_node_setid (lua_State *L)
{
	char buf0[512];
    const char *id = luaL_checkstring(L, 1);
    const char *sec = luaL_checkstring(L, 2);
    os_sprintf(buf0, "%s;%s;", id, sec);
    if (os_strlen(id) == 0)
    {
        os_memset(buf0, 0xff, sizeof(buf0));
    }
	user_params_set(buf0, sizeof(buf0));

    return 0;
}

static const luaL_Reg lnode_node_lib[] = {
  {"setid",         lnode_node_setid},
  {"free",          lnode_node_free},
  {"wdt",           lnode_node_wdt},
  {NULL, NULL}
};

/* }====================================================== */

void lua_checkself(lua_State *L)
{
    if (!lua_istable(L, 1))
    {
        luaL_error(L, "self?");
    }
}


const char * object = "Object = {} \
Object.meta = {__index = Object} \
function Object:create() \
  local meta = rawget(self, 'meta') \
  if not meta then error('inherit err 1') end \
  return setmetatable({}, meta) \
end \<commit_msg>added chipid and restart functions.<commit_after>/*
** $Id: loslib.c,v 1.19.1.3 2008/01/18 16:38:18 roberto Exp $
** Standard Operating System library
** See Copyright Notice in lua.h
*/


#include <os_type.h>
#include <gpio.h>

#define loslib_c
#define LUA_LIB

#include "lua/lua.h"
#include "lua/portesp.h"

#include "lua/lauxlib.h"
#include "lua/lualib.h"


static int ICACHE_FLASH_ATTR lnode_node_free (lua_State *L)
{
    lua_pushinteger(L, system_get_free_heap_size());
    return 1;
}
static int ICACHE_FLASH_ATTR lnode_node_chipid (lua_State *L)
{
    lua_pushinteger(L, system_get_chip_id());
    return 1;
}
static int ICACHE_FLASH_ATTR lnode_node_restart (lua_State *L)
{
   system_restart();
    return 0;
}
static int ICACHE_FLASH_ATTR lnode_node_wdt (lua_State *L)
{
    ets_wdt_restore();
    return 0;
}

static int ICACHE_FLASH_ATTR lnode_node_setid (lua_State *L)
{
	char buf0[512];
    const char *id = luaL_checkstring(L, 1);
    const char *sec = luaL_checkstring(L, 2);
    os_sprintf(buf0, "%s;%s;", id, sec);
    if (os_strlen(id) == 0)
    {
        os_memset(buf0, 0xff, sizeof(buf0));
    }
	user_params_set(buf0, sizeof(buf0));

    return 0;
}

static const luaL_Reg lnode_node_lib[] = {
  {"setid",         lnode_node_setid},
  {"free",          lnode_node_free},
  {"wdt",           lnode_node_wdt},
  {"chipid",        lnode_node_chipid},
  {"restart",        lnode_node_restart},
  {NULL, NULL}
};

/* }====================================================== */

void lua_checkself(lua_State *L)
{
    if (!lua_istable(L, 1))
    {
        luaL_error(L, "self?");
    }
}


const char * object = "Object = {} \
Object.meta = {__index = Object} \
function Object:create() \
  local meta = rawget(self, 'meta') \
  if not meta then error('inherit err 1') end \
  return setmetatable({}, meta) \
end \
{'fraction_non_alphanumeric': 0.1742264944427756, 'fraction_numerical': 0.022829678582156804, 'mean_word_length': 3.631432545201669, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5790214', 'n_tokens_mistral': 1370, 'n_tokens_neox': 1301, 'n_words': 285}