3 * useful utility routines' imports and exports, used in daemon
6 * Copyright 1996-2017 Ian Jackson <ian@davenant.greenend.org.uk>.
7 * Copyright 2000 Ben Harris <bjh21@cam.ac.uk>
8 * Copyright 2016-2017 Peter Benie <pjb1008@cam.ac.uk>
10 * This is free software; you can redistribute it and/or modify it
11 * 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, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with userv; if not, see <http://www.gnu.org/licenses/>.
27 char *xstrcat3save(const char *a, const char *b, const char *c);
28 char *xstrsubsave(const char *begin, int len);
30 void miscerror(const char *what) NONRETURNING;
31 int makeroom(char **buffer, int *size, int needed);
32 /* makeroom returns -1 if needed was far too large; otherwise returns 0. */
34 /* It doesn't appear to be documented whether [v]snprintf put a null
35 * in if they overrun. GNU libc does, but I don't want to rely on
37 * So here are some functions that always do, regardless - including
38 * versions of strcat and strcpy. The ...nyt...cat functions take the
39 * maximum length of the resulting buffer as size parameter, rather
40 * than the maximum length of the added portion.
43 * ...n... specify copied length (inc. any null), may or may not null-terminate
44 * ...ny... specify copied length (inc. null) and always null-terminate
45 * ...nyt...cat specify total buffer length and always null-terminate
48 /* Function names best pronounced with a Russian accent. */
49 void vsnyprintf(char *buffer, size_t size, const char *fmt, va_list al);
50 void snyprintf(char *buffer, size_t size, const char *fmt, ...) PRINTFFORMAT(3,4);
51 void strnycpy(char *dest, const char *src, size_t size);
53 void vsnytprintfcat(char *buffer, size_t size, const char *fmt, va_list al);
54 void snytprintfcat(char *buffer, size_t size, const char *fmt, ...) PRINTFFORMAT(3,4);
55 void strnytcat(char *dest, const char *src, size_t size);
58 int setenv(const char *name, const char *value, int overwrite);
59 #endif /* HAVE_SETENV */