3 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
4 .. SPDX-License-Identifier: CC-BY-4.0
5 .. CAUTION: this document is generated from source in doc/src/rtd.
6 .. To make changes edit the source and recompile the document.
7 .. Do NOT make changes directly to .rst or .md files.
10 ============================================================================================
12 ============================================================================================
15 ============================================================================================
19 --------------------------------------------------------------------------------------------
24 --------------------------------------------------------------------------------------------
30 #include <rmr/ring_inline.h>
31 char* rmr_fib( char* fname );
32 int rmr_has_str( char const* buf, char const* str, char sep, int max );
33 int rmr_tokenise( char* buf, char** tokens, int max, char sep );
34 void* rmr_mk_ring( int size );
35 void rmr_ring_free( void* vr );
36 static inline void* rmr_ring_extract( void* vr )
37 static inline int rmr_ring_insert( void* vr, void* new_data )
42 --------------------------------------------------------------------------------------------
44 These functions support the RMR library, and are made
45 available to user applications as some (e.g. route table
46 generators) might need and/or want to make use of them. The
47 rmr_fib function accepts a file name and reads the entire
48 file into a single buffer. The intent is to provide an easy
49 way to load a static route table without a lot of buffered
52 The rmr_has_str function accepts a *buffer* containing a set
53 of delimited tokens (e.g. foo,bar,goo) and returns true if
54 the target string, *str,* matches one of the tokens. The
55 *sep* parameter provides the separation character in the
56 buffer (e.g a comma) and *max* indicates the maximum number
57 of tokens to split the buffer into before checking.
59 The rmr_tokenise function is a simple tokeniser which splits
60 *buf* into tokens at each occurrence of *sep*. Multiple
61 occurrences of the separator character (e.g. a,,b) result in
62 a nil token. Pointers to the tokens are placed into the
63 *tokens* array provided by the caller which is assumed to
64 have at least enough space for *max* entries.
66 The rmr_mk_ring function creates a buffer ring with *size*
69 The rmr_ring_free function accepts a pointer to a ring
70 context and frees the associated memory.
72 The rmr_ring_insert and rmr_ring_extract functions are
73 provided as static inline functions via the
74 *rmr/ring_inline.h* header file. These functions both accept
75 the ring *context* returned by mk_ring, and either insert a
76 pointer at the next available slot (tail) or extract the data
80 --------------------------------------------------------------------------------------------
82 The following are the return values for each of these
85 The rmr_fib function returns a pointer to the buffer
86 containing the contents of the file. The buffer is terminated
87 with a single nil character (0) making it a legitimate C
88 string. If the file was empty or nonexistent, a buffer with
89 an immediate nil character. If it is important to the calling
90 programme to know if the file was empty or did not exist, the
91 caller should use the system stat function call to make that
94 The rmr_has_str function returns 1 if *buf* contains the
95 token referenced by &ita and false (0) if it does not. On
96 error, a -1 value is returned and errno is set accordingly.
98 The rmr_tokenise function returns the actual number of token
99 pointers placed into *tokens*
101 The rmr_mk_ring function returns a void pointer which is the
102 *context* for the ring.
104 The rmr_ring_insert function returns 1 if the data was
105 successfully inserted into the ring, and 0 if the ring is
106 full and the pointer could not be deposited.
108 The rmr_ring_extract will return the data which is at the
109 head of the ring, or NULL if the ring is empty.
112 --------------------------------------------------------------------------------------------
114 Not many of these functions set the value in errno, however
115 the value may be one of the following:
120 Parameter(s) passed to the function were not valid.
124 --------------------------------------------------------------------------------------------
128 --------------------------------------------------------------------------------------------
130 rmr_alloc_msg(3), rmr_call(3), rmr_free_msg(3), rmr_init(3),
131 rmr_payload_size(3), rmr_send_msg(3), rmr_rcv_msg(3),
132 rmr_rcv_specific(3), rmr_rts_msg(3), rmr_ready(3),