Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 1 | /**************************************************************************** |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 2 | * Copyright 2019-2022,2024 Thomas E. Dickey * |
| 3 | * Copyright 1998-2015,2017 Free Software Foundation, Inc. * |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 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 | /* |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 34 | * $Id: progs.priv.h,v 1.62 2024/04/08 17:28:28 tom Exp $ |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 35 | * |
| 36 | * progs.priv.h |
| 37 | * |
| 38 | * Header file for curses utility programs |
| 39 | */ |
| 40 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 41 | #ifndef PROGS_PRIV_H |
| 42 | #define PROGS_PRIV_H 1 |
| 43 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 44 | #include <curses.priv.h> |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 45 | |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 46 | #include <ctype.h> |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 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 | |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 74 | #if HAVE_GETOPT_H |
| 75 | #include <getopt.h> |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 76 | #elif !defined(HAVE_GETOPT_HEADER) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 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 | |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 84 | #include <tic.h> |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 85 | |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 86 | #if HAVE_NC_FREEALL |
| 87 | #undef ExitProgram |
| 88 | #ifdef USE_LIBTINFO |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 89 | #define ExitProgram(code) exit_terminfo(code) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 90 | #else |
| 91 | #define ExitProgram(code) _nc_free_tic(code) |
| 92 | #endif |
| 93 | #endif |
| 94 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 95 | /* error-returns for tput */ |
| 96 | #define ErrUsage 2 |
| 97 | #define ErrTermType 3 |
| 98 | #define ErrCapName 4 |
| 99 | #define ErrSystem(n) (4 + (n)) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 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 |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 109 | # define isascii(c) 1 /* not really ascii anyway */ |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 110 | # endif |
| 111 | #endif |
| 112 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 113 | #define VtoTrace(opt) (unsigned) ((opt > 0) ? opt : (opt == 0)) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 114 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 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 |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 136 | |
| 137 | #endif /* PROGS_PRIV_H */ |