Enumerations

bconfig_type

enum bconfig\_type {

block_io_err_cause

enum block\_io\_err\_cause {

cf_class

enum cf\_class {

cf_operation

enum cf\_operation { CF\_OPERATIONS };

cf_type

enum cf\_type {

crc_mode

enum crc\_mode {

daemon_flags

enum daemon\_flags {

fb_flags

enum fb\_flags {

fb_type

enum fb\_type {

fbsock_err_flags

enum fbsock\_err\_flags {

log_file_flag

enum log\_file\_flag {

log_levels

enum log\_levels {

ls_flag

enum ls\_flag {

ls_fmt

enum ls\_fmt {

main_hook_return

enum main\_hook\_return {

rec_io_notify_status

enum rec\_io\_notify\_status {

resource_flags

enum resource\_flags {

size_units

enum size\_units {

xtype_fmt

enum xtype\_fmt {

Structures

BUF_T

typedef struct BUF\_T {

bh_heap

struct bh\_heap {

bh_node

struct bh\_node {

cf_item

struct cf\_item {

cf_journal_item

struct cf\_journal\_item;

cf_section

struct cf\_section {

cf_user_type

struct cf\_user\_type {

clist

typedef struct clist {

cnode

typedef struct cnode {

crc32_context

typedef struct crc32\_context {

daemon_control_params

struct daemon\_control\_params {

daemon_params

struct daemon\_params {

eltpool

struct eltpool {

exception

struct exception {

fastbuf

struct fastbuf {

fb_params

struct fb\_params {

fbpool

struct fbpool {

fbsock_params

struct fbsock\_params {

lizard_buffer

struct lizard\_buffer;

log_msg

struct log\_msg {

log_stream

struct log\_stream {

main_block_io

struct main\_block\_io {

main_context

struct main\_context {

main_file

struct main\_file {

main_hook

struct main\_hook {

main_process

struct main\_process {

main_rec_io

struct main\_rec\_io {

main_signal

struct main\_signal {

main_timer

struct main\_timer {

md5_context

typedef struct { \... } md5\_context;

mempool

struct mempool {

mempool_state

struct mempool\_state {

mempool_stats

struct mempool\_stats {

opt_item

struct opt\_item {

opt_section

struct opt\_section {

res_class

struct res\_class {

resource

struct resource {

respool

struct respool {

sha1_context

typedef struct { \... } sha1\_context;

sha1_hmac_context

typedef struct { \... } sha1\_hmac\_context;

simp2_node

typedef struct simp2\_node {

simp_node

typedef struct simp\_node {

slist

typedef struct slist {

snode

typedef struct snode {

table

struct table {

table_col_instance

struct table\_col\_instance {

table_column

struct table\_column {

table_formatter

struct table\_formatter {

table_template

struct table\_template {

token_bucket_filter

struct token\_bucket\_filter {

trans

struct trans {

ucw_allocator

struct ucw\_allocator {

unit_definition

struct unit\_definition {

xtype

struct xtype {

Types

byte

typedef uint8\_t byte;

cf_copier

typedef char \*cf\_copier(void \*dest, void \*src);

cf_dumper1

typedef void cf\_dumper1(struct fastbuf \*fb, void \*ptr);

cf_hook

typedef char \*cf\_hook(void \*ptr);

cf_parser

typedef char \*cf\_parser(uint number, char \*\*pars, void \*ptr);

cf_parser1

typedef char \*cf\_parser1(char \*string, void \*ptr);

s16

typedef int16\_t s16;

s32

typedef int32\_t s32;

s64

typedef int64\_t s64;

s8

typedef int8\_t s8;

timestamp_t

typedef s64 timestamp\_t;

u16

typedef uint16\_t u16;

u32

typedef uint32\_t u32;

u64

typedef uint64\_t u64;

u8

typedef uint8\_t u8;

ucw_off_t

typedef s64 ucw\_off\_t;

uint

typedef unsigned int uint;

uns

typedef uint uns;

xtype_fmt_formatter

typedef const char \* (\*xtype\_fmt\_formatter)(u32 fmt, struct mempool \*pool);

xtype_fmt_parser

typedef const char \* (\*xtype\_fmt\_parser)(const char \*str, u32 \*dest, struct mempool \*pool);

xtype_formatter

typedef const char \* (\*xtype\_formatter)(void \*src, u32 fmt, struct mempool \*pool);

xtype_parser

typedef const char \* (\*xtype\_parser)(const char \*str, void \*dest, struct mempool \*pool);

Functions

ASORT_PREFIX(sort)

static void ASORT\_PREFIX(sort)(ASORT\_ARRAY\_ARG uint array\_size ASORT\_EXTRA\_ARGS);

ASORT_PREFIX(sort)

static ASORT\_KEY\_TYPE \*ASORT\_PREFIX(sort)(ASORT\_KEY\_TYPE \*array, uint num\_elts ASORT\_HASH\_ARGS);

Cxvalue

static inline uint Cxvalue(byte x);

GBUF_PREFIX(done)

static void UNUSED GBUF\_PREFIX(done)(BUF\_T \*b);

GBUF_PREFIX(grow)

static inline GBUF\_TYPE \*GBUF\_PREFIX(grow)(BUF\_T \*b, size\_t len);

GBUF_PREFIX(init)

static inline void GBUF\_PREFIX(init)(BUF\_T \*b);

GBUF_PREFIX(set_size)

static void UNUSED GBUF\_PREFIX(set\_size)(BUF\_T \*b, size\_t len);

HASH_PREFIX(cleanup)

static void HASH\_PREFIX(cleanup)(TA);

HASH_PREFIX(delete)

static int HASH\_PREFIX(delete)(TAC HASH\_KEY\_DECL);

HASH_PREFIX(find)

static HASH\_NODE\* HASH\_PREFIX(find)(TAC HASH\_KEY\_DECL);

HASH_PREFIX(find_next)

static HASH\_NODE\* HASH\_PREFIX(find\_next)(TAC P(node) \*start);

HASH_PREFIX(init)

static void HASH\_PREFIX(init)(TA);

HASH_PREFIX(lookup)

static HASH\_NODE\* HASH\_PREFIX(lookup)(TAC HASH\_KEY\_DECL, int \*new\_item);

HASH_PREFIX(new)

static HASH\_NODE \* HASH\_PREFIX(new)(TAC HASH\_KEY\_DECL);

HASH_PREFIX(remove)

static void HASH\_PREFIX(remove)(TAC HASH\_NODE \*n);

adler32

static inline uint adler32(const byte \*buf, uint len);

adler32_update

uint adler32\_update(uint adler, const byte \*ptr, uint len);

base224_decode

uint base224\_decode(byte \*dest, const byte \*src, uint len);

base224_encode

uint base224\_encode(byte \*dest, const byte \*src, uint len);

base64_decode

uint base64\_decode(byte \*dest, const byte \*src, uint len);

base64_encode

uint base64\_encode(byte \*dest, const byte \*src, uint len);

bavailr

static inline uint bavailr(struct fastbuf \*f);

bavailw

static inline uint bavailw(struct fastbuf \*f);

bb_printf

char \*bb\_printf(bb\_t \*bb, const char \*fmt, \...);

bb_printf_at

char \*bb\_printf\_at(bb\_t \*bb, size\_t ofs, const char \*fmt, \...);

bb_vprintf

char \*bb\_vprintf(bb\_t \*bb, const char \*fmt, va\_list args);

bb_vprintf_at

char \*bb\_vprintf\_at(bb\_t \*bb, size\_t ofs, const char \*fmt, va\_list args);

bbcopy

static inline void bbcopy(struct fastbuf \*f, struct fastbuf \*t, uint l);

bclose

void bclose(struct fastbuf \*f);

bconfig

int bconfig(struct fastbuf \*f, uint type, int data);

bdirect_read_commit

static inline void bdirect\_read\_commit(struct fastbuf \*f, byte \*pos);

bdirect_read_commit_modified

static inline void bdirect\_read\_commit\_modified(struct fastbuf \*f, byte \*pos);

bdirect_read_prepare

static inline uint bdirect\_read\_prepare(struct fastbuf \*f, byte \*\*buf);

bdirect_write_commit

static inline void bdirect\_write\_commit(struct fastbuf \*f, byte \*pos);

bdirect_write_prepare

static inline uint bdirect\_write\_prepare(struct fastbuf \*f, byte \*\*buf);

beof

static inline int beof(struct fastbuf \*f);

bfdopen

struct fastbuf \*bfdopen(int fd, uint buflen);

bfdopen_shared

struct fastbuf \*bfdopen\_shared(int fd, uint buflen);

bfilesize

ucw\_off\_t bfilesize(struct fastbuf \*f);

bfilesync

void bfilesync(struct fastbuf \*b);

bfix_tmp_file

void bfix\_tmp\_file(struct fastbuf \*fb, const char \*name);

bflush

void bflush(struct fastbuf \*f);

bget_utf16_be

static inline int bget\_utf16\_be(struct fastbuf \*b);

bget_utf16_le

static inline int bget\_utf16\_le(struct fastbuf \*b);

bget_utf8

static inline int bget\_utf8(struct fastbuf \*b);

bget_utf8_32

static inline int bget\_utf8\_32(struct fastbuf \*b);

bgetc

static inline int bgetc(struct fastbuf \*f);

bgets

char \*bgets(struct fastbuf \*f, char \*b, uint l);

bgets0

char \*bgets0(struct fastbuf \*f, char \*b, uint l);

bgets_bb

uint bgets\_bb(struct fastbuf \*f, struct bb\_t \*b, uint limit);

bgets_mp

char \*bgets\_mp(struct fastbuf \*f, struct mempool \*mp);

bgets_nodie

int bgets\_nodie(struct fastbuf \*f, char \*b, uint l);

big_alloc

void \*big\_alloc(u64 len) LIKE\_MALLOC;

big_alloc_zero

void \*big\_alloc\_zero(u64 len) LIKE\_MALLOC;

big_free

void big\_free(void \*start, u64 len);

block_io_add

void block\_io\_add(struct main\_block\_io \*bio, int fd);

block_io_del

void block\_io\_del(struct main\_block\_io \*bio);

block_io_is_active

static inline int block\_io\_is\_active(struct main\_block\_io \*bio);

block_io_read

void block\_io\_read(struct main\_block\_io \*bio, void \*buf, uint len);

block_io_set_timeout

void block\_io\_set\_timeout(struct main\_block\_io \*bio, timestamp\_t expires\_delta);

block_io_write

void block\_io\_write(struct main\_block\_io \*bio, void \*buf, uint len);

bopen

struct fastbuf \*bopen(const char \*name, uint mode, uint buflen);

bopen_fd

static inline struct fastbuf \*bopen\_fd(int fd, struct fb\_params \*params);

bopen_fd_name

struct fastbuf \*bopen\_fd\_name(int fd, struct fb\_params \*params, const char \*name);

bopen_file

struct fastbuf \*bopen\_file(const char \*name, int mode, struct fb\_params \*params);

bopen_file_try

struct fastbuf \*bopen\_file\_try(const char \*name, int mode, struct fb\_params \*params);

bopen_limited_fd

struct fastbuf \*bopen\_limited\_fd(int fd, uint bufsize, uint limit);

bopen_tmp

struct fastbuf \*bopen\_tmp(uint buflen);

bopen_tmp_file

struct fastbuf \*bopen\_tmp\_file(struct fb\_params \*params);

bopen_try

struct fastbuf \*bopen\_try(const char \*name, uint mode, uint buflen);

bpeekc

static inline int bpeekc(struct fastbuf \*f);

bprintf

int bprintf(struct fastbuf \*b, const char \*msg, \...);

bput_utf16_be

static inline void bput\_utf16\_be(struct fastbuf \*b, uint u);

bput_utf16_le

static inline void bput\_utf16\_le(struct fastbuf \*b, uint u);

bput_utf8

static inline void bput\_utf8(struct fastbuf \*b, uint u);

bput_utf8_32

static inline void bput\_utf8\_32(struct fastbuf \*b, uint u);

bputc

static inline void bputc(struct fastbuf \*f, uint c);

bputs

static inline void bputs(struct fastbuf \*f, const char \*b);

bputs0

static inline void bputs0(struct fastbuf \*f, const char \*b);

bputsn

static inline void bputsn(struct fastbuf \*f, const char \*b);

bread

static inline uint bread(struct fastbuf \*f, void \*b, uint l);

breadb

static inline uint breadb(struct fastbuf \*f, void \*b, uint l);

brewind

void brewind(struct fastbuf \*f);

bseek

void bseek(struct fastbuf \*f, ucw\_off\_t pos, int whence);

bsetpos

void bsetpos(struct fastbuf \*f, ucw\_off\_t pos);

bskip

static inline int bskip(struct fastbuf \*f, uint len);

btell

static inline ucw\_off\_t btell(struct fastbuf \*f);

bthrow

void bthrow(struct fastbuf \*f, const char \*id, const char \*fmt, \...) FORMAT\_CHECK(printf,3,4) NONRET;

bungetc

static inline void bungetc(struct fastbuf \*f);

bwrite

static inline void bwrite(struct fastbuf \*f, const void \*b, uint l);

cf_close_group

int cf\_close\_group(void);

cf_declare_rel_section

void cf\_declare\_rel\_section(const char \*name, struct cf\_section \*sec, void \*ptr, uint allow\_unknown);

cf_declare_section

void cf\_declare\_section(const char \*name, struct cf\_section \*sec, uint allow\_unknown);

cf_delete_context

void cf\_delete\_context(struct cf\_context \*cc);

cf_dump_sections

void cf\_dump\_sections(struct fastbuf \*fb);

cf_find_item

char \*cf\_find\_item(const char \*name, struct cf\_item \*item);

cf_get_pool

struct mempool \*cf\_get\_pool(void);

cf_getopt

int cf\_getopt(int argc, char \* const argv[], const char \*short\_opts, const struct option \*long\_opts, int \*long\_index);

cf_init_section

void cf\_init\_section(const char \*name, struct cf\_section \*sec, void \*ptr, uint do\_bzero);

cf_journal_block

void cf\_journal\_block(void \*ptr, uint len);

cf_journal_commit_transaction

void cf\_journal\_commit\_transaction(uint new\_pool, struct cf\_journal\_item \*oldj);

cf_journal_new_transaction

struct cf\_journal\_item \*cf\_journal\_new\_transaction(uint new\_pool);

cf_journal_rollback_transaction

void cf\_journal\_rollback\_transaction(uint new\_pool, struct cf\_journal\_item \*oldj);

cf_load

int cf\_load(const char \*file);

cf_malloc

void \*cf\_malloc(uint size);

cf_malloc_zero

void \*cf\_malloc\_zero(uint size);

cf_modify_item

char \*cf\_modify\_item(struct cf\_item \*item, enum cf\_operation op, int number, char \*\*pars);

cf_new_context

struct cf\_context \*cf\_new\_context(void);

cf_open_group

void cf\_open\_group(void);

cf_parse_double

char \*cf\_parse\_double(const char \*str, double \*ptr);

cf_parse_int

char \*cf\_parse\_int(const char \*str, int \*ptr);

cf_parse_ip

char \*cf\_parse\_ip(const char \*p, u32 \*varp);

cf_parse_u64

char \*cf\_parse\_u64(const char \*str, u64 \*ptr);

cf_printf

char \*cf\_printf(const char \*fmt, \...) FORMAT\_CHECK(printf,1,2);

cf_reload

int cf\_reload(const char \*file);

cf_revert

void cf\_revert(void);

cf_set

int cf\_set(const char \*string);

cf_set_journalling

void cf\_set\_journalling(int enable);

cf_strdup

char \*cf\_strdup(const char \*s);

cf_switch_context

struct cf\_context \*cf\_switch\_context(struct cf\_context \*cc);

clist_add_head

static inline void clist\_add\_head(clist \*l, cnode \*n);

clist_add_tail

static inline void clist\_add\_tail(clist \*l, cnode \*n);

clist_empty

static inline int clist\_empty(clist \*l);

clist_head

static inline void \*clist\_head(clist \*l);

clist_init

static inline void clist\_init(clist \*l);

clist_insert_after

static inline void clist\_insert\_after(cnode \*what, cnode \*after);

clist_insert_before

static inline void clist\_insert\_before(cnode \*what, cnode \*before);

clist_insert_list_after

static inline void clist\_insert\_list\_after(clist \*what, cnode \*after);

clist_is_linked

static inline int clist\_is\_linked(cnode \*n);

clist_move

static inline void clist\_move(clist \*to, clist \*from);

clist_next

static inline void \*clist\_next(clist \*l, cnode \*n);

clist_prev

static inline void \*clist\_prev(clist \*l, cnode \*n);

clist_remove

static inline void clist\_remove(cnode \*n);

clist_remove_head

static inline void \*clist\_remove\_head(clist \*l);

clist_remove_tail

static inline void \*clist\_remove\_tail(clist \*l);

clist_size

static inline uint clist\_size(clist \*l);

clist_tail

static inline void \*clist\_tail(clist \*l);

clist_unlink

static inline void clist\_unlink(cnode \*n);

clist_unlink_head

static inline void \*clist\_unlink\_head(clist \*l);

clist_unlink_tail

static inline void \*clist\_unlink\_tail(clist \*l);

crc32_final

static inline u32 crc32\_final(crc32\_context \*ctx);

crc32_hash_buffer

u32 crc32\_hash\_buffer(const byte \*buf, uint len);

crc32_init

void crc32\_init(crc32\_context \*ctx, uint crc\_mode);

crc32_update

static inline void crc32\_update(crc32\_context \*ctx, const byte \*buf, uint len);

daemon_control

enum daemon\_control\_status daemon\_control(struct daemon\_control\_params \*dc);

daemon_exit

void daemon\_exit(struct daemon\_params \*dp);

daemon_init

void daemon\_init(struct daemon\_params \*dp);

daemon_resolve_ugid

void daemon\_resolve\_ugid(struct daemon\_params \*dp);

daemon_switch_ugid

void daemon\_switch\_ugid(struct daemon\_params \*dp);

die

void die(const char \*, \...) NONRET FORMAT\_CHECK(printf,1,2);

ep_alloc

static inline void \*ep\_alloc(struct eltpool \*pool);

ep_delete

void ep\_delete(struct eltpool \*pool);

ep_free

static inline void ep\_free(struct eltpool \*pool, void \*p);

ep_new

struct eltpool \*ep\_new(uint elt\_size, uint elts\_per\_chunk);

ep_total_size

u64 ep\_total\_size(struct eltpool \*pool);

fb_tie

struct fastbuf \*fb\_tie(struct fastbuf \*b);

fb_wrap_hex_in

struct fastbuf \*fb\_wrap\_hex\_in(struct fastbuf \*f);

fb_wrap_hex_out

struct fastbuf \*fb\_wrap\_hex\_out(struct fastbuf \*f);

fbatomic_commit

static inline void fbatomic\_commit(struct fastbuf \*b);

fbatomic_open

struct fastbuf \*fbatomic\_open(const char \*name, struct fastbuf \*master, uint bufsize, int record\_len);

fbbuf_count_written

static inline uint fbbuf\_count\_written(struct fastbuf \*f);

fbbuf_init_read

void fbbuf\_init\_read(struct fastbuf \*f, byte \*buffer, uint size, uint can\_overwrite);

fbbuf_init_write

void fbbuf\_init\_write(struct fastbuf \*f, byte \*buffer, uint size);

fbgrow_create

struct fastbuf \*fbgrow\_create(uint basic\_size);

fbgrow_create_mp

struct fastbuf \*fbgrow\_create\_mp(struct mempool \*mp, uint basic\_size);

fbgrow_get_buf

uint fbgrow\_get\_buf(struct fastbuf \*b, byte \*\*buf);

fbgrow_reset

void fbgrow\_reset(struct fastbuf \*b);

fbgrow_rewind

void fbgrow\_rewind(struct fastbuf \*b);

fbmem_clone_read

struct fastbuf \*fbmem\_clone\_read(struct fastbuf \*f);

fbmem_create

struct fastbuf \*fbmem\_create(uint blocksize);

fbmulti_append

void fbmulti\_append(struct fastbuf \*f, struct fastbuf \*fb);

fbmulti_create

struct fastbuf \*fbmulti\_create(void);

fbmulti_remove

void fbmulti\_remove(struct fastbuf \*f, struct fastbuf \*fb);

fbnull_open

struct fastbuf \*fbnull\_open(uint bufsize);

fbnull_start

void fbnull\_start(struct fastbuf \*b, byte \*buf, uint bufsize);

fbnull_test

bool fbnull\_test(struct fastbuf \*b);

fbpool_end

void \*fbpool\_end(struct fbpool \*fb);

fbpool_init

void fbpool\_init(struct fbpool \*fb);

fbpool_start

void fbpool\_start(struct fbpool \*fb, struct mempool \*mp, size\_t init\_size);

fbsock_create

struct fastbuf \*fbsock\_create(struct fbsock\_params \*par);

file_add

void file\_add(struct main\_file \*fi);

file_chg

void file\_chg(struct main\_file \*fi);

file_debug

void file\_debug(struct main\_file \*fi);

file_del

void file\_del(struct main\_file \*fi);

file_is_active

static inline int file\_is\_active(struct main\_file \*fi);

get_timer

uint get\_timer(timestamp\_t \*timer);

get_timestamp

timestamp\_t get\_timestamp(void);

get_u16

static inline uint get\_u16(const void \*p);

get_u16_be

static inline uint get\_u16\_be(const void \*p);

get_u16_le

static inline uint get\_u16\_le(const void \*p);

get_u32

static inline u32 get\_u32(const void \*p);

get_u32_be

static inline u32 get\_u32\_be(const void \*p);

get_u32_le

static inline u32 get\_u32\_le(const void \*p);

get_u40

static inline u64 get\_u40(const void \*p);

get_u40_be

static inline u64 get\_u40\_be(const void \*p);

get_u40_le

static inline u64 get\_u40\_le(const void \*p);

get_u64

static inline u64 get\_u64(const void \*p);

get_u64_be

static inline u64 get\_u64\_be(const void \*p);

get_u64_le

static inline u64 get\_u64\_le(const void \*p);

get_u8

static inline uint get\_u8(const void \*p);

hash_block

uint hash\_block(const byte \*buf, uint len) PURE;

hash_block_aligned

uint hash\_block\_aligned(const byte \*buf, uint len) PURE;

hash_pointer

static inline uint CONST hash\_pointer(void \*x);

hash_string

uint hash\_string(const char \*str) PURE;

hash_string_aligned

uint hash\_string\_aligned(const char \*str) PURE;

hash_string_nocase

uint hash\_string\_nocase(const char \*str) PURE;

hash_u32

static inline uint CONST hash\_u32(uint x);

hash_u64

static inline uint CONST hash\_u64(u64 x);

hex_to_mem

const char \*hex\_to\_mem(byte \*dest, const char \*src, size\_t max\_bytes, uint flags);

hook_add

void hook\_add(struct main\_hook \*ho);

hook_debug

void hook\_debug(struct main\_hook \*ho);

hook_del

void hook\_del(struct main\_hook \*ho);

hook_is_active

static inline int hook\_is\_active(struct main\_hook \*ho);

init_timer

void init\_timer(timestamp\_t \*timer);

isprime

int isprime(uint x);

lizard_alloc

struct lizard\_buffer \*lizard\_alloc(void);

lizard_compress

int lizard\_compress(const byte \*in, uint in\_len, byte \*out);

lizard_decompress

int lizard\_decompress(const byte \*in, byte \*out);

lizard_decompress_safe

byte \*lizard\_decompress\_safe(const byte \*in, struct lizard\_buffer \*buf, uint expected\_length);

lizard_free

void lizard\_free(struct lizard\_buffer \*buf);

log_add_substream

void log\_add\_substream(struct log\_stream \*where, struct log\_stream \*what);

log_check_configured

char \*log\_check\_configured(const char \*name);

log_close_all

void log\_close\_all(void);

log_close_stream

int log\_close\_stream(struct log\_stream \*ls);

log_configured

void log\_configured(const char \*name);

log_default_stream

static inline struct log\_stream \*log\_default\_stream(void);

log_drop_stderr

void log\_drop\_stderr(void);

log_file

void log\_file(const char \*name);

log_find_type

int log\_find\_type(const char \*name);

log_fork

void log\_fork(void);

log_init

void log\_init(const char \*argv0);

log_new_configured

struct log\_stream \*log\_new\_configured(const char \*name);

log_new_fd

struct log\_stream \*log\_new\_fd(int fd, uint flags);

log_new_file

struct log\_stream \*log\_new\_file(const char \*path, uint flags);

log_new_stream

struct log\_stream \*log\_new\_stream(size\_t size);

log_new_syslog

struct log\_stream \*log\_new\_syslog(const char \*facility, int options);

log_pass_filtered

void log\_pass\_filtered(struct log\_stream \*ls, struct log\_msg \*m);

log_ref_stream

static inline struct log\_stream \*log\_ref\_stream(struct log\_stream \*ls);

log_register_type

int log\_register\_type(const char \*name);

log_rm_substream

int log\_rm\_substream(struct log\_stream \*where, struct log\_stream \*what);

log_set_default_stream

void log\_set\_default\_stream(struct log\_stream \*ls);

log_set_format

void log\_set\_format(struct log\_stream \*ls, uint mask, uint data);

log_stream_by_flags

struct log\_stream \*log\_stream\_by\_flags(uint flags);

log_switch

int log\_switch(void);

log_switch_disable

void log\_switch\_disable(void);

log_switch_enable

void log\_switch\_enable(void);

log_syslog_facility_exists

int log\_syslog\_facility\_exists(const char \*facility);

log_type_name

char \*log\_type\_name(uint flags);

main_cleanup

void main\_cleanup(void);

main_current

struct main\_context \*main\_current(void);

main_debug_context

void main\_debug\_context(struct main\_context \*m);

main_delete

void main\_delete(struct main\_context \*m);

main_destroy

void main\_destroy(struct main\_context \*m);

main_get_now

static inline timestamp\_t main\_get\_now(void);

main_get_time

void main\_get\_time(void);

main_init

void main\_init(void);

main_loop

void main\_loop(void);

main_new

struct main\_context \*main\_new(void);

main_shut_down

static inline void main\_shut\_down(void);

main_step

void main\_step(void);

main_switch_context

struct main\_context \*main\_switch\_context(struct main\_context \*m);

main_teardown

void main\_teardown(void);

md5_final

byte \*md5\_final(md5\_context \*context);

md5_hash_buffer

void md5\_hash\_buffer(byte \*outbuf, const byte \*buffer, uint length);

md5_init

void md5\_init(md5\_context \*context);

md5_transform

void md5\_transform(u32 buf[4], const u32 in[16]);

md5_update

void md5\_update(md5\_context \*context, const byte \*buf, uint len);

mem_to_hex

void mem\_to\_hex(char \*dest, const byte \*src, size\_t bytes, uint flags);

mp_alloc

void \*mp\_alloc(struct mempool \*pool, size\_t size);

mp_alloc_fast

static inline void \*mp\_alloc\_fast(struct mempool \*pool, size\_t size);

mp_alloc_fast_noalign

static inline void \*mp\_alloc\_fast\_noalign(struct mempool \*pool, size\_t size);

mp_alloc_noalign

void \*mp\_alloc\_noalign(struct mempool \*pool, size\_t size);

mp_alloc_zero

void \*mp\_alloc\_zero(struct mempool \*pool, size\_t size);

mp_append_block

static inline void \*mp\_append\_block(struct mempool \*pool, void \*p, const void \*block, size\_t size);

mp_append_char

static inline char \*mp\_append\_char(struct mempool \*pool, char \*p, uint c);

mp_append_string

static inline void \*mp\_append\_string(struct mempool \*pool, void \*p, const char \*str);

mp_append_utf8_32

void \*mp\_append\_utf8\_32(struct mempool \*pool, void \*p, uint c);

mp_avail

static inline size\_t mp\_avail(struct mempool \*pool);

mp_delete

void mp\_delete(struct mempool \*pool);

mp_end

static inline void \*mp\_end(struct mempool \*pool, void \*end);

mp_end_string

static inline char \*mp\_end\_string(struct mempool \*pool, void \*end);

mp_expand

static inline void \*mp\_expand(struct mempool \*pool);

mp_flush

void mp\_flush(struct mempool \*pool);

mp_get_allocator

static inline struct ucw\_allocator \*mp\_get\_allocator(struct mempool \*mp);

mp_grow

static inline void \*mp\_grow(struct mempool \*pool, size\_t size);

mp_init

void mp\_init(struct mempool \*pool, size\_t chunk\_size);

mp_memdup

void \*mp\_memdup(struct mempool \*, const void \*, size\_t) LIKE\_MALLOC;

mp_multicat

char \*mp\_multicat(struct mempool \*, \...) LIKE\_MALLOC SENTINEL\_CHECK;

mp_new

struct mempool \*mp\_new(size\_t chunk\_size);

mp_open

size\_t mp\_open(struct mempool \*pool, void \*ptr);

mp_open_fast

static inline size\_t mp\_open\_fast(struct mempool \*pool, void \*ptr);

mp_pop

void mp\_pop(struct mempool \*pool);

mp_printf

char \*mp\_printf(struct mempool \*mp, const char \*fmt, \...) FORMAT\_CHECK(printf,2,3) LIKE\_MALLOC;

mp_printf_append

char \*mp\_printf\_append(struct mempool \*mp, char \*ptr, const char \*fmt, \...) FORMAT\_CHECK(printf,3,4);

mp_ptr

static inline void \*mp\_ptr(struct mempool \*pool);

mp_push

struct mempool\_state \*mp\_push(struct mempool \*pool);

mp_realloc

void \*mp\_realloc(struct mempool \*pool, void \*ptr, size\_t size);

mp_realloc_fast

static inline void \*mp\_realloc\_fast(struct mempool \*pool, void \*ptr, size\_t size);

mp_realloc_zero

void \*mp\_realloc\_zero(struct mempool \*pool, void \*ptr, size\_t size);

mp_restore

void mp\_restore(struct mempool \*pool, struct mempool\_state \*state);

mp_restore_fast

static inline void mp\_restore\_fast(struct mempool \*pool, struct mempool\_state \*state);

mp_save

static inline void mp\_save(struct mempool \*pool, struct mempool\_state \*state);

mp_shrink

void mp\_shrink(struct mempool \*pool, u64 min\_total\_size);

mp_size

static inline size\_t mp\_size(struct mempool \*pool, void \*ptr);

mp_spread

static inline void \*mp\_spread(struct mempool \*pool, void \*p, size\_t size);

mp_start

void \*mp\_start(struct mempool \*pool, size\_t size);

mp_start_fast

static inline void \*mp\_start\_fast(struct mempool \*pool, size\_t size);

mp_start_fast_noalign

static inline void \*mp\_start\_fast\_noalign(struct mempool \*pool, size\_t size);

mp_stats

void mp\_stats(struct mempool \*pool, struct mempool\_stats \*stats);

mp_str_from_mem

char \*mp\_str\_from\_mem(struct mempool \*p, const void \*mem, size\_t len) LIKE\_MALLOC;

mp_strcat

static inline char \*LIKE\_MALLOC mp\_strcat(struct mempool \*mp, const char \*x, const char \*y);

mp_strdup

char \*mp\_strdup(struct mempool \*, const char \*) LIKE\_MALLOC;

mp_strjoin

char \*mp\_strjoin(struct mempool \*p, char \*\*a, uint n, uint sep) LIKE\_MALLOC;

mp_total_size

u64 mp\_total\_size(struct mempool \*pool);

mp_vprintf

char \*mp\_vprintf(struct mempool \*mp, const char \*fmt, va\_list args) LIKE\_MALLOC;

mp_vprintf_append

char \*mp\_vprintf\_append(struct mempool \*mp, char \*ptr, const char \*fmt, va\_list args);

msg

void msg(uint flags, const char \*fmt, \...) FORMAT\_CHECK(printf,2,3);

next_table_prime

uint next\_table\_prime(uint x);

nextprime

uint nextprime(uint x);

open_tmp

int open\_tmp(char \*name\_buf, int open\_flags, int mode);

opt_failure

void opt\_failure(const char \* mesg, \...) FORMAT\_CHECK(printf,1,2) NONRET;

opt_parse

int opt\_parse(const struct opt\_section \* options, char \*\* argv);

prev_table_prime

uint prev\_table\_prime(uint x);

process_add

void process\_add(struct main\_process \*mp);

process_debug

void process\_debug(struct main\_process \*pr);

process_del

void process\_del(struct main\_process \*mp);

process_fork

int process\_fork(struct main\_process \*mp);

process_is_active

static inline int process\_is\_active(struct main\_process \*mp);

put_u16

static inline void put\_u16(void \*p, uint x);

put_u16_be

static inline void put\_u16\_be(void \*p, uint x);

put_u16_le

static inline void put\_u16\_le(void \*p, uint x);

put_u32

static inline void put\_u32(void \*p, u32 x);

put_u32_be

static inline void put\_u32\_be(void \*p, u32 x);

put_u32_le

static inline void put\_u32\_le(void \*p, u32 x);

put_u40

static inline void put\_u40(void \*p, u64 x);

put_u64

static inline void put\_u64(void \*p, u64 x);

put_u64_be

static inline void put\_u64\_be(void \*p, u64 x);

put_u64_le

static inline void put\_u64\_le(void \*p, u64 x);

put_u8

static inline void put\_u8(void \*p, uint x);

random_max

uint random\_max(uint max);

random_max_u64

u64 random\_max\_u64(u64 max);

random_u32

uint random\_u32(void);

random_u64

u64 random\_u64(void);

rec_io_add

void rec\_io\_add(struct main\_rec\_io \*rio, int fd);

rec_io_del

void rec\_io\_del(struct main\_rec\_io \*rio);

rec_io_is_active

static inline int rec\_io\_is\_active(struct main\_rec\_io \*rio);

rec_io_parse_line

uint rec\_io\_parse\_line(struct main\_rec\_io \*rio);

rec_io_set_timeout

void rec\_io\_set\_timeout(struct main\_rec\_io \*rio, timestamp\_t expires\_delta);

rec_io_start_read

void rec\_io\_start\_read(struct main\_rec\_io \*rio);

rec_io_stop_read

void rec\_io\_stop\_read(struct main\_rec\_io \*rio);

res_add

void res\_add(struct resource \*r);

res_detach

void res\_detach(struct resource \*r);

res_drop

void res\_drop(struct resource \*r);

res_dump

void res\_dump(struct resource \*r, uint indent);

res_eltpool

struct resource \*res\_eltpool(struct eltpool \*ep);

res_for_fd

struct resource \*res\_for\_fd(int fd);

res_free

void res\_free(struct resource \*r);

res_init

static inline struct resource \*res\_init(struct resource \*r, const struct res\_class \*rc, void \*priv);

res_malloc

void \*res\_malloc(size\_t size, struct resource \*\*ptr) LIKE\_MALLOC;

res_malloc_zero

void \*res\_malloc\_zero(size\_t size, struct resource \*\*ptr) LIKE\_MALLOC;

res_mempool

struct resource \*res\_mempool(struct mempool \*mp);

res_new

static inline struct resource \*res\_new(const struct res\_class \*rc, void \*priv);

res_permanent

static inline void res\_permanent(struct resource \*r);

res_realloc

void \*res\_realloc(struct resource \*res, size\_t size);

res_subpool

struct resource \*res\_subpool(struct respool \*rp);

res_temporary

static inline void res\_temporary(struct resource \*r);

reset_getopt

void reset\_getopt(void);

rp_commit

void rp\_commit(struct respool \*rp);

rp_current

static inline struct respool \*rp\_current(void);

rp_delete

void rp\_delete(struct respool \*rp);

rp_detach

void rp\_detach(struct respool \*rp);

rp_dump

void rp\_dump(struct respool \*rp, uint indent);

rp_new

struct respool \*rp\_new(const char \*name, struct mempool \*mp);

rp_switch

static inline struct respool \*rp\_switch(struct respool \*rp);

sha1_final

byte \*sha1\_final(sha1\_context \*hd);

sha1_hash_buffer

void sha1\_hash\_buffer(byte \*outbuf, const byte \*buffer, uint length);

sha1_hmac

void sha1\_hmac(byte \*outbuf, const byte \*key, uint keylen, const byte \*data, uint datalen);

sha1_init

void sha1\_init(sha1\_context \*hd);

sha1_update

void sha1\_update(sha1\_context \*hd, const byte \*inbuf, uint inlen);

sig_name_to_number

int sig\_name\_to\_number(const char \*name);

sig_number_to_name

const char \*sig\_number\_to\_name(int number);

signal_add

void signal\_add(struct main\_signal \*ms);

signal_debug

void signal\_debug(struct main\_signal \*sg);

signal_del

void signal\_del(struct main\_signal \*ms);

signal_is_active

static inline int signal\_is\_active(struct main\_signal \*ms);

simp2_append

simp2\_node \*simp2\_append(struct mempool \*mp, clist \*l);

simp_append

simp\_node \*simp\_append(struct mempool \*mp, clist \*l);

slist_add_head

static inline void slist\_add\_head(slist \*l, snode \*n);

slist_add_tail

static inline void slist\_add\_tail(slist \*l, snode \*n);

slist_empty

static inline int slist\_empty(slist \*l);

slist_head

static inline void \*slist\_head(slist \*l);

slist_init

static inline void slist\_init(slist \*l);

slist_insert_after

static inline void slist\_insert\_after(slist \*l, snode \*what, snode \*after);

slist_insert_before

void slist\_insert\_before(slist \*l, snode \*what, snode \*before);

slist_next

static inline void \*slist\_next(snode \*n);

slist_prev

void \*slist\_prev(slist \*l, snode \*n);

slist_remove

void slist\_remove(slist \*l, snode \*n);

slist_remove_after

static inline void slist\_remove\_after(slist \*l, snode \*after);

slist_remove_head

static inline void \*slist\_remove\_head(slist \*l);

slist_remove_tail

static inline void slist\_remove\_tail(slist \*l);

slist_size

static inline uint slist\_size(slist \*l);

slist_tail

static inline void \*slist\_tail(slist \*l);

str_count_char

size\_t str\_count\_char(const char \*str, uint chr);

str_format_flags

char \*str\_format\_flags(char \*dest, const char \*fmt, uint flags);

str_has_prefix

int str\_has\_prefix(const char \*str, const char \*prefix);

str_has_suffix

int str\_has\_suffix(const char \*str, const char \*suffix);

str_hier_prefix

int str\_hier\_prefix(const char \*str, const char \*prefix, uint sep);

str_hier_suffix

int str\_hier\_suffix(const char \*str, const char \*suffix, uint sep);

str_len

uint str\_len(const char \*str) PURE;

str_len_aligned

uint str\_len\_aligned(const char \*str) PURE;

str_match_pattern

int str\_match\_pattern(const char \*patt, const char \*str);

str_match_pattern_nocase

int str\_match\_pattern\_nocase(const char \*patt, const char \*str);

str_sepsplit

int str\_sepsplit(char \*str, uint sep, char \*\*rec, uint max);

str_unesc

char \*str\_unesc(char \*dest, const char \*src);

str_wordsplit

int str\_wordsplit(char \*str, char \*\*rec, uint max);

switch_timer

uint switch\_timer(timestamp\_t \*oldt, timestamp\_t \*newt);

table_cleanup

void table\_cleanup(struct table \*tbl);

table_col_fbend

void table\_col\_fbend(struct table \*tbl);

table_col_fbstart

struct fastbuf \*table\_col\_fbstart(struct table \*tbl, int col);

table_col_generic_format

void table\_col\_generic\_format(struct table \*tbl, int col, void \*value, const struct xtype \*expected\_type);

table_col_is_printed

bool table\_col\_is\_printed(struct table \*tbl, uint col\_def\_idx);

table_col_printf

void table\_col\_printf(struct table \*tbl, int col, const char \*fmt, \...) FORMAT\_CHECK(printf, 3, 4);

table_end

void table\_end(struct table \*tbl);

table_end_row

void table\_end\_row(struct table \*tbl);

table_get_col_idx

int table\_get\_col\_idx(struct table \*tbl, const char \*col\_name);

table_get_col_list

const char \*table\_get\_col\_list(struct table \*tbl);

table_init

struct table \*table\_init(const struct table\_template \*tbl\_template);

table_reset_row

void table\_reset\_row(struct table \*tbl);

table_set_col_opt

const char \*table\_set\_col\_opt(struct table \*tbl, uint col\_inst\_idx, const char \*col\_opt);

table_set_col_order

void table\_set\_col\_order(struct table \*tbl, const struct table\_col\_instance \*col\_order);

table_set_col_order_by_name

const char \*table\_set\_col\_order\_by\_name(struct table \*tbl, const char \*col\_order);

table_set_formatter

void table\_set\_formatter(struct table \*tbl, const struct table\_formatter \*fmt);

table_set_gary_options

const char \*table\_set\_gary\_options(struct table \*tbl, char \*\*gary\_table\_opts);

table_set_option

const char \*table\_set\_option(struct table \*tbl, const char \*opt);

table_set_option_value

const char \*table\_set\_option\_value(struct table \*tbl, const char \*key, const char \*value);

table_start

void table\_start(struct table \*tbl, struct fastbuf \*out);

tbf_init

void tbf\_init(struct token\_bucket\_filter \*f);

tbf_limit

int tbf\_limit(struct token\_bucket\_filter \*f, timestamp\_t now);

temp_file_name

void temp\_file\_name(char \*name\_buf, int \*open\_flags);

timer_add

void timer\_add(struct main\_timer \*tm, timestamp\_t expires);

timer_add_rel

void timer\_add\_rel(struct main\_timer \*tm, timestamp\_t expires\_delta);

timer_debug

void timer\_debug(struct main\_timer \*tm);

timer_del

void timer\_del(struct main\_timer \*tm);

timer_is_active

static inline int timer\_is\_active(struct main\_timer \*tm);

trans_caught

void trans\_caught(void);

trans_cleanup

void trans\_cleanup(void);

trans_commit

void trans\_commit(void);

trans_current_exc

struct exception \*trans\_current\_exc(void);

trans_dump

void trans\_dump(void);

trans_fold

void trans\_fold(void);

trans_get_current

struct trans \*trans\_get\_current(void);

trans_init

void trans\_init(void);

trans_open

struct trans \*trans\_open(void);

trans_rollback

void trans\_rollback(void);

trans_throw

void trans\_throw(const char \*id, void \*object, const char \*fmt, \...) FORMAT\_CHECK(printf,3,4) NONRET;

trans_throw_exc

void trans\_throw\_exc(struct exception \*x) NONRET;

trans_vthrow

void trans\_vthrow(const char \*id, void \*object, const char \*fmt, va\_list args) NONRET;

unicode_sanitize_char

static inline uint unicode\_sanitize\_char(uint u);

utf16_be_get

static inline void \*utf16\_be\_get(const void \*p, uint \*uu);

utf16_be_get_repl

static inline void \*utf16\_be\_get\_repl(const void \*p, uint \*uu, uint repl);

utf16_be_put

static inline void \*utf16\_be\_put(void \*p, uint u);

utf16_le_get

static inline void \*utf16\_le\_get(const void \*p, uint \*uu);

utf16_le_get_repl

static inline void \*utf16\_le\_get\_repl(const void \*p, uint \*uu, uint repl);

utf16_le_put

static inline void \*utf16\_le\_put(void \*p, uint u);

utf8_32_get

static inline byte \*utf8\_32\_get(const byte \*p, uint \*uu);

utf8_32_get_repl

static inline byte \*utf8\_32\_get\_repl(const byte \*p, uint \*uu, uint repl);

utf8_32_put

static inline byte \*utf8\_32\_put(byte \*p, uint u);

utf8_encoding_len

static inline uint utf8\_encoding\_len(uint c);

utf8_get

static inline byte \*utf8\_get(const byte \*p, uint \*uu);

utf8_get_repl

static inline byte \*utf8\_get\_repl(const byte \*p, uint \*uu, uint repl);

utf8_put

static inline byte \*utf8\_put(byte \*p, uint u);

utf8_space

static inline uint utf8\_space(uint u);

utf8_strlen

size\_t utf8\_strlen(const byte \*str);

utf8_strnlen

size\_t utf8\_strnlen(const byte \*str, size\_t n);

varint_get

static inline const byte \*varint\_get(const byte \*p, u64 \*res);

varint_get32

static inline const byte \*varint\_get32(const byte \*p, u32 \*res);

varint_invalid

static inline int varint\_invalid(const byte \*p);

varint_len

static inline uint varint\_len(const byte hdr);

varint_put

static inline uint varint\_put(byte \*p, u64 u);

varint_put_invalid

static inline uint varint\_put\_invalid(byte \*p);

varint_space

static inline uint varint\_space(u64 u);

vbprintf

int vbprintf(struct fastbuf \*b, const char \*msg, va\_list args);

vdie

void vdie(const char \*fmt, va\_list args) NONRET;

vmsg

void vmsg(uint flags, const char \*fmt, va\_list args);

xfree

void xfree(void \*);

xmalloc

void \*xmalloc(size\_t) LIKE\_MALLOC;

xmalloc_zero

void \*xmalloc\_zero(size\_t) LIKE\_MALLOC;

xrealloc

void \*xrealloc(void \*, size\_t);

xstrdup

char \*xstrdup(const char \*) LIKE\_MALLOC;

xtype_format_fmt

const char \*xtype\_format\_fmt(struct xtype \*xt, u32 fmt, struct mempool \*pool);

xtype_parse_fmt

const char \*xtype\_parse\_fmt(const struct xtype \*xt, const char \*str, u32 \*dest, struct mempool \*pool);

xtype_unit_parser

int xtype\_unit\_parser(const char \*str, const struct unit\_definition \*units);

Variables

body

void daemon\_run(struct daemon\_params \*dp, void (\*body)(struct daemon\_params \*dp));

cf_2string_list_config

extern struct cf\_section cf\_2string\_list\_config;

cf_def_file

extern char \*cf\_def\_file;

cf_def_file

extern char \*cf\_def\_file;

cf_env_file

extern char \*cf\_env\_file;

cf_env_file

extern char \*cf\_env\_file;

cf_string_list_config

extern struct cf\_section cf\_string\_list\_config;

fbpar_cf

extern struct cf\_section fbpar\_cf;

fbpar_def

extern struct fb\_params fbpar\_def;

log_die_hook

extern void (\*log\_die\_hook)(void);

log_pid

extern int log\_pid;

log_title

extern char \*log\_title;

table_fmt_blockline

extern const struct table\_formatter table\_fmt\_blockline;

table_fmt_human_readable

extern const struct table\_formatter table\_fmt\_human\_readable;

table_fmt_machine_readable

extern const struct table\_formatter table\_fmt\_machine\_readable;

timestamp_type

extern struct cf\_user\_type timestamp\_type;

ucw_allocator_std

extern struct ucw\_allocator ucw\_allocator\_std;

ucw_allocator_zeroed

extern struct ucw\_allocator ucw\_allocator\_zeroed;

Preprocessor definitions

ABS

\#define ABS(x) ((x) < 0 ? -(x) : (x))

ALIGN_PTR

\#define ALIGN\_PTR(p, s) ((uintptr\_t)(p) % (s) ? (typeof(p))((uintptr\_t)(p) + (s) - (uintptr\_t)(p) % (s)) : (p))

ALIGN_TO

\#define ALIGN\_TO(s, a) (((s)+a-1)&~(a-1))

ALWAYS_INLINE

\#define ALWAYS\_INLINE inline \_\_attribute\_\_((always\_inline))

ARRAY_SIZE

\#define ARRAY\_SIZE(a) (sizeof(a)/sizeof(\*(a)))

ARY_LT_NUM

\#define ARY\_LT\_NUM(ary,i,x) (ary)[i] < (x)

ASSERT

\#define ASSERT(x) ({ if (unlikely(!(x))) assert\_failed(\#x, \_\_FILE\_\_, \_\_LINE\_\_); 1; })

ASSERT_MSG

\#define ASSERT\_MSG(cond,str,x\...) ({ if (unlikely(!(cond))) assert\_failed\_msg(\#cond, \_\_FILE\_\_, \_\_LINE\_\_, str,\#\#x); 1; })

ASSERT_READABLE

\#define ASSERT\_READABLE(ptr) ({ volatile char \*\_\_p = (ptr); \*\_\_p; })

ASSERT_WRITEABLE

\#define ASSERT\_WRITEABLE(ptr) ({ volatile char \*\_\_p = (ptr); \*\_\_p = \*\_\_p; })

BASE224_ENC_LENGTH

\#define BASE224\_ENC\_LENGTH(x) (((x)\*8+38)/39\*5)

BASE224_IN_CHUNK

\#define BASE224\_IN\_CHUNK 39

BASE224_OUT_CHUNK

\#define BASE224\_OUT\_CHUNK 40

BASE64_ENC_LENGTH

\#define BASE64\_ENC\_LENGTH(x) (((x)+2)/3 \*4)

BASE64_IN_CHUNK

\#define BASE64\_IN\_CHUNK 3

BASE64_OUT_CHUNK

\#define BASE64\_OUT\_CHUNK 4

BIN_SEARCH_EQ

\#define BIN\_SEARCH\_EQ(ary,N,x) ({ int i = BIN\_SEARCH\_FIRST\_GE(ary,N,x); if (i >= (N) || (ary)[i] != (x)) i=-1; i; })

BIN_SEARCH_FIRST_GE

\#define BIN\_SEARCH\_FIRST\_GE(ary,N,x) BIN\_SEARCH\_FIRST\_GE\_CMP(ary,N,x,ARY\_LT\_NUM)

BIN_SEARCH_FIRST_GE_CMP

\#define BIN\_SEARCH\_FIRST\_GE\_CMP(ary,N,x,ary\_lt\_x) ({ \

BUF_T

\#define BUF\_T GBUF\_PREFIX(t)

CELL_ALIGN_LEFT

\#define CELL\_ALIGN\_LEFT (1U << 31)

CF_ANY_NUM

\#define CF\_ANY\_NUM -0x7fffffff

CF_BITMAP_INT

\#define CF\_BITMAP\_INT(n,p) { .cls = CC\_BITMAP, .type = CT\_INT, .name = n, .number = 1, .ptr = CHECK\_PTR\_TYPE(p,u32\*) }

CF_BITMAP_LOOKUP

\#define CF\_BITMAP\_LOOKUP(n,p,t) { .cls = CC\_BITMAP, .type = CT\_LOOKUP, .name = n, .number = 1, .ptr = CHECK\_PTR\_TYPE(p,u32\*), .u.lookup = t }

CF_COMMIT

\#define CF\_COMMIT(f) .commit = (cf\_hook\*) f

CF_COPY

\#define CF\_COPY(f) .copy = (cf\_copier\*) f

CF_DOUBLE

\#define CF\_DOUBLE(n,p) CF\_STATIC(n,p,DOUBLE,double,1)

CF_DOUBLE_ARY

\#define CF\_DOUBLE\_ARY(n,p,c) CF\_STATIC(n,p,DOUBLE,double,c)

CF_DOUBLE_DYN

\#define CF\_DOUBLE\_DYN(n,p,c) CF\_DYNAMIC(n,p,DOUBLE,double,c)

CF_DYNAMIC

\#define CF\_DYNAMIC(n,p,T,t,c) { .cls = CC\_DYNAMIC, .type = CT\_\#\#T, .name = n, .number = c, .ptr = CHECK\_PTR\_TYPE(p,t\*\*) }

CF_END

\#define CF\_END { .cls = CC\_END }

CF_INIT

\#define CF\_INIT(f) .init = (cf\_hook\*) f

CF_INT

\#define CF\_INT(n,p) CF\_STATIC(n,p,INT,int,1)

CF_INT_ARY

\#define CF\_INT\_ARY(n,p,c) CF\_STATIC(n,p,INT,int,c)

CF_INT_DYN

\#define CF\_INT\_DYN(n,p,c) CF\_DYNAMIC(n,p,INT,int,c)

CF_IP

\#define CF\_IP(n,p) CF\_STATIC(n,p,IP,u32,1)

CF_IP_ARY

\#define CF\_IP\_ARY(n,p,c) CF\_STATIC(n,p,IP,u32,c)

CF_IP_DYN

\#define CF\_IP\_DYN(n,p,c) CF\_DYNAMIC(n,p,IP,u32,c)

CF_ITEMS

\#define CF\_ITEMS .cfg = ( struct cf\_item[] )

CF_LIST

\#define CF\_LIST(n,p,s) { .cls = CC\_LIST, .name = n, .number = 1, .ptr = CHECK\_PTR\_TYPE(p,clist\*), .u.sec = s }

CF_LONG_OPTS

\#define CF\_LONG\_OPTS {"config", 1, 0, \'C\'}, {"set", 1, 0, \'S\'}, CF\_LONG\_OPTS\_DEBUG

CF_LOOKUP

\#define CF\_LOOKUP(n,p,t) { .cls = CC\_STATIC, .type = CT\_LOOKUP, .name = n, .number = 1, .ptr = CHECK\_PTR\_TYPE(p,int\*), .u.lookup = t }

CF_LOOKUP_ARY

\#define CF\_LOOKUP\_ARY(n,p,t,c) { .cls = CC\_STATIC, .type = CT\_LOOKUP, .name = n, .number = c, .ptr = CHECK\_PTR\_TYPE(p,int\*), .u.lookup = t }

CF_LOOKUP_DYN

\#define CF\_LOOKUP\_DYN(n,p,t,c) { .cls = CC\_DYNAMIC, .type = CT\_LOOKUP, .name = n, .number = c, .ptr = CHECK\_PTR\_TYPE(p,int\*\*), .u.lookup = t }

CF_NO_LONG_OPTS

\#define CF\_NO\_LONG\_OPTS (const struct option []) { CF\_LONG\_OPTS { NULL, 0, 0, 0 } }

CF_OPERATIONS

\#define CF\_OPERATIONS T(CLOSE) T(SET) T(CLEAR) T(ALL) \

CF_PARSER

\#define CF\_PARSER(n,p,f,c) { .cls = CC\_PARSER, .name = n, .number = c, .ptr = p, .u.par = (cf\_parser\*) f }

CF_SECTION

\#define CF\_SECTION(n,p,s) { .cls = CC\_SECTION, .name = n, .number = 1, .ptr = p, .u.sec = s }

CF_SHORT_OPTS

\#define CF\_SHORT\_OPTS "C:S:"

CF_STATIC

\#define CF\_STATIC(n,p,T,t,c) { .cls = CC\_STATIC, .type = CT\_\#\#T, .name = n, .number = c, .ptr = CHECK\_PTR\_TYPE(p,t\*) }

CF_STRING

\#define CF\_STRING(n,p) CF\_STATIC(n,p,STRING,char\*,1)

CF_STRING_ARY

\#define CF\_STRING\_ARY(n,p,c) CF\_STATIC(n,p,STRING,char\*,c)

CF_STRING_DYN

\#define CF\_STRING\_DYN(n,p,c) CF\_DYNAMIC(n,p,STRING,char\*,c)

CF_TYPE

\#define CF\_TYPE(s) .size = sizeof(s)

CF_U64

\#define CF\_U64(n,p) CF\_STATIC(n,p,U64,u64,1)

CF_U64_ARY

\#define CF\_U64\_ARY(n,p,c) CF\_STATIC(n,p,U64,u64,c)

CF_U64_DYN

\#define CF\_U64\_DYN(n,p,c) CF\_DYNAMIC(n,p,U64,u64,c)

CF_UINT

\#define CF\_UINT(n,p) CF\_STATIC(n,p,INT,uint,1)

CF_UINT_ARY

\#define CF\_UINT\_ARY(n,p,c) CF\_STATIC(n,p,INT,uint,c)

CF_UINT_DYN

\#define CF\_UINT\_DYN(n,p,c) CF\_DYNAMIC(n,p,INT,uint,c)

CF_USAGE

\#define CF\_USAGE \

CF_USER

\#define CF\_USER(n,p,t) { .cls = CC\_STATIC, .type = CT\_USER, .name = n, .number = 1, .ptr = p, .u.utype = t }

CF_USER_ARY

\#define CF\_USER\_ARY(n,p,t,c) { .cls = CC\_STATIC, .type = CT\_USER, .name = n, .number = c, .ptr = p, .u.utype = t }

CF_USER_DYN

\#define CF\_USER\_DYN(n,p,t,c) { .cls = CC\_DYNAMIC, .type = CT\_USER, .name = n, .number = c, .ptr = p, .u.utype = t }

CF_XTYPE

\#define CF\_XTYPE(n,p,t) { .cls = CC\_STATIC, .type = CT\_XTYPE, .name = n, .number = 1, .ptr = p, .u.xtype = t }

CF_XTYPE_ARY

\#define CF\_XTYPE\_ARY(n,p,t,c) { .cls = CC\_STATIC, .type = CT\_XTYPE, .name = n, .number = c, .ptr = p, .u.xtype = t }

CF_XTYPE_DYN

\#define CF\_XTYPE\_DYN(n,p,t,c) { .cls = CC\_DYNAMIC, .type = CT\_XTYPE, .name = n, .number = c, .ptr = p, .u.xtype = t }

CHECK_PTR_TYPE

\#define CHECK\_PTR\_TYPE(x, type) ((x)-(type)(x) + (type)(x))

CLAMP

\#define CLAMP(x,min,max) ({ typeof(x) \_t=x; (\_t < min) ? min : (\_t > max) ? max : \_t; })

CLIST_FOR_EACH

\#define CLIST\_FOR\_EACH(type,n,list) for(type n=(void\*)(list).head.next; (cnode\*)(n) != &(list).head; n=(void\*)((cnode\*)(n))->next)

CLIST_FOR_EACH_BACKWARDS

\#define CLIST\_FOR\_EACH\_BACKWARDS(type,n,list) for(type n=(void\*)(list).head.prev; (cnode\*)(n) != &(list).head; n=(void\*)((cnode\*)(n))->prev)

CLIST_FOR_EACH_DELSAFE

\#define CLIST\_FOR\_EACH\_DELSAFE(type,n,list,tmp) for(type n=(void\*)(list).head.next; tmp=(void\*)((cnode\*)(n))->next, (cnode\*)(n) != &(list).head; n=(void\*)tmp)

CLIST_WALK

\#define CLIST\_WALK(n,list) for(n=(void\*)(list).head.next; (cnode\*)(n) != &(list).head; n=(void\*)((cnode\*)(n))->next)

CLIST_WALK_DELSAFE

\#define CLIST\_WALK\_DELSAFE(n,list,tmp) for(n=(void\*)(list).head.next; tmp=(void\*)((cnode\*)(n))->next, (cnode\*)(n) != &(list).head; n=(void\*)tmp)

COMPARE

\#define COMPARE(x,y) do { if ((x)<(y)) return -1; if ((x)>(y)) return 1; } while(0)

CONST

\#define CONST \_\_attribute\_\_((const))

CONSTRUCTOR

\#define CONSTRUCTOR \_\_attribute\_\_((constructor))

CONSTRUCTOR_WITH_PRIORITY

\#define CONSTRUCTOR\_WITH\_PRIORITY(p) \_\_attribute\_\_((constructor(p)))

Calpha

\#define Calpha(x) Ccat(x, \_C\_ALPHA)

Cblank

\#define Cblank(x) Ccat(x, \_C\_BLANK)

Cctrl

\#define Cctrl(x) Ccat(x, \_C\_CTRL)

Cdigit

\#define Cdigit(x) Ccat(x, \_C\_DIGIT)

Clocase

\#define Clocase(x) (ucw\_c\_lower[(byte)(x)])

Clower

\#define Clower(x) Ccat(x, \_C\_LOWER)

Cupcase

\#define Cupcase(x) (ucw\_c\_upper[(byte)(x)])

Cupper

\#define Cupper(x) Ccat(x, \_C\_UPPER)

Cword

\#define Cword(x) Ccat(x, \_C\_WORD)

Cxdigit

\#define Cxdigit(x) Ccat(x, \_C\_XDIGIT)

DARY_LEN

\#define DARY\_LEN(a) GARY\_SIZE(a)

DBG

\#define DBG(x,y\...) msg(L\_DEBUG, x,\#\#y)

DBG_SPOT

\#define DBG\_SPOT msg(L\_DEBUG, "%s:%d (%s)", \_\_FILE\_\_, \_\_LINE\_\_, \_\_func\_\_)

FORMAT_CHECK

\#define FORMAT\_CHECK(x,y,z) \_\_attribute\_\_((format(x,y,z)))

GARY_FIX

\#define GARY\_FIX(ptr) (ptr) = gary\_fix((ptr))

GARY_FREE

\#define GARY\_FREE(ptr) gary\_free(ptr)

GARY_INIT

\#define GARY\_INIT(ptr, n) (ptr) = gary\_init(sizeof(\*(ptr)), (n), &ucw\_allocator\_std)

GARY_INIT_ALLOC

\#define GARY\_INIT\_ALLOC(ptr, n, a) (ptr) = gary\_init(sizeof(\*(ptr)), (n), (a))

GARY_INIT_OR_RESIZE

\#define GARY\_INIT\_OR\_RESIZE(ptr, n) (ptr) = (ptr) ? gary\_set\_size((ptr), (n)) : gary\_init(sizeof(\*(ptr)), (n), &ucw\_allocator\_std)

GARY_INIT_SPACE

\#define GARY\_INIT\_SPACE(ptr, n) do { GARY\_INIT(ptr, n); (GARY\_HDR(ptr))->num\_elts = 0; } while (0)

GARY_INIT_SPACE_ALLOC

\#define GARY\_INIT\_SPACE\_ALLOC(ptr, n, a) do { GARY\_INIT\_ALLOC(ptr, n, a); (GARY\_HDR(ptr))->num\_elts = 0; } while (0)

GARY_INIT_SPACE_ZERO

\#define GARY\_INIT\_SPACE\_ZERO(ptr, n) do { GARY\_INIT\_ZERO(ptr, n); (GARY\_HDR(ptr))->num\_elts = 0; } while (0)

GARY_INIT_ZERO

\#define GARY\_INIT\_ZERO(ptr, n) (ptr) = gary\_init(sizeof(\*(ptr)), (n), &ucw\_allocator\_zeroed)

GARY_POP

\#define GARY\_POP(ptr) GARY\_POP\_MULTI(ptr, 1)

GARY_POP_MULTI

\#define GARY\_POP\_MULTI(ptr, n) GARY\_HDR(ptr)->num\_elts -= (n)

GARY_PUSH

\#define GARY\_PUSH(ptr) GARY\_PUSH\_MULTI(ptr, 1)

GARY_PUSH_MULTI

\#define GARY\_PUSH\_MULTI(ptr, n) ({ \

GARY_RESIZE

\#define GARY\_RESIZE(ptr, n) ((ptr) = gary\_set\_size((ptr), (n)))

GARY_SIZE

\#define GARY\_SIZE(ptr) (GARY\_HDR(ptr)->num\_elts)

GLUE

\#define GLUE(x,y) x\#\#y

GLUE_

\#define GLUE\_(x,y) x\#\#\_\#\#y

HEAP_DECREASE

\#define HEAP\_DECREASE(type,heap,num,less,swap,pos,elt) \

HEAP_DELETE

\#define HEAP\_DELETE(type,heap,num,less,swap,pos) \

HEAP_DELETE_MIN

\#define HEAP\_DELETE\_MIN(type,heap,num,less,swap) \

HEAP_INCREASE

\#define HEAP\_INCREASE(type,heap,num,less,swap,pos,elt) \

HEAP_INIT

\#define HEAP\_INIT(type,heap,num,less,swap) \

HEAP_INSERT

\#define HEAP\_INSERT(type,heap,num,less,swap,elt) \

HEAP_REPLACE

\#define HEAP\_REPLACE(type,heap,num,less,swap,pos,elt) \

HEAP_REPLACE_MIN

\#define HEAP\_REPLACE\_MIN(type,heap,num,less,swap,elt) \

HEAP_SWAP

\#define HEAP\_SWAP(heap,a,b,t) (t=heap[a], heap[a]=heap[b], heap[b]=t)

LIKE_MALLOC

\#define LIKE\_MALLOC \_\_attribute\_\_((malloc))

LIZARD_MAX_LEN

\#define LIZARD\_MAX\_LEN(LENGTH) ((LENGTH) \* LIZARD\_MAX\_MULTIPLY + LIZARD\_MAX\_ADD)

LIZARD_NEEDS_CHARS

\#define LIZARD\_NEEDS\_CHARS 8

LSFMT_DEFAULT

\#define LSFMT\_DEFAULT (LSFMT\_LEVEL | LSFMT\_TIME | LSFMT\_TITLE | LSFMT\_PID)

LS_GET_CTRL

\#define LS\_GET\_CTRL(flags) (((flags) & LS\_CTRL\_MASK) >> LS\_CTRL\_POS)

LS_GET_LEVEL

\#define LS\_GET\_LEVEL(flags) (((flags) & LS\_LEVEL\_MASK) >> LS\_LEVEL\_POS)

LS_GET_STRNUM

\#define LS\_GET\_STRNUM(flags) (((flags) & LS\_STRNUM\_MASK) >> LS\_STRNUM\_POS)

LS_GET_TYPE

\#define LS\_GET\_TYPE(flags) (((flags) & LS\_TYPE\_MASK) >> LS\_TYPE\_POS)

LS_SET_CTRL

\#define LS\_SET\_CTRL(ctrl) ((ctrl) << LS\_CTRL\_POS)

LS_SET_LEVEL

\#define LS\_SET\_LEVEL(level) ((level) << LS\_LEVEL\_POS)

LS_SET_STRNUM

\#define LS\_SET\_STRNUM(strnum) ((strnum) << LS\_STRNUM\_POS)

LS_SET_TYPE

\#define LS\_SET\_TYPE(type) ((type) << LS\_TYPE\_POS)

L_LOGGER_ERR

\#define L\_LOGGER\_ERR 0x40000000

L_SIGHANDLER

\#define L\_SIGHANDLER 0x80000000

MAX

\#define MAX(a,b) (((a)>(b))?(a):(b))

MD5_HEX_SIZE

\#define MD5\_HEX\_SIZE 33

MD5_SIZE

\#define MD5\_SIZE 16

MIN

\#define MIN(a,b) (((a)<(b))?(a):(b))

NONRET

\#define NONRET \_\_attribute\_\_((noreturn))

NO_INLINE

\#define NO\_INLINE \_\_attribute\_\_((noinline))

OFFSETOF

\#define OFFSETOF(s, i) ((uint)offsetof(s, i))

OPT_BEFORE_CONFIG

\#define OPT\_BEFORE\_CONFIG 0x800

OPT_BOOL

\#define OPT\_BOOL(shortopt, longopt, target, fl, desc) { .letter = shortopt, .name = longopt, .ptr = CHECK\_PTR\_TYPE(&target, int \*), .help = desc, .flags = fl, .cls = OPT\_CL\_BOOL, .type = CT\_INT }

OPT_BREAK

\#define OPT\_BREAK(shortopt, longopt, fl) { .letter = shortopt, .name = longopt, .flags = fl, .cls = OPT\_CL\_BREAK }

OPT_CALL

\#define OPT\_CALL(shortopt, longopt, fn, data, fl, desc) { .letter = shortopt, .name = longopt, .ptr = data, .help = desc, .u.call = fn, .flags = fl, .cls = OPT\_CL\_CALL, .type = CT\_USER }

OPT_DOUBLE

\#define OPT\_DOUBLE(shortopt, longopt, target, fl, desc) { .letter = shortopt, .name = longopt, .ptr = CHECK\_PTR\_TYPE(&target, double \*), .help = desc, .flags = fl, .cls = OPT\_CL\_STATIC, .type = CT\_DOUBLE }

OPT_DOUBLE_MULTIPLE

\#define OPT\_DOUBLE\_MULTIPLE(shortopt, longopt, target, fl, desc) { .letter = shortopt, .name = longopt, .ptr = CHECK\_PTR\_TYPE(&target, double \*\*), .help = desc, .flags = fl, .cls = OPT\_CL\_MULTIPLE, .type = CT\_DOUBLE }

OPT_END

\#define OPT\_END { .cls = OPT\_CL\_END }

OPT_HELP

\#define OPT\_HELP(line) { .help = line, .cls = OPT\_CL\_HELP }

OPT_HELP_COL

\#define OPT\_HELP\_COL 0x1000

OPT_HELP_COLUMNS

\#define OPT\_HELP\_COLUMNS(line) { .help = line, .flags = OPT\_HELP\_COL, .cls = OPT\_CL\_HELP }

OPT_HELP_OPTION

\#define OPT\_HELP\_OPTION OPT\_CALL(0, "help", opt\_handle\_help, NULL, OPT\_BEFORE\_CONFIG | OPT\_INTERNAL | OPT\_NO\_VALUE, "\tShow this help")

OPT_HOOK

\#define OPT\_HOOK(fn, data, events) { .cls = OPT\_CL\_HOOK, .u.hook = fn, .flags = events, .ptr = data }

OPT_HOOK_AFTER_VALUE

\#define OPT\_HOOK\_AFTER\_VALUE 0x4

OPT_HOOK_BEFORE_ARG

\#define OPT\_HOOK\_BEFORE\_ARG 0x1

OPT_HOOK_BEFORE_VALUE

\#define OPT\_HOOK\_BEFORE\_VALUE 0x2

OPT_HOOK_FINAL

\#define OPT\_HOOK\_FINAL 0x8

OPT_INC

\#define OPT\_INC(shortopt, longopt, target, fl, desc) { .letter = shortopt, .name = longopt, .ptr = CHECK\_PTR\_TYPE(&target, int \*), .flags = fl, .help = desc, .cls = OPT\_CL\_INC, .type = CT\_INT }

OPT_INT

\#define OPT\_INT(shortopt, longopt, target, fl, desc) { .letter = shortopt, .name = longopt, .ptr = CHECK\_PTR\_TYPE(&target, int \*), .help = desc, .flags = fl, .cls = OPT\_CL\_STATIC, .type = CT\_INT }

OPT_INT_MULTIPLE

\#define OPT\_INT\_MULTIPLE(shortopt, longopt, target, fl, desc) { .letter = shortopt, .name = longopt, .ptr = CHECK\_PTR\_TYPE(&target, int \*\*), .help = desc, .flags = fl, .cls = OPT\_CL\_MULTIPLE, .type = CT\_INT }

OPT_IP

\#define OPT\_IP(shortopt, longopt, target, fl, desc) { .letter = shortopt, .name = longopt, .ptr = CHECK\_PTR\_TYPE(&target, u32 \*), .help = desc, .flags = fl, .cls = OPT\_CL\_STATIC, .type = CT\_IP }

OPT_IP_MULTIPLE

\#define OPT\_IP\_MULTIPLE(shortopt, longopt, target, fl, desc) { .letter = shortopt, .name = longopt, .ptr = CHECK\_PTR\_TYPE(&target, u32 \*\*), .help = desc, .flags = fl, .cls = OPT\_CL\_MULTIPLE, .type = CT\_IP }

OPT_ITEMS

\#define OPT\_ITEMS .opt = ( struct opt\_item[] )

OPT_LAST_ARG

\#define OPT\_LAST\_ARG 0x40

OPT_MAYBE_VALUE

\#define OPT\_MAYBE\_VALUE 0x8

OPT_MULTIPLE

\#define OPT\_MULTIPLE 0x200

OPT_NEGATIVE

\#define OPT\_NEGATIVE 0x10

OPT_NO_VALUE

\#define OPT\_NO\_VALUE 0x4

OPT_REQUIRED

\#define OPT\_REQUIRED 0x1

OPT_REQUIRED_VALUE

\#define OPT\_REQUIRED\_VALUE 0x2

OPT_SECTION

\#define OPT\_SECTION(sec) { .cls = OPT\_CL\_SECTION, .u.section = &sec }

OPT_SINGLE

\#define OPT\_SINGLE 0x100

OPT_STRING

\#define OPT\_STRING(shortopt, longopt, target, fl, desc) { .letter = shortopt, .name = longopt, .ptr = CHECK\_PTR\_TYPE(&target, char \*\*), .help = desc, .flags = fl, .cls = OPT\_CL\_STATIC, .type = CT\_STRING }

OPT_STRING_MULTIPLE

\#define OPT\_STRING\_MULTIPLE(shortopt, longopt, target, fl, desc) { .letter = shortopt, .name = longopt, .ptr = CHECK\_PTR\_TYPE(&target, char \*\*\*), .help = desc, .flags = fl, .cls = OPT\_CL\_MULTIPLE, .type = CT\_STRING }

OPT_SWITCH

\#define OPT\_SWITCH(shortopt, longopt, target, val, fl, desc) { .letter = shortopt, .name = longopt, .ptr = CHECK\_PTR\_TYPE(&target, int \*), .help = desc, .flags = fl, .cls = OPT\_CL\_SWITCH, .type = CT\_LOOKUP, .u.value = val }

OPT_U64

\#define OPT\_U64(shortopt, longopt, target, fl, desc) { .letter = shortopt, .name = longopt, .ptr = CHECK\_PTR\_TYPE(&target, u64 \*), .help = desc, .flags = fl, .cls = OPT\_CL\_STATIC, .type = CT\_U64 }

OPT_U64_MULTIPLE

\#define OPT\_U64\_MULTIPLE(shortopt, longopt, target, fl, desc) { .letter = shortopt, .name = longopt, .ptr = CHECK\_PTR\_TYPE(&target, u64 \*\*), .help = desc, .flags = fl, .cls = OPT\_CL\_MULTIPLE, .type = CT\_U64 }

OPT_UINT

\#define OPT\_UINT(shortopt, longopt, target, fl, desc) { .letter = shortopt, .name = longopt, .ptr = CHECK\_PTR\_TYPE(&target, uint \*), .help = desc, .flags = fl, .cls = OPT\_CL\_STATIC, .type = CT\_INT }

OPT_UINT_MULTIPLE

\#define OPT\_UINT\_MULTIPLE(shortopt, longopt, target, fl, desc) { .letter = shortopt, .name = longopt, .ptr = CHECK\_PTR\_TYPE(&target, uint \*\*), .help = desc, .flags = fl, .cls = OPT\_CL\_MULTIPLE, .type = CT\_INT }

OPT_USER

\#define OPT\_USER(shortopt, longopt, target, ttype, fl, desc) { .letter = shortopt, .name = longopt, .ptr = &target, .u.utype = &ttype, .flags = fl, .help = desc, .cls = OPT\_CL\_STATIC, .type = CT\_USER }

OPT_USER_MULTIPLE

\#define OPT\_USER\_MULTIPLE(shortopt, longopt, target, ttype, fl, desc) { .letter = shortopt, .name = longopt, .ptr = &target, .u.utype = &ttype, .flags = fl, .help = desc, .cls = OPT\_CL\_MULTIPLE, .type = CT\_USER }

OPT_VALUE_FLAGS

\#define OPT\_VALUE\_FLAGS (OPT\_REQUIRED\_VALUE | OPT\_NO\_VALUE | OPT\_MAYBE\_VALUE)

OPT_XTYPE

\#define OPT\_XTYPE(shortopt, longopt, target, ttype, fl, desc) { .letter = shortopt, .name = longopt, .ptr = &target, .u.xtype = &ttype, .flags = fl, .help = desc, .cls = OPT\_CL\_STATIC, .type = CT\_XTYPE }

OPT_XTYPE_MULTIPLE

\#define OPT\_XTYPE\_MULTIPLE(shortopt, longopt, target, ttype, fl, desc) { .letter = shortopt, .name = longopt, .ptr = &target, .u.xtype = &ttype, .flags = fl, .help = desc, .cls = OPT\_CL\_MULTIPLE, .type = CT\_XTYPE }

PACKED

\#define PACKED \_\_attribute\_\_((packed))

PTR_TO

\#define PTR\_TO(s, i) &((s\*)0)->i

PURE

\#define PURE \_\_attribute\_\_((pure))

REV_COMPARE

\#define REV\_COMPARE(x,y) COMPARE(y,x)

ROL

\#define ROL(x, bits) (((x) << (bits)) | ((uint)(x) >> (sizeof(uint)\*8 - (bits))))

ROR

\#define ROR(x, bits) (((uint)(x) >> (bits)) | ((x) << (sizeof(uint)\*8 - (bits))))

SENTINEL_CHECK

\#define SENTINEL\_CHECK \_\_attribute\_\_((sentinel))

SHA1_BLOCK_SIZE

\#define SHA1\_BLOCK\_SIZE 64

SHA1_HEX_SIZE

\#define SHA1\_HEX\_SIZE 41

SKIP_BACK

\#define SKIP\_BACK(s, i, p) ((s \*)((char \*)p - OFFSETOF(s, i)))

SLIST_FOR_EACH

\#define SLIST\_FOR\_EACH(type,n,list) for(type n=(void\*)(list).head.next; n; n=(void\*)((snode\*)(n))->next)

SLIST_WALK

\#define SLIST\_WALK(n,list) for(n=(void\*)(list).head.next; (n); (n)=(void\*)((snode\*)(n))->next)

SLIST_WALK_DELSAFE

\#define SLIST\_WALK\_DELSAFE(n,list,prev) for((prev)=(void\*)&(list).head; (n)=(void\*)((snode\*)prev)->next; (prev)=(((snode\*)(prev))->next==(snode\*)(n) ? (void\*)(n) : (void\*)(prev)))

STRINGIFY

\#define STRINGIFY(x) \#x

STRINGIFY_EXPANDED

\#define STRINGIFY\_EXPANDED(x) STRINGIFY(x)

TABLE_COL_BODY

\#define TABLE\_COL\_BODY(\_name, \_type) void table\_col\_\#\#\_name(struct table \*tbl, int col, \_type val) {\

TBL_COL

\#define TBL\_COL(\_idx) { .idx = \_idx, .fmt = XTYPE\_FMT\_DEFAULT, .next\_column = -1 }

TBL_FMT_HUMAN_READABLE

\#define TBL\_FMT\_HUMAN\_READABLE .formatter = &table\_fmt\_human\_readable

UNI_REPLACEMENT

\#define UNI\_REPLACEMENT 0xfffc

UNUSED

\#define UNUSED \_\_attribute\_\_((unused))

UTF8_MAX_LEN

\#define UTF8\_MAX\_LEN 6

XT_SIZE_FMT_UNIT

\#define XT\_SIZE\_FMT\_UNIT(\_unit) (\_unit | XT\_SIZE\_FMT\_FIXED\_UNIT)

XT_TIMESTAMP_FMT_DATETIME

\#define XT\_TIMESTAMP\_FMT\_DATETIME XTYPE\_FMT\_PRETTY

XT_TIMESTAMP_FMT_EPOCH

\#define XT\_TIMESTAMP\_FMT\_EPOCH XTYPE\_FMT\_RAW

bgets_stk

\#define bgets\_stk(fb) \

likely

\#define likely(x) \_\_builtin\_expect((x),1)

unlikely

\#define unlikely(x) \_\_builtin\_expect((x),0)