Debian Codegraph @

src/util/replace.h

raw
1 /*
2 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 */
23
24 /* Local replacements for functions found in some, but not all, libc's */
25 #ifndef XFONT_REPLACE_H
26 #define XFONT_REPLACE_H
27
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31
32 #include <X11/Xfuncproto.h>
33
34 #include <stdlib.h>
35 #if defined(HAVE_LIBBSD) && defined(HAVE_REALLOCARRAY)
36 #include <bsd/stdlib.h> /* for reallocarray */
37 #endif
38
39 #ifndef HAVE_REALLOCARRAY
40 extern _X_HIDDEN void *
41 reallocarray(void *optr, size_t nmemb, size_t size);
42 #endif
43
44 #ifndef mallocarray
45 #define mallocarray(n, s) reallocarray(NULL, n, s)
46 #endif
47
48 #include <string.h>
49 #if defined(HAVE_LIBBSD) && defined(HAVE_STRLCPY)
50 #include <bsd/string.h> /* for strlcpy, strlcat */
51 #endif
52
53 #ifndef HAVE_STRLCPY
54 extern _X_HIDDEN size_t
55 strlcpy(char *dst, const char *src, size_t siz);
56 extern _X_HIDDEN size_t
57 strlcat(char *dst, const char *src, size_t siz);
58 #endif
59
60 #ifndef HAVE_ERR_H
61 #define err(eval, ...) do { \
62 fprintf(stderr, __VA_ARGS__); \
63 fprintf(stderr, "\n"); \
64 exit(eval); \
65 } while (0)
66 #define vwarn(...) do { \
67 fprintf(stderr, __VA_ARGS__); \
68 fprintf(stderr, "\n"); \
69 } while (0)
70 #endif
71
72 #ifndef HAVE_REALPATH
73 extern _X_HIDDEN char *
74 realpath(const char *path, char *resolved_path);
75 #endif
76
77 #endif /* XFONT_REPLACE_H */