elemy-utils 1.0.0
Macros | Functions | Variables
el_utils.c File Reference
#include <unistd.h>
#include <errno.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <byteswap.h>
#include <time.h>
#include <malloc.h>
#include <termios.h>
#include <signal.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <netdb.h>
#include <sys/param.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>
#include <pthread.h>
#include <sys/resource.h>
#include "elutils/el_utils.h"
Include dependency graph for el_utils.c:

Macros

#define _GNU_SOURCE
 STDERR_FILENO, tcsetattr, sysconf(_SC_PAGESIZE) ... More...
 
#define TEST_ALLOC(PARA, POLE)   if (PARA->POLE == NULL) { free(par_d); free(pars); free_conn_param(PARA); return NULL; }
 
#define BUF_SZ   (1024)
 
#define INDENT_SIZE   (4)
 retutn string of length INDENT_SIZE * level More...
 

Functions

void el_init_rw_shared_attr (void)
 
void el_destroy_rw_shared_attr (void)
 
pthread_rwlockattr_t * el_get_rw_shared_attr (void)
 
void __attach (void)
 
void __detach (void)
 
size_t strlcpy (char *dest, const char *src, size_t dest_size)
 
int set_stdin_nowait_cr (int nowait)
 
void restore_stdin_cr (void)
 
void set_restore_stdin_cr (void)
 
void termination_handler (int signum)
 
void el_set_ctrlc_exit (int ex)
 if parameter != 0 set var to TRUE: on Ctrl-C exit. if == 0 dsont exit. More...
 
void el_set_ctrlc_param (void *arg)
 
void el_set_ctrlc_call (el_ctrlc_call_t arg)
 
void termination_sigaction (int signum, siginfo_t *siginfo, void *param)
 
void set_termination_action (void)
 
int get_serial_stat (int fd)
 
void set_serial_stat (int fd, int serial)
 
int get_serial_dtr (int fd)
 
char * get_serial_dtr_s (int fd)
 
int get_serial_dsr (int fd)
 
char * get_serial_dsr_s (int fd)
 
int get_serial_rts (int fd)
 
char * get_serial_rts_s (int fd)
 
int get_serial_cts (int fd)
 
char * get_serial_cts_s (int fd)
 
int get_serial_cd (int fd)
 
char * get_serial_cd_s (int fd)
 
void show_serial_stat (int fd)
 
void set_serial_stat_ln (int fd, int ln_bt, int val)
 
char ** split_string (char *str, char delim, int *number)
 split string into words by delimeter, heading/trailing WhiteSpaces prohibited, possible empty words s = " ss,bb,cc,zz,,qq\0" ps_split_str(s, ',', 5, &cnt); ->{"ss", "bb", "cc", "zz", "", 0} ",ss," -> {"", "ss", "", 0} More...
 
int cnt_splited_strings (char **ss)
 
void dbg_string_list (char **string_list)
 show NULL terminated list (array) of strings More...
 
char * get_family_name (int family)
 return name of IPvX family More...
 
char * get_sock_type_name (int sock_type)
 
int validate_ip_addr (const char *ip_addr)
 check is string is IPv4 or IPv6 or smth else More...
 
int test_connect (struct addrinfo *ai_ptr, int *err)
 
int test_bind (struct addrinfo *ai_ptr, int *err)
 
void show_sa (struct sockaddr *sa, char *buf, int buf_sz)
 
void show_ai_list (struct addrinfo *ai_list)
 
struct addrinfo * tcp_get_addr_info (char *addr, char *service, int family, int slave, int *err)
 
int max_sockadddr_sz (void)
 
int conn_nonb (int fd, struct sockaddr *sa, int sa_len, uint64_t timeout, int *err)
 
int check_rs_speed (int sp)
 
conn_params_tparse_conn_params (char *params)
 parch string with connection parameters and fill struct conn_param_t More...
 
void free_conn_param (conn_params_t *c_p)
 
int fill_sockaddr_sinx (conn_params_t *c_p, int *err)
 
const char * argp_std_key_name (int par)
 
int wait_read_fd (int fd, uint64_t timeout, int *err)
 wait ready for read More...
 
int wait_write_fd (int fd, uint64_t timeout, int *err)
 
int bytes_of_bits (int bits)
 
char * conn_role_name (int cr)
 
void setnonblocking (int sock)
 
void set_fd_cloexec (int fd)
 
int set_reuseaddr (int fd)
 
char * time64_to_str (uint64_t tm, char *buf)
 
const char * ps_error_text (int error)
 
int press_enter (char *msg, char *cmp_str)
 
