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