progs.priv.h revision 97049
11556Srgrimes/****************************************************************************
21556Srgrimes * Copyright (c) 1998-2000 Free Software Foundation, Inc.                   *
31556Srgrimes *                                                                          *
41556Srgrimes * Permission is hereby granted, free of charge, to any person obtaining a  *
51556Srgrimes * copy of this software and associated documentation files (the            *
61556Srgrimes * "Software"), to deal in the Software without restriction, including      *
71556Srgrimes * without limitation the rights to use, copy, modify, merge, publish,      *
81556Srgrimes * distribute, distribute with modifications, sublicense, and/or sell       *
91556Srgrimes * copies of the Software, and to permit persons to whom the Software is    *
101556Srgrimes * furnished to do so, subject to the following conditions:                 *
111556Srgrimes *                                                                          *
121556Srgrimes * The above copyright notice and this permission notice shall be included  *
131556Srgrimes * in all copies or substantial portions of the Software.                   *
141556Srgrimes *                                                                          *
151556Srgrimes * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
161556Srgrimes * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
171556Srgrimes * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
181556Srgrimes * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
191556Srgrimes * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
201556Srgrimes * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
211556Srgrimes * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
221556Srgrimes *                                                                          *
231556Srgrimes * Except as contained in this notice, the name(s) of the above copyright   *
241556Srgrimes * holders shall not be used in advertising or otherwise to promote the     *
251556Srgrimes * sale, use or other dealings in this Software without prior written       *
261556Srgrimes * authorization.                                                           *
271556Srgrimes ****************************************************************************/
281556Srgrimes
291556Srgrimes/****************************************************************************
301556Srgrimes *  Author: Thomas E. Dickey <dickey@clark.net> 1997,1998                   *
311556Srgrimes ****************************************************************************/
321556Srgrimes/*
331556Srgrimes * $Id: progs.priv.h,v 1.27 2001/06/18 18:43:52 tom Exp $
3436150Scharnier *
3536150Scharnier *	progs.priv.h
3636150Scharnier *
371556Srgrimes *	Header file for curses utility programs
3899110Sobrien */
3999110Sobrien
401556Srgrimes#include <ncurses_cfg.h>
4117987Speter
42149017Sstefanf#if USE_RCS_IDS
43209337Sjilles#define MODULE_ID(id) static const char Ident[] = id;
4417987Speter#else
451556Srgrimes#define MODULE_ID(id) /*nothing*/
461556Srgrimes#endif
471556Srgrimes
481556Srgrimes#include <stdlib.h>
491556Srgrimes#include <ctype.h>
501556Srgrimes#include <string.h>
511556Srgrimes#include <sys/types.h>
521556Srgrimes
531556Srgrimes#if HAVE_UNISTD_H
541556Srgrimes#include <unistd.h>
551556Srgrimes#else
561556Srgrimes# if HAVE_LIBC_H
571556Srgrimes# include <libc.h>
5817987Speter# endif
5959436Scracauer#endif
6017987Speter
611556Srgrimes#if HAVE_SYS_BSDTYPES_H
6217987Speter#include <sys/bsdtypes.h>	/* needed for ISC */
631556Srgrimes#endif
641556Srgrimes
651556Srgrimes#if HAVE_LIMITS_H
661556Srgrimes# include <limits.h>
671556Srgrimes#elif HAVE_SYS_PARAM_H
68142845Sobrien# include <sys/param.h>
69142845Sobrien#endif
701556Srgrimes
711556Srgrimes#if HAVE_DIRENT_H
7217987Speter# include <dirent.h>
731556Srgrimes# define NAMLEN(dirent) strlen((dirent)->d_name)
741556Srgrimes#else
751556Srgrimes# define dirent direct
761556Srgrimes# define NAMLEN(dirent) (dirent)->d_namlen
771556Srgrimes# if HAVE_SYS_NDIR_H
781556Srgrimes#  include <sys/ndir.h>
791556Srgrimes# endif
801556Srgrimes# if HAVE_SYS_DIR_H
811556Srgrimes#  include <sys/dir.h>
821556Srgrimes# endif
83206145Sjilles# if HAVE_NDIR_H
84206145Sjilles#  include <ndir.h>
85206145Sjilles# endif
86206145Sjilles#endif
871556Srgrimes
881556Srgrimes#include <errno.h>
89213760Sobrien
90213760Sobrien#if DECL_ERRNO
91213760Sobrienextern int errno;
92213760Sobrien#endif
931556Srgrimes
94213760Sobrien#if HAVE_GETOPT_H
951556Srgrimes#include <getopt.h>
96213760Sobrien#else
97213760Sobrien/* 'getopt()' may be prototyped in <stdlib.h>, but declaring its
98213760Sobrien * variables doesn't hurt.
99213760Sobrien */
100213760Sobrienextern char *optarg;
101213760Sobrienextern int optind;
102213760Sobrien#endif /* HAVE_GETOPT_H */
1031556Srgrimes
10418018Speter#include <curses.h>
10518018Speter#include <term_entry.h>
1061556Srgrimes#include <tic.h>
1071556Srgrimes#include <nc_alloc.h>
108213811Sobrien
109213811Sobrien/* usually in <unistd.h> */
110213811Sobrien#ifndef STDOUT_FILENO
111213811Sobrien#define STDOUT_FILENO 1
112213811Sobrien#endif
113213811Sobrien
114213811Sobrien#ifndef STDERR_FILENO
115213811Sobrien#define STDERR_FILENO 2
116213811Sobrien#endif
117213811Sobrien
118213811Sobrien#ifndef EXIT_SUCCESS
119213811Sobrien#define EXIT_SUCCESS 0
120213811Sobrien#endif
121213811Sobrien
122213811Sobrien#ifndef EXIT_FAILURE
123213811Sobrien#define EXIT_FAILURE 1
1241556Srgrimes#endif
12517987Speter
126213811Sobrien#ifndef R_OK
127206145Sjilles#define	R_OK	4		/* Test for readable.  */
128206145Sjilles#endif
129206145Sjilles
130206145Sjilles#ifndef W_OK
131206145Sjilles#define	W_OK	2		/* Test for writable.  */
132206145Sjilles#endif
133206145Sjilles
134206145Sjilles#ifndef X_OK
135206145Sjilles#define	X_OK	1		/* Test for executable.  */
136206145Sjilles#endif
137206145Sjilles
138206145Sjilles#ifndef F_OK
139206145Sjilles#define	F_OK	0		/* Test for existence.  */
140206145Sjilles#endif
141206145Sjilles
142213811Sobrien/* usually in <unistd.h> */
143206145Sjilles#ifndef STDOUT_FILENO
144206145Sjilles#define STDOUT_FILENO 1
145206145Sjilles#endif
146206145Sjilles
147206145Sjilles#ifndef STDERR_FILENO
148206145Sjilles#define STDERR_FILENO 2
149206145Sjilles#endif
150206145Sjilles
151206145Sjilles/* may be in limits.h, included from various places */
152206145Sjilles#ifndef PATH_MAX
153206145Sjilles# if defined(_POSIX_PATH_MAX)
154206145Sjilles#  define PATH_MAX _POSIX_PATH_MAX
155206145Sjilles# elif defined(MAXPATHLEN)
156206145Sjilles#  define PATH_MAX MAXPATHLEN
157213811Sobrien# else
158206145Sjilles#  define PATH_MAX 255	/* the Posix minimum pathsize */
159206145Sjilles# endif
160206145Sjilles#endif
161206145Sjilles
162206145Sjilles/* We use isascii only to guard against use of 7-bit ctype tables in the
163206145Sjilles * isprint test in infocmp.
164206145Sjilles */
165206145Sjilles#if !HAVE_ISASCII
166206145Sjilles# undef isascii
167206145Sjilles# if ('z'-'a' == 25) && ('z' < 127) && ('Z'-'A' == 25) && ('Z' < 127) && ('9' < 127)
168206145Sjilles#  define isascii(c) (UChar(c) <= 127)
169206145Sjilles# else
170206145Sjilles#  define isascii(c) 1	/* not really ascii anyway */
171206145Sjilles# endif
172206145Sjilles#endif
173206145Sjilles
174206145Sjilles#define UChar(c)    ((unsigned char)(c))
175206145Sjilles
176206145Sjilles#define SIZEOF(v) (sizeof(v)/sizeof(v[0]))
177213811Sobrien