blob: 648bedf7cc111138f5de1be9d68a9bdf70be618a [file] [log] [blame]
E. Scott Daniels117030c2020-04-10 17:17:02 -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
E. Scott Daniels117030c2020-04-10 17:17:02 -04007============================================================================================
8Man Page: rmr_support
9============================================================================================
10
E. Scott Daniels117030c2020-04-10 17:17:02 -040011
E. Scott Danielsa3a121c2020-05-06 09:07:08 -040012
13
14RMR LIBRARY FUNCTIONS
15=====================
16
17
18
19NAME
20----
21
E. Scott Daniels117030c2020-04-10 17:17:02 -040022RMR support functions
E. Scott Danielsa3a121c2020-05-06 09:07:08 -040023
24
25SYNOPSIS
26--------
27
E. Scott Daniels117030c2020-04-10 17:17:02 -040028
29::
E. Scott Danielsa3a121c2020-05-06 09:07:08 -040030
E. Scott Daniels117030c2020-04-10 17:17:02 -040031 #include <rmr/rmr.h>
32 #include <rmr/ring_inline.h>
E. Scott Danielsa3a121c2020-05-06 09:07:08 -040033
E. Scott Daniels117030c2020-04-10 17:17:02 -040034 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 );
E. Scott Danielsa3a121c2020-05-06 09:07:08 -040039
E. Scott Daniels117030c2020-04-10 17:17:02 -040040 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 Daniels117030c2020-04-10 17:17:02 -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
E. Scott Danielsa3a121c2020-05-06 09:07:08 -040051``rmr_fib`` function accepts a file name and reads the entire
E. Scott Daniels117030c2020-04-10 17:17:02 -040052file 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
E. Scott Danielsa3a121c2020-05-06 09:07:08 -040056The ``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
E. Scott Daniels117030c2020-04-10 17:17:02 -040059*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
E. Scott Danielsa3a121c2020-05-06 09:07:08 -040063The ``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
E. Scott Daniels117030c2020-04-10 17:17:02 -040068have at least enough space for *max* entries.
69
E. Scott Danielsa3a121c2020-05-06 09:07:08 -040070The ``rmr_mk_ring`` function creates a buffer ring with
71*size* entries.
E. Scott Daniels117030c2020-04-10 17:17:02 -040072
E. Scott Danielsa3a121c2020-05-06 09:07:08 -040073The ``rmr_ring_free`` function accepts a pointer to a ring
E. Scott Daniels117030c2020-04-10 17:17:02 -040074context and frees the associated memory.
75
E. Scott Danielsa3a121c2020-05-06 09:07:08 -040076The ``rmr_ring_insert`` and ``rmr_ring_extract`` functions
77are provided as static inline functions via the
E. Scott Daniels117030c2020-04-10 17:17:02 -040078*rmr/ring_inline.h* header file. These functions both accept
E. Scott Danielsa3a121c2020-05-06 09:07:08 -040079the ring *context* returned by ``mk_ring,`` and either insert
80a pointer at the next available slot (tail) or extract the
81data at the head.
82
83
84RETURN VALUES
85-------------
86
E. Scott Daniels117030c2020-04-10 17:17:02 -040087The following are the return values for each of these
88functions.
89
E. Scott Danielsa3a121c2020-05-06 09:07:08 -040090The ``rmr_fib`` function returns a pointer to the buffer
E. Scott Daniels117030c2020-04-10 17:17:02 -040091containing 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
E. Scott Danielsa3a121c2020-05-06 09:07:08 -040099The ``rmr_has_str`` function returns 1 if *buf* contains the
E. Scott Daniels117030c2020-04-10 17:17:02 -0400100token referenced by &ita and false (0) if it does not. On
E. Scott Danielsa3a121c2020-05-06 09:07:08 -0400101error, a -1 value is returned and ``errno`` is set
102accordingly.
E. Scott Daniels117030c2020-04-10 17:17:02 -0400103
E. Scott Danielsa3a121c2020-05-06 09:07:08 -0400104The ``rmr_tokenise`` function returns the actual number of
105token pointers placed into *tokens*
E. Scott Daniels117030c2020-04-10 17:17:02 -0400106
E. Scott Danielsa3a121c2020-05-06 09:07:08 -0400107The ``rmr_mk_ring`` function returns a void pointer which is
108the *context* for the ring.
E. Scott Daniels117030c2020-04-10 17:17:02 -0400109
E. Scott Danielsa3a121c2020-05-06 09:07:08 -0400110The ``rmr_ring_insert`` function returns 1 if the data was
E. Scott Daniels117030c2020-04-10 17:17:02 -0400111successfully inserted into the ring, and 0 if the ring is
112full and the pointer could not be deposited.
113
E. Scott Danielsa3a121c2020-05-06 09:07:08 -0400114The ``rmr_ring_extract`` will return the data which is at the
E. Scott Daniels117030c2020-04-10 17:17:02 -0400115head of the ring, or NULL if the ring is empty.
E. Scott Danielsa3a121c2020-05-06 09:07:08 -0400116
117
118ERRORS
119------
120
121Not many of these functions set the value in ``errno,``
122however the value may be one of the following:
E. Scott Daniels117030c2020-04-10 17:17:02 -0400123
E. Scott Danielsa3a121c2020-05-06 09:07:08 -0400124 .. 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
E. Scott Daniels117030c2020-04-10 17:17:02 -0400133
E. Scott Danielsa3a121c2020-05-06 09:07:08 -0400134
135
136EXAMPLE
137-------
138
139
140
141SEE ALSO
142--------
143
E. Scott Daniels117030c2020-04-10 17:17:02 -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),