Detect FPU by checking CPUID features.
[dragonfly.git] / contrib / bind-9.5.2 / lib / isc / include / isc / string.h
blobb49fdbc327f15ee4a07f56d620f1ceb98f1a86ea
1 /*
2 * Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 2000, 2001, 2003 Internet Software Consortium.
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
18 /* $Id: string.h,v 1.23 2007/09/13 04:48:16 each Exp $ */
20 #ifndef ISC_STRING_H
21 #define ISC_STRING_H 1
23 /*! \file isc/string.h */
25 #include <isc/formatcheck.h>
26 #include <isc/int.h>
27 #include <isc/lang.h>
28 #include <isc/platform.h>
29 #include <isc/types.h>
31 #include <string.h>
33 #ifdef ISC_PLATFORM_HAVESTRINGSH
34 #include <strings.h>
35 #endif
37 #define ISC_STRING_MAGIC 0x5e
39 ISC_LANG_BEGINDECLS
41 isc_uint64_t
42 isc_string_touint64(char *source, char **endp, int base);
43 /*%<
44 * Convert the string pointed to by 'source' to isc_uint64_t.
46 * On successful conversion 'endp' points to the first character
47 * after conversion is complete.
49 * 'base': 0 or 2..36
51 * If base is 0 the base is computed from the string type.
53 * On error 'endp' points to 'source'.
56 isc_result_t
57 isc_string_copy(char *target, size_t size, const char *source);
59 * Copy the string pointed to by 'source' to 'target' which is a
60 * pointer to a string of at least 'size' bytes.
62 * Requires:
63 * 'target' is a pointer to a char[] of at least 'size' bytes.
64 * 'size' an integer > 0.
65 * 'source' == NULL or points to a NUL terminated string.
67 * Ensures:
68 * If result == ISC_R_SUCCESS
69 * 'target' will be a NUL terminated string of no more
70 * than 'size' bytes (including NUL).
72 * If result == ISC_R_NOSPACE
73 * 'target' is undefined.
75 * Returns:
76 * ISC_R_SUCCESS -- 'source' was successfully copied to 'target'.
77 * ISC_R_NOSPACE -- 'source' could not be copied since 'target'
78 * is too small.
81 void
82 isc_string_copy_truncate(char *target, size_t size, const char *source);
84 * Copy the string pointed to by 'source' to 'target' which is a
85 * pointer to a string of at least 'size' bytes.
87 * Requires:
88 * 'target' is a pointer to a char[] of at least 'size' bytes.
89 * 'size' an integer > 0.
90 * 'source' == NULL or points to a NUL terminated string.
92 * Ensures:
93 * 'target' will be a NUL terminated string of no more
94 * than 'size' bytes (including NUL).
97 isc_result_t
98 isc_string_append(char *target, size_t size, const char *source);
100 * Append the string pointed to by 'source' to 'target' which is a
101 * pointer to a NUL terminated string of at least 'size' bytes.
103 * Requires:
104 * 'target' is a pointer to a NUL terminated char[] of at
105 * least 'size' bytes.
106 * 'size' an integer > 0.
107 * 'source' == NULL or points to a NUL terminated string.
109 * Ensures:
110 * If result == ISC_R_SUCCESS
111 * 'target' will be a NUL terminated string of no more
112 * than 'size' bytes (including NUL).
114 * If result == ISC_R_NOSPACE
115 * 'target' is undefined.
117 * Returns:
118 * ISC_R_SUCCESS -- 'source' was successfully appended to 'target'.
119 * ISC_R_NOSPACE -- 'source' could not be appended since 'target'
120 * is too small.
123 void
124 isc_string_append_truncate(char *target, size_t size, const char *source);
126 * Append the string pointed to by 'source' to 'target' which is a
127 * pointer to a NUL terminated string of at least 'size' bytes.
129 * Requires:
130 * 'target' is a pointer to a NUL terminated char[] of at
131 * least 'size' bytes.
132 * 'size' an integer > 0.
133 * 'source' == NULL or points to a NUL terminated string.
135 * Ensures:
136 * 'target' will be a NUL terminated string of no more
137 * than 'size' bytes (including NUL).
140 isc_result_t
141 isc_string_printf(char *target, size_t size, const char *format, ...)
142 ISC_FORMAT_PRINTF(3, 4);
144 * Print 'format' to 'target' which is a pointer to a string of at least
145 * 'size' bytes.
147 * Requires:
148 * 'target' is a pointer to a char[] of at least 'size' bytes.
149 * 'size' an integer > 0.
150 * 'format' == NULL or points to a NUL terminated string.
152 * Ensures:
153 * If result == ISC_R_SUCCESS
154 * 'target' will be a NUL terminated string of no more
155 * than 'size' bytes (including NUL).
157 * If result == ISC_R_NOSPACE
158 * 'target' is undefined.
160 * Returns:
161 * ISC_R_SUCCESS -- 'format' was successfully printed to 'target'.
162 * ISC_R_NOSPACE -- 'format' could not be printed to 'target' since it
163 * is too small.
166 void
167 isc_string_printf_truncate(char *target, size_t size, const char *format, ...)
168 ISC_FORMAT_PRINTF(3, 4);
170 * Print 'format' to 'target' which is a pointer to a string of at least
171 * 'size' bytes.
173 * Requires:
174 * 'target' is a pointer to a char[] of at least 'size' bytes.
175 * 'size' an integer > 0.
176 * 'format' == NULL or points to a NUL terminated string.
178 * Ensures:
179 * 'target' will be a NUL terminated string of no more
180 * than 'size' bytes (including NUL).
184 char *
185 isc_string_regiondup(isc_mem_t *mctx, const isc_region_t *source);
187 * Copy the region pointed to by r to a NUL terminated string
188 * allocated from the memory context pointed to by mctx.
190 * The result should be deallocated using isc_mem_free()
192 * Requires:
193 * 'mctx' is a point to a valid memory context.
194 * 'source' is a pointer to a valid region.
196 * Returns:
197 * a pointer to a NUL terminated string or
198 * NULL if memory for the copy could not be allocated
202 char *
203 isc_string_separate(char **stringp, const char *delim);
205 #ifdef ISC_PLATFORM_NEEDSTRSEP
206 #define strsep isc_string_separate
207 #endif
209 #ifdef ISC_PLATFORM_NEEDMEMMOVE
210 #define memmove(a,b,c) bcopy(b,a,c)
211 #endif
213 size_t
214 isc_string_strlcpy(char *dst, const char *src, size_t size);
217 #ifdef ISC_PLATFORM_NEEDSTRLCPY
218 #define strlcpy isc_string_strlcpy
219 #endif
222 size_t
223 isc_string_strlcat(char *dst, const char *src, size_t size);
225 #ifdef ISC_PLATFORM_NEEDSTRLCAT
226 #define strlcat isc_string_strlcat
227 #endif
229 ISC_LANG_ENDDECLS
231 #endif /* ISC_STRING_H */