|
SPRAAK
|
Collaboration diagram for API_SprLibInternal::lib::core:Data Structures | |
| class | SprStreamFile |
| Stream object that refers to classical file descriptors. More... | |
| class | SprStreamNull |
| Stream object that refers to the null device. More... | |
| class | SprStreamBuf |
| Stream object that refers to the null device. More... | |
| class | SprStreamDynBuf |
| Stream object that refers to a dynamically allocated buffer. More... | |
| class | SprStreamDynStr |
| Stream object that refers to a dynamic string. More... | |
Namespaces | |
| xref_spr_ini_fini | |
| Module initilisation and finalisation | |
| xref_spr_class | |
| Working with SPRAAK classes and objects | |
Modules | |
| API_SprLibInternal::lib::core::filefmt | |
Macros | |
| #define | SPR_DT_ENUM_INITIALIZER(name, str_tbl) |
| #define | SPR_INI_DEP(dep_mod_name) |
| #define | SPR_INI_MOD(mod_name, ini_func, fini_func, dep_lst) |
| #define | SPR_DEFAULT_FORMAT |
| #define | SPR_DEFAULT_FORMAT_STR |
| #define | spr_assert1(routine__, tst__) |
| #define | spr_assert2(routine__, tst__) |
| #define | spr_assert3(routine__, tst__) |
Typedefs | |
| typedef int(* | SprDT_read1 )(const SprDT *restrict dt, SprStream *restrict fd, void *restrict dst) |
| typedef int(* | SprDT_write1 )(const SprDT *restrict dt, SprStream *restrict fd, const void *restrict src) |
| typedef char *(* | SprDT_str_cvt )(const SprDT *restrict dt, void *restrict dst, const char *restrict str) |
| typedef void(* | SprDT_free )(const SprDT *restrict dt, void *restrict ptr) |
| typedef void *(* | SprDT_cpy )(const SprDT *restrict dt, void *restrict dst, const void *restrict src) |
| typedef SprDynStr(* | SprDT_str )(const SprDT *restrict dt, const void *restrict src) |
| typedef ssize_t(* | SprDT_print )(const SprDT *restrict dt, SprStream *restrict fd, const void *restrict src) |
| typedef struct SprIniDep | SprIniDep |
| typedef struct SprIniMod | SprIniMod |
Functions | |
| int | spr_atomic_slot_acquire0_nowait (SprAtomicSlot *slot) |
| void | spr_atomic_slot_signal_ready (SprAtomicSlot *slot, int ndx) |
| int | spr_atomic_slot_signal_ready_acquire0_nowait (SprAtomicSlot *slot, int ndx) |
| void | spr_atomic_slot_release (SprAtomicSlot *slot, int ndx) |
| void | spr_atomic_slot_release0 (SprAtomicSlot *slot) |
| Release slot 0. More... | |
| uint32_t | spr_atomic_slot_release_nocheck (SprAtomicSlot *slot, int ndx) |
| void | spr_atomic_slot_release0_check (SprAtomicSlot *slot) |
| int | spr_atomic_slot_release_check0 (SprAtomicSlot *slot, int ndx) |
| void | spr_atomic_slot_release_all (SprAtomicSlot *slot) |
| char * | spr_ctime (const time_t *timep, char *buf, size_t sz) |
| struct tm * | spr_gmtime (const time_t *timep, struct tm *result) |
| char * | spr_f64_to_str (char buf[32], double x) |
| char * | spr_f32_to_str (char buf[16], float x) |
| void | spr_dt_free (const SprDT *restrict dt, void *restrict ptr) |
| void | spr_dt_alloc_free (const SprDT *restrict dt, void *restrict ptr) |
| Free for simple allocated objects. More... | |
| size_t | spr_dynmem_item_cnt (void) |
| size_t | spr_dynmem_byte_cnt (void) |
| void | spr_hexdump2buf (char *dst, const void *data, size_t size) |
| int | spr_dynmem_dump (SprStream *fd) |
| Dump the data that is still allocated to file fd. This routine is not mult-threading safe. More... | |
| const char * | spr_str_no_empty (const char *str, const char *str_empty) |
| void | spr_dynmem_cfg (int mode) |
| int | spr_hash_strlin_searchn (const char *restrict const hlst[], int Nel, const char *restrict str) |
| int | spr_ini_register (SprIniMod *curr_mod) |
| int | spr_ini_resolve (void) |
| int | spr_kset_enohdr_adjust (SprStream *restrict fd) |
| SprKeySet * | spr_kset_read_spraak (SprStream *restrict fd, SprKeySet *restrict keys) |
| int | spr_kset_write_spraak (SprStream *restrict fd, SprKeySet *restrict keys, int mode) |
| SprKeySet * | spr_kset_read_key (SprStream *restrict fd, SprKeySet *restrict keys) |
| int | spr_kset_write_key (SprStream *restrict fd, SprKeySet *restrict keys, int mode) |
| int | spr_kset_stream_adjust_close (SprStream *restrict fd, ssize_t dim1) |
| void | spr_msg_set_timeout (int sec) |
| int | spr_msg_ini_time (SprMsgId *prog) |
| SprSrmEl * | spr_srm_check (const SprSrmEl *srm_el) |
| SprStream * | spr_stream_close_check_auto (SprStream *restrict fd, SprMsgId *restrict routine) |
| SprStream * | spr_stream_nullqw_make (SprStreamNull *restrict fd) |
| off_t | spr_stream_buf_tell (SprStreamBuf *restrict fd) |
| SprStream * | spr_stream_buf_make (const char *name, uint8_t *buf, size_t size, size_t fill, unsigned int flags, SprKeySet *keys) |
| SprStream * | spr_stream_bufqr_make (SprStreamBuf *restrict fd, const char *restrict buf, size_t size) |
| const void * | spr_stream_buf_get (SprStreamBuf *fd) |
| void | spr_stream_buf_rewind (SprStreamBuf *fd) |
| void * | spr_stream_dynbuf_close_getdata (SprStreamDynBuf *restrict fd) |
| SprDynStr | spr_stream_dynstr_close_getdata (SprStreamDynStr *restrict fd) |
| void * | spr_stream_dynbufq_close (SprStreamDynBuf *restrict fd) |
| SprDynStr | spr_stream_dynstrq_close (SprStreamDynStr *restrict fd) |
| SprStream * | spr_stream_dynbufq_make (SprStreamDynBuf *restrict fd, void *restrict buf, size_t alen, size_t fill) |
| SprStream * | spr_stream_dynstrq_make (SprStreamDynStr *restrict fd, SprDynStr str, size_t fill) |
| size_t | spr_strlenq (const char *restrict str) |
| size_t | spr_strlenoq (const char *restrict str) |
Variables | |
| const char * | spr_ini_fail |
| #define SPR_DT_ENUM_INITIALIZER | ( | name, | |
| str_tbl | |||
| ) |
Initialize some static enumeration type. The static means that but the type and the NULL terminated array of strings will exist for as long as the enumeration type is needed, and that neither must be explicitely freed.
The name argument specifies the string respresentation (used in file headers, messages, ...) that will be used for this type. Typically this is of the form "ENUM_...".
The str_tbl is the NULL terminated list of string giving the possible different values. The string are mapped to 0...(#strings-1). There is (currently) no provision to map to strings to the same number, to allow gaps in the numbering or to allow negative numbers.
Code example:
| #define SPR_INI_DEP | ( | dep_mod_name | ) |
Initialize an element in the dependency list (of the type SprIniDep). See Module initilisation and finalisation for an example.
| #define SPR_INI_MOD | ( | mod_name, | |
| ini_func, | |||
| fini_func, | |||
| dep_lst | |||
| ) |
Initialize the main dependecy structure (of the type SprIniMod). See Module initilisation and finalisation for an example.
| #define SPR_DEFAULT_FORMAT |
| #define SPR_DEFAULT_FORMAT_STR |
| #define spr_assert1 | ( | routine__, | |
| tst__ | |||
| ) |
| #define spr_assert2 | ( | routine__, | |
| tst__ | |||
| ) |
| #define spr_assert3 | ( | routine__, | |
| tst__ | |||
| ) |
| typedef int(* SprDT_write1)(const SprDT *restrict dt, SprStream *restrict fd, const void *restrict src) |
| typedef char*(* SprDT_str_cvt)(const SprDT *restrict dt, void *restrict dst, const char *restrict str) |
| typedef void(* SprDT_free)(const SprDT *restrict dt, void *restrict ptr) |
| typedef void*(* SprDT_cpy)(const SprDT *restrict dt, void *restrict dst, const void *restrict src) |
| typedef ssize_t(* SprDT_print)(const SprDT *restrict dt, SprStream *restrict fd, const void *restrict src) |
Opaque type needed to create a dependency for ini or fini routine. See Module initilisation and finalisation for more details.
Opaque type needed to create a dependency for ini or fini routine. See Module initilisation and finalisation for more details.
| int spr_atomic_slot_acquire0_nowait | ( | SprAtomicSlot * | slot | ) |
Try to get slot 0.
| void spr_atomic_slot_signal_ready | ( | SprAtomicSlot * | slot, |
| int | ndx | ||
| ) |
Signal that a previously acquired slot is ready for further processing.
| int spr_atomic_slot_signal_ready_acquire0_nowait | ( | SprAtomicSlot * | slot, |
| int | ndx | ||
| ) |
Signal that a previously acquired slot is ready and try to aquire slot 0 (to further process the content of slot ndx and any other slot that is ready).
| void spr_atomic_slot_release | ( | SprAtomicSlot * | slot, |
| int | ndx | ||
| ) |
Clear the ready flag for a previously acquired slot and release the slot (for reuse).
| void spr_atomic_slot_release0 | ( | SprAtomicSlot * | slot | ) |
Release slot 0.
| uint32_t spr_atomic_slot_release_nocheck | ( | SprAtomicSlot * | slot, |
| int | ndx | ||
| ) |
Clear the ready flag for a previously acquired slot and release the slot (for reuse). Do not check for waiting threads.
| void spr_atomic_slot_release0_check | ( | SprAtomicSlot * | slot | ) |
Do the checking part after a series of spr_atomic_slot_release_nocheck() calls.
| int spr_atomic_slot_release_check0 | ( | SprAtomicSlot * | slot, |
| int | ndx | ||
| ) |
Clear the ready flag for a previously acquired slot and release the slot (for reuse). This routine should only be used when the caller has acquired slot 0 (the real resource).
| void spr_atomic_slot_release_all | ( | SprAtomicSlot * | slot | ) |
Release all slots.
| char* spr_ctime | ( | const time_t * | timep, |
| char * | buf, | ||
| size_t | sz | ||
| ) |
Replaces the ctime() function in a thread-safe fashion by writing the result to the buffer buf of length sz.
| struct tm* spr_gmtime | ( | const time_t * | timep, |
| struct tm * | result | ||
| ) |
Replaces the gmtime() function in a thread-safe fashion by writing the result to the buffer result.
| char* spr_f64_to_str | ( | char | buf[32], |
| double | x | ||
| ) |
Make a standardized numeric representation of the given double x and write it to buf. Should be very similar to sprintf(buf,"\%.15\#g",x).
| char* spr_f32_to_str | ( | char | buf[16], |
| float | x | ||
| ) |
Make a standardized numeric representation of the given float x and write it to buf. Should be very similar to sprintf(buf,"\%.6\#g",x).
| void spr_dt_free | ( | const SprDT *restrict | dt, |
| void *restrict | ptr | ||
| ) |
Release all memory associated to the object of type dt located at address ptr.
| void spr_dt_alloc_free | ( | const SprDT *restrict | dt, |
| void *restrict | ptr | ||
| ) |
Free for simple allocated objects.
| size_t spr_dynmem_item_cnt | ( | void | ) |
Return the total number of items allocated (and not yet freed). The count also includes the dynamically sized strings and the structures needed for the large pools of identical sized items.
| size_t spr_dynmem_byte_cnt | ( | void | ) |
Return the total number of bytes allocated (and not yet freed). The count also includes the dynamically sized strings (which are typically over-allocated) and the structures needed for the large pools of identical sized items. The returned value is only accurate if the accounting system is active.
| void spr_hexdump2buf | ( | char * | dst, |
| const void * | data, | ||
| size_t | size | ||
| ) |
Auxilary routine for hexdumping data to the message system (via a temporary buffer).
| dst | String to print the hexdump to (must be 60 characters long). |
| data | The data to dump. |
| size | The number of bytes to dump (will be clipped to 16 bytes). |
| int spr_dynmem_dump | ( | SprStream * | fd | ) |
Dump the data that is still allocated to file fd. 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.
| fd | File to dump the data to. |
| const char* spr_str_no_empty | ( | const char * | str, |
| const char * | str_empty | ||
| ) |
| str | String to check. |
| str_empty | Alternative. |
| void spr_dynmem_cfg | ( | int | mode | ) |
Set the amount of accounting and checking for the dynamic memory management sub-system in SPRAAK. The mode can be set to the following values:
'–check_dynmem <lvl>' option is specified when calling a program or by setting the 'SPR_DYNMEM_CHECK' environment variable. | mode | Amount of accounting and checking requested. |
| int spr_hash_strlin_searchn | ( | 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. A string str matches an entry in hlst if all its characters up till but not including the terminating '\0' match with hlst[ndx], i.e. if memcpy(str,hlst[ndx],strlen(str)) equals 0. An addition contraint is that only one entry in hlst may match.
| int spr_ini_register | ( | SprIniMod * | curr_mod | ) |
| int spr_ini_resolve | ( | void | ) |
| int spr_kset_enohdr_adjust | ( | SprStream *restrict | fd | ) |
Adjust the dimension keys when reading from a disk based file with no (or an external) header.
Read the key-set keys from the open stream fd using the SPRAAK-header format. The stream must be in read mode and the read pointer should be positioned right after (or right before) the magic word (file header indicator). If keys equals NULL, the keyset internal to fd will be used (which will be allocated if needed). In other words, the only way to use a keyset different to the one inside fd is by specifying a non NULL keys argument.
Write the key-set keys to the open stream fd using the SPRAAK-header format. If keys equals NULL, the keyset internal to fd will be used. The flag mode determines how much space the header may occupy on disk:
Read the key-set keys from the open stream fd using the key-header format. The stream must be in read mode and the read pointer should be positioned right after (or right before) the magic word (file header indicator). If keys equals NULL, the keyset internal to fd will be used (which will be allocated if needed). In other words, the only way to use a keyset different to the one inside fd is by specifying a non NULL keys argument.
Write the key-set keys to the open stream fd using the key-header format. If keys equals NULL, the keyset internal to fd will be used. The flag mode determines how much space the header may occupy on disk:
| int spr_kset_stream_adjust_close | ( | SprStream *restrict | fd, |
| ssize_t | dim1 | ||
| ) |
Adjust the key DIM1 to its new value, try to adjust the header on the media and close the stream. See spr_kset_set_value_dim1(), spr_kset_stream_modif() and spr_stream_close() for more details.
| void spr_msg_set_timeout | ( | int | sec | ) |
Allow the message system to timeout. A value of 0 disables the timing out the message system. Any other value will timeout the message system after sec seconds starting from when this routine was called;
| sec | Timeout value in seconds |
| int spr_msg_ini_time | ( | SprMsgId * | prog | ) |
Check if the shared resource srm_el is present in the hash table (the table must be in a locked state!!!).
| srm_el | Shared resource. |
Remove the file from the auto-removal queue.
| SprStream* spr_stream_nullqw_make | ( | SprStreamNull *restrict | fd | ) |
Quickly initialize the '/dev/null' stream fd for writing.
| off_t spr_stream_buf_tell | ( | SprStreamBuf *restrict | fd | ) |
| SprStream* spr_stream_buf_make | ( | const char * | name, |
| uint8_t * | buf, | ||
| size_t | size, | ||
| size_t | fill, | ||
| unsigned int | flags, | ||
| SprKeySet * | keys | ||
| ) |
Create a stream named name that maps to a static data buffer buf of length size. The buffer is already filled with data up till position fill. The flags and keys arguments behave identically as in spr_stream_open().
| SprStream* spr_stream_bufqr_make | ( | SprStreamBuf *restrict | fd, |
| const char *restrict | buf, | ||
| size_t | size | ||
| ) |
Quickly initialize the stream fd for reading (ASCII mode) from the buffer buf assuming a length of size bytes.
| const void* spr_stream_buf_get | ( | SprStreamBuf * | fd | ) |
Get the content of the static buffer (after flushing all pending write data).
| void spr_stream_buf_rewind | ( | SprStreamBuf * | fd | ) |
| void* spr_stream_dynbuf_close_getdata | ( | SprStreamDynBuf *restrict | fd | ) |
Close the dynamic buffer stream and return the dynamically allocated buffer.
| SprDynStr spr_stream_dynstr_close_getdata | ( | SprStreamDynStr *restrict | fd | ) |
Close the dynamic string buffer stream and return the dynamic string.
| void* spr_stream_dynbufq_close | ( | SprStreamDynBuf *restrict | fd | ) |
Close the 'quick' dynamic buffer stream and return the dynamic buffer.
| SprDynStr spr_stream_dynstrq_close | ( | SprStreamDynStr *restrict | fd | ) |
Close the 'quick' dynamic string buffer stream and return the dynamic string.
| SprStream* spr_stream_dynbufq_make | ( | SprStreamDynBuf *restrict | fd, |
| void *restrict | buf, | ||
| size_t | alen, | ||
| size_t | fill | ||
| ) |
Quickly initialize the stream fd for writing (ASCII mode) to the dynamically allocated buffer buf of size alen assuming fill characters/bytes are already filled in.
| SprStream* spr_stream_dynstrq_make | ( | SprStreamDynStr *restrict | fd, |
| SprDynStr | str, | ||
| size_t | fill | ||
| ) |
Quickly initialize the stream fd for writing (ASCII mode) to the dynamic string str assuming fill characters/bytes are already filled in.
| size_t spr_strlenq | ( | const char *restrict | str | ) |
Determine the length of a string when it would be converted to a quoted string.
| size_t spr_strlenoq | ( | const char *restrict | str | ) |
Determine the length of a string when it would be optionally (i.e. if required for proper reading) converted to a quoted string.
| const char* spr_ini_fail |
Since initialisation and finalisation routines cannot return any values, error conditions are collected in this variable. See Module initilisation and finalisation for an example.
1.8.6