blob: cc63e43152d2151825babc075493bf38c5ee9bb1 [file] [log] [blame]
E. Scott Danielsece5bbe2020-07-21 13:39:18 -04001.. This work is licensed under a Creative Commons Attribution 4.0 International License.
2.. SPDX-License-Identifier: CC-BY-4.0
3.. CAUTION: this document is generated from source in doc/src/rtd.
4.. To make changes edit the source and recompile the document.
5.. Do NOT make changes directly to .rst or .md files.
6
7============================================================================================
8Man Page: rmr_support
9============================================================================================
10
11
E. Scott Danielsa3a121c2020-05-06 09:07:08 -040012
13
14RMR LIBRARY FUNCTIONS
15=====================
16
17
18
19NAME
20----
21
E. Scott Danielsece5bbe2020-07-21 13:39:18 -040022RMR support functions
E. Scott Danielsa3a121c2020-05-06 09:07:08 -040023
24
25SYNOPSIS
26--------
27
E. Scott Danielsece5bbe2020-07-21 13:39:18 -040028
29::
30
31 #include <rmr/rmr.h>
32 #include <rmr/ring_inline.h>
33
34 char* rmr_fib( char* fname );
35 int rmr_has_str( char const* buf, char const* str, char sep, int max );
36 int rmr_tokenise( char* buf, char** tokens, int max, char sep );
37 void* rmr_mk_ring( int size );
38 void rmr_ring_free( void* vr );
39
40 static inline void* rmr_ring_extract( void* vr )
41 static inline int rmr_ring_insert( void* vr, void* new_data )
42
E. Scott Danielsa3a121c2020-05-06 09:07:08 -040043
44
45DESCRIPTION
46-----------
47
E. Scott Danielsece5bbe2020-07-21 13:39:18 -040048These functions support the RMR library, and are made
49available to user applications as some (e.g. route table
50generators) might need and/or want to make use of them. The
51``rmr_fib`` function accepts a file name and reads the entire
52file into a single buffer. The intent is to provide an easy
53way to load a static route table without a lot of buffered
54I/O hoops.
55
56The ``rmr_has_str`` function accepts a *buffer* containing a
57set of delimited tokens (e.g. foo,bar,goo) and returns true
58if the target string, *str,* matches one of the tokens. The
59*sep* parameter provides the separation character in the
60buffer (e.g a comma) and *max* indicates the maximum number
61of tokens to split the buffer into before checking.
62
63The ``rmr_tokenise`` function is a simple tokeniser which
64splits *buf* into tokens at each occurrence of *sep*.
65Multiple occurrences of the separator character (e.g. a,,b)
66result in a nil token. Pointers to the tokens are placed into
67the *tokens* array provided by the caller which is assumed to
68have at least enough space for *max* entries.
69
70The ``rmr_mk_ring`` function creates a buffer ring with
71*size* entries.
72
73The ``rmr_ring_free`` function accepts a pointer to a ring
74context and frees the associated memory.
75
76The ``rmr_ring_insert`` and ``rmr_ring_extract`` functions
77are provided as static inline functions via the
78*rmr/ring_inline.h* header file. These functions both accept
79the ring *context* returned by ``mk_ring,`` and either insert
80a pointer at the next available slot (tail) or extract the
81data at the head.
E. Scott Danielsa3a121c2020-05-06 09:07:08 -040082
83
84RETURN VALUES
85-------------
86
E. Scott Danielsece5bbe2020-07-21 13:39:18 -040087The following are the return values for each of these
88functions.
89
90The ``rmr_fib`` function returns a pointer to the buffer
91containing the contents of the file. The buffer is terminated
92with a single nil character (0) making it a legitimate C
93string. If the file was empty or nonexistent, a buffer with
94an immediate nil character. If it is important to the calling
95programme to know if the file was empty or did not exist, the
96caller should use the system stat function call to make that
97determination.
98
99The ``rmr_has_str`` function returns 1 if *buf* contains the
100token referenced by &ita and false (0) if it does not. On
101error, a -1 value is returned and ``errno`` is set
102accordingly.
103
104The ``rmr_tokenise`` function returns the actual number of
105token pointers placed into *tokens*
106
107The ``rmr_mk_ring`` function returns a void pointer which is
108the *context* for the ring.
109
110The ``rmr_ring_insert`` function returns 1 if the data was
111successfully inserted into the ring, and 0 if the ring is
112full and the pointer could not be deposited.
113
114The ``rmr_ring_extract`` will return the data which is at the
115head of the ring, or NULL if the ring is empty.
E. Scott Danielsa3a121c2020-05-06 09:07:08 -0400116
117
118ERRORS
119------
120
E. Scott Danielsece5bbe2020-07-21 13:39:18 -0400121Not many of these functions set the value in ``errno,``
122however the value may be one of the following:
123
124 .. list-table::
125 :widths: auto
126 :header-rows: 0
127 :class: borderless
128
129 * - **INVAL**
130 -
131 Parameter(s) passed to the function were not valid.
132
133
E. Scott Danielsa3a121c2020-05-06 09:07:08 -0400134
135
136EXAMPLE
137-------
138
139
140
141SEE ALSO
142--------
143
E. Scott Danielsece5bbe2020-07-21 13:39:18 -0400144rmr_alloc_msg(3), rmr_call(3), rmr_free_msg(3), rmr_init(3),
145rmr_payload_size(3), rmr_send_msg(3), rmr_rcv_msg(3),
146rmr_rcv_specific(3), rmr_rts_msg(3), rmr_ready(3),