]> ncurses.scripts.mit.edu Git - ncurses.git/blob - progs/progs.priv.h
ncurses 6.5 - patch 20240504
[ncurses.git] / progs / progs.priv.h
1 /****************************************************************************
2  * Copyright 2019-2022,2024 Thomas E. Dickey                                *
3  * Copyright 1998-2015,2017 Free Software Foundation, Inc.                  *
4  *                                                                          *
5  * Permission is hereby granted, free of charge, to any person obtaining a  *
6  * copy of this software and associated documentation files (the            *
7  * "Software"), to deal in the Software without restriction, including      *
8  * without limitation the rights to use, copy, modify, merge, publish,      *
9  * distribute, distribute with modifications, sublicense, and/or sell       *
10  * copies of the Software, and to permit persons to whom the Software is    *
11  * furnished to do so, subject to the following conditions:                 *
12  *                                                                          *
13  * The above copyright notice and this permission notice shall be included  *
14  * in all copies or substantial portions of the Software.                   *
15  *                                                                          *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
19  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
20  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
21  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
22  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
23  *                                                                          *
24  * Except as contained in this notice, the name(s) of the above copyright   *
25  * holders shall not be used in advertising or otherwise to promote the     *
26  * sale, use or other dealings in this Software without prior written       *
27  * authorization.                                                           *
28  ****************************************************************************/
29
30 /****************************************************************************
31  *  Author: Thomas E. Dickey                    1997-on                     *
32  ****************************************************************************/
33 /*
34  * $Id: progs.priv.h,v 1.62 2024/04/08 17:28:28 tom Exp $
35  *
36  *      progs.priv.h
37  *
38  *      Header file for curses utility programs
39  */
40
41 #ifndef PROGS_PRIV_H
42 #define PROGS_PRIV_H 1
43
44 #include <curses.priv.h>
45
46 #include <ctype.h>
47
48 #if HAVE_DIRENT_H
49 # include <dirent.h>
50 # define NAMLEN(dirent) strlen((dirent)->d_name)
51 # if defined(_FILE_OFFSET_BITS) && defined(HAVE_STRUCT_DIRENT64)
52 #  if !defined(_LP64) && (_FILE_OFFSET_BITS == 64)
53 #   define      DIRENT  struct dirent64
54 #  else
55 #   define      DIRENT  struct dirent
56 #  endif
57 # else
58 #  define       DIRENT  struct dirent
59 # endif
60 #else
61 # define DIRENT struct direct
62 # define NAMLEN(dirent) (dirent)->d_namlen
63 # if HAVE_SYS_NDIR_H
64 #  include <sys/ndir.h>
65 # endif
66 # if HAVE_SYS_DIR_H
67 #  include <sys/dir.h>
68 # endif
69 # if HAVE_NDIR_H
70 #  include <ndir.h>
71 # endif
72 #endif
73
74 #if HAVE_GETOPT_H
75 #include <getopt.h>
76 #elif !defined(HAVE_GETOPT_HEADER)
77 /* 'getopt()' may be prototyped in <stdlib.h>, but declaring its
78  * variables doesn't hurt.
79  */
80 extern char *optarg;
81 extern int optind;
82 #endif /* HAVE_GETOPT_H */
83
84 #include <tic.h>
85
86 #if HAVE_NC_FREEALL
87 #undef ExitProgram
88 #ifdef USE_LIBTINFO
89 #define ExitProgram(code) exit_terminfo(code)
90 #else
91 #define ExitProgram(code) _nc_free_tic(code)
92 #endif
93 #endif
94
95 /* error-returns for tput */
96 #define ErrUsage        2
97 #define ErrTermType     3
98 #define ErrCapName      4
99 #define ErrSystem(n)    (4 + (n))
100
101 /* We use isascii only to guard against use of 7-bit ctype tables in the
102  * isprint test in infocmp.
103  */
104 #if !HAVE_ISASCII
105 # undef isascii
106 # if ('z'-'a' == 25) && ('z' < 127) && ('Z'-'A' == 25) && ('Z' < 127) && ('9' < 127)
107 #  define isascii(c) (UChar(c) <= 127)
108 # else
109 #  define isascii(c) 1          /* not really ascii anyway */
110 # endif
111 #endif
112
113 #define VtoTrace(opt) (unsigned) ((opt > 0) ? opt : (opt == 0))
114
115 /*
116  * If configured for tracing, the debug- and trace-output are merged together
117  * in the trace file for "upper" levels of the verbose option.
118  */
119 #ifdef TRACE
120 #define use_verbosity(level) do { \
121                 set_trace_level(level); \
122                 if (_nc_tracing > DEBUG_LEVEL(2)) \
123                     _nc_tracing |= TRACE_MAXIMUM; \
124                 else if (_nc_tracing == DEBUG_LEVEL(2)) \
125                     _nc_tracing |= TRACE_ORDINARY; \
126                 if (level >= 2) \
127                     curses_trace(_nc_tracing); \
128         } while (0)
129 #else
130 #define use_verbosity(level) do { set_trace_level(level); } while (0)
131 #endif
132
133 #ifndef CUR
134 #define CUR ((TERMTYPE *)(cur_term))->
135 #endif
136
137 #endif /* PROGS_PRIV_H */