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