replace.h revision 6a46240f
1c7b4381aSmrg/* 26a46240fSmrg * Copyright (c) 2019, Oracle and/or its affiliates. 3c7b4381aSmrg * 4c7b4381aSmrg * Permission is hereby granted, free of charge, to any person obtaining a 5c7b4381aSmrg * copy of this software and associated documentation files (the "Software"), 6c7b4381aSmrg * to deal in the Software without restriction, including without limitation 7c7b4381aSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8c7b4381aSmrg * and/or sell copies of the Software, and to permit persons to whom the 9c7b4381aSmrg * Software is furnished to do so, subject to the following conditions: 10c7b4381aSmrg * 11c7b4381aSmrg * The above copyright notice and this permission notice (including the next 12c7b4381aSmrg * paragraph) shall be included in all copies or substantial portions of the 13c7b4381aSmrg * Software. 14c7b4381aSmrg * 15c7b4381aSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16c7b4381aSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17c7b4381aSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18c7b4381aSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19c7b4381aSmrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20c7b4381aSmrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21c7b4381aSmrg * DEALINGS IN THE SOFTWARE. 22c7b4381aSmrg */ 23c7b4381aSmrg 24c7b4381aSmrg/* Local replacements for functions found in some, but not all, libc's */ 25c7b4381aSmrg#ifndef XFONT_REPLACE_H 26c7b4381aSmrg#define XFONT_REPLACE_H 27c7b4381aSmrg 28c7b4381aSmrg#ifdef HAVE_CONFIG_H 29c7b4381aSmrg#include <config.h> 30c7b4381aSmrg#endif 31c7b4381aSmrg 32c7b4381aSmrg#include <X11/Xfuncproto.h> 33c7b4381aSmrg 34c7b4381aSmrg#include <stdlib.h> 35c7b4381aSmrg 36c7b4381aSmrg#ifndef HAVE_REALLOCARRAY 37c7b4381aSmrgextern _X_HIDDEN void * 38c7b4381aSmrgreallocarray(void *optr, size_t nmemb, size_t size); 39c7b4381aSmrg#endif 40c7b4381aSmrg 41c7b4381aSmrg#ifndef mallocarray 42c7b4381aSmrg#define mallocarray(n, s) reallocarray(NULL, n, s) 43c7b4381aSmrg#endif 44c7b4381aSmrg 45c7b4381aSmrg#include <string.h> 46c7b4381aSmrg 47c7b4381aSmrg#ifndef HAVE_STRLCPY 48c7b4381aSmrgextern _X_HIDDEN size_t 49c7b4381aSmrgstrlcpy(char *dst, const char *src, size_t siz); 50c7b4381aSmrgextern _X_HIDDEN size_t 51c7b4381aSmrgstrlcat(char *dst, const char *src, size_t siz); 52c7b4381aSmrg#endif 53c7b4381aSmrg 5460da515cSmrg#ifndef HAVE_ERR_H 5560da515cSmrg#define err(eval, ...) do { \ 5660da515cSmrg fprintf(stderr, __VA_ARGS__); \ 5760da515cSmrg fprintf(stderr, "\n"); \ 5860da515cSmrg exit(eval); \ 5960da515cSmrg } while (0) 6060da515cSmrg#define vwarn(...) do { \ 6160da515cSmrg fprintf(stderr, __VA_ARGS__); \ 6260da515cSmrg fprintf(stderr, "\n"); \ 6360da515cSmrg } while (0) 6460da515cSmrg#endif 6560da515cSmrg 6660da515cSmrg#ifndef HAVE_REALPATH 6760da515cSmrgextern _X_HIDDEN char * 6860da515cSmrgrealpath(const char *path, char *resolved_path); 6960da515cSmrg#endif 70c7b4381aSmrg 71c7b4381aSmrg#endif /* XFONT_REPLACE_H */ 72