xref: /illumos-gate/usr/src/lib/libxcurses/h/mks.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
28*7c478bd9Sstevel@tonic-gate 
29*7c478bd9Sstevel@tonic-gate /*
30*7c478bd9Sstevel@tonic-gate  * MKS header file.  Defines that make programming easier for us.
31*7c478bd9Sstevel@tonic-gate  * Includes MKS-specific things and posix routines.
32*7c478bd9Sstevel@tonic-gate  *
33*7c478bd9Sstevel@tonic-gate  * Copyright 1985, 1993 by Mortice Kern Systems Inc.  All rights reserved.
34*7c478bd9Sstevel@tonic-gate  *
35*7c478bd9Sstevel@tonic-gate  * $Header: /rd/h/rcs/mks.h 1.233 1995/09/28 19:45:19 mark Exp $
36*7c478bd9Sstevel@tonic-gate  */
37*7c478bd9Sstevel@tonic-gate 
38*7c478bd9Sstevel@tonic-gate #ifndef	__M_MKS_H__
39*7c478bd9Sstevel@tonic-gate #define	__M_MKS_H__
40*7c478bd9Sstevel@tonic-gate 
41*7c478bd9Sstevel@tonic-gate /*
42*7c478bd9Sstevel@tonic-gate  * This should be a feature test macro defined in the Makefile or
43*7c478bd9Sstevel@tonic-gate  * cc command line.
44*7c478bd9Sstevel@tonic-gate  */
45*7c478bd9Sstevel@tonic-gate #ifndef	MKS
46*7c478bd9Sstevel@tonic-gate #define	MKS	1
47*7c478bd9Sstevel@tonic-gate #endif
48*7c478bd9Sstevel@tonic-gate 
49*7c478bd9Sstevel@tonic-gate /*
50*7c478bd9Sstevel@tonic-gate  * Write function declarations as follows:
51*7c478bd9Sstevel@tonic-gate  *	extern char	*function ANSI((char *cp, int flags, NODE *np));
52*7c478bd9Sstevel@tonic-gate  * Expansion of this happens only when __STDC__ is set.
53*7c478bd9Sstevel@tonic-gate  */
54*7c478bd9Sstevel@tonic-gate #ifdef	__STDC__
55*7c478bd9Sstevel@tonic-gate #define	ANSI(x)	x
56*7c478bd9Sstevel@tonic-gate #define	_VOID	void		/* Used in VOID *malloc() */
57*7c478bd9Sstevel@tonic-gate #else
58*7c478bd9Sstevel@tonic-gate #define	const
59*7c478bd9Sstevel@tonic-gate #define	signed
60*7c478bd9Sstevel@tonic-gate #define	volatile
61*7c478bd9Sstevel@tonic-gate #define	ANSI(x)	()
62*7c478bd9Sstevel@tonic-gate #define	_VOID	char		/* Used in _VOID *malloc() */
63*7c478bd9Sstevel@tonic-gate #endif
64*7c478bd9Sstevel@tonic-gate 
65*7c478bd9Sstevel@tonic-gate #ifndef	STATIC
66*7c478bd9Sstevel@tonic-gate #  define	STATIC	static		/* Used for function definition */
67*7c478bd9Sstevel@tonic-gate #endif	/*STATIC*/
68*7c478bd9Sstevel@tonic-gate 
69*7c478bd9Sstevel@tonic-gate #ifndef	STATREF
70*7c478bd9Sstevel@tonic-gate #  ifdef	__STDC__
71*7c478bd9Sstevel@tonic-gate #    define	STATREF	static
72*7c478bd9Sstevel@tonic-gate #  else
73*7c478bd9Sstevel@tonic-gate #    define	STATREF		/* Used in local function forward declaration */
74*7c478bd9Sstevel@tonic-gate #  endif
75*7c478bd9Sstevel@tonic-gate #endif	/*STATREF*/
76*7c478bd9Sstevel@tonic-gate 
77*7c478bd9Sstevel@tonic-gate #define	LEXTERN	extern		/* Library external reference */
78*7c478bd9Sstevel@tonic-gate #define	LDEFN			/* Define Loadable library entry */
79*7c478bd9Sstevel@tonic-gate 
80*7c478bd9Sstevel@tonic-gate typedef	void	(*_sigfun_t)(int);
81*7c478bd9Sstevel@tonic-gate 
82*7c478bd9Sstevel@tonic-gate #include <mkslocal.h>
83*7c478bd9Sstevel@tonic-gate #include <stdio.h>
84*7c478bd9Sstevel@tonic-gate #include <unistd.h>
85*7c478bd9Sstevel@tonic-gate #include <limits.h>
86*7c478bd9Sstevel@tonic-gate #include <sys/stat.h>	/* required for m_samefile() prototype. */
87*7c478bd9Sstevel@tonic-gate #include <m_wchar.h>
88*7c478bd9Sstevel@tonic-gate #include <m_i18n.h>
89*7c478bd9Sstevel@tonic-gate #include <m_invari.h>
90*7c478bd9Sstevel@tonic-gate 
91*7c478bd9Sstevel@tonic-gate #if M_TFGETC || M_STTY_CC
92*7c478bd9Sstevel@tonic-gate #include <termios.h>
93*7c478bd9Sstevel@tonic-gate #endif
94*7c478bd9Sstevel@tonic-gate 
95*7c478bd9Sstevel@tonic-gate #ifndef	M_LIBDIR
96*7c478bd9Sstevel@tonic-gate  # error "You must define M_LIBDIR in mkslocal.h"
97*7c478bd9Sstevel@tonic-gate #endif
98*7c478bd9Sstevel@tonic-gate 
99*7c478bd9Sstevel@tonic-gate #ifndef M_ETCDIR
100*7c478bd9Sstevel@tonic-gate  # error "You must define M_ETCDIR in mkslocal.h"
101*7c478bd9Sstevel@tonic-gate #endif
102*7c478bd9Sstevel@tonic-gate 
103*7c478bd9Sstevel@tonic-gate #ifndef M_SPOOLDIR
104*7c478bd9Sstevel@tonic-gate  # error "You must define M_SPOOLDIR in mkslocal.h"
105*7c478bd9Sstevel@tonic-gate #endif
106*7c478bd9Sstevel@tonic-gate 
107*7c478bd9Sstevel@tonic-gate #ifndef	M_MANPATH
108*7c478bd9Sstevel@tonic-gate  # error "You must define M_MANPATH in mkslocal.h"
109*7c478bd9Sstevel@tonic-gate #endif
110*7c478bd9Sstevel@tonic-gate 
111*7c478bd9Sstevel@tonic-gate #if defined(I18N) && !defined(M_NLSDIR)
112*7c478bd9Sstevel@tonic-gate  # error "You must define M_NLSDIR in mkslocal.h"
113*7c478bd9Sstevel@tonic-gate #endif
114*7c478bd9Sstevel@tonic-gate 
115*7c478bd9Sstevel@tonic-gate #if (defined(M_I18N_MKS_FULL) || defined(M_I18N_MKS_XPG)) && !defined(I18N)
116*7c478bd9Sstevel@tonic-gate  # error I18N must be defined
117*7c478bd9Sstevel@tonic-gate #endif
118*7c478bd9Sstevel@tonic-gate 
119*7c478bd9Sstevel@tonic-gate /* P_tmpdir - used by tmpnam.c and tempnam.c.
120*7c478bd9Sstevel@tonic-gate  * Could be in <stdio.h>. But in case it is not ..
121*7c478bd9Sstevel@tonic-gate  */
122*7c478bd9Sstevel@tonic-gate #ifndef P_tmpdir
123*7c478bd9Sstevel@tonic-gate #  ifndef M_TMPDIR
124*7c478bd9Sstevel@tonic-gate      # error  M_TMPDIR must be defined in mkslocal.h
125*7c478bd9Sstevel@tonic-gate #  endif
126*7c478bd9Sstevel@tonic-gate #  define P_tmpdir        M_TMPDIR
127*7c478bd9Sstevel@tonic-gate #endif /* P_tmpdir */
128*7c478bd9Sstevel@tonic-gate 
129*7c478bd9Sstevel@tonic-gate /* L_cuserid - used by cuserid.c
130*7c478bd9Sstevel@tonic-gate  * Could be in <stdio.h>. But in case it is not ..
131*7c478bd9Sstevel@tonic-gate  */
132*7c478bd9Sstevel@tonic-gate #ifndef L_cuserid
133*7c478bd9Sstevel@tonic-gate #  ifndef M_L_CUSERID
134*7c478bd9Sstevel@tonic-gate      # error  M_L_CUSERID must be defined in mkslocal.h
135*7c478bd9Sstevel@tonic-gate #  endif
136*7c478bd9Sstevel@tonic-gate #  define L_cuserid        M_L_CUSERID
137*7c478bd9Sstevel@tonic-gate #endif /* L_cuserid */
138*7c478bd9Sstevel@tonic-gate 
139*7c478bd9Sstevel@tonic-gate #ifdef	M_AUDIT
140*7c478bd9Sstevel@tonic-gate LEXTERN	char	*m_audmode (int, int);
141*7c478bd9Sstevel@tonic-gate #if !defined(M_AUDITW1) || !defined(M_AUDITW2)
142*7c478bd9Sstevel@tonic-gate  # error "With M_AUDIT set, you must define M_AUDITW1 and M_AUDITW2"
143*7c478bd9Sstevel@tonic-gate #endif
144*7c478bd9Sstevel@tonic-gate #endif  /*M_AUDIT*/
145*7c478bd9Sstevel@tonic-gate 
146*7c478bd9Sstevel@tonic-gate #ifndef M_CS_PATH
147*7c478bd9Sstevel@tonic-gate  # error "You must define M_CS_PATH in mkslocal.h"
148*7c478bd9Sstevel@tonic-gate #endif
149*7c478bd9Sstevel@tonic-gate 
150*7c478bd9Sstevel@tonic-gate #ifndef M_CS_SHELL
151*7c478bd9Sstevel@tonic-gate  # error "You must define M_CS_SHELL in mkslocal.h"
152*7c478bd9Sstevel@tonic-gate #endif
153*7c478bd9Sstevel@tonic-gate 
154*7c478bd9Sstevel@tonic-gate #ifndef M_SH_USER_FDS
155*7c478bd9Sstevel@tonic-gate /*
156*7c478bd9Sstevel@tonic-gate  * default number of user file descriptors to be used in the shell
157*7c478bd9Sstevel@tonic-gate  * Must be >= 10, should be <= OPEN_MAX/2.
158*7c478bd9Sstevel@tonic-gate  */
159*7c478bd9Sstevel@tonic-gate #define M_SH_USER_FDS   10
160*7c478bd9Sstevel@tonic-gate #endif /*M_SH_USER_FDS*/
161*7c478bd9Sstevel@tonic-gate 
162*7c478bd9Sstevel@tonic-gate #ifndef M_SH_MAX_FUNCTION_EVAL_DEPTH
163*7c478bd9Sstevel@tonic-gate #define M_SH_MAX_FUNCTION_EVAL_DEPTH	100
164*7c478bd9Sstevel@tonic-gate #endif
165*7c478bd9Sstevel@tonic-gate 
166*7c478bd9Sstevel@tonic-gate #ifndef M_MANPAGER
167*7c478bd9Sstevel@tonic-gate #define M_MANPAGER	"more -A -s"
168*7c478bd9Sstevel@tonic-gate #endif
169*7c478bd9Sstevel@tonic-gate 
170*7c478bd9Sstevel@tonic-gate /* set up alert and verticalTab characters - This assumes an ANSI-C compiler */
171*7c478bd9Sstevel@tonic-gate #undef	M_ALERT
172*7c478bd9Sstevel@tonic-gate #undef	M_VTAB
173*7c478bd9Sstevel@tonic-gate #define	M_ALERT	'\a'
174*7c478bd9Sstevel@tonic-gate #define	M_VTAB	'\v'
175*7c478bd9Sstevel@tonic-gate 
176*7c478bd9Sstevel@tonic-gate #ifndef M_ESCAPE
177*7c478bd9Sstevel@tonic-gate #  define	M_ESCAPE '\033'		/* default to ASCII code for <ESC> */
178*7c478bd9Sstevel@tonic-gate #endif /*M_ESCAPE*/
179*7c478bd9Sstevel@tonic-gate 
180*7c478bd9Sstevel@tonic-gate #ifndef	SETVBUF
181*7c478bd9Sstevel@tonic-gate /* if SETVBUF not previously defined, then use default ANSI-C definition */
182*7c478bd9Sstevel@tonic-gate #  define	SETVBUF	setvbuf
183*7c478bd9Sstevel@tonic-gate #endif
184*7c478bd9Sstevel@tonic-gate 
185*7c478bd9Sstevel@tonic-gate #ifdef M_NULL
186*7c478bd9Sstevel@tonic-gate /* if M_NULL defined in <mkslocal.h> then want to redefine NULL */
187*7c478bd9Sstevel@tonic-gate #undef        NULL
188*7c478bd9Sstevel@tonic-gate #define       NULL    (M_NULL)
189*7c478bd9Sstevel@tonic-gate #endif /*M_NULL*/
190*7c478bd9Sstevel@tonic-gate 
191*7c478bd9Sstevel@tonic-gate /*
192*7c478bd9Sstevel@tonic-gate  * Useful additions to sys/stat.h.
193*7c478bd9Sstevel@tonic-gate  */
194*7c478bd9Sstevel@tonic-gate #ifndef S_IRALL
195*7c478bd9Sstevel@tonic-gate #define	S_IRALL		(S_IRUSR|S_IRGRP|S_IROTH)
196*7c478bd9Sstevel@tonic-gate #endif
197*7c478bd9Sstevel@tonic-gate #ifndef S_IWALL
198*7c478bd9Sstevel@tonic-gate #define	S_IWALL		(S_IWUSR|S_IWGRP|S_IWOTH)
199*7c478bd9Sstevel@tonic-gate #endif
200*7c478bd9Sstevel@tonic-gate #ifndef S_IXALL
201*7c478bd9Sstevel@tonic-gate #define	S_IXALL		(S_IXUSR|S_IXGRP|S_IXOTH)
202*7c478bd9Sstevel@tonic-gate #endif
203*7c478bd9Sstevel@tonic-gate 
204*7c478bd9Sstevel@tonic-gate #ifndef M_DEFMODE	/* Default directory creation mode */
205*7c478bd9Sstevel@tonic-gate #define	M_DEFMODE	((mode_t)S_IRALL|S_IWALL)/* Default file creation mode*/
206*7c478bd9Sstevel@tonic-gate #endif
207*7c478bd9Sstevel@tonic-gate #ifndef M_DIRMODE
208*7c478bd9Sstevel@tonic-gate #define	M_DIRMODE	((mode_t)S_IRALL|S_IWALL|S_IXALL)
209*7c478bd9Sstevel@tonic-gate #endif
210*7c478bd9Sstevel@tonic-gate 
211*7c478bd9Sstevel@tonic-gate #ifndef	M_FLDSEP
212*7c478bd9Sstevel@tonic-gate #define	M_FLDSEP	':'	/* UNIX field separator for passwd, PATH */
213*7c478bd9Sstevel@tonic-gate #endif
214*7c478bd9Sstevel@tonic-gate 
215*7c478bd9Sstevel@tonic-gate #ifndef M_TTYNAME
216*7c478bd9Sstevel@tonic-gate #define M_TTYNAME "/dev/tty"
217*7c478bd9Sstevel@tonic-gate #endif
218*7c478bd9Sstevel@tonic-gate 
219*7c478bd9Sstevel@tonic-gate #ifndef	M_NULLNAME
220*7c478bd9Sstevel@tonic-gate #define	M_NULLNAME "/dev/null"
221*7c478bd9Sstevel@tonic-gate #endif
222*7c478bd9Sstevel@tonic-gate 
223*7c478bd9Sstevel@tonic-gate #ifndef	M_FSDELIM
224*7c478bd9Sstevel@tonic-gate #define	M_FSDELIM(c)	((c)=='/')
225*7c478bd9Sstevel@tonic-gate #endif
226*7c478bd9Sstevel@tonic-gate 
227*7c478bd9Sstevel@tonic-gate #ifndef	M_DRDELIM
228*7c478bd9Sstevel@tonic-gate #define	M_DRDELIM(c)	(0)
229*7c478bd9Sstevel@tonic-gate #endif
230*7c478bd9Sstevel@tonic-gate 
231*7c478bd9Sstevel@tonic-gate #ifndef	M_DIRSTAT
232*7c478bd9Sstevel@tonic-gate #define	M_DIRSTAT(name, dp, sb)	stat((name), (sb))
233*7c478bd9Sstevel@tonic-gate #endif
234*7c478bd9Sstevel@tonic-gate 
235*7c478bd9Sstevel@tonic-gate #ifndef	M_HIDDEN
236*7c478bd9Sstevel@tonic-gate #define	M_HIDDEN(dirp, dp)	((dp)->d_name[0] == '.')
237*7c478bd9Sstevel@tonic-gate #endif
238*7c478bd9Sstevel@tonic-gate 
239*7c478bd9Sstevel@tonic-gate #ifndef M_FSMOUNT		/* for use by setmnt routine */
240*7c478bd9Sstevel@tonic-gate #define M_FSMOUNT M_ETCDIR(mtab)
241*7c478bd9Sstevel@tonic-gate #endif
242*7c478bd9Sstevel@tonic-gate 
243*7c478bd9Sstevel@tonic-gate #ifndef M_FSALL			/* for use by setmnt routine */
244*7c478bd9Sstevel@tonic-gate #define M_FSALL M_ETCDIR(fstab)
245*7c478bd9Sstevel@tonic-gate #endif
246*7c478bd9Sstevel@tonic-gate 
247*7c478bd9Sstevel@tonic-gate #ifndef	M_NLSCHARMAP		/* Default charmap file for localedef */
248*7c478bd9Sstevel@tonic-gate #define	M_NLSCHARMAP	M_NLSDIR(charmap/ISO_8859-1)
249*7c478bd9Sstevel@tonic-gate #endif
250*7c478bd9Sstevel@tonic-gate 
251*7c478bd9Sstevel@tonic-gate #ifndef M_POSIXPATH	/* used when I18N undefined, default posix path */
252*7c478bd9Sstevel@tonic-gate #define	M_POSIXPATH	M_NLSDIR(locale/POSIX)
253*7c478bd9Sstevel@tonic-gate #endif
254*7c478bd9Sstevel@tonic-gate 
255*7c478bd9Sstevel@tonic-gate #ifndef	M_ISEOV
256*7c478bd9Sstevel@tonic-gate #define	M_ISEOV(error)	0
257*7c478bd9Sstevel@tonic-gate #endif
258*7c478bd9Sstevel@tonic-gate 
259*7c478bd9Sstevel@tonic-gate #ifndef	M_IS_NATIVE_LOCALE
260*7c478bd9Sstevel@tonic-gate #define	M_IS_NATIVE_LOCALE(s)	(strcmp(s, "POSIX")==0 || strcmp(s, "C")==0)
261*7c478bd9Sstevel@tonic-gate #endif
262*7c478bd9Sstevel@tonic-gate 
263*7c478bd9Sstevel@tonic-gate #ifndef	M_FSCLOSE
264*7c478bd9Sstevel@tonic-gate #define	M_FSCLOSE(fp)
265*7c478bd9Sstevel@tonic-gate #endif
266*7c478bd9Sstevel@tonic-gate 
267*7c478bd9Sstevel@tonic-gate #ifndef ROOTUID		/* default superuser uid = 0 */
268*7c478bd9Sstevel@tonic-gate #define	ROOTUID	0
269*7c478bd9Sstevel@tonic-gate #endif
270*7c478bd9Sstevel@tonic-gate 
271*7c478bd9Sstevel@tonic-gate #ifndef ROOTGID		/* default superuser gid = 0 */
272*7c478bd9Sstevel@tonic-gate #define	ROOTGID	0
273*7c478bd9Sstevel@tonic-gate #endif
274*7c478bd9Sstevel@tonic-gate 
275*7c478bd9Sstevel@tonic-gate #ifndef M_GROUP_PASSWD
276*7c478bd9Sstevel@tonic-gate #define M_GROUP_PASSWD(grp)  (grp->gr_passwd)
277*7c478bd9Sstevel@tonic-gate #endif
278*7c478bd9Sstevel@tonic-gate 
279*7c478bd9Sstevel@tonic-gate 
280*7c478bd9Sstevel@tonic-gate #ifndef M_NUMSIZE
281*7c478bd9Sstevel@tonic-gate /*
282*7c478bd9Sstevel@tonic-gate  * define the expected max length of a printed number. (used in awk)
283*7c478bd9Sstevel@tonic-gate  * This should be the longest expected size for any type of number
284*7c478bd9Sstevel@tonic-gate  * ie. float, long etc.
285*7c478bd9Sstevel@tonic-gate  * This number is used to calculate the approximate
286*7c478bd9Sstevel@tonic-gate  * number of bytes needed to hold the number.
287*7c478bd9Sstevel@tonic-gate  */
288*7c478bd9Sstevel@tonic-gate #define	M_NUMSIZE	30
289*7c478bd9Sstevel@tonic-gate #endif /* M_NUMSIZE */
290*7c478bd9Sstevel@tonic-gate 
291*7c478bd9Sstevel@tonic-gate /*
292*7c478bd9Sstevel@tonic-gate  * VARARG[12345]: declare variadic functions.
293*7c478bd9Sstevel@tonic-gate  * Expands to either a standard C prototype or a K&R declaration.
294*7c478bd9Sstevel@tonic-gate  * For example:
295*7c478bd9Sstevel@tonic-gate  *
296*7c478bd9Sstevel@tonic-gate  * #include <stdarg.h>
297*7c478bd9Sstevel@tonic-gate  * int
298*7c478bd9Sstevel@tonic-gate  * fprintf VARARG2(FILE*, fp, char*, fmt)
299*7c478bd9Sstevel@tonic-gate  * {
300*7c478bd9Sstevel@tonic-gate  *	va_list	ap;
301*7c478bd9Sstevel@tonic-gate  *
302*7c478bd9Sstevel@tonic-gate  *	va_start(ap, fmt);
303*7c478bd9Sstevel@tonic-gate  *	cp = va_arg(ap, char*);
304*7c478bd9Sstevel@tonic-gate  *	va_end(ap);
305*7c478bd9Sstevel@tonic-gate  * }
306*7c478bd9Sstevel@tonic-gate  */
307*7c478bd9Sstevel@tonic-gate #ifndef VARARG1
308*7c478bd9Sstevel@tonic-gate #ifdef	__STDC__
309*7c478bd9Sstevel@tonic-gate #define VARARG1(type, name) (type name, ...)
310*7c478bd9Sstevel@tonic-gate #define	VARARG2(t1, n1, t2, n2) (t1 n1, t2 n2, ...)
311*7c478bd9Sstevel@tonic-gate #define	VARARG3(t1, n1, t2, n2, t3, n3) (t1 n1, t2 n2, t3 n3, ...)
312*7c478bd9Sstevel@tonic-gate #define	VARARG4(t1, n1, t2, n2, t3, n3, t4, n4) \
313*7c478bd9Sstevel@tonic-gate 		(t1 n1, t2 n2, t3 n3, t4 n4, ...)
314*7c478bd9Sstevel@tonic-gate #define	VARARG5(t1, n1, t2, n2, t3, n3, t4, n4, t5, n5) \
315*7c478bd9Sstevel@tonic-gate 		(t1 n1, t2 n2, t3 n3, t4 n4, t5 n5, ...)
316*7c478bd9Sstevel@tonic-gate #else
317*7c478bd9Sstevel@tonic-gate #define	VARARG1(type, name) (name, va_alist) type name; int va_alist
318*7c478bd9Sstevel@tonic-gate #define VARARG2(t1, n1, t2, n2) (n1, n2, va_alist) t1 n1; t2 n2; int va_alist
319*7c478bd9Sstevel@tonic-gate #define VARARG3(t1, n1, t2, n2, t3, n3) (n1, n2, n3, va_alist) \
320*7c478bd9Sstevel@tonic-gate 		t1 n1; t2 n2; t3 n3; int va_alist
321*7c478bd9Sstevel@tonic-gate #define VARARG4(t1, n1, t2, n2, t3, n3, t4, n4) (n1, n2, n3, n4, va_alist) \
322*7c478bd9Sstevel@tonic-gate 		t1 n1; t2 n2; t3 n3; t4 n4; int va_alist
323*7c478bd9Sstevel@tonic-gate #define VARARG5(t1, n1, t2, n2, t3, n3, t4, n4, t5, n5) \
324*7c478bd9Sstevel@tonic-gate 		(n1, n2, n3, n4, n5, va_alist) \
325*7c478bd9Sstevel@tonic-gate 		t1 n1; t2 n2; t3 n3; t4 n4; t5 n5; int va_alist
326*7c478bd9Sstevel@tonic-gate #endif
327*7c478bd9Sstevel@tonic-gate #endif
328*7c478bd9Sstevel@tonic-gate 
329*7c478bd9Sstevel@tonic-gate 
330*7c478bd9Sstevel@tonic-gate /*
331*7c478bd9Sstevel@tonic-gate  * MKS-specific library entry points.
332*7c478bd9Sstevel@tonic-gate  */
333*7c478bd9Sstevel@tonic-gate extern	char	*_cmdname;
334*7c478bd9Sstevel@tonic-gate LEXTERN	char	*basename (char *);
335*7c478bd9Sstevel@tonic-gate LEXTERN	void	crc16 (ushort *, ushort);
336*7c478bd9Sstevel@tonic-gate LEXTERN	void	crcccitt (ushort *, ushort);
337*7c478bd9Sstevel@tonic-gate LEXTERN	int	eprintf (const char *, ...);
338*7c478bd9Sstevel@tonic-gate LEXTERN	void	eputs (const char *);
339*7c478bd9Sstevel@tonic-gate LEXTERN	pid_t	fexecve (const char *, char *const *, char *const *);
340*7c478bd9Sstevel@tonic-gate LEXTERN	pid_t	fexecvp (const char *, char *const *);
341*7c478bd9Sstevel@tonic-gate LEXTERN	pid_t	fexecvep (const char *, char *const *, char *const *);
342*7c478bd9Sstevel@tonic-gate LEXTERN int	execvep (const char *, char *const *, char *const *);
343*7c478bd9Sstevel@tonic-gate LEXTERN	int	isabsname (const char *);
344*7c478bd9Sstevel@tonic-gate LEXTERN	const char *m_cescape (wint_t);
345*7c478bd9Sstevel@tonic-gate LEXTERN	int	m_escapec (char **);
346*7c478bd9Sstevel@tonic-gate LEXTERN	const char *m_toprint (wint_t);
347*7c478bd9Sstevel@tonic-gate #if M_STTY_CC
348*7c478bd9Sstevel@tonic-gate LEXTERN	int	m_stty_cc (cc_t* cp, char *str);
349*7c478bd9Sstevel@tonic-gate #endif
350*7c478bd9Sstevel@tonic-gate LEXTERN	char	*m_cmdname (char *);
351*7c478bd9Sstevel@tonic-gate LEXTERN	char	*m_strmode (mode_t);
352*7c478bd9Sstevel@tonic-gate LEXTERN	char	*m_readmode (const char *);
353*7c478bd9Sstevel@tonic-gate LEXTERN	char	*m_readnum (long *, char *, char **, int);
354*7c478bd9Sstevel@tonic-gate LEXTERN	char	*m_readunum (unsigned long *, char *, char **, int);
355*7c478bd9Sstevel@tonic-gate LEXTERN	mode_t	m_getmode (mode_t);
356*7c478bd9Sstevel@tonic-gate LEXTERN	int	m_wallow (int, const char *);
357*7c478bd9Sstevel@tonic-gate LEXTERN	char	*m_pathcat (const char *, const char *);
358*7c478bd9Sstevel@tonic-gate LEXTERN	void	m_sigcleanup (void (*__handler)(int __signo) );
359*7c478bd9Sstevel@tonic-gate LEXTERN	void	m_defaction (int __signo);
360*7c478bd9Sstevel@tonic-gate LEXTERN	char	*m_strdup (const char *s);
361*7c478bd9Sstevel@tonic-gate LEXTERN int     m_stricmp (const char *, const char *);
362*7c478bd9Sstevel@tonic-gate LEXTERN	char	*m_self (int, char *, char *);
363*7c478bd9Sstevel@tonic-gate LEXTERN	int	m_grouplist (char *user, gid_t *gidlist[]);
364*7c478bd9Sstevel@tonic-gate LEXTERN	int	m_setgroups (int gidsetsize, gid_t grouplist[]);
365*7c478bd9Sstevel@tonic-gate LEXTERN	uint	m_binsrch (uint n, int (*cmp)(uint i));
366*7c478bd9Sstevel@tonic-gate LEXTERN	char	*m_dirname (const char*);
367*7c478bd9Sstevel@tonic-gate LEXTERN	char	*m_confstr (int);
368*7c478bd9Sstevel@tonic-gate 
369*7c478bd9Sstevel@tonic-gate LEXTERN	void	m_crcposix (ulong *, const uchar *, size_t);
370*7c478bd9Sstevel@tonic-gate LEXTERN	int	m_setprio (int, unsigned int, int);
371*7c478bd9Sstevel@tonic-gate LEXTERN	int	m_getprio (int, unsigned int);
372*7c478bd9Sstevel@tonic-gate LEXTERN int	m_incrnice (int, unsigned int, int);
373*7c478bd9Sstevel@tonic-gate LEXTERN	char	*m_devname (dev_t);
374*7c478bd9Sstevel@tonic-gate LEXTERN char	*m_mountdir (const char *);
375*7c478bd9Sstevel@tonic-gate LEXTERN int	m_absname(char *, char *, char *, size_t);
376*7c478bd9Sstevel@tonic-gate LEXTERN int	m_samefile(char *, struct stat *, char *, struct stat *);
377*7c478bd9Sstevel@tonic-gate 
378*7c478bd9Sstevel@tonic-gate /* __m_system() : alternate interface into system() */
379*7c478bd9Sstevel@tonic-gate LEXTERN int	__m_system (const char *, const char *, const char *);
380*7c478bd9Sstevel@tonic-gate 
381*7c478bd9Sstevel@tonic-gate 
382*7c478bd9Sstevel@tonic-gate /* conversion routines - between single byte and UNICODE (wide) strings.
383*7c478bd9Sstevel@tonic-gate  * These return a pointer to malloc'd memory.
384*7c478bd9Sstevel@tonic-gate  * It is the caller's responsiblity to free() it, if necessary
385*7c478bd9Sstevel@tonic-gate  * These are for use primarily on NT
386*7c478bd9Sstevel@tonic-gate  */
387*7c478bd9Sstevel@tonic-gate extern char *m_unicodetosb(const wchar_t*);
388*7c478bd9Sstevel@tonic-gate extern wchar_t *m_sbtounicode(const char*);
389*7c478bd9Sstevel@tonic-gate 
390*7c478bd9Sstevel@tonic-gate 
391*7c478bd9Sstevel@tonic-gate /*
392*7c478bd9Sstevel@tonic-gate  * things that could go into an "m_stdio.h"
393*7c478bd9Sstevel@tonic-gate  */
394*7c478bd9Sstevel@tonic-gate 
395*7c478bd9Sstevel@tonic-gate /* m_unlink() : alternate unlink() for use with vendor-provided
396*7c478bd9Sstevel@tonic-gate  * libraries that do not have a satisfactory unlink() */
397*7c478bd9Sstevel@tonic-gate #ifndef M_UNLINK
398*7c478bd9Sstevel@tonic-gate #define m_unlink(s)	unlink(s)
399*7c478bd9Sstevel@tonic-gate #endif
400*7c478bd9Sstevel@tonic-gate 
401*7c478bd9Sstevel@tonic-gate /* __m_popen() : alternate interface into popen() */
402*7c478bd9Sstevel@tonic-gate LEXTERN FILE	*__m_popen (const char *, const char *,
403*7c478bd9Sstevel@tonic-gate 			    const char *, const char *);
404*7c478bd9Sstevel@tonic-gate LEXTERN FILE	*__m_popenvp (const char *mode, const char *shell,
405*7c478bd9Sstevel@tonic-gate 			      char const * const *args);
406*7c478bd9Sstevel@tonic-gate 
407*7c478bd9Sstevel@tonic-gate #if M_TFGETC
408*7c478bd9Sstevel@tonic-gate LEXTERN int	m_tfgetc (FILE *fp, struct termios *tp);
409*7c478bd9Sstevel@tonic-gate #else
410*7c478bd9Sstevel@tonic-gate #define		m_tfgetc(fp,tp)	fgetc(fp)
411*7c478bd9Sstevel@tonic-gate #endif
412*7c478bd9Sstevel@tonic-gate 
413*7c478bd9Sstevel@tonic-gate /* m_fsopen() - special routine for curses */
414*7c478bd9Sstevel@tonic-gate LEXTERN	FILE	*m_fsopen (char *, size_t, const char *, FILE *);
415*7c478bd9Sstevel@tonic-gate 
416*7c478bd9Sstevel@tonic-gate #ifndef M_FFLUSH_NOT_POSIX_1
417*7c478bd9Sstevel@tonic-gate # define	m_fflush fflush
418*7c478bd9Sstevel@tonic-gate #else
419*7c478bd9Sstevel@tonic-gate   LEXTERN	int	m_fflush (FILE *);
420*7c478bd9Sstevel@tonic-gate #endif
421*7c478bd9Sstevel@tonic-gate 
422*7c478bd9Sstevel@tonic-gate /* m_fgets return values */
423*7c478bd9Sstevel@tonic-gate enum {
424*7c478bd9Sstevel@tonic-gate 	M_FGETS_OK,	/* Normal return */
425*7c478bd9Sstevel@tonic-gate 	M_FGETS_EOF,	/*
426*7c478bd9Sstevel@tonic-gate 			 * Regular EOF (same as NULL from fgets).
427*7c478bd9Sstevel@tonic-gate 			 * Buffer is *untouched*.
428*7c478bd9Sstevel@tonic-gate 			 */
429*7c478bd9Sstevel@tonic-gate 	M_FGETS_SHORT,	/*
430*7c478bd9Sstevel@tonic-gate 			 * Short input (buf[strlen(buf)-1] != '\n')
431*7c478bd9Sstevel@tonic-gate 			 * This is a trailing line, without a newline at the
432*7c478bd9Sstevel@tonic-gate 			 * end of the file.  The buffer is valid, ending in
433*7c478bd9Sstevel@tonic-gate 			 * a \0, with no newline.  The case of terminal input
434*7c478bd9Sstevel@tonic-gate 			 * ending with an EOF in the middle of the line will
435*7c478bd9Sstevel@tonic-gate 			 * restart -- typing two EOF's will result in this
436*7c478bd9Sstevel@tonic-gate 			 * case.
437*7c478bd9Sstevel@tonic-gate 			 */
438*7c478bd9Sstevel@tonic-gate 	M_FGETS_LONG,	/*
439*7c478bd9Sstevel@tonic-gate 			 * Line too long: newline not found within len bytes
440*7c478bd9Sstevel@tonic-gate 			 * (buf[len-1] != '\n').
441*7c478bd9Sstevel@tonic-gate 			 * At this point, while((c=getc(fp)) != '\n') ...
442*7c478bd9Sstevel@tonic-gate 			 * is a valid method to get the rest of the line.
443*7c478bd9Sstevel@tonic-gate 			 */
444*7c478bd9Sstevel@tonic-gate 	M_FGETS_BINARY,	/*
445*7c478bd9Sstevel@tonic-gate 			 * Input contained an invalid character (e.g. \0)
446*7c478bd9Sstevel@tonic-gate 			 * Buffer contents *undefined*.
447*7c478bd9Sstevel@tonic-gate 			 */
448*7c478bd9Sstevel@tonic-gate 	M_FGETS_ERROR	/*
449*7c478bd9Sstevel@tonic-gate 			 * A system call returned an error, errno is set.
450*7c478bd9Sstevel@tonic-gate 			 * Buffer contents *undefined*.
451*7c478bd9Sstevel@tonic-gate 			 */
452*7c478bd9Sstevel@tonic-gate };
453*7c478bd9Sstevel@tonic-gate LEXTERN int	m_fgets (char *, size_t, FILE *);
454*7c478bd9Sstevel@tonic-gate 
455*7c478bd9Sstevel@tonic-gate /*
456*7c478bd9Sstevel@tonic-gate  * end of things that could go into an "m_stdio.h"
457*7c478bd9Sstevel@tonic-gate  */
458*7c478bd9Sstevel@tonic-gate 
459*7c478bd9Sstevel@tonic-gate LEXTERN	int	m_winsize (int *, int *);
460*7c478bd9Sstevel@tonic-gate LEXTERN	char	*m_cuserid ();
461*7c478bd9Sstevel@tonic-gate 
462*7c478bd9Sstevel@tonic-gate /* m_ctype: generic character classification */
463*7c478bd9Sstevel@tonic-gate typedef	int	m_ctype_t;		/* ctype property */
464*7c478bd9Sstevel@tonic-gate LEXTERN	m_ctype_t	m_ctype (const char *property);
465*7c478bd9Sstevel@tonic-gate LEXTERN	int	m_isctype (int c, m_ctype_t ctype);
466*7c478bd9Sstevel@tonic-gate LEXTERN	char	*m_readdate (char *, time_t *, int);
467*7c478bd9Sstevel@tonic-gate 
468*7c478bd9Sstevel@tonic-gate #ifndef M_READDATE_SYSV
469*7c478bd9Sstevel@tonic-gate #define M_READDATE_SYSV 0
470*7c478bd9Sstevel@tonic-gate #endif
471*7c478bd9Sstevel@tonic-gate #ifndef M_READDATE_BSD
472*7c478bd9Sstevel@tonic-gate #define M_READDATE_BSD  1
473*7c478bd9Sstevel@tonic-gate #endif
474*7c478bd9Sstevel@tonic-gate 
475*7c478bd9Sstevel@tonic-gate #ifdef M_MALLOC
476*7c478bd9Sstevel@tonic-gate   LEXTERN _VOID *m_malloc (size_t size);
477*7c478bd9Sstevel@tonic-gate #else
478*7c478bd9Sstevel@tonic-gate # define m_malloc(size)	malloc(size)
479*7c478bd9Sstevel@tonic-gate #endif /*M_MALLOC*/
480*7c478bd9Sstevel@tonic-gate 
481*7c478bd9Sstevel@tonic-gate #ifdef M_REALLOC
482*7c478bd9Sstevel@tonic-gate   LEXTERN _VOID *m_realloc (void* ptr, size_t size);
483*7c478bd9Sstevel@tonic-gate #else
484*7c478bd9Sstevel@tonic-gate # define m_realloc	realloc
485*7c478bd9Sstevel@tonic-gate #endif /*M_MALLOC*/
486*7c478bd9Sstevel@tonic-gate 
487*7c478bd9Sstevel@tonic-gate #ifdef NAME_MAX
488*7c478bd9Sstevel@tonic-gate #define		m_namemax(path) NAME_MAX
489*7c478bd9Sstevel@tonic-gate #else
490*7c478bd9Sstevel@tonic-gate LEXTERN int	m_namemax (char *path);
491*7c478bd9Sstevel@tonic-gate #endif /*NAME_MAX*/
492*7c478bd9Sstevel@tonic-gate 
493*7c478bd9Sstevel@tonic-gate #ifdef PATH_MAX
494*7c478bd9Sstevel@tonic-gate #define		m_pathmax(path)	PATH_MAX
495*7c478bd9Sstevel@tonic-gate #else
496*7c478bd9Sstevel@tonic-gate LEXTERN	int	m_pathmax (char *path);
497*7c478bd9Sstevel@tonic-gate #endif /* PATH_MAX */
498*7c478bd9Sstevel@tonic-gate 
499*7c478bd9Sstevel@tonic-gate #ifdef M_DEVBIN
500*7c478bd9Sstevel@tonic-gate  LEXTERN int     m_devbin (int fd);	    /* begin raw I/O transfer */
501*7c478bd9Sstevel@tonic-gate  LEXTERN void    m_devstd (int fd, int mode); /* end raw I/O transfer */
502*7c478bd9Sstevel@tonic-gate #else
503*7c478bd9Sstevel@tonic-gate # define	m_devbin(fd)	0
504*7c478bd9Sstevel@tonic-gate # define	m_devstd(fd, mode)
505*7c478bd9Sstevel@tonic-gate #endif /*M_DEVBIN*/
506*7c478bd9Sstevel@tonic-gate 
507*7c478bd9Sstevel@tonic-gate #ifndef	m_setbinary
508*7c478bd9Sstevel@tonic-gate #define	m_setbinary(fp)
509*7c478bd9Sstevel@tonic-gate #endif /*m_setbinary*/
510*7c478bd9Sstevel@tonic-gate 
511*7c478bd9Sstevel@tonic-gate #ifndef M_PRIO_PROCESS
512*7c478bd9Sstevel@tonic-gate #define M_PRIO_PROCESS	0
513*7c478bd9Sstevel@tonic-gate #endif
514*7c478bd9Sstevel@tonic-gate #ifndef M_PRIO_PGRP
515*7c478bd9Sstevel@tonic-gate #define M_PRIO_PGRP	1
516*7c478bd9Sstevel@tonic-gate #endif
517*7c478bd9Sstevel@tonic-gate #ifndef M_PRIO_USER
518*7c478bd9Sstevel@tonic-gate #define M_PRIO_USER	2
519*7c478bd9Sstevel@tonic-gate #endif
520*7c478bd9Sstevel@tonic-gate 
521*7c478bd9Sstevel@tonic-gate /* m_wallow type values */
522*7c478bd9Sstevel@tonic-gate #ifndef MWA_NO
523*7c478bd9Sstevel@tonic-gate #define	MWA_NO	0		/* Deny talk, write */
524*7c478bd9Sstevel@tonic-gate #endif
525*7c478bd9Sstevel@tonic-gate #ifndef MWA_YES
526*7c478bd9Sstevel@tonic-gate #define	MWA_YES	1		/* Allow talk, write */
527*7c478bd9Sstevel@tonic-gate #endif
528*7c478bd9Sstevel@tonic-gate #ifndef MWA_TEST
529*7c478bd9Sstevel@tonic-gate #define	MWA_TEST 2		/* Test for YES/NO */
530*7c478bd9Sstevel@tonic-gate #endif
531*7c478bd9Sstevel@tonic-gate 
532*7c478bd9Sstevel@tonic-gate /* Interface for compression (m_cm_*) and decompression (m_dc_*) */
533*7c478bd9Sstevel@tonic-gate LEXTERN int	m_cm_open (int (*wrtfn) (const uchar *,int), int);
534*7c478bd9Sstevel@tonic-gate LEXTERN	int	m_cm_write (const uchar *, int);
535*7c478bd9Sstevel@tonic-gate LEXTERN	int	m_cm_close (int);
536*7c478bd9Sstevel@tonic-gate LEXTERN char	*m_cm_error (void);
537*7c478bd9Sstevel@tonic-gate LEXTERN int	m_dc_open (ssize_t (*rdfn)(uchar *, int));
538*7c478bd9Sstevel@tonic-gate LEXTERN	ssize_t	m_dc_read (uchar *, size_t);
539*7c478bd9Sstevel@tonic-gate LEXTERN	int	m_dc_close (int);
540*7c478bd9Sstevel@tonic-gate LEXTERN char	*m_dc_error (void);
541*7c478bd9Sstevel@tonic-gate 
542*7c478bd9Sstevel@tonic-gate LEXTERN	int	m_mkpardir (char *);
543*7c478bd9Sstevel@tonic-gate 
544*7c478bd9Sstevel@tonic-gate /*
545*7c478bd9Sstevel@tonic-gate  * Some UNIX routines that aren't in SVID
546*7c478bd9Sstevel@tonic-gate  */
547*7c478bd9Sstevel@tonic-gate LEXTERN	void	cfree (void *, size_t, size_t);
548*7c478bd9Sstevel@tonic-gate LEXTERN void	swaw (const short *, short *, int);
549*7c478bd9Sstevel@tonic-gate 
550*7c478bd9Sstevel@tonic-gate /* Some dos routines we sometimes want from posix utilities */
551*7c478bd9Sstevel@tonic-gate LEXTERN	void	_uttoof (time_t, ushort *, ushort *);
552*7c478bd9Sstevel@tonic-gate LEXTERN	time_t	_oftout (ushort, ushort);
553*7c478bd9Sstevel@tonic-gate 
554*7c478bd9Sstevel@tonic-gate 
555*7c478bd9Sstevel@tonic-gate #ifndef	M_SETENV
556*7c478bd9Sstevel@tonic-gate #define	m_setenv()	environ
557*7c478bd9Sstevel@tonic-gate #endif
558*7c478bd9Sstevel@tonic-gate 
559*7c478bd9Sstevel@tonic-gate #ifdef M_NON_STATIC_GETENV
560*7c478bd9Sstevel@tonic-gate #define __m_getenv getenv
561*7c478bd9Sstevel@tonic-gate #else
562*7c478bd9Sstevel@tonic-gate LEXTERN	char 	*__m_getenv(char const *);  /* Library safe getenv() */
563*7c478bd9Sstevel@tonic-gate #endif
564*7c478bd9Sstevel@tonic-gate 
565*7c478bd9Sstevel@tonic-gate #ifndef M_CRON_MAILER
566*7c478bd9Sstevel@tonic-gate /*
567*7c478bd9Sstevel@tonic-gate  * Default case: assume only POSIX.2 mailx is available.
568*7c478bd9Sstevel@tonic-gate  * Must be careful when cron sends output to mailx.
569*7c478bd9Sstevel@tonic-gate  * We must ensure that lines with leading '~' are escaped
570*7c478bd9Sstevel@tonic-gate  * so mailx doesn't interpret these lines
571*7c478bd9Sstevel@tonic-gate  * This string MUST include a trailing space character.
572*7c478bd9Sstevel@tonic-gate  */
573*7c478bd9Sstevel@tonic-gate #define M_CRON_MAILER	"sed -e s/^~/~~/ | mailx "
574*7c478bd9Sstevel@tonic-gate #endif
575*7c478bd9Sstevel@tonic-gate 
576*7c478bd9Sstevel@tonic-gate /*
577*7c478bd9Sstevel@tonic-gate  * m_cp() - copy a file in an O/S specific way.  See m_cp.3
578*7c478bd9Sstevel@tonic-gate  * for details
579*7c478bd9Sstevel@tonic-gate  */
580*7c478bd9Sstevel@tonic-gate 
581*7c478bd9Sstevel@tonic-gate /* Return codes */
582*7c478bd9Sstevel@tonic-gate #define M_CP_ERR	-1
583*7c478bd9Sstevel@tonic-gate #define M_CP_NOOP	-2
584*7c478bd9Sstevel@tonic-gate 
585*7c478bd9Sstevel@tonic-gate /* processing flags */
586*7c478bd9Sstevel@tonic-gate #define M_CP_PRESERVE	1
587*7c478bd9Sstevel@tonic-gate 
588*7c478bd9Sstevel@tonic-gate /*
589*7c478bd9Sstevel@tonic-gate  * MKS MEMORY MANIPULATIONS:
590*7c478bd9Sstevel@tonic-gate  *      Specific to MKS and non-portable.
591*7c478bd9Sstevel@tonic-gate  */
592*7c478bd9Sstevel@tonic-gate LEXTERN _VOID   *membtst (const char *s, size_t m, int c);
593*7c478bd9Sstevel@tonic-gate 
594*7c478bd9Sstevel@tonic-gate #ifdef M_LDATA
595*7c478bd9Sstevel@tonic-gate #define memLchr         memchr
596*7c478bd9Sstevel@tonic-gate #define memSLccpy       memccpy
597*7c478bd9Sstevel@tonic-gate #define memLbtst        membtst
598*7c478bd9Sstevel@tonic-gate #define memLset         memset
599*7c478bd9Sstevel@tonic-gate #define memLLcpy        memcpy
600*7c478bd9Sstevel@tonic-gate #define memLLrlcpy      memrlcpy
601*7c478bd9Sstevel@tonic-gate #define memLLcmp        memcmp
602*7c478bd9Sstevel@tonic-gate #else
603*7c478bd9Sstevel@tonic-gate /* for machines with small data models (e.g PC's - DOS, OS2) */
604*7c478bd9Sstevel@tonic-gate LEXTERN void    far*memLchr (const void far*s, int c, size_t n);
605*7c478bd9Sstevel@tonic-gate LEXTERN void    *memSLccpy (_VOID *s1, const _VOID far*s2, int, size_t n);
606*7c478bd9Sstevel@tonic-gate LEXTERN void    far*memLbtst (const char far*s, size_t m, int n);
607*7c478bd9Sstevel@tonic-gate LEXTERN void    far*memLset (void far*s, int c, size_t n);
608*7c478bd9Sstevel@tonic-gate LEXTERN void    far*memLsetl (void far*p, int value, long count);
609*7c478bd9Sstevel@tonic-gate LEXTERN void    far*memLLcpy (void far*s1, const void far*s2, size_t n);
610*7c478bd9Sstevel@tonic-gate LEXTERN void    far*memLLrlcpy (void far*s1, const void far*s2, size_t);
611*7c478bd9Sstevel@tonic-gate LEXTERN int     memLLcmp (const void far *s1,const void far *s2,size_t n);
612*7c478bd9Sstevel@tonic-gate #endif /* M_LDATA */
613*7c478bd9Sstevel@tonic-gate 
614*7c478bd9Sstevel@tonic-gate 
615*7c478bd9Sstevel@tonic-gate /* mks error handling routines */
616*7c478bd9Sstevel@tonic-gate #include <stdarg.h>
617*7c478bd9Sstevel@tonic-gate LEXTERN	void	m_error (const char * fmt, ...);
618*7c478bd9Sstevel@tonic-gate LEXTERN	void	m_errorexit (const char *fmt, va_list args);
619*7c478bd9Sstevel@tonic-gate LEXTERN	void	m_errorret (const char *fmt, va_list args);
620*7c478bd9Sstevel@tonic-gate LEXTERN	void	m_errorjmp (const char *fmt, va_list args);
621*7c478bd9Sstevel@tonic-gate LEXTERN	void	m_errornull (const char *fmt, va_list args);
622*7c478bd9Sstevel@tonic-gate LEXTERN	void	(*m_errorfn) (const char *fmt, va_list args);
623*7c478bd9Sstevel@tonic-gate #define	M_ERROR(fn)	void (*m_errorfn) (const char *fmt, va_list args) = fn
624*7c478bd9Sstevel@tonic-gate 
625*7c478bd9Sstevel@tonic-gate /*
626*7c478bd9Sstevel@tonic-gate  * The filesystem type and attribute routine
627*7c478bd9Sstevel@tonic-gate  */
628*7c478bd9Sstevel@tonic-gate #ifndef	M_FSTYPE
629*7c478bd9Sstevel@tonic-gate #define	m_fstype(path)	M_FSTYPE_POSIX
630*7c478bd9Sstevel@tonic-gate #endif
631*7c478bd9Sstevel@tonic-gate 
632*7c478bd9Sstevel@tonic-gate /* File system types */
633*7c478bd9Sstevel@tonic-gate #define	M_FSTYPE_MASK	0x1
634*7c478bd9Sstevel@tonic-gate #define	M_FSTYPE_POSIX	0
635*7c478bd9Sstevel@tonic-gate #define	M_FSTYPE_FAT	1
636*7c478bd9Sstevel@tonic-gate 
637*7c478bd9Sstevel@tonic-gate /* File system attributes */
638*7c478bd9Sstevel@tonic-gate #define	M_FSATTR_NO_LEADING_DOT	0x08
639*7c478bd9Sstevel@tonic-gate #define	M_FSATTR_ONE_DOT	0x10
640*7c478bd9Sstevel@tonic-gate #define	M_FSATTR_SHORT_FILENAME	0x20
641*7c478bd9Sstevel@tonic-gate #define	M_FSATTR_SHORT_EXT	0x40
642*7c478bd9Sstevel@tonic-gate #define	M_FSATTR_LOWER_CASE	0x80
643*7c478bd9Sstevel@tonic-gate 
644*7c478bd9Sstevel@tonic-gate /* This one should be ifdef'ed on something else */
645*7c478bd9Sstevel@tonic-gate #ifndef	M_FNMATCH_DUALCASE
646*7c478bd9Sstevel@tonic-gate #define	m_get_original_filename_case(path)	/* nil */
647*7c478bd9Sstevel@tonic-gate #endif
648*7c478bd9Sstevel@tonic-gate 
649*7c478bd9Sstevel@tonic-gate /*
650*7c478bd9Sstevel@tonic-gate  * m_tempname() generates a filename for a temp file using "code"
651*7c478bd9Sstevel@tonic-gate  * in the name.
652*7c478bd9Sstevel@tonic-gate  */
653*7c478bd9Sstevel@tonic-gate #ifndef M_TEMPNAME
654*7c478bd9Sstevel@tonic-gate #define m_tempname(code)	tempnam(__m_getenv("TMPDIR"), (code))
655*7c478bd9Sstevel@tonic-gate #else
656*7c478bd9Sstevel@tonic-gate char *m_tempname(char const *code);
657*7c478bd9Sstevel@tonic-gate #endif
658*7c478bd9Sstevel@tonic-gate 
659*7c478bd9Sstevel@tonic-gate /*
660*7c478bd9Sstevel@tonic-gate  * __m_getopt() alternate "stateless" entry into getopt().
661*7c478bd9Sstevel@tonic-gate  */
662*7c478bd9Sstevel@tonic-gate 
663*7c478bd9Sstevel@tonic-gate struct getopt_state {
664*7c478bd9Sstevel@tonic-gate         char    *optarg;                /* Argument */
665*7c478bd9Sstevel@tonic-gate         int     optind;                 /* Index into argv */
666*7c478bd9Sstevel@tonic-gate         int     opterr;                 /* Print error message */
667*7c478bd9Sstevel@tonic-gate         int     optopt;                 /* Invalid option */
668*7c478bd9Sstevel@tonic-gate         int     index;                  /* argv[optind] index */
669*7c478bd9Sstevel@tonic-gate #ifdef  M_I18N_MB
670*7c478bd9Sstevel@tonic-gate         mbstate_t st;                   /* State of argv[optind][index] */
671*7c478bd9Sstevel@tonic-gate #endif
672*7c478bd9Sstevel@tonic-gate };
673*7c478bd9Sstevel@tonic-gate 
674*7c478bd9Sstevel@tonic-gate int __m_getopt(int argc, char * const *argv, char const *optstring,
675*7c478bd9Sstevel@tonic-gate                struct getopt_state *state);
676*7c478bd9Sstevel@tonic-gate 
677*7c478bd9Sstevel@tonic-gate 
678*7c478bd9Sstevel@tonic-gate #ifdef M_MKSEXTRA_H
679*7c478bd9Sstevel@tonic-gate /* Any overrides etcetera for a particular system can go in here */
680*7c478bd9Sstevel@tonic-gate #include <mksextra.h>
681*7c478bd9Sstevel@tonic-gate #endif /* M_MKSEXTRA_H */
682*7c478bd9Sstevel@tonic-gate 
683*7c478bd9Sstevel@tonic-gate #endif	/* __M_MKS_H__ */
684