int file_check_exist (char *fl_name)
 check file More...
 
int64_t file_fd_size (int fd)
 
int64_t file_size (const char *filename)
 
int parse_array (void *dst, void *src, int cnt, int sz)
 parse array of strings values into array of 'sz' size elements More...
 
int pid_exist (pid_t pid)
 check existance process(thread) with pid More...
 
void * el_compare_mem_prepare (void *mem, int mem_sz)
 
int el_compare_mem_do (void *mem, int mem_sz, void *copy)
 
long ps_pagesize (void)
 
void ps_meminfo (long *page_sz, long *shmem_sz, long *data_sz, long *stack_sz)
 
void read_off_memory_status (statm_t *result)
 
uint16_t modbus_crc16 (uint8_t *buffer, uint16_t buffer_length)
 
int ps_put_mem (char *file_name, void *mem_ptr, int mem_sz)
 put memory to file More...
 
char * get_n_bytes (const char *str, int pos, int cnt)
 malloc buf of cnt+1 bytes and cope there bytes from str+pos AS IS More...
 
char * find_free_name_num (char *name)
 
char * mk_indent (int level)
 
void free_array (void **arr, int cnt)
 
char * build_msg_with_prev (const char *prev_msg, const char *format,...)
 

Variables

static uint64_t start_tm
 < bswap_16(x);bswap_32(x);bswap_64(x); More...
 
static pthread_rwlockattr_t rwl_shared_attr
 
static pthread_rwlockattr_t * rwl_shared_attr_ptr = NULL
 
static int el_ctrlc_exit = 1
 Attributes around Ctrl-C called func. More...
 
static el_ctrlc_call_t el_ctrlc_call = NULL
 
static void * el_ctrlc_call_param = NULL
 
static char * DEFAULT_PORT = "502"
 get list of addrs parameters for pair address/port More...
 
static const uint8_t table_crc_hi [] = { 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 }
 
static const uint8_t table_crc_lo [] = { 0x00, 0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0xB7, 0xB6, 0x76, 0x72, 0xB2, 0xB3, 0x73, 0xB1, 0x71, 0x70, 0xB0, 0x50, 0x90, 0x91, 0x51, 0x93, 0x53, 0x52, 0x92, 0x96, 0x56, 0x57, 0x97, 0x55, 0x95, 0x94, 0x54, 0x9C, 0x5C, 0x5D, 0x9D, 0x5F, 0x9F, 0x9E, 0x5E, 0x5A, 0x9A, 0x9B, 0x5B, 0x99, 0x59, 0x58, 0x98, 0x88, 0x48, 0x49, 0x89, 0x4B, 0x8B, 0x8A, 0x4A, 0x4E, 0x8E, 0x8F, 0x4F, 0x8D, 0x4D, 0x4C, 0x8C, 0x44, 0x84, 0x85, 0x45, 0x87, 0x47, 0x46, 0x86, 0x82, 0x42, 0x43, 0x83, 0x41, 0x81, 0x80, 0x40 }
 
static char * indent_strings []
 

Detailed Description

el_utils.c

Utility for project

Created on: 11 мар. 2023 г. Author: ps

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

STDERR_FILENO, tcsetattr, sysconf(_SC_PAGESIZE) ...

for 'bool' type

◆ BUF_SZ

#define BUF_SZ   (1024)

◆ INDENT_SIZE

#define INDENT_SIZE   (4)

retutn string of length INDENT_SIZE * level

up to 4 level

◆ TEST_ALLOC

#define TEST_ALLOC (   PARA,
  POLE 
)    if (PARA->POLE == NULL) { free(par_d); free(pars); free_conn_param(PARA); return NULL; }

Function Documentation

◆ __attach()

void __attach ( void  )

◆ __detach()

void __detach ( void  )
Here is the call graph for this function:

◆ argp_std_key_name()

const char * argp_std_key_name ( int  par)

◆ build_msg_with_prev()

char * build_msg_with_prev ( const char *  prev_msg,
const char *  format,
  ... 
)

◆ bytes_of_bits()

int bytes_of_bits ( int  bits)

◆ check_rs_speed()

int check_rs_speed ( int  sp)

check speed in available

Parameters
sptesting speed
Returns
-1 if wrong speed else speed.

◆ cnt_splited_strings()

int cnt_splited_strings ( char **  ss)

◆ conn_nonb()

int conn_nonb ( int  fd,
struct sockaddr *  sa,
int  sa_len,
uint64_t  timeout,
int *  err 
)
Here is the caller graph for this function:

◆ conn_role_name()

char * conn_role_name ( int  cr)

◆ dbg_string_list()

