1 /* 2 * Copyright (c) 2010, 2011 Ryan Flannery <ryan.flannery@gmail.com> 3 * 4 * Permission to use, copy, modify, and distribute this software for any 5 * purpose with or without fee is hereby granted, provided that the above 6 * copyright notice and this permission notice appear in all copies. 7 * 8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 */ 16 17 /* 18 * Compatibility goo for other OS's. These files are intended to add 19 * support for various FEATURES that other OS's do not support. Kinda' 20 * like what autoconf is supposed to do, but doesn't. 21 * 22 * These files consist of the following: 23 * 24 * compat.h This file, which contains the main feature-goo, along 25 * with any OS specific goo. See below for details. 26 * 27 * compat.c The counterpart to this file, which includes all the 28 * necessary #includes of compat/ stuff to add various 29 * features. 30 * 31 * compat/ The directory containing all OpenBSD-specific 32 * features of vitunes that may be needed on other OS's. 33 * 34 */ 35 36 #ifndef COMPAT_H 37 #define COMPAT_H 38 39 /* OpenBSD has fparseln(3), but it must be included thusly */ 40 #if defined(__OpenBSD__) 41 # include <stdio.h> 42 # include <util.h> 43 #endif 44 45 /* FreeBSD has fparseln(3), but it must be included thusly */ 46 #if defined(__FreeBSD__) 47 # include <stdio.h> 48 # include <sys/types.h> 49 # include <libutil.h> 50 #endif 51 52 /* Mac OS X needs strtonum(3) */ 53 #if defined(__APPLE__) && defined(__MACH__) 54 # define COMPAT_NEED_STRTONUM 55 #endif 56 57 /* Linux needs the following.. */ 58 #if defined(__linux) 59 # define COMPAT_NEED_FPARSELN 60 # define COMPAT_NEED_OPTRESET 61 # define COMPAT_NEED_STRLCAT 62 # define COMPAT_NEED_STRTONUM 63 64 /* still unsure/curious about these last two */ 65 # ifndef u_short 66 typedef unsigned short u_short; 67 # endif 68 # ifndef PATH_MAX 69 # include <linux/limits.h> 70 # else 71 # define PATH_MAX 4096 72 # endif 73 #endif 74 75 76 /* Now add necessary prototypes... */ 77 78 #ifdef COMPAT_NEED_FPARSELN 79 # include <stdio.h> 80 char *fparseln(FILE *fp, size_t *size, size_t *lineno, 81 const char str[3], int flags); 82 #endif 83 84 #ifdef COMPAT_NEED_OPTRESET 85 extern int optreset; 86 #endif 87 88 #ifdef COMPAT_NEED_STRLCAT 89 size_t strlcat(char *dst, const char *src, size_t siz); 90 size_t strlcpy(char *dst, const char *src, size_t siz); 91 #endif 92 93 #ifdef COMPAT_NEED_STRTONUM 94 long long strtonum(const char *, long long, long long, const char **); 95 #endif 96 97 #endif 98