SPRAAK
|
Data Structures | |
struct | SprAtomicSlot |
struct | SprDTCvtAux |
struct | SprDTCvtAuxSrm |
class | SprDT |
class | SprDT_ET |
A base type. More... | |
class | SprDT_EnumT |
struct | SprMPool |
struct | SprStdKeys |
struct | SprSrmDir |
Return structure for the spr_srm_dir() function. More... | |
struct | SprStrSplit |
structure to indicate fields in a multi field line More... | |
union | SprScanfDst |
struct | SprScanfErr |
struct | SprExprScanErr |
Give detailed feedback on a parse error when looking for the end of an expression. More... | |
struct | SprStreamOpenInfo |
struct | SprStreamOpenCPHInfo |
class | SprStream |
The generic stream pointer. For more info, see stream.c. More... | |
Namespaces | |
xref_spr_sec_srm_code | |
Typical usage scenarios of shared resources | |
Macros | |
#define | spr_dt_f64 |
#define | spr_dt_f32 |
#define | spr_dt_i64 |
#define | spr_dt_u64 |
#define | spr_dt_i32 |
#define | spr_dt_u32 |
#define | spr_dt_i16 |
#define | spr_dt_u16 |
#define | spr_dt_i8 |
#define | spr_dt_u8 |
#define | spr_dt_char |
#define | spr_dt_alaw |
#define | spr_dt_ulaw |
#define | spr_dt_dynstr |
#define | spr_dt_int |
#define | spr_dt_uint |
#define | spr_dt_long |
#define | spr_dt_ulong |
#define | spr_dt_ssize |
#define | spr_dt_size |
#define | spr_dt_ptr |
#define | spr_dt_bool |
#define | spr_dt_true |
#define | spr_dt_false |
#define | spr_dt_string |
#define | spr_od_end |
Indicate the end of an argument description list. More... | |
#define | spr_od_info(title, info) |
#define | spr_od_include(other_opt_spec, offs) |
#define | spr_od_alias(alias, original) |
#define | spr_od_funcarg0(name, flags, brief, detailed, func) |
#define | spr_od_funcarg1(name, flags, brief, detailed, func, def_val) |
#define | spr_od_posarg(flags, brief, detailed, type, offs, def_val) |
#define | SPR_MPOOL_CHUNK_SZ |
#define | SPR_MPOOL_INITIALIZER(type, next_el) |
#define | SPR_MPOOL_INIT(mpool, type, next_el) |
#define | SPR_DEFAULT_FSHIFT |
The default frame shift (10 msec). More... | |
#define | SPR_DEFAULT_SAMPLEFREQ |
The default sample frequency (8kHz). More... | |
#define | SPR_MSG_ID(var, name) |
#define | SPR_SET_THREAD_ID(thread_name) |
#define | spr_error(routine,...) |
Send an error message. More... | |
#define | spr_warning(routine,...) |
Send a warning message. More... | |
#define | spr_info(routine,...) |
Send an info message. More... | |
#define | spr_msg_long_start(lvl, routine,...) |
Send a long debug message at a given level lvl. More... | |
#define | spr_msg_async_start(lvl, routine,...) |
#define | SPR_CAST(spr__base, spr__class, spr__object) |
Cast the type of a class object. More... | |
#define | SPR_CLASSID_FORM_CLASS(spr__class) |
#define | SPR_DO(spr__class, spr__method,...) |
Call a method from a class. More... | |
#define | SPR_DO_FPTR(spr__class, spr__method, spr__object) |
Get function pointer for a given method. More... | |
#define | SPR_DO_OPTR(spr__class, spr__method, spr__object) |
Get the adjusted object pointer for a given method. More... | |
#define | SprMethodPtr(spr__class, spr__method) |
Generate a method function pointer type. More... | |
#define | SPR_OBJECT_INIT(spr__class, spr__object) |
Initialize RTTI of a dynamically allocated object. More... | |
#define | SPR_LVAR_OBJECT_INIT(spr__class, spr__object) |
Initialize RTTI of a statically allocated object. More... | |
#define | spr_stderr |
Stream handler for the 'stderr' stream. More... | |
Typedefs | |
typedef SprDTCvtAux *(* | _FuncPtr1_DATATYPE_ )(struct SprDTCvtAuxSrm *aux_data, const SprDT *dt_dst, const SprDT *dt_src) |
typedef void *(* | SprDTCvt1Func )(void *restrict dst, const void *restrict src, const SprDTCvtAux *restrict aux) |
typedef void *(* | SprDTCvtNFunc )(void *restrict dst, const void *restrict src, size_t Nel, const SprDTCvtAux *restrict aux) |
typedef void *(* | SprDTCvtNsiFunc )(void *restrict dst, const void *restrict src, size_t Nel, size_t offs_src_next, const SprDTCvtAux *restrict aux) |
typedef void *(* | SprDTCvtNdiFunc )(void *restrict dst, const void *restrict src, size_t Nel, size_t offs_dst_next, const SprDTCvtAux *restrict aux) |
typedef void *(* | SprDTCvtNsdiFunc )(void *restrict dst, const void *restrict src, size_t Nel, size_t offs_src_next, size_t offs_dst_next, const SprDTCvtAux *restrict aux) |
typedef int(* | SprDTRead1Func )(const SprDT *dt, SprStream *restrict fd, void *restrict dst) |
typedef ssize_t(* | SprDTReadNFunc )(const SprDT *dt, SprStream *restrict fd, void *restrict dst, size_t Nel) |
typedef ssize_t(* | SprDTReadNiFunc )(const SprDT *dt, SprStream *restrict fd, void *restrict dst, size_t Nel, size_t offs_next) |
typedef int(* | SprDTWrite1Func )(const SprDT *dt, SprStream *restrict fd, const void *restrict src) |
typedef int(* | SprDTWriteNFunc )(const SprDT *dt, SprStream *restrict fd, const void *restrict src, size_t Nel) |
typedef int(* | SprDTWriteNiFunc )(const SprDT *dt, SprStream *restrict fd, const void *restrict src, size_t Nel, size_t offs_next) |
typedef ssize_t(* | SprDTSkipNFunc )(const SprDT *dt, SprStream *restrict fd, size_t Nel) |
typedef struct SprHtblStr | SprHtblStr |
typedef void(* | SprMsgCatchFunc )(int lvl, const char *thread, const char *routine, const char *format, va_list *list) |
typedef struct spr_t_object | SprObject |
typedef struct SprSrmEl | SprSrmEl |
typedef void(* | SprSrmFree )(SprSrmEl *srm_el, SprMsgId *routine) |
Prototype of a function to free the content of a resource. More... | |
typedef struct SprStreamOpenParam | SprStreamOpenParam |
typedef int(* | SprStreamOpenProtocol )(SprStreamOpenInfo *info, SprStreamOpenParam *param) |
typedef int(* | SprStreamOpenCoder )(SprStreamOpenInfo *info, SprStreamOpenParam *param) |
typedef char *(* | SprStreamOpenDecodeParam )(SprStreamOpenParam **param_info, char *param_desc, SprStreamOpenInfo *info) |
typedef SprStreamOpenParam *(* | SprStreamOpenFreeParam )(SprStreamOpenInfo *info, SprStreamOpenParam *param_data) |
typedef int(* | SprStreamOpenHdrRead )(SprStreamOpenInfo *info, SprStreamOpenParam *param) |
typedef int(* | SprStreamOpenHdrWrite )(SprStreamOpenInfo *info, SprStreamOpenParam *param) |
typedef int(* | SprStreamOpenCheck )(SprStreamOpenInfo *info, SprStreamOpenParam *param) |
typedef const uint8_t *(* | SprStream_buf_fill )(struct SprStream *restrict fd, int min_fill) |
typedef uint8_t *(* | SprStream_buf_flush )(struct SprStream *restrict fd) |
typedef size_t(* | SprStream_ebuf_read )(struct SprStream *restrict fd, void *restrict buf, size_t size) |
typedef int(* | SprStream_ebuf_write )(struct SprStream *restrict fd, const void *restrict buf, size_t size) |
Functions | |
void | spr_atomic_nop_MBwrite (void) |
void | spr_atomic_nop_MBread (void) |
void | spr_atomic_nop_MBfull (void) |
Impose a full (read+write) memory barrier. More... | |
uint32_t | spr_atomic_get32_MBacquire (volatile uint32_t *ptr) |
uint32_t | spr_atomic_twinget32_MBnone (uint32_t *ptr, uint32_t *val2) |
uint64_t | spr_atomic_twingetc48_18_MBnone (uint64_t *ptr, uint64_t *val2) |
void | spr_atomic_set32_MBrelease (volatile uint32_t *ptr, uint32_t value) |
void | spr_atomic_twinset32_MBrelease (volatile uint32_t *ptr, uint32_t value1, uint32_t value2) |
void | spr_atomic_inc32_MBnone (volatile uint32_t *ptr) |
uint32_t | spr_atomic_dec32_MBnone (volatile uint32_t *ptr) |
uint32_t | spr_atomic_add32_MBnone (volatile uint32_t *ptr, uint32_t value) |
uint32_t | spr_atomic_or32_MBnone (volatile uint32_t *ptr, uint32_t value) |
uint32_t | spr_atomic_and32_MBnone (volatile uint32_t *ptr, uint32_t value) |
uint32_t | spr_atomic_swap32_MBnone (volatile uint32_t *ptr, uint32_t value) |
int | spr_atomic_cas32_MBnone (volatile uint32_t *ptr, uint32_t tst_value, uint32_t new_value) |
int | spr_atomic_twincas32_MBnone (volatile uint32_t *ptr, uint32_t tst_value1, uint32_t tst_value2, uint32_t new_value1, uint32_t new_value2) |
int | spr_atomic_bitset32_MBnone (volatile uint32_t *ptr, int bit_ndx) |
int | spr_atomic_bitclr32_MBnone (volatile uint32_t *ptr, int bit_ndx) |
int | spr_atomic_slot_acquire_nowait (SprAtomicSlot *slot) |
int | spr_atomic_slot_acquire_wait (SprAtomicSlot *slot) |
int | spr_atomic_slot_acquire0_wait (SprAtomicSlot *slot) |
int | spr_atomic_slot_acquire_all (SprAtomicSlot *slot) |
double | spr_strtod (const char *str, const char *str_end, char **eptr) |
char * | spr_dt_qstr_cvt_insitu (char *restrict str) |
char * | spr_dt_qstr_skip (const char *str) |
int | spr_dt_alaw2short (int aval) |
int | spr_dt_short2alaw (int sval) |
int | spr_dt_ulaw2short (int uval) |
int | spr_dt_short2ulaw (int sval) |
int32_t | spr_atoi32 (const char *str, int *err) |
uint32_t | spr_atou32 (const char *str, int *err) |
int64_t | spr_atoi64 (const char *str, int *err) |
uint64_t | spr_atou64 (const char *str, int *err) |
float | spr_atof32 (const char *str, int *err) |
double | spr_atof64 (const char *str, int *err) |
ssize_t | spr_dt_print_vec (SprStream *fd, const SprDT *dt, const void *vec, int vlen, const char *info) |
int | spr_dt_str2vec (const char *str, const SprDT *dt, void *restrict vec, int N) |
int | spr_dt_str2vec_dyn (const char *str, const SprDT *dt, void **dst) |
SprDynStr | spr_dt_vec2str (SprDynStr dst, const SprDT *dt, const void *vec, int N) |
void * | spr_free (void *ptr, const SprMsgId *routine, const char *item) |
void * | spr_malloc (size_t size, const SprMsgId *routine, const char *item) |
void * | spr_realloc (void *ptr, size_t size, const SprMsgId *routine, const char *item) |
unsigned int | spr_dynmem_check (SprMsgId *routine, const char *id) |
Check if the heap is corrupted. This routine is not mult-threading safe. More... | |
char * | spr_strdup (const char *src, const SprMsgId *routine, const char *item) |
char * | spr_strndup (const char *src, size_t size, const SprMsgId *routine, const char *item) |
char * | spr_strcpy (char **restrict dst, const char *restrict src) |
char * | spr_strcat (char *restrict str1, const char *restrict str2, int *restrict str1_len, int str2_len, int *restrict alen) |
char * | spr_dynstr2alloc (SprDynStr str) |
SprDynStr | spr_dynstr_free (SprDynStr str, const SprMsgId *routine, const char *item) |
SprDynStr | spr_dynstr_alloc (size_t size, const SprMsgId *routine, const char *item) |
SprDynStr | spr_dynstr_realloc (SprDynStr str, size_t size, const SprMsgId *routine, const char *item) |
SprDynStr | spr_dynstr_enlarge (SprDynStr str, size_t size, const SprMsgId *routine, const char *item) |
size_t | spr_dynstr_maxlen (SprDynStr str) |
SprDynStr | spr_dynstr_cpy (SprDynStr dst, const char *src) |
SprDynStr | spr_dynstr_ncpy (SprDynStr dst, const char *src, size_t src_len) |
SprDynStr | spr_dynstr_dup (const char *src, const SprMsgId *routine, const char *item) |
SprDynStr | spr_dynstr_ndup (const char *src, size_t src_len) |
SprDynStr | spr_dynstr_cat (SprDynStr restrict str1, const char *restrict str2, int *restrict str1_len, int str2_len) |
const char * | spr_str_nonull_ (const char *str) |
const char * | spr_str_nonull (const char *str, const char *str_null) |
size_t | spr_dynmem_pool_count_alloc (const SprMPool *mpool) |
size_t | spr_dynmem_pool_count_free (const SprMPool *mpool) |
size_t | spr_dynmem_pool_free (SprMPool *mpool, SprMsgId *routine) |
void * | spr_dynmem_pool_enlarge (SprMPool *mpool) |
int | spr_fmsnzb32 (uint32_t val) |
int | spr_fmsnzb32x0 (uint32_t val) |
int | spr_fmsnzb64 (uint64_t val) |
int | spr_fmsnzb64x0 (uint64_t val) |
int | spr_flsnzb32 (uint32_t val) |
int | spr_flsnzb32x0 (uint32_t val) |
int | spr_flsnzb64 (uint64_t val) |
int | spr_flsnzb64x0 (uint64_t val) |
int | spr_popcount16 (uint16_t val) |
Return the number of 1 bits in val. More... | |
int | spr_popcount32 (uint32_t val) |
Return the number of 1 bits in val. More... | |
int | spr_popcount64 (uint64_t val) |
Return the number of 1 bits in val. More... | |
uint32_t | spr_rotl32 (uint32_t val, unsigned int ndx) |
Rotate the value val ndx bits to the left. More... | |
uint32_t | spr_rotr32 (uint32_t val, unsigned int ndx) |
Rotate the value val ndx bits to the right. More... | |
uint64_t | spr_rotl64 (uint64_t val, unsigned int ndx) |
Rotate the value val ndx bits to the left. More... | |
uint64_t | spr_rotr64 (uint64_t val, unsigned int ndx) |
Rotate the value val ndx bits to the right. More... | |
uint64_t | spr_wide_umul32 (uint32_t val1, uint32_t val2) |
Double wide unsigned multiplication. More... | |
uint32_t | spr_wide_umul32hi (uint32_t val1, uint32_t val2) |
int64_t | spr_wide_smul32 (int32_t val1, int32_t val2) |
Double wide signed multiplication. More... | |
int32_t | spr_wide_smul32hi (int32_t val1, int32_t val2) |
int | spr_bittest (const unsigned int *bitarray, int ndx) |
void | spr_bitset (unsigned int *bitarray, int ndx) |
Set the value of bit ndx in bit array bitarray to 1. More... | |
void | spr_bitclr (unsigned int *bitarray, int ndx) |
Set the value of bit ndx in bit array bitarray to 0. More... | |
uint16_t | spr_bswap16 (uint16_t val) |
uint32_t | spr_bswap32 (uint32_t val) |
uint64_t | spr_bswap64 (uint64_t val) |
unsigned int | spr_sqrt_u32 (unsigned int nr) |
int | spr_prime_check (unsigned int nr) |
unsigned int | spr_prime_find (unsigned int nr) |
unsigned int | spr_hash_str (const char *str) |
unsigned int | spr_hash_str2 (const char *str, size_t str_len) |
unsigned int | spr_hash_str_len (const char *str, size_t *len) |
void | spr_htbl_str_init (SprHtblStr *restrict htbl, unsigned int flags, int keystr_offs) |
SprHtblStr * | spr_htbl_str_new (unsigned int flags, int keystr_offs) |
SprHtblStr * | spr_htbl_str_free (SprHtblStr *restrict htbl) |
unsigned int | spr_htbl_str_Nel (const SprHtblStr *restrict htbl) |
const char * | spr_htbl_str_iter (const SprHtblStr *restrict htbl, int *restrict ndx) |
const char * | spr_htbl_str_ndx2str (const SprHtblStr *restrict htbl, int ndx) |
int | spr_htbl_str_find_ndx (const SprHtblStr *restrict htbl, const char *restrict str) |
int | spr_htbl_str_find_ndx2 (const SprHtblStr *restrict htbl, const char *restrict str, size_t str_len) |
const char * | spr_htbl_str_find_key (const SprHtblStr *restrict htbl, const char *restrict str) |
int | spr_htbl_str_add (SprHtblStr *restrict htbl, const char *restrict str) |
int | spr_htbl_str_cadd (SprHtblStr *restrict htbl, const char *restrict str, int *restrict duplicate) |
int | spr_htbl_str_add_replace (SprHtblStr *restrict htbl, const char *restrict str) |
int | spr_htbl_str_rm_key (SprHtblStr *restrict htbl, const char *restrict str) |
int | spr_htbl_str_rm_ndx (SprHtblStr *restrict htbl, int ndx) |
int | spr_hash_strlin_search (const char *restrict const hlst[], int Nel, const char *restrict str) |
int | spr_hash_strlin_search_err (const char *restrict const hlst[], int Nel, const char *restrict str) |
int | spr_hash_strnlin_search (const char *restrict const hlst[], const char *restrict str, size_t str_len) |
int | spr_hash_strnlin_search_err (const char *restrict const hlst[], const char *restrict str, size_t str_len) |
SprKeySet * | spr_kset_alloc (void) |
SprKeySet * | spr_kset_reset (SprKeySet *keys) |
SprKeySet * | spr_kset_free (SprKeySet *keys) |
Free a previously allocated keyset. More... | |
int | spr_kset_set (SprKeySet *keys, const char *key, const char *value) |
int | spr_kset_cset (SprKeySet *keys, const char *key, const char *value) |
int | spr_kset_set_value (SprKeySet *keys, const char *key, const SprDT *dt, const void *value) |
int | spr_kset_set_value_size (SprKeySet *keys, const char *key, ssize_t value) |
int | spr_kset_set_value_double (SprKeySet *keys, const char *key, double value) |
int | spr_kset_set_value_float (SprKeySet *keys, const char *key, float value) |
const char * | spr_kset_get (const SprKeySet *keys, const char *key) |
const char * | spr_kset_get_err (const SprKeySet *keys, const char *key) |
int | spr_kset_get_value (const SprKeySet *keys, const char *key, const SprDT *dt, void *dst, const void *def_val) |
ssize_t | spr_kset_get_value_size (const SprKeySet *keys, const char *key, ssize_t nf_val) |
double | spr_kset_get_value_double (const SprKeySet *keys, const char *key, double nf_val) |
float | spr_kset_get_value_float (const SprKeySet *keys, const char *key, float nf_val) |
int | spr_kset_rm (SprKeySet *keys, const char *key) |
int | spr_kset_get_value_format (const SprKeySet *keys) |
int | spr_kset_get_value_format_alt (const SprKeySet *keys, int alt_val) |
int | spr_kset_get_value_layout (const SprKeySet *keys) |
const SprDT * | spr_kset_get_value_type (const SprKeySet *keys) |
const SprDT * | spr_kset_get_value_type_alt (const SprKeySet *keys, const SprDT *alt_val) |
ssize_t | spr_kset_get_value_dim1 (const SprKeySet *keys) |
ssize_t | spr_kset_get_value_dim1_alt (const SprKeySet *keys, ssize_t alt_val) |
ssize_t | spr_kset_get_value_dim2 (const SprKeySet *keys) |
ssize_t | spr_kset_get_value_dim2_alt (const SprKeySet *keys, ssize_t alt_val) |
ssize_t | spr_kset_get_value_nchan (const SprKeySet *keys) |
ssize_t | spr_kset_get_value_nchan_alt (const SprKeySet *keys, ssize_t alt_val) |
ssize_t | spr_kset_get_value_chanlen (const SprKeySet *keys) |
ssize_t | spr_kset_get_value_chanlen_alt (const SprKeySet *keys, ssize_t alt_val) |
double | spr_kset_get_value_fshift (const SprKeySet *keys) |
double | spr_kset_get_value_fshift_alt (const SprKeySet *keys, double alt_val) |
double | spr_kset_get_value_foffset (const SprKeySet *keys) |
double | spr_kset_get_value_foffset_alt (const SprKeySet *keys, double alt_val) |
int | spr_kset_get_values_dim_and_type (const SprKeySet *keys, int *dim1, int *dim2, const SprDT **dt, const char *fname, SprMsgId *routine) |
int | spr_kset_set_value_dim1 (SprKeySet *keys, ssize_t value) |
int | spr_kset_set_value_dim2 (SprKeySet *keys, ssize_t value) |
SprKeySet * | spr_kset_cpy (const SprKeySet *keys) |
const char * | spr_kset_iter (const SprKeySet *restrict keys, int *restrict iter, const char **restrict value) |
int | spr_kset_print (SprStream *restrict fd, const SprKeySet *restrict keys) |
void | spr_kset_get_stdset (SprStdKeys *restrict res, const SprKeySet *restrict keys) |
Retrieve the 'standard' keys from keys. More... | |
SprKeySet * | spr_kset_set_defaults (SprKeySet *restrict keys, SprStream *restrict fd, const char *restrict fname) |
SprKeySet * | spr_kset_check (const SprKeySet *keys, const char *fname) |
ssize_t | spr_kset_sample_adjust (SprKeySet *restrict keys, const double *restrict fshift_ptr, const double *restrict flength_ptr, int htk_convention) |
int | spr_kset_stream_modif (SprStream *restrict fd) |
int | spr_msg (int lvl, SprMsgId *routine, const char *fmt,...) |
int | spr_msg_check (int lvl, SprMsgId *routine) |
int | spr_set_thread_id (const char *name) |
void | spr_msg_modif_lvl (int lvl) |
Set the global message filter level to lvl, i.e. only messages with a level equal to or lower than lvl will be output (unless routine or thread specific levels are defined. More... | |
int | spr_msg_get_lvl (void) |
int | spr_msg_modif_in (const char *filter_desc, int action) |
int | spr_msg_modif_from (const char *filter_desc, int action) |
SprDynStr | spr_msg_get_in (void) |
SprDynStr | spr_msg_get_from (void) |
int | spr_msg_modif_stream (SprStream *restrict stream, const char *restrict fname) |
void | spr_msg_modif_catch_func (SprMsgCatchFunc handler) |
char * | spr_path_ext_ptr (const char *fname) |
int | spr_path_dir_len (const char *fname) |
char * | spr_path_split_insitu (char **path, char **suffix, char *fname) |
int | spr_signal_report (int action_mask) |
const char * | SPR_CLASSID_FROM_OBJ (const void *object) |
SprSrmEl * | spr_srm_retrieve (unsigned int class_id, const char *name) |
SprSrmEl * | spr_srm_retrieve_alt (unsigned int class_id, const char *name, size_t sz) |
SprSrmEl * | spr_srm_get (unsigned int class_id, const char *name) |
SprSrmEl * | spr_srm_create (unsigned int class_id, const char *name, int name_is_persistent) |
SprSrmEl * | spr_srm_retrieve_or_create (unsigned int class_id, const char *name, int name_is_persistent) |
int | spr_srm_release (SprSrmEl *srm_el, int action) |
void | spr_srm_release_quick (SprSrmEl *srm_el) |
void | spr_srm_release_nocheck (SprSrmEl *srm_el) |
SprSrmDir * | spr_srm_dir (unsigned int class_id) |
int | spr_srm_check_initialized (SprSrmEl *srm_el) |
int | spr_srm_set_free_routine (SprSrmEl *srm_el, SprSrmFree free_func) |
int | spr_srm_set_info_val1_ptr (SprSrmEl *srm_el, void *val) |
int | spr_srm_set_info_val1_ndx (SprSrmEl *srm_el, unsigned int val) |
int | spr_srm_set_info_val2_ptr (SprSrmEl *srm_el, void *val) |
int | spr_srm_set_info_val2_ndx (SprSrmEl *srm_el, unsigned int val) |
void * | spr_srm_get_info_val1_ptr (const SprSrmEl *srm_el, int *err) |
unsigned int | spr_srm_get_info_val1_ndx (const SprSrmEl *srm_el, int *err) |
void * | spr_srm_get_info_val2_ptr (const SprSrmEl *srm_el, int *err) |
unsigned int | spr_srm_get_info_val2_ndx (const SprSrmEl *srm_el, int *err) |
int | spr_isspace (unsigned int chr) |
int | spr_isspace0 (unsigned int chr) |
int | spr_isupper (unsigned int chr) |
int | spr_islower (unsigned int chr) |
int | spr_toupper (unsigned int chr) |
int | spr_tolower (unsigned int chr) |
int | spr_isalpha (unsigned int chr) |
int | spr_isalpha_ (unsigned int chr) |
int | spr_isalnum (unsigned int chr) |
int | spr_isalnum_ (unsigned int chr) |
int | spr_isalphax_ (unsigned int chr) |
int | spr_isalnumx_ (unsigned int chr) |
int | spr_isdigit (unsigned int chr) |
int | spr_isxdigit (unsigned int chr) |
char * | spr_str_skip_space (const char *str) |
Skip 0 or more initial spaces. More... | |
char * | spr_str_skip_word (const char *str) |
int | spr_str_split (char *str, char **tok, int max_tok, char **rem) |
int | spr_str_split_ref (const char *str, SprStrSplit *tok, int max_tok, const char **rem) |
char ** | spr_str_split_dyn (char *str, int *max_tok) |
int | spr_str_trim_spaces (char *str) |
int | spr_scanf_simple (const char *str, const char *fmt, SprScanfDst *dst, SprScanfErr *err) |
char * | spr_expr_scan (const char *str, int len, unsigned int flags, SprExprScanErr *err) |
size_t | spr_stream_read (SprStream *restrict fd, void *restrict buf, size_t size) |
Read from a stream. More... | |
int | spr_stream_write (SprStream *restrict fd, const void *restrict buf, size_t size) |
Write to a stream. More... | |
size_t | spr_stream_skip (SprStream *restrict fd, size_t size) |
Skip data from a stream. More... | |
int | spr_stream_fill (SprStream *restrict fd, int chr, size_t size) |
int | spr_stream_mkdir_parents (SprMsgId *routine, char *path) |
SprStream * | spr_stream_dynbuf_make (const char *name, void *buf, size_t alen, size_t fill, unsigned int flags, SprKeySet *keys) |
SprStream * | spr_stream_dynstr_make (const char *name, SprDynStr str, size_t fill, unsigned int flags, SprKeySet *keys) |
SprStream * | spr_stream_open_write (const char *restrict fname, unsigned int flags, const char *def_keys,...) |
unsigned int | spr_stream_check (const char *restrict fname, unsigned int flags) |
int | spr_fgetc (SprStream *restrict fd) |
int | spr_fgetc_utf8 (SprStream *restrict fd) |
int | spr_ungetc (SprStream *restrict fd, int chr) |
int | spr_ungetc_utf8 (SprStream *restrict fd, int chr) |
int | spr_fputc (SprStream *restrict fd, int chr) |
int | spr_fputc_utf8 (SprStream *restrict fd, int chr) |
SprDynStr | spr_fgets (SprDynStr restrict str, SprStream *restrict fd, unsigned int flags, int *restrict pos) |
char * | spr_fgets_alt (char *restrict str, int *restrict alen, SprStream *restrict fd, unsigned int flags, int *restrict pos) |
ssize_t | spr_fputs (SprStream *restrict fd, const char *restrict str) |
ssize_t | spr_fputsq (SprStream *restrict fd, const char *restrict str) |
ssize_t | spr_fputsoq (SprStream *restrict fd, const char *restrict str) |
int | spr_stream_hex_write (SprStream *restrict fd, const void *restrict data, size_t Nel, size_t el_size) |
int | spr_stream_hex_read (SprStream *restrict fd, void *restrict data, size_t Nel, size_t el_size) |
off_t | spr_stream_copy_data (SprStream *restrict dst, SprStream *restrict src) |
int | spr_fprintf (SprStream *restrict fd, const char *restrict fmt,...) |
int | spr_vfprintf (SprStream *restrict fd, const char *restrict fmt, va_list args) |
size_t | spr_snprintf (char *restrict buf, size_t size, const char *restrict fmt,...) |
size_t | spr_snprintf0 (char *restrict buf, size_t size, const char *restrict fmt,...) |
size_t | spr_vsnprintf (char *restrict buf, size_t size, const char *restrict fmt, va_list args) |
SprDynStr | spr_sprintf (SprDynStr restrict str, const char *restrict fmt,...) |
SprDynStr | spr_vsprintf (SprDynStr restrict str, const char *restrict fmt, va_list args) |
SprDynStr | spr_soprintf (SprDynStr restrict str, size_t *restrict offset, const char *restrict fmt,...) |
SprDynStr | spr_vsoprintf (SprDynStr restrict str, size_t *restrict offset, const char *restrict fmt, va_list args) |
char * | spr_sprintf_alt (SprDynStr restrict str, int *restrict alen, const char *restrict fmt,...) |
char * | spr_vsprintf_alt (char *restrict str, int *restrict alen, const char *restrict fmt, va_list args) |
char * | spr_soprintf_alt (char *restrict str, int *restrict alen, int *restrict pos, const char *restrict fmt,...) |
SprDynStr | spr_vsoprintf_alt (char *restrict str, int *restrict alen, int *restrict pos, const char *restrict fmt, va_list args) |
SprStream * | spr_stream_open_tmp (const char *template_str, unsigned int flags,...) |
size_t | spr_utf8_len (const char *str) |
char * | spr_utf8_next (const char *str) |
char * | spr_utf8_nextN (const char *str, int N) |
char * | spr_utf8_prev (const char *str) |
char * | spr_utf8_get_advance (int *utf_chr, const char *str) |
char * | spr_utf8_check (const char *str, SprMsgId *routine) |
int | spr_utf8_chr_len (unsigned int chr) |
char * | spr_utf8_chr_put_advance (char *str, unsigned int chr) |
Variables | |
SprDT | spr_dt_dt [1] |
SprDT | spr_dt_custom [1] |
const SprOptDesc | spr_od_common [] |
const SprHtblStr | spr_htbl_str_empty |
const char | spr_kset_key_data [] |
the string "DATA" More... | |
const char | spr_kset_key_layout [] |
the string "LAYOUT" More... | |
const char | spr_kset_key_format [] |
the string "FORMAT" More... | |
const char | spr_kset_key_type [] |
the string "TYPE" More... | |
const char | spr_kset_key_dim1 [] |
the string "DIM1" More... | |
const char | spr_kset_key_dim2 [] |
the string "DIM2" More... | |
const char | spr_kset_key_fshift [] |
the string "FSHIFT" More... | |
const char | spr_kset_key_foffset [] |
the string "FOFFSET" More... | |
const char | spr_kset_key_flength [] |
the string "FLENGTH" More... | |
const char | spr_kset_key_nchan [] |
the string "NCHAN" More... | |
const char | spr_kset_key_chanlen [] |
the string "CHANLEN" More... | |
const char | spr_kset_key_vlen [] |
the string "VLEN" More... | |
const char | spr_kset_key_vnum [] |
the string "VNUM" More... | |
const char | spr_kset_key_compress [] |
the string "COMPRESS" More... | |
const char | spr_kset_key_samplefreq [] |
the string "SAMPLEFREQ" More... | |
const char | spr_kset_val_minus1 [] |
const char *const | spr_kset_format_str [] |
const char *const | spr_kset_layout_str [] |
const char *const | spr_kset_data_str [SPR_KEY_DATA_NR+1] |
SprStream * | spr_msg_stream |
volatile int | spr_signal_flag |
break requested ? More... | |
const char | spr_str_srm_cid_classid [] |
const char | spr_str_srm_cid_datatype [] |
const char | spr_str_srm_cid_datatype_cvt [] |
const char | spr_str_srm_cid_dynlib [] |
const char | spr_str_srm_cid_globvar [] |
const char | spr_str_srm_cid_vfs_open [] |
const char | spr_str_srm_cid_vfs_ext [] |
const char | spr_str_srm_cid_vfs_dev [] |
const char | spr_str_srm_cid_vfs_mem [] |
const char * | spr_stream_tmpdir |
#define spr_dt_f64 |
The SPRAAK data type identifier (SprDT element) for a double precision (64 bits) float. The string respresentation (used in file headers, messages, ...) of this type is "F64".
#define spr_dt_f32 |
The SPRAAK data type identifier (SprDT element) for a single precision (32 bits) float. The string respresentation (used in file headers, messages, ...) of this type is "F32".
#define spr_dt_i64 |
The SPRAAK data type identifier (SprDT element) for a 64 bits signed integer. The string respresentation (used in file headers, messages, ...) of this type is "I64".
#define spr_dt_u64 |
The SPRAAK data type identifier (SprDT element) for a 64 bits unsigned integer. The string respresentation (used in file headers, messages, ...) of this type is "U64".
#define spr_dt_i32 |
The SPRAAK data type identifier (SprDT element) for a 32 bits signed integer. The string respresentation (used in file headers, messages, ...) of this type is "I32".
#define spr_dt_u32 |
The SPRAAK data type identifier (SprDT element) for a 32 bits unsigned integer. The string respresentation (used in file headers, messages, ...) of this type is "U32".
#define spr_dt_i16 |
The SPRAAK data type identifier (SprDT element) for a 16 bits signed integer. The string respresentation (used in file headers, messages, ...) of this type is "I16".
#define spr_dt_u16 |
The SPRAAK data type identifier (SprDT element) for a 16 bits unsigned integer. The string respresentation (used in file headers, messages, ...) of this type is "U16".
#define spr_dt_i8 |
The SPRAAK data type identifier (SprDT element) for an 8 bits signed integer. The string respresentation (used in file headers, messages, ...) of this type is "I8".
#define spr_dt_u8 |
The SPRAAK data type identifier (SprDT element) for an 8 bits unsigned integer. The string respresentation (used in file headers, messages, ...) of this type is "U8".
#define spr_dt_char |
The SPRAAK data type identifier (SprDT element) for a dynamically allocated string. The string respresentation (used in file headers, messages, ...) of this type is "DYNSTR".
#define spr_dt_alaw |
The SPRAAK data type identifier (SprDT element) for an alaw code (8 bits unsigned integer). The string respresentation (used in file headers, messages, ...) of this type is "ALAW".
#define spr_dt_ulaw |
The SPRAAK data type identifier (SprDT element) for an ulaw code (8 bits unsigned integer). The string respresentation (used in file headers, messages, ...) of this type is "ULAW".
#define spr_dt_dynstr |
The SPRAAK data type identifier (SprDT element) for a dynamically allocated string. The string respresentation (used in file headers, messages, ...) of this type is "DYNSTR".
#define spr_dt_int |
The SPRAAK data type identifier (SprDT element) for a standard integer (int). The string respresentation (used in file headers, messages, ...) of this type is "I32".
#define spr_dt_uint |
The SPRAAK data type identifier (SprDT element) for a standard unsigned integer (unsigned int). The string respresentation (used in file headers, messages, ...) of this type is "U32".
#define spr_dt_long |
#define spr_dt_ulong |
#define spr_dt_ssize |
#define spr_dt_size |
#define spr_dt_ptr |
Some generic pointer type. Useful for dumping the values to the screen.
#define spr_dt_bool |
The SPRAAK data type identifier (SprDT element) for a boolean (an integer having the values 0 or 1). The string respresentation (used in file headers, messages, ...) of this type is "BOOL".
#define spr_dt_true |
The SPRAAK data type identifier (SprDT element) for a boolean (an integer having the values 0 or 1) that has as default value 1 (true). The string respresentation (used in file headers, messages, ...) of this type is "BOOL".
#define spr_dt_false |
The SPRAAK data type identifier (SprDT element) for a boolean (an integer having the values 0 or 1) that has as default value 0 (false). The string respresentation (used in file headers, messages, ...) of this type is "BOOL".
#define spr_dt_string |
The SPRAAK data type identifier (SprDT element) for a string pointer. The string respresentation (used in file headers, messages, ...) of this type is "STRING".
#define spr_od_end |
Indicate the end of an argument description list.
#define spr_od_info | ( | title, | |
info | |||
) |
Specify some (global) comment instead of an argument. The title and info arguments are strings containing the paragraph title (optional) and the actual information.
#define spr_od_include | ( | other_opt_spec, | |
offs | |||
) |
Include the content of an other (pre-existent) option description other_opt_spec.
#define spr_od_alias | ( | alias, | |
original | |||
) |
Define an alias alias for an other (earlier defined) options original.
#define spr_od_funcarg0 | ( | name, | |
flags, | |||
brief, | |||
detailed, | |||
func | |||
) |
Define an option that will trigger a call to the function (*func)(const SprOptDesc*od_match,const SprOptDesc*od_list)
when specified (the normal result of specifying an option is decoding the argument and storing its values). The function must return 0 on success and -1 on failure.
#define spr_od_funcarg1 | ( | name, | |
flags, | |||
brief, | |||
detailed, | |||
func, | |||
def_val | |||
) |
Define an option that will trigger a call to the function (*func)(const SprOptDesc*od_match,const char *arg_val)
when specified (the normal result of specifying an option is decoding the argument and storing its values). The function must return 0 on success and -1 on failure.
#define spr_od_posarg | ( | flags, | |
brief, | |||
detailed, | |||
type, | |||
offs, | |||
def_val | |||
) |
Define a positional (ordinal) argument, i.e. an argument with no option name. Ordinal arguments are filled in on a first come first served base.
#define SPR_MPOOL_CHUNK_SZ |
Number of elements allocated per chunk (i.e. per call to spr_dynmem_pool_enlarge()).
#define SPR_MPOOL_INITIALIZER | ( | type, | |
next_el | |||
) |
Initialize a memory pool for a certain type type using type->next_el to link the free elements together.
#define SPR_MPOOL_INIT | ( | mpool, | |
type, | |||
next_el | |||
) |
Initialize a memory pool for a certain type type using type->next_el to link the free elements together.
#define SPR_DEFAULT_FSHIFT |
The default frame shift (10 msec).
#define SPR_DEFAULT_SAMPLEFREQ |
The default sample frequency (8kHz).
#define SPR_MSG_ID | ( | var, | |
name | |||
) |
Macro to set the routine id (requires that the name is static). For examples, see the global comment.
#define SPR_SET_THREAD_ID | ( | thread_name | ) |
#define spr_error | ( | routine, | |
... | |||
) |
Send an error message.
Is identical to spr_msg(SPR_ERROR,routine,fmt,...)
#define spr_warning | ( | routine, | |
... | |||
) |
Send a warning message.
Is identical to spr_msg(SPR_WARNING,routine,...)
#define spr_info | ( | routine, | |
... | |||
) |
Send an info message.
Is identical to spr_msg(SPR_INFO,routine,...)
#define spr_msg_long_start | ( | lvl, | |
routine, | |||
... | |||
) |
Send a long debug message at a given level lvl.
#define spr_msg_async_start | ( | lvl, | |
routine, | |||
... | |||
) |
Try to send a long debug message at a given level lvl from s signal handler. No message will be sent if the message system is busy (should be fixed).
#define SPR_CAST | ( | spr__base, | |
spr__class, | |||
spr__object | |||
) |
Cast the type of a class object.
Cast the type of the object spr__object of type spr__class to one of its base classes spr__base.
#define SPR_CLASSID_FORM_CLASS | ( | spr__class | ) |
Get the id (a unique pointer to a string) of the class the object belongs to.
#define SPR_DO | ( | spr__class, | |
spr__method, | |||
... | |||
) |
Call a method from a class.
Call method spr__method from and object of class spr__class. For non static methods the first argument must be the object.
For static methods with no arguments, the last argument must be empty, i.e. call the method by using a
construct.
#define SPR_DO_FPTR | ( | spr__class, | |
spr__method, | |||
spr__object | |||
) |
Get function pointer for a given method.
Get the function pointer for method spr__method from class spr__class given object spr__object. For static methods, the third argument must be empty or NULL. For an example see SprMethodPtr.
#define SPR_DO_OPTR | ( | spr__class, | |
spr__method, | |||
spr__object | |||
) |
Get the adjusted object pointer for a given method.
Get the adjusted object pointer for method <spr__method) from class spr__class given object spr__object. For an example see SprMethodPtr.
#define SprMethodPtr | ( | spr__class, | |
spr__method | |||
) |
Generate a method function pointer type.
Generate the type for a function pointer to method spr__method from class spr__class.
Example:
#define SPR_OBJECT_INIT | ( | spr__class, | |
spr__object | |||
) |
Initialize RTTI of a dynamically allocated object.
Initialize the run-time type information (RTTI) of an object that is dynamically allocated. This must be done for every new allocated object!
Example:
#define SPR_LVAR_OBJECT_INIT | ( | spr__class, | |
spr__object | |||
) |
Initialize RTTI of a statically allocated object.
Initialize the RTTI of an object that is statically allocated. This must be done for every local or static variable that is an object!
Example:
#define spr_stderr |
Stream handler for the 'stderr' stream.
typedef SprDTCvtAux*(* _FuncPtr1_DATATYPE_)(struct SprDTCvtAuxSrm *aux_data, const SprDT *dt_dst, const SprDT *dt_src) |
typedef void*(* SprDTCvt1Func)(void *restrict dst,const void *restrict src,const SprDTCvtAux *restrict aux) |
Function pointer to a function that converts data from one type to another and returns &dst[1] if successfull or NULL on failure. See SprDT::get_cvt1_func() for more details.
typedef void*(* SprDTCvtNFunc)(void *restrict dst,const void *restrict src,size_t Nel,const SprDTCvtAux *restrict aux) |
Function pointer to a function that converts data from one type to another and returns &dst[Nel] if successfull or NULL on failure. See SprDT::get_cvtN_func() for more details.
typedef void*(* SprDTCvtNsiFunc)(void *restrict dst,const void *restrict src,size_t Nel,size_t offs_src_next,const SprDTCvtAux *restrict aux) |
Function pointer to a function that converts data from one type to another and returns &dst[Nel] if successfull or NULL on failure. See SprDT::get_cvtNsi_func() for more details.
typedef void*(* SprDTCvtNdiFunc)(void *restrict dst,const void *restrict src,size_t Nel,size_t offs_dst_next,const SprDTCvtAux *restrict aux) |
Function pointer to a function that converts data from one type to another and returns (dst+Nel*offs_dst_next) if successfull or NULL on failure. See SprDT::get_cvtNdi_func() for more details.
typedef void*(* SprDTCvtNsdiFunc)(void *restrict dst,const void *restrict src,size_t Nel,size_t offs_src_next,size_t offs_dst_next,const SprDTCvtAux *restrict aux) |
Function pointer to a function that converts data from one type to another and returns (dst+Nel*offs_dst_next) if successfull or NULL on failure. See SprDT::get_cvtNsdi_func() for more details.
Pointer to a SprDT::read1() method, see SprDT::get_read1_func() and SprDT::read1() for more details.
typedef ssize_t(* SprDTReadNFunc)(const SprDT *dt, SprStream *restrict fd, void *restrict dst, size_t Nel) |
Pointer to a SprDT::readN() method, see SprDT::get_readN_func() and SprDT::readN() for more details.
typedef ssize_t(* SprDTReadNiFunc)(const SprDT *dt, SprStream *restrict fd, void *restrict dst, size_t Nel, size_t offs_next) |
Pointer to a SprDT::readNi() method, see SprDT::get_readNi_func() and SprDT::readNi() for more details.
Pointer to a SprDT::write1() method, see SprDT::get_write1_func() and SprDT::write1() for more details.
typedef int(* SprDTWriteNFunc)(const SprDT *dt, SprStream *restrict fd, const void *restrict src, size_t Nel) |
Pointer to a SprDT::writeN() method, see SprDT::get_writeN_func() and SprDT::writeN() for more details.
typedef int(* SprDTWriteNiFunc)(const SprDT *dt, SprStream *restrict fd, const void *restrict src, size_t Nel, size_t offs_next) |
Pointer to a SprDT::writeNi() method, see SprDT::get_writeNi_func() and SprDT::writeNi() for more details.
Pointer to a SprDT::skipN() method, see SprDT::get_skipN_func() and SprDT::skipN() for more details.
typedef struct SprHtblStr SprHtblStr |
A hash table that stores strings (the keys) and, if desired, allows to user to map these keys to corresponding values. The hash table is designed to be compact (especially when only few keys need to be stored), and can be easily embedded in a larger structure. Assigning values to the keys in the hash table can be done in two ways (which can even be combined).
The first method uses the fact that the keys are internally mapped to sequential indexes. I.e. the indices returned by e.g. spr_htbl_qstr2ndx_find() will be 0...N-1, N being the numbers of strings in the hash table. Otherwise said, the keys are mapped to indexes 0...N-1 and the indeces equal the order in which the keys were added to the hash table. In case elements are removed, gaps occur in the sequential ordering (unless it was the last added key that was removed). When adding new keys afterwards, the gaps created in the sequential numbering by removing elements are filled first, after which the indices for new strings will again be sequential.
Instead of relaying on the sequential indexes, the user can also embed extra information (the value) in the strings (the keys) stored in the hash table. The extra information can either follow the terminating '\0' of the key-string or it can precede the key-string. Note that all functions (except for spr_htbl_str_free()) are agnostic concerning extra information preceding or following the key-string. In practice, this means that when using embedded extra information preceding the key-string one should always offset the pointer to point to the key-string field when calling any of the 'add' routines, and know that all returned pointers will again point to the key-string field (and hence should be negatively offset if one want to access the embedded extra information).
Below is an example of how extra information can be embedded:
typedef void(* SprMsgCatchFunc)(int lvl,const char *thread,const char *routine,const char *format,va_list *list) |
Function to catch severe (WARNING & ERROR) messages with. Calls to such a function will be serialized (protected by a mutex). Only one handler can be installed.
typedef struct spr_t_object SprObject |
An empty object (except for the the pointer to the run-time type information). The presence of the RTTI-pointer allows classes that derive directly or indirectly from this class to have virtual methods.
The basic type for a shared resource. This is an opaque type. All modifiable content can be accessed by means of (inline) functions.
Prototype of a function to free the content of a resource.
typedef struct SprStreamOpenParam SprStreamOpenParam |
typedef int(* SprStreamOpenProtocol)(SprStreamOpenInfo *info, SprStreamOpenParam *param) |
Pointer to a function that opens the stream with as "path name" info->fname. The param argument is either NULL or a structure made earlier by a call to the corresponding SprStreamOpenDecodeParam function. The remaining information (keyset, flags) can be found in info. See spr_stream_open() for the meaning of the bits in info->flags.
typedef int(* SprStreamOpenCoder)(SprStreamOpenInfo *info, SprStreamOpenParam *param) |
Point to a function to push and extra coder (or several) on top of the open file info->fd. The param argument is either NULL or a structure made earlier by a call to the corresponding SprStreamOpenDecodeParam function.
typedef char*(* SprStreamOpenDecodeParam)(SprStreamOpenParam **param_info, char *param_desc, SprStreamOpenInfo *info) |
Point to a function to decode the parameters specified in param_desc and store whatever data that will be needed in the corresponding SprStreamOpenProtocol, SprStreamOpenCoder, SprStreamOpenHdrRead or SprStreamOpenHdrWrite function in a newly allocated data structure.
How the parameters in param_desc are formatted free although the format "key=value;" (value van be a quoted string) is strongly advised since this is consistent with how all the other parameters are passed. The only real constraint on the parameter description is that it starts with an square bracket open character ('[') and stops at an square bracket close character (']'). Note that the square bracket open character may have been replaced by a '\0' beforehand.
The processed part of param_desc may be used as temporary buffer (or scratch pad) which is guaranteed to last until the parameter info *param_info is freed.
typedef SprStreamOpenParam*(* SprStreamOpenFreeParam)(SprStreamOpenInfo *info, SprStreamOpenParam *param_data) |
Point to a function to free the parameter data param_data made by a previous call to the corresponding SprStreamOpenDecodeParam function. The info argument is typically not needed, but is given for the sake of orthogonality w.r.t. the other functions.
typedef int(* SprStreamOpenHdrRead)(SprStreamOpenInfo *info, SprStreamOpenParam *param) |
Point to a function to read the file header from info->fd and fill in the keys in info->keys (any previously present keys are considered to be default values). On entry, info->keys may be NULL. The param argument points to the data structure made by a call to the corresponding SprStreamOpenDecodeParam function.
typedef int(* SprStreamOpenHdrWrite)(SprStreamOpenInfo *info, SprStreamOpenParam *param) |
Pointer to a function to write a file header containing the keys in info->keys to info->fd. On entry, info->keys may be NULL (is a valid keyset for some header formats), so do not forget to check this if you need a non NULL keyset. The param argument points to the data structure made by a call to the corresponding SprStreamOpenDecodeParam function.
typedef int(* SprStreamOpenCheck)(SprStreamOpenInfo *info, SprStreamOpenParam *param) |
Pointer to a function to check the capabilities of a stream.
typedef const uint8_t*(* SprStream_buf_fill)(struct SprStream *restrict fd, int min_fill) |
typedef uint8_t*(* SprStream_buf_flush)(struct SprStream *restrict fd) |
typedef size_t(* SprStream_ebuf_read)(struct SprStream *restrict fd, void *restrict buf, size_t size) |
typedef int(* SprStream_ebuf_write)(struct SprStream *restrict fd, const void *restrict buf, size_t size) |
enum SprOptFlags |
enum SPR_KEY_FORMAT |
Possible values for the 'FORMAT' key. This is a closed list (i.e. these are the only legal values). The values written in the header should be one of the following:
Enumerator | |
---|---|
SPR_KEY_FORMAT_BIN01 |
Binary data, little endian format. |
SPR_KEY_FORMAT_BIN10 |
Binary data, big endian format. |
SPR_KEY_FORMAT_ASCII |
Ascii data. |
SPR_KEY_FORMAT_NR |
enum SPR_KEY_LAYOUT |
Possible values for the 'LAYOUT' key. This is a closed list (i.e. these are the only legal values). The values written in the header should be one of the following:
enum SPR_KEY_DATA |
Possible values for the 'DATA' key. This is an open list (i.e. these are more legal values then listed here). Typical values found in headers are:
The string representations belonging to the different SPR_KEY_DATA_XXX constants.
anonymous enum |
anonymous enum |
Possible actions for spr_msg_modif_in() and spr_msg_modif_from().
Enumerator | |
---|---|
SPR_MSG_SET | |
SPR_MSG_RM | |
SPR_MSG_ADD |
anonymous enum |
anonymous enum |
Possible actions for the spr_srm_release() routine.
Enumerator | |
---|---|
SPR_SRM_EXPORT | |
SPR_SRM_RELEASE | |
SPR_SRM_RELEASE2 | |
SPR_SRM_RELEASE_DELAYED | |
SPR_SRM_CHECK_RELEASE | |
SPR_SRM_AD_ENLIST | |
SPR_SRM_AD_DELIST | |
SPR_SRM_RELEASE_UNLOCKED |
anonymous enum |
A set of default classes with known index for storing shared resources in.
Enumerator | |
---|---|
SPR_SRM_CID_CLASSID |
Class-id are also shared resources and hence hace a class to store them in. 'val1' contains the class number. |
SPR_SRM_CID_DATATYPE |
Datatypes. 'val1' is a pointer to the corresponding SprDT structure. |
SPR_SRM_CID_DTCVT |
Conversion rules between datatypes. 'val1' is a pointer to the actual conversion routine; 'val2' is a pointer to the auxilary data (of the type SprDtCvtAuxSrm). |
SPR_SRM_CID_DYNLIB |
Dynamic libraries. 'val1' is a pointer to the handle for the dynamic labrary (see dlopen()). |
SPR_SRM_CID_GLOBVAR |
Global variables. 'val1' is a pointer to ??? |
SPR_SRM_CID_VFS_OPEN |
Handler to cope with a stream coder/protocol/header. 'val1' is a pointer to a SprStreamOpenCPHInfo strcuture. |
SPR_SRM_CID_VFS_EXT |
Information about file name extensions and their meaning. 'val1' is a pointer to a SprStreamOpenExtInfo strcuture. |
SPR_SRM_CID_VFS_DEV |
Device in the virtual file system. 'val1' is a pointer to ??? |
SPR_SRM_CID_VFS_MEM |
File in meory in the virtual file system. 'val1' is a pointer to ??? |
SPR_SRM_CID_RESERVED |
These low valued class-id are reserved, i.e. they cannot be released, destroyed, ... |
enum SprExprScanCodes |
Specify when an expression ends: scan until a valid seperator is found.
enum SprStreamFlags |
Flags for opening a file.
Flags for internal use.
Enumerator | |
---|---|
SPR_STREAM_CREATE |
Create the file if it does not exist. |
SPR_STREAM_TRUNC |
When opening a file for writing, truncate the file to length 0. |
SPR_STREAM_APPEND |
Open the file and position the write pointer to the end of the file. |
SPR_STREAM_READ |
Open the file for reading (the default). |
SPR_STREAM_WRITE |
Open the file for writing. |
SPR_STREAM_RW |
Open the file for reading and writing. The stream will be put in WRITE mode initialy if the CREATE, TRUNC or APPEND flag is set as well, otherwise the initial mode for the stream will be the READ mode. |
SPR_STREAM_LINEBUF |
Buffer the IO read operations on a line by line base instead of the normal 4K blocks. |
SPR_STREAM_UNBUF |
Do minimal (i.e. almost no) buffering on the IO operations. |
SPR_STREAM_SILENT |
Do not report errors on this stream via the message system. |
SPR_STREAM_SILENTEOF |
Do not report EOF errors on this stream via the message system. |
SPR_STREAM_NONBLOCK |
Open the file in a non-blocking mode, i.e. reads will return the available amount of data only, writes may not write all requested data, so retries may be needed. |
SPR_STREAM_KEEPKSET |
Do not free the keyset given as argument to the spr_stream_open() routine when opening the stream fails. |
SPR_STREAM_NOHDR |
Open the file without writing/reading a header. |
SPR_STREAM_SEEK |
Make sure random seeks on the file are possible. |
SPR_STREAM_REWIND |
Make sure a rewind (full restart) on the file is possible. |
SPR_STREAM_AUTOCLOSE |
Automatically close the file when the program terminates. |
SPR_STREAM_AUTORM |
Automatically close and remove the file when the program terminates. |
SPR_STREAM_ASCII |
Force the stream in ASCII mode after opening it. |
anonymous enum |
Possible 'modes' as stream can be in. The 'mode' is used primarily by the SprDT read and write methods.
void spr_atomic_nop_MBwrite | ( | void | ) |
Impose a write memory barrier. This means that to the outside world, it must appear as if all writes before the barrier have been finished before any of the writes after the barrier are executed.
void spr_atomic_nop_MBread | ( | void | ) |
Impose a read memory barrier. This means that all reads (from the out-side world) before the barrier must have been finished before any of the reads after the barrier are executed.
void spr_atomic_nop_MBfull | ( | void | ) |
Impose a full (read+write) memory barrier.
uint32_t spr_atomic_get32_MBacquire | ( | volatile uint32_t * | ptr | ) |
Read a 32bits value from memory and ensure that later memory reads from the outside world are started after this atomic read, i.e. do not read values older than what was read in the atomic operation.
uint32_t spr_atomic_twinget32_MBnone | ( | uint32_t * | ptr, |
uint32_t * | val2 | ||
) |
Read two 32 bit values from memory in a single atomic operation (very usefull for cache tables).
uint64_t spr_atomic_twingetc48_18_MBnone | ( | uint64_t * | ptr, |
uint64_t * | val2 | ||
) |
Read a pointer (48bits) and a transaction counter (18bits) from memory in a single (64bits) atomic operation. This is a poor-mans solution for 64bits machines that do not provide real twin-ops on 64bits quantities (and only use 48 of the 64 bits for pointers + assures that pointers are aligned to al least 32bits quantities). The chance of having an ABA-problems with a 64bits transaction counters is practically zero (it would take current computers 100+ years to warp-around the counter). 18bits counter are a lot less safe, so avoid this construct for essential code.
void spr_atomic_set32_MBrelease | ( | volatile uint32_t * | ptr, |
uint32_t | value | ||
) |
Write value to the given memory location and ensure that all earlier memory writes become visible to the outside world before the atomic write.
void spr_atomic_twinset32_MBrelease | ( | volatile uint32_t * | ptr, |
uint32_t | value1, | ||
uint32_t | value2 | ||
) |
Write (value1,value2) to the given memory location in a single atomic operation (very usefull for cache tables).
void spr_atomic_inc32_MBnone | ( | volatile uint32_t * | ptr | ) |
Increment the value on the given memory address by one.
uint32_t spr_atomic_dec32_MBnone | ( | volatile uint32_t * | ptr | ) |
Decrement the value on the given memory address by one and test for zero.
uint32_t spr_atomic_add32_MBnone | ( | volatile uint32_t * | ptr, |
uint32_t | value | ||
) |
Add value to the value on a given memory address.
uint32_t spr_atomic_or32_MBnone | ( | volatile uint32_t * | ptr, |
uint32_t | value | ||
) |
Or the value on a given memory address with value.
uint32_t spr_atomic_and32_MBnone | ( | volatile uint32_t * | ptr, |
uint32_t | value | ||
) |
And the value on a given memory address with value.
uint32_t spr_atomic_swap32_MBnone | ( | volatile uint32_t * | ptr, |
uint32_t | value | ||
) |
Store value on the given memory address ptr and return the old value stored at the memory location. In other words, swap or exchange values.
int spr_atomic_cas32_MBnone | ( | volatile uint32_t * | ptr, |
uint32_t | tst_value, | ||
uint32_t | new_value | ||
) |
Test if *ptr (still) equals tst_value, and if so, store new_value in ptr.
int spr_atomic_twincas32_MBnone | ( | volatile uint32_t * | ptr, |
uint32_t | tst_value1, | ||
uint32_t | tst_value2, | ||
uint32_t | new_value1, | ||
uint32_t | new_value2 | ||
) |
Test if *ptr (still) equals {tst_value1,tst_value2} and if so, store {new_value1,new_value2} in *ptr.
int spr_atomic_bitset32_MBnone | ( | volatile uint32_t * | ptr, |
int | bit_ndx | ||
) |
Set a bit bit_ndx in bit array ptr to 1.
int spr_atomic_bitclr32_MBnone | ( | volatile uint32_t * | ptr, |
int | bit_ndx | ||
) |
Set a bit bit_ndx in bit array ptr to 0.
int spr_atomic_slot_acquire_nowait | ( | SprAtomicSlot * | slot | ) |
Try to get slot 0 (the main resource), and if that slot is not available, try to get any other free slot (an auxilary resource).
If a free slot is found, lock it (clear the appropriate bit in slot->msk) and return the slot number.
int spr_atomic_slot_acquire_wait | ( | SprAtomicSlot * | slot | ) |
Try to get slot 0, and if that slot is not available, try to get any other free slot. If there are no free slots, then wait until a slot becomes free.
int spr_atomic_slot_acquire0_wait | ( | SprAtomicSlot * | slot | ) |
Try to get slot 0. If slot 0 is not available, then wait.
int spr_atomic_slot_acquire_all | ( | SprAtomicSlot * | slot | ) |
Acquire all slots, i.e. make sure this thread is the only one using the system.
double spr_strtod | ( | const char * | str, |
const char * | str_end, | ||
char ** | eptr | ||
) |
Convert the initial portion of the string pointed to by str to a double value. The string str ends either in a '\0' or at the location pointed to by str_end (whichever condition occurs first). If eptr is not NULL, a pointer to the character after the last character used in the conversion is stored in the location referenced by eptr.
char* spr_dt_qstr_cvt_insitu | ( | char *restrict | str | ) |
Convert the quoted string str to an unquoted string (with all escape codes converted). The converted string is written over the quoted source string. The final '"' in the source string is replaced by a '\0' after which the conversion stops.
char* spr_dt_qstr_skip | ( | const char * | str | ) |
Go to the end of the quoted string str.
int spr_dt_alaw2short | ( | int | aval | ) |
int spr_dt_short2alaw | ( | int | sval | ) |
int spr_dt_ulaw2short | ( | int | uval | ) |
int spr_dt_short2ulaw | ( | int | sval | ) |
int32_t spr_atoi32 | ( | const char * | str, |
int * | err | ||
) |
Convert str to a signed 32 bits interger.
uint32_t spr_atou32 | ( | const char * | str, |
int * | err | ||
) |
Convert str to an unsigned 32 bits interger.
int64_t spr_atoi64 | ( | const char * | str, |
int * | err | ||
) |
Convert str to a signed 64 bits interger.
uint64_t spr_atou64 | ( | const char * | str, |
int * | err | ||
) |
Convert str to an unsigned 64 bits interger.
float spr_atof32 | ( | const char * | str, |
int * | err | ||
) |
Convert str to a 32 bits floating point value.
double spr_atof64 | ( | const char * | str, |
int * | err | ||
) |
Convert str to a 64 bits floating point value.
ssize_t spr_dt_print_vec | ( | SprStream * | fd, |
const SprDT * | dt, | ||
const void * | vec, | ||
int | vlen, | ||
const char * | info | ||
) |
Print a vector vec of vlen data elements of type dt to the stream fd. Each printed element is preceeded by a single space and the last elements is followed by new-line character. If the string info is not NULL, that string will be printed before the vector is.
fd | Destination stream. |
dt | Type of the data elements. |
vec | Data vector |
vlen | Vector length. |
info | Extra string. |
int spr_dt_str2vec | ( | const char * | str, |
const SprDT * | dt, | ||
void *restrict | vec, | ||
int | N | ||
) |
Convert the ASCII string str to an array vec containing values of the type dt. Values are assumed to be seperated be spaces. Only the first N values are stored in vec. The remainder of the string is still processed (must contain valid values) and the remaining values are counted.
int spr_dt_str2vec_dyn | ( | const char * | str, |
const SprDT * | dt, | ||
void ** | dst | ||
) |
Convert the ASCII string str to an array *dst containing values of the type dt. Values are assumed to be seperated be spaces.
Convert the array vec containing N values of the type dt to a dynamic string. Each value is seperated by a space. If not NULL, the dynamic string dst is used to write the result to.
void* spr_free | ( | void * | ptr, |
const SprMsgId * | routine, | ||
const char * | item | ||
) |
Free the memory space pointed to by ptr, which must have been returned by a previous call to spr_malloc() or spr_realloc(). If ptr is NULL, no operation is performed.
ptr | Item to free. |
routine | Identify the calling routine. |
item | Name of the item. |
void* spr_malloc | ( | size_t | size, |
const SprMsgId * | routine, | ||
const char * | item | ||
) |
Allocate size bytes and return the pointer to the newly allocated memory. The content of memory area is random (the bytes have not been zeroed).
size | Requested memory size (in butes). |
routine | Identify the calling routine. |
item | Name of the item. |
void* spr_realloc | ( | void * | ptr, |
size_t | size, | ||
const SprMsgId * | routine, | ||
const char * | item | ||
) |
Changes the size of the memory block pointed to by ptr to be size bytes long. The contents will be unchanged up till the minimum of the old and new sizes; extra allocated memory is uninitialized. The returned pointer may differ from the original pointer ptr, i.e. the memory area may have been moved to acquire the necessary space. In that case, the original memory area is automatically freed. If ptr is NULL, the call is equivalent to spr_malloc(size,...). If size is equal to zero, the call is equivalent to (spr_free(ptr),spr_malloc(0,routine,size)). Unless ptr is NULL, it must have been returned by an earlier call to spr_malloc() or spr_realloc().
ptr | Item to reallocate. |
size | Requested memory size (in butes). |
routine | Identify the calling routine. |
item | Name of the item. |
unsigned int spr_dynmem_check | ( | SprMsgId * | routine, |
const char * | id | ||
) |
Check if the heap is corrupted. This routine is not mult-threading safe.
it should only be called from the main thread after all helper threads have stopped or are idling.
routine | Identify the calling routine. |
id | Identify the call. |
char* spr_strdup | ( | const char * | src, |
const SprMsgId * | routine, | ||
const char * | item | ||
) |
src | Source string. |
routine | Identify the calling routine. |
item | Name of the new string. |
char* spr_strndup | ( | const char * | src, |
size_t | size, | ||
const SprMsgId * | routine, | ||
const char * | item | ||
) |
src | Source string. |
size | Size of the string. |
routine | Identify the calling routine. |
item | Name of the new string. |
char* spr_strcpy | ( | char **restrict | dst, |
const char *restrict | src | ||
) |
Make a copy of src to a (re)allocated chunk of memory in *dst.
dst | Destination string. |
src | Source string. |
char* spr_strcat | ( | char *restrict | str1, |
const char *restrict | str2, | ||
int *restrict | str1_len, | ||
int | str2_len, | ||
int *restrict | alen | ||
) |
Append str2 to the dynamically allocated string str1.
str1 | Source string. |
str2 | String to append. |
str1_len | Length of str1. If not NULL, *str1_len is used to specify the length of str1 on entry and to return the total length of the newly formed (concattenated) string. A value of (-1) on input is equivalent to the value strlen(str1). |
str2_len | Length of str2. Contains the length of str2. A value of (-1) is equivalent to the value strlen(str1). |
alen | Allocated length of str1. If not NULL. *alen must contain the allocated length of str1 on entry (or an under estimate) and will contain the new allocated length (or the old value if no reallocation was needed) of the newly formed (concattenated) string when returning. |
char* spr_dynstr2alloc | ( | SprDynStr | str | ) |
Change the dynamic string str into a plain allocate string.
Free the dynamic string str, which must have been returned by a previous call to str_dynstr_alloc() or equiavlent. If str is NULL, no operation is performed. For more details see spr_free().
str | String to free. |
routine | Identify the calling routine. |
item | Name of the item. |
Allocate a dynamic string capable of holding size bytes (this includes the terminating '\0'). For more details see spr_malloc().
size | Requested size (in butes). |
routine | Identify the calling routine. |
item | Name of the item. |
SprDynStr spr_dynstr_realloc | ( | SprDynStr | str, |
size_t | size, | ||
const SprMsgId * | routine, | ||
const char * | item | ||
) |
Resize the string str to fit the given length size (don't forget to count the trailing '\0'). If you are not interested in saving space but just want to make sure the dynamic string is large enough, use spr_dynstr_enlarge() instead. If the string is truncated, a terminating '\0' will be placed at the end.
str | String to reallocate. |
size | Requested size (in butes). |
routine | Identify the calling routine. |
item | Name of the item. |
SprDynStr spr_dynstr_enlarge | ( | SprDynStr | str, |
size_t | size, | ||
const SprMsgId * | routine, | ||
const char * | item | ||
) |
Resize the string str to fit at least the given length size (don't forget to count the trailing '\0').
str | String to reallocate. |
size | Requested size. |
routine | Identify the calling routine. |
item | Name of the item. |
size_t spr_dynstr_maxlen | ( | SprDynStr | str | ) |
Determine the maximum size (including the final '\0') the string str may become before it must be reallocated (or enlarged).
str | The string. |
Copy the string src to the dynamic string dst. If necessary, dst is enlarged.
For more details, see strcpy().
dst | Destination string. |
src | Source string. |
Copy the string src of length src_len (not including the final '\0') to the dynamic string dst. If src is longer than src_len, dst will be truncated to src_len and a final '\0' will be added. If src_len equals (-1), the length is calculated using strlen(). If necessary, dst is enlarged.
For more details, see strncpy().
dst | Destination string. |
src | Source string. |
src_len | Length of the source string. |
Make a new dynamic string containing a copy of src. For more details, see strdup().
src | Source string. |
routine | Identify the calling routine. |
item | Name of the new string. |
SprDynStr spr_dynstr_ndup | ( | const char * | src, |
size_t | src_len | ||
) |
Make a new dynamic string containing a copy of the string src of length src_len (length not including the final '\0'). If src is longer than src_len, the copy will be truncated to src_len and a final '\0' will be added. If src_len equals (-1), the length is calculated using strlen().
For more details, see strdup().
src | Source string. |
src_len | Length of the source string. |
SprDynStr spr_dynstr_cat | ( | SprDynStr restrict | str1, |
const char *restrict | str2, | ||
int *restrict | str1_len, | ||
int | str2_len | ||
) |
Append str2 to the dynamic string str1.
str1 | Source string. |
str2 | String to append. |
str1_len | Length of str1. If not NULL, *str1_len is used a length of str1 on entry and will contain the total length of the newly formed (concattenated) string when returning. If value of (-1) on input is equivalent to strlen(str1). |
str2_len | Length of str2. Contains the length of str2. A value of (-1) is equivalent to strlen(str1). |
const char* spr_str_nonull_ | ( | const char * | str | ) |
str | String to check. |
const char* spr_str_nonull | ( | const char * | str, |
const char * | str_null | ||
) |
str | String to check. |
str_null | Alternative. |
size_t spr_dynmem_pool_count_alloc | ( | const SprMPool * | mpool | ) |
mpool | The pool of identical sized objects. |
size_t spr_dynmem_pool_count_free | ( | const SprMPool * | mpool | ) |
mpool | The pool of identical sized objects. |
Free all allocated data in the memory pool mpool by freeing all allocated chunks of memory.
mpool | The pool of identical sized objects. |
routine | Identify the calling routine. |
void* spr_dynmem_pool_enlarge | ( | SprMPool * | mpool | ) |
Allocate a set of objects of size mpool->el_size. The elements are linked together with a pointer at offset mpool->link_ptr_offs in each element, thus making a list of new/free elements. The element size and how they are linked together should be set once when initializing mpool, e.g. by using the SPR_MPOOL_INIT() or SPR_MPOOL_INITIALIZER() macros, and must not be changed there after or unexpected bahaviour is to be expected.
mpool | The pool of identical sized objects. |
int spr_fmsnzb32 | ( | uint32_t | val | ) |
Return the index (31...0) of the most significant non zero bit of val. If val is zero, a (-1) is returned.
int spr_fmsnzb32x0 | ( | uint32_t | val | ) |
Return the index (31...0) of the most significant non zero bit of val. If val is zero, the return value is undefined.
int spr_fmsnzb64 | ( | uint64_t | val | ) |
Return the index (63...0) of the most significant non zero bit of val. If val is zero, a (-1) is returned.
int spr_fmsnzb64x0 | ( | uint64_t | val | ) |
Return the index (63...0) of the most significant non zero bit of val. If val is zero, a the return value is undefined.
int spr_flsnzb32 | ( | uint32_t | val | ) |
Return the index (31...0) of the least significant non zero bit of val. If val is zero, a (-1) is returned.
int spr_flsnzb32x0 | ( | uint32_t | val | ) |
Return the index (31...0) of the least significant non zero bit of val. If val is zero, the return value is undefined.
int spr_flsnzb64 | ( | uint64_t | val | ) |
Return the index (63...0) of the least significant non zero bit of val. If val is zero, a (-1) is returned.
int spr_flsnzb64x0 | ( | uint64_t | val | ) |
Return the index (63...0) of the least significant non zero bit of val. If val is zero, a the return value is undefined.
int spr_popcount16 | ( | uint16_t | val | ) |
Return the number of 1 bits in val.
int spr_popcount32 | ( | uint32_t | val | ) |
Return the number of 1 bits in val.
int spr_popcount64 | ( | uint64_t | val | ) |
Return the number of 1 bits in val.
uint32_t spr_rotl32 | ( | uint32_t | val, |
unsigned int | ndx | ||
) |
Rotate the value val ndx bits to the left.
uint32_t spr_rotr32 | ( | uint32_t | val, |
unsigned int | ndx | ||
) |
Rotate the value val ndx bits to the right.
uint64_t spr_rotl64 | ( | uint64_t | val, |
unsigned int | ndx | ||
) |
Rotate the value val ndx bits to the left.
uint64_t spr_rotr64 | ( | uint64_t | val, |
unsigned int | ndx | ||
) |
Rotate the value val ndx bits to the right.
uint64_t spr_wide_umul32 | ( | uint32_t | val1, |
uint32_t | val2 | ||
) |
Double wide unsigned multiplication.
uint32_t spr_wide_umul32hi | ( | uint32_t | val1, |
uint32_t | val2 | ||
) |
Double wide unsigned multiplication and shift. Typically used for fixed point multiplications.
int64_t spr_wide_smul32 | ( | int32_t | val1, |
int32_t | val2 | ||
) |
Double wide signed multiplication.
int32_t spr_wide_smul32hi | ( | int32_t | val1, |
int32_t | val2 | ||
) |
Double wide signed multiplication and shift. Typically used for fixed point multiplications.
int spr_bittest | ( | const unsigned int * | bitarray, |
int | ndx | ||
) |
void spr_bitset | ( | unsigned int * | bitarray, |
int | ndx | ||
) |
Set the value of bit ndx in bit array bitarray to 1.
void spr_bitclr | ( | unsigned int * | bitarray, |
int | ndx | ||
) |
Set the value of bit ndx in bit array bitarray to 0.
uint16_t spr_bswap16 | ( | uint16_t | val | ) |
uint32_t spr_bswap32 | ( | uint32_t | val | ) |
uint64_t spr_bswap64 | ( | uint64_t | val | ) |
unsigned int spr_sqrt_u32 | ( | unsigned int | nr | ) |
Calculate the square root of an unsigned integer (without using the FPU). The result is rounded towards zero.
int spr_prime_check | ( | unsigned int | nr | ) |
Check if the given number nr is a prime number.
unsigned int spr_prime_find | ( | unsigned int | nr | ) |
Find the first prime number that is larger or equal to the given argument nr.
unsigned int spr_hash_str | ( | const char * | str | ) |
Calculate a hash value for the string str.
unsigned int spr_hash_str2 | ( | const char * | str, |
size_t | str_len | ||
) |
Calculate the hash value for the string str of length str_len.
unsigned int spr_hash_str_len | ( | const char * | str, |
size_t * | len | ||
) |
Calculate both the length and the hash value for the string str.
void spr_htbl_str_init | ( | SprHtblStr *restrict | htbl, |
unsigned int | flags, | ||
int | keystr_offs | ||
) |
Initialize the static allocated or embedded string hash table htbl. The flags argument can be a combination of the following:
The keystr_offs allows one to preceed each string added to the hash table by some element specific structure (e.g. a pointer). For more details, see the documentation on the SprHtblStr structure.
SprHtblStr* spr_htbl_str_new | ( | unsigned int | flags, |
int | keystr_offs | ||
) |
Allocate and initialize a new string hash table. For the meaning of the flags and keystr_offs, see spr_htbl_str_init().
SprHtblStr* spr_htbl_str_free | ( | SprHtblStr *restrict | htbl | ) |
Free the string hash table htbl. Whether the strings in the hash table are freed or not depends on the flags given when creating the hash table.
unsigned int spr_htbl_str_Nel | ( | const SprHtblStr *restrict | htbl | ) |
const char* spr_htbl_str_iter | ( | const SprHtblStr *restrict | htbl, |
int *restrict | ndx | ||
) |
Iterator over all strings stored in the hash table:
const char* spr_htbl_str_ndx2str | ( | const SprHtblStr *restrict | htbl, |
int | ndx | ||
) |
int spr_htbl_str_find_ndx | ( | const SprHtblStr *restrict | htbl, |
const char *restrict | str | ||
) |
Search string str in the hash table htbl and return the index.
int spr_htbl_str_find_ndx2 | ( | const SprHtblStr *restrict | htbl, |
const char *restrict | str, | ||
size_t | str_len | ||
) |
Search string str of length str_len in the hash table htbl and return the index. If str_len equals (-1) the full length of str is used.
const char* spr_htbl_str_find_key | ( | const SprHtblStr *restrict | htbl, |
const char *restrict | str | ||
) |
Search string str in the hash table htbl and return the pointer to the key-string from the hash table.
int spr_htbl_str_add | ( | SprHtblStr *restrict | htbl, |
const char *restrict | str | ||
) |
Add string str to the hash table htbl and return the index.
int spr_htbl_str_cadd | ( | SprHtblStr *restrict | htbl, |
const char *restrict | str, | ||
int *restrict | duplicate | ||
) |
Search string str in the hash table htbl and add the string if not found. The flag *duplicate, if not NULL, will be set to 1 or 0 if the string is found or added respectively. See spr_htbl_str_add() about which string gets which index.
int spr_htbl_str_add_replace | ( | SprHtblStr *restrict | htbl, |
const char *restrict | str | ||
) |
Search string str in the hash table htbl, replace the hash table entry when found or add the string if not found. See spr_htbl_str_add() about which string gets which index.
int spr_htbl_str_rm_key | ( | SprHtblStr *restrict | htbl, |
const char *restrict | str | ||
) |
Find string str in the hash table htbl and remove it.
int spr_htbl_str_rm_ndx | ( | SprHtblStr *restrict | htbl, |
int | ndx | ||
) |
Remove the string at index ndx from the hash table htbl.
int spr_hash_strlin_search | ( | const char *restrict const | hlst[], |
int | Nel, | ||
const char *restrict | str | ||
) |
Lookup string str in the lookup table (a list of strings) hlst. Nel is the number of elements in the array hlst. If Nel equals -1, the lookup table is assumed to be NULL terminated.
int spr_hash_strlin_search_err | ( | const char *restrict const | hlst[], |
int | Nel, | ||
const char *restrict | str | ||
) |
Lookup string str in the lookup table (a list of strings) hlst. Nel is the number of elements in the array hlst. If Nel equals -1, the lookup table is assumed to be NULL terminated.
int spr_hash_strnlin_search | ( | const char *restrict const | hlst[], |
const char *restrict | str, | ||
size_t | str_len | ||
) |
Lookup string str[0:str_len-1] in the lookup table (a NULL terminated list of strings) hlst.
int spr_hash_strnlin_search_err | ( | const char *restrict const | hlst[], |
const char *restrict | str, | ||
size_t | str_len | ||
) |
Lookup string str[0:str_len-1] in the lookup table (a NULL terminated list of strings) hlst.
SprKeySet* spr_kset_alloc | ( | void | ) |
Allocate a new keyset.
Clear the content of a previously allocated keyset.
int spr_kset_set | ( | SprKeySet * | keys, |
const char * | key, | ||
const char * | value | ||
) |
Adds the key-value pair (key,value) to the key-set keys. Both key and value must be valid strings (non NULL, '\0' terminated). The strings are copied, so key nor value have to be preserved after this call.
int spr_kset_cset | ( | SprKeySet * | keys, |
const char * | key, | ||
const char * | value | ||
) |
Adds the key-value pair (key,value) to the key-set keys if the key is not yet present in the keyset.
Adds the key-value pair (key,str(value)) to the key-set keys. The key key must be valid strings (non NULL, '\0' terminated). The value must be of the data type dt. Both the key and the value are copied, so key nor value have to be preserved after this call.
int spr_kset_set_value_size | ( | SprKeySet * | keys, |
const char * | key, | ||
ssize_t | value | ||
) |
Adds the key-value pair (key,str(value)) to the key-set keys. Behaves identical to spr_kset_set_value(keys,key,spr_dt_ssize,&value) (assuming one can take the addres of value).
int spr_kset_set_value_double | ( | SprKeySet * | keys, |
const char * | key, | ||
double | value | ||
) |
Adds the key-value pair (key,str(value)) to the key-set keys. Behaves identical to spr_kset_set_value(keys,key,spr_dt_f64,&value) (assuming one can take the addres of value).
int spr_kset_set_value_float | ( | SprKeySet * | keys, |
const char * | key, | ||
float | value | ||
) |
Adds the key-value pair (key,str(value)) to the key-set keys. Behaves identical to spr_kset_set_value(keys,key,spr_dt_f32,&value) (assuming one can take the addres of value).
const char* spr_kset_get | ( | const SprKeySet * | keys, |
const char * | key | ||
) |
Search the key key in the key-set keys and returns the corresponding value if found.
const char* spr_kset_get_err | ( | const SprKeySet * | keys, |
const char * | key | ||
) |
Search the key key in the key-set keys and returns the corresponding value if found.
int spr_kset_get_value | ( | const SprKeySet * | keys, |
const char * | key, | ||
const SprDT * | dt, | ||
void * | dst, | ||
const void * | def_val | ||
) |
Search the key key in the key-set keys. If the key was found, the corresponding value (a string) is converted to something of the type dt and store in *dst. If not found (or if the conversion fails), *def_val (if not NULL) is copied to *dst.
ssize_t spr_kset_get_value_size | ( | const SprKeySet * | keys, |
const char * | key, | ||
ssize_t | nf_val | ||
) |
Search the key key in the key-set keys. If the key was found, and the corresponding value (a string) could be converted successfuly to a ssize_t value, this value will be returned. Otherwise (key not found or unable to convert to ssize_t), the value nf_val will be returned.
double spr_kset_get_value_double | ( | const SprKeySet * | keys, |
const char * | key, | ||
double | nf_val | ||
) |
Search the key key in the key-set keys. If the key was found, and the corresponding value (a string) could be converted successfuly to a double, this value will be returned. Otherwise (key not found or unable to convert to a double), the value nf_val will be returned.
float spr_kset_get_value_float | ( | const SprKeySet * | keys, |
const char * | key, | ||
float | nf_val | ||
) |
Search the key key in the key-set keys. If the key was found, and the corresponding value (a string) could be converted successfuly to a float, this value will be returned. Otherwise (key not found or unable to convert to a float), the value nf_val will be returned.
int spr_kset_rm | ( | SprKeySet * | keys, |
const char * | key | ||
) |
Remove the key key from the key-set keys.
int spr_kset_get_value_format | ( | const SprKeySet * | keys | ) |
Get the 'FORMAT' key from the keyset keys.
int spr_kset_get_value_format_alt | ( | const SprKeySet * | keys, |
int | alt_val | ||
) |
int spr_kset_get_value_layout | ( | const SprKeySet * | keys | ) |
Get the 'LAYOUT' key from the keyset keys.
Get the 'TYPE' key from the keyset keys.
ssize_t spr_kset_get_value_dim1 | ( | const SprKeySet * | keys | ) |
Get the 'DIM1' key from the keyset keys. DIM1 corresponds to:
ssize_t spr_kset_get_value_dim1_alt | ( | const SprKeySet * | keys, |
ssize_t | alt_val | ||
) |
ssize_t spr_kset_get_value_dim2 | ( | const SprKeySet * | keys | ) |
Get the 'DIM2' key from the keyset keys. DIM2 corresponds to
ssize_t spr_kset_get_value_dim2_alt | ( | const SprKeySet * | keys, |
ssize_t | alt_val | ||
) |
ssize_t spr_kset_get_value_nchan | ( | const SprKeySet * | keys | ) |
Get the 'NCHAN' key from the keyset keys. NCHAN corresponds to the number of audio channels in the recording. The data for the different channels is stored in an interleaved fashion. For track files, this means that each vector of size DIM2 contains NCHAN feature vectors stored in an interleved fashion.
ssize_t spr_kset_get_value_nchan_alt | ( | const SprKeySet * | keys, |
ssize_t | alt_val | ||
) |
ssize_t spr_kset_get_value_chanlen | ( | const SprKeySet * | keys | ) |
Get the 'CHANLEN' key from the keyset keys. CHANLEN corresponds to the number of sample points in the recording.
ssize_t spr_kset_get_value_chanlen_alt | ( | const SprKeySet * | keys, |
ssize_t | alt_val | ||
) |
double spr_kset_get_value_fshift | ( | const SprKeySet * | keys | ) |
Get the 'FSHIFT' key (frame shift in seconds) from the keyset keys.
double spr_kset_get_value_fshift_alt | ( | const SprKeySet * | keys, |
double | alt_val | ||
) |
double spr_kset_get_value_foffset | ( | const SprKeySet * | keys | ) |
Get the 'FOFFSET' key (frame offset in seconds) from the keyset keys.
double spr_kset_get_value_foffset_alt | ( | const SprKeySet * | keys, |
double | alt_val | ||
) |
int spr_kset_get_values_dim_and_type | ( | const SprKeySet * | keys, |
int * | dim1, | ||
int * | dim2, | ||
const SprDT ** | dt, | ||
const char * | fname, | ||
SprMsgId * | routine | ||
) |
Get the values for the keys DIM1, DIM2 and TYPE. An error message is sent if any of these keys does not exists. An error message is also sent if there values differ from the values found in dim1, *dim2 or *dt respectively. This check on the value can be disabled by setting *dim1, *dim2 or *dt to -1, -1 or NULL respectively. In that case, the value(s) read from the keys will be written in *dim1, *dim2 or *dt.
int spr_kset_set_value_dim1 | ( | SprKeySet * | keys, |
ssize_t | value | ||
) |
Set the value for the DIM1 key in keyset keys to value.
int spr_kset_set_value_dim2 | ( | SprKeySet * | keys, |
ssize_t | value | ||
) |
Set the value for the DIM2 key in keyset keys to value.
Allocate a new keyset and copy the content of keys to it.
const char* spr_kset_iter | ( | const SprKeySet *restrict | keys, |
int *restrict | iter, | ||
const char **restrict | value | ||
) |
Iterator over all key-value pairs stored in the keyset.
Print the content of the keyset (raw dump).
void spr_kset_get_stdset | ( | SprStdKeys *restrict | res, |
const SprKeySet *restrict | keys | ||
) |
Retrieve the 'standard' keys from keys.
SprKeySet* spr_kset_set_defaults | ( | SprKeySet *restrict | keys, |
SprStream *restrict | fd, | ||
const char *restrict | fname | ||
) |
Set default values for the keys in keyset keys, or if keys equals NULL, the keys associated to fd.
If fd is not NULL, and if the stream contains sample data or if the number of frames, vectors, entries, ... is unknown, the silent-eof flag of the stream will be turned on (see SprStream::silenteof() for more info).
The fname argument is used for error reporting. If fname equals NULL, the name will be extracted from the stream descriptor fd.
Check the legality of the keys in the keyset keys under the assumption of having one of the standard 'DATA' types: SAMPLE, TRACK, CORPUS, SEG
ssize_t spr_kset_sample_adjust | ( | SprKeySet *restrict | keys, |
const double *restrict | fshift_ptr, | ||
const double *restrict | flength_ptr, | ||
int | htk_convention | ||
) |
Adjust the keys (DIM1,DIM2,FSHIFT,FLENGTH,FOFFSET) given some new values for the frame shift (*fshift_ptr if fshift_ptr!=NULL) and/or the frame length (*flength_ptr if flength_ptr!=NULL), and given the key SAMPLEFREQ and the limitation that frames have a fixed (integer) length. If the parameter htk_convention is not 0, a non-zero frame offset equal to (flength-fshift)/2.0 will be assumed.
int spr_kset_stream_modif | ( | SprStream *restrict | fd | ) |
Try to write a header in the same location as the old header and if this fails, try to create the necessary space by moving the data block. This only works for the key and SPRAAK header formats.
int spr_msg | ( | int | lvl, |
SprMsgId * | routine, | ||
const char * | fmt, | ||
... | |||
) |
Signal an error (lvl==SPR_ERROR), warning(lvl==SPR_WARNING), info(lvl==SPR_INFO) or debug(lvl>=1) message.
Error and warning messages are always output. Most other messages will be ignored. Whether a message is ignored depends on the current active triggers and filters and on the global message level (see spr_msg_modif_lvl(), spr_msg_modif_in() and spr_msg_modif_from()).
The messages are sent as a single printf(fmt,...) command. The messages should be short, i.e. no longer than 1023 characters, and if they consist of multiple lines, all extra lines must start with a tab ('\t').
lvl | Message level. |
routine | Identifies the calling routine. |
fmt | Format for printing. |
int spr_msg_check | ( | int | lvl, |
SprMsgId * | routine | ||
) |
Check if a message from the given routine at level lvl would be printed (i.e. not ignored).
lvl | Message level. |
routine | Identifies the calling routine. |
int spr_set_thread_id | ( | const char * | name | ) |
Set the thread id for dynamic names. Ssee the global comment for more details.
void spr_msg_modif_lvl | ( | int | lvl | ) |
Set the global message filter level to lvl, i.e. only messages with a level equal to or lower than lvl will be output (unless routine or thread specific levels are defined.
see spr_msg_modif_in() and spr_msg_modif_from()).
lvl | The new message level. |
int spr_msg_get_lvl | ( | void | ) |
Get the current global message level.
int spr_msg_modif_in | ( | const char * | filter_desc, |
int | action | ||
) |
Update the filters for the message system. Filters allow you to let pass only those messages that come from selected routines and threads. The action argument can have the following values:
The filter description filter_desc is either a NULL pointer (only relevant for the SPR_MSG_SET action) or a string containing zero, one or more patterns seperated by spaces. Each pattern has the following format (regular expression format):
For those who prefer a textual description, the pattern consists of a name (a sequences of letters, numbers and underscores) optionally preceded and followed by a '*'. Following this there is an optional message level (a one or two digit number) in between round brackets '()'. This whole construct can be preceded by a pound sign '#'. The pound sign indicates that the pattern applies to a thread name instead of to a routine name. The wild-char '*' behaves similar to the '*' in file name matching, i.e. it matches 0 or more arbitrary characters.
When filters are active, only messages from matching routines and/or threads will be output. If no level is given in the pattern, the global message level (see spr_msg_modif_lvl()) will be used. If no filter patterns are set, all routines and/or threads match (given that the level is lower or equal to the global message level).
filter_desc | List of function/thread patterns and optional levels. |
action | Action: set, remove or add the patterns. |
int spr_msg_modif_from | ( | const char * | filter_desc, |
int | action | ||
) |
Set triggers for the message system, i.e. let only start passing messages once a message has come along for which the originating routine and/or thread matches the specified filter description filter_desc and the level of the message is equal or lower then the routine/thread specific threshold (or global threshold if no specific routine/thread threshold is specified). From that moment on, the filters (see spr_msg_modif_in()) will become active.
This function also automatically switches the message system in trigger mode if the routine and/or thread trigger list is non empty.
For more details on the arguments, see spr_msg_modif_in().
filter_desc | List of function/thread patterns and optional levels. |
action | Flag: replace or augment the list. |
SprDynStr spr_msg_get_in | ( | void | ) |
Get the list of currently active filters. For a description of the format, see spr_msg_modif_in().
SprDynStr spr_msg_get_from | ( | void | ) |
Get the list of currently active triggers. For a description of the format, see spr_msg_modif_in().
int spr_msg_modif_stream | ( | SprStream *restrict | stream, |
const char *restrict | fname | ||
) |
Change the stream the messages are send to, to stream if stream!=NULL and to a stream corresponding to fname otherwise.
The previous message stream will be closed after the new has been opened. By default all messages are witten to 'stderr'.
stream | The new stream to send messages to. |
fname | The file to open (stream==NULL). |
void spr_msg_modif_catch_func | ( | SprMsgCatchFunc | handler | ) |
Install (or uninstall if handler equals NULL) a handler that will be called on errors and warnings.
handler | The new handler to call on warning/errors. |
char* spr_path_ext_ptr | ( | const char * | fname | ) |
int spr_path_dir_len | ( | const char * | fname | ) |
Return the length of the leading directory component (including the last '/') in the given file-name fname or zero if no path component was found.
char* spr_path_split_insitu | ( | char ** | path, |
char ** | suffix, | ||
char * | fname | ||
) |
Split the given filename in path, base name and suffix. The original string is corrupted by this operation.
int spr_signal_report | ( | int | action_mask | ) |
Install a signal handler.
The action_mask flag is combination of the SPR_SIGNAL_{CTRLC
,QUIT,ERROR,PIPE,USR1/2} bit mask flags. When a bit is set, the occurence of a signal that maps that action is reported back to the main program using the global variable spr_signal_flag (by setting the corresponding bit). It is up to all routines to check for the global variable spr_signal_flag and act upon its value.
When a bit in action_mask is not set, the default reaction on that action is triggered.
When action_mask equals -1, the current value of the mask is used to reset the whole system.
The signal handler reacts on the following signals (the bit the signal maps to in spr_signal_flag and the default action are given between brackets):
An avalance of identical signals will automatically trigger the SPR_SIGNAL_ERROR action.
Some SPRAAK programs use the two user signals to report back on their current status (progress) by e.g. reporting on which entry in the corpus they are working.
const char* SPR_CLASSID_FROM_OBJ | ( | const void * | object | ) |
Get the id (a unique pointer to a string) of the class the object object belongs to.
SprSrmEl* spr_srm_retrieve | ( | unsigned int | class_id, |
const char * | name | ||
) |
Lookup the shared resource (class_id,name) and if its found lock it down so nobody can destroy it while you use it.
class_id | Class-id for the resource (type of resource). |
name | Name of the resource. |
SprSrmEl* spr_srm_retrieve_alt | ( | unsigned int | class_id, |
const char * | name, | ||
size_t | sz | ||
) |
Lookup the shared resource (class_id,name[0:sz-1]) and if its found lock it down so nobody can destroy it while you use it.
class_id | Class-id for the resource (type of resource). |
name | Name of the resource. |
sz | Length of name. |
SprSrmEl* spr_srm_get | ( | unsigned int | class_id, |
const char * | name | ||
) |
Retrieve and lock a shared resource.
class_id | Class-id for the resource (type of resource). |
name | Name of the resource. |
SprSrmEl* spr_srm_create | ( | unsigned int | class_id, |
const char * | name, | ||
int | name_is_persistent | ||
) |
Create a new resource and lock it down. The resource is not yet initialized. Once it is fully initialized (using the routines of the form srm_set_xxx()) the resource must be released (see spr_srm_release()) in order for other routines, threads, ... to be able to use the resource. In the time between the creation of the resource and releasing it (signaling that is is initialized), all threads trying to access the resource will be blocked. This makes the whole system MT-safe at the cost of possible dead-locks if your code is not well behaving.
class_id | Class-id for the resource (type of resource). |
name | Name of the resource. |
name_is_persistent | Indicate that the given string is persistent, and hence no copy must be made. |
SprSrmEl* spr_srm_retrieve_or_create | ( | unsigned int | class_id, |
const char * | name, | ||
int | name_is_persistent | ||
) |
Retrieve an existing or create a new resource. If another thread is in the process of initializing a resource, the calling thread will be blocked until the other thread releases the initialized resource (or destroys it if the initialization fails). See spr_srm_create() for more details.
class_id | Class-id for the resource (type of resource). |
name | Name of the resource. |
name_is_persistent | Indicate that the given string is persistent, and hence no copy must be made. |
int spr_srm_release | ( | SprSrmEl * | srm_el, |
int | action | ||
) |
Release or export a previously retrieved or created shared resource srm_el. Each retrieve and create operation puts one extra lock on the resource. A resource is only kept alive as long as there is at least a single lock on the resource. If the last lock is released, the resource is destroyed.
The action flag can have the following values:
In combination with the above actions, you can also enlist or delist the shared resource for auto destruction, i.e. automatic destruction of the resource when SPRAAK is closed down:
If (and only if) the routine is called from a destroy routine then the action flag must also contain ('+' or '|' operator) the SPR_SRM_RELEASE_UNLOCKED flag.
When exporting a class-id resource (i.e. srm_el belongs to the class SPR_SRM_CID_CLASSID) this routine will check the given class-id (the value of 'val1') or search for a suitable class-id ('val1' not set). If registering the class-id resource is successful, the class-id will be returned.
srm_el | Shared resource handler. |
action | Requested operation. |
void spr_srm_release_quick | ( | SprSrmEl * | srm_el | ) |
Release a previously retrieved shared resource srm_el. This routine is equivalent to spr_srm_release(srm_el,SPR_SRM_RELEASE), except that it executes a lot faster.
void spr_srm_release_nocheck | ( | SprSrmEl * | srm_el | ) |
Release a previously retrieved shared resource srm_el, do not check if the shared resource is no longer needed and hence should be destroyed. This routine is equivalent to spr_srm_release(srm_el,SPR_SRM_RELEASE_DELAYED), except that it executes a lot faster.
SprSrmDir* spr_srm_dir | ( | unsigned int | class_id | ) |
List all available resources for a given class_id.
int spr_srm_check_initialized | ( | SprSrmEl * | srm_el | ) |
Check if a resource handler returned by spr_srm_retrieve_or_create() points to an existing resource or to a freshly created and hence uninitialized resource.
srm_el | Shared resource handler. |
int spr_srm_set_free_routine | ( | SprSrmEl * | srm_el, |
SprSrmFree | free_func | ||
) |
If a resource is no longer needed (no one has a lock on it), its content will be destroyed. The routine allows you to install a resource specific free routine.
srm_el | Shared resource handler. |
free_func | Function to call when the resource is destroyed. |
int spr_srm_set_info_val1_ptr | ( | SprSrmEl * | srm_el, |
void * | val | ||
) |
Set value1 of resource srm_el to val.
srm_el | Shared resource handler. |
int spr_srm_set_info_val1_ndx | ( | SprSrmEl * | srm_el, |
unsigned int | val | ||
) |
Set value1 of resource srm_el to val.
srm_el | Shared resource handler. |
int spr_srm_set_info_val2_ptr | ( | SprSrmEl * | srm_el, |
void * | val | ||
) |
Set value2 of resource srm_el to val.
srm_el | Shared resource handler. |
int spr_srm_set_info_val2_ndx | ( | SprSrmEl * | srm_el, |
unsigned int | val | ||
) |
Set value2 of resource srm_el to val.
srm_el | Shared resource handler. |
void* spr_srm_get_info_val1_ptr | ( | const SprSrmEl * | srm_el, |
int * | err | ||
) |
Get value1 of resource srm_el. If err is not NULL, a possible error condition will be signaled as well.
srm_el | Shared resource handler. |
err | Signal if the operation failed. |
unsigned int spr_srm_get_info_val1_ndx | ( | const SprSrmEl * | srm_el, |
int * | err | ||
) |
Get value1 of resource srm_el. If err is not NULL, a possible error condition will be signaled as well.
srm_el | Shared resource handler. |
err | Signal if the operation failed. |
void* spr_srm_get_info_val2_ptr | ( | const SprSrmEl * | srm_el, |
int * | err | ||
) |
Get value2 of resource srm_el. If err is not NULL, a possible error condition will be signaled as well.
srm_el | Shared resource handler. |
err | Signal if the operation failed. |
unsigned int spr_srm_get_info_val2_ndx | ( | const SprSrmEl * | srm_el, |
int * | err | ||
) |
Get value2 of resource srm_el. If err is not NULL, a possible error condition will be signaled as well.
srm_el | Shared resource handler. |
err | Signal if the operation failed. |
int spr_isspace | ( | unsigned int | chr | ) |
Check if the given character is within the normal ASCII range (0...127) and is a space.
int spr_isspace0 | ( | unsigned int | chr | ) |
Check if the given character is within the normal ASCII range (0...127) and is a space or '\0'.
int spr_isupper | ( | unsigned int | chr | ) |
Check if the given character is within the normal ASCII range (0...127) and is an uppercase letter.
int spr_islower | ( | unsigned int | chr | ) |
Check if the given character is within the normal ASCII range (0...127) and is an lowercase letter.
int spr_toupper | ( | unsigned int | chr | ) |
Convert a character to uppercase if it lays is within the normal ASCII range (0...127) and is a letter.
int spr_tolower | ( | unsigned int | chr | ) |
Convert a character to lowercase if it lays is within the normal ASCII range (0...127) and is a letter.
int spr_isalpha | ( | unsigned int | chr | ) |
Check if the given character is within the normal ASCII range (0...127) and is an alphabetic character (a letter).
int spr_isalpha_ | ( | unsigned int | chr | ) |
Check if the given character is within the normal ASCII range (0...127) and is an alphabetic character (a letter) or '_'.
int spr_isalnum | ( | unsigned int | chr | ) |
Check if the given character is within the normal ASCII range (0...127) and is an alphanumeric character (letter or number).
int spr_isalnum_ | ( | unsigned int | chr | ) |
Check if the given character is within the normal ASCII range (0...127) and is an alphanumeric character (letter or number) or '_'.
int spr_isalphax_ | ( | unsigned int | chr | ) |
Check if the given character is an alphabetic character (a letter) or '_' or is an UTF-8 character (character in the range [128...255]).
int spr_isalnumx_ | ( | unsigned int | chr | ) |
Check if the given character is an alphanumeric character (letter or number) or '_' or is an UTF-8 character (character in the range [128...255]).
int spr_isdigit | ( | unsigned int | chr | ) |
Check if the given character is within the normal ASCII range (0...127) and is a digit.
int spr_isxdigit | ( | unsigned int | chr | ) |
Check if the given character is within the normal ASCII range (0...127) and is a hexadecimal digit ([0-9A-Fa-f]).
char* spr_str_skip_space | ( | const char * | str | ) |
Skip 0 or more initial spaces.
char* spr_str_skip_word | ( | const char * | str | ) |
Advance till the end of the word, i.e. the first space or the terminating '\0'.
int spr_str_split | ( | char * | str, |
char ** | tok, | ||
int | max_tok, | ||
char ** | rem | ||
) |
Split the input string str in-situ into tokens ('\0' terminated). The tokens must either start and stop with a double-quote (C-strings) or must be seperated by white-space characters. The pointers to the first max_tok strings are stored in the array tok. The remaining part of the string str is no further split into tokens. If *rem is not NULL, it will point to the remaining part or the terminating '\0' in str when there were max_tok or less fields present. Leading and trailing white-space characters of all tokens and of the remaining part are removed. All tokens starting (and ending) with double quotes \" are assumed to be quoted C-strings and will be converted to plain strings.
int spr_str_split_ref | ( | const char * | str, |
SprStrSplit * | tok, | ||
int | max_tok, | ||
const char ** | rem | ||
) |
Split the input string str into tokens. The start and length of the first max_tok (or less) tokens is returned in tok (not '\0' terminated). The tokens must either start and stop with a double-quote (C-strings) or must be seperated by white-space characters. The C-strings are left unchanged, i.e. the escaped characters are not converted. The remaining part of the string str is no further split into tokens. If *rem is not NULL, it will point to the remaining part or the terminating '\0' in str when there were max_tok or less fields present. Leading and trailing white-space characters are ignored.
char** spr_str_split_dyn | ( | char * | str, |
int * | max_tok | ||
) |
Split the input string str in-situ into tokens ('\0' terminated) using the same conventions as spr_str_split(). If max_tok is not NULL, it must contain the maximum number of tokens desired (use -1 for all tokens) on entry and it will contain the number of tokens found on exit. The returned array will be NULL terminated, except when max_tok is not NULL and (*max_tok!=-1) and more tokens are available. In that case, the returned array will contain *max_tok+1 elements with the last element pointing to the remaining part of the string str.
int spr_str_trim_spaces | ( | char * | str | ) |
Remove trailing spaces and new-lines from a string.
int spr_scanf_simple | ( | const char * | str, |
const char * | fmt, | ||
SprScanfDst * | dst, | ||
SprScanfErr * | err | ||
) |
Decode a the content of the string str based on the format encoded in fmt. The output is stored in dst. If not NULL, err will contain information to see up till where the input could be decoded. The format string is a concattenation of '%' constructions, which match some high level construct such as a number or some white-space, and any other character which must match the input verbatim. All decoding is greedy.
The following '%' constructions are supported:
Any character that has a contextual meaning in the '%' constructions (e.g. the ',' in the '%[?]' construction can be treated as a normal character by prefixing it with a '\' character (requires two '\' in a C-string).
char* spr_expr_scan | ( | const char * | str, |
int | len, | ||
unsigned int | flags, | ||
SprExprScanErr * | err | ||
) |
Scan for the end of a C-alike expression. Scanning start at the beginning of str and, depending on the flags set in flags expects a term (something that evaluates to a value) or a statement. Note: if there are still brackets open, then the routine will scan until all brackets are close and only then check for a matching stop.
The scanning stops if one of the conditions set in flags is met (without any pending open brackets):
When specifying the SPR_SCAN_OP flag, the minimal operator precedence on which to stop can be specified as well (listed from low to high precedence; only one of these flags should be given):
If needed, comments can be skipped. The possible comment formats are controled with the following flags:
The interpretation of certain characters can be modified with the following flags:
If err is not NULL, details concerning an error will be stored in the following fields:
The following error conditions are known:
str | scan in this string |
len | lenght of the string or (-1) if '\0' terminted string |
flags | flags specifying what an 'end of the expression' constitutes |
err | give details on an error |
size_t spr_stream_read | ( | SprStream *restrict | fd, |
void *restrict | buf, | ||
size_t | size | ||
) |
Read from a stream.
Attempt to read size bytes from stream fd into the buffer buf and advance the read position by the number of bytes actually read.
fd | Stream object. |
buf | Buffer to write the data to. |
size | Number of bytes to read. |
int spr_stream_write | ( | SprStream *restrict | fd, |
const void *restrict | buf, | ||
size_t | size | ||
) |
Write to a stream.
Attempt to write size bytes from buffer buf to stream fd and advance the write position by the number of bytes actually written.
fd | Stream object. |
buf | Buffer containing the data to write. |
size | Number of bytes to write. |
size_t spr_stream_skip | ( | SprStream *restrict | fd, |
size_t | size | ||
) |
Skip data from a stream.
Skip size bytes (i.e. read but do not store) from the stream fd.
fd | Stream object. |
size | Number of bytes to skip. |
int spr_stream_fill | ( | SprStream *restrict | fd, |
int | chr, | ||
size_t | size | ||
) |
Attempt to write size times the character chr to stream fd and advance the write position by the number of bytes actually written.
fd | Stream object. |
chr | Character used for filling. |
size | Repeat factor. |
int spr_stream_mkdir_parents | ( | SprMsgId * | routine, |
char * | path | ||
) |
Make the directory path and if necessary the parent directories.
SprStream* spr_stream_dynbuf_make | ( | const char * | name, |
void * | buf, | ||
size_t | alen, | ||
size_t | fill, | ||
unsigned int | flags, | ||
SprKeySet * | keys | ||
) |
Create a stream named name that maps to the dynamically allocated buffer buf of length alen assuming fill characters/bytes are readily available for reading. The flags and keys arguments behave identically as in spr_stream_open().
SprStream* spr_stream_dynstr_make | ( | const char * | name, |
SprDynStr | str, | ||
size_t | fill, | ||
unsigned int | flags, | ||
SprKeySet * | keys | ||
) |
Create a stream named name that maps to the dynamic string str assuming fill characters/bytes are readily available for reading. The flags and keys arguments behave identically as in spr_stream_open().
SprStream* spr_stream_open_write | ( | const char *restrict | fname, |
unsigned int | flags, | ||
const char * | def_keys, | ||
... | |||
) |
Create a new keyset and open the stream (file) the file name fname refers to for writing using that keyset.
The flags argument has the same meaning as with spr_stream_open(), except the that SPR_STREAM_WRITE, SPR_STREAM_CREATE, and SPR_STREAM_TRUNC bits are automatically set.
The def_keys argument must contain one or more of the following characters (exactly in the order as listed below, except for 'X', 'Y' and 'Z' which may be intermixed):
All flags, except for 'X', 'Y' and 'Z' may be specified only once.
unsigned int spr_stream_check | ( | const char *restrict | fname, |
unsigned int | flags | ||
) |
Check if the stream (file) the (rich) file name fname refers to exists, and could be opened in the mode indicated by the argument flags (see spr_stream_open() for more details on the flags).
int spr_fgetc | ( | SprStream *restrict | fd | ) |
Read a single character from the file fd.
int spr_fgetc_utf8 | ( | SprStream *restrict | fd | ) |
Read a single UTF-8 character from the file fd.
int spr_ungetc | ( | SprStream *restrict | fd, |
int | chr | ||
) |
Push a single character back to the read stream fd.
int spr_ungetc_utf8 | ( | SprStream *restrict | fd, |
int | chr | ||
) |
Push a single UTF-8 character (can map to multiple bytes) back to the read stream fd.
int spr_fputc | ( | SprStream *restrict | fd, |
int | chr | ||
) |
Write the character chr to the stream fd.
int spr_fputc_utf8 | ( | SprStream *restrict | fd, |
int | chr | ||
) |
Write the UTF-8 character chr (can map to multiple bytes) to the stream fd.
SprDynStr spr_fgets | ( | SprDynStr restrict | str, |
SprStream *restrict | fd, | ||
unsigned int | flags, | ||
int *restrict | pos | ||
) |
Read a string (dynamically allocated) from to the stream fd. If the pos argument is not NULL, then the read string will be written in the string starting at position *pos and *pos will be updated to reflect to total length of the string (excluding the final '\0'). The str argument can be either NULL or an existing dynamic string. The returned string is a dynamic string and must be treated as such (e.g. using spr_dynstr_free() to release the allocated memory). The flags argument can be a combination of the following bitmap flags:
char* spr_fgets_alt | ( | char *restrict | str, |
int *restrict | alen, | ||
SprStream *restrict | fd, | ||
unsigned int | flags, | ||
int *restrict | pos | ||
) |
Read a string (dynamically allocated) from to the stream fd. The argument str can be either NULL (*alen must then equal 0) or an existing allocated chunk of memory of length *alen. If the pos argument is not NULL, then the read string will be written in the string starting at position *pos and *pos will be updated to reflect to total length of the string (excluding the final '\0'). The returned string is an allocated chunk of memory of length *alen and must be treated as such (e.g. using spr_free() to release the allocated memory). The argument flags can be a combination of the following bitmap flags:
ssize_t spr_fputs | ( | SprStream *restrict | fd, |
const char *restrict | str | ||
) |
Write the '\0' terminated string str to the stream fd.
ssize_t spr_fputsq | ( | SprStream *restrict | fd, |
const char *restrict | str | ||
) |
Write the '\0' terminated string str to the stream fd as a quoted string, i.e. surrounded by double quotes and all problematic characters replaced by equivalent escape codes.
ssize_t spr_fputsoq | ( | SprStream *restrict | fd, |
const char *restrict | str | ||
) |
Write the '\0' terminated string str to the stream fd, either as is (unquoted) of if needed surrounded by double quotes and all problematic characters replaced by equivalent escape codes.
int spr_stream_hex_write | ( | SprStream *restrict | fd, |
const void *restrict | data, | ||
size_t | Nel, | ||
size_t | el_size | ||
) |
Write the binary data *data consisting of Nel elements of size el_size to the stream fd as hexadecimal data. The elements should be atomic data types (char, short, int, long, long long, float, double).
int spr_stream_hex_read | ( | SprStream *restrict | fd, |
void *restrict | data, | ||
size_t | Nel, | ||
size_t | el_size | ||
) |
Read Nel elements of size el_size as hexadecimal data from fd. The data is stored in binary form in the buffer data. The elements should be atomic data types (char, short, int, long, long long, float, double).
Copy all data from stream src (till end-of-file) to stream dst. On entry, src and dst must be in read and write mode respectively, and the stream read and write pointers must be positioned as desired (typically right after the header).
int spr_fprintf | ( | SprStream *restrict | fd, |
const char *restrict | fmt, | ||
... | |||
) |
Formatted output of data. See fprintf() for more details.
int spr_vfprintf | ( | SprStream *restrict | fd, |
const char *restrict | fmt, | ||
va_list | args | ||
) |
Formatted output of data. See vfprintf() and spr_fprintf() for more details.
size_t spr_snprintf | ( | char *restrict | buf, |
size_t | size, | ||
const char *restrict | fmt, | ||
... | |||
) |
Formatted output of data to a string. See snprintf() for more details.
size_t spr_snprintf0 | ( | char *restrict | buf, |
size_t | size, | ||
const char *restrict | fmt, | ||
... | |||
) |
Identical to spr_snprintf(), except that the result is guaranteed to be '\0' terminated (except if size equals 0). A warning is given in case the result needed to be truncated.
size_t spr_vsnprintf | ( | char *restrict | buf, |
size_t | size, | ||
const char *restrict | fmt, | ||
va_list | args | ||
) |
Formatted output of data to a string. See snprintf() and spr_snprintf() for more details.
Formatted output of data to the dynamic string str. This routine automatically expands the string to meet the data requirements. See sprintf() for more details on the format specifier fmt.
Formatted output of data to a string. See sprintf() and spr_sprintf() for more details.
SprDynStr spr_soprintf | ( | SprDynStr restrict | str, |
size_t *restrict | offset, | ||
const char *restrict | fmt, | ||
... | |||
) |
Formatted output of data to a dynamic string str. Output start at *offset. The output starts at offset offset. See sprintf() and spr_sprintf() for more details.
SprDynStr spr_vsoprintf | ( | SprDynStr restrict | str, |
size_t *restrict | offset, | ||
const char *restrict | fmt, | ||
va_list | args | ||
) |
Formatted output of data to a dynamic string str. The output starts at offset offset. See vsprintf() and spr_vsprintf() for more details.
char* spr_sprintf_alt | ( | SprDynStr restrict | str, |
int *restrict | alen, | ||
const char *restrict | fmt, | ||
... | |||
) |
Formatted output of data to the dynamically allocated string str with alen bytes allocated. This routine automatically expands the string to meet the data requirements. See sprintf() for more details on the format specifier fmt.
char* spr_vsprintf_alt | ( | char *restrict | str, |
int *restrict | alen, | ||
const char *restrict | fmt, | ||
va_list | args | ||
) |
Formatted output of data to the dynamically allocated string str with alen bytes allocated. See sprintf() and spr_sprintf() for more details.
char* spr_soprintf_alt | ( | char *restrict | str, |
int *restrict | alen, | ||
int *restrict | pos, | ||
const char *restrict | fmt, | ||
... | |||
) |
Formatted output of data to the dynamically allocated string str with alen bytes allocated. Output starts at *pos. This routine automatically expands the string to meet the data requirements. See sprintf() for more details on the format specifier fmt.
SprDynStr spr_vsoprintf_alt | ( | char *restrict | str, |
int *restrict | alen, | ||
int *restrict | pos, | ||
const char *restrict | fmt, | ||
va_list | args | ||
) |
Formatted output of data to the dynamically allocated string str with alen bytes allocated. Output starts at *pos. This routine automatically expands the string to meet the data requirements. See sprintf() for more details on the format specifier fmt.
SprStream* spr_stream_open_tmp | ( | const char * | template_str, |
unsigned int | flags, | ||
... | |||
) |
Create a headerless temporary file and open for writing and reading. Other flags such as buffering can be specified in flags. If template_str is not NULL, then use the provided template and extra arguments to create a filename. If template_str is NULL, then generate a random name.
size_t spr_utf8_len | ( | const char * | str | ) |
Count how many utf-8 characters a given string contains.
char* spr_utf8_next | ( | const char * | str | ) |
Advance to the next utf-8 character.
char* spr_utf8_nextN | ( | const char * | str, |
int | N | ||
) |
Advance to the next utf-8 character N times.
char* spr_utf8_prev | ( | const char * | str | ) |
Back-up till the previous utf-8 character.
char* spr_utf8_get_advance | ( | int * | utf_chr, |
const char * | str | ||
) |
Get the current utf-8 character from str, store the character value in utf_chr and advance to the next character.
char* spr_utf8_check | ( | const char * | str, |
SprMsgId * | routine | ||
) |
Test if str is a valid utf-8 encoded string. If not, and if routine is not NULL, a warning is printed.
int spr_utf8_chr_len | ( | unsigned int | chr | ) |
Determine the length required to encode chr in utf-8 format.
char* spr_utf8_chr_put_advance | ( | char * | str, |
unsigned int | chr | ||
) |
Encode the character chr as a utf-8 (multi-byte) code and write it to str.
SprDT spr_dt_dt[1] |
The SPRAAK data type identifier (SprDT element) for data type identifiers. The string respresentation (used in file headers, messages, ...) of this type is "TYPE".
SprDT spr_dt_custom[1] |
The SPRAAK data type identifier (SprDT element) for something we can't handle. The string respresentation (used in file headers, messages, ...) of this type is "CUSTOM".
const SprOptDesc spr_od_common[] |
const SprHtblStr spr_htbl_str_empty |
const char spr_kset_key_data[] |
the string "DATA"
usefull for accessing this key.
const char spr_kset_key_layout[] |
the string "LAYOUT"
usefull for accessing this key.
const char spr_kset_key_format[] |
the string "FORMAT"
usefull for accessing this key.
const char spr_kset_key_type[] |
the string "TYPE"
usefull for accessing this key.
const char spr_kset_key_dim1[] |
the string "DIM1"
usefull for accessing this key.
const char spr_kset_key_dim2[] |
the string "DIM2"
usefull for accessing this key.
const char spr_kset_key_fshift[] |
the string "FSHIFT"
usefull for accessing this key.
const char spr_kset_key_foffset[] |
the string "FOFFSET"
usefull for accessing this key.
const char spr_kset_key_flength[] |
the string "FLENGTH"
usefull for accessing this key.
const char spr_kset_key_nchan[] |
the string "NCHAN"
usefull for accessing this key.
const char spr_kset_key_chanlen[] |
the string "CHANLEN"
usefull for accessing this key.
const char spr_kset_key_vlen[] |
the string "VLEN"
usefull for accessing this key.
const char spr_kset_key_vnum[] |
the string "VNUM"
usefull for accessing this key.
const char spr_kset_key_compress[] |
the string "COMPRESS"
usefull for accessing this key.
const char spr_kset_key_samplefreq[] |
the string "SAMPLEFREQ"
usefull for accessing this key.
const char spr_kset_val_minus1[] |
the string "-1 ", typically used as place holder for a key that will be filled in later (when the value is know), hence the inclusion of some extra spaces.
const char* const spr_kset_format_str[] |
The string representations belonging to the different SPR_KEY_FORMAT_XXX constants.
const char* const spr_kset_layout_str[] |
The string representations belonging to the different SPR_KEY_LAYOUT_XXX constants.
const char* const spr_kset_data_str[SPR_KEY_DATA_NR+1] |
SprStream* spr_msg_stream |
The message stream. Should only be used in between a pair of spr_msg_long_start() and spr_msg_long_stop() commands.
volatile int spr_signal_flag |
break requested ?
const char spr_str_srm_cid_classid[] |
const char spr_str_srm_cid_datatype[] |
const char spr_str_srm_cid_datatype_cvt[] |
const char spr_str_srm_cid_dynlib[] |
const char spr_str_srm_cid_globvar[] |
const char spr_str_srm_cid_vfs_open[] |
const char spr_str_srm_cid_vfs_ext[] |
const char spr_str_srm_cid_vfs_dev[] |
const char spr_str_srm_cid_vfs_mem[] |
const char* spr_stream_tmpdir |