blob: 272fb399650f3716e7d62adbe884677a68ca71cc [file] [log] [blame]
E. Scott Daniels117030c2020-04-10 17:17:02 -04001
2
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.
8
9
10============================================================================================
11Man Page: rmr_support
12============================================================================================
13
14RMR Library Functions
15============================================================================================
16
17
18NAME
19--------------------------------------------------------------------------------------------
20
21RMR support functions
22
23SYNOPSIS
24--------------------------------------------------------------------------------------------
25
26
27::
28
29 #include <rmr/rmr.h>
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 )
38
39
40
41DESCRIPTION
42--------------------------------------------------------------------------------------------
43
44These functions support the RMR library, and are made
45available to user applications as some (e.g. route table
46generators) might need and/or want to make use of them. The
47rmr_fib function accepts a file name and reads the entire
48file into a single buffer. The intent is to provide an easy
49way to load a static route table without a lot of buffered
50I/O hoops.
51
52The rmr_has_str function accepts a *buffer* containing a set
53of delimited tokens (e.g. foo,bar,goo) and returns true if
54the target string, *str,* matches one of the tokens. The
55*sep* parameter provides the separation character in the
56buffer (e.g a comma) and *max* indicates the maximum number
57of tokens to split the buffer into before checking.
58
59The rmr_tokenise function is a simple tokeniser which splits
60*buf* into tokens at each occurrence of *sep*. Multiple
61occurrences of the separator character (e.g. a,,b) result in
62a nil token. Pointers to the tokens are placed into the
63*tokens* array provided by the caller which is assumed to
64have at least enough space for *max* entries.
65
66The rmr_mk_ring function creates a buffer ring with *size*
67entries.
68
69The rmr_ring_free function accepts a pointer to a ring
70context and frees the associated memory.
71
72The rmr_ring_insert and rmr_ring_extract functions are
73provided as static inline functions via the
74*rmr/ring_inline.h* header file. These functions both accept
75the ring *context* returned by mk_ring, and either insert a
76pointer at the next available slot (tail) or extract the data
77at the head.
78
79RETURN VALUES
80--------------------------------------------------------------------------------------------
81
82The following are the return values for each of these
83functions.
84
85The rmr_fib function returns a pointer to the buffer
86containing the contents of the file. The buffer is terminated
87with a single nil character (0) making it a legitimate C
88string. If the file was empty or nonexistent, a buffer with
89an immediate nil character. If it is important to the calling
90programme to know if the file was empty or did not exist, the
91caller should use the system stat function call to make that
92determination.
93
94The rmr_has_str function returns 1 if *buf* contains the
95token referenced by &ita and false (0) if it does not. On
96error, a -1 value is returned and errno is set accordingly.
97
98The rmr_tokenise function returns the actual number of token
99pointers placed into *tokens*
100
101The rmr_mk_ring function returns a void pointer which is the
102*context* for the ring.
103
104The rmr_ring_insert function returns 1 if the data was
105successfully inserted into the ring, and 0 if the ring is
106full and the pointer could not be deposited.
107
108The rmr_ring_extract will return the data which is at the
109head of the ring, or NULL if the ring is empty.
110
111ERRORS
112--------------------------------------------------------------------------------------------
113
114Not many of these functions set the value in errno, however
115the value may be one of the following:
116
117
118INVAL
119
120 Parameter(s) passed to the function were not valid.
121
122
123EXAMPLE
124--------------------------------------------------------------------------------------------
125
126
127SEE ALSO
128--------------------------------------------------------------------------------------------
129
130rmr_alloc_msg(3), rmr_call(3), rmr_free_msg(3), rmr_init(3),
131rmr_payload_size(3), rmr_send_msg(3), rmr_rcv_msg(3),
132rmr_rcv_specific(3), rmr_rts_msg(3), rmr_ready(3),