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