replace.h revision 6a46240f
1/* 2 * Copyright (c) 2019, Oracle and/or its affiliates. 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 36#ifndef HAVE_REALLOCARRAY 37extern _X_HIDDEN void * 38reallocarray(void *optr, size_t nmemb, size_t size); 39#endif 40 41#ifndef mallocarray 42#define mallocarray(n, s) reallocarray(NULL, n, s) 43#endif 44 45#include <string.h> 46 47#ifndef HAVE_STRLCPY 48extern _X_HIDDEN size_t 49strlcpy(char *dst, const char *src, size_t siz); 50extern _X_HIDDEN size_t 51strlcat(char *dst, const char *src, size_t siz); 52#endif 53 54#ifndef HAVE_ERR_H 55#define err(eval, ...) do { \ 56 fprintf(stderr, __VA_ARGS__); \ 57 fprintf(stderr, "\n"); \ 58 exit(eval); \ 59 } while (0) 60#define vwarn(...) do { \ 61 fprintf(stderr, __VA_ARGS__); \ 62 fprintf(stderr, "\n"); \ 63 } while (0) 64#endif 65 66#ifndef HAVE_REALPATH 67extern _X_HIDDEN char * 68realpath(const char *path, char *resolved_path); 69#endif 70 71#endif /* XFONT_REPLACE_H */ 72