type stringclasses 5
values | content stringlengths 9 163k |
|---|---|
defines |
#define TCPD_ACCEPT_UNREF(accept) \ |
defines |
#define BUFLEN 1024 |
functions | int lua_tcpd_server_close(lua_State *L)
{
SERVER *serv = luaL_checkudata(L, 1, LUA_TCPD_SERVER_TYPE);
CLEAR_REF(L, serv->onAcceptRef)
CLEAR_REF(L, serv->onSSLHostNameRef)
if (serv->host)
{
free(serv->host);
serv->host = NULL;
} |
functions | FAN_HAS_OPENSSL
if (serv->ctx)
{
SSL_CTX_free(serv->ctx);
EC_KEY_free(serv->ecdh);
serv->ctx = NULL;
serv->ecdh = NULL;
} |
functions | int lua_tcpd_server_gc(lua_State *L)
{
return lua_tcpd_server_close(L);
} |
functions | int lua_tcpd_accept_tostring(lua_State *L)
{
ACCEPT *accept = luaL_checkudata(L, 1, LUA_TCPD_ACCEPT_TYPE);
lua_pushfstring(L, LUA_TCPD_ACCEPT_TYPE, accept->ip, accept->port);
return 1;
} |
functions | int lua_tcpd_server_tostring(lua_State *L)
{
SERVER *serv = luaL_checkudata(L, 1, LUA_TCPD_SERVER_TYPE);
if (serv->listener)
{
char host[INET6_ADDRSTRLEN];
regress_get_socket_host(evconnlistener_get_fd(serv->listener), host);
lua_pushfstring(
L, LUA_TCPD_SERVER_TYPE, host,
regress_get_... |
functions | void tcpd_accept_eventcb(struct bufferevent *bev, short events,
void *arg)
{
ACCEPT *accept = (ACCEPT *)arg;
if (events & BEV_EVENT_ERROR || events & BEV_EVENT_EOF ||
events & BEV_EVENT_TIMEOUT)
{
if (events & BEV_EVENT_ERROR)
{
#if DEBUG
printf("BEV_EVENT_ERRO... |
functions | else if (events & BEV_EVENT_TIMEOUT)
{
lua_pushstring(co, "timeout");
} |
functions | else if (events & BEV_EVENT_EOF)
{
lua_pushstring(co, "client disconnected");
} |
functions | void tcpd_accept_readcb(struct bufferevent *bev, void *ctx)
{
ACCEPT *accept = (ACCEPT *)ctx;
char buf[BUFLEN];
int n;
BYTEARRAY ba = {0} |
functions | void tcpd_accept_writecb(struct bufferevent *bev, void *ctx)
{
ACCEPT *accept = (ACCEPT *)ctx;
if (evbuffer_get_length(bufferevent_get_output(bev)) == 0)
{
if (accept->onSendReadyRef != LUA_NOREF)
{
lua_State *mainthread = accept->mainthread;
lua_lock(mainthread);
lua_State *co = lua_ne... |
functions | void connlistener_cb(struct evconnlistener *listener, evutil_socket_t fd,
struct sockaddr *addr, int socklen, void *arg)
{
SERVER *serv = (SERVER *)arg;
if (serv->onAcceptRef != LUA_NOREF)
{
lua_State *mainthread = serv->mainthread;
lua_lock(mainthread);
lua_State *co = lua_newth... |
functions | int tcpd_accept_bind(lua_State *L)
{
ACCEPT *accept = luaL_checkudata(L, 1, LUA_TCPD_ACCEPT_TYPE);
luaL_checktype(L, 2, LUA_TTABLE);
lua_settop(L, 2);
lua_pushvalue(L, 1);
accept->selfRef = luaL_ref(L, LUA_REGISTRYINDEX);
SET_FUNC_REF_FROM_TABLE(L, accept->onReadRef, 2, "onread")
SET_FUNC_REF_FROM_TABL... |
functions | int ssl_servername_cb(SSL *s, int *ad, void *arg)
{
const char *hostname = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name);
// if (hostname)
// printf("Hostname in TLS extension: \"%s\"\n", hostname);
SERVER *serv = (SERVER *)arg;
if (hostname && serv->onSSLHostNameRef != LUA_NOREF)
{
lua_State *mai... |
functions | void tcpd_server_rebind(lua_State *L, SERVER *serv)
{
if (serv->listener)
{
evconnlistener_free(serv->listener);
serv->listener = NULL;
} |
functions | int lua_tcpd_server_rebind(lua_State *L)
{
SERVER *serv = luaL_checkudata(L, 1, LUA_TCPD_SERVER_TYPE);
tcpd_server_rebind(L, serv);
return 0;
} |
functions | int tcpd_bind(lua_State *L)
{
event_mgr_init();
luaL_checktype(L, 1, LUA_TTABLE);
lua_settop(L, 1);
SERVER *serv = lua_newuserdata(L, sizeof(SERVER));
memset(serv, 0, sizeof(SERVER));
luaL_getmetatable(L, LUA_TCPD_SERVER_TYPE);
lua_setmetatable(L, -2);
serv->mainthread = utlua_mainthread(L);
SET_FU... |
functions | else
if (ssl)
{
luaL_error(L, "ssl is not supported on micro version.");
} |
functions | void tcpd_conn_readcb(struct bufferevent *bev, void *ctx)
{
Conn *conn = (Conn *)ctx;
char buf[BUFLEN];
int n;
BYTEARRAY ba;
bytearray_alloc(&ba, BUFLEN * 2);
struct evbuffer *input = bufferevent_get_input(bev);
while ((n = evbuffer_remove(input, buf, sizeof(buf))) > 0)
{
bytearray_writebuffer(&ba,... |
functions | void tcpd_conn_writecb(struct bufferevent *bev, void *ctx)
{
Conn *conn = (Conn *)ctx;
if (evbuffer_get_length(bufferevent_get_output(bev)) == 0)
{
if (conn->onSendReadyRef != LUA_NOREF)
{
lua_State *mainthread = conn->mainthread;
lua_lock(mainthread);
lua_State *co = lua_newthread(main... |
functions | void tcpd_conn_eventcb(struct bufferevent *bev, short events,
void *arg)
{
Conn *conn = (Conn *)arg;
if (events & BEV_EVENT_CONNECTED)
{
// printf("tcp connected.\n");
if (conn->onConnectedRef != LUA_NOREF)
{
lua_State *mainthread = conn->mainthread;
... |
functions | else if (events & BEV_EVENT_ERROR || events & BEV_EVENT_EOF ||
events & BEV_EVENT_TIMEOUT)
{
#if FAN_HAS_OPENSSL
SSL *ssl = bufferevent_openssl_get_ssl(bev);
if (ssl)
{
SSL_set_shutdown(ssl, SSL_RECEIVED_SHUTDOWN);
SSL_shutdown(ssl);
} |
functions | else if (events & BEV_EVENT_WRITING)
{
lua_pushliteral(co, "write timeout");
} |
functions | else if (events & BEV_EVENT_ERROR)
{
#if FAN_HAS_OPENSSL
if (conn->ssl_error)
{
lua_pushfstring(co, "SSLError: %s", conn->ssl_error);
} |
functions | else if (events & BEV_EVENT_EOF)
{
lua_pushliteral(co, "server disconnected");
} |
functions | int ssl_verifypeer_cb(int preverify_ok, X509_STORE_CTX *ctx)
{
if (!preverify_ok)
{
SSL *ssl = X509_STORE_CTX_get_ex_data(ctx, SSL_get_ex_data_X509_STORE_CTX_idx());
Conn *conn = SSL_get_ex_data(ssl, conn_index);
int err = X509_STORE_CTX_get_error(ctx);
conn->ssl_error = strdup(X509_verify_cert_err... |
functions | void luatcpd_reconnect(Conn *conn)
{
if (conn->buf)
{
bufferevent_free(conn->buf);
conn->buf = NULL;
} |
functions | IP_BOUND_IF
if (conn->interface)
{
setsockopt(fd, IPPROTO_IP, IP_BOUND_IF, &conn->interface, sizeof(conn->interface));
} |
functions | endif
if (rc < 0)
{
LOGE("could not connect to %s:%d %s", conn->host, conn->port,
evutil_socket_error_to_string(EVUTIL_SOCKET_ERROR()));
bufferevent_free(conn->buf);
conn->buf = NULL;
return;
} |
functions | int tcpd_connect(lua_State *L)
{
event_mgr_init();
luaL_checktype(L, 1, LUA_TTABLE);
lua_settop(L, 1);
Conn *conn = lua_newuserdata(L, sizeof(Conn));
memset(conn, 0, sizeof(Conn));
luaL_getmetatable(L, LUA_TCPD_CONNECTION_TYPE);
lua_setmetatable(L, -2);
conn->mainthread = utlua_mainthread(L);
conn-... |
functions | else
if (ssl)
{
luaL_error(L, "ssl is not supported on micro version.");
} |
functions | int tcpd_conn_close(lua_State *L)
{
Conn *conn = luaL_checkudata(L, 1, LUA_TCPD_CONNECTION_TYPE);
if (event_mgr_base_current() && conn->buf)
{
bufferevent_free(conn->buf);
conn->buf = NULL;
} |
functions | FAN_HAS_OPENSSL
if (conn->sslctx)
{
conn->sslctx->retainCount--;
if (conn->sslctx->retainCount <= 0)
{
lua_pushnil(L);
lua_setfield(L, LUA_REGISTRYINDEX, conn->sslctx->key);
SSL_CTX_free(conn->sslctx->ssl_ctx);
free(conn->sslctx->key);
} |
functions | int tcpd_conn_gc(lua_State *L) { return tcpd_conn_close(L); } |
functions | int tcpd_accept_remote(lua_State *L)
{
ACCEPT *accept = luaL_checkudata(L, 1, LUA_TCPD_ACCEPT_TYPE);
lua_newtable(L);
lua_pushstring(L, accept->ip);
lua_setfield(L, -2, "ip");
lua_pushinteger(L, accept->port);
lua_setfield(L, -2, "port");
return 1;
} |
functions | int tcpd_accept_original_dst(lua_State *L)
{
ACCEPT *accept = luaL_checkudata(L, 1, LUA_TCPD_ACCEPT_TYPE);
evutil_socket_t fd = bufferevent_getfd(accept->buf);
struct sockaddr_storage ss;
socklen_t len = sizeof(struct sockaddr_storage);
if (getsockopt(fd, SOL_IP, SO_ORIGINAL_DST, &ss, &len))
{
lua_push... |
functions | else if (ss.ss_family == AF_INET6)
{
struct sockaddr_in6 *addr_in = (struct sockaddr_in6 *)&ss;
port = ntohs(((struct sockaddr_in6 *)&ss)->sin6_port);
inet_ntop(addr_in->sin6_family, (void *)&(addr_in->sin6_addr), host,
INET6_ADDRSTRLEN);
} |
functions | int tcpd_accept_getsockname(lua_State *L)
{
ACCEPT *accept = luaL_checkudata(L, 1, LUA_TCPD_ACCEPT_TYPE);
evutil_socket_t fd = bufferevent_getfd(accept->buf);
struct sockaddr_storage ss;
socklen_t len = sizeof(struct sockaddr_storage);
if (getsockname(fd, (struct sockaddr *)&ss, &len))
{
lua_pushnil(L)... |
functions | else if (ss.ss_family == AF_INET6)
{
struct sockaddr_in6 *addr_in = (struct sockaddr_in6 *)&ss;
port = ntohs(((struct sockaddr_in6 *)&ss)->sin6_port);
inet_ntop(addr_in->sin6_family, (void *)&(addr_in->sin6_addr), host,
INET6_ADDRSTRLEN);
} |
functions | int tcpd_accept_close(lua_State *L)
{
ACCEPT *accept = luaL_checkudata(L, 1, LUA_TCPD_ACCEPT_TYPE);
if (event_mgr_base_current() && accept->buf)
{
bufferevent_free(accept->buf);
accept->buf = NULL;
} |
functions | int lua_tcpd_accept_gc(lua_State *L) { return tcpd_accept_close(L); } |
functions | int tcpd_accept_read_pause(lua_State *L)
{
ACCEPT *accept = luaL_checkudata(L, 1, LUA_TCPD_ACCEPT_TYPE);
if (accept->buf)
{
bufferevent_disable(accept->buf, EV_READ);
} |
functions | int tcpd_accept_read_resume(lua_State *L)
{
ACCEPT *accept = luaL_checkudata(L, 1, LUA_TCPD_ACCEPT_TYPE);
if (accept->buf)
{
bufferevent_enable(accept->buf, EV_READ);
} |
functions | int tcpd_conn_read_pause(lua_State *L)
{
Conn *conn = luaL_checkudata(L, 1, LUA_TCPD_CONNECTION_TYPE);
if (conn->buf)
{
bufferevent_disable(conn->buf, EV_READ);
} |
functions | int tcpd_conn_read_resume(lua_State *L)
{
Conn *conn = luaL_checkudata(L, 1, LUA_TCPD_CONNECTION_TYPE);
if (conn->buf)
{
bufferevent_enable(conn->buf, EV_READ);
} |
functions | int tcpd_conn_send(lua_State *L)
{
Conn *conn = luaL_checkudata(L, 1, LUA_TCPD_CONNECTION_TYPE);
size_t len = 0;
const char *data = luaL_checklstring(L, 2, &len);
if (data && len > 0 && conn->buf)
{
if (conn->read_timeout > 0)
{
struct timeval tv1;
d2tv(conn->read_timeout, &tv1);
if... |
functions | int tcpd_conn_reconnect(lua_State *L)
{
Conn *conn = luaL_checkudata(L, 1, LUA_TCPD_CONNECTION_TYPE);
luatcpd_reconnect(conn);
return 0;
} |
functions | int tcpd_accept_flush(lua_State *L)
{
ACCEPT *accept = luaL_checkudata(L, 1, LUA_TCPD_ACCEPT_TYPE);
int mode = luaL_optinteger(L, 2, BEV_NORMAL);
lua_pushinteger(L, bufferevent_flush(accept->buf, EV_WRITE, mode));
return 1;
} |
functions | int tcpd_accept_send(lua_State *L)
{
ACCEPT *accept = luaL_checkudata(L, 1, LUA_TCPD_ACCEPT_TYPE);
size_t len = 0;
const char *data = luaL_checklstring(L, 2, &len);
if (data && len > 0 && accept->buf)
{
bufferevent_write(accept->buf, data, len);
size_t total = evbuffer_get_length(bufferevent_get_outp... |
functions | int luaopen_fan_tcpd(lua_State *L)
{
#if FAN_HAS_OPENSSL
conn_index = SSL_get_ex_new_index(0, "conn_index", NULL, NULL, NULL);
#endif
luaL_newmetatable(L, LUA_TCPD_CONNECTION_TYPE);
lua_pushcfunction(L, &tcpd_conn_send);
lua_setfield(L, -2, "send");
lua_pushcfunction(L, &tcpd_conn_read_pause);
lua_setfie... |
includes | #include <stdint.h> |
includes |
#include <xc.h> |
includes | #include <system.h> |
includes | #include <system_config.h> |
includes | #include <usb/usb.h> |
includes |
#include <xc.h> |
functions | void SYSTEM_Initialize( SYSTEM_STATE state )
{
//On the PIC24FJ64GB004 Family of USB microcontrollers, the PLL will not power up and be enabled
//by default, even if a PLL enabled oscillator configuration is selected (such as HS+PLL).
//This allows the device to power up at a lower initial operating frequen... |
includes | #include <stdio.h> |
includes | #include <stdlib.h> |
includes | #include <sys/types.h> |
includes | #include <errno.h> |
includes | #include <string.h> |
includes | #include <fcntl.h> |
includes | #include <unistd.h> |
includes | #include <dirent.h> |
functions | int dbr_refresh_object(const char *schema,
const char *ora_type,
const char *object,
time_t last_ddl_time) {
char object_with_suffix[300];
// convert oracle type to filesystem type
char *fs_type = strdup(ora_type);
... |
functions | int dbr_delete_obsolete() {
#ifdef _MSC_VER
logmsg(LOG_ERROR, "dbr_delete_obsolete() - this function is not yet implemented for Windows platform!");
return EXIT_FAILURE;
#else
char cache_fn[4096];
DIR *dir = opendir(g_conf._temppath);
if (dir == NULL) {
logmsg(LOG_ERROR, "dbr_delete_obsolete() - ... |
functions | int dbr_refresh_cache() {
int retval = EXIT_SUCCESS;
const char *query =
"select o.owner, o.object_type, o.object_name, \
to_char(o.last_ddl_time, 'yyyy-mm-dd hh24:mi:ss') as last_ddl_time\
from all_objects o\
where generated='N'\
and (o.object_type != 'TYPE' or o.subobject_name IS NULL)\
and object_type I... |
functions | int
fetchint(uint addr, int *ip)
{
if(addr >= curr_proc->sz || addr+4 > curr_proc->sz)
return -1;
*ip = *(int*)(addr);
return 0;
} |
functions | int
fetchstr(uint addr, char **pp)
{
char *s, *ep;
if(addr >= curr_proc->sz)
return -1;
*pp = (char*)addr;
ep = (char*)curr_proc->sz;
for(s = *pp; s < ep; s++)
if(*s == 0)
return s - *pp;
return -1;
} |
functions | int
argint(int n, int *ip)
{
return fetchint(curr_proc->tf->sp + 4*n, ip);
} |
functions | int
argptr(int n, char **pp, int size)
{
int i;
if(argint(n, &i) < 0)
return -1;
if((uint)i >= curr_proc->sz || (uint)i+size > curr_proc->sz)
return -1;
*pp = (char*)i;
return 0;
} |
functions | int
argstr(int n, char **pp)
{
int addr;
if(argint(n, &addr) < 0)
return -1;
return fetchstr(addr, pp);
} |
functions | void
syscall(void)
{
int num;
num = curr_proc->tf->r0;
if(num > 0 && num < NELEM(syscalls) && syscalls[num]) {
// cprintf("\n%d %s: sys call %d syscall address %x\n",
// curr_proc->pid, curr_proc->name, num, syscalls[num]);
if(num == SYS_exec) {
if(syscalls[num]() == -1) curr_proc->tf->r0 = -... |
includes | #include <stdlib.h> |
defines |
#define LOG_FUNCTION_START(fmt, ...) \
|
defines | #define LOG_FUNCTION_END(status, ...) \
|
defines | #define LOG_FUNCTION_END_FMT(status, fmt, ...) \
|
functions | VL53L0X_Error VL53L0X_check_part_used(VL53L0X_DEV Dev,
uint8_t *Revision,
VL53L0X_DeviceInfo_t *pVL53L0X_DeviceInfo) {
VL53L0X_Error Status = VL53L0X_ERROR_NONE;
uint8_t ModuleIdInt;
char *ProductId_tmp;
LOG_FUNCTION_START("");
Status = VL53L0X_get_info_from_device(Dev, 2)... |
functions | VL53L0X_Error VL53L0X_get_device_info(VL53L0X_DEV Dev,
VL53L0X_DeviceInfo_t *pVL53L0X_DeviceInfo) {
VL53L0X_Error Status = VL53L0X_ERROR_NONE;
uint8_t revision_id;
uint8_t Revision;
Status = VL53L0X_check_part_used(Dev, &Revision, pVL53L0X_DeviceInfo);
if (Status == VL53L0X_ERROR_N... |
functions | else if (Revision < 39) {
VL53L0X_COPYSTRING(pVL53L0X_DeviceInfo->Name,
VL53L0X_STRING_DEVICE_INFO_NAME_TS2);
} |
functions | VL53L0X_Error VL53L0X_get_device_error_string(VL53L0X_DeviceError ErrorCode,
char *pDeviceErrorString) {
VL53L0X_Error Status = VL53L0X_ERROR_NONE;
LOG_FUNCTION_START("");
switch (ErrorCode) {
case VL53L0X_DEVICEERROR_NONE:
VL53L0X_COPYSTRING(pDeviceErrorString,
... |
functions | VL53L0X_Error VL53L0X_get_range_status_string(uint8_t RangeStatus,
char *pRangeStatusString) {
VL53L0X_Error Status = VL53L0X_ERROR_NONE;
LOG_FUNCTION_START("");
switch (RangeStatus) {
case 0:
VL53L0X_COPYSTRING(pRangeStatusString,
VL53L0X_STRING_RA... |
functions | VL53L0X_Error VL53L0X_get_pal_error_string(VL53L0X_Error PalErrorCode,
char *pPalErrorString) {
VL53L0X_Error Status = VL53L0X_ERROR_NONE;
LOG_FUNCTION_START("");
switch (PalErrorCode) {
case VL53L0X_ERROR_NONE:
VL53L0X_COPYSTRING(pPalErrorString,
V... |
functions | VL53L0X_Error VL53L0X_get_pal_state_string(VL53L0X_State PalStateCode,
char *pPalStateString) {
VL53L0X_Error Status = VL53L0X_ERROR_NONE;
LOG_FUNCTION_START("");
switch (PalStateCode) {
case VL53L0X_STATE_POWERDOWN:
VL53L0X_COPYSTRING(pPalStateString,
... |
functions | VL53L0X_Error VL53L0X_get_sequence_steps_info(
VL53L0X_SequenceStepId SequenceStepId,
char *pSequenceStepsString) {
VL53L0X_Error Status = VL53L0X_ERROR_NONE;
LOG_FUNCTION_START("");
switch (SequenceStepId) {
case VL53L0X_SEQUENCESTEP_TCC:
VL53L0X_COPYSTRING(pSeq... |
functions | VL53L0X_Error VL53L0X_get_limit_check_info(VL53L0X_DEV Dev, uint16_t LimitCheckId,
char *pLimitCheckString) {
VL53L0X_Error Status = VL53L0X_ERROR_NONE;
LOG_FUNCTION_START("");
switch (LimitCheckId) {
case VL53L0X_CHECKENABLE_SIGMA_FINAL_RANGE:
VL53L0X_COPYSTRING(pLimit... |
includes | #include <stdio.h> |
includes | #include <stdlib.h> |
includes | #include <string.h> |
includes | #include <unistd.h> |
includes | #include <sys/types.h> |
includes | #include <sys/stat.h> |
includes | #include <sys/dir.h> |
includes | #include <io.h> |
defines | #define D_GNU_SOURCE
|
defines | #define _GNU_SOURCE
|
functions | int isDir(const char* path)
{
struct stat st;
lstat(path, &st);
return S_ISDIR(st.st_mode);
} |
functions | int doTraversal(const char *path, int recursive,file_callback xCallback,void * usr)
{
DIR *pdir;
struct dirent *pdirent;
char tmp[1024];
pdir = opendir(path);
if(pdir)
{
while((pdirent = readdir(pdir)) != 0)
{
//ignore "." && ".."
if(!strcmp(pdirent->d_name, ".")||
!strcmp(pdirent->d_nam... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.