4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
21 * All rights reserved.
23 * The Original Code is: all of this file.
25 * Contributor(s): none yet.
27 * ***** END GPL LICENSE BLOCK *****
35 /** \file BLI_string.h
44 * Duplicates the cstring @a str into a newly mallocN'd
45 * string and returns it.
47 * @param str The string to be duplicated
48 * @retval Returns the duplicated string
50 char *BLI_strdup(const char *str);
53 * Duplicates the first @a len bytes of cstring @a str
54 * into a newly mallocN'd string and returns it. @a str
55 * is assumed to be at least len bytes long.
57 * @param str The string to be duplicated
58 * @param len The number of bytes to duplicate
59 * @retval Returns the duplicated string
61 char *BLI_strdupn(const char *str, const size_t len);
64 * Appends the two strings, and returns new mallocN'ed string
65 * @param str1 first string for copy
66 * @param str2 second string for append
69 char *BLI_strdupcat(const char *str1, const char *str2);
72 * Like strncpy but ensures dst is always
75 * @param dst Destination for copy
76 * @param src Source string to copy
77 * @param maxncpy Maximum number of characters to copy (generally
81 char *BLI_strncpy(char *dst, const char *src, const size_t maxncpy);
83 /* Makes a copy of the text within the "" that appear after some text 'blahblah'
84 * i.e. for string 'pose["apples"]' with prefix 'pose[', it should grab "apples"
86 * - str: is the entire string to chop
87 * - prefix: is the part of the string to leave out
89 * Assume that the strings returned must be freed afterwards, and that the inputs will contain
92 char *BLI_getQuotedStr(const char *str, const char *prefix);
95 * Returns a copy of the cstring @a str into a newly mallocN'd
96 * string with all instances of oldText replaced with newText,
99 * @param str The string to replace occurances of oldText in
100 * @param oldText The text in the string to find and replace
101 * @param newText The text in the string to find and replace
102 * @retval Returns the duplicated string
104 char *BLI_replacestr(char *str, const char *oldText, const char *newText);
107 * Replacement for snprintf
109 size_t BLI_snprintf(char *buffer, size_t len, const char *format, ...)
111 __attribute__ ((format (printf, 3, 4)))
116 * Print formatted string into a newly mallocN'd string
119 char *BLI_sprintfN(const char *format, ...)
121 __attribute__ ((format (printf, 1, 2)))
126 * Compare two strings
128 * @retval True if the strings are equal, false otherwise.
130 int BLI_streq(const char *a, const char *b);
133 * Compare two strings without regard to case.
135 * @retval True if the strings are equal, false otherwise.
137 int BLI_strcaseeq(const char *a, const char *b);
139 char *BLI_strcasestr(const char *s, const char *find);
140 int BLI_strcasecmp(const char *s1, const char *s2);
141 int BLI_strncasecmp(const char *s1, const char *s2, size_t len);
142 int BLI_natstrcmp(const char *s1, const char *s2);
143 size_t BLI_strnlen(const char *str, size_t maxlen);
145 void BLI_timestr(double _time, char *str); /* time var is global */
147 int BLI_utf8_invalid_byte(const char *str, int length);
148 int BLI_utf8_invalid_strip(char *str, int length);