3 * useful utility routines' imports and exports, used in daemon
5 * Copyright (C)1996-1997 Ian Jackson
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with userv; if not, write to the Free Software
19 * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 char *xmstrcat3save(const char *a, const char *b, const char *c);
26 char *xmstrsave(const char *s);
27 char *xmstrsubsave(const char *begin, int len);
29 void miscerror(const char *what) NONRETURNING;
30 void syscallerror(const char *what) NONRETURNING;
31 void *xmalloc(size_t s);
32 void *xrealloc(void *p, size_t s);
33 char *xstrdup(const char *str);
34 void makeroom(char **buffer, int *size, int needed);
36 /* It doesn't appear to be documented whether [v]snprintf put a null
37 * in if they overrun. GNU libc does, but I don't want to rely on
39 * So here are some functions that always do, regardless - including
40 * versions of strcat and strcpy. The ...nyt...cat functions take the
41 * maximum length of the resulting buffer as size parameter, rather
42 * than the maximum length of the added portion.
45 * ...n... specify copied length (inc. any null), may or may not null-terminate
46 * ...ny... specify copied length (inc. null) and always null-terminate
47 * ...nyt...cat specify total buffer length and always null-terminate
50 /* Function names best pronounced with a Russian accent. */
51 void vsnyprintf(char *buffer, size_t size, const char *fmt, va_list al);
52 void snyprintf(char *buffer, size_t size, const char *fmt, ...) PRINTFFORMAT(3,4);
53 void strnycpy(char *dest, const char *src, size_t size);
55 void vsnytprintfcat(char *buffer, size_t size, const char *fmt, va_list al);
56 void snytprintfcat(char *buffer, size_t size, const char *fmt, ...) PRINTFFORMAT(3,4);
57 void strnytcat(char *dest, const char *src, size_t size);