2 ==================================================================================
3 Copyright (c) 2019 Nokia
4 Copyright (c) 2018-2019 AT&T Intellectual Property.
6 Licensed under the Apache License, Version 2.0 (the "License");
7 you may not use this file except in compliance with the License.
8 You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17 ==================================================================================
20 Mnemonic rmr_support_man.xfm
21 Abstract The manual page for the rmr_ functions that support the library
22 and are available to support other applications such as the route
23 table generator, but are not directly related to message sending
24 and receiving. These "second class" functions therefore are
25 likely not to need a dedicated man page, so we lump them all
27 Author E. Scott Daniels
32 .im &{lib}/man/setup.im
36 &h1(RMR Library Functions)
44 #include <rmr/ring_inline.h>
46 char* rmr_fib( char* fname );
47 int rmr_has_str( char const* buf, char const* str, char sep, int max );
48 int rmr_tokenise( char* buf, char** tokens, int max, char sep );
49 void* rmr_mk_ring( int size );
50 void rmr_ring_free( void* vr );
52 static inline void* rmr_ring_extract( void* vr )
53 static inline int rmr_ring_insert( void* vr, void* new_data )
58 These functions support the RMR library, and are made available to user applications
59 as some (e.g. route table generators) might need and/or want to make use of them.
63 The &cw(rmr_fib) function accepts a file name and reads the entire file into a single buffer.
64 The intent is to provide an easy way to load a static route table without a lot of
68 The &cw(rmr_has_str) function accepts a &ital(buffer) containing a set of delimited tokens (e.g. foo,bar,goo)
69 and returns true if the target string, &ital(str,) matches one of the tokens.
70 The &ital(sep) parameter provides the separation character in the buffer (e.g a comma)
71 and &ital(max) indicates the maximum number of tokens to split the buffer into
75 The &cw(rmr_tokenise) function is a simple tokeniser which splits &ital(buf) into tokens
76 at each occurrence of &ital(sep).
77 Multiple occurrences of the separator character (e.g. a,,b) result in a nil token.
78 Pointers to the tokens are placed into the &ital(tokens) array provided by the caller which
79 is assumed to have at least enough space for &ital(max) entries.
82 The &cw(rmr_mk_ring) function creates a buffer ring with &ital(size) entries.
85 The &cw(rmr_ring_free) function accepts a pointer to a ring context and frees the associated memory.
88 The &cw(rmr_ring_insert) and &cw(rmr_ring_extract) functions are provided as static inline functions
89 via the &ital(rmr/ring_inline.h) header file.
90 These functions both accept the ring &ital(context) returned by &cw(mk_ring,) and either insert a
91 pointer at the next available slot (tail) or extract the data at the head.
94 The following are the return values for each of these functions.
97 The &cw(rmr_fib) function returns a pointer to the buffer containing the contents of the
99 The buffer is terminated with a single nil character (0) making it a legitimate C string.
100 If the file was empty or nonexistent, a buffer with an immediate nil character.
101 If it is important to the calling programme to know if the file was empty or did not exist,
102 the caller should use the system stat function call to make that determination.
105 The &cw(rmr_has_str) function returns 1 if &ital(buf) contains the token referenced by &ita(str,)
106 and false (0) if it does not.
107 On error, a -1 value is returned and &cw(errno) is set accordingly.
110 The &cw(rmr_tokenise) function returns the actual number of token pointers placed into &ital(tokens)
113 The &cw(rmr_mk_ring) function returns a void pointer which is the &ital(context) for the ring.
116 The &cw(rmr_ring_insert) function returns 1 if the data was successfully inserted into the ring, and
117 0 if the ring is full and the pointer could not be deposited.
120 The &cw(rmr_ring_extract) will return the data which is at the head of the ring, or NULL if the
124 Not many of these functions set the value in &cw(errno,) however the value may be one of the following:
125 &beg_dlist(.75i : ^&bold_font )
126 &di(INVAL) Parameter(s) passed to the function were not valid.