regify utility  2.0.0-0
cleaner.h
1 /*
2  * Copyright regify
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20  * SOFTWARE.
21  */
88 #ifndef REGIFY_UTIL_CLEANER_H
89 #define REGIFY_UTIL_CLEANER_H
90 
91 /* Only need to export C interface if used by C++ source code */
92 #ifdef __cplusplus
93 extern "C" {
94 #endif /* __cplusplus */
95 
96 /*****************************************************************************
97 * *
98 * ---------------------- Public Cleaner Interface ------------------------ *
99 * *
100 *****************************************************************************/
101 
105 typedef rusize_s (*rcWriteFn) (perm_ptr ctx, trans_ptr buf, rusize len);
106 
110 typedef rusize_s (*rcReadFn) (perm_ptr ctx, ptr buf, rusize len);
111 
124 RUAPI ruCleaner ruCleanNew(rusize chunkSize);
125 
132 
140 typedef void (*ruCleanerCb) (perm_ptr user_data, trans_chars key, trans_chars subst);
141 
150 RUAPI int32_t ruCleanDump(ruCleaner cp, ruCleanerCb lf, perm_ptr user_data);
151 
159 RUAPI int32_t ruCleanAdd(ruCleaner rc, trans_chars instr, trans_chars substitute);
160 
167 RUAPI int32_t ruCleanRemove(ruCleaner rc, trans_chars instr);
168 
182 RUAPI int32_t ruCleanIo(ruCleaner rc, rcReadFn reader, perm_ptr readCtx,
183  rcWriteFn writer, perm_ptr writeCtx);
184 
200 RUAPI int32_t ruCleanToWriter(ruCleaner rc, trans_chars in, rusize len,
201  rcWriteFn writer, perm_ptr writeCtx);
202 
203 #ifndef CLEANER_ONLY
218 RUAPI int32_t ruCleanToString(ruCleaner rc, trans_chars in, rusize len, ruString *out);
219 #endif
220 
224 #ifdef __cplusplus
225 }
226 #endif /* __cplusplus */
227 #endif //REGIFY_UTIL_CLEANER_H
RUAPI int32_t ruCleanAdd(ruCleaner rc, trans_chars instr, trans_chars substitute)
void(* ruCleanerCb)(perm_ptr user_data, trans_chars key, trans_chars subst)
Definition: cleaner.h:140
void * ruCleaner
Definition: regify-util.h:690
rusize_s(* rcReadFn)(perm_ptr ctx, ptr buf, rusize len)
Definition: cleaner.h:110
RUAPI int32_t ruCleanRemove(ruCleaner rc, trans_chars instr)
RUAPI ruCleaner ruCleanFree(ruCleaner rc)
RUAPI int32_t ruCleanToString(ruCleaner rc, trans_chars in, rusize len, ruString *out)
Does replacements in given string and returns out in given String Object.
RUAPI ruCleaner ruCleanNew(rusize chunkSize)
Creates a new ruCleaner object. To be freed with ruCleanFree.
RUAPI int32_t ruCleanIo(ruCleaner rc, rcReadFn reader, perm_ptr readCtx, rcWriteFn writer, perm_ptr writeCtx)
Does replacements using the given I/O functions.
RUAPI int32_t ruCleanToWriter(ruCleaner rc, trans_chars in, rusize len, rcWriteFn writer, perm_ptr writeCtx)
Does replacements on given string using the given Output function.
RUAPI int32_t ruCleanDump(ruCleaner cp, ruCleanerCb lf, perm_ptr user_data)
rusize_s(* rcWriteFn)(perm_ptr ctx, trans_ptr buf, rusize len)
Definition: cleaner.h:105
const void * trans_ptr
A transient pointer.
Definition: regify-util.h:287
const void * perm_ptr
A permanent pointer.
Definition: regify-util.h:277
const char * trans_chars
A transient NULL terminated string pointer.
Definition: regify-util.h:186
size_t rusize
Abstracted version of size_t.
Definition: regify-util.h:338
void * ptr
A generic pointer.
Definition: regify-util.h:304
signed long rusize_s
Abstracted version of size_t but signed.
Definition: regify-util.h:152
void * ruString
An opaque data type representing a regify-util string object.
Definition: string.h:45