version 1.1.1.1, 2013/01/17 10:05:35
|
version 1.14, 2022/02/01 20:46:57
|
Line 12 terms:
|
Line 12 terms:
|
All of the documentation and software included in the ELWIX and AITNET |
All of the documentation and software included in the ELWIX and AITNET |
Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
Releases is copyrighted by ELWIX - Sofia/Bulgaria <info@elwix.org> |
|
|
Copyright 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 | Copyright 2004 - 2022 |
by Michael Pounov <misho@elwix.org>. All rights reserved. |
by Michael Pounov <misho@elwix.org>. All rights reserved. |
|
|
Redistribution and use in source and binary forms, with or without |
Redistribution and use in source and binary forms, with or without |
Line 57 typedef enum {
|
Line 57 typedef enum {
|
i8, i16, i32, i64, /* integers ... */ |
i8, i16, i32, i64, /* integers ... */ |
} ait_type_t; |
} ait_type_t; |
|
|
typedef struct { | typedef struct __packed { |
uint8_t val_type; |
uint8_t val_type; |
union { |
union { |
struct { |
struct { |
uint8_t val_in:1; |
uint8_t val_in:1; |
uint8_t val_be:1; |
uint8_t val_be:1; |
uint8_t val_le:1; |
uint8_t val_le:1; |
uint8_t val_pad:5; | uint8_t val_const:1; |
| uint8_t val_f0:1; |
| uint8_t val_f1:1; |
| uint8_t val_f2:1; |
| uint8_t val_f3:1; |
}; |
}; |
uint8_t val_opt; |
uint8_t val_opt; |
}; |
}; |
Line 89 typedef struct {
|
Line 93 typedef struct {
|
int64_t i64; |
int64_t i64; |
} val; |
} val; |
uint8_t val_data[0]; |
uint8_t val_data[0]; |
} __packed ait_val_t; /* sizeof 16 bytes */ | } /*__packed*/ ait_val_t; /* sizeof 16 bytes */ |
|
|
#define AIT_TYPE(_vl) ((ait_type_t) (_vl)->val_type) |
#define AIT_TYPE(_vl) ((ait_type_t) (_vl)->val_type) |
#define AIT_LEN(_vl) (_vl)->val_len |
#define AIT_LEN(_vl) (_vl)->val_len |
Line 99 typedef struct {
|
Line 103 typedef struct {
|
#define AIT_IN(_vl) (_vl)->val_in |
#define AIT_IN(_vl) (_vl)->val_in |
#define AIT_BE(_vl) (_vl)->val_be |
#define AIT_BE(_vl) (_vl)->val_be |
#define AIT_LE(_vl) (_vl)->val_le |
#define AIT_LE(_vl) (_vl)->val_le |
|
#define AIT_CONST(_vl) (_vl)->val_const |
|
#define AIT_FLAG0(_vl) (_vl)->val_f0 |
|
#define AIT_FLAG1(_vl) (_vl)->val_f1 |
|
#define AIT_FLAG2(_vl) (_vl)->val_f2 |
|
#define AIT_FLAG3(_vl) (_vl)->val_f3 |
#define AIT_BLOB_CHUNKS(_vl, _n) (AIT_LEN((_vl)) / _n + (AIT_LEN((_vl)) % _n) ? 1 : 0) |
#define AIT_BLOB_CHUNKS(_vl, _n) (AIT_LEN((_vl)) / _n + (AIT_LEN((_vl)) % _n) ? 1 : 0) |
#define AIT_ISEMPTY(_vl) (AIT_TYPE((_vl)) == empty) |
#define AIT_ISEMPTY(_vl) (AIT_TYPE((_vl)) == empty) |
|
|
Line 123 typedef struct {
|
Line 132 typedef struct {
|
#define AIT_GET_F32(_vl) (assert(AIT_TYPE((_vl)) == f32), (_vl)->val.f32) |
#define AIT_GET_F32(_vl) (assert(AIT_TYPE((_vl)) == f32), (_vl)->val.f32) |
#define AIT_GET_F64(_vl) (assert(AIT_TYPE((_vl)) == f64), (_vl)->val.f64) |
#define AIT_GET_F64(_vl) (assert(AIT_TYPE((_vl)) == f64), (_vl)->val.f64) |
|
|
#define AIT_SET_DATA(_vl, _p, _len) do { ait_val_t *__val = e_realloc((_vl), (sizeof(ait_val_t) + _len)); \ | #define AIT_SET_DATA(_vl, _p, _len) do { assert(!(_vl) || ((_vl) && !AIT_CONST((_vl)))); \ |
| ait_val_t *__val = e_realloc((_vl), \ |
| (sizeof(ait_val_t) + _len)); \ |
if (__val) { \ |
if (__val) { \ |
void *__p = (_p); \ |
void *__p = (_p); \ |
if (__p) \ |
if (__p) \ |
Line 133 typedef struct {
|
Line 144 typedef struct {
|
(_vl) = __val; \ |
(_vl) = __val; \ |
} \ |
} \ |
} while (0); |
} while (0); |
#define AIT_SET_PTR(_vl, _p, _len) do { ait_val_t *__val = (_vl); assert(__val); \ | #define AIT_SET_PTR(_vl, _p, _len) do { ait_val_t *__val = (_vl); \ |
| assert(__val && !AIT_CONST(__val)); \ |
__val->val_type = ptr; __val->val.ptr = _p; \ |
__val->val_type = ptr; __val->val.ptr = _p; \ |
AIT_LEN(__val) = _len; } while (0) |
AIT_LEN(__val) = _len; } while (0) |
#define AIT_RE_BUF(_vl, _len) do { ait_val_t *__val = (_vl); assert(__val && !__val->val_in); \ | #define AIT_RE_BUF(_vl, _len) do { ait_val_t *__val = (_vl); \ |
| assert(__val && !__val->val_in && !AIT_CONST(__val)); \ |
void *__ptr = e_realloc(AIT_GET_BUF(__val), _len); \ |
void *__ptr = e_realloc(AIT_GET_BUF(__val), _len); \ |
if (__ptr) { \ |
if (__ptr) { \ |
__val->val.buffer = __ptr; AIT_LEN(__val) = _len; \ |
__val->val.buffer = __ptr; AIT_LEN(__val) = _len; \ |
} } while (0) |
} } while (0) |
#define AIT_SET_BUFSIZ(_vl, _c, _len) do { ait_val_t *__val = (_vl); assert(__val); \ | #define AIT_SET_BUFSIZ(_vl, _c, _len) do { ait_val_t *__val = (_vl); \ |
| assert(__val && !AIT_CONST(__val)); \ |
__val->val.buffer = e_malloc(_len); \ |
__val->val.buffer = e_malloc(_len); \ |
if (__val->val.buffer) { \ |
if (__val->val.buffer) { \ |
__val->val_in ^= __val->val_in; \ |
__val->val_in ^= __val->val_in; \ |
__val->val_type = buffer; AIT_LEN(__val) = _len; \ |
__val->val_type = buffer; AIT_LEN(__val) = _len; \ |
memset(__val->val.buffer, _c, _len); \ |
memset(__val->val.buffer, _c, _len); \ |
} } while (0) |
} } while (0) |
#define AIT_SET_BUF(_vl, _v, _len) do { ait_val_t *__val = (_vl); void *__p = (_v); assert(__val); \ | #define AIT_SET_BUF(_vl, _v, _len) do { ait_val_t *__val = (_vl); void *__p = (_v); \ |
| assert(__val && !AIT_CONST(__val)); \ |
__val->val.buffer = e_malloc(_len); \ |
__val->val.buffer = e_malloc(_len); \ |
if (__val->val.buffer) { \ |
if (__val->val.buffer) { \ |
__val->val_in ^= __val->val_in; \ |
__val->val_in ^= __val->val_in; \ |
Line 158 typedef struct {
|
Line 173 typedef struct {
|
else \ |
else \ |
memset(__val->val.buffer, 0, _len); \ |
memset(__val->val.buffer, 0, _len); \ |
} } while (0) |
} } while (0) |
#define AIT_SET_STR(_vl, _v) do { ait_val_t *__val = (_vl); const char *__s = (_v); assert(__val); \ | #define AIT_SET_STR(_vl, _v) do { ait_val_t *__val = (_vl); const char *__s = (_v); \ |
| assert(__val && !AIT_CONST(__val)); \ |
__val->val_type = string; \ |
__val->val_type = string; \ |
__val->val_in ^= __val->val_in; \ |
__val->val_in ^= __val->val_in; \ |
if (__s) { \ |
if (__s) { \ |
Line 170 typedef struct {
|
Line 186 typedef struct {
|
AIT_LEN(__val) = 0; \ |
AIT_LEN(__val) = 0; \ |
} \ |
} \ |
} while (0) |
} while (0) |
#define AIT_SET_STRSIZ(_vl, _len) do { ait_val_t *__val = (_vl); assert(__val); \ | #define AIT_SET_STRSIZ(_vl, _len) do { ait_val_t *__val = (_vl); \ |
| assert(__val && !AIT_CONST(__val)); \ |
__val->val.string = (int8_t*) e_malloc(_len + 1); \ |
__val->val.string = (int8_t*) e_malloc(_len + 1); \ |
if (__val->val.string) { \ |
if (__val->val.string) { \ |
__val->val_in ^= __val->val_in; \ |
__val->val_in ^= __val->val_in; \ |
Line 179 typedef struct {
|
Line 196 typedef struct {
|
} \ |
} \ |
} while (0) |
} while (0) |
#define AIT_SET_STRCAT(_vl, _v) do { ait_val_t *__val = (_vl); const char *__s = (_v); int __l; \ |
#define AIT_SET_STRCAT(_vl, _v) do { ait_val_t *__val = (_vl); const char *__s = (_v); int __l; \ |
assert(__val && !__val->val_in); \ | assert(__val && !__val->val_in && !AIT_CONST(__val)); \ |
assert(AIT_TYPE(__val) == string); \ |
assert(AIT_TYPE(__val) == string); \ |
if (!__s || !*__s) \ |
if (!__s || !*__s) \ |
break; \ |
break; \ |
Line 198 typedef struct {
|
Line 215 typedef struct {
|
} \ |
} \ |
} while (0) |
} while (0) |
#define AIT_SET_STRCPY(_vl, _v) do { ait_val_t *__val = (_vl); const char *__s = (_v); int __l; \ |
#define AIT_SET_STRCPY(_vl, _v) do { ait_val_t *__val = (_vl); const char *__s = (_v); int __l; \ |
assert(__val && !__val->val_in); \ | assert(__val && !__val->val_in && !AIT_CONST(__val)); \ |
assert(AIT_TYPE(__val) == string); \ |
assert(AIT_TYPE(__val) == string); \ |
if (!__s || !*__s) \ |
if (!__s || !*__s) \ |
break; \ |
break; \ |
Line 212 typedef struct {
|
Line 229 typedef struct {
|
AIT_LEN(__val)); \ |
AIT_LEN(__val)); \ |
} } while (0) |
} } while (0) |
#define AIT_SET_STRLCPY(_vl, _v, _len) do { ait_val_t *__val = (_vl); const char *__s = (_v); \ |
#define AIT_SET_STRLCPY(_vl, _v, _len) do { ait_val_t *__val = (_vl); const char *__s = (_v); \ |
assert(__val && !__val->val_in); \ | assert(__val && !__val->val_in && !AIT_CONST(__val)); \ |
assert(AIT_TYPE(__val) == string); \ |
assert(AIT_TYPE(__val) == string); \ |
if (!__s || !*__s) \ |
if (!__s || !*__s) \ |
break; \ |
break; \ |
Line 223 typedef struct {
|
Line 240 typedef struct {
|
strlcpy((char*) __val->val.string, __s, \ |
strlcpy((char*) __val->val.string, __s, \ |
AIT_LEN(__val)); \ |
AIT_LEN(__val)); \ |
} } while (0) |
} } while (0) |
#define AIT_SET_BLOB(_vl, _n, _len) do { ait_val_t *__val = (_vl); assert(__val); \ | #define AIT_SET_BLOB(_vl, _n, _len) do { ait_val_t *__val = (_vl); \ |
| assert(__val && !AIT_CONST(__val)); \ |
__val->val_type = blob; __val->val.blob = _n; \ |
__val->val_type = blob; __val->val.blob = _n; \ |
AIT_LEN(__val) = _len; } while (0) |
AIT_LEN(__val) = _len; } while (0) |
#define AIT_SET_BLOB2(_vl, _bv) do { ait_val_t *__val = (_vl); assert(__val); assert((_bv)); \ | #define AIT_SET_BLOB2(_vl, _bv) do { ait_val_t *__val = (_vl); assert((_bv)); \ |
| assert(__val && !AIT_CONST(__val)); \ |
__val->val_type = blob; AIT_LEN(__val) = \ |
__val->val_type = blob; AIT_LEN(__val) = \ |
(_bv)->blob_len; \ |
(_bv)->blob_len; \ |
__val->val.blob = (_bv)->blob_var; } while (0) |
__val->val.blob = (_bv)->blob_var; } while (0) |
#define AIT_NEW_BLOB(_vl, _len) AIT_SET_BLOB((_vl), 0, _len) |
#define AIT_NEW_BLOB(_vl, _len) AIT_SET_BLOB((_vl), 0, _len) |
|
|
#define AIT_SET_U8(_vl, _n) do { ait_val_t *__val = (_vl); assert(__val); \ | #define AIT_SET_U8(_vl, _n) do { ait_val_t *__val = (_vl); \ |
| assert(__val && !AIT_CONST(__val)); \ |
__val->val_type = u8; __val->val.u8 = _n; \ |
__val->val_type = u8; __val->val.u8 = _n; \ |
AIT_LEN(__val) = sizeof(uint8_t); } while (0) |
AIT_LEN(__val) = sizeof(uint8_t); } while (0) |
#define AIT_SET_U16(_vl, _n) do { ait_val_t *__val = (_vl); assert(__val); \ | #define AIT_SET_U16(_vl, _n) do { ait_val_t *__val = (_vl); \ |
| assert(__val && !AIT_CONST(__val)); \ |
__val->val_type = u16; __val->val.u16 = _n; \ |
__val->val_type = u16; __val->val.u16 = _n; \ |
AIT_LEN(__val) = sizeof(uint16_t); } while (0) |
AIT_LEN(__val) = sizeof(uint16_t); } while (0) |
#define AIT_SET_U32(_vl, _n) do { ait_val_t *__val = (_vl); assert(__val); \ | #define AIT_SET_U32(_vl, _n) do { ait_val_t *__val = (_vl); \ |
| assert(__val && !AIT_CONST(__val)); \ |
__val->val_type = u32; __val->val.u32 = _n; \ |
__val->val_type = u32; __val->val.u32 = _n; \ |
AIT_LEN(__val) = sizeof(uint32_t); } while (0) |
AIT_LEN(__val) = sizeof(uint32_t); } while (0) |
#define AIT_SET_U64(_vl, _n) do { ait_val_t *__val = (_vl); assert(__val); \ | #define AIT_SET_U64(_vl, _n) do { ait_val_t *__val = (_vl); \ |
| assert(__val && !AIT_CONST(__val)); \ |
__val->val_type = u64; __val->val.u64 = _n; \ |
__val->val_type = u64; __val->val.u64 = _n; \ |
AIT_LEN(__val) = sizeof(uint64_t); } while (0) |
AIT_LEN(__val) = sizeof(uint64_t); } while (0) |
#define AIT_SET_I8(_vl, _n) do { ait_val_t *__val = (_vl); assert(__val); \ | #define AIT_SET_I8(_vl, _n) do { ait_val_t *__val = (_vl); \ |
| assert(__val && !AIT_CONST(__val)); \ |
__val->val_type = i8; __val->val.i8 = _n; \ |
__val->val_type = i8; __val->val.i8 = _n; \ |
AIT_LEN(__val) = sizeof(int8_t); } while (0) |
AIT_LEN(__val) = sizeof(int8_t); } while (0) |
#define AIT_SET_I16(_vl, _n) do { ait_val_t *__val = (_vl); assert(__val); \ | #define AIT_SET_I16(_vl, _n) do { ait_val_t *__val = (_vl); \ |
| assert(__val && !AIT_CONST(__val)); \ |
__val->val_type = i16; __val->val.i16 = _n; \ |
__val->val_type = i16; __val->val.i16 = _n; \ |
AIT_LEN(__val) = sizeof(int16_t); } while (0) |
AIT_LEN(__val) = sizeof(int16_t); } while (0) |
#define AIT_SET_I32(_vl, _n) do { ait_val_t *__val = (_vl); assert(__val); \ | #define AIT_SET_I32(_vl, _n) do { ait_val_t *__val = (_vl); \ |
| assert(__val && !AIT_CONST(__val)); \ |
__val->val_type = i32; __val->val.i32 = _n; \ |
__val->val_type = i32; __val->val.i32 = _n; \ |
AIT_LEN(__val) = sizeof(int32_t); } while (0) |
AIT_LEN(__val) = sizeof(int32_t); } while (0) |
#define AIT_SET_I64(_vl, _n) do { ait_val_t *__val = (_vl); assert(__val); \ | #define AIT_SET_I64(_vl, _n) do { ait_val_t *__val = (_vl); \ |
| assert(__val && !AIT_CONST(__val)); \ |
__val->val_type = i64; __val->val.i64 = _n; \ |
__val->val_type = i64; __val->val.i64 = _n; \ |
AIT_LEN(__val) = sizeof(int64_t); } while (0) |
AIT_LEN(__val) = sizeof(int64_t); } while (0) |
#define AIT_SET_F32(_vl, _n) do { ait_val_t *__val = (_vl); assert(__val); \ | #define AIT_SET_F32(_vl, _n) do { ait_val_t *__val = (_vl); \ |
| assert(__val && !AIT_CONST(__val)); \ |
__val->val_type = f32; __val->val.f32 = _n; \ |
__val->val_type = f32; __val->val.f32 = _n; \ |
AIT_LEN(__val) = sizeof(float); } while (0) |
AIT_LEN(__val) = sizeof(float); } while (0) |
#define AIT_SET_F64(_vl, _n) do { ait_val_t *__val = (_vl); assert(__val); \ | #define AIT_SET_F64(_vl, _n) do { ait_val_t *__val = (_vl); \ |
| assert(__val && !AIT_CONST(__val)); \ |
__val->val_type = f64; __val->val.f64 = _n; \ |
__val->val_type = f64; __val->val.f64 = _n; \ |
AIT_LEN(__val) = sizeof(double); } while (0) |
AIT_LEN(__val) = sizeof(double); } while (0) |
|
|
#define AIT_COPY_VAL(_vl, _v) do { assert((_vl)); assert((_v)); \ | #define AIT_COPY_VAL(_vl, _v) do { assert((_vl) && (_v) && !AIT_CONST((_vl))); \ |
memcpy((_vl), (_v), sizeof(ait_val_t)); \ |
memcpy((_vl), (_v), sizeof(ait_val_t)); \ |
switch (AIT_TYPE((_vl))) { \ |
switch (AIT_TYPE((_vl))) { \ |
case buffer: \ |
case buffer: \ |
Line 279 typedef struct {
|
Line 308 typedef struct {
|
break; \ |
break; \ |
} \ |
} \ |
} while (0) |
} while (0) |
|
/* Additional helper macro, which can help about copy data variables */ |
#define AIT_COPY_DATA(_vl, _v) do { AIT_COPY_VAL((_vl), (_v)); \ |
#define AIT_COPY_DATA(_vl, _v) do { AIT_COPY_VAL((_vl), (_v)); \ |
if (AIT_TYPE((_vl)) == data) \ |
if (AIT_TYPE((_vl)) == data) \ |
AIT_SET_DATA((_vl), AIT_GET_DATA((_v)), \ |
AIT_SET_DATA((_vl), AIT_GET_DATA((_v)), \ |
AIT_LEN((_v))); \ |
AIT_LEN((_v))); \ |
} while (0) |
} while (0) |
|
|
|
#define AIT_VAL_INITIALIZER(_vl) { .val_type = empty, { .val_opt = 0 }, \ |
|
.val_key = 0, .val_len = 0, \ |
|
.val.net = 0LL \ |
|
} |
|
#define AIT_VAL_INIT AIT_VAL_INITIALIZER() |
#define AIT_INIT_VAL(_vl) (memset((_vl), 0, sizeof(ait_val_t))) |
#define AIT_INIT_VAL(_vl) (memset((_vl), 0, sizeof(ait_val_t))) |
#define AIT_INIT_VAL2(_vl, _t) do { \ |
#define AIT_INIT_VAL2(_vl, _t) do { \ |
AIT_INIT_VAL((_vl)); \ |
AIT_INIT_VAL((_vl)); \ |
Line 313 typedef struct {
|
Line 348 typedef struct {
|
AIT_LEN(__val) = 0; \ |
AIT_LEN(__val) = 0; \ |
AIT_KEY(__val) = 0; \ |
AIT_KEY(__val) = 0; \ |
} while (0) |
} while (0) |
#define AIT_ZERO_VAL(_vl) do { ait_val_t *__val = (_vl); assert(__val); \ | #define AIT_ZERO_VAL(_vl) do { ait_val_t *__val = (_vl); \ |
| assert(__val && !AIT_CONST(__val)); \ |
switch (AIT_TYPE(__val)) { \ |
switch (AIT_TYPE(__val)) { \ |
case buffer: \ |
case buffer: \ |
case string: \ |
case string: \ |
|
assert(!__val->val_in); \ |
if (__val->val.buffer) \ |
if (__val->val.buffer) \ |
memset(__val->val.buffer, 0, \ |
memset(__val->val.buffer, 0, \ |
AIT_LEN(__val)); \ |
AIT_LEN(__val)); \ |
Line 340 typedef struct {
|
Line 377 typedef struct {
|
* @vars = Variable array |
* @vars = Variable array |
* return: -1 error, 0 nothing done or >0 size of marshaled data |
* return: -1 error, 0 nothing done or >0 size of marshaled data |
*/ |
*/ |
inline int ait_vars2buffer(unsigned char * __restrict buf, int buflen, | int ait_vars2buffer(unsigned char * __restrict buf, int buflen, array_t * __restrict vars); |
array_t * __restrict vars); | |
/* |
/* |
* ait_buffer2vars() - De-marshaling data from buffer to array with variables |
* ait_buffer2vars() - De-marshaling data from buffer to array with variables |
* |
* |
Line 352 inline int ait_vars2buffer(unsigned char * __restrict
|
Line 388 inline int ait_vars2buffer(unsigned char * __restrict
|
*DON'T MODIFY OR DESTROY BUFFER*. =0 call array_Free() before array_Destroy() |
*DON'T MODIFY OR DESTROY BUFFER*. =0 call array_Free() before array_Destroy() |
* return: =NULL error, !=NULL allocated variable array, after use must free with array_Destroy() |
* return: =NULL error, !=NULL allocated variable array, after use must free with array_Destroy() |
*/ |
*/ |
inline array_t *ait_buffer2vars(unsigned char * __restrict buf, int buflen, int vnum, int zcpy); | array_t *ait_buffer2vars(unsigned char * __restrict buf, int buflen, int vnum, int zcpy); |
/* |
/* |
|
* ait_var2tlv() - Marshaling data from variable to TLV buffer |
|
* |
|
* @buf = Buffer, If =NULL then we return only needed buffer size |
|
* @buflen = Size of buffer |
|
* @var = Variable |
|
* return: -1 error, 0 nothing done or >0 size of marshaled data |
|
*/ |
|
int ait_var2tlv(u_char * __restrict buf, int buflen, ait_val_t * __restrict v); |
|
/* |
|
* ait_vars2tlv() - Marshaling data from array with variables to TLV buffer |
|
* |
|
* @buf = Buffer, If =NULL then we return only needed buffer size |
|
* @buflen = Size of buffer |
|
* @vars = Variable array |
|
* return: -1 error, 0 nothing done or >0 size of marshaled data |
|
*/ |
|
int ait_vars2tlv(u_char * __restrict buf, int buflen, array_t * __restrict vars); |
|
/* |
|
* ait_tlv2var() - De-marshaling data from TLV buffer to variable |
|
* |
|
* @buf = Buffer |
|
* @buflen = Size of buffer |
|
* @next_tlv = Next TLV position, if it is !=NULL |
|
* return: =NULL error, !=NULL allocated variable array, after use must free with ait_freeVar() |
|
*/ |
|
ait_val_t *ait_tlv2var(u_char * __restrict buf, int buflen, off_t *next_tlv); |
|
/* |
|
* ait_tlv2vars() - De-marshaling data from TLV buffer to array with variables |
|
* |
|
* @buf = Buffer |
|
* @buflen = Size of buffer |
|
* return: =NULL error, !=NULL allocated variable array, after use must free with ait_freeVars() |
|
*/ |
|
array_t *ait_tlv2vars(u_char * __restrict buf, int buflen); |
|
/* |
* ait_vars2map() - Marshaling data from array with variables to memory map |
* ait_vars2map() - Marshaling data from array with variables to memory map |
* |
* |
* @buf = Buffer |
* @buf = Buffer |
Line 361 inline array_t *ait_buffer2vars(unsigned char * __rest
|
Line 432 inline array_t *ait_buffer2vars(unsigned char * __rest
|
* @vars = Variable array |
* @vars = Variable array |
* return: -1 error, 0 nothing done or >0 size of marshaled data |
* return: -1 error, 0 nothing done or >0 size of marshaled data |
*/ |
*/ |
inline int ait_vars2map(unsigned char * __restrict buf, int buflen, array_t * __restrict vars); | int ait_vars2map(unsigned char * __restrict buf, int buflen, array_t * __restrict vars); |
/* |
/* |
* ait_map2vars() - De-marshaling data from memory map to array with variables |
* ait_map2vars() - De-marshaling data from memory map to array with variables |
* |
* |
Line 372 inline int ait_vars2map(unsigned char * __restrict buf
|
Line 443 inline int ait_vars2map(unsigned char * __restrict buf
|
*DON'T MODIFY OR DESTROY BUFFER*. =0 call array_Free() before array_Destroy() |
*DON'T MODIFY OR DESTROY BUFFER*. =0 call array_Free() before array_Destroy() |
* return: =NULL error, !=NULL allocated variable array, after use must free with array_Destroy() |
* return: =NULL error, !=NULL allocated variable array, after use must free with array_Destroy() |
*/ |
*/ |
inline array_t *ait_map2vars(unsigned char * __restrict buf, int buflen, int vnum, int zcpy); | array_t *ait_map2vars(unsigned char * __restrict buf, int buflen, int vnum, int zcpy); |
|
|
|
/* |
|
* ait_array2vars() - Build array with variables from Null Terminated String Array |
|
* |
|
* @args = Null-terminated array with strings |
|
* @dn = Convert numbers from strings to numbers into variables |
|
* return: =NULL error, !=NULL allocated variable array, after use must free with ait_freeVars() |
|
*/ |
|
array_t *ait_array2vars(const char **args, int dn); |
|
|
/* |
/* |
* ait_allocVar() - Allocate memory for variable |
* ait_allocVar() - Allocate memory for variable |
* |
* |
* return: NULL error or new variable, after use free variable with ait_freeVar() |
* return: NULL error or new variable, after use free variable with ait_freeVar() |
*/ |
*/ |
inline ait_val_t *ait_allocVar(void); | ait_val_t *ait_allocVar(void); |
/* |
/* |
* ait_freeVar() - Free allocated memory for variable |
* ait_freeVar() - Free allocated memory for variable |
* |
* |
* @val = Variable |
* @val = Variable |
* return: none |
* return: none |
*/ |
*/ |
inline void ait_freeVar(ait_val_t ** __restrict val); | void ait_freeVar(ait_val_t ** __restrict val); |
/* |
/* |
* ait_makeVar() - Allocate memory and fill variable |
* ait_makeVar() - Allocate memory and fill variable |
* |
* |
Line 403 ait_val_t *ait_makeVar(ait_type_t type, ...);
|
Line 482 ait_val_t *ait_makeVar(ait_type_t type, ...);
|
* @v = variable |
* @v = variable |
* return: return raw data |
* return: return raw data |
*/ |
*/ |
inline uint64_t ait_getlikeVar(ait_val_t * __restrict v); | uint64_t ait_getlikeVar(ait_val_t * __restrict v); |
/* |
/* |
* ait_setlikeVar() - Set variable like ... |
* ait_setlikeVar() - Set variable like ... |
* |
* |
Line 413 inline uint64_t ait_getlikeVar(ait_val_t * __restrict
|
Line 492 inline uint64_t ait_getlikeVar(ait_val_t * __restrict
|
* @... = data |
* @... = data |
* return: -1 error or 0 ok |
* return: -1 error or 0 ok |
*/ |
*/ |
inline int ait_setlikeVar(ait_val_t * __restrict v, ait_type_t t, unsigned int l, ...); | int ait_setlikeVar(ait_val_t * __restrict v, ait_type_t t, unsigned int l, ...); |
/* |
/* |
* ait_sprintfVar() - Builtin string variable from formatted input |
* ait_sprintfVar() - Builtin string variable from formatted input |
* |
* |
Line 430 int ait_sprintfVar(ait_val_t * __restrict v, const cha
|
Line 509 int ait_sprintfVar(ait_val_t * __restrict v, const cha
|
* @b = 2nd variable |
* @b = 2nd variable |
* return: 0 is equal or !=0 is different |
* return: 0 is equal or !=0 is different |
*/ |
*/ |
inline int ait_cmpVar(ait_val_t * __restrict a, ait_val_t * __restrict b); | int ait_cmpVar(ait_val_t * __restrict a, ait_val_t * __restrict b); |
/* |
/* |
* ait_hashVar() - Generate hash key for variable from string or value |
* ait_hashVar() - Generate hash key for variable from string or value |
* |
* |
Line 447 unsigned short ait_hashVar(ait_val_t * __restrict v, c
|
Line 526 unsigned short ait_hashVar(ait_val_t * __restrict v, c
|
* @varnum = Number of variables |
* @varnum = Number of variables |
* return: =NULL error or !=NULL allocated array |
* return: =NULL error or !=NULL allocated array |
*/ |
*/ |
inline array_t *ait_allocVars(int varnum); | array_t *ait_allocVars(int varnum); |
/* |
/* |
* ait_clrVars() - Clear ait_val_t elements from array |
* ait_clrVars() - Clear ait_val_t elements from array |
* |
* |
* @vars = Variable array |
* @vars = Variable array |
* return: -1 error or size of array |
* return: -1 error or size of array |
*/ |
*/ |
inline int ait_clrVars(array_t * __restrict vars); | int ait_clrVars(array_t * __restrict vars); |
/* |
/* |
* ait_freeVars() - Free ait_val_t array |
* ait_freeVars() - Free ait_val_t array |
* |
* |
* @vars = Variable array |
* @vars = Variable array |
* return: none |
* return: none |
*/ |
*/ |
inline void ait_freeVars(array_t ** __restrict vars); | void ait_freeVars(array_t ** __restrict vars); |
/* |
/* |
* ait_getVars() - Get ait_val_t element from array and if not exists allocate it |
* ait_getVars() - Get ait_val_t element from array and if not exists allocate it |
* |
* |
Line 469 inline void ait_freeVars(array_t ** __restrict vars);
|
Line 548 inline void ait_freeVars(array_t ** __restrict vars);
|
* @n = index of variable into array |
* @n = index of variable into array |
* return: NULL error or !=NULL ait_val_t element |
* return: NULL error or !=NULL ait_val_t element |
*/ |
*/ |
inline ait_val_t *ait_getVars(array_t ** __restrict vars, int n); | ait_val_t *ait_getVars(array_t ** __restrict vars, int n); |
/* |
/* |
|
* ait_resideVars() - Calculate footprint of resided variables into array |
|
* |
|
* @vars = Variable array |
|
* return: bytes for whole array |
|
*/ |
|
size_t ait_resideVars(array_t * __restrict vars); |
|
/* |
* ait_sortVarsByKey() - Sorting array with variables by key |
* ait_sortVarsByKey() - Sorting array with variables by key |
* |
* |
* @vars = Variable array |
* @vars = Variable array |
* @order = Sort order. If =0 ascend or !=0 descend |
* @order = Sort order. If =0 ascend or !=0 descend |
* return: none |
* return: none |
*/ |
*/ |
inline void ait_sortVarsByKey(array_t * __restrict vars, int order); | void ait_sortVarsByKey(array_t * __restrict vars, int order); |
/* |
/* |
* ait_sortVarsByVal() - Sorting array with variables by value |
* ait_sortVarsByVal() - Sorting array with variables by value |
* |
* |
Line 486 inline void ait_sortVarsByKey(array_t * __restrict var
|
Line 572 inline void ait_sortVarsByKey(array_t * __restrict var
|
* @cmp = Custom compare function for sorting. If =NULL compare by value |
* @cmp = Custom compare function for sorting. If =NULL compare by value |
* return: none |
* return: none |
*/ |
*/ |
inline void ait_sortVarsByVal(array_t * __restrict vars, int order, | void ait_sortVarsByVal(array_t * __restrict vars, int order, |
int (*cmp)(const void*, const void*)); |
int (*cmp)(const void*, const void*)); |
/* |
/* |
* ait_findKeyVars() - Find variable by key from array |
* ait_findKeyVars() - Find variable by key from array |
Line 503 ait_val_t *ait_findKeyVars(array_t * __restrict vars,
|
Line 589 ait_val_t *ait_findKeyVars(array_t * __restrict vars,
|
* @key = Search string |
* @key = Search string |
* return: NULL error or not found, !=NULL valid element |
* return: NULL error or not found, !=NULL valid element |
*/ |
*/ |
inline ait_val_t *ait_findKeyHash(array_t * __restrict vars, const char * __restrict key); | ait_val_t *ait_findKeyHash(array_t * __restrict vars, const char * __restrict key); |
/* |
/* |
* ait_hashKeyVars() - Generate hash keys for variables |
* ait_hashKeyVars() - Generate hash keys for variables |
* |
* |
* @vars = Variables |
* @vars = Variables |
* return -1 error or 0 ok |
* return -1 error or 0 ok |
*/ |
*/ |
inline int ait_hashKeyVars(array_t * __restrict vars); | int ait_hashKeyVars(array_t * __restrict vars); |
|
|
|
|
#endif |
#endif |