1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 * 4 * ------+---------+---------+---------+---------+---------+---------+---------* 5 * Copyright (c) 2003,2013 - Garance Alistair Drosehn <gad@FreeBSD.org>. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * The views and conclusions contained in the software and documentation 30 * are those of the authors and should not be interpreted as representing 31 * official policies, either expressed or implied, of the FreeBSD Project. 32 * 33 * ------+---------+---------+---------+---------+---------+---------+---------* 34 * $FreeBSD$ 35 * ------+---------+---------+---------+---------+---------+---------+---------* 36 */ 37 38 /* 39 * The main goal of this include file is to provide a platform-neutral way 40 * to define some macros that lpr wants from FreeBSD's <sys/cdefs.h>. This 41 * will simply use the standard <sys/cdefs.h> when compiled in FreeBSD, but 42 * other OS's may not have /usr/include/sys/cdefs.h (or even if that file 43 * exists, it may not define all the macros that lpr will use). 44 */ 45 46 #if !defined(_LP_CDEFS_H_) 47 #define _LP_CDEFS_H_ 48 49 /* 50 * For non-BSD platforms, you can compile lpr with -DHAVE_SYS_CDEFS_H 51 * if <sys/cdefs.h> should be included. 52 */ 53 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) 54 # define HAVE_SYS_CDEFS_H 55 #endif 56 #if defined(HAVE_SYS_CDEFS_H) 57 # include <sys/cdefs.h> 58 #endif 59 60 /* 61 * FreeBSD added a closefrom() routine in release 8.0. When compiling 62 * `lpr' on other platforms you might want to include bsd-closefrom.c 63 * from the portable-openssh project. 64 */ 65 #ifndef USE_CLOSEFROM 66 # if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) 67 # define USE_CLOSEFROM 1 68 # endif 69 #endif 70 /* The macro USE_CLOSEFROM must be defined with a value of 0 or 1. */ 71 #ifndef USE_CLOSEFROM 72 # define USE_CLOSEFROM 0 73 #endif 74 75 /* 76 * __unused is a compiler-specific trick which can be used to avoid 77 * warnings about a variable which is defined but never referenced. 78 * Some lpr files use this, so define a null version if it was not 79 * defined by <sys/cdefs.h>. 80 */ 81 #if !defined(__unused) 82 # define __unused 83 #endif 84 85 /* 86 * All the lpr source files will want to reference __FBSDID() to 87 * handle rcs id's. 88 */ 89 #if !defined(__FBSDID) 90 # if defined(lint) || defined(STRIP_FBSDID) 91 # define __FBSDID(s) struct skip_rcsid_struct 92 # elif defined(__IDSTRING) /* NetBSD */ 93 # define __FBSDID(s) __IDSTRING(rcsid,s) 94 # else 95 # define __FBSDID(s) static const char rcsid[] __unused = s 96 # endif 97 #endif /* __FBSDID */ 98 99 /* 100 * Some lpr include files use __BEGIN_DECLS and __END_DECLS. 101 */ 102 #if !defined(__BEGIN_DECLS) 103 # if defined(__cplusplus) 104 # define __BEGIN_DECLS extern "C" { 105 # define __END_DECLS } 106 # else 107 # define __BEGIN_DECLS 108 # define __END_DECLS 109 # endif 110 #endif 111 112 /* 113 * __printflike and __printf0like are a compiler-specific tricks to 114 * tell the compiler to check the format-codes in printf-like 115 * routines wrt the args that will be formatted. 116 */ 117 #if !defined(__printflike) 118 # define __printflike(fmtarg, firstvararg) 119 #endif 120 #if !defined(__printf0like) 121 # define __printf0like(fmtarg, firstvararg) 122 #endif 123 124 #endif /* !_LP_CDEFS_H_ */ 125