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