blob: fea18b8d72c33c56409b379641e6bedf639efb58 [file] [log] [blame]
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05301/****************************************************************************
micky3879b9f5e72025-07-08 18:04:53 -04002 * Copyright 2019-2022,2024 Thomas E. Dickey *
3 * Copyright 1998-2015,2017 Free Software Foundation, Inc. *
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +05304 * *
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/*
micky3879b9f5e72025-07-08 18:04:53 -040034 * $Id: progs.priv.h,v 1.62 2024/04/08 17:28:28 tom Exp $
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053035 *
36 * progs.priv.h
37 *
38 * Header file for curses utility programs
39 */
40
Steve Kondikae271bc2015-11-15 02:50:53 +010041#ifndef PROGS_PRIV_H
42#define PROGS_PRIV_H 1
43
micky3879b9f5e72025-07-08 18:04:53 -040044#include <curses.priv.h>
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053045
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053046#include <ctype.h>
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053047
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
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053074#if HAVE_GETOPT_H
75#include <getopt.h>
Steve Kondikae271bc2015-11-15 02:50:53 +010076#elif !defined(HAVE_GETOPT_HEADER)
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053077/* 'getopt()' may be prototyped in <stdlib.h>, but declaring its
78 * variables doesn't hurt.
79 */
80extern char *optarg;
81extern int optind;
82#endif /* HAVE_GETOPT_H */
83
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053084#include <tic.h>
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053085
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053086#if HAVE_NC_FREEALL
87#undef ExitProgram
88#ifdef USE_LIBTINFO
micky3879b9f5e72025-07-08 18:04:53 -040089#define ExitProgram(code) exit_terminfo(code)
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +053090#else
91#define ExitProgram(code) _nc_free_tic(code)
92#endif
93#endif
94
micky3879b9f5e72025-07-08 18:04:53 -040095/* error-returns for tput */
96#define ErrUsage 2
97#define ErrTermType 3
98#define ErrCapName 4
99#define ErrSystem(n) (4 + (n))
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530100
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
Steve Kondikae271bc2015-11-15 02:50:53 +0100109# define isascii(c) 1 /* not really ascii anyway */
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530110# endif
111#endif
112
micky3879b9f5e72025-07-08 18:04:53 -0400113#define VtoTrace(opt) (unsigned) ((opt > 0) ? opt : (opt == 0))
Amit Daniel Kachhape6a01f52011-07-20 11:45:59 +0530114
micky3879b9f5e72025-07-08 18:04:53 -0400115/*
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
Steve Kondikae271bc2015-11-15 02:50:53 +0100136
137#endif /* PROGS_PRIV_H */