![]() |
![]()
| ![]() |
![]()
NAME
LIBRARYPDEL Library (libpdel, -lpdel) SYNOPSIS
DESCRIPTIONA A struct structs_type { size_t size; /* size of an instance */ const char *name; /* human informative name */ int tclass; /* type class */ structs_init_t *init; /* type "init" method */ structs_copy_t *copy; /* type "copy" method */ structs_equal_t *equal; /* type "equal" method */ structs_ascify_t *ascify; /* type "ascify" method */ structs_binify_t *binify; /* type "binify" method */ structs_encode_t *encode; /* type "encode" method */ structs_decode_t *decode; /* type "decode" method */ structs_uninit_t *uninit; /* type "uninit" method */ union { /* type specific arguments */ const void *v; const char *s; int i; } args[3]; }; size is equal to the size of one instance of the data structure. The name is ignored by the
tclass is an internal field used by the
STRUCTS_TYPE_PRIMITIVE Primitive type STRUCTS_TYPE_POINTER Pointer STRUCTS_TYPE_ARRAY Variable length array STRUCTS_TYPE_FIXEDARRAY Fixed length array STRUCTS_TYPE_STRUCTURE Structure type STRUCTS_TYPE_UNION Union For user-defined types,
The
typedef int structs_init_t(const struct structs_type *type, void *data); It should initialize the uninitialized region of
memory pointed to by data to be an instance of the
type. The instance should be equal to the default value for the type. On
success,
The
typedef int structs_copy_t(const struct structs_type *type, const void *from, void *to); It should initialize the uninitialized region of
memory pointed to by to to be a new instance of the
type equal to the instance pointed to by from. On
success,
The
typedef int structs_equal_t(const struct structs_type *type, const void *data1, const void *data2); data1 and
data2 point to initialized instances of the type
type.
The
typedef char *structs_ascify_t(const struct structs_type *type, const char *mtype, const void *data); data points to an initialized
instance of the type type.
The
typedef int structs_binify_t(const struct structs_type *type, const char *ascii, void *data, char *ebuf, size_t emax); data points to an
uninitialized region of memory large enough to hold an instance of the type
type.
The
typedef int structs_encode_t(const struct structs_type *type, const char *mtype, struct structs_data *code, const void *data); data points to an initialized
instance of the type type.
struct structs_data { u_int length; /* number of bytes */ u_char *data; /* byte sequence */ }; The binary sequence must be unique, in the sense that
it can be used as input to the
The
typedef int structs_decode_t(const struct structs_type *type, const u_char *code, size_t cmax, void *data, char *ebuf, size_t emax); data points to an
uninitialized region of memory large enough to hold an instance of the type
type.
The
typedef void structs_uninit_t(const struct structs_type *type, void *data); data points to an initialized
instance of the type type.
The args array is useful for when the same functions are used to implement several distinct but related types. Predefined MethodsThe following
RETURN VALUESAll of the above functions indicate an error condition by
returning either -1 or Whenever there is an error, no partial work is done: the state of the parameters has not changed, and nothing has been allocated or freed. SEE ALSOlibpdel(3), snprintf(3), structs(3), structs_type_array(3), structs_type_boolean(3), structs_type_bpf(3), structs_type_data(3), structs_type_dnsname(3), structs_type_ether(3), structs_type_float(3), structs_type_id(3), structs_type_int(3), structs_type_ip4(3), structs_type_ip6(3), structs_type_null(3), structs_type_pointer(3), structs_type_regex(3), structs_type_string(3), structs_type_struct(3), structs_type_time(3), structs_type_union(3), typed_mem(3) HISTORYThe PDEL library was developed at Packet Design, LLC.
AUTHORSArchie Cobbs ⟨archie@freebsd.org⟩ BUGSInstead of the tclass field, each type should provide its own method for accessing sub-elements as appropriate.
|