version 1.5.2.1, 2013/08/21 16:04:14
|
version 1.12.2.2, 2022/01/24 17:07:24
|
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 { |
Line 93 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 308 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)), \ |
Line 318 typedef struct {
|
Line 319 typedef struct {
|
.val_key = 0, .val_len = 0, \ |
.val_key = 0, .val_len = 0, \ |
.val.net = 0LL \ |
.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 351 typedef struct {
|
Line 353 typedef struct {
|
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 374 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 |
*/ |
*/ |
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 388 int ait_vars2buffer(unsigned char * __restrict buf, in
|
Line 390 int ait_vars2buffer(unsigned char * __restrict buf, in
|
*/ |
*/ |
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_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_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 408 int ait_vars2map(unsigned char * __restrict buf, int b
|
Line 427 int ait_vars2map(unsigned char * __restrict buf, int b
|
*/ |
*/ |
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 |
Line 508 ait_val_t *ait_getVars(array_t ** __restrict vars, int
|
Line 535 ait_val_t *ait_getVars(array_t ** __restrict vars, int
|
* ait_resideVars() - Calculate footprint of resided variables into array |
* ait_resideVars() - Calculate footprint of resided variables into array |
* |
* |
* @vars = Variable array |
* @vars = Variable array |
* return: -1 error or !=-1 bytes for whole array | * return: bytes for whole array |
*/ |
*/ |
ssize_t ait_resideVars(array_t * __restrict vars); | size_t ait_resideVars(array_t * __restrict vars); |
/* |
/* |
* ait_sortVarsByKey() - Sorting array with variables by key |
* ait_sortVarsByKey() - Sorting array with variables by key |
* |
* |