3 * useful utility routines' imports and exports, used in daemon
5 * userv is copyright Ian Jackson and other contributors.
6 * See README for full authorship information.
8 * This is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with userv; if not, see <http://www.gnu.org/licenses/>.
25 char *xstrcat3save(const char *a, const char *b, const char *c);
26 char *xstrsubsave(const char *begin, int len);
28 void miscerror(const char *what) NONRETURNING;
29 int makeroom(char **buffer, int *size, int needed);
30 /* makeroom returns -1 if needed was far too large; otherwise returns 0. */
32 /* It doesn't appear to be documented whether [v]snprintf put a null
33 * in if they overrun. GNU libc does, but I don't want to rely on
35 * So here are some functions that always do, regardless - including
36 * versions of strcat and strcpy. The ...nyt...cat functions take the
37 * maximum length of the resulting buffer as size parameter, rather
38 * than the maximum length of the added portion.
41 * ...n... specify copied length (inc. any null), may or may not null-terminate
42 * ...ny... specify copied length (inc. null) and always null-terminate
43 * ...nyt...cat specify total buffer length and always null-terminate
46 /* Function names best pronounced with a Russian accent. */
47 void vsnyprintf(char *buffer, size_t size, const char *fmt, va_list al);
48 void snyprintf(char *buffer, size_t size, const char *fmt, ...) PRINTFFORMAT(3,4);
49 void strnycpy(char *dest, const char *src, size_t size);
51 void vsnytprintfcat(char *buffer, size_t size, const char *fmt, va_list al);
52 void snytprintfcat(char *buffer, size_t size, const char *fmt, ...) PRINTFFORMAT(3,4);
53 void strnytcat(char *dest, const char *src, size_t size);
56 int setenv(const char *name, const char *value, int overwrite);
57 #endif /* HAVE_SETENV */