VERSION: Disable GIT_SNAPSHOT for the 4.16.4 release.
[Samba.git] / lib / util / substitute.h
blob3134cfcdea54f55dfd89c7c3a6ef48a97e9252a5
1 /*
2 Unix SMB/CIFS implementation.
3 Samba utility functions
5 Copyright (C) Andrew Tridgell 1992-2001
6 Copyright (C) Simo Sorce 2001-2002
7 Copyright (C) Martin Pool 2003
8 Copyright (C) James Peach 2005
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #ifndef _SAMBA_SUBSTITUTE_H_
25 #define _SAMBA_SUBSTITUTE_H_
27 #include <talloc.h>
29 /**
30 Substitute a string for a pattern in another string. Make sure there is
31 enough room!
33 This routine looks for pattern in s and replaces it with
34 insert. It may do multiple replacements.
36 Any of " ; ' $ or ` in the insert string are replaced with _
37 if len==0 then the string cannot be extended. This is different from the old
38 use of len==0 which was for no length checks to be done.
39 **/
40 void string_sub(char *s,const char *pattern, const char *insert, size_t len);
42 /**
43 Similar to string_sub() but allows for any character to be substituted.
44 Use with caution!
45 if len==0 then the string cannot be extended. This is different from the old
46 use of len==0 which was for no length checks to be done.
47 **/
48 void all_string_sub(char *s,const char *pattern,const char *insert, size_t len);
50 char *talloc_string_sub2(TALLOC_CTX *mem_ctx, const char *src,
51 const char *pattern,
52 const char *insert,
53 bool remove_unsafe_characters,
54 bool replace_once,
55 bool allow_trailing_dollar);
56 char *talloc_string_sub(TALLOC_CTX *mem_ctx,
57 const char *src,
58 const char *pattern,
59 const char *insert);
60 char *talloc_all_string_sub(TALLOC_CTX *ctx,
61 const char *src,
62 const char *pattern,
63 const char *insert);
64 #endif /* _SAMBA_SUBSTITUTE_H_ */