libstrl  0.5.1
strl.h
Go to the documentation of this file.
1 /* -*- mode: c; -*-
2  * Copyright 2011 Nathan Phillip Brink <ohnobinki@ohnopublishing.net>
3  *
4  * This file is part of libstrl.
5  *
6  * libstrl is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License as
8  * published by the Free Software Foundation, either version 3 of the
9  * License, or (at your option) any later version.
10  *
11  * libstrl is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with libstrl. If not, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef _LIBSTRL_STRL_H
22 #define _LIBSTRL_STRL_H
23 
127 /* size_t, ssize_t */
128 #include <sys/types.h>
129 
130 /*
131  * Since we provide functions only if the system doesn't have them, we
132  * here hook into the real headers so that the user need only #include
133  * <strl.h>.
134  */
135 #include <string.h>
136 #include <wchar.h>
137 
138 #ifndef _LIBSTRL_WITH_UNIFDEF
139 /*
140 #define _LIBSTRL_DECLARE_ASPRINTF
141 */
142 
143 /*
144 #define _LIBSTRL_DECLARE_GETDELIM
145 */
146 
147 /*
148 #define _LIBSTRL_DECLARE_GETLINE
149 */
150 
151 
152 #define _LIBSTRL_DECLARE_STRLCAT
153 
154 
155 
156 #define _LIBSTRL_DECLARE_STRLCPY
157 
158 
159 /*
160 #define _LIBSTRL_DECLARE_STRNLEN
161 */
162 
163 /*
164 #define _LIBSTRL_DECLARE_STRNDUP
165 */
166 
167 
168 
169 #define _LIBSTRL_DECLARE_WCSLCAT
170 
171 
172 
173 #define _LIBSTRL_DECLARE_WCSLCPY
174 
175 
176 /*
177 #define _LIBSTRL_DECLARE_WCSNLEN
178 */
179 
180 /*
181 #define _LIBSTRL_DECLARE_VASPRINTF
182 */
183 #endif /* !_LIBSTRL_WITH_UNIFDEF */
184 
185 #ifdef _LIBSTRL_DECLARE_ASPRINTF
186 
211 int asprintf(char **s, const char *format, ...);
212 #endif
213 
214 #ifdef _LIBSTRL_DECLARE_GETDELIM
215 #undef getdelim
216 
266 ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream);
267 #endif /* _LIBSTRL_DECLARE_GETDELIM */
268 
269 #ifdef _LIBSTRL_DECLARE_GETLINE
270 #undef getline
271 
292 ssize_t getline(char **lineptr, size_t *n, FILE *stream);
293 #endif /* _LIBSTRL_DECLARE_GETLINE */
294 
295 #ifdef _LIBSTRL_DECLARE_STRLCAT
296 #undef strlcat
297 
323 size_t strlcat(char *dst, const char *src, size_t len);
324 
325 #endif /* _LIBSTRL_DECLARE_STRLCAT */
326 
327 #ifdef _LIBSTRL_DECLARE_STRLCPY
328 #undef strlcpy
329 
362 size_t strlcpy(char *dst, const char *src, size_t len);
363 
364 #endif /* _LIBSTRL_DECLARE_STRLCPY */
365 
366 #ifdef _LIBSTRL_DECLARE_STRNLEN
367 #undef strnlen
368 
396 size_t strnlen(const char *s, size_t maxlen);
397 #endif /* _LIBSTRL_DECLARE_STRNLEN */
398 
399 #ifdef _LIBSTRL_DECLARE_STRNDUP
400 #undef strndup
401 
426 char *strndup(const char *s, size_t n);
427 #endif /* _LIBSTRL_DECLARE_STRNDUP */
428 
429 #ifdef _LIBSTRL_DECLARE_WCSLCAT
430 #undef wcslcat
431 
459 size_t wcslcat(wchar_t *dst, const wchar_t *src, size_t len);
460 
461 #endif /* _LIBSTRL_DECLARE_WCSLCAT */
462 
463 #ifdef _LIBSTRL_DECLARE_WCSLCPY
464 #undef wcslcpy
465 
491 size_t wcslcpy(wchar_t *dst, const wchar_t *src, size_t len);
492 
493 #endif /* _LIBSTRL_DECLARE_WCSLCPY */
494 
495 #ifdef _LIBSTRL_DECLARE_WCSNLEN
496 #undef wcsnlen
497 
521 size_t wcsnlen(const wchar_t *s, size_t maxlen);
522 #endif /* _LIBSTRL_DECLARE_WCSNLEN */
523 
524 #ifdef _LIBSTRL_DECLARE_VASPRINTF
525 
553 #include <stdarg.h>
554 int vasprintf(char **s, const char *format, va_list ap);
555 #endif
556 
557 #endif /* _LIBSTRL_STRL_H */
int vasprintf(char **s, const char *format, va_list ap)
Allocate a buffer of appropriate size and format a string into it.
size_t strlcpy(char *dst, const char *src, size_t len)
Copy a string into another buffer with extra string length checks and gauranteeing NUL termination...
ssize_t getdelim(char **lineptr, size_t *n, int delim, FILE *stream)
Read from a stream until a delimiter is reached.
int asprintf(char **s, const char *format,...)
Allocate a buffer of appropriate size and format a string into it.
size_t strnlen(const char *s, size_t maxlen)
Count up to the first n characters in a string.
size_t wcslcat(wchar_t *dst, const wchar_t *src, size_t len)
Concatenate a wide string onto a buffer, setting the null terminator and avoiding writing beyond the ...
size_t wcsnlen(const wchar_t *s, size_t maxlen)
Count up to the first n wide characters in a string.
ssize_t getline(char **lineptr, size_t *n, FILE *stream)
Read one line from a stream into a buffer.
size_t strlcat(char *dst, const char *src, size_t len)
Concatenate a string onto another string without causing the destination string to overrun its buffer...
size_t wcslcpy(wchar_t *dst, const wchar_t *src, size_t len)
Copy a wide string into a buffer without overflowing it, placing an appropriate null terminator...
char * strndup(const char *s, size_t n)
Duplicate a string, but possibly truncate it.