|
actf 0.0.1
An acute CTF reader
|
Field related methods. More...
#include <stdbool.h>#include <stdint.h>#include <stddef.h>#include "fld_cls.h"#include "types.h"Go to the source code of this file.
Enumerations | |
| enum | actf_fld_type { ACTF_FLD_TYPE_NIL , ACTF_FLD_TYPE_BOOL , ACTF_FLD_TYPE_SINT , ACTF_FLD_TYPE_UINT , ACTF_FLD_TYPE_BIT_MAP , ACTF_FLD_TYPE_REAL , ACTF_FLD_TYPE_STR , ACTF_FLD_TYPE_BLOB , ACTF_FLD_TYPE_ARR , ACTF_FLD_TYPE_STRUCT } |
| Field types. | |
Functions | |
| const actf_fld_cls * | actf_fld_fld_cls (const actf_fld *fld) |
| Get the class of a field. | |
| enum actf_fld_type | actf_fld_type (const actf_fld *fld) |
| Get the type of a field. | |
| const char * | actf_fld_type_name (enum actf_fld_type type) |
| Get the name of a type. | |
| bool | actf_fld_bool (const actf_fld *fld) |
| Get a bool representation of a field. | |
| uint64_t | actf_fld_uint64 (const actf_fld *fld) |
| Get a uint64 representation of the field. | |
| int64_t | actf_fld_int64 (const actf_fld *fld) |
| Get an int64 representation of the field. | |
| float | actf_fld_float (const actf_fld *fld) |
| Get a float representation of the field. | |
| double | actf_fld_double (const actf_fld *fld) |
| Get a double representation of the field. | |
| const char * | actf_fld_str_raw (const actf_fld *fld) |
| Get the raw string data representation of a field. | |
| size_t | actf_fld_str_sz (const actf_fld *fld) |
| Get the number of bytes the string data of a field occupies, including the null-terminator if it exists. | |
| const void * | actf_fld_blob (const actf_fld *fld) |
| Get data of a blob field. | |
| size_t | actf_fld_blob_sz (const actf_fld *fld) |
| Get the number of bytes a blob field occupies. | |
| size_t | actf_fld_arr_len (const actf_fld *fld) |
| Get the number of elements in an array field. | |
| const actf_fld * | actf_fld_arr_idx (const actf_fld *fld, size_t i) |
| Get the element of a specific index in an array field. | |
| const actf_fld * | actf_fld_struct_fld (const actf_fld *fld, const char *key) |
| Get the member with a name matching key in a struct field. | |
| const actf_fld * | actf_fld_struct_fldn (const actf_fld *fld, const char *key, size_t len) |
| Same as actf_fld_struct_fld() but with an explicit key length. | |
| size_t | actf_fld_struct_len (const actf_fld *fld) |
| Get the number of members in a struct field. | |
| const actf_fld * | actf_fld_struct_fld_idx (const actf_fld *fld, size_t i) |
| Get the i:th member of a struct field. | |
| const char * | actf_fld_struct_fld_name_idx (const actf_fld *fld, size_t i) |
| Get the name of the ith member in a struct field. | |
Field related methods.
| const actf_fld_cls * actf_fld_fld_cls | ( | const actf_fld * | fld | ) |
Get the class of a field.
| fld | the field |
| enum actf_fld_type actf_fld_type | ( | const actf_fld * | fld | ) |
Get the type of a field.
| fld | the field |
| const char * actf_fld_type_name | ( | enum actf_fld_type | type | ) |
Get the name of a type.
| type | the type |
| bool actf_fld_bool | ( | const actf_fld * | fld | ) |
Get a bool representation of a field.
| fld | the field |
| uint64_t actf_fld_uint64 | ( | const actf_fld * | fld | ) |
Get a uint64 representation of the field.
| fld | the field |
| int64_t actf_fld_int64 | ( | const actf_fld * | fld | ) |
Get an int64 representation of the field.
| fld | the field |
| float actf_fld_float | ( | const actf_fld * | fld | ) |
Get a float representation of the field.
NOTE: Requires class introspection to know which one is "true" for a field.
| fld | the field |
| double actf_fld_double | ( | const actf_fld * | fld | ) |
Get a double representation of the field.
NOTE: Requires class introspection to know which one is "true" for a field.
| fld | the field |
| const char * actf_fld_str_raw | ( | const actf_fld * | fld | ) |
Get the raw string data representation of a field.
The returned data is read directly from the data stream and is NOT guaranteed to be a null-terminated string. The CTF specification puts no requirements on static or dynamic length strings being null-terminated. The encoding of the returned string is determined by the field class, see actf_fld_cls_encoding().
Use actf_fld_str_raw() together with actf_fld_str_sz() for thrilling zero-copy action with this footgun.
| fld | the string field |
| size_t actf_fld_str_sz | ( | const actf_fld * | fld | ) |
Get the number of bytes the string data of a field occupies, including the null-terminator if it exists.
| fld | the string field |
| const void * actf_fld_blob | ( | const actf_fld * | fld | ) |
Get data of a blob field.
Use actf_fld_blob_sz() to determine the size of the returned data.
| fld | the blob field |
| size_t actf_fld_blob_sz | ( | const actf_fld * | fld | ) |
Get the number of bytes a blob field occupies.
| fld | the blob field |
| size_t actf_fld_arr_len | ( | const actf_fld * | fld | ) |
Get the number of elements in an array field.
| fld | the array field |
Get the element of a specific index in an array field.
| fld | the array field |
| i | the index of the element |
Get the member with a name matching key in a struct field.
| fld | the struct field |
| key | the member name to find |
| size_t actf_fld_struct_len | ( | const actf_fld * | fld | ) |
Get the number of members in a struct field.
| fld | the struct field |
Get the i:th member of a struct field.
| fld | the struct field |
| i | the index of the member |
| const char * actf_fld_struct_fld_name_idx | ( | const actf_fld * | fld, |
| size_t | i ) |
Get the name of the ith member in a struct field.
| fld | the struct field |
| i | the index of the member |