xref: /illumos-gate/usr/src/lib/libxcurses/h/mks.h (revision 2b395c3c)
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  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
27  */
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 int	execvep (const char *, char *const *, char *const *);
340 LEXTERN	int	isabsname (const char *);
341 LEXTERN	const char *m_cescape (wint_t);
342 LEXTERN	int	m_escapec (char **);
343 LEXTERN	const char *m_toprint (wint_t);
344 #if M_STTY_CC
345 LEXTERN	int	m_stty_cc (cc_t* cp, char *str);
346 #endif
347 LEXTERN	char	*m_cmdname (char *);
348 LEXTERN	char	*m_strmode (mode_t);
349 LEXTERN	char	*m_readmode (const char *);
350 LEXTERN	char	*m_readnum (long *, char *, char **, int);
351 LEXTERN	char	*m_readunum (unsigned long *, char *, char **, int);
352 LEXTERN	mode_t	m_getmode (mode_t);
353 LEXTERN	int	m_wallow (int, const char *);
354 LEXTERN	char	*m_pathcat (const char *, const char *);
355 LEXTERN	void	m_sigcleanup (void (*__handler)(int __signo) );
356 LEXTERN	void	m_defaction (int __signo);
357 LEXTERN	char	*m_strdup (const char *s);
358 LEXTERN int     m_stricmp (const char *, const char *);
359 LEXTERN	char	*m_self (int, char *, char *);
360 LEXTERN	int	m_grouplist (char *user, gid_t *gidlist[]);
361 LEXTERN	int	m_setgroups (int gidsetsize, gid_t grouplist[]);
362 LEXTERN	uint	m_binsrch (uint n, int (*cmp)(uint i));
363 LEXTERN	char	*m_dirname (const char*);
364 LEXTERN	char	*m_confstr (int);
365 
366 LEXTERN	void	m_crcposix (ulong *, const uchar *, size_t);
367 LEXTERN	int	m_setprio (int, unsigned int, int);
368 LEXTERN	int	m_getprio (int, unsigned int);
369 LEXTERN int	m_incrnice (int, unsigned int, int);
370 LEXTERN	char	*m_devname (dev_t);
371 LEXTERN char	*m_mountdir (const char *);
372 LEXTERN int	m_absname(char *, char *, char *, size_t);
373 LEXTERN int	m_samefile(char *, struct stat *, char *, struct stat *);
374 
375 /* __m_system() : alternate interface into system() */
376 LEXTERN int	__m_system (const char *, const char *, const char *);
377 
378 
379 /* conversion routines - between single byte and UNICODE (wide) strings.
380  * These return a pointer to malloc'd memory.
381  * It is the caller's responsiblity to free() it, if necessary
382  * These are for use primarily on NT
383  */
384 extern char *m_unicodetosb(const wchar_t*);
385 extern wchar_t *m_sbtounicode(const char*);
386 
387 
388 /*
389  * things that could go into an "m_stdio.h"
390  */
391 
392 /* m_unlink() : alternate unlink() for use with vendor-provided
393  * libraries that do not have a satisfactory unlink() */
394 #ifndef M_UNLINK
395 #define m_unlink(s)	unlink(s)
396 #endif
397 
398 /* __m_popen() : alternate interface into popen() */
399 LEXTERN FILE	*__m_popen (const char *, const char *,
400 			    const char *, const char *);
401 LEXTERN FILE	*__m_popenvp (const char *mode, const char *shell,
402 			      char const * const *args);
403 
404 #if M_TFGETC
405 LEXTERN int	m_tfgetc (FILE *fp, struct termios *tp);
406 #else
407 #define		m_tfgetc(fp,tp)	fgetc(fp)
408 #endif
409 
410 /* m_fsopen() - special routine for curses */
411 LEXTERN	FILE	*m_fsopen (char *, size_t, const char *, FILE *);
412 
413 #ifndef M_FFLUSH_NOT_POSIX_1
414 # define	m_fflush fflush
415 #else
416   LEXTERN	int	m_fflush (FILE *);
417 #endif
418 
419 /* m_fgets return values */
420 enum {
421 	M_FGETS_OK,	/* Normal return */
422 	M_FGETS_EOF,	/*
423 			 * Regular EOF (same as NULL from fgets).
424 			 * Buffer is *untouched*.
425 			 */
426 	M_FGETS_SHORT,	/*
427 			 * Short input (buf[strlen(buf)-1] != '\n')
428 			 * This is a trailing line, without a newline at the
429 			 * end of the file.  The buffer is valid, ending in
430 			 * a \0, with no newline.  The case of terminal input
431 			 * ending with an EOF in the middle of the line will
432 			 * restart -- typing two EOF's will result in this
433 			 * case.
434 			 */
435 	M_FGETS_LONG,	/*
436 			 * Line too long: newline not found within len bytes
437 			 * (buf[len-1] != '\n').
438 			 * At this point, while((c=getc(fp)) != '\n') ...
439 			 * is a valid method to get the rest of the line.
440 			 */
441 	M_FGETS_BINARY,	/*
442 			 * Input contained an invalid character (e.g. \0)
443 			 * Buffer contents *undefined*.
444 			 */
445 	M_FGETS_ERROR	/*
446 			 * A system call returned an error, errno is set.
447 			 * Buffer contents *undefined*.
448 			 */
449 };
450 LEXTERN int	m_fgets (char *, size_t, FILE *);
451 
452 /*
453  * end of things that could go into an "m_stdio.h"
454  */
455 
456 LEXTERN	int	m_winsize (int *, int *);
457 LEXTERN	char	*m_cuserid ();
458 
459 /* m_ctype: generic character classification */
460 typedef	int	m_ctype_t;		/* ctype property */
461 LEXTERN	m_ctype_t	m_ctype (const char *property);
462 LEXTERN	int	m_isctype (int c, m_ctype_t ctype);
463 LEXTERN	char	*m_readdate (char *, time_t *, int);
464 
465 #ifndef M_READDATE_SYSV
466 #define M_READDATE_SYSV 0
467 #endif
468 #ifndef M_READDATE_BSD
469 #define M_READDATE_BSD  1
470 #endif
471 
472 #ifdef M_MALLOC
473   LEXTERN _VOID *m_malloc (size_t size);
474 #else
475 # define m_malloc(size)	malloc(size)
476 #endif /*M_MALLOC*/
477 
478 #ifdef M_REALLOC
479   LEXTERN _VOID *m_realloc (void* ptr, size_t size);
480 #else
481 # define m_realloc	realloc
482 #endif /*M_MALLOC*/
483 
484 #ifdef NAME_MAX
485 #define		m_namemax(path) NAME_MAX
486 #else
487 LEXTERN int	m_namemax (char *path);
488 #endif /*NAME_MAX*/
489 
490 #ifdef PATH_MAX
491 #define		m_pathmax(path)	PATH_MAX
492 #else
493 LEXTERN	int	m_pathmax (char *path);
494 #endif /* PATH_MAX */
495 
496 #ifdef M_DEVBIN
497  LEXTERN int     m_devbin (int fd);	    /* begin raw I/O transfer */
498  LEXTERN void    m_devstd (int fd, int mode); /* end raw I/O transfer */
499 #else
500 # define	m_devbin(fd)	0
501 # define	m_devstd(fd, mode)
502 #endif /*M_DEVBIN*/
503 
504 #ifndef	m_setbinary
505 #define	m_setbinary(fp)
506 #endif /*m_setbinary*/
507 
508 #ifndef M_PRIO_PROCESS
509 #define M_PRIO_PROCESS	0
510 #endif
511 #ifndef M_PRIO_PGRP
512 #define M_PRIO_PGRP	1
513 #endif
514 #ifndef M_PRIO_USER
515 #define M_PRIO_USER	2
516 #endif
517 
518 /* m_wallow type values */
519 #ifndef MWA_NO
520 #define	MWA_NO	0		/* Deny talk, write */
521 #endif
522 #ifndef MWA_YES
523 #define	MWA_YES	1		/* Allow talk, write */
524 #endif
525 #ifndef MWA_TEST
526 #define	MWA_TEST 2		/* Test for YES/NO */
527 #endif
528 
529 /* Interface for compression (m_cm_*) and decompression (m_dc_*) */
530 LEXTERN int	m_cm_open (int (*wrtfn) (const uchar *,int), int);
531 LEXTERN	int	m_cm_write (const uchar *, int);
532 LEXTERN	int	m_cm_close (int);
533 LEXTERN char	*m_cm_error (void);
534 LEXTERN int	m_dc_open (ssize_t (*rdfn)(uchar *, int));
535 LEXTERN	ssize_t	m_dc_read (uchar *, size_t);
536 LEXTERN	int	m_dc_close (int);
537 LEXTERN char	*m_dc_error (void);
538 
539 LEXTERN	int	m_mkpardir (char *);
540 
541 /*
542  * Some UNIX routines that aren't in SVID
543  */
544 LEXTERN	void	cfree (void *, size_t, size_t);
545 LEXTERN void	swaw (const short *, short *, int);
546 
547 /* Some dos routines we sometimes want from posix utilities */
548 LEXTERN	void	_uttoof (time_t, ushort *, ushort *);
549 LEXTERN	time_t	_oftout (ushort, ushort);
550 
551 
552 #ifndef	M_SETENV
553 #define	m_setenv()	environ
554 #endif
555 
556 #ifdef M_NON_STATIC_GETENV
557 #define __m_getenv getenv
558 #else
559 LEXTERN	char	*__m_getenv(char const *);  /* Library safe getenv() */
560 #endif
561 
562 #ifndef M_CRON_MAILER
563 /*
564  * Default case: assume only POSIX.2 mailx is available.
565  * Must be careful when cron sends output to mailx.
566  * We must ensure that lines with leading '~' are escaped
567  * so mailx doesn't interpret these lines
568  * This string MUST include a trailing space character.
569  */
570 #define M_CRON_MAILER	"sed -e s/^~/~~/ | mailx "
571 #endif
572 
573 /*
574  * m_cp() - copy a file in an O/S specific way.  See m_cp.3
575  * for details
576  */
577 
578 /* Return codes */
579 #define M_CP_ERR	-1
580 #define M_CP_NOOP	-2
581 
582 /* processing flags */
583 #define M_CP_PRESERVE	1
584 
585 /*
586  * MKS MEMORY MANIPULATIONS:
587  *      Specific to MKS and non-portable.
588  */
589 LEXTERN _VOID   *membtst (const char *s, size_t m, int c);
590 
591 #ifdef M_LDATA
592 #define memLchr         memchr
593 #define memSLccpy       memccpy
594 #define memLbtst        membtst
595 #define memLset         memset
596 #define memLLcpy        memcpy
597 #define memLLrlcpy      memrlcpy
598 #define memLLcmp        memcmp
599 #else
600 /* for machines with small data models (e.g PC's - DOS, OS2) */
601 LEXTERN void    far*memLchr (const void far*s, int c, size_t n);
602 LEXTERN void    *memSLccpy (_VOID *s1, const _VOID far*s2, int, size_t n);
603 LEXTERN void    far*memLbtst (const char far*s, size_t m, int n);
604 LEXTERN void    far*memLset (void far*s, int c, size_t n);
605 LEXTERN void    far*memLsetl (void far*p, int value, long count);
606 LEXTERN void    far*memLLcpy (void far*s1, const void far*s2, size_t n);
607 LEXTERN void    far*memLLrlcpy (void far*s1, const void far*s2, size_t);
608 LEXTERN int     memLLcmp (const void far *s1,const void far *s2,size_t n);
609 #endif /* M_LDATA */
610 
611 
612 /* mks error handling routines */
613 #include <stdarg.h>
614 LEXTERN	void	m_error (const char * fmt, ...);
615 LEXTERN	void	m_errorexit (const char *fmt, va_list args);
616 LEXTERN	void	m_errorret (const char *fmt, va_list args);
617 LEXTERN	void	m_errorjmp (const char *fmt, va_list args);
618 LEXTERN	void	m_errornull (const char *fmt, va_list args);
619 LEXTERN	void	(*m_errorfn) (const char *fmt, va_list args);
620 #define	M_ERROR(fn)	void (*m_errorfn) (const char *fmt, va_list args) = fn
621 
622 /*
623  * The filesystem type and attribute routine
624  */
625 #ifndef	M_FSTYPE
626 #define	m_fstype(path)	M_FSTYPE_POSIX
627 #endif
628 
629 /* File system types */
630 #define	M_FSTYPE_MASK	0x1
631 #define	M_FSTYPE_POSIX	0
632 #define	M_FSTYPE_FAT	1
633 
634 /* File system attributes */
635 #define	M_FSATTR_NO_LEADING_DOT	0x08
636 #define	M_FSATTR_ONE_DOT	0x10
637 #define	M_FSATTR_SHORT_FILENAME	0x20
638 #define	M_FSATTR_SHORT_EXT	0x40
639 #define	M_FSATTR_LOWER_CASE	0x80
640 
641 /* This one should be ifdef'ed on something else */
642 #ifndef	M_FNMATCH_DUALCASE
643 #define	m_get_original_filename_case(path)	/* nil */
644 #endif
645 
646 /*
647  * m_tempname() generates a filename for a temp file using "code"
648  * in the name.
649  */
650 #ifndef M_TEMPNAME
651 #define m_tempname(code)	tempnam(__m_getenv("TMPDIR"), (code))
652 #else
653 char *m_tempname(char const *code);
654 #endif
655 
656 /*
657  * __m_getopt() alternate "stateless" entry into getopt().
658  */
659 
660 struct getopt_state {
661         char    *optarg;                /* Argument */
662         int     optind;                 /* Index into argv */
663         int     opterr;                 /* Print error message */
664         int     optopt;                 /* Invalid option */
665         int     index;                  /* argv[optind] index */
666 #ifdef  M_I18N_MB
667         mbstate_t st;                   /* State of argv[optind][index] */
668 #endif
669 };
670 
671 int __m_getopt(int argc, char * const *argv, char const *optstring,
672                struct getopt_state *state);
673 
674 
675 #ifdef M_MKSEXTRA_H
676 /* Any overrides etcetera for a particular system can go in here */
677 #include <mksextra.h>
678 #endif /* M_MKSEXTRA_H */
679 
680 #endif	/* __M_MKS_H__ */
681