void dbg_string_list ( char **  string_list)

show NULL terminated list (array) of strings

◆ el_compare_mem_do()

int el_compare_mem_do ( void *  mem,
int  mem_sz,
void *  copy 
)

◆ el_compare_mem_prepare()

void * el_compare_mem_prepare ( void *  mem,
int  mem_sz 
)

funcs detect side effect after activity

used to detect side effect after any activity with memoty block. Using: at first copy memory into malloced block. then do smth. at end compare to blocks.

pthread_rwlockattr_t *ppp = el_get_rw_shared_attr();
void *zzz = COMPARE_MEM_PREPARE(ppp);
pthread_rwlock_init(&main_shmem->shm_rwl, ppp)
COMPARE_MEM_DO(ppp, zzz);
pthread_rwlockattr_t * el_get_rw_shared_attr(void)
Definition: el_utils.c:63
#define COMPARE_MEM_PREPARE(MEMAS)
Definition: el_utils.h:418
#define COMPARE_MEM_DO(MEMAS, COPY)
Definition: el_utils.h:419

first ''el_compare_mem_prepare'' return malloced block or NULL on error (ENOMEM) second ''el_compare_mem_do'' compare blocks end return 1 if differ, 0 if not or prepare bad (really impossible).

◆ el_destroy_rw_shared_attr()

void el_destroy_rw_shared_attr ( void  )
Here is the caller graph for this function:

◆ el_get_rw_shared_attr()

pthread_rwlockattr_t * el_get_rw_shared_attr ( void  )

◆ el_init_rw_shared_attr()

void el_init_rw_shared_attr ( void  )
Here is the call graph for this function:

◆ el_set_ctrlc_call()

void el_set_ctrlc_call ( el_ctrlc_call_t  arg)

◆ el_set_ctrlc_exit()

void el_set_ctrlc_exit ( int  ex)

if parameter != 0 set var to TRUE: on Ctrl-C exit. if == 0 dsont exit.

◆ el_set_ctrlc_param()

void el_set_ctrlc_param ( void *  arg)

◆ file_check_exist()

int file_check_exist ( char *  fl_name)

check file

Parameters
fl_namefile name
Returns
1 - exist 0 - not exist (ENOENT) removed -1 - error
Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_fd_size()

int64_t file_fd_size ( int  fd)
Returns
file size from descriptor or -1 on error
Here is the call graph for this function:

◆ file_size()

int64_t file_size ( const char *  filename)

◆ fill_sockaddr_sinx()

int fill_sockaddr_sinx ( conn_params_t c_p,
int *  err 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_free_name_num()

char * find_free_name_num ( char *  name)

\grief search fist free name for mask <name>_NNNN

Parameters
namemasndastory part of file name
Returns
ptr to malloced free file name

on parameter give file name like "[[/]path_to_file/]this_is_filer_name" return first (no more then 999) free file name like "this_is_filer_name_25"

Here is the call graph for this function:

◆ free_array()

void free_array ( void **  arr,
int  cnt 
)

◆ free_conn_param()

void free_conn_param ( conn_params_t c_p)
Here is the caller graph for this function:

◆ get_family_name()

char * get_family_name ( int  family)

return name of IPvX family

Parameters
familyas in socket(), getaddrinfo()
Here is the caller graph for this function:

◆ get_n_bytes()

char * get_n_bytes ( const char *  str,
int  pos,
int  cnt 
)

malloc buf of cnt+1 bytes and cope there bytes from str+pos AS IS

Parameters
strstring for work
posstart of substring
cntnumber of bytes to copy return ptr to created buffer with substring else NULL on error

return string MUST BE FREED

◆ get_serial_cd()

int get_serial_cd ( int  fd)
Here is the call graph for this function:

◆ get_serial_cd_s()

char * get_serial_cd_s ( int  fd)
Here is the call graph for this function:

◆ get_serial_cts()

int get_serial_cts ( int  fd)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_serial_cts_s()

char * get_serial_cts_s ( int  fd)
Here is the call graph for this function:

◆ get_serial_dsr()

int get_serial_dsr ( int  fd)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_serial_dsr_s()

char * get_serial_dsr_s ( int  fd)
Here is the call graph for this function:

◆ get_serial_dtr()

int get_serial_dtr ( int  fd)

get fd return 0/1 status of signal/line dtr,rts,cts...

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_serial_dtr_s()

char * get_serial_dtr_s ( int  fd)
Here is the call graph for this function:

◆ get_serial_rts()

int get_serial_rts ( int  fd)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_serial_rts_s()

char * get_serial_rts_s ( int  fd)
Here is the call graph for this function:

◆ get_serial_stat()

int get_serial_stat ( int  fd)
Here is the caller graph for this function:

◆ get_sock_type_name()

char * get_sock_type_name ( int  sock_type)
Here is the caller graph for this function:

◆ max_sockadddr_sz()

int max_sockadddr_sz ( void  )
Returns
max size of sockaddr

◆ mk_indent()

char * mk_indent ( int  level)

◆ modbus_crc16()

uint16_t modbus_crc16 ( uint8_t *  buffer,
uint16_t  buffer_length 
)

◆ parse_array()

int parse_array ( void *  dst,
void *  src,
int  cnt,
int  sz 
)

parse array of strings values into array of 'sz' size elements

◆ parse_conn_params()

conn_params_t * parse_conn_params ( char *  params)

parch string with connection parameters and fill struct conn_param_t

configure connection parameters id,slave,slave_id,tcp,pes70.ru,1331 id,master,tcp,1.2.3.4,1331 id,slave,slave_id,tcp,::1,1331 id,master,rs,/dev/ttyUSB1,57600[,CD,DTR,DSR,CTS,RTS]

Returns
ptr to allocated parameters. or NULL in error (ENOMEM or bardak in params)
Here is the call graph for this function:

◆ pid_exist()

int pid_exist ( pid_t  pid)

check existance process(thread) with pid

Parameters
pidprocess/thread ID as getpid/gettid
Returns
1 - exist, 0 - absent,
Here is the call graph for this function:

◆ press_enter()

int press_enter ( char *  msg,
char *  cmp_str 
)

◆ ps_error_text()

const char * ps_error_text ( int  error)
Here is the caller graph for this function:

◆ ps_meminfo()

void ps_meminfo ( long *  page_sz,
long *  shmem_sz,
long *  data_sz,
long *  stack_sz 
)

dont wotrk properly

◆ ps_pagesize()

long ps_pagesize ( void  )
Here is the caller graph for this function:

◆ ps_put_mem()

int ps_put_mem ( char *  file_name,
void *  mem_ptr,
int  mem_sz 
)

put memory to file

Parameters
f_nptr to file name
memptr to memory area
mem_szarea size return 0 success -1 error

◆ read_off_memory_status()

void read_off_memory_status ( statm_t result)
Here is the call graph for this function:

◆ restore_stdin_cr()

void restore_stdin_cr ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_fd_cloexec()

void set_fd_cloexec ( int  fd)

◆ set_restore_stdin_cr()

void set_restore_stdin_cr ( void  )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_reuseaddr()

int set_reuseaddr ( int  fd)

◆ set_serial_stat()

void set_serial_stat ( int  fd,
int  serial 
)

◆ set_serial_stat_ln()

void set_serial_stat_ln ( int  fd,
int  ln_bt,
int  val 
)

◆ set_stdin_nowait_cr()

int set_stdin_nowait_cr ( int  nowait)

IF nowait THEN disable wait 'CR' ELSE restore old settings

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_termination_action()

void set_termination_action ( void  )
Here is the call graph for this function:

◆ setnonblocking()

void setnonblocking ( int  sock)

◆ show_ai_list()

void show_ai_list ( struct addrinfo *  ai_list)
Here is the call graph for this function:

◆ show_sa()

void show_sa ( struct sockaddr *  sa,
char *  buf,
int  buf_sz 
)
Parameters
saptr to sockaddr
bufmust be enough for addr:port for IPv4/IPv6
buf_szsize of buf

◆ show_serial_stat()

void show_serial_stat ( int  fd)
Here is the call graph for this function:

◆ split_string()

char ** split_string ( char *  str,
char  delim,
int *  number 
)

split string into words by delimeter, heading/trailing WhiteSpaces prohibited, possible empty words s = " ss,bb,cc,zz,,qq\0" ps_split_str(s, ',', 5, &cnt); ->{"ss", "bb", "cc", "zz", "", 0} ",ss," -> {"", "ss", "", 0}

Returns
ptr to slovar, NULL on error. Malloced place for array for ALL fields. Return pts (and change string) no more then *number fields if *number != 0. SLOVAR )-TERMINALTED ARRAY OG STREING PTRS

function change str caller MUST free return ptr

Here is the caller graph for this function:

◆ strlcpy()

size_t strlcpy ( char *  dest,
const char *  src,
size_t  dest_size 
)

◆ tcp_get_addr_info()

struct addrinfo * tcp_get_addr_info ( char *  addr,
char *  service,
int  family,
int  slave,
int *  err 
)

as default use port 502

Here is the caller graph for this function:

◆ termination_handler()

void termination_handler ( int  signum)
Here is the call graph for this function:

◆ termination_sigaction()

void termination_sigaction ( int  signum,
siginfo_t *  siginfo,
void *  param 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_bind()

int test_bind ( struct addrinfo *  ai_ptr,
int *  err 
)
Here is the caller graph for this function:

◆ test_connect()

int test_connect ( struct addrinfo *  ai_ptr,
int *  err 
)
Returns
-1 error, system error in *err ; error from socket and connect 0 all right
Here is the call graph for this function:
Here is the caller graph for this function:

◆ time64_to_str()

char * time64_to_str ( uint64_t  tm,
char *  buf 
)

convert uint64_t timestump to time string

Parameters
tmIN - timestump in nanosec
bufIN - buffer for date string, If NULL - malloc it
Returns
ptr to buf

◆ validate_ip_addr()

int validate_ip_addr ( const char *  ip_addr)

check is string is IPv4 or IPv6 or smth else

Get string with IP address

Returns
IT_NOT_IP, IT_IPV4, IT_IPV6

◆ wait_read_fd()

int wait_read_fd ( int  fd,
uint64_t  timeout,
int *  err 
)

wait ready for read

Returns
-1: error (*err - errorcode), 0 - timeout, 1 - ready this fd

◆ wait_write_fd()

int wait_write_fd ( int  fd,
uint64_t  timeout,
int *  err 
)

Variable Documentation

◆ DEFAULT_PORT

char* DEFAULT_PORT = "502"
static

get list of addrs parameters for pair address/port

Parameters
addr- ptr to ip_r/ip_dr_v6/FQDN. NULL - any (used in server/slave)
service- port as string/service name. if NULL - default 502
family- set address family to look. AF_INET, AF_INET6, AF_UNSPEC (for both)
Returns
ptr to addrinfo-s

For server addr must be NULL, then will be setted flag ai_hints.ai_flags |= AI_PASSIVE; IF ADDR == NULL that means return addresses available to bind().

ai_hints.ai_flags |= AI_ADDRCONFIG; //exclude not existing protocol (IPv4/IPv6) from addr list Else return addresses avaiilable to connect()

for free result use freeaddrinfo(GAI_ai_list);

◆ el_ctrlc_call

el_ctrlc_call_t el_ctrlc_call = NULL
static

◆ el_ctrlc_call_param

void* el_ctrlc_call_param = NULL
static

◆ el_ctrlc_exit

int el_ctrlc_exit = 1
static

Attributes around Ctrl-C called func.

To call ''typedef void (*el_ctrlc_call_t)(void *ar);'' func at Ctrl-C: Set Ctrl-C-called func param by ''void el_set_ctrlc_param(void *arg)'' Set Ctrl-C-called func by ''void el_set_ctrlc_call(el_ctrlc_call_t arg)'' Press Ctrl-C

To change behaviour of Ctrl-C use ''void el_set_ctrlc_exit(int ex);''. If (ex != 0) then on Ctrl-C exit; else not exit.

◆ indent_strings

char* indent_strings[]
static
Initial value:
= {
"",
" ",
" ",
" ",
" "
}

◆ rwl_shared_attr

pthread_rwlockattr_t rwl_shared_attr
static

◆ rwl_shared_attr_ptr

pthread_rwlockattr_t* rwl_shared_attr_ptr = NULL
static

◆ start_tm

uint64_t start_tm
static

< bswap_16(x);bswap_32(x);bswap_64(x);

◆ table_crc_hi

const uint8_t table_crc_hi[] = { 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40 }
static

◆ table_crc_lo

const uint8_t table_crc_lo[] = { 0x00, 0xC0, 0xC1, 0x01, 0xC3, 0x03, 0x02, 0xC2, 0xC6, 0x06, 0x07, 0xC7, 0x05, 0xC5, 0xC4, 0x04, 0xCC, 0x0C, 0x0D, 0xCD, 0x0F, 0xCF, 0xCE, 0x0E, 0x0A, 0xCA, 0xCB, 0x0B, 0xC9, 0x09, 0x08, 0xC8, 0xD8, 0x18, 0x19, 0xD9, 0x1B, 0xDB, 0xDA, 0x1A, 0x1E, 0xDE, 0xDF, 0x1F, 0xDD, 0x1D, 0x1C, 0xDC, 0x14, 0xD4, 0xD5, 0x15, 0xD7, 0x17, 0x16, 0xD6, 0xD2, 0x12, 0x13, 0xD3, 0x11, 0xD1, 0xD0, 0x10, 0x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