blob: 786fe558506e917fd3fd9ec655a71b9940f5980e [file] [log] [blame]
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05301/****************************************************************************
Steve Kondikae271bc2015-11-15 02:50:53 +01002 * Copyright (c) 1998-2014,2015 Free Software Foundation, Inc. *
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05303 * *
4 * Permission is hereby granted, free of charge, to any person obtaining a *
5 * copy of this software and associated documentation files (the *
6 * "Software"), to deal in the Software without restriction, including *
7 * without limitation the rights to use, copy, modify, merge, publish, *
8 * distribute, distribute with modifications, sublicense, and/or sell *
9 * copies of the Software, and to permit persons to whom the Software is *
10 * furnished to do so, subject to the following conditions: *
11 * *
12 * The above copyright notice and this permission notice shall be included *
13 * in all copies or substantial portions of the Software. *
14 * *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
22 * *
23 * Except as contained in this notice, the name(s) of the above copyright *
24 * holders shall not be used in advertising or otherwise to promote the *
25 * sale, use or other dealings in this Software without prior written *
26 * authorization. *
27 ****************************************************************************/
28
29/****************************************************************************
30 * Author: Thomas E. Dickey 1997-on *
31 ****************************************************************************/
32/*
Steve Kondikae271bc2015-11-15 02:50:53 +010033 * $Id: progs.priv.h,v 1.41 2015/05/23 23:53:55 tom Exp $
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053034 *
35 * progs.priv.h
36 *
37 * Header file for curses utility programs
38 */
39
Steve Kondikae271bc2015-11-15 02:50:53 +010040#ifndef PROGS_PRIV_H
41#define PROGS_PRIV_H 1
42
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053043#include <ncurses_cfg.h>
44
45#if USE_RCS_IDS
46#define MODULE_ID(id) static const char Ident[] = id;
47#else
Steve Kondikae271bc2015-11-15 02:50:53 +010048#define MODULE_ID(id) /*nothing */
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053049#endif
50
51#include <stdlib.h>
52#include <ctype.h>
53#include <string.h>
54#include <sys/types.h>
55
56#if HAVE_UNISTD_H
57#include <unistd.h>
58#endif
59
60#if HAVE_SYS_BSDTYPES_H
61#include <sys/bsdtypes.h> /* needed for ISC */
62#endif
63
64#if HAVE_LIMITS_H
65# include <limits.h>
66#elif HAVE_SYS_PARAM_H
67# include <sys/param.h>
68#endif
69
70#if HAVE_DIRENT_H
71# include <dirent.h>
72# define NAMLEN(dirent) strlen((dirent)->d_name)
73# if defined(_FILE_OFFSET_BITS) && defined(HAVE_STRUCT_DIRENT64)
74# if !defined(_LP64) && (_FILE_OFFSET_BITS == 64)
75# define DIRENT struct dirent64
76# else
77# define DIRENT struct dirent
78# endif
79# else
80# define DIRENT struct dirent
81# endif
82#else
83# define DIRENT struct direct
84# define NAMLEN(dirent) (dirent)->d_namlen
85# if HAVE_SYS_NDIR_H
86# include <sys/ndir.h>
87# endif
88# if HAVE_SYS_DIR_H
89# include <sys/dir.h>
90# endif
91# if HAVE_NDIR_H
92# include <ndir.h>
93# endif
94#endif
95
Steve Kondikae271bc2015-11-15 02:50:53 +010096#if HAVE_INTTYPES_H
97# include <inttypes.h>
98#else
99# if HAVE_STDINT_H
100# include <stdint.h>
101# endif
102#endif
103
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530104#include <assert.h>
105#include <errno.h>
106
107#if DECL_ERRNO
108extern int errno;
109#endif
110
111#if HAVE_GETOPT_H
112#include <getopt.h>
Steve Kondikae271bc2015-11-15 02:50:53 +0100113#elif !defined(HAVE_GETOPT_HEADER)
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530114/* 'getopt()' may be prototyped in <stdlib.h>, but declaring its
115 * variables doesn't hurt.
116 */
117extern char *optarg;
118extern int optind;
119#endif /* HAVE_GETOPT_H */
120
121#include <curses.h>
122#include <term_entry.h>
Steve Kondikae271bc2015-11-15 02:50:53 +0100123#include <nc_termios.h>
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530124#include <tic.h>
125#include <nc_tparm.h>
126
Steve Kondikae271bc2015-11-15 02:50:53 +0100127#include <nc_string.h>
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530128#include <nc_alloc.h>
129#if HAVE_NC_FREEALL
130#undef ExitProgram
131#ifdef USE_LIBTINFO
132#define ExitProgram(code) _nc_free_tinfo(code)
133#else
134#define ExitProgram(code) _nc_free_tic(code)
135#endif
136#endif
137
Steve Kondikae271bc2015-11-15 02:50:53 +0100138#if defined(__GNUC__) && defined(_FORTIFY_SOURCE)
139#define IGNORE_RC(func) errno = (int) func
140#else
141#define IGNORE_RC(func) (void) func
142#endif /* gcc workarounds */
143
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530144/* usually in <unistd.h> */
145#ifndef STDOUT_FILENO
146#define STDOUT_FILENO 1
147#endif
148
149#ifndef STDERR_FILENO
150#define STDERR_FILENO 2
151#endif
152
153#ifndef EXIT_SUCCESS
154#define EXIT_SUCCESS 0
155#endif
156
157#ifndef EXIT_FAILURE
158#define EXIT_FAILURE 1
159#endif
160
161#ifndef R_OK
162#define R_OK 4 /* Test for readable. */
163#endif
164
165#ifndef W_OK
166#define W_OK 2 /* Test for writable. */
167#endif
168
169#ifndef X_OK
170#define X_OK 1 /* Test for executable. */
171#endif
172
173#ifndef F_OK
174#define F_OK 0 /* Test for existence. */
175#endif
176
177/* usually in <unistd.h> */
178#ifndef STDOUT_FILENO
179#define STDOUT_FILENO 1
180#endif
181
182#ifndef STDERR_FILENO
183#define STDERR_FILENO 2
184#endif
185
186/* may be in limits.h, included from various places */
187#ifndef PATH_MAX
188# if defined(_POSIX_PATH_MAX)
189# define PATH_MAX _POSIX_PATH_MAX
190# elif defined(MAXPATHLEN)
191# define PATH_MAX MAXPATHLEN
192# else
Steve Kondikae271bc2015-11-15 02:50:53 +0100193# define PATH_MAX 255 /* the Posix minimum pathsize */
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530194# endif
195#endif
196
197/* We use isascii only to guard against use of 7-bit ctype tables in the
198 * isprint test in infocmp.
199 */
200#if !HAVE_ISASCII
201# undef isascii
202# if ('z'-'a' == 25) && ('z' < 127) && ('Z'-'A' == 25) && ('Z' < 127) && ('9' < 127)
203# define isascii(c) (UChar(c) <= 127)
204# else
Steve Kondikae271bc2015-11-15 02:50:53 +0100205# define isascii(c) 1 /* not really ascii anyway */
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530206# endif
207#endif
208
209#define UChar(c) ((unsigned char)(c))
210
211#define SIZEOF(v) (sizeof(v)/sizeof(v[0]))
Steve Kondikae271bc2015-11-15 02:50:53 +0100212
213#endif /* PROGS_PRIV_H */