Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- llava_next/include/lzma/base.h +747 -0
- llava_next/include/lzma/bcj.h +98 -0
- llava_next/include/lzma/block.h +694 -0
- llava_next/include/lzma/check.h +163 -0
- llava_next/include/lzma/container.h +995 -0
- llava_next/include/lzma/delta.h +95 -0
- llava_next/include/lzma/filter.h +769 -0
- llava_next/include/lzma/hardware.h +62 -0
- llava_next/include/lzma/index.h +882 -0
- llava_next/include/lzma/index_hash.h +123 -0
- llava_next/include/lzma/lzma12.h +568 -0
- llava_next/include/lzma/stream_flags.h +265 -0
- llava_next/include/lzma/version.h +134 -0
- llava_next/include/lzma/vli.h +166 -0
- llava_next/include/ncurses/curses.h +0 -0
- llava_next/include/ncurses/cursesapp.h +191 -0
- llava_next/include/ncurses/cursesf.h +968 -0
- llava_next/include/ncurses/cursesm.h +674 -0
- llava_next/include/ncurses/cursesp.h +271 -0
- llava_next/include/ncurses/cursesw.h +1581 -0
- llava_next/include/ncurses/cursslk.h +240 -0
- llava_next/include/ncurses/eti.h +55 -0
- llava_next/include/ncurses/etip.h +406 -0
- llava_next/include/ncurses/form.h +460 -0
- llava_next/include/ncurses/menu.h +281 -0
- llava_next/include/ncurses/nc_tparm.h +92 -0
- llava_next/include/ncurses/ncurses.h +0 -0
- llava_next/include/ncurses/ncurses_dll.h +99 -0
- llava_next/include/ncurses/panel.h +100 -0
- llava_next/include/ncurses/term.h +893 -0
- llava_next/include/ncurses/term_entry.h +239 -0
- llava_next/include/ncurses/termcap.h +73 -0
- llava_next/include/ncurses/tic.h +396 -0
- llava_next/include/ncurses/unctrl.h +68 -0
- llava_next/include/ncursesw/curses.h +0 -0
- llava_next/include/ncursesw/cursesf.h +968 -0
- llava_next/include/ncursesw/cursesm.h +674 -0
- llava_next/include/ncursesw/cursesp.h +271 -0
- llava_next/include/ncursesw/cursesw.h +1581 -0
- llava_next/include/ncursesw/form.h +460 -0
- llava_next/include/ncursesw/nc_tparm.h +92 -0
- llava_next/include/ncursesw/term.h +893 -0
- llava_next/include/ncursesw/term_entry.h +239 -0
- llava_next/include/ncursesw/unctrl.h +68 -0
- llava_next/include/openssl/asn1err.h +140 -0
- llava_next/include/openssl/asn1t.h +946 -0
- llava_next/include/openssl/blowfish.h +78 -0
- llava_next/include/openssl/bnerr.h +47 -0
- llava_next/include/openssl/camellia.h +117 -0
- llava_next/include/openssl/comperr.h +31 -0
llava_next/include/lzma/base.h
ADDED
|
@@ -0,0 +1,747 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* SPDX-License-Identifier: 0BSD */
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* \file lzma/base.h
|
| 5 |
+
* \brief Data types and functions used in many places in liblzma API
|
| 6 |
+
* \note Never include this file directly. Use <lzma.h> instead.
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
/*
|
| 10 |
+
* Author: Lasse Collin
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
#ifndef LZMA_H_INTERNAL
|
| 14 |
+
# error Never include this file directly. Use <lzma.h> instead.
|
| 15 |
+
#endif
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
/**
|
| 19 |
+
* \brief Boolean
|
| 20 |
+
*
|
| 21 |
+
* This is here because C89 doesn't have stdbool.h. To set a value for
|
| 22 |
+
* variables having type lzma_bool, you can use
|
| 23 |
+
* - C99's 'true' and 'false' from stdbool.h;
|
| 24 |
+
* - C++'s internal 'true' and 'false'; or
|
| 25 |
+
* - integers one (true) and zero (false).
|
| 26 |
+
*/
|
| 27 |
+
typedef unsigned char lzma_bool;
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* \brief Type of reserved enumeration variable in structures
|
| 32 |
+
*
|
| 33 |
+
* To avoid breaking library ABI when new features are added, several
|
| 34 |
+
* structures contain extra variables that may be used in future. Since
|
| 35 |
+
* sizeof(enum) can be different than sizeof(int), and sizeof(enum) may
|
| 36 |
+
* even vary depending on the range of enumeration constants, we specify
|
| 37 |
+
* a separate type to be used for reserved enumeration variables. All
|
| 38 |
+
* enumeration constants in liblzma API will be non-negative and less
|
| 39 |
+
* than 128, which should guarantee that the ABI won't break even when
|
| 40 |
+
* new constants are added to existing enumerations.
|
| 41 |
+
*/
|
| 42 |
+
typedef enum {
|
| 43 |
+
LZMA_RESERVED_ENUM = 0
|
| 44 |
+
} lzma_reserved_enum;
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
/**
|
| 48 |
+
* \brief Return values used by several functions in liblzma
|
| 49 |
+
*
|
| 50 |
+
* Check the descriptions of specific functions to find out which return
|
| 51 |
+
* values they can return. With some functions the return values may have
|
| 52 |
+
* more specific meanings than described here; those differences are
|
| 53 |
+
* described per-function basis.
|
| 54 |
+
*/
|
| 55 |
+
typedef enum {
|
| 56 |
+
LZMA_OK = 0,
|
| 57 |
+
/**<
|
| 58 |
+
* \brief Operation completed successfully
|
| 59 |
+
*/
|
| 60 |
+
|
| 61 |
+
LZMA_STREAM_END = 1,
|
| 62 |
+
/**<
|
| 63 |
+
* \brief End of stream was reached
|
| 64 |
+
*
|
| 65 |
+
* In encoder, LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, or
|
| 66 |
+
* LZMA_FINISH was finished. In decoder, this indicates
|
| 67 |
+
* that all the data was successfully decoded.
|
| 68 |
+
*
|
| 69 |
+
* In all cases, when LZMA_STREAM_END is returned, the last
|
| 70 |
+
* output bytes should be picked from strm->next_out.
|
| 71 |
+
*/
|
| 72 |
+
|
| 73 |
+
LZMA_NO_CHECK = 2,
|
| 74 |
+
/**<
|
| 75 |
+
* \brief Input stream has no integrity check
|
| 76 |
+
*
|
| 77 |
+
* This return value can be returned only if the
|
| 78 |
+
* LZMA_TELL_NO_CHECK flag was used when initializing
|
| 79 |
+
* the decoder. LZMA_NO_CHECK is just a warning, and
|
| 80 |
+
* the decoding can be continued normally.
|
| 81 |
+
*
|
| 82 |
+
* It is possible to call lzma_get_check() immediately after
|
| 83 |
+
* lzma_code has returned LZMA_NO_CHECK. The result will
|
| 84 |
+
* naturally be LZMA_CHECK_NONE, but the possibility to call
|
| 85 |
+
* lzma_get_check() may be convenient in some applications.
|
| 86 |
+
*/
|
| 87 |
+
|
| 88 |
+
LZMA_UNSUPPORTED_CHECK = 3,
|
| 89 |
+
/**<
|
| 90 |
+
* \brief Cannot calculate the integrity check
|
| 91 |
+
*
|
| 92 |
+
* The usage of this return value is different in encoders
|
| 93 |
+
* and decoders.
|
| 94 |
+
*
|
| 95 |
+
* Encoders can return this value only from the initialization
|
| 96 |
+
* function. If initialization fails with this value, the
|
| 97 |
+
* encoding cannot be done, because there's no way to produce
|
| 98 |
+
* output with the correct integrity check.
|
| 99 |
+
*
|
| 100 |
+
* Decoders can return this value only from lzma_code() and
|
| 101 |
+
* only if the LZMA_TELL_UNSUPPORTED_CHECK flag was used when
|
| 102 |
+
* initializing the decoder. The decoding can still be
|
| 103 |
+
* continued normally even if the check type is unsupported,
|
| 104 |
+
* but naturally the check will not be validated, and possible
|
| 105 |
+
* errors may go undetected.
|
| 106 |
+
*
|
| 107 |
+
* With decoder, it is possible to call lzma_get_check()
|
| 108 |
+
* immediately after lzma_code() has returned
|
| 109 |
+
* LZMA_UNSUPPORTED_CHECK. This way it is possible to find
|
| 110 |
+
* out what the unsupported Check ID was.
|
| 111 |
+
*/
|
| 112 |
+
|
| 113 |
+
LZMA_GET_CHECK = 4,
|
| 114 |
+
/**<
|
| 115 |
+
* \brief Integrity check type is now available
|
| 116 |
+
*
|
| 117 |
+
* This value can be returned only by the lzma_code() function
|
| 118 |
+
* and only if the decoder was initialized with the
|
| 119 |
+
* LZMA_TELL_ANY_CHECK flag. LZMA_GET_CHECK tells the
|
| 120 |
+
* application that it may now call lzma_get_check() to find
|
| 121 |
+
* out the Check ID. This can be used, for example, to
|
| 122 |
+
* implement a decoder that accepts only files that have
|
| 123 |
+
* strong enough integrity check.
|
| 124 |
+
*/
|
| 125 |
+
|
| 126 |
+
LZMA_MEM_ERROR = 5,
|
| 127 |
+
/**<
|
| 128 |
+
* \brief Cannot allocate memory
|
| 129 |
+
*
|
| 130 |
+
* Memory allocation failed, or the size of the allocation
|
| 131 |
+
* would be greater than SIZE_MAX.
|
| 132 |
+
*
|
| 133 |
+
* Due to internal implementation reasons, the coding cannot
|
| 134 |
+
* be continued even if more memory were made available after
|
| 135 |
+
* LZMA_MEM_ERROR.
|
| 136 |
+
*/
|
| 137 |
+
|
| 138 |
+
LZMA_MEMLIMIT_ERROR = 6,
|
| 139 |
+
/**<
|
| 140 |
+
* \brief Memory usage limit was reached
|
| 141 |
+
*
|
| 142 |
+
* Decoder would need more memory than allowed by the
|
| 143 |
+
* specified memory usage limit. To continue decoding,
|
| 144 |
+
* the memory usage limit has to be increased with
|
| 145 |
+
* lzma_memlimit_set().
|
| 146 |
+
*
|
| 147 |
+
* liblzma 5.2.6 and earlier had a bug in single-threaded .xz
|
| 148 |
+
* decoder (lzma_stream_decoder()) which made it impossible
|
| 149 |
+
* to continue decoding after LZMA_MEMLIMIT_ERROR even if
|
| 150 |
+
* the limit was increased using lzma_memlimit_set().
|
| 151 |
+
* Other decoders worked correctly.
|
| 152 |
+
*/
|
| 153 |
+
|
| 154 |
+
LZMA_FORMAT_ERROR = 7,
|
| 155 |
+
/**<
|
| 156 |
+
* \brief File format not recognized
|
| 157 |
+
*
|
| 158 |
+
* The decoder did not recognize the input as supported file
|
| 159 |
+
* format. This error can occur, for example, when trying to
|
| 160 |
+
* decode .lzma format file with lzma_stream_decoder,
|
| 161 |
+
* because lzma_stream_decoder accepts only the .xz format.
|
| 162 |
+
*/
|
| 163 |
+
|
| 164 |
+
LZMA_OPTIONS_ERROR = 8,
|
| 165 |
+
/**<
|
| 166 |
+
* \brief Invalid or unsupported options
|
| 167 |
+
*
|
| 168 |
+
* Invalid or unsupported options, for example
|
| 169 |
+
* - unsupported filter(s) or filter options; or
|
| 170 |
+
* - reserved bits set in headers (decoder only).
|
| 171 |
+
*
|
| 172 |
+
* Rebuilding liblzma with more features enabled, or
|
| 173 |
+
* upgrading to a newer version of liblzma may help.
|
| 174 |
+
*/
|
| 175 |
+
|
| 176 |
+
LZMA_DATA_ERROR = 9,
|
| 177 |
+
/**<
|
| 178 |
+
* \brief Data is corrupt
|
| 179 |
+
*
|
| 180 |
+
* The usage of this return value is different in encoders
|
| 181 |
+
* and decoders. In both encoder and decoder, the coding
|
| 182 |
+
* cannot continue after this error.
|
| 183 |
+
*
|
| 184 |
+
* Encoders return this if size limits of the target file
|
| 185 |
+
* format would be exceeded. These limits are huge, thus
|
| 186 |
+
* getting this error from an encoder is mostly theoretical.
|
| 187 |
+
* For example, the maximum compressed and uncompressed
|
| 188 |
+
* size of a .xz Stream is roughly 8 EiB (2^63 bytes).
|
| 189 |
+
*
|
| 190 |
+
* Decoders return this error if the input data is corrupt.
|
| 191 |
+
* This can mean, for example, invalid CRC32 in headers
|
| 192 |
+
* or invalid check of uncompressed data.
|
| 193 |
+
*/
|
| 194 |
+
|
| 195 |
+
LZMA_BUF_ERROR = 10,
|
| 196 |
+
/**<
|
| 197 |
+
* \brief No progress is possible
|
| 198 |
+
*
|
| 199 |
+
* This error code is returned when the coder cannot consume
|
| 200 |
+
* any new input and produce any new output. The most common
|
| 201 |
+
* reason for this error is that the input stream being
|
| 202 |
+
* decoded is truncated or corrupt.
|
| 203 |
+
*
|
| 204 |
+
* This error is not fatal. Coding can be continued normally
|
| 205 |
+
* by providing more input and/or more output space, if
|
| 206 |
+
* possible.
|
| 207 |
+
*
|
| 208 |
+
* Typically the first call to lzma_code() that can do no
|
| 209 |
+
* progress returns LZMA_OK instead of LZMA_BUF_ERROR. Only
|
| 210 |
+
* the second consecutive call doing no progress will return
|
| 211 |
+
* LZMA_BUF_ERROR. This is intentional.
|
| 212 |
+
*
|
| 213 |
+
* With zlib, Z_BUF_ERROR may be returned even if the
|
| 214 |
+
* application is doing nothing wrong, so apps will need
|
| 215 |
+
* to handle Z_BUF_ERROR specially. The above hack
|
| 216 |
+
* guarantees that liblzma never returns LZMA_BUF_ERROR
|
| 217 |
+
* to properly written applications unless the input file
|
| 218 |
+
* is truncated or corrupt. This should simplify the
|
| 219 |
+
* applications a little.
|
| 220 |
+
*/
|
| 221 |
+
|
| 222 |
+
LZMA_PROG_ERROR = 11,
|
| 223 |
+
/**<
|
| 224 |
+
* \brief Programming error
|
| 225 |
+
*
|
| 226 |
+
* This indicates that the arguments given to the function are
|
| 227 |
+
* invalid or the internal state of the decoder is corrupt.
|
| 228 |
+
* - Function arguments are invalid or the structures
|
| 229 |
+
* pointed by the argument pointers are invalid
|
| 230 |
+
* e.g. if strm->next_out has been set to NULL and
|
| 231 |
+
* strm->avail_out > 0 when calling lzma_code().
|
| 232 |
+
* - lzma_* functions have been called in wrong order
|
| 233 |
+
* e.g. lzma_code() was called right after lzma_end().
|
| 234 |
+
* - If errors occur randomly, the reason might be flaky
|
| 235 |
+
* hardware.
|
| 236 |
+
*
|
| 237 |
+
* If you think that your code is correct, this error code
|
| 238 |
+
* can be a sign of a bug in liblzma. See the documentation
|
| 239 |
+
* how to report bugs.
|
| 240 |
+
*/
|
| 241 |
+
|
| 242 |
+
LZMA_SEEK_NEEDED = 12,
|
| 243 |
+
/**<
|
| 244 |
+
* \brief Request to change the input file position
|
| 245 |
+
*
|
| 246 |
+
* Some coders can do random access in the input file. The
|
| 247 |
+
* initialization functions of these coders take the file size
|
| 248 |
+
* as an argument. No other coders can return LZMA_SEEK_NEEDED.
|
| 249 |
+
*
|
| 250 |
+
* When this value is returned, the application must seek to
|
| 251 |
+
* the file position given in lzma_stream.seek_pos. This value
|
| 252 |
+
* is guaranteed to never exceed the file size that was
|
| 253 |
+
* specified at the coder initialization.
|
| 254 |
+
*
|
| 255 |
+
* After seeking the application should read new input and
|
| 256 |
+
* pass it normally via lzma_stream.next_in and .avail_in.
|
| 257 |
+
*/
|
| 258 |
+
|
| 259 |
+
/*
|
| 260 |
+
* These enumerations may be used internally by liblzma
|
| 261 |
+
* but they will never be returned to applications.
|
| 262 |
+
*/
|
| 263 |
+
LZMA_RET_INTERNAL1 = 101,
|
| 264 |
+
LZMA_RET_INTERNAL2 = 102,
|
| 265 |
+
LZMA_RET_INTERNAL3 = 103,
|
| 266 |
+
LZMA_RET_INTERNAL4 = 104,
|
| 267 |
+
LZMA_RET_INTERNAL5 = 105,
|
| 268 |
+
LZMA_RET_INTERNAL6 = 106,
|
| 269 |
+
LZMA_RET_INTERNAL7 = 107,
|
| 270 |
+
LZMA_RET_INTERNAL8 = 108
|
| 271 |
+
} lzma_ret;
|
| 272 |
+
|
| 273 |
+
|
| 274 |
+
/**
|
| 275 |
+
* \brief The 'action' argument for lzma_code()
|
| 276 |
+
*
|
| 277 |
+
* After the first use of LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, LZMA_FULL_BARRIER,
|
| 278 |
+
* or LZMA_FINISH, the same 'action' must be used until lzma_code() returns
|
| 279 |
+
* LZMA_STREAM_END. Also, the amount of input (that is, strm->avail_in) must
|
| 280 |
+
* not be modified by the application until lzma_code() returns
|
| 281 |
+
* LZMA_STREAM_END. Changing the 'action' or modifying the amount of input
|
| 282 |
+
* will make lzma_code() return LZMA_PROG_ERROR.
|
| 283 |
+
*/
|
| 284 |
+
typedef enum {
|
| 285 |
+
LZMA_RUN = 0,
|
| 286 |
+
/**<
|
| 287 |
+
* \brief Continue coding
|
| 288 |
+
*
|
| 289 |
+
* Encoder: Encode as much input as possible. Some internal
|
| 290 |
+
* buffering will probably be done (depends on the filter
|
| 291 |
+
* chain in use), which causes latency: the input used won't
|
| 292 |
+
* usually be decodeable from the output of the same
|
| 293 |
+
* lzma_code() call.
|
| 294 |
+
*
|
| 295 |
+
* Decoder: Decode as much input as possible and produce as
|
| 296 |
+
* much output as possible.
|
| 297 |
+
*/
|
| 298 |
+
|
| 299 |
+
LZMA_SYNC_FLUSH = 1,
|
| 300 |
+
/**<
|
| 301 |
+
* \brief Make all the input available at output
|
| 302 |
+
*
|
| 303 |
+
* Normally the encoder introduces some latency.
|
| 304 |
+
* LZMA_SYNC_FLUSH forces all the buffered data to be
|
| 305 |
+
* available at output without resetting the internal
|
| 306 |
+
* state of the encoder. This way it is possible to use
|
| 307 |
+
* compressed stream for example for communication over
|
| 308 |
+
* network.
|
| 309 |
+
*
|
| 310 |
+
* Only some filters support LZMA_SYNC_FLUSH. Trying to use
|
| 311 |
+
* LZMA_SYNC_FLUSH with filters that don't support it will
|
| 312 |
+
* make lzma_code() return LZMA_OPTIONS_ERROR. For example,
|
| 313 |
+
* LZMA1 doesn't support LZMA_SYNC_FLUSH but LZMA2 does.
|
| 314 |
+
*
|
| 315 |
+
* Using LZMA_SYNC_FLUSH very often can dramatically reduce
|
| 316 |
+
* the compression ratio. With some filters (for example,
|
| 317 |
+
* LZMA2), fine-tuning the compression options may help
|
| 318 |
+
* mitigate this problem significantly (for example,
|
| 319 |
+
* match finder with LZMA2).
|
| 320 |
+
*
|
| 321 |
+
* Decoders don't support LZMA_SYNC_FLUSH.
|
| 322 |
+
*/
|
| 323 |
+
|
| 324 |
+
LZMA_FULL_FLUSH = 2,
|
| 325 |
+
/**<
|
| 326 |
+
* \brief Finish encoding of the current Block
|
| 327 |
+
*
|
| 328 |
+
* All the input data going to the current Block must have
|
| 329 |
+
* been given to the encoder (the last bytes can still be
|
| 330 |
+
* pending in *next_in). Call lzma_code() with LZMA_FULL_FLUSH
|
| 331 |
+
* until it returns LZMA_STREAM_END. Then continue normally
|
| 332 |
+
* with LZMA_RUN or finish the Stream with LZMA_FINISH.
|
| 333 |
+
*
|
| 334 |
+
* This action is currently supported only by Stream encoder
|
| 335 |
+
* and easy encoder (which uses Stream encoder). If there is
|
| 336 |
+
* no unfinished Block, no empty Block is created.
|
| 337 |
+
*/
|
| 338 |
+
|
| 339 |
+
LZMA_FULL_BARRIER = 4,
|
| 340 |
+
/**<
|
| 341 |
+
* \brief Finish encoding of the current Block
|
| 342 |
+
*
|
| 343 |
+
* This is like LZMA_FULL_FLUSH except that this doesn't
|
| 344 |
+
* necessarily wait until all the input has been made
|
| 345 |
+
* available via the output buffer. That is, lzma_code()
|
| 346 |
+
* might return LZMA_STREAM_END as soon as all the input
|
| 347 |
+
* has been consumed (avail_in == 0).
|
| 348 |
+
*
|
| 349 |
+
* LZMA_FULL_BARRIER is useful with a threaded encoder if
|
| 350 |
+
* one wants to split the .xz Stream into Blocks at specific
|
| 351 |
+
* offsets but doesn't care if the output isn't flushed
|
| 352 |
+
* immediately. Using LZMA_FULL_BARRIER allows keeping
|
| 353 |
+
* the threads busy while LZMA_FULL_FLUSH would make
|
| 354 |
+
* lzma_code() wait until all the threads have finished
|
| 355 |
+
* until more data could be passed to the encoder.
|
| 356 |
+
*
|
| 357 |
+
* With a lzma_stream initialized with the single-threaded
|
| 358 |
+
* lzma_stream_encoder() or lzma_easy_encoder(),
|
| 359 |
+
* LZMA_FULL_BARRIER is an alias for LZMA_FULL_FLUSH.
|
| 360 |
+
*/
|
| 361 |
+
|
| 362 |
+
LZMA_FINISH = 3
|
| 363 |
+
/**<
|
| 364 |
+
* \brief Finish the coding operation
|
| 365 |
+
*
|
| 366 |
+
* All the input data must have been given to the encoder
|
| 367 |
+
* (the last bytes can still be pending in next_in).
|
| 368 |
+
* Call lzma_code() with LZMA_FINISH until it returns
|
| 369 |
+
* LZMA_STREAM_END. Once LZMA_FINISH has been used,
|
| 370 |
+
* the amount of input must no longer be changed by
|
| 371 |
+
* the application.
|
| 372 |
+
*
|
| 373 |
+
* When decoding, using LZMA_FINISH is optional unless the
|
| 374 |
+
* LZMA_CONCATENATED flag was used when the decoder was
|
| 375 |
+
* initialized. When LZMA_CONCATENATED was not used, the only
|
| 376 |
+
* effect of LZMA_FINISH is that the amount of input must not
|
| 377 |
+
* be changed just like in the encoder.
|
| 378 |
+
*/
|
| 379 |
+
} lzma_action;
|
| 380 |
+
|
| 381 |
+
|
| 382 |
+
/**
|
| 383 |
+
* \brief Custom functions for memory handling
|
| 384 |
+
*
|
| 385 |
+
* A pointer to lzma_allocator may be passed via lzma_stream structure
|
| 386 |
+
* to liblzma, and some advanced functions take a pointer to lzma_allocator
|
| 387 |
+
* as a separate function argument. The library will use the functions
|
| 388 |
+
* specified in lzma_allocator for memory handling instead of the default
|
| 389 |
+
* malloc() and free(). C++ users should note that the custom memory
|
| 390 |
+
* handling functions must not throw exceptions.
|
| 391 |
+
*
|
| 392 |
+
* Single-threaded mode only: liblzma doesn't make an internal copy of
|
| 393 |
+
* lzma_allocator. Thus, it is OK to change these function pointers in
|
| 394 |
+
* the middle of the coding process, but obviously it must be done
|
| 395 |
+
* carefully to make sure that the replacement 'free' can deallocate
|
| 396 |
+
* memory allocated by the earlier 'alloc' function(s).
|
| 397 |
+
*
|
| 398 |
+
* Multithreaded mode: liblzma might internally store pointers to the
|
| 399 |
+
* lzma_allocator given via the lzma_stream structure. The application
|
| 400 |
+
* must not change the allocator pointer in lzma_stream or the contents
|
| 401 |
+
* of the pointed lzma_allocator structure until lzma_end() has been used
|
| 402 |
+
* to free the memory associated with that lzma_stream. The allocation
|
| 403 |
+
* functions might be called simultaneously from multiple threads, and
|
| 404 |
+
* thus they must be thread safe.
|
| 405 |
+
*/
|
| 406 |
+
typedef struct {
|
| 407 |
+
/**
|
| 408 |
+
* \brief Pointer to a custom memory allocation function
|
| 409 |
+
*
|
| 410 |
+
* If you don't want a custom allocator, but still want
|
| 411 |
+
* custom free(), set this to NULL and liblzma will use
|
| 412 |
+
* the standard malloc().
|
| 413 |
+
*
|
| 414 |
+
* \param opaque lzma_allocator.opaque (see below)
|
| 415 |
+
* \param nmemb Number of elements like in calloc(). liblzma
|
| 416 |
+
* will always set nmemb to 1, so it is safe to
|
| 417 |
+
* ignore nmemb in a custom allocator if you like.
|
| 418 |
+
* The nmemb argument exists only for
|
| 419 |
+
* compatibility with zlib and libbzip2.
|
| 420 |
+
* \param size Size of an element in bytes.
|
| 421 |
+
* liblzma never sets this to zero.
|
| 422 |
+
*
|
| 423 |
+
* \return Pointer to the beginning of a memory block of
|
| 424 |
+
* 'size' bytes, or NULL if allocation fails
|
| 425 |
+
* for some reason. When allocation fails, functions
|
| 426 |
+
* of liblzma return LZMA_MEM_ERROR.
|
| 427 |
+
*
|
| 428 |
+
* The allocator should not waste time zeroing the allocated buffers.
|
| 429 |
+
* This is not only about speed, but also memory usage, since the
|
| 430 |
+
* operating system kernel doesn't necessarily allocate the requested
|
| 431 |
+
* memory in physical memory until it is actually used. With small
|
| 432 |
+
* input files, liblzma may actually need only a fraction of the
|
| 433 |
+
* memory that it requested for allocation.
|
| 434 |
+
*
|
| 435 |
+
* \note LZMA_MEM_ERROR is also used when the size of the
|
| 436 |
+
* allocation would be greater than SIZE_MAX. Thus,
|
| 437 |
+
* don't assume that the custom allocator must have
|
| 438 |
+
* returned NULL if some function from liblzma
|
| 439 |
+
* returns LZMA_MEM_ERROR.
|
| 440 |
+
*/
|
| 441 |
+
void *(LZMA_API_CALL *alloc)(void *opaque, size_t nmemb, size_t size);
|
| 442 |
+
|
| 443 |
+
/**
|
| 444 |
+
* \brief Pointer to a custom memory freeing function
|
| 445 |
+
*
|
| 446 |
+
* If you don't want a custom freeing function, but still
|
| 447 |
+
* want a custom allocator, set this to NULL and liblzma
|
| 448 |
+
* will use the standard free().
|
| 449 |
+
*
|
| 450 |
+
* \param opaque lzma_allocator.opaque (see below)
|
| 451 |
+
* \param ptr Pointer returned by lzma_allocator.alloc(),
|
| 452 |
+
* or when it is set to NULL, a pointer returned
|
| 453 |
+
* by the standard malloc().
|
| 454 |
+
*/
|
| 455 |
+
void (LZMA_API_CALL *free)(void *opaque, void *ptr);
|
| 456 |
+
|
| 457 |
+
/**
|
| 458 |
+
* \brief Pointer passed to .alloc() and .free()
|
| 459 |
+
*
|
| 460 |
+
* opaque is passed as the first argument to lzma_allocator.alloc()
|
| 461 |
+
* and lzma_allocator.free(). This intended to ease implementing
|
| 462 |
+
* custom memory allocation functions for use with liblzma.
|
| 463 |
+
*
|
| 464 |
+
* If you don't need this, you should set this to NULL.
|
| 465 |
+
*/
|
| 466 |
+
void *opaque;
|
| 467 |
+
|
| 468 |
+
} lzma_allocator;
|
| 469 |
+
|
| 470 |
+
|
| 471 |
+
/**
|
| 472 |
+
* \brief Internal data structure
|
| 473 |
+
*
|
| 474 |
+
* The contents of this structure is not visible outside the library.
|
| 475 |
+
*/
|
| 476 |
+
typedef struct lzma_internal_s lzma_internal;
|
| 477 |
+
|
| 478 |
+
|
| 479 |
+
/**
|
| 480 |
+
* \brief Passing data to and from liblzma
|
| 481 |
+
*
|
| 482 |
+
* The lzma_stream structure is used for
|
| 483 |
+
* - passing pointers to input and output buffers to liblzma;
|
| 484 |
+
* - defining custom memory handler functions; and
|
| 485 |
+
* - holding a pointer to coder-specific internal data structures.
|
| 486 |
+
*
|
| 487 |
+
* Typical usage:
|
| 488 |
+
*
|
| 489 |
+
* - After allocating lzma_stream (on stack or with malloc()), it must be
|
| 490 |
+
* initialized to LZMA_STREAM_INIT (see LZMA_STREAM_INIT for details).
|
| 491 |
+
*
|
| 492 |
+
* - Initialize a coder to the lzma_stream, for example by using
|
| 493 |
+
* lzma_easy_encoder() or lzma_auto_decoder(). Some notes:
|
| 494 |
+
* - In contrast to zlib, strm->next_in and strm->next_out are
|
| 495 |
+
* ignored by all initialization functions, thus it is safe
|
| 496 |
+
* to not initialize them yet.
|
| 497 |
+
* - The initialization functions always set strm->total_in and
|
| 498 |
+
* strm->total_out to zero.
|
| 499 |
+
* - If the initialization function fails, no memory is left allocated
|
| 500 |
+
* that would require freeing with lzma_end() even if some memory was
|
| 501 |
+
* associated with the lzma_stream structure when the initialization
|
| 502 |
+
* function was called.
|
| 503 |
+
*
|
| 504 |
+
* - Use lzma_code() to do the actual work.
|
| 505 |
+
*
|
| 506 |
+
* - Once the coding has been finished, the existing lzma_stream can be
|
| 507 |
+
* reused. It is OK to reuse lzma_stream with different initialization
|
| 508 |
+
* function without calling lzma_end() first. Old allocations are
|
| 509 |
+
* automatically freed.
|
| 510 |
+
*
|
| 511 |
+
* - Finally, use lzma_end() to free the allocated memory. lzma_end() never
|
| 512 |
+
* frees the lzma_stream structure itself.
|
| 513 |
+
*
|
| 514 |
+
* Application may modify the values of total_in and total_out as it wants.
|
| 515 |
+
* They are updated by liblzma to match the amount of data read and
|
| 516 |
+
* written but aren't used for anything else except as a possible return
|
| 517 |
+
* values from lzma_get_progress().
|
| 518 |
+
*/
|
| 519 |
+
typedef struct {
|
| 520 |
+
const uint8_t *next_in; /**< Pointer to the next input byte. */
|
| 521 |
+
size_t avail_in; /**< Number of available input bytes in next_in. */
|
| 522 |
+
uint64_t total_in; /**< Total number of bytes read by liblzma. */
|
| 523 |
+
|
| 524 |
+
uint8_t *next_out; /**< Pointer to the next output position. */
|
| 525 |
+
size_t avail_out; /**< Amount of free space in next_out. */
|
| 526 |
+
uint64_t total_out; /**< Total number of bytes written by liblzma. */
|
| 527 |
+
|
| 528 |
+
/**
|
| 529 |
+
* \brief Custom memory allocation functions
|
| 530 |
+
*
|
| 531 |
+
* In most cases this is NULL which makes liblzma use
|
| 532 |
+
* the standard malloc() and free().
|
| 533 |
+
*
|
| 534 |
+
* \note In 5.0.x this is not a const pointer.
|
| 535 |
+
*/
|
| 536 |
+
const lzma_allocator *allocator;
|
| 537 |
+
|
| 538 |
+
/** Internal state is not visible to applications. */
|
| 539 |
+
lzma_internal *internal;
|
| 540 |
+
|
| 541 |
+
/*
|
| 542 |
+
* Reserved space to allow possible future extensions without
|
| 543 |
+
* breaking the ABI. Excluding the initialization of this structure,
|
| 544 |
+
* you should not touch these, because the names of these variables
|
| 545 |
+
* may change.
|
| 546 |
+
*/
|
| 547 |
+
|
| 548 |
+
/** \private Reserved member. */
|
| 549 |
+
void *reserved_ptr1;
|
| 550 |
+
|
| 551 |
+
/** \private Reserved member. */
|
| 552 |
+
void *reserved_ptr2;
|
| 553 |
+
|
| 554 |
+
/** \private Reserved member. */
|
| 555 |
+
void *reserved_ptr3;
|
| 556 |
+
|
| 557 |
+
/** \private Reserved member. */
|
| 558 |
+
void *reserved_ptr4;
|
| 559 |
+
|
| 560 |
+
/**
|
| 561 |
+
* \brief New seek input position for LZMA_SEEK_NEEDED
|
| 562 |
+
*
|
| 563 |
+
* When lzma_code() returns LZMA_SEEK_NEEDED, the new input position
|
| 564 |
+
* needed by liblzma will be available seek_pos. The value is
|
| 565 |
+
* guaranteed to not exceed the file size that was specified when
|
| 566 |
+
* this lzma_stream was initialized.
|
| 567 |
+
*
|
| 568 |
+
* In all other situations the value of this variable is undefined.
|
| 569 |
+
*/
|
| 570 |
+
uint64_t seek_pos;
|
| 571 |
+
|
| 572 |
+
/** \private Reserved member. */
|
| 573 |
+
uint64_t reserved_int2;
|
| 574 |
+
|
| 575 |
+
/** \private Reserved member. */
|
| 576 |
+
size_t reserved_int3;
|
| 577 |
+
|
| 578 |
+
/** \private Reserved member. */
|
| 579 |
+
size_t reserved_int4;
|
| 580 |
+
|
| 581 |
+
/** \private Reserved member. */
|
| 582 |
+
lzma_reserved_enum reserved_enum1;
|
| 583 |
+
|
| 584 |
+
/** \private Reserved member. */
|
| 585 |
+
lzma_reserved_enum reserved_enum2;
|
| 586 |
+
|
| 587 |
+
} lzma_stream;
|
| 588 |
+
|
| 589 |
+
|
| 590 |
+
/**
|
| 591 |
+
* \brief Initialization for lzma_stream
|
| 592 |
+
*
|
| 593 |
+
* When you declare an instance of lzma_stream, you can immediately
|
| 594 |
+
* initialize it so that initialization functions know that no memory
|
| 595 |
+
* has been allocated yet:
|
| 596 |
+
*
|
| 597 |
+
* lzma_stream strm = LZMA_STREAM_INIT;
|
| 598 |
+
*
|
| 599 |
+
* If you need to initialize a dynamically allocated lzma_stream, you can use
|
| 600 |
+
* memset(strm_pointer, 0, sizeof(lzma_stream)). Strictly speaking, this
|
| 601 |
+
* violates the C standard since NULL may have different internal
|
| 602 |
+
* representation than zero, but it should be portable enough in practice.
|
| 603 |
+
* Anyway, for maximum portability, you can use something like this:
|
| 604 |
+
*
|
| 605 |
+
* lzma_stream tmp = LZMA_STREAM_INIT;
|
| 606 |
+
* *strm = tmp;
|
| 607 |
+
*/
|
| 608 |
+
#define LZMA_STREAM_INIT \
|
| 609 |
+
{ NULL, 0, 0, NULL, 0, 0, NULL, NULL, \
|
| 610 |
+
NULL, NULL, NULL, NULL, 0, 0, 0, 0, \
|
| 611 |
+
LZMA_RESERVED_ENUM, LZMA_RESERVED_ENUM }
|
| 612 |
+
|
| 613 |
+
|
| 614 |
+
/**
|
| 615 |
+
* \brief Encode or decode data
|
| 616 |
+
*
|
| 617 |
+
* Once the lzma_stream has been successfully initialized (e.g. with
|
| 618 |
+
* lzma_stream_encoder()), the actual encoding or decoding is done
|
| 619 |
+
* using this function. The application has to update strm->next_in,
|
| 620 |
+
* strm->avail_in, strm->next_out, and strm->avail_out to pass input
|
| 621 |
+
* to and get output from liblzma.
|
| 622 |
+
*
|
| 623 |
+
* See the description of the coder-specific initialization function to find
|
| 624 |
+
* out what 'action' values are supported by the coder.
|
| 625 |
+
*
|
| 626 |
+
* \param strm Pointer to lzma_stream that is at least initialized
|
| 627 |
+
* with LZMA_STREAM_INIT.
|
| 628 |
+
* \param action Action for this function to take. Must be a valid
|
| 629 |
+
* lzma_action enum value.
|
| 630 |
+
*
|
| 631 |
+
* \return Any valid lzma_ret. See the lzma_ret enum description for more
|
| 632 |
+
* information.
|
| 633 |
+
*/
|
| 634 |
+
extern LZMA_API(lzma_ret) lzma_code(lzma_stream *strm, lzma_action action)
|
| 635 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 636 |
+
|
| 637 |
+
|
| 638 |
+
/**
|
| 639 |
+
* \brief Free memory allocated for the coder data structures
|
| 640 |
+
*
|
| 641 |
+
* After lzma_end(strm), strm->internal is guaranteed to be NULL. No other
|
| 642 |
+
* members of the lzma_stream structure are touched.
|
| 643 |
+
*
|
| 644 |
+
* \note zlib indicates an error if application end()s unfinished
|
| 645 |
+
* stream structure. liblzma doesn't do this, and assumes that
|
| 646 |
+
* application knows what it is doing.
|
| 647 |
+
*
|
| 648 |
+
* \param strm Pointer to lzma_stream that is at least initialized
|
| 649 |
+
* with LZMA_STREAM_INIT.
|
| 650 |
+
*/
|
| 651 |
+
extern LZMA_API(void) lzma_end(lzma_stream *strm) lzma_nothrow;
|
| 652 |
+
|
| 653 |
+
|
| 654 |
+
/**
|
| 655 |
+
* \brief Get progress information
|
| 656 |
+
*
|
| 657 |
+
* In single-threaded mode, applications can get progress information from
|
| 658 |
+
* strm->total_in and strm->total_out. In multi-threaded mode this is less
|
| 659 |
+
* useful because a significant amount of both input and output data gets
|
| 660 |
+
* buffered internally by liblzma. This makes total_in and total_out give
|
| 661 |
+
* misleading information and also makes the progress indicator updates
|
| 662 |
+
* non-smooth.
|
| 663 |
+
*
|
| 664 |
+
* This function gives realistic progress information also in multi-threaded
|
| 665 |
+
* mode by taking into account the progress made by each thread. In
|
| 666 |
+
* single-threaded mode *progress_in and *progress_out are set to
|
| 667 |
+
* strm->total_in and strm->total_out, respectively.
|
| 668 |
+
*
|
| 669 |
+
* \param strm Pointer to lzma_stream that is at least
|
| 670 |
+
* initialized with LZMA_STREAM_INIT.
|
| 671 |
+
* \param[out] progress_in Pointer to the number of input bytes processed.
|
| 672 |
+
* \param[out] progress_out Pointer to the number of output bytes processed.
|
| 673 |
+
*/
|
| 674 |
+
extern LZMA_API(void) lzma_get_progress(lzma_stream *strm,
|
| 675 |
+
uint64_t *progress_in, uint64_t *progress_out) lzma_nothrow;
|
| 676 |
+
|
| 677 |
+
|
| 678 |
+
/**
|
| 679 |
+
* \brief Get the memory usage of decoder filter chain
|
| 680 |
+
*
|
| 681 |
+
* This function is currently supported only when *strm has been initialized
|
| 682 |
+
* with a function that takes a memlimit argument. With other functions, you
|
| 683 |
+
* should use e.g. lzma_raw_encoder_memusage() or lzma_raw_decoder_memusage()
|
| 684 |
+
* to estimate the memory requirements.
|
| 685 |
+
*
|
| 686 |
+
* This function is useful e.g. after LZMA_MEMLIMIT_ERROR to find out how big
|
| 687 |
+
* the memory usage limit should have been to decode the input. Note that
|
| 688 |
+
* this may give misleading information if decoding .xz Streams that have
|
| 689 |
+
* multiple Blocks, because each Block can have different memory requirements.
|
| 690 |
+
*
|
| 691 |
+
* \param strm Pointer to lzma_stream that is at least initialized
|
| 692 |
+
* with LZMA_STREAM_INIT.
|
| 693 |
+
*
|
| 694 |
+
* \return How much memory is currently allocated for the filter
|
| 695 |
+
* decoders. If no filter chain is currently allocated,
|
| 696 |
+
* some non-zero value is still returned, which is less than
|
| 697 |
+
* or equal to what any filter chain would indicate as its
|
| 698 |
+
* memory requirement.
|
| 699 |
+
*
|
| 700 |
+
* If this function isn't supported by *strm or some other error
|
| 701 |
+
* occurs, zero is returned.
|
| 702 |
+
*/
|
| 703 |
+
extern LZMA_API(uint64_t) lzma_memusage(const lzma_stream *strm)
|
| 704 |
+
lzma_nothrow lzma_attr_pure;
|
| 705 |
+
|
| 706 |
+
|
| 707 |
+
/**
|
| 708 |
+
* \brief Get the current memory usage limit
|
| 709 |
+
*
|
| 710 |
+
* This function is supported only when *strm has been initialized with
|
| 711 |
+
* a function that takes a memlimit argument.
|
| 712 |
+
*
|
| 713 |
+
* \param strm Pointer to lzma_stream that is at least initialized
|
| 714 |
+
* with LZMA_STREAM_INIT.
|
| 715 |
+
*
|
| 716 |
+
* \return On success, the current memory usage limit is returned
|
| 717 |
+
* (always non-zero). On error, zero is returned.
|
| 718 |
+
*/
|
| 719 |
+
extern LZMA_API(uint64_t) lzma_memlimit_get(const lzma_stream *strm)
|
| 720 |
+
lzma_nothrow lzma_attr_pure;
|
| 721 |
+
|
| 722 |
+
|
| 723 |
+
/**
|
| 724 |
+
* \brief Set the memory usage limit
|
| 725 |
+
*
|
| 726 |
+
* This function is supported only when *strm has been initialized with
|
| 727 |
+
* a function that takes a memlimit argument.
|
| 728 |
+
*
|
| 729 |
+
* liblzma 5.2.3 and earlier has a bug where memlimit value of 0 causes
|
| 730 |
+
* this function to do nothing (leaving the limit unchanged) and still
|
| 731 |
+
* return LZMA_OK. Later versions treat 0 as if 1 had been specified (so
|
| 732 |
+
* lzma_memlimit_get() will return 1 even if you specify 0 here).
|
| 733 |
+
*
|
| 734 |
+
* liblzma 5.2.6 and earlier had a bug in single-threaded .xz decoder
|
| 735 |
+
* (lzma_stream_decoder()) which made it impossible to continue decoding
|
| 736 |
+
* after LZMA_MEMLIMIT_ERROR even if the limit was increased using
|
| 737 |
+
* lzma_memlimit_set(). Other decoders worked correctly.
|
| 738 |
+
*
|
| 739 |
+
* \return Possible lzma_ret values:
|
| 740 |
+
* - LZMA_OK: New memory usage limit successfully set.
|
| 741 |
+
* - LZMA_MEMLIMIT_ERROR: The new limit is too small.
|
| 742 |
+
* The limit was not changed.
|
| 743 |
+
* - LZMA_PROG_ERROR: Invalid arguments, e.g. *strm doesn't
|
| 744 |
+
* support memory usage limit.
|
| 745 |
+
*/
|
| 746 |
+
extern LZMA_API(lzma_ret) lzma_memlimit_set(
|
| 747 |
+
lzma_stream *strm, uint64_t memlimit) lzma_nothrow;
|
llava_next/include/lzma/bcj.h
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* SPDX-License-Identifier: 0BSD */
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* \file lzma/bcj.h
|
| 5 |
+
* \brief Branch/Call/Jump conversion filters
|
| 6 |
+
* \note Never include this file directly. Use <lzma.h> instead.
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
/*
|
| 10 |
+
* Author: Lasse Collin
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
#ifndef LZMA_H_INTERNAL
|
| 14 |
+
# error Never include this file directly. Use <lzma.h> instead.
|
| 15 |
+
#endif
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
/* Filter IDs for lzma_filter.id */
|
| 19 |
+
|
| 20 |
+
/**
|
| 21 |
+
* \brief Filter for x86 binaries
|
| 22 |
+
*/
|
| 23 |
+
#define LZMA_FILTER_X86 LZMA_VLI_C(0x04)
|
| 24 |
+
|
| 25 |
+
/**
|
| 26 |
+
* \brief Filter for Big endian PowerPC binaries
|
| 27 |
+
*/
|
| 28 |
+
#define LZMA_FILTER_POWERPC LZMA_VLI_C(0x05)
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* \brief Filter for IA-64 (Itanium) binaries
|
| 32 |
+
*/
|
| 33 |
+
#define LZMA_FILTER_IA64 LZMA_VLI_C(0x06)
|
| 34 |
+
|
| 35 |
+
/**
|
| 36 |
+
* \brief Filter for ARM binaries
|
| 37 |
+
*/
|
| 38 |
+
#define LZMA_FILTER_ARM LZMA_VLI_C(0x07)
|
| 39 |
+
|
| 40 |
+
/**
|
| 41 |
+
* \brief Filter for ARM-Thumb binaries
|
| 42 |
+
*/
|
| 43 |
+
#define LZMA_FILTER_ARMTHUMB LZMA_VLI_C(0x08)
|
| 44 |
+
|
| 45 |
+
/**
|
| 46 |
+
* \brief Filter for SPARC binaries
|
| 47 |
+
*/
|
| 48 |
+
#define LZMA_FILTER_SPARC LZMA_VLI_C(0x09)
|
| 49 |
+
|
| 50 |
+
/**
|
| 51 |
+
* \brief Filter for ARM64 binaries
|
| 52 |
+
*/
|
| 53 |
+
#define LZMA_FILTER_ARM64 LZMA_VLI_C(0x0A)
|
| 54 |
+
|
| 55 |
+
/**
|
| 56 |
+
* \brief Filter for RISC-V binaries
|
| 57 |
+
*/
|
| 58 |
+
#define LZMA_FILTER_RISCV LZMA_VLI_C(0x0B)
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
/**
|
| 62 |
+
* \brief Options for BCJ filters
|
| 63 |
+
*
|
| 64 |
+
* The BCJ filters never change the size of the data. Specifying options
|
| 65 |
+
* for them is optional: if pointer to options is NULL, default value is
|
| 66 |
+
* used. You probably never need to specify options to BCJ filters, so just
|
| 67 |
+
* set the options pointer to NULL and be happy.
|
| 68 |
+
*
|
| 69 |
+
* If options with non-default values have been specified when encoding,
|
| 70 |
+
* the same options must also be specified when decoding.
|
| 71 |
+
*
|
| 72 |
+
* \note At the moment, none of the BCJ filters support
|
| 73 |
+
* LZMA_SYNC_FLUSH. If LZMA_SYNC_FLUSH is specified,
|
| 74 |
+
* LZMA_OPTIONS_ERROR will be returned. If there is need,
|
| 75 |
+
* partial support for LZMA_SYNC_FLUSH can be added in future.
|
| 76 |
+
* Partial means that flushing would be possible only at
|
| 77 |
+
* offsets that are multiple of 2, 4, or 16 depending on
|
| 78 |
+
* the filter, except x86 which cannot be made to support
|
| 79 |
+
* LZMA_SYNC_FLUSH predictably.
|
| 80 |
+
*/
|
| 81 |
+
typedef struct {
|
| 82 |
+
/**
|
| 83 |
+
* \brief Start offset for conversions
|
| 84 |
+
*
|
| 85 |
+
* This setting is useful only when the same filter is used
|
| 86 |
+
* _separately_ for multiple sections of the same executable file,
|
| 87 |
+
* and the sections contain cross-section branch/call/jump
|
| 88 |
+
* instructions. In that case it is beneficial to set the start
|
| 89 |
+
* offset of the non-first sections so that the relative addresses
|
| 90 |
+
* of the cross-section branch/call/jump instructions will use the
|
| 91 |
+
* same absolute addresses as in the first section.
|
| 92 |
+
*
|
| 93 |
+
* When the pointer to options is NULL, the default value (zero)
|
| 94 |
+
* is used.
|
| 95 |
+
*/
|
| 96 |
+
uint32_t start_offset;
|
| 97 |
+
|
| 98 |
+
} lzma_options_bcj;
|
llava_next/include/lzma/block.h
ADDED
|
@@ -0,0 +1,694 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* SPDX-License-Identifier: 0BSD */
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* \file lzma/block.h
|
| 5 |
+
* \brief .xz Block handling
|
| 6 |
+
* \note Never include this file directly. Use <lzma.h> instead.
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
/*
|
| 10 |
+
* Author: Lasse Collin
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
#ifndef LZMA_H_INTERNAL
|
| 14 |
+
# error Never include this file directly. Use <lzma.h> instead.
|
| 15 |
+
#endif
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
/**
|
| 19 |
+
* \brief Options for the Block and Block Header encoders and decoders
|
| 20 |
+
*
|
| 21 |
+
* Different Block handling functions use different parts of this structure.
|
| 22 |
+
* Some read some members, other functions write, and some do both. Only the
|
| 23 |
+
* members listed for reading need to be initialized when the specified
|
| 24 |
+
* functions are called. The members marked for writing will be assigned
|
| 25 |
+
* new values at some point either by calling the given function or by
|
| 26 |
+
* later calls to lzma_code().
|
| 27 |
+
*/
|
| 28 |
+
typedef struct {
|
| 29 |
+
/**
|
| 30 |
+
* \brief Block format version
|
| 31 |
+
*
|
| 32 |
+
* To prevent API and ABI breakages when new features are needed,
|
| 33 |
+
* a version number is used to indicate which members in this
|
| 34 |
+
* structure are in use:
|
| 35 |
+
* - liblzma >= 5.0.0: version = 0 is supported.
|
| 36 |
+
* - liblzma >= 5.1.4beta: Support for version = 1 was added,
|
| 37 |
+
* which adds the ignore_check member.
|
| 38 |
+
*
|
| 39 |
+
* If version is greater than one, most Block related functions
|
| 40 |
+
* will return LZMA_OPTIONS_ERROR (lzma_block_header_decode() works
|
| 41 |
+
* with any version value).
|
| 42 |
+
*
|
| 43 |
+
* Read by:
|
| 44 |
+
* - lzma_block_header_size()
|
| 45 |
+
* - lzma_block_header_encode()
|
| 46 |
+
* - lzma_block_header_decode()
|
| 47 |
+
* - lzma_block_compressed_size()
|
| 48 |
+
* - lzma_block_unpadded_size()
|
| 49 |
+
* - lzma_block_total_size()
|
| 50 |
+
* - lzma_block_encoder()
|
| 51 |
+
* - lzma_block_decoder()
|
| 52 |
+
* - lzma_block_buffer_encode()
|
| 53 |
+
* - lzma_block_uncomp_encode()
|
| 54 |
+
* - lzma_block_buffer_decode()
|
| 55 |
+
*
|
| 56 |
+
* Written by:
|
| 57 |
+
* - lzma_block_header_decode()
|
| 58 |
+
*/
|
| 59 |
+
uint32_t version;
|
| 60 |
+
|
| 61 |
+
/**
|
| 62 |
+
* \brief Size of the Block Header field in bytes
|
| 63 |
+
*
|
| 64 |
+
* This is always a multiple of four.
|
| 65 |
+
*
|
| 66 |
+
* Read by:
|
| 67 |
+
* - lzma_block_header_encode()
|
| 68 |
+
* - lzma_block_header_decode()
|
| 69 |
+
* - lzma_block_compressed_size()
|
| 70 |
+
* - lzma_block_unpadded_size()
|
| 71 |
+
* - lzma_block_total_size()
|
| 72 |
+
* - lzma_block_decoder()
|
| 73 |
+
* - lzma_block_buffer_decode()
|
| 74 |
+
*
|
| 75 |
+
* Written by:
|
| 76 |
+
* - lzma_block_header_size()
|
| 77 |
+
* - lzma_block_buffer_encode()
|
| 78 |
+
* - lzma_block_uncomp_encode()
|
| 79 |
+
*/
|
| 80 |
+
uint32_t header_size;
|
| 81 |
+
# define LZMA_BLOCK_HEADER_SIZE_MIN 8
|
| 82 |
+
# define LZMA_BLOCK_HEADER_SIZE_MAX 1024
|
| 83 |
+
|
| 84 |
+
/**
|
| 85 |
+
* \brief Type of integrity Check
|
| 86 |
+
*
|
| 87 |
+
* The Check ID is not stored into the Block Header, thus its value
|
| 88 |
+
* must be provided also when decoding.
|
| 89 |
+
*
|
| 90 |
+
* Read by:
|
| 91 |
+
* - lzma_block_header_encode()
|
| 92 |
+
* - lzma_block_header_decode()
|
| 93 |
+
* - lzma_block_compressed_size()
|
| 94 |
+
* - lzma_block_unpadded_size()
|
| 95 |
+
* - lzma_block_total_size()
|
| 96 |
+
* - lzma_block_encoder()
|
| 97 |
+
* - lzma_block_decoder()
|
| 98 |
+
* - lzma_block_buffer_encode()
|
| 99 |
+
* - lzma_block_buffer_decode()
|
| 100 |
+
*/
|
| 101 |
+
lzma_check check;
|
| 102 |
+
|
| 103 |
+
/**
|
| 104 |
+
* \brief Size of the Compressed Data in bytes
|
| 105 |
+
*
|
| 106 |
+
* Encoding: If this is not LZMA_VLI_UNKNOWN, Block Header encoder
|
| 107 |
+
* will store this value to the Block Header. Block encoder doesn't
|
| 108 |
+
* care about this value, but will set it once the encoding has been
|
| 109 |
+
* finished.
|
| 110 |
+
*
|
| 111 |
+
* Decoding: If this is not LZMA_VLI_UNKNOWN, Block decoder will
|
| 112 |
+
* verify that the size of the Compressed Data field matches
|
| 113 |
+
* compressed_size.
|
| 114 |
+
*
|
| 115 |
+
* Usually you don't know this value when encoding in streamed mode,
|
| 116 |
+
* and thus cannot write this field into the Block Header.
|
| 117 |
+
*
|
| 118 |
+
* In non-streamed mode you can reserve space for this field before
|
| 119 |
+
* encoding the actual Block. After encoding the data, finish the
|
| 120 |
+
* Block by encoding the Block Header. Steps in detail:
|
| 121 |
+
*
|
| 122 |
+
* - Set compressed_size to some big enough value. If you don't know
|
| 123 |
+
* better, use LZMA_VLI_MAX, but remember that bigger values take
|
| 124 |
+
* more space in Block Header.
|
| 125 |
+
*
|
| 126 |
+
* - Call lzma_block_header_size() to see how much space you need to
|
| 127 |
+
* reserve for the Block Header.
|
| 128 |
+
*
|
| 129 |
+
* - Encode the Block using lzma_block_encoder() and lzma_code().
|
| 130 |
+
* It sets compressed_size to the correct value.
|
| 131 |
+
*
|
| 132 |
+
* - Use lzma_block_header_encode() to encode the Block Header.
|
| 133 |
+
* Because space was reserved in the first step, you don't need
|
| 134 |
+
* to call lzma_block_header_size() anymore, because due to
|
| 135 |
+
* reserving, header_size has to be big enough. If it is "too big",
|
| 136 |
+
* lzma_block_header_encode() will add enough Header Padding to
|
| 137 |
+
* make Block Header to match the size specified by header_size.
|
| 138 |
+
*
|
| 139 |
+
* Read by:
|
| 140 |
+
* - lzma_block_header_size()
|
| 141 |
+
* - lzma_block_header_encode()
|
| 142 |
+
* - lzma_block_compressed_size()
|
| 143 |
+
* - lzma_block_unpadded_size()
|
| 144 |
+
* - lzma_block_total_size()
|
| 145 |
+
* - lzma_block_decoder()
|
| 146 |
+
* - lzma_block_buffer_decode()
|
| 147 |
+
*
|
| 148 |
+
* Written by:
|
| 149 |
+
* - lzma_block_header_decode()
|
| 150 |
+
* - lzma_block_compressed_size()
|
| 151 |
+
* - lzma_block_encoder()
|
| 152 |
+
* - lzma_block_decoder()
|
| 153 |
+
* - lzma_block_buffer_encode()
|
| 154 |
+
* - lzma_block_uncomp_encode()
|
| 155 |
+
* - lzma_block_buffer_decode()
|
| 156 |
+
*/
|
| 157 |
+
lzma_vli compressed_size;
|
| 158 |
+
|
| 159 |
+
/**
|
| 160 |
+
* \brief Uncompressed Size in bytes
|
| 161 |
+
*
|
| 162 |
+
* This is handled very similarly to compressed_size above.
|
| 163 |
+
*
|
| 164 |
+
* uncompressed_size is needed by fewer functions than
|
| 165 |
+
* compressed_size. This is because uncompressed_size isn't
|
| 166 |
+
* needed to validate that Block stays within proper limits.
|
| 167 |
+
*
|
| 168 |
+
* Read by:
|
| 169 |
+
* - lzma_block_header_size()
|
| 170 |
+
* - lzma_block_header_encode()
|
| 171 |
+
* - lzma_block_decoder()
|
| 172 |
+
* - lzma_block_buffer_decode()
|
| 173 |
+
*
|
| 174 |
+
* Written by:
|
| 175 |
+
* - lzma_block_header_decode()
|
| 176 |
+
* - lzma_block_encoder()
|
| 177 |
+
* - lzma_block_decoder()
|
| 178 |
+
* - lzma_block_buffer_encode()
|
| 179 |
+
* - lzma_block_uncomp_encode()
|
| 180 |
+
* - lzma_block_buffer_decode()
|
| 181 |
+
*/
|
| 182 |
+
lzma_vli uncompressed_size;
|
| 183 |
+
|
| 184 |
+
/**
|
| 185 |
+
* \brief Array of filters
|
| 186 |
+
*
|
| 187 |
+
* There can be 1-4 filters. The end of the array is marked with
|
| 188 |
+
* .id = LZMA_VLI_UNKNOWN.
|
| 189 |
+
*
|
| 190 |
+
* Read by:
|
| 191 |
+
* - lzma_block_header_size()
|
| 192 |
+
* - lzma_block_header_encode()
|
| 193 |
+
* - lzma_block_encoder()
|
| 194 |
+
* - lzma_block_decoder()
|
| 195 |
+
* - lzma_block_buffer_encode()
|
| 196 |
+
* - lzma_block_buffer_decode()
|
| 197 |
+
*
|
| 198 |
+
* Written by:
|
| 199 |
+
* - lzma_block_header_decode(): Note that this does NOT free()
|
| 200 |
+
* the old filter options structures. All unused filters[] will
|
| 201 |
+
* have .id == LZMA_VLI_UNKNOWN and .options == NULL. If
|
| 202 |
+
* decoding fails, all filters[] are guaranteed to be
|
| 203 |
+
* LZMA_VLI_UNKNOWN and NULL.
|
| 204 |
+
*
|
| 205 |
+
* \note Because of the array is terminated with
|
| 206 |
+
* .id = LZMA_VLI_UNKNOWN, the actual array must
|
| 207 |
+
* have LZMA_FILTERS_MAX + 1 members or the Block
|
| 208 |
+
* Header decoder will overflow the buffer.
|
| 209 |
+
*/
|
| 210 |
+
lzma_filter *filters;
|
| 211 |
+
|
| 212 |
+
/**
|
| 213 |
+
* \brief Raw value stored in the Check field
|
| 214 |
+
*
|
| 215 |
+
* After successful coding, the first lzma_check_size(check) bytes
|
| 216 |
+
* of this array contain the raw value stored in the Check field.
|
| 217 |
+
*
|
| 218 |
+
* Note that CRC32 and CRC64 are stored in little endian byte order.
|
| 219 |
+
* Take it into account if you display the Check values to the user.
|
| 220 |
+
*
|
| 221 |
+
* Written by:
|
| 222 |
+
* - lzma_block_encoder()
|
| 223 |
+
* - lzma_block_decoder()
|
| 224 |
+
* - lzma_block_buffer_encode()
|
| 225 |
+
* - lzma_block_uncomp_encode()
|
| 226 |
+
* - lzma_block_buffer_decode()
|
| 227 |
+
*/
|
| 228 |
+
uint8_t raw_check[LZMA_CHECK_SIZE_MAX];
|
| 229 |
+
|
| 230 |
+
/*
|
| 231 |
+
* Reserved space to allow possible future extensions without
|
| 232 |
+
* breaking the ABI. You should not touch these, because the names
|
| 233 |
+
* of these variables may change. These are and will never be used
|
| 234 |
+
* with the currently supported options, so it is safe to leave these
|
| 235 |
+
* uninitialized.
|
| 236 |
+
*/
|
| 237 |
+
|
| 238 |
+
/** \private Reserved member. */
|
| 239 |
+
void *reserved_ptr1;
|
| 240 |
+
|
| 241 |
+
/** \private Reserved member. */
|
| 242 |
+
void *reserved_ptr2;
|
| 243 |
+
|
| 244 |
+
/** \private Reserved member. */
|
| 245 |
+
void *reserved_ptr3;
|
| 246 |
+
|
| 247 |
+
/** \private Reserved member. */
|
| 248 |
+
uint32_t reserved_int1;
|
| 249 |
+
|
| 250 |
+
/** \private Reserved member. */
|
| 251 |
+
uint32_t reserved_int2;
|
| 252 |
+
|
| 253 |
+
/** \private Reserved member. */
|
| 254 |
+
lzma_vli reserved_int3;
|
| 255 |
+
|
| 256 |
+
/** \private Reserved member. */
|
| 257 |
+
lzma_vli reserved_int4;
|
| 258 |
+
|
| 259 |
+
/** \private Reserved member. */
|
| 260 |
+
lzma_vli reserved_int5;
|
| 261 |
+
|
| 262 |
+
/** \private Reserved member. */
|
| 263 |
+
lzma_vli reserved_int6;
|
| 264 |
+
|
| 265 |
+
/** \private Reserved member. */
|
| 266 |
+
lzma_vli reserved_int7;
|
| 267 |
+
|
| 268 |
+
/** \private Reserved member. */
|
| 269 |
+
lzma_vli reserved_int8;
|
| 270 |
+
|
| 271 |
+
/** \private Reserved member. */
|
| 272 |
+
lzma_reserved_enum reserved_enum1;
|
| 273 |
+
|
| 274 |
+
/** \private Reserved member. */
|
| 275 |
+
lzma_reserved_enum reserved_enum2;
|
| 276 |
+
|
| 277 |
+
/** \private Reserved member. */
|
| 278 |
+
lzma_reserved_enum reserved_enum3;
|
| 279 |
+
|
| 280 |
+
/** \private Reserved member. */
|
| 281 |
+
lzma_reserved_enum reserved_enum4;
|
| 282 |
+
|
| 283 |
+
/**
|
| 284 |
+
* \brief A flag to Block decoder to not verify the Check field
|
| 285 |
+
*
|
| 286 |
+
* This member is supported by liblzma >= 5.1.4beta if .version >= 1.
|
| 287 |
+
*
|
| 288 |
+
* If this is set to true, the integrity check won't be calculated
|
| 289 |
+
* and verified. Unless you know what you are doing, you should
|
| 290 |
+
* leave this to false. (A reason to set this to true is when the
|
| 291 |
+
* file integrity is verified externally anyway and you want to
|
| 292 |
+
* speed up the decompression, which matters mostly when using
|
| 293 |
+
* SHA-256 as the integrity check.)
|
| 294 |
+
*
|
| 295 |
+
* If .version >= 1, read by:
|
| 296 |
+
* - lzma_block_decoder()
|
| 297 |
+
* - lzma_block_buffer_decode()
|
| 298 |
+
*
|
| 299 |
+
* Written by (.version is ignored):
|
| 300 |
+
* - lzma_block_header_decode() always sets this to false
|
| 301 |
+
*/
|
| 302 |
+
lzma_bool ignore_check;
|
| 303 |
+
|
| 304 |
+
/** \private Reserved member. */
|
| 305 |
+
lzma_bool reserved_bool2;
|
| 306 |
+
|
| 307 |
+
/** \private Reserved member. */
|
| 308 |
+
lzma_bool reserved_bool3;
|
| 309 |
+
|
| 310 |
+
/** \private Reserved member. */
|
| 311 |
+
lzma_bool reserved_bool4;
|
| 312 |
+
|
| 313 |
+
/** \private Reserved member. */
|
| 314 |
+
lzma_bool reserved_bool5;
|
| 315 |
+
|
| 316 |
+
/** \private Reserved member. */
|
| 317 |
+
lzma_bool reserved_bool6;
|
| 318 |
+
|
| 319 |
+
/** \private Reserved member. */
|
| 320 |
+
lzma_bool reserved_bool7;
|
| 321 |
+
|
| 322 |
+
/** \private Reserved member. */
|
| 323 |
+
lzma_bool reserved_bool8;
|
| 324 |
+
|
| 325 |
+
} lzma_block;
|
| 326 |
+
|
| 327 |
+
|
| 328 |
+
/**
|
| 329 |
+
* \brief Decode the Block Header Size field
|
| 330 |
+
*
|
| 331 |
+
* To decode Block Header using lzma_block_header_decode(), the size of the
|
| 332 |
+
* Block Header has to be known and stored into lzma_block.header_size.
|
| 333 |
+
* The size can be calculated from the first byte of a Block using this macro.
|
| 334 |
+
* Note that if the first byte is 0x00, it indicates beginning of Index; use
|
| 335 |
+
* this macro only when the byte is not 0x00.
|
| 336 |
+
*
|
| 337 |
+
* There is no encoding macro because lzma_block_header_size() and
|
| 338 |
+
* lzma_block_header_encode() should be used.
|
| 339 |
+
*/
|
| 340 |
+
#define lzma_block_header_size_decode(b) (((uint32_t)(b) + 1) * 4)
|
| 341 |
+
|
| 342 |
+
|
| 343 |
+
/**
|
| 344 |
+
* \brief Calculate Block Header Size
|
| 345 |
+
*
|
| 346 |
+
* Calculate the minimum size needed for the Block Header field using the
|
| 347 |
+
* settings specified in the lzma_block structure. Note that it is OK to
|
| 348 |
+
* increase the calculated header_size value as long as it is a multiple of
|
| 349 |
+
* four and doesn't exceed LZMA_BLOCK_HEADER_SIZE_MAX. Increasing header_size
|
| 350 |
+
* just means that lzma_block_header_encode() will add Header Padding.
|
| 351 |
+
*
|
| 352 |
+
* \note This doesn't check that all the options are valid i.e. this
|
| 353 |
+
* may return LZMA_OK even if lzma_block_header_encode() or
|
| 354 |
+
* lzma_block_encoder() would fail. If you want to validate the
|
| 355 |
+
* filter chain, consider using lzma_memlimit_encoder() which as
|
| 356 |
+
* a side-effect validates the filter chain.
|
| 357 |
+
*
|
| 358 |
+
* \param block Block options
|
| 359 |
+
*
|
| 360 |
+
* \return Possible lzma_ret values:
|
| 361 |
+
* - LZMA_OK: Size calculated successfully and stored to
|
| 362 |
+
* block->header_size.
|
| 363 |
+
* - LZMA_OPTIONS_ERROR: Unsupported version, filters or
|
| 364 |
+
* filter options.
|
| 365 |
+
* - LZMA_PROG_ERROR: Invalid values like compressed_size == 0.
|
| 366 |
+
*/
|
| 367 |
+
extern LZMA_API(lzma_ret) lzma_block_header_size(lzma_block *block)
|
| 368 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 369 |
+
|
| 370 |
+
|
| 371 |
+
/**
|
| 372 |
+
* \brief Encode Block Header
|
| 373 |
+
*
|
| 374 |
+
* The caller must have calculated the size of the Block Header already with
|
| 375 |
+
* lzma_block_header_size(). If a value larger than the one calculated by
|
| 376 |
+
* lzma_block_header_size() is used, the Block Header will be padded to the
|
| 377 |
+
* specified size.
|
| 378 |
+
*
|
| 379 |
+
* \param block Block options to be encoded.
|
| 380 |
+
* \param[out] out Beginning of the output buffer. This must be
|
| 381 |
+
* at least block->header_size bytes.
|
| 382 |
+
*
|
| 383 |
+
* \return Possible lzma_ret values:
|
| 384 |
+
* - LZMA_OK: Encoding was successful. block->header_size
|
| 385 |
+
* bytes were written to output buffer.
|
| 386 |
+
* - LZMA_OPTIONS_ERROR: Invalid or unsupported options.
|
| 387 |
+
* - LZMA_PROG_ERROR: Invalid arguments, for example
|
| 388 |
+
* block->header_size is invalid or block->filters is NULL.
|
| 389 |
+
*/
|
| 390 |
+
extern LZMA_API(lzma_ret) lzma_block_header_encode(
|
| 391 |
+
const lzma_block *block, uint8_t *out)
|
| 392 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 393 |
+
|
| 394 |
+
|
| 395 |
+
/**
|
| 396 |
+
* \brief Decode Block Header
|
| 397 |
+
*
|
| 398 |
+
* block->version should (usually) be set to the highest value supported
|
| 399 |
+
* by the application. If the application sets block->version to a value
|
| 400 |
+
* higher than supported by the current liblzma version, this function will
|
| 401 |
+
* downgrade block->version to the highest value supported by it. Thus one
|
| 402 |
+
* should check the value of block->version after calling this function if
|
| 403 |
+
* block->version was set to a non-zero value and the application doesn't
|
| 404 |
+
* otherwise know that the liblzma version being used is new enough to
|
| 405 |
+
* support the specified block->version.
|
| 406 |
+
*
|
| 407 |
+
* The size of the Block Header must have already been decoded with
|
| 408 |
+
* lzma_block_header_size_decode() macro and stored to block->header_size.
|
| 409 |
+
*
|
| 410 |
+
* The integrity check type from Stream Header must have been stored
|
| 411 |
+
* to block->check.
|
| 412 |
+
*
|
| 413 |
+
* block->filters must have been allocated, but they don't need to be
|
| 414 |
+
* initialized (possible existing filter options are not freed).
|
| 415 |
+
*
|
| 416 |
+
* \param[out] block Destination for Block options
|
| 417 |
+
* \param allocator lzma_allocator for custom allocator functions.
|
| 418 |
+
* Set to NULL to use malloc() (and also free()
|
| 419 |
+
* if an error occurs).
|
| 420 |
+
* \param in Beginning of the input buffer. This must be
|
| 421 |
+
* at least block->header_size bytes.
|
| 422 |
+
*
|
| 423 |
+
* \return Possible lzma_ret values:
|
| 424 |
+
* - LZMA_OK: Decoding was successful. block->header_size
|
| 425 |
+
* bytes were read from the input buffer.
|
| 426 |
+
* - LZMA_OPTIONS_ERROR: The Block Header specifies some
|
| 427 |
+
* unsupported options such as unsupported filters. This can
|
| 428 |
+
* happen also if block->version was set to a too low value
|
| 429 |
+
* compared to what would be required to properly represent
|
| 430 |
+
* the information stored in the Block Header.
|
| 431 |
+
* - LZMA_DATA_ERROR: Block Header is corrupt, for example,
|
| 432 |
+
* the CRC32 doesn't match.
|
| 433 |
+
* - LZMA_PROG_ERROR: Invalid arguments, for example
|
| 434 |
+
* block->header_size is invalid or block->filters is NULL.
|
| 435 |
+
*/
|
| 436 |
+
extern LZMA_API(lzma_ret) lzma_block_header_decode(lzma_block *block,
|
| 437 |
+
const lzma_allocator *allocator, const uint8_t *in)
|
| 438 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 439 |
+
|
| 440 |
+
|
| 441 |
+
/**
|
| 442 |
+
* \brief Validate and set Compressed Size according to Unpadded Size
|
| 443 |
+
*
|
| 444 |
+
* Block Header stores Compressed Size, but Index has Unpadded Size. If the
|
| 445 |
+
* application has already parsed the Index and is now decoding Blocks,
|
| 446 |
+
* it can calculate Compressed Size from Unpadded Size. This function does
|
| 447 |
+
* exactly that with error checking:
|
| 448 |
+
*
|
| 449 |
+
* - Compressed Size calculated from Unpadded Size must be positive integer,
|
| 450 |
+
* that is, Unpadded Size must be big enough that after Block Header and
|
| 451 |
+
* Check fields there's still at least one byte for Compressed Size.
|
| 452 |
+
*
|
| 453 |
+
* - If Compressed Size was present in Block Header, the new value
|
| 454 |
+
* calculated from Unpadded Size is compared against the value
|
| 455 |
+
* from Block Header.
|
| 456 |
+
*
|
| 457 |
+
* \note This function must be called _after_ decoding the Block Header
|
| 458 |
+
* field so that it can properly validate Compressed Size if it
|
| 459 |
+
* was present in Block Header.
|
| 460 |
+
*
|
| 461 |
+
* \param block Block options: block->header_size must
|
| 462 |
+
* already be set with lzma_block_header_size().
|
| 463 |
+
* \param unpadded_size Unpadded Size from the Index field in bytes
|
| 464 |
+
*
|
| 465 |
+
* \return Possible lzma_ret values:
|
| 466 |
+
* - LZMA_OK: block->compressed_size was set successfully.
|
| 467 |
+
* - LZMA_DATA_ERROR: unpadded_size is too small compared to
|
| 468 |
+
* block->header_size and lzma_check_size(block->check).
|
| 469 |
+
* - LZMA_PROG_ERROR: Some values are invalid. For example,
|
| 470 |
+
* block->header_size must be a multiple of four and
|
| 471 |
+
* between 8 and 1024 inclusive.
|
| 472 |
+
*/
|
| 473 |
+
extern LZMA_API(lzma_ret) lzma_block_compressed_size(
|
| 474 |
+
lzma_block *block, lzma_vli unpadded_size)
|
| 475 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 476 |
+
|
| 477 |
+
|
| 478 |
+
/**
|
| 479 |
+
* \brief Calculate Unpadded Size
|
| 480 |
+
*
|
| 481 |
+
* The Index field stores Unpadded Size and Uncompressed Size. The latter
|
| 482 |
+
* can be taken directly from the lzma_block structure after coding a Block,
|
| 483 |
+
* but Unpadded Size needs to be calculated from Block Header Size,
|
| 484 |
+
* Compressed Size, and size of the Check field. This is where this function
|
| 485 |
+
* is needed.
|
| 486 |
+
*
|
| 487 |
+
* \param block Block options: block->header_size must already be
|
| 488 |
+
* set with lzma_block_header_size().
|
| 489 |
+
*
|
| 490 |
+
* \return Unpadded Size on success, or zero on error.
|
| 491 |
+
*/
|
| 492 |
+
extern LZMA_API(lzma_vli) lzma_block_unpadded_size(const lzma_block *block)
|
| 493 |
+
lzma_nothrow lzma_attr_pure;
|
| 494 |
+
|
| 495 |
+
|
| 496 |
+
/**
|
| 497 |
+
* \brief Calculate the total encoded size of a Block
|
| 498 |
+
*
|
| 499 |
+
* This is equivalent to lzma_block_unpadded_size() except that the returned
|
| 500 |
+
* value includes the size of the Block Padding field.
|
| 501 |
+
*
|
| 502 |
+
* \param block Block options: block->header_size must already be
|
| 503 |
+
* set with lzma_block_header_size().
|
| 504 |
+
*
|
| 505 |
+
* \return On success, total encoded size of the Block. On error,
|
| 506 |
+
* zero is returned.
|
| 507 |
+
*/
|
| 508 |
+
extern LZMA_API(lzma_vli) lzma_block_total_size(const lzma_block *block)
|
| 509 |
+
lzma_nothrow lzma_attr_pure;
|
| 510 |
+
|
| 511 |
+
|
| 512 |
+
/**
|
| 513 |
+
* \brief Initialize .xz Block encoder
|
| 514 |
+
*
|
| 515 |
+
* Valid actions for lzma_code() are LZMA_RUN, LZMA_SYNC_FLUSH (only if the
|
| 516 |
+
* filter chain supports it), and LZMA_FINISH.
|
| 517 |
+
*
|
| 518 |
+
* The Block encoder encodes the Block Data, Block Padding, and Check value.
|
| 519 |
+
* It does NOT encode the Block Header which can be encoded with
|
| 520 |
+
* lzma_block_header_encode().
|
| 521 |
+
*
|
| 522 |
+
* \param strm Pointer to lzma_stream that is at least initialized
|
| 523 |
+
* with LZMA_STREAM_INIT.
|
| 524 |
+
* \param block Block options: block->version, block->check,
|
| 525 |
+
* and block->filters must have been initialized.
|
| 526 |
+
*
|
| 527 |
+
* \return Possible lzma_ret values:
|
| 528 |
+
* - LZMA_OK: All good, continue with lzma_code().
|
| 529 |
+
* - LZMA_MEM_ERROR
|
| 530 |
+
* - LZMA_OPTIONS_ERROR
|
| 531 |
+
* - LZMA_UNSUPPORTED_CHECK: block->check specifies a Check ID
|
| 532 |
+
* that is not supported by this build of liblzma. Initializing
|
| 533 |
+
* the encoder failed.
|
| 534 |
+
* - LZMA_PROG_ERROR
|
| 535 |
+
*/
|
| 536 |
+
extern LZMA_API(lzma_ret) lzma_block_encoder(
|
| 537 |
+
lzma_stream *strm, lzma_block *block)
|
| 538 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 539 |
+
|
| 540 |
+
|
| 541 |
+
/**
|
| 542 |
+
* \brief Initialize .xz Block decoder
|
| 543 |
+
*
|
| 544 |
+
* Valid actions for lzma_code() are LZMA_RUN and LZMA_FINISH. Using
|
| 545 |
+
* LZMA_FINISH is not required. It is supported only for convenience.
|
| 546 |
+
*
|
| 547 |
+
* The Block decoder decodes the Block Data, Block Padding, and Check value.
|
| 548 |
+
* It does NOT decode the Block Header which can be decoded with
|
| 549 |
+
* lzma_block_header_decode().
|
| 550 |
+
*
|
| 551 |
+
* \param strm Pointer to lzma_stream that is at least initialized
|
| 552 |
+
* with LZMA_STREAM_INIT.
|
| 553 |
+
* \param block Block options
|
| 554 |
+
*
|
| 555 |
+
* \return Possible lzma_ret values:
|
| 556 |
+
* - LZMA_OK: All good, continue with lzma_code().
|
| 557 |
+
* - LZMA_PROG_ERROR
|
| 558 |
+
* - LZMA_MEM_ERROR
|
| 559 |
+
*/
|
| 560 |
+
extern LZMA_API(lzma_ret) lzma_block_decoder(
|
| 561 |
+
lzma_stream *strm, lzma_block *block)
|
| 562 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 563 |
+
|
| 564 |
+
|
| 565 |
+
/**
|
| 566 |
+
* \brief Calculate maximum output size for single-call Block encoding
|
| 567 |
+
*
|
| 568 |
+
* This is equivalent to lzma_stream_buffer_bound() but for .xz Blocks.
|
| 569 |
+
* See the documentation of lzma_stream_buffer_bound().
|
| 570 |
+
*
|
| 571 |
+
* \param uncompressed_size Size of the data to be encoded with the
|
| 572 |
+
* single-call Block encoder.
|
| 573 |
+
*
|
| 574 |
+
* \return Maximum output size in bytes for single-call Block encoding.
|
| 575 |
+
*/
|
| 576 |
+
extern LZMA_API(size_t) lzma_block_buffer_bound(size_t uncompressed_size)
|
| 577 |
+
lzma_nothrow;
|
| 578 |
+
|
| 579 |
+
|
| 580 |
+
/**
|
| 581 |
+
* \brief Single-call .xz Block encoder
|
| 582 |
+
*
|
| 583 |
+
* In contrast to the multi-call encoder initialized with
|
| 584 |
+
* lzma_block_encoder(), this function encodes also the Block Header. This
|
| 585 |
+
* is required to make it possible to write appropriate Block Header also
|
| 586 |
+
* in case the data isn't compressible, and different filter chain has to be
|
| 587 |
+
* used to encode the data in uncompressed form using uncompressed chunks
|
| 588 |
+
* of the LZMA2 filter.
|
| 589 |
+
*
|
| 590 |
+
* When the data isn't compressible, header_size, compressed_size, and
|
| 591 |
+
* uncompressed_size are set just like when the data was compressible, but
|
| 592 |
+
* it is possible that header_size is too small to hold the filter chain
|
| 593 |
+
* specified in block->filters, because that isn't necessarily the filter
|
| 594 |
+
* chain that was actually used to encode the data. lzma_block_unpadded_size()
|
| 595 |
+
* still works normally, because it doesn't read the filters array.
|
| 596 |
+
*
|
| 597 |
+
* \param block Block options: block->version, block->check,
|
| 598 |
+
* and block->filters must have been initialized.
|
| 599 |
+
* \param allocator lzma_allocator for custom allocator functions.
|
| 600 |
+
* Set to NULL to use malloc() and free().
|
| 601 |
+
* \param in Beginning of the input buffer
|
| 602 |
+
* \param in_size Size of the input buffer
|
| 603 |
+
* \param[out] out Beginning of the output buffer
|
| 604 |
+
* \param[out] out_pos The next byte will be written to out[*out_pos].
|
| 605 |
+
* *out_pos is updated only if encoding succeeds.
|
| 606 |
+
* \param out_size Size of the out buffer; the first byte into
|
| 607 |
+
* which no data is written to is out[out_size].
|
| 608 |
+
*
|
| 609 |
+
* \return Possible lzma_ret values:
|
| 610 |
+
* - LZMA_OK: Encoding was successful.
|
| 611 |
+
* - LZMA_BUF_ERROR: Not enough output buffer space.
|
| 612 |
+
* - LZMA_UNSUPPORTED_CHECK
|
| 613 |
+
* - LZMA_OPTIONS_ERROR
|
| 614 |
+
* - LZMA_MEM_ERROR
|
| 615 |
+
* - LZMA_DATA_ERROR
|
| 616 |
+
* - LZMA_PROG_ERROR
|
| 617 |
+
*/
|
| 618 |
+
extern LZMA_API(lzma_ret) lzma_block_buffer_encode(
|
| 619 |
+
lzma_block *block, const lzma_allocator *allocator,
|
| 620 |
+
const uint8_t *in, size_t in_size,
|
| 621 |
+
uint8_t *out, size_t *out_pos, size_t out_size)
|
| 622 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 623 |
+
|
| 624 |
+
|
| 625 |
+
/**
|
| 626 |
+
* \brief Single-call uncompressed .xz Block encoder
|
| 627 |
+
*
|
| 628 |
+
* This is like lzma_block_buffer_encode() except this doesn't try to
|
| 629 |
+
* compress the data and instead encodes the data using LZMA2 uncompressed
|
| 630 |
+
* chunks. The required output buffer size can be determined with
|
| 631 |
+
* lzma_block_buffer_bound().
|
| 632 |
+
*
|
| 633 |
+
* Since the data won't be compressed, this function ignores block->filters.
|
| 634 |
+
* This function doesn't take lzma_allocator because this function doesn't
|
| 635 |
+
* allocate any memory from the heap.
|
| 636 |
+
*
|
| 637 |
+
* \param block Block options: block->version, block->check,
|
| 638 |
+
* and block->filters must have been initialized.
|
| 639 |
+
* \param in Beginning of the input buffer
|
| 640 |
+
* \param in_size Size of the input buffer
|
| 641 |
+
* \param[out] out Beginning of the output buffer
|
| 642 |
+
* \param[out] out_pos The next byte will be written to out[*out_pos].
|
| 643 |
+
* *out_pos is updated only if encoding succeeds.
|
| 644 |
+
* \param out_size Size of the out buffer; the first byte into
|
| 645 |
+
* which no data is written to is out[out_size].
|
| 646 |
+
*
|
| 647 |
+
* \return Possible lzma_ret values:
|
| 648 |
+
* - LZMA_OK: Encoding was successful.
|
| 649 |
+
* - LZMA_BUF_ERROR: Not enough output buffer space.
|
| 650 |
+
* - LZMA_UNSUPPORTED_CHECK
|
| 651 |
+
* - LZMA_OPTIONS_ERROR
|
| 652 |
+
* - LZMA_MEM_ERROR
|
| 653 |
+
* - LZMA_DATA_ERROR
|
| 654 |
+
* - LZMA_PROG_ERROR
|
| 655 |
+
*/
|
| 656 |
+
extern LZMA_API(lzma_ret) lzma_block_uncomp_encode(lzma_block *block,
|
| 657 |
+
const uint8_t *in, size_t in_size,
|
| 658 |
+
uint8_t *out, size_t *out_pos, size_t out_size)
|
| 659 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 660 |
+
|
| 661 |
+
|
| 662 |
+
/**
|
| 663 |
+
* \brief Single-call .xz Block decoder
|
| 664 |
+
*
|
| 665 |
+
* This is single-call equivalent of lzma_block_decoder(), and requires that
|
| 666 |
+
* the caller has already decoded Block Header and checked its memory usage.
|
| 667 |
+
*
|
| 668 |
+
* \param block Block options
|
| 669 |
+
* \param allocator lzma_allocator for custom allocator functions.
|
| 670 |
+
* Set to NULL to use malloc() and free().
|
| 671 |
+
* \param in Beginning of the input buffer
|
| 672 |
+
* \param in_pos The next byte will be read from in[*in_pos].
|
| 673 |
+
* *in_pos is updated only if decoding succeeds.
|
| 674 |
+
* \param in_size Size of the input buffer; the first byte that
|
| 675 |
+
* won't be read is in[in_size].
|
| 676 |
+
* \param[out] out Beginning of the output buffer
|
| 677 |
+
* \param[out] out_pos The next byte will be written to out[*out_pos].
|
| 678 |
+
* *out_pos is updated only if encoding succeeds.
|
| 679 |
+
* \param out_size Size of the out buffer; the first byte into
|
| 680 |
+
* which no data is written to is out[out_size].
|
| 681 |
+
*
|
| 682 |
+
* \return Possible lzma_ret values:
|
| 683 |
+
* - LZMA_OK: Decoding was successful.
|
| 684 |
+
* - LZMA_OPTIONS_ERROR
|
| 685 |
+
* - LZMA_DATA_ERROR
|
| 686 |
+
* - LZMA_MEM_ERROR
|
| 687 |
+
* - LZMA_BUF_ERROR: Output buffer was too small.
|
| 688 |
+
* - LZMA_PROG_ERROR
|
| 689 |
+
*/
|
| 690 |
+
extern LZMA_API(lzma_ret) lzma_block_buffer_decode(
|
| 691 |
+
lzma_block *block, const lzma_allocator *allocator,
|
| 692 |
+
const uint8_t *in, size_t *in_pos, size_t in_size,
|
| 693 |
+
uint8_t *out, size_t *out_pos, size_t out_size)
|
| 694 |
+
lzma_nothrow;
|
llava_next/include/lzma/check.h
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* SPDX-License-Identifier: 0BSD */
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* \file lzma/check.h
|
| 5 |
+
* \brief Integrity checks
|
| 6 |
+
* \note Never include this file directly. Use <lzma.h> instead.
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
/*
|
| 10 |
+
* Author: Lasse Collin
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
#ifndef LZMA_H_INTERNAL
|
| 14 |
+
# error Never include this file directly. Use <lzma.h> instead.
|
| 15 |
+
#endif
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
/**
|
| 19 |
+
* \brief Type of the integrity check (Check ID)
|
| 20 |
+
*
|
| 21 |
+
* The .xz format supports multiple types of checks that are calculated
|
| 22 |
+
* from the uncompressed data. They vary in both speed and ability to
|
| 23 |
+
* detect errors.
|
| 24 |
+
*/
|
| 25 |
+
typedef enum {
|
| 26 |
+
LZMA_CHECK_NONE = 0,
|
| 27 |
+
/**<
|
| 28 |
+
* No Check is calculated.
|
| 29 |
+
*
|
| 30 |
+
* Size of the Check field: 0 bytes
|
| 31 |
+
*/
|
| 32 |
+
|
| 33 |
+
LZMA_CHECK_CRC32 = 1,
|
| 34 |
+
/**<
|
| 35 |
+
* CRC32 using the polynomial from the IEEE 802.3 standard
|
| 36 |
+
*
|
| 37 |
+
* Size of the Check field: 4 bytes
|
| 38 |
+
*/
|
| 39 |
+
|
| 40 |
+
LZMA_CHECK_CRC64 = 4,
|
| 41 |
+
/**<
|
| 42 |
+
* CRC64 using the polynomial from the ECMA-182 standard
|
| 43 |
+
*
|
| 44 |
+
* Size of the Check field: 8 bytes
|
| 45 |
+
*/
|
| 46 |
+
|
| 47 |
+
LZMA_CHECK_SHA256 = 10
|
| 48 |
+
/**<
|
| 49 |
+
* SHA-256
|
| 50 |
+
*
|
| 51 |
+
* Size of the Check field: 32 bytes
|
| 52 |
+
*/
|
| 53 |
+
} lzma_check;
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
/**
|
| 57 |
+
* \brief Maximum valid Check ID
|
| 58 |
+
*
|
| 59 |
+
* The .xz file format specification specifies 16 Check IDs (0-15). Some
|
| 60 |
+
* of them are only reserved, that is, no actual Check algorithm has been
|
| 61 |
+
* assigned. When decoding, liblzma still accepts unknown Check IDs for
|
| 62 |
+
* future compatibility. If a valid but unsupported Check ID is detected,
|
| 63 |
+
* liblzma can indicate a warning; see the flags LZMA_TELL_NO_CHECK,
|
| 64 |
+
* LZMA_TELL_UNSUPPORTED_CHECK, and LZMA_TELL_ANY_CHECK in container.h.
|
| 65 |
+
*/
|
| 66 |
+
#define LZMA_CHECK_ID_MAX 15
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
/**
|
| 70 |
+
* \brief Test if the given Check ID is supported
|
| 71 |
+
*
|
| 72 |
+
* LZMA_CHECK_NONE and LZMA_CHECK_CRC32 are always supported (even if
|
| 73 |
+
* liblzma is built with limited features).
|
| 74 |
+
*
|
| 75 |
+
* \note It is safe to call this with a value that is not in the
|
| 76 |
+
* range [0, 15]; in that case the return value is always false.
|
| 77 |
+
*
|
| 78 |
+
* \param check Check ID
|
| 79 |
+
*
|
| 80 |
+
* \return lzma_bool:
|
| 81 |
+
* - true if Check ID is supported by this liblzma build.
|
| 82 |
+
* - false otherwise.
|
| 83 |
+
*/
|
| 84 |
+
extern LZMA_API(lzma_bool) lzma_check_is_supported(lzma_check check)
|
| 85 |
+
lzma_nothrow lzma_attr_const;
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
/**
|
| 89 |
+
* \brief Get the size of the Check field with the given Check ID
|
| 90 |
+
*
|
| 91 |
+
* Although not all Check IDs have a check algorithm associated, the size of
|
| 92 |
+
* every Check is already frozen. This function returns the size (in bytes) of
|
| 93 |
+
* the Check field with the specified Check ID. The values are:
|
| 94 |
+
* { 0, 4, 4, 4, 8, 8, 8, 16, 16, 16, 32, 32, 32, 64, 64, 64 }
|
| 95 |
+
*
|
| 96 |
+
* \param check Check ID
|
| 97 |
+
*
|
| 98 |
+
* \return Size of the Check field in bytes. If the argument is not in
|
| 99 |
+
* the range [0, 15], UINT32_MAX is returned.
|
| 100 |
+
*/
|
| 101 |
+
extern LZMA_API(uint32_t) lzma_check_size(lzma_check check)
|
| 102 |
+
lzma_nothrow lzma_attr_const;
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
/**
|
| 106 |
+
* \brief Maximum size of a Check field
|
| 107 |
+
*/
|
| 108 |
+
#define LZMA_CHECK_SIZE_MAX 64
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
/**
|
| 112 |
+
* \brief Calculate CRC32
|
| 113 |
+
*
|
| 114 |
+
* Calculate CRC32 using the polynomial from the IEEE 802.3 standard.
|
| 115 |
+
*
|
| 116 |
+
* \param buf Pointer to the input buffer
|
| 117 |
+
* \param size Size of the input buffer
|
| 118 |
+
* \param crc Previously returned CRC value. This is used to
|
| 119 |
+
* calculate the CRC of a big buffer in smaller chunks.
|
| 120 |
+
* Set to zero when starting a new calculation.
|
| 121 |
+
*
|
| 122 |
+
* \return Updated CRC value, which can be passed to this function
|
| 123 |
+
* again to continue CRC calculation.
|
| 124 |
+
*/
|
| 125 |
+
extern LZMA_API(uint32_t) lzma_crc32(
|
| 126 |
+
const uint8_t *buf, size_t size, uint32_t crc)
|
| 127 |
+
lzma_nothrow lzma_attr_pure;
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
/**
|
| 131 |
+
* \brief Calculate CRC64
|
| 132 |
+
*
|
| 133 |
+
* Calculate CRC64 using the polynomial from the ECMA-182 standard.
|
| 134 |
+
*
|
| 135 |
+
* This function is used similarly to lzma_crc32().
|
| 136 |
+
*
|
| 137 |
+
* \param buf Pointer to the input buffer
|
| 138 |
+
* \param size Size of the input buffer
|
| 139 |
+
* \param crc Previously returned CRC value. This is used to
|
| 140 |
+
* calculate the CRC of a big buffer in smaller chunks.
|
| 141 |
+
* Set to zero when starting a new calculation.
|
| 142 |
+
*
|
| 143 |
+
* \return Updated CRC value, which can be passed to this function
|
| 144 |
+
* again to continue CRC calculation.
|
| 145 |
+
*/
|
| 146 |
+
extern LZMA_API(uint64_t) lzma_crc64(
|
| 147 |
+
const uint8_t *buf, size_t size, uint64_t crc)
|
| 148 |
+
lzma_nothrow lzma_attr_pure;
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
/**
|
| 152 |
+
* \brief Get the type of the integrity check
|
| 153 |
+
*
|
| 154 |
+
* This function can be called only immediately after lzma_code() has
|
| 155 |
+
* returned LZMA_NO_CHECK, LZMA_UNSUPPORTED_CHECK, or LZMA_GET_CHECK.
|
| 156 |
+
* Calling this function in any other situation has undefined behavior.
|
| 157 |
+
*
|
| 158 |
+
* \param strm Pointer to lzma_stream meeting the above conditions.
|
| 159 |
+
*
|
| 160 |
+
* \return Check ID in the lzma_stream, or undefined if called improperly.
|
| 161 |
+
*/
|
| 162 |
+
extern LZMA_API(lzma_check) lzma_get_check(const lzma_stream *strm)
|
| 163 |
+
lzma_nothrow;
|
llava_next/include/lzma/container.h
ADDED
|
@@ -0,0 +1,995 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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0BSD */
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* \file lzma/container.h
|
| 5 |
+
* \brief File formats
|
| 6 |
+
* \note Never include this file directly. Use <lzma.h> instead.
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
/*
|
| 10 |
+
* Author: Lasse Collin
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
#ifndef LZMA_H_INTERNAL
|
| 14 |
+
# error Never include this file directly. Use <lzma.h> instead.
|
| 15 |
+
#endif
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
/************
|
| 19 |
+
* Encoding *
|
| 20 |
+
************/
|
| 21 |
+
|
| 22 |
+
/**
|
| 23 |
+
* \brief Default compression preset
|
| 24 |
+
*
|
| 25 |
+
* It's not straightforward to recommend a default preset, because in some
|
| 26 |
+
* cases keeping the resource usage relatively low is more important that
|
| 27 |
+
* getting the maximum compression ratio.
|
| 28 |
+
*/
|
| 29 |
+
#define LZMA_PRESET_DEFAULT UINT32_C(6)
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
/**
|
| 33 |
+
* \brief Mask for preset level
|
| 34 |
+
*
|
| 35 |
+
* This is useful only if you need to extract the level from the preset
|
| 36 |
+
* variable. That should be rare.
|
| 37 |
+
*/
|
| 38 |
+
#define LZMA_PRESET_LEVEL_MASK UINT32_C(0x1F)
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
/*
|
| 42 |
+
* Preset flags
|
| 43 |
+
*
|
| 44 |
+
* Currently only one flag is defined.
|
| 45 |
+
*/
|
| 46 |
+
|
| 47 |
+
/**
|
| 48 |
+
* \brief Extreme compression preset
|
| 49 |
+
*
|
| 50 |
+
* This flag modifies the preset to make the encoding significantly slower
|
| 51 |
+
* while improving the compression ratio only marginally. This is useful
|
| 52 |
+
* when you don't mind spending time to get as small result as possible.
|
| 53 |
+
*
|
| 54 |
+
* This flag doesn't affect the memory usage requirements of the decoder (at
|
| 55 |
+
* least not significantly). The memory usage of the encoder may be increased
|
| 56 |
+
* a little but only at the lowest preset levels (0-3).
|
| 57 |
+
*/
|
| 58 |
+
#define LZMA_PRESET_EXTREME (UINT32_C(1) << 31)
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
/**
|
| 62 |
+
* \brief Multithreading options
|
| 63 |
+
*/
|
| 64 |
+
typedef struct {
|
| 65 |
+
/**
|
| 66 |
+
* \brief Flags
|
| 67 |
+
*
|
| 68 |
+
* Set this to zero if no flags are wanted.
|
| 69 |
+
*
|
| 70 |
+
* Encoder: No flags are currently supported.
|
| 71 |
+
*
|
| 72 |
+
* Decoder: Bitwise-or of zero or more of the decoder flags:
|
| 73 |
+
* - LZMA_TELL_NO_CHECK
|
| 74 |
+
* - LZMA_TELL_UNSUPPORTED_CHECK
|
| 75 |
+
* - LZMA_TELL_ANY_CHECK
|
| 76 |
+
* - LZMA_IGNORE_CHECK
|
| 77 |
+
* - LZMA_CONCATENATED
|
| 78 |
+
* - LZMA_FAIL_FAST
|
| 79 |
+
*/
|
| 80 |
+
uint32_t flags;
|
| 81 |
+
|
| 82 |
+
/**
|
| 83 |
+
* \brief Number of worker threads to use
|
| 84 |
+
*/
|
| 85 |
+
uint32_t threads;
|
| 86 |
+
|
| 87 |
+
/**
|
| 88 |
+
* \brief Encoder only: Maximum uncompressed size of a Block
|
| 89 |
+
*
|
| 90 |
+
* The encoder will start a new .xz Block every block_size bytes.
|
| 91 |
+
* Using LZMA_FULL_FLUSH or LZMA_FULL_BARRIER with lzma_code()
|
| 92 |
+
* the caller may tell liblzma to start a new Block earlier.
|
| 93 |
+
*
|
| 94 |
+
* With LZMA2, a recommended block size is 2-4 times the LZMA2
|
| 95 |
+
* dictionary size. With very small dictionaries, it is recommended
|
| 96 |
+
* to use at least 1 MiB block size for good compression ratio, even
|
| 97 |
+
* if this is more than four times the dictionary size. Note that
|
| 98 |
+
* these are only recommendations for typical use cases; feel free
|
| 99 |
+
* to use other values. Just keep in mind that using a block size
|
| 100 |
+
* less than the LZMA2 dictionary size is waste of RAM.
|
| 101 |
+
*
|
| 102 |
+
* Set this to 0 to let liblzma choose the block size depending
|
| 103 |
+
* on the compression options. For LZMA2 it will be 3*dict_size
|
| 104 |
+
* or 1 MiB, whichever is more.
|
| 105 |
+
*
|
| 106 |
+
* For each thread, about 3 * block_size bytes of memory will be
|
| 107 |
+
* allocated. This may change in later liblzma versions. If so,
|
| 108 |
+
* the memory usage will probably be reduced, not increased.
|
| 109 |
+
*/
|
| 110 |
+
uint64_t block_size;
|
| 111 |
+
|
| 112 |
+
/**
|
| 113 |
+
* \brief Timeout to allow lzma_code() to return early
|
| 114 |
+
*
|
| 115 |
+
* Multithreading can make liblzma consume input and produce
|
| 116 |
+
* output in a very bursty way: it may first read a lot of input
|
| 117 |
+
* to fill internal buffers, then no input or output occurs for
|
| 118 |
+
* a while.
|
| 119 |
+
*
|
| 120 |
+
* In single-threaded mode, lzma_code() won't return until it has
|
| 121 |
+
* either consumed all the input or filled the output buffer. If
|
| 122 |
+
* this is done in multithreaded mode, it may cause a call
|
| 123 |
+
* lzma_code() to take even tens of seconds, which isn't acceptable
|
| 124 |
+
* in all applications.
|
| 125 |
+
*
|
| 126 |
+
* To avoid very long blocking times in lzma_code(), a timeout
|
| 127 |
+
* (in milliseconds) may be set here. If lzma_code() would block
|
| 128 |
+
* longer than this number of milliseconds, it will return with
|
| 129 |
+
* LZMA_OK. Reasonable values are 100 ms or more. The xz command
|
| 130 |
+
* line tool uses 300 ms.
|
| 131 |
+
*
|
| 132 |
+
* If long blocking times are acceptable, set timeout to a special
|
| 133 |
+
* value of 0. This will disable the timeout mechanism and will make
|
| 134 |
+
* lzma_code() block until all the input is consumed or the output
|
| 135 |
+
* buffer has been filled.
|
| 136 |
+
*
|
| 137 |
+
* \note Even with a timeout, lzma_code() might sometimes take
|
| 138 |
+
* a long time to return. No timing guarantees are made.
|
| 139 |
+
*/
|
| 140 |
+
uint32_t timeout;
|
| 141 |
+
|
| 142 |
+
/**
|
| 143 |
+
* \brief Encoder only: Compression preset
|
| 144 |
+
*
|
| 145 |
+
* The preset is set just like with lzma_easy_encoder().
|
| 146 |
+
* The preset is ignored if filters below is non-NULL.
|
| 147 |
+
*/
|
| 148 |
+
uint32_t preset;
|
| 149 |
+
|
| 150 |
+
/**
|
| 151 |
+
* \brief Encoder only: Filter chain (alternative to a preset)
|
| 152 |
+
*
|
| 153 |
+
* If this is NULL, the preset above is used. Otherwise the preset
|
| 154 |
+
* is ignored and the filter chain specified here is used.
|
| 155 |
+
*/
|
| 156 |
+
const lzma_filter *filters;
|
| 157 |
+
|
| 158 |
+
/**
|
| 159 |
+
* \brief Encoder only: Integrity check type
|
| 160 |
+
*
|
| 161 |
+
* See check.h for available checks. The xz command line tool
|
| 162 |
+
* defaults to LZMA_CHECK_CRC64, which is a good choice if you
|
| 163 |
+
* are unsure.
|
| 164 |
+
*/
|
| 165 |
+
lzma_check check;
|
| 166 |
+
|
| 167 |
+
/*
|
| 168 |
+
* Reserved space to allow possible future extensions without
|
| 169 |
+
* breaking the ABI. You should not touch these, because the names
|
| 170 |
+
* of these variables may change. These are and will never be used
|
| 171 |
+
* with the currently supported options, so it is safe to leave these
|
| 172 |
+
* uninitialized.
|
| 173 |
+
*/
|
| 174 |
+
/** \private Reserved member. */
|
| 175 |
+
lzma_reserved_enum reserved_enum1;
|
| 176 |
+
|
| 177 |
+
/** \private Reserved member. */
|
| 178 |
+
lzma_reserved_enum reserved_enum2;
|
| 179 |
+
|
| 180 |
+
/** \private Reserved member. */
|
| 181 |
+
lzma_reserved_enum reserved_enum3;
|
| 182 |
+
|
| 183 |
+
/** \private Reserved member. */
|
| 184 |
+
uint32_t reserved_int1;
|
| 185 |
+
|
| 186 |
+
/** \private Reserved member. */
|
| 187 |
+
uint32_t reserved_int2;
|
| 188 |
+
|
| 189 |
+
/** \private Reserved member. */
|
| 190 |
+
uint32_t reserved_int3;
|
| 191 |
+
|
| 192 |
+
/** \private Reserved member. */
|
| 193 |
+
uint32_t reserved_int4;
|
| 194 |
+
|
| 195 |
+
/**
|
| 196 |
+
* \brief Memory usage limit to reduce the number of threads
|
| 197 |
+
*
|
| 198 |
+
* Encoder: Ignored.
|
| 199 |
+
*
|
| 200 |
+
* Decoder:
|
| 201 |
+
*
|
| 202 |
+
* If the number of threads has been set so high that more than
|
| 203 |
+
* memlimit_threading bytes of memory would be needed, the number
|
| 204 |
+
* of threads will be reduced so that the memory usage will not exceed
|
| 205 |
+
* memlimit_threading bytes. However, if memlimit_threading cannot
|
| 206 |
+
* be met even in single-threaded mode, then decoding will continue
|
| 207 |
+
* in single-threaded mode and memlimit_threading may be exceeded
|
| 208 |
+
* even by a large amount. That is, memlimit_threading will never make
|
| 209 |
+
* lzma_code() return LZMA_MEMLIMIT_ERROR. To truly cap the memory
|
| 210 |
+
* usage, see memlimit_stop below.
|
| 211 |
+
*
|
| 212 |
+
* Setting memlimit_threading to UINT64_MAX or a similar huge value
|
| 213 |
+
* means that liblzma is allowed to keep the whole compressed file
|
| 214 |
+
* and the whole uncompressed file in memory in addition to the memory
|
| 215 |
+
* needed by the decompressor data structures used by each thread!
|
| 216 |
+
* In other words, a reasonable value limit must be set here or it
|
| 217 |
+
* will cause problems sooner or later. If you have no idea what
|
| 218 |
+
* a reasonable value could be, try lzma_physmem() / 4 as a starting
|
| 219 |
+
* point. Setting this limit will never prevent decompression of
|
| 220 |
+
* a file; this will only reduce the number of threads.
|
| 221 |
+
*
|
| 222 |
+
* If memlimit_threading is greater than memlimit_stop, then the value
|
| 223 |
+
* of memlimit_stop will be used for both.
|
| 224 |
+
*/
|
| 225 |
+
uint64_t memlimit_threading;
|
| 226 |
+
|
| 227 |
+
/**
|
| 228 |
+
* \brief Memory usage limit that should never be exceeded
|
| 229 |
+
*
|
| 230 |
+
* Encoder: Ignored.
|
| 231 |
+
*
|
| 232 |
+
* Decoder: If decompressing will need more than this amount of
|
| 233 |
+
* memory even in the single-threaded mode, then lzma_code() will
|
| 234 |
+
* return LZMA_MEMLIMIT_ERROR.
|
| 235 |
+
*/
|
| 236 |
+
uint64_t memlimit_stop;
|
| 237 |
+
|
| 238 |
+
/** \private Reserved member. */
|
| 239 |
+
uint64_t reserved_int7;
|
| 240 |
+
|
| 241 |
+
/** \private Reserved member. */
|
| 242 |
+
uint64_t reserved_int8;
|
| 243 |
+
|
| 244 |
+
/** \private Reserved member. */
|
| 245 |
+
void *reserved_ptr1;
|
| 246 |
+
|
| 247 |
+
/** \private Reserved member. */
|
| 248 |
+
void *reserved_ptr2;
|
| 249 |
+
|
| 250 |
+
/** \private Reserved member. */
|
| 251 |
+
void *reserved_ptr3;
|
| 252 |
+
|
| 253 |
+
/** \private Reserved member. */
|
| 254 |
+
void *reserved_ptr4;
|
| 255 |
+
|
| 256 |
+
} lzma_mt;
|
| 257 |
+
|
| 258 |
+
|
| 259 |
+
/**
|
| 260 |
+
* \brief Calculate approximate memory usage of easy encoder
|
| 261 |
+
*
|
| 262 |
+
* This function is a wrapper for lzma_raw_encoder_memusage().
|
| 263 |
+
*
|
| 264 |
+
* \param preset Compression preset (level and possible flags)
|
| 265 |
+
*
|
| 266 |
+
* \return Number of bytes of memory required for the given
|
| 267 |
+
* preset when encoding or UINT64_MAX on error.
|
| 268 |
+
*/
|
| 269 |
+
extern LZMA_API(uint64_t) lzma_easy_encoder_memusage(uint32_t preset)
|
| 270 |
+
lzma_nothrow lzma_attr_pure;
|
| 271 |
+
|
| 272 |
+
|
| 273 |
+
/**
|
| 274 |
+
* \brief Calculate approximate decoder memory usage of a preset
|
| 275 |
+
*
|
| 276 |
+
* This function is a wrapper for lzma_raw_decoder_memusage().
|
| 277 |
+
*
|
| 278 |
+
* \param preset Compression preset (level and possible flags)
|
| 279 |
+
*
|
| 280 |
+
* \return Number of bytes of memory required to decompress a file
|
| 281 |
+
* that was compressed using the given preset or UINT64_MAX
|
| 282 |
+
* on error.
|
| 283 |
+
*/
|
| 284 |
+
extern LZMA_API(uint64_t) lzma_easy_decoder_memusage(uint32_t preset)
|
| 285 |
+
lzma_nothrow lzma_attr_pure;
|
| 286 |
+
|
| 287 |
+
|
| 288 |
+
/**
|
| 289 |
+
* \brief Initialize .xz Stream encoder using a preset number
|
| 290 |
+
*
|
| 291 |
+
* This function is intended for those who just want to use the basic features
|
| 292 |
+
* of liblzma (that is, most developers out there).
|
| 293 |
+
*
|
| 294 |
+
* If initialization fails (return value is not LZMA_OK), all the memory
|
| 295 |
+
* allocated for *strm by liblzma is always freed. Thus, there is no need
|
| 296 |
+
* to call lzma_end() after failed initialization.
|
| 297 |
+
*
|
| 298 |
+
* If initialization succeeds, use lzma_code() to do the actual encoding.
|
| 299 |
+
* Valid values for 'action' (the second argument of lzma_code()) are
|
| 300 |
+
* LZMA_RUN, LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, and LZMA_FINISH. In future,
|
| 301 |
+
* there may be compression levels or flags that don't support LZMA_SYNC_FLUSH.
|
| 302 |
+
*
|
| 303 |
+
* \param strm Pointer to lzma_stream that is at least initialized
|
| 304 |
+
* with LZMA_STREAM_INIT.
|
| 305 |
+
* \param preset Compression preset to use. A preset consist of level
|
| 306 |
+
* number and zero or more flags. Usually flags aren't
|
| 307 |
+
* used, so preset is simply a number [0, 9] which match
|
| 308 |
+
* the options -0 ... -9 of the xz command line tool.
|
| 309 |
+
* Additional flags can be set using bitwise-or with
|
| 310 |
+
* the preset level number, e.g. 6 | LZMA_PRESET_EXTREME.
|
| 311 |
+
* \param check Integrity check type to use. See check.h for available
|
| 312 |
+
* checks. The xz command line tool defaults to
|
| 313 |
+
* LZMA_CHECK_CRC64, which is a good choice if you are
|
| 314 |
+
* unsure. LZMA_CHECK_CRC32 is good too as long as the
|
| 315 |
+
* uncompressed file is not many gigabytes.
|
| 316 |
+
*
|
| 317 |
+
* \return Possible lzma_ret values:
|
| 318 |
+
* - LZMA_OK: Initialization succeeded. Use lzma_code() to
|
| 319 |
+
* encode your data.
|
| 320 |
+
* - LZMA_MEM_ERROR: Memory allocation failed.
|
| 321 |
+
* - LZMA_OPTIONS_ERROR: The given compression preset is not
|
| 322 |
+
* supported by this build of liblzma.
|
| 323 |
+
* - LZMA_UNSUPPORTED_CHECK: The given check type is not
|
| 324 |
+
* supported by this liblzma build.
|
| 325 |
+
* - LZMA_PROG_ERROR: One or more of the parameters have values
|
| 326 |
+
* that will never be valid. For example, strm == NULL.
|
| 327 |
+
*/
|
| 328 |
+
extern LZMA_API(lzma_ret) lzma_easy_encoder(
|
| 329 |
+
lzma_stream *strm, uint32_t preset, lzma_check check)
|
| 330 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 331 |
+
|
| 332 |
+
|
| 333 |
+
/**
|
| 334 |
+
* \brief Single-call .xz Stream encoding using a preset number
|
| 335 |
+
*
|
| 336 |
+
* The maximum required output buffer size can be calculated with
|
| 337 |
+
* lzma_stream_buffer_bound().
|
| 338 |
+
*
|
| 339 |
+
* \param preset Compression preset to use. See the description
|
| 340 |
+
* in lzma_easy_encoder().
|
| 341 |
+
* \param check Type of the integrity check to calculate from
|
| 342 |
+
* uncompressed data.
|
| 343 |
+
* \param allocator lzma_allocator for custom allocator functions.
|
| 344 |
+
* Set to NULL to use malloc() and free().
|
| 345 |
+
* \param in Beginning of the input buffer
|
| 346 |
+
* \param in_size Size of the input buffer
|
| 347 |
+
* \param[out] out Beginning of the output buffer
|
| 348 |
+
* \param[out] out_pos The next byte will be written to out[*out_pos].
|
| 349 |
+
* *out_pos is updated only if encoding succeeds.
|
| 350 |
+
* \param out_size Size of the out buffer; the first byte into
|
| 351 |
+
* which no data is written to is out[out_size].
|
| 352 |
+
*
|
| 353 |
+
* \return Possible lzma_ret values:
|
| 354 |
+
* - LZMA_OK: Encoding was successful.
|
| 355 |
+
* - LZMA_BUF_ERROR: Not enough output buffer space.
|
| 356 |
+
* - LZMA_UNSUPPORTED_CHECK
|
| 357 |
+
* - LZMA_OPTIONS_ERROR
|
| 358 |
+
* - LZMA_MEM_ERROR
|
| 359 |
+
* - LZMA_DATA_ERROR
|
| 360 |
+
* - LZMA_PROG_ERROR
|
| 361 |
+
*/
|
| 362 |
+
extern LZMA_API(lzma_ret) lzma_easy_buffer_encode(
|
| 363 |
+
uint32_t preset, lzma_check check,
|
| 364 |
+
const lzma_allocator *allocator,
|
| 365 |
+
const uint8_t *in, size_t in_size,
|
| 366 |
+
uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow;
|
| 367 |
+
|
| 368 |
+
|
| 369 |
+
/**
|
| 370 |
+
* \brief Initialize .xz Stream encoder using a custom filter chain
|
| 371 |
+
*
|
| 372 |
+
* \param strm Pointer to lzma_stream that is at least initialized
|
| 373 |
+
* with LZMA_STREAM_INIT.
|
| 374 |
+
* \param filters Array of filters terminated with
|
| 375 |
+
* .id == LZMA_VLI_UNKNOWN. See filters.h for more
|
| 376 |
+
* information.
|
| 377 |
+
* \param check Type of the integrity check to calculate from
|
| 378 |
+
* uncompressed data.
|
| 379 |
+
*
|
| 380 |
+
* \return Possible lzma_ret values:
|
| 381 |
+
* - LZMA_OK: Initialization was successful.
|
| 382 |
+
* - LZMA_MEM_ERROR
|
| 383 |
+
* - LZMA_UNSUPPORTED_CHECK
|
| 384 |
+
* - LZMA_OPTIONS_ERROR
|
| 385 |
+
* - LZMA_PROG_ERROR
|
| 386 |
+
*/
|
| 387 |
+
extern LZMA_API(lzma_ret) lzma_stream_encoder(lzma_stream *strm,
|
| 388 |
+
const lzma_filter *filters, lzma_check check)
|
| 389 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 390 |
+
|
| 391 |
+
|
| 392 |
+
/**
|
| 393 |
+
* \brief Calculate approximate memory usage of multithreaded .xz encoder
|
| 394 |
+
*
|
| 395 |
+
* Since doing the encoding in threaded mode doesn't affect the memory
|
| 396 |
+
* requirements of single-threaded decompressor, you can use
|
| 397 |
+
* lzma_easy_decoder_memusage(options->preset) or
|
| 398 |
+
* lzma_raw_decoder_memusage(options->filters) to calculate
|
| 399 |
+
* the decompressor memory requirements.
|
| 400 |
+
*
|
| 401 |
+
* \param options Compression options
|
| 402 |
+
*
|
| 403 |
+
* \return Number of bytes of memory required for encoding with the
|
| 404 |
+
* given options. If an error occurs, for example due to
|
| 405 |
+
* unsupported preset or filter chain, UINT64_MAX is returned.
|
| 406 |
+
*/
|
| 407 |
+
extern LZMA_API(uint64_t) lzma_stream_encoder_mt_memusage(
|
| 408 |
+
const lzma_mt *options) lzma_nothrow lzma_attr_pure;
|
| 409 |
+
|
| 410 |
+
|
| 411 |
+
/**
|
| 412 |
+
* \brief Initialize multithreaded .xz Stream encoder
|
| 413 |
+
*
|
| 414 |
+
* This provides the functionality of lzma_easy_encoder() and
|
| 415 |
+
* lzma_stream_encoder() as a single function for multithreaded use.
|
| 416 |
+
*
|
| 417 |
+
* The supported actions for lzma_code() are LZMA_RUN, LZMA_FULL_FLUSH,
|
| 418 |
+
* LZMA_FULL_BARRIER, and LZMA_FINISH. Support for LZMA_SYNC_FLUSH might be
|
| 419 |
+
* added in the future.
|
| 420 |
+
*
|
| 421 |
+
* \param strm Pointer to lzma_stream that is at least initialized
|
| 422 |
+
* with LZMA_STREAM_INIT.
|
| 423 |
+
* \param options Pointer to multithreaded compression options
|
| 424 |
+
*
|
| 425 |
+
* \return Possible lzma_ret values:
|
| 426 |
+
* - LZMA_OK
|
| 427 |
+
* - LZMA_MEM_ERROR
|
| 428 |
+
* - LZMA_UNSUPPORTED_CHECK
|
| 429 |
+
* - LZMA_OPTIONS_ERROR
|
| 430 |
+
* - LZMA_PROG_ERROR
|
| 431 |
+
*/
|
| 432 |
+
extern LZMA_API(lzma_ret) lzma_stream_encoder_mt(
|
| 433 |
+
lzma_stream *strm, const lzma_mt *options)
|
| 434 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 435 |
+
|
| 436 |
+
|
| 437 |
+
/**
|
| 438 |
+
* \brief Calculate recommended Block size for multithreaded .xz encoder
|
| 439 |
+
*
|
| 440 |
+
* This calculates a recommended Block size for multithreaded encoding given
|
| 441 |
+
* a filter chain. This is used internally by lzma_stream_encoder_mt() to
|
| 442 |
+
* determine the Block size if the block_size member is not set to the
|
| 443 |
+
* special value of 0 in the lzma_mt options struct.
|
| 444 |
+
*
|
| 445 |
+
* If one wishes to change the filters between Blocks, this function is
|
| 446 |
+
* helpful to set the block_size member of the lzma_mt struct before calling
|
| 447 |
+
* lzma_stream_encoder_mt(). Since the block_size member represents the
|
| 448 |
+
* maximum possible Block size for the multithreaded .xz encoder, one can
|
| 449 |
+
* use this function to find the maximum recommended Block size based on
|
| 450 |
+
* all planned filter chains. Otherwise, the multithreaded encoder will
|
| 451 |
+
* base its maximum Block size on the first filter chain used (if the
|
| 452 |
+
* block_size member is not set), which may unnecessarily limit the Block
|
| 453 |
+
* size for a later filter chain.
|
| 454 |
+
*
|
| 455 |
+
* \param filters Array of filters terminated with
|
| 456 |
+
* .id == LZMA_VLI_UNKNOWN.
|
| 457 |
+
*
|
| 458 |
+
* \return Recommended Block size in bytes, or UINT64_MAX if
|
| 459 |
+
* an error occurred.
|
| 460 |
+
*/
|
| 461 |
+
extern LZMA_API(uint64_t) lzma_mt_block_size(const lzma_filter *filters)
|
| 462 |
+
lzma_nothrow;
|
| 463 |
+
|
| 464 |
+
|
| 465 |
+
/**
|
| 466 |
+
* \brief Initialize .lzma encoder (legacy file format)
|
| 467 |
+
*
|
| 468 |
+
* The .lzma format is sometimes called the LZMA_Alone format, which is the
|
| 469 |
+
* reason for the name of this function. The .lzma format supports only the
|
| 470 |
+
* LZMA1 filter. There is no support for integrity checks like CRC32.
|
| 471 |
+
*
|
| 472 |
+
* Use this function if and only if you need to create files readable by
|
| 473 |
+
* legacy LZMA tools such as LZMA Utils 4.32.x. Moving to the .xz format
|
| 474 |
+
* is strongly recommended.
|
| 475 |
+
*
|
| 476 |
+
* The valid action values for lzma_code() are LZMA_RUN and LZMA_FINISH.
|
| 477 |
+
* No kind of flushing is supported, because the file format doesn't make
|
| 478 |
+
* it possible.
|
| 479 |
+
*
|
| 480 |
+
* \param strm Pointer to lzma_stream that is at least initialized
|
| 481 |
+
* with LZMA_STREAM_INIT.
|
| 482 |
+
* \param options Pointer to encoder options
|
| 483 |
+
*
|
| 484 |
+
* \return Possible lzma_ret values:
|
| 485 |
+
* - LZMA_OK
|
| 486 |
+
* - LZMA_MEM_ERROR
|
| 487 |
+
* - LZMA_OPTIONS_ERROR
|
| 488 |
+
* - LZMA_PROG_ERROR
|
| 489 |
+
*/
|
| 490 |
+
extern LZMA_API(lzma_ret) lzma_alone_encoder(
|
| 491 |
+
lzma_stream *strm, const lzma_options_lzma *options)
|
| 492 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 493 |
+
|
| 494 |
+
|
| 495 |
+
/**
|
| 496 |
+
* \brief Calculate output buffer size for single-call Stream encoder
|
| 497 |
+
*
|
| 498 |
+
* When trying to compress incompressible data, the encoded size will be
|
| 499 |
+
* slightly bigger than the input data. This function calculates how much
|
| 500 |
+
* output buffer space is required to be sure that lzma_stream_buffer_encode()
|
| 501 |
+
* doesn't return LZMA_BUF_ERROR.
|
| 502 |
+
*
|
| 503 |
+
* The calculated value is not exact, but it is guaranteed to be big enough.
|
| 504 |
+
* The actual maximum output space required may be slightly smaller (up to
|
| 505 |
+
* about 100 bytes). This should not be a problem in practice.
|
| 506 |
+
*
|
| 507 |
+
* If the calculated maximum size doesn't fit into size_t or would make the
|
| 508 |
+
* Stream grow past LZMA_VLI_MAX (which should never happen in practice),
|
| 509 |
+
* zero is returned to indicate the error.
|
| 510 |
+
*
|
| 511 |
+
* \note The limit calculated by this function applies only to
|
| 512 |
+
* single-call encoding. Multi-call encoding may (and probably
|
| 513 |
+
* will) have larger maximum expansion when encoding
|
| 514 |
+
* incompressible data. Currently there is no function to
|
| 515 |
+
* calculate the maximum expansion of multi-call encoding.
|
| 516 |
+
*
|
| 517 |
+
* \param uncompressed_size Size in bytes of the uncompressed
|
| 518 |
+
* input data
|
| 519 |
+
*
|
| 520 |
+
* \return Maximum number of bytes needed to store the compressed data.
|
| 521 |
+
*/
|
| 522 |
+
extern LZMA_API(size_t) lzma_stream_buffer_bound(size_t uncompressed_size)
|
| 523 |
+
lzma_nothrow;
|
| 524 |
+
|
| 525 |
+
|
| 526 |
+
/**
|
| 527 |
+
* \brief Single-call .xz Stream encoder
|
| 528 |
+
*
|
| 529 |
+
* \param filters Array of filters terminated with
|
| 530 |
+
* .id == LZMA_VLI_UNKNOWN. See filters.h for more
|
| 531 |
+
* information.
|
| 532 |
+
* \param check Type of the integrity check to calculate from
|
| 533 |
+
* uncompressed data.
|
| 534 |
+
* \param allocator lzma_allocator for custom allocator functions.
|
| 535 |
+
* Set to NULL to use malloc() and free().
|
| 536 |
+
* \param in Beginning of the input buffer
|
| 537 |
+
* \param in_size Size of the input buffer
|
| 538 |
+
* \param[out] out Beginning of the output buffer
|
| 539 |
+
* \param[out] out_pos The next byte will be written to out[*out_pos].
|
| 540 |
+
* *out_pos is updated only if encoding succeeds.
|
| 541 |
+
* \param out_size Size of the out buffer; the first byte into
|
| 542 |
+
* which no data is written to is out[out_size].
|
| 543 |
+
*
|
| 544 |
+
* \return Possible lzma_ret values:
|
| 545 |
+
* - LZMA_OK: Encoding was successful.
|
| 546 |
+
* - LZMA_BUF_ERROR: Not enough output buffer space.
|
| 547 |
+
* - LZMA_UNSUPPORTED_CHECK
|
| 548 |
+
* - LZMA_OPTIONS_ERROR
|
| 549 |
+
* - LZMA_MEM_ERROR
|
| 550 |
+
* - LZMA_DATA_ERROR
|
| 551 |
+
* - LZMA_PROG_ERROR
|
| 552 |
+
*/
|
| 553 |
+
extern LZMA_API(lzma_ret) lzma_stream_buffer_encode(
|
| 554 |
+
lzma_filter *filters, lzma_check check,
|
| 555 |
+
const lzma_allocator *allocator,
|
| 556 |
+
const uint8_t *in, size_t in_size,
|
| 557 |
+
uint8_t *out, size_t *out_pos, size_t out_size)
|
| 558 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 559 |
+
|
| 560 |
+
|
| 561 |
+
/**
|
| 562 |
+
* \brief MicroLZMA encoder
|
| 563 |
+
*
|
| 564 |
+
* The MicroLZMA format is a raw LZMA stream whose first byte (always 0x00)
|
| 565 |
+
* has been replaced with bitwise-negation of the LZMA properties (lc/lp/pb).
|
| 566 |
+
* This encoding ensures that the first byte of MicroLZMA stream is never
|
| 567 |
+
* 0x00. There is no end of payload marker and thus the uncompressed size
|
| 568 |
+
* must be stored separately. For the best error detection the dictionary
|
| 569 |
+
* size should be stored separately as well but alternatively one may use
|
| 570 |
+
* the uncompressed size as the dictionary size when decoding.
|
| 571 |
+
*
|
| 572 |
+
* With the MicroLZMA encoder, lzma_code() behaves slightly unusually.
|
| 573 |
+
* The action argument must be LZMA_FINISH and the return value will never be
|
| 574 |
+
* LZMA_OK. Thus the encoding is always done with a single lzma_code() after
|
| 575 |
+
* the initialization. The benefit of the combination of initialization
|
| 576 |
+
* function and lzma_code() is that memory allocations can be re-used for
|
| 577 |
+
* better performance.
|
| 578 |
+
*
|
| 579 |
+
* lzma_code() will try to encode as much input as is possible to fit into
|
| 580 |
+
* the given output buffer. If not all input can be encoded, the stream will
|
| 581 |
+
* be finished without encoding all the input. The caller must check both
|
| 582 |
+
* input and output buffer usage after lzma_code() (total_in and total_out
|
| 583 |
+
* in lzma_stream can be convenient). Often lzma_code() can fill the output
|
| 584 |
+
* buffer completely if there is a lot of input, but sometimes a few bytes
|
| 585 |
+
* may remain unused because the next LZMA symbol would require more space.
|
| 586 |
+
*
|
| 587 |
+
* lzma_stream.avail_out must be at least 6. Otherwise LZMA_PROG_ERROR
|
| 588 |
+
* will be returned.
|
| 589 |
+
*
|
| 590 |
+
* The LZMA dictionary should be reasonably low to speed up the encoder
|
| 591 |
+
* re-initialization. A good value is bigger than the resulting
|
| 592 |
+
* uncompressed size of most of the output chunks. For example, if output
|
| 593 |
+
* size is 4 KiB, dictionary size of 32 KiB or 64 KiB is good. If the
|
| 594 |
+
* data compresses extremely well, even 128 KiB may be useful.
|
| 595 |
+
*
|
| 596 |
+
* The MicroLZMA format and this encoder variant were made with the EROFS
|
| 597 |
+
* file system in mind. This format may be convenient in other embedded
|
| 598 |
+
* uses too where many small streams are needed. XZ Embedded includes a
|
| 599 |
+
* decoder for this format.
|
| 600 |
+
*
|
| 601 |
+
* \param strm Pointer to lzma_stream that is at least initialized
|
| 602 |
+
* with LZMA_STREAM_INIT.
|
| 603 |
+
* \param options Pointer to encoder options
|
| 604 |
+
*
|
| 605 |
+
* \return Possible lzma_ret values:
|
| 606 |
+
* - LZMA_STREAM_END: All good. Check the amounts of input used
|
| 607 |
+
* and output produced. Store the amount of input used
|
| 608 |
+
* (uncompressed size) as it needs to be known to decompress
|
| 609 |
+
* the data.
|
| 610 |
+
* - LZMA_OPTIONS_ERROR
|
| 611 |
+
* - LZMA_MEM_ERROR
|
| 612 |
+
* - LZMA_PROG_ERROR: In addition to the generic reasons for this
|
| 613 |
+
* error code, this may also be returned if there isn't enough
|
| 614 |
+
* output space (6 bytes) to create a valid MicroLZMA stream.
|
| 615 |
+
*/
|
| 616 |
+
extern LZMA_API(lzma_ret) lzma_microlzma_encoder(
|
| 617 |
+
lzma_stream *strm, const lzma_options_lzma *options)
|
| 618 |
+
lzma_nothrow;
|
| 619 |
+
|
| 620 |
+
|
| 621 |
+
/************
|
| 622 |
+
* Decoding *
|
| 623 |
+
************/
|
| 624 |
+
|
| 625 |
+
/**
|
| 626 |
+
* This flag makes lzma_code() return LZMA_NO_CHECK if the input stream
|
| 627 |
+
* being decoded has no integrity check. Note that when used with
|
| 628 |
+
* lzma_auto_decoder(), all .lzma files will trigger LZMA_NO_CHECK
|
| 629 |
+
* if LZMA_TELL_NO_CHECK is used.
|
| 630 |
+
*/
|
| 631 |
+
#define LZMA_TELL_NO_CHECK UINT32_C(0x01)
|
| 632 |
+
|
| 633 |
+
|
| 634 |
+
/**
|
| 635 |
+
* This flag makes lzma_code() return LZMA_UNSUPPORTED_CHECK if the input
|
| 636 |
+
* stream has an integrity check, but the type of the integrity check is not
|
| 637 |
+
* supported by this liblzma version or build. Such files can still be
|
| 638 |
+
* decoded, but the integrity check cannot be verified.
|
| 639 |
+
*/
|
| 640 |
+
#define LZMA_TELL_UNSUPPORTED_CHECK UINT32_C(0x02)
|
| 641 |
+
|
| 642 |
+
|
| 643 |
+
/**
|
| 644 |
+
* This flag makes lzma_code() return LZMA_GET_CHECK as soon as the type
|
| 645 |
+
* of the integrity check is known. The type can then be got with
|
| 646 |
+
* lzma_get_check().
|
| 647 |
+
*/
|
| 648 |
+
#define LZMA_TELL_ANY_CHECK UINT32_C(0x04)
|
| 649 |
+
|
| 650 |
+
|
| 651 |
+
/**
|
| 652 |
+
* This flag makes lzma_code() not calculate and verify the integrity check
|
| 653 |
+
* of the compressed data in .xz files. This means that invalid integrity
|
| 654 |
+
* check values won't be detected and LZMA_DATA_ERROR won't be returned in
|
| 655 |
+
* such cases.
|
| 656 |
+
*
|
| 657 |
+
* This flag only affects the checks of the compressed data itself; the CRC32
|
| 658 |
+
* values in the .xz headers will still be verified normally.
|
| 659 |
+
*
|
| 660 |
+
* Don't use this flag unless you know what you are doing. Possible reasons
|
| 661 |
+
* to use this flag:
|
| 662 |
+
*
|
| 663 |
+
* - Trying to recover data from a corrupt .xz file.
|
| 664 |
+
*
|
| 665 |
+
* - Speeding up decompression, which matters mostly with SHA-256
|
| 666 |
+
* or with files that have compressed extremely well. It's recommended
|
| 667 |
+
* to not use this flag for this purpose unless the file integrity is
|
| 668 |
+
* verified externally in some other way.
|
| 669 |
+
*
|
| 670 |
+
* Support for this flag was added in liblzma 5.1.4beta.
|
| 671 |
+
*/
|
| 672 |
+
#define LZMA_IGNORE_CHECK UINT32_C(0x10)
|
| 673 |
+
|
| 674 |
+
|
| 675 |
+
/**
|
| 676 |
+
* This flag enables decoding of concatenated files with file formats that
|
| 677 |
+
* allow concatenating compressed files as is. From the formats currently
|
| 678 |
+
* supported by liblzma, only the .xz and .lz formats allow concatenated
|
| 679 |
+
* files. Concatenated files are not allowed with the legacy .lzma format.
|
| 680 |
+
*
|
| 681 |
+
* This flag also affects the usage of the 'action' argument for lzma_code().
|
| 682 |
+
* When LZMA_CONCATENATED is used, lzma_code() won't return LZMA_STREAM_END
|
| 683 |
+
* unless LZMA_FINISH is used as 'action'. Thus, the application has to set
|
| 684 |
+
* LZMA_FINISH in the same way as it does when encoding.
|
| 685 |
+
*
|
| 686 |
+
* If LZMA_CONCATENATED is not used, the decoders still accept LZMA_FINISH
|
| 687 |
+
* as 'action' for lzma_code(), but the usage of LZMA_FINISH isn't required.
|
| 688 |
+
*/
|
| 689 |
+
#define LZMA_CONCATENATED UINT32_C(0x08)
|
| 690 |
+
|
| 691 |
+
|
| 692 |
+
/**
|
| 693 |
+
* This flag makes the threaded decoder report errors (like LZMA_DATA_ERROR)
|
| 694 |
+
* as soon as they are detected. This saves time when the application has no
|
| 695 |
+
* interest in a partially decompressed truncated or corrupt file. Note that
|
| 696 |
+
* due to timing randomness, if the same truncated or corrupt input is
|
| 697 |
+
* decompressed multiple times with this flag, a different amount of output
|
| 698 |
+
* may be produced by different runs, and even the error code might vary.
|
| 699 |
+
*
|
| 700 |
+
* When using LZMA_FAIL_FAST, it is recommended to use LZMA_FINISH to tell
|
| 701 |
+
* the decoder when no more input will be coming because it can help fast
|
| 702 |
+
* detection and reporting of truncated files. Note that in this situation
|
| 703 |
+
* truncated files might be diagnosed with LZMA_DATA_ERROR instead of
|
| 704 |
+
* LZMA_OK or LZMA_BUF_ERROR!
|
| 705 |
+
*
|
| 706 |
+
* Without this flag the threaded decoder will provide as much output as
|
| 707 |
+
* possible at first and then report the pending error. This default behavior
|
| 708 |
+
* matches the single-threaded decoder and provides repeatable behavior
|
| 709 |
+
* with truncated or corrupt input. There are a few special cases where the
|
| 710 |
+
* behavior can still differ like memory allocation failures (LZMA_MEM_ERROR).
|
| 711 |
+
*
|
| 712 |
+
* Single-threaded decoders currently ignore this flag.
|
| 713 |
+
*
|
| 714 |
+
* Support for this flag was added in liblzma 5.3.3alpha. Note that in older
|
| 715 |
+
* versions this flag isn't supported (LZMA_OPTIONS_ERROR) even by functions
|
| 716 |
+
* that ignore this flag in newer liblzma versions.
|
| 717 |
+
*/
|
| 718 |
+
#define LZMA_FAIL_FAST UINT32_C(0x20)
|
| 719 |
+
|
| 720 |
+
|
| 721 |
+
/**
|
| 722 |
+
* \brief Initialize .xz Stream decoder
|
| 723 |
+
*
|
| 724 |
+
* \param strm Pointer to lzma_stream that is at least initialized
|
| 725 |
+
* with LZMA_STREAM_INIT.
|
| 726 |
+
* \param memlimit Memory usage limit as bytes. Use UINT64_MAX
|
| 727 |
+
* to effectively disable the limiter. liblzma
|
| 728 |
+
* 5.2.3 and earlier don't allow 0 here and return
|
| 729 |
+
* LZMA_PROG_ERROR; later versions treat 0 as if 1
|
| 730 |
+
* had been specified.
|
| 731 |
+
* \param flags Bitwise-or of zero or more of the decoder flags:
|
| 732 |
+
* LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK,
|
| 733 |
+
* LZMA_TELL_ANY_CHECK, LZMA_IGNORE_CHECK,
|
| 734 |
+
* LZMA_CONCATENATED, LZMA_FAIL_FAST
|
| 735 |
+
*
|
| 736 |
+
* \return Possible lzma_ret values:
|
| 737 |
+
* - LZMA_OK: Initialization was successful.
|
| 738 |
+
* - LZMA_MEM_ERROR: Cannot allocate memory.
|
| 739 |
+
* - LZMA_OPTIONS_ERROR: Unsupported flags
|
| 740 |
+
* - LZMA_PROG_ERROR
|
| 741 |
+
*/
|
| 742 |
+
extern LZMA_API(lzma_ret) lzma_stream_decoder(
|
| 743 |
+
lzma_stream *strm, uint64_t memlimit, uint32_t flags)
|
| 744 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 745 |
+
|
| 746 |
+
|
| 747 |
+
/**
|
| 748 |
+
* \brief Initialize multithreaded .xz Stream decoder
|
| 749 |
+
*
|
| 750 |
+
* The decoder can decode multiple Blocks in parallel. This requires that each
|
| 751 |
+
* Block Header contains the Compressed Size and Uncompressed size fields
|
| 752 |
+
* which are added by the multi-threaded encoder, see lzma_stream_encoder_mt().
|
| 753 |
+
*
|
| 754 |
+
* A Stream with one Block will only utilize one thread. A Stream with multiple
|
| 755 |
+
* Blocks but without size information in Block Headers will be processed in
|
| 756 |
+
* single-threaded mode in the same way as done by lzma_stream_decoder().
|
| 757 |
+
* Concatenated Streams are processed one Stream at a time; no inter-Stream
|
| 758 |
+
* parallelization is done.
|
| 759 |
+
*
|
| 760 |
+
* This function behaves like lzma_stream_decoder() when options->threads == 1
|
| 761 |
+
* and options->memlimit_threading <= 1.
|
| 762 |
+
*
|
| 763 |
+
* \param strm Pointer to lzma_stream that is at least initialized
|
| 764 |
+
* with LZMA_STREAM_INIT.
|
| 765 |
+
* \param options Pointer to multithreaded compression options
|
| 766 |
+
*
|
| 767 |
+
* \return Possible lzma_ret values:
|
| 768 |
+
* - LZMA_OK: Initialization was successful.
|
| 769 |
+
* - LZMA_MEM_ERROR: Cannot allocate memory.
|
| 770 |
+
* - LZMA_MEMLIMIT_ERROR: Memory usage limit was reached.
|
| 771 |
+
* - LZMA_OPTIONS_ERROR: Unsupported flags.
|
| 772 |
+
* - LZMA_PROG_ERROR
|
| 773 |
+
*/
|
| 774 |
+
extern LZMA_API(lzma_ret) lzma_stream_decoder_mt(
|
| 775 |
+
lzma_stream *strm, const lzma_mt *options)
|
| 776 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 777 |
+
|
| 778 |
+
|
| 779 |
+
/**
|
| 780 |
+
* \brief Decode .xz, .lzma, and .lz (lzip) files with autodetection
|
| 781 |
+
*
|
| 782 |
+
* This decoder autodetects between the .xz, .lzma, and .lz file formats,
|
| 783 |
+
* and calls lzma_stream_decoder(), lzma_alone_decoder(), or
|
| 784 |
+
* lzma_lzip_decoder() once the type of the input file has been detected.
|
| 785 |
+
*
|
| 786 |
+
* Support for .lz was added in 5.4.0.
|
| 787 |
+
*
|
| 788 |
+
* If the flag LZMA_CONCATENATED is used and the input is a .lzma file:
|
| 789 |
+
* For historical reasons concatenated .lzma files aren't supported.
|
| 790 |
+
* If there is trailing data after one .lzma stream, lzma_code() will
|
| 791 |
+
* return LZMA_DATA_ERROR. (lzma_alone_decoder() doesn't have such a check
|
| 792 |
+
* as it doesn't support any decoder flags. It will return LZMA_STREAM_END
|
| 793 |
+
* after one .lzma stream.)
|
| 794 |
+
*
|
| 795 |
+
* \param strm Pointer to lzma_stream that is at least initialized
|
| 796 |
+
* with LZMA_STREAM_INIT.
|
| 797 |
+
* \param memlimit Memory usage limit as bytes. Use UINT64_MAX
|
| 798 |
+
* to effectively disable the limiter. liblzma
|
| 799 |
+
* 5.2.3 and earlier don't allow 0 here and return
|
| 800 |
+
* LZMA_PROG_ERROR; later versions treat 0 as if 1
|
| 801 |
+
* had been specified.
|
| 802 |
+
* \param flags Bitwise-or of zero or more of the decoder flags:
|
| 803 |
+
* LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK,
|
| 804 |
+
* LZMA_TELL_ANY_CHECK, LZMA_IGNORE_CHECK,
|
| 805 |
+
* LZMA_CONCATENATED, LZMA_FAIL_FAST
|
| 806 |
+
*
|
| 807 |
+
* \return Possible lzma_ret values:
|
| 808 |
+
* - LZMA_OK: Initialization was successful.
|
| 809 |
+
* - LZMA_MEM_ERROR: Cannot allocate memory.
|
| 810 |
+
* - LZMA_OPTIONS_ERROR: Unsupported flags
|
| 811 |
+
* - LZMA_PROG_ERROR
|
| 812 |
+
*/
|
| 813 |
+
extern LZMA_API(lzma_ret) lzma_auto_decoder(
|
| 814 |
+
lzma_stream *strm, uint64_t memlimit, uint32_t flags)
|
| 815 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 816 |
+
|
| 817 |
+
|
| 818 |
+
/**
|
| 819 |
+
* \brief Initialize .lzma decoder (legacy file format)
|
| 820 |
+
*
|
| 821 |
+
* Valid 'action' arguments to lzma_code() are LZMA_RUN and LZMA_FINISH.
|
| 822 |
+
* There is no need to use LZMA_FINISH, but it's allowed because it may
|
| 823 |
+
* simplify certain types of applications.
|
| 824 |
+
*
|
| 825 |
+
* \param strm Pointer to lzma_stream that is at least initialized
|
| 826 |
+
* with LZMA_STREAM_INIT.
|
| 827 |
+
* \param memlimit Memory usage limit as bytes. Use UINT64_MAX
|
| 828 |
+
* to effectively disable the limiter. liblzma
|
| 829 |
+
* 5.2.3 and earlier don't allow 0 here and return
|
| 830 |
+
* LZMA_PROG_ERROR; later versions treat 0 as if 1
|
| 831 |
+
* had been specified.
|
| 832 |
+
*
|
| 833 |
+
* \return Possible lzma_ret values:
|
| 834 |
+
* - LZMA_OK
|
| 835 |
+
* - LZMA_MEM_ERROR
|
| 836 |
+
* - LZMA_PROG_ERROR
|
| 837 |
+
*/
|
| 838 |
+
extern LZMA_API(lzma_ret) lzma_alone_decoder(
|
| 839 |
+
lzma_stream *strm, uint64_t memlimit)
|
| 840 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 841 |
+
|
| 842 |
+
|
| 843 |
+
/**
|
| 844 |
+
* \brief Initialize .lz (lzip) decoder (a foreign file format)
|
| 845 |
+
*
|
| 846 |
+
* This decoder supports the .lz format version 0 and the unextended .lz
|
| 847 |
+
* format version 1:
|
| 848 |
+
*
|
| 849 |
+
* - Files in the format version 0 were produced by lzip 1.3 and older.
|
| 850 |
+
* Such files aren't common but may be found from file archives
|
| 851 |
+
* as a few source packages were released in this format. People
|
| 852 |
+
* might have old personal files in this format too. Decompression
|
| 853 |
+
* support for the format version 0 was removed in lzip 1.18.
|
| 854 |
+
*
|
| 855 |
+
* - lzip 1.3 added decompression support for .lz format version 1 files.
|
| 856 |
+
* Compression support was added in lzip 1.4. In lzip 1.6 the .lz format
|
| 857 |
+
* version 1 was extended to support the Sync Flush marker. This extension
|
| 858 |
+
* is not supported by liblzma. lzma_code() will return LZMA_DATA_ERROR
|
| 859 |
+
* at the location of the Sync Flush marker. In practice files with
|
| 860 |
+
* the Sync Flush marker are very rare and thus liblzma can decompress
|
| 861 |
+
* almost all .lz files.
|
| 862 |
+
*
|
| 863 |
+
* Just like with lzma_stream_decoder() for .xz files, LZMA_CONCATENATED
|
| 864 |
+
* should be used when decompressing normal standalone .lz files.
|
| 865 |
+
*
|
| 866 |
+
* The .lz format allows putting non-.lz data at the end of a file after at
|
| 867 |
+
* least one valid .lz member. That is, one can append custom data at the end
|
| 868 |
+
* of a .lz file and the decoder is required to ignore it. In liblzma this
|
| 869 |
+
* is relevant only when LZMA_CONCATENATED is used. In that case lzma_code()
|
| 870 |
+
* will return LZMA_STREAM_END and leave lzma_stream.next_in pointing to
|
| 871 |
+
* the first byte of the non-.lz data. An exception to this is if the first
|
| 872 |
+
* 1-3 bytes of the non-.lz data are identical to the .lz magic bytes
|
| 873 |
+
* (0x4C, 0x5A, 0x49, 0x50; "LZIP" in US-ASCII). In such a case the 1-3 bytes
|
| 874 |
+
* will have been ignored by lzma_code(). If one wishes to locate the non-.lz
|
| 875 |
+
* data reliably, one must ensure that the first byte isn't 0x4C. Actually
|
| 876 |
+
* one should ensure that none of the first four bytes of trailing data are
|
| 877 |
+
* equal to the magic bytes because lzip >= 1.20 requires it by default.
|
| 878 |
+
*
|
| 879 |
+
* \param strm Pointer to lzma_stream that is at least initialized
|
| 880 |
+
* with LZMA_STREAM_INIT.
|
| 881 |
+
* \param memlimit Memory usage limit as bytes. Use UINT64_MAX
|
| 882 |
+
* to effectively disable the limiter.
|
| 883 |
+
* \param flags Bitwise-or of flags, or zero for no flags.
|
| 884 |
+
* All decoder flags listed above are supported
|
| 885 |
+
* although only LZMA_CONCATENATED and (in very rare
|
| 886 |
+
* cases) LZMA_IGNORE_CHECK are actually useful.
|
| 887 |
+
* LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK,
|
| 888 |
+
* and LZMA_FAIL_FAST do nothing. LZMA_TELL_ANY_CHECK
|
| 889 |
+
* is supported for consistency only as CRC32 is
|
| 890 |
+
* always used in the .lz format.
|
| 891 |
+
*
|
| 892 |
+
* \return Possible lzma_ret values:
|
| 893 |
+
* - LZMA_OK: Initialization was successful.
|
| 894 |
+
* - LZMA_MEM_ERROR: Cannot allocate memory.
|
| 895 |
+
* - LZMA_OPTIONS_ERROR: Unsupported flags
|
| 896 |
+
* - LZMA_PROG_ERROR
|
| 897 |
+
*/
|
| 898 |
+
extern LZMA_API(lzma_ret) lzma_lzip_decoder(
|
| 899 |
+
lzma_stream *strm, uint64_t memlimit, uint32_t flags)
|
| 900 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 901 |
+
|
| 902 |
+
|
| 903 |
+
/**
|
| 904 |
+
* \brief Single-call .xz Stream decoder
|
| 905 |
+
*
|
| 906 |
+
* \param memlimit Pointer to how much memory the decoder is allowed
|
| 907 |
+
* to allocate. The value pointed by this pointer is
|
| 908 |
+
* modified if and only if LZMA_MEMLIMIT_ERROR is
|
| 909 |
+
* returned.
|
| 910 |
+
* \param flags Bitwise-or of zero or more of the decoder flags:
|
| 911 |
+
* LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK,
|
| 912 |
+
* LZMA_IGNORE_CHECK, LZMA_CONCATENATED,
|
| 913 |
+
* LZMA_FAIL_FAST. Note that LZMA_TELL_ANY_CHECK
|
| 914 |
+
* is not allowed and will return LZMA_PROG_ERROR.
|
| 915 |
+
* \param allocator lzma_allocator for custom allocator functions.
|
| 916 |
+
* Set to NULL to use malloc() and free().
|
| 917 |
+
* \param in Beginning of the input buffer
|
| 918 |
+
* \param in_pos The next byte will be read from in[*in_pos].
|
| 919 |
+
* *in_pos is updated only if decoding succeeds.
|
| 920 |
+
* \param in_size Size of the input buffer; the first byte that
|
| 921 |
+
* won't be read is in[in_size].
|
| 922 |
+
* \param[out] out Beginning of the output buffer
|
| 923 |
+
* \param[out] out_pos The next byte will be written to out[*out_pos].
|
| 924 |
+
* *out_pos is updated only if decoding succeeds.
|
| 925 |
+
* \param out_size Size of the out buffer; the first byte into
|
| 926 |
+
* which no data is written to is out[out_size].
|
| 927 |
+
*
|
| 928 |
+
* \return Possible lzma_ret values:
|
| 929 |
+
* - LZMA_OK: Decoding was successful.
|
| 930 |
+
* - LZMA_FORMAT_ERROR
|
| 931 |
+
* - LZMA_OPTIONS_ERROR
|
| 932 |
+
* - LZMA_DATA_ERROR
|
| 933 |
+
* - LZMA_NO_CHECK: This can be returned only if using
|
| 934 |
+
* the LZMA_TELL_NO_CHECK flag.
|
| 935 |
+
* - LZMA_UNSUPPORTED_CHECK: This can be returned only if using
|
| 936 |
+
* the LZMA_TELL_UNSUPPORTED_CHECK flag.
|
| 937 |
+
* - LZMA_MEM_ERROR
|
| 938 |
+
* - LZMA_MEMLIMIT_ERROR: Memory usage limit was reached.
|
| 939 |
+
* The minimum required memlimit value was stored to *memlimit.
|
| 940 |
+
* - LZMA_BUF_ERROR: Output buffer was too small.
|
| 941 |
+
* - LZMA_PROG_ERROR
|
| 942 |
+
*/
|
| 943 |
+
extern LZMA_API(lzma_ret) lzma_stream_buffer_decode(
|
| 944 |
+
uint64_t *memlimit, uint32_t flags,
|
| 945 |
+
const lzma_allocator *allocator,
|
| 946 |
+
const uint8_t *in, size_t *in_pos, size_t in_size,
|
| 947 |
+
uint8_t *out, size_t *out_pos, size_t out_size)
|
| 948 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 949 |
+
|
| 950 |
+
|
| 951 |
+
/**
|
| 952 |
+
* \brief MicroLZMA decoder
|
| 953 |
+
*
|
| 954 |
+
* See lzma_microlzma_encoder() for more information.
|
| 955 |
+
*
|
| 956 |
+
* The lzma_code() usage with this decoder is completely normal. The
|
| 957 |
+
* special behavior of lzma_code() applies to lzma_microlzma_encoder() only.
|
| 958 |
+
*
|
| 959 |
+
* \param strm Pointer to lzma_stream that is at least initialized
|
| 960 |
+
* with LZMA_STREAM_INIT.
|
| 961 |
+
* \param comp_size Compressed size of the MicroLZMA stream.
|
| 962 |
+
* The caller must somehow know this exactly.
|
| 963 |
+
* \param uncomp_size Uncompressed size of the MicroLZMA stream.
|
| 964 |
+
* If the exact uncompressed size isn't known, this
|
| 965 |
+
* can be set to a value that is at most as big as
|
| 966 |
+
* the exact uncompressed size would be, but then the
|
| 967 |
+
* next argument uncomp_size_is_exact must be false.
|
| 968 |
+
* \param uncomp_size_is_exact
|
| 969 |
+
* If true, uncomp_size must be exactly correct.
|
| 970 |
+
* This will improve error detection at the end of
|
| 971 |
+
* the stream. If the exact uncompressed size isn't
|
| 972 |
+
* known, this must be false. uncomp_size must still
|
| 973 |
+
* be at most as big as the exact uncompressed size
|
| 974 |
+
* is. Setting this to false when the exact size is
|
| 975 |
+
* known will work but error detection at the end of
|
| 976 |
+
* the stream will be weaker.
|
| 977 |
+
* \param dict_size LZMA dictionary size that was used when
|
| 978 |
+
* compressing the data. It is OK to use a bigger
|
| 979 |
+
* value too but liblzma will then allocate more
|
| 980 |
+
* memory than would actually be required and error
|
| 981 |
+
* detection will be slightly worse. (Note that with
|
| 982 |
+
* the implementation in XZ Embedded it doesn't
|
| 983 |
+
* affect the memory usage if one specifies bigger
|
| 984 |
+
* dictionary than actually required.)
|
| 985 |
+
*
|
| 986 |
+
* \return Possible lzma_ret values:
|
| 987 |
+
* - LZMA_OK
|
| 988 |
+
* - LZMA_MEM_ERROR
|
| 989 |
+
* - LZMA_OPTIONS_ERROR
|
| 990 |
+
* - LZMA_PROG_ERROR
|
| 991 |
+
*/
|
| 992 |
+
extern LZMA_API(lzma_ret) lzma_microlzma_decoder(
|
| 993 |
+
lzma_stream *strm, uint64_t comp_size,
|
| 994 |
+
uint64_t uncomp_size, lzma_bool uncomp_size_is_exact,
|
| 995 |
+
uint32_t dict_size) lzma_nothrow;
|
llava_next/include/lzma/delta.h
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* SPDX-License-Identifier: 0BSD */
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* \file lzma/delta.h
|
| 5 |
+
* \brief Delta filter
|
| 6 |
+
* \note Never include this file directly. Use <lzma.h> instead.
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
/*
|
| 10 |
+
* Author: Lasse Collin
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
#ifndef LZMA_H_INTERNAL
|
| 14 |
+
# error Never include this file directly. Use <lzma.h> instead.
|
| 15 |
+
#endif
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
/**
|
| 19 |
+
* \brief Filter ID
|
| 20 |
+
*
|
| 21 |
+
* Filter ID of the Delta filter. This is used as lzma_filter.id.
|
| 22 |
+
*/
|
| 23 |
+
#define LZMA_FILTER_DELTA LZMA_VLI_C(0x03)
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
/**
|
| 27 |
+
* \brief Type of the delta calculation
|
| 28 |
+
*
|
| 29 |
+
* Currently only byte-wise delta is supported. Other possible types could
|
| 30 |
+
* be, for example, delta of 16/32/64-bit little/big endian integers, but
|
| 31 |
+
* these are not currently planned since byte-wise delta is almost as good.
|
| 32 |
+
*/
|
| 33 |
+
typedef enum {
|
| 34 |
+
LZMA_DELTA_TYPE_BYTE
|
| 35 |
+
} lzma_delta_type;
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
/**
|
| 39 |
+
* \brief Options for the Delta filter
|
| 40 |
+
*
|
| 41 |
+
* These options are needed by both encoder and decoder.
|
| 42 |
+
*/
|
| 43 |
+
typedef struct {
|
| 44 |
+
/** For now, this must always be LZMA_DELTA_TYPE_BYTE. */
|
| 45 |
+
lzma_delta_type type;
|
| 46 |
+
|
| 47 |
+
/**
|
| 48 |
+
* \brief Delta distance
|
| 49 |
+
*
|
| 50 |
+
* With the only currently supported type, LZMA_DELTA_TYPE_BYTE,
|
| 51 |
+
* the distance is as bytes.
|
| 52 |
+
*
|
| 53 |
+
* Examples:
|
| 54 |
+
* - 16-bit stereo audio: distance = 4 bytes
|
| 55 |
+
* - 24-bit RGB image data: distance = 3 bytes
|
| 56 |
+
*/
|
| 57 |
+
uint32_t dist;
|
| 58 |
+
|
| 59 |
+
/**
|
| 60 |
+
* \brief Minimum value for lzma_options_delta.dist.
|
| 61 |
+
*/
|
| 62 |
+
# define LZMA_DELTA_DIST_MIN 1
|
| 63 |
+
|
| 64 |
+
/**
|
| 65 |
+
* \brief Maximum value for lzma_options_delta.dist.
|
| 66 |
+
*/
|
| 67 |
+
# define LZMA_DELTA_DIST_MAX 256
|
| 68 |
+
|
| 69 |
+
/*
|
| 70 |
+
* Reserved space to allow possible future extensions without
|
| 71 |
+
* breaking the ABI. You should not touch these, because the names
|
| 72 |
+
* of these variables may change. These are and will never be used
|
| 73 |
+
* when type is LZMA_DELTA_TYPE_BYTE, so it is safe to leave these
|
| 74 |
+
* uninitialized.
|
| 75 |
+
*/
|
| 76 |
+
|
| 77 |
+
/** \private Reserved member. */
|
| 78 |
+
uint32_t reserved_int1;
|
| 79 |
+
|
| 80 |
+
/** \private Reserved member. */
|
| 81 |
+
uint32_t reserved_int2;
|
| 82 |
+
|
| 83 |
+
/** \private Reserved member. */
|
| 84 |
+
uint32_t reserved_int3;
|
| 85 |
+
|
| 86 |
+
/** \private Reserved member. */
|
| 87 |
+
uint32_t reserved_int4;
|
| 88 |
+
|
| 89 |
+
/** \private Reserved member. */
|
| 90 |
+
void *reserved_ptr1;
|
| 91 |
+
|
| 92 |
+
/** \private Reserved member. */
|
| 93 |
+
void *reserved_ptr2;
|
| 94 |
+
|
| 95 |
+
} lzma_options_delta;
|
llava_next/include/lzma/filter.h
ADDED
|
@@ -0,0 +1,769 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* SPDX-License-Identifier: 0BSD */
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* \file lzma/filter.h
|
| 5 |
+
* \brief Common filter related types and functions
|
| 6 |
+
* \note Never include this file directly. Use <lzma.h> instead.
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
/*
|
| 10 |
+
* Author: Lasse Collin
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
#ifndef LZMA_H_INTERNAL
|
| 14 |
+
# error Never include this file directly. Use <lzma.h> instead.
|
| 15 |
+
#endif
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
/**
|
| 19 |
+
* \brief Maximum number of filters in a chain
|
| 20 |
+
*
|
| 21 |
+
* A filter chain can have 1-4 filters, of which three are allowed to change
|
| 22 |
+
* the size of the data. Usually only one or two filters are needed.
|
| 23 |
+
*/
|
| 24 |
+
#define LZMA_FILTERS_MAX 4
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* \brief Filter options
|
| 29 |
+
*
|
| 30 |
+
* This structure is used to pass a Filter ID and a pointer to the filter's
|
| 31 |
+
* options to liblzma. A few functions work with a single lzma_filter
|
| 32 |
+
* structure, while most functions expect a filter chain.
|
| 33 |
+
*
|
| 34 |
+
* A filter chain is indicated with an array of lzma_filter structures.
|
| 35 |
+
* The array is terminated with .id = LZMA_VLI_UNKNOWN. Thus, the filter
|
| 36 |
+
* array must have LZMA_FILTERS_MAX + 1 elements (that is, five) to
|
| 37 |
+
* be able to hold any arbitrary filter chain. This is important when
|
| 38 |
+
* using lzma_block_header_decode() from block.h, because a filter array
|
| 39 |
+
* that is too small would make liblzma write past the end of the array.
|
| 40 |
+
*/
|
| 41 |
+
typedef struct {
|
| 42 |
+
/**
|
| 43 |
+
* \brief Filter ID
|
| 44 |
+
*
|
| 45 |
+
* Use constants whose name begin with 'LZMA_FILTER_' to specify
|
| 46 |
+
* different filters. In an array of lzma_filter structures, use
|
| 47 |
+
* LZMA_VLI_UNKNOWN to indicate end of filters.
|
| 48 |
+
*
|
| 49 |
+
* \note This is not an enum, because on some systems enums
|
| 50 |
+
* cannot be 64-bit.
|
| 51 |
+
*/
|
| 52 |
+
lzma_vli id;
|
| 53 |
+
|
| 54 |
+
/**
|
| 55 |
+
* \brief Pointer to filter-specific options structure
|
| 56 |
+
*
|
| 57 |
+
* If the filter doesn't need options, set this to NULL. If id is
|
| 58 |
+
* set to LZMA_VLI_UNKNOWN, options is ignored, and thus
|
| 59 |
+
* doesn't need be initialized.
|
| 60 |
+
*/
|
| 61 |
+
void *options;
|
| 62 |
+
|
| 63 |
+
} lzma_filter;
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
/**
|
| 67 |
+
* \brief Test if the given Filter ID is supported for encoding
|
| 68 |
+
*
|
| 69 |
+
* \param id Filter ID
|
| 70 |
+
*
|
| 71 |
+
* \return lzma_bool:
|
| 72 |
+
* - true if the Filter ID is supported for encoding by this
|
| 73 |
+
* liblzma build.
|
| 74 |
+
* - false otherwise.
|
| 75 |
+
*/
|
| 76 |
+
extern LZMA_API(lzma_bool) lzma_filter_encoder_is_supported(lzma_vli id)
|
| 77 |
+
lzma_nothrow lzma_attr_const;
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
/**
|
| 81 |
+
* \brief Test if the given Filter ID is supported for decoding
|
| 82 |
+
*
|
| 83 |
+
* \param id Filter ID
|
| 84 |
+
*
|
| 85 |
+
* \return lzma_bool:
|
| 86 |
+
* - true if the Filter ID is supported for decoding by this
|
| 87 |
+
* liblzma build.
|
| 88 |
+
* - false otherwise.
|
| 89 |
+
*/
|
| 90 |
+
extern LZMA_API(lzma_bool) lzma_filter_decoder_is_supported(lzma_vli id)
|
| 91 |
+
lzma_nothrow lzma_attr_const;
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
/**
|
| 95 |
+
* \brief Copy the filters array
|
| 96 |
+
*
|
| 97 |
+
* Copy the Filter IDs and filter-specific options from src to dest.
|
| 98 |
+
* Up to LZMA_FILTERS_MAX filters are copied, plus the terminating
|
| 99 |
+
* .id == LZMA_VLI_UNKNOWN. Thus, dest should have at least
|
| 100 |
+
* LZMA_FILTERS_MAX + 1 elements space unless the caller knows that
|
| 101 |
+
* src is smaller than that.
|
| 102 |
+
*
|
| 103 |
+
* Unless the filter-specific options is NULL, the Filter ID has to be
|
| 104 |
+
* supported by liblzma, because liblzma needs to know the size of every
|
| 105 |
+
* filter-specific options structure. The filter-specific options are not
|
| 106 |
+
* validated. If options is NULL, any unsupported Filter IDs are copied
|
| 107 |
+
* without returning an error.
|
| 108 |
+
*
|
| 109 |
+
* Old filter-specific options in dest are not freed, so dest doesn't
|
| 110 |
+
* need to be initialized by the caller in any way.
|
| 111 |
+
*
|
| 112 |
+
* If an error occurs, memory possibly already allocated by this function
|
| 113 |
+
* is always freed. liblzma versions older than 5.2.7 may modify the dest
|
| 114 |
+
* array and leave its contents in an undefined state if an error occurs.
|
| 115 |
+
* liblzma 5.2.7 and newer only modify the dest array when returning LZMA_OK.
|
| 116 |
+
*
|
| 117 |
+
* \param src Array of filters terminated with
|
| 118 |
+
* .id == LZMA_VLI_UNKNOWN.
|
| 119 |
+
* \param[out] dest Destination filter array
|
| 120 |
+
* \param allocator lzma_allocator for custom allocator functions.
|
| 121 |
+
* Set to NULL to use malloc() and free().
|
| 122 |
+
*
|
| 123 |
+
* \return Possible lzma_ret values:
|
| 124 |
+
* - LZMA_OK
|
| 125 |
+
* - LZMA_MEM_ERROR
|
| 126 |
+
* - LZMA_OPTIONS_ERROR: Unsupported Filter ID and its options
|
| 127 |
+
* is not NULL.
|
| 128 |
+
* - LZMA_PROG_ERROR: src or dest is NULL.
|
| 129 |
+
*/
|
| 130 |
+
extern LZMA_API(lzma_ret) lzma_filters_copy(
|
| 131 |
+
const lzma_filter *src, lzma_filter *dest,
|
| 132 |
+
const lzma_allocator *allocator)
|
| 133 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
/**
|
| 137 |
+
* \brief Free the options in the array of lzma_filter structures
|
| 138 |
+
*
|
| 139 |
+
* This frees the filter chain options. The filters array itself is not freed.
|
| 140 |
+
*
|
| 141 |
+
* The filters array must have at most LZMA_FILTERS_MAX + 1 elements
|
| 142 |
+
* including the terminating element which must have .id = LZMA_VLI_UNKNOWN.
|
| 143 |
+
* For all elements before the terminating element:
|
| 144 |
+
* - options will be freed using the given lzma_allocator or,
|
| 145 |
+
* if allocator is NULL, using free().
|
| 146 |
+
* - options will be set to NULL.
|
| 147 |
+
* - id will be set to LZMA_VLI_UNKNOWN.
|
| 148 |
+
*
|
| 149 |
+
* If filters is NULL, this does nothing. Again, this never frees the
|
| 150 |
+
* filters array itself.
|
| 151 |
+
*
|
| 152 |
+
* \param filters Array of filters terminated with
|
| 153 |
+
* .id == LZMA_VLI_UNKNOWN.
|
| 154 |
+
* \param allocator lzma_allocator for custom allocator functions.
|
| 155 |
+
* Set to NULL to use malloc() and free().
|
| 156 |
+
*/
|
| 157 |
+
extern LZMA_API(void) lzma_filters_free(
|
| 158 |
+
lzma_filter *filters, const lzma_allocator *allocator)
|
| 159 |
+
lzma_nothrow;
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
/**
|
| 163 |
+
* \brief Calculate approximate memory requirements for raw encoder
|
| 164 |
+
*
|
| 165 |
+
* This function can be used to calculate the memory requirements for
|
| 166 |
+
* Block and Stream encoders too because Block and Stream encoders don't
|
| 167 |
+
* need significantly more memory than raw encoder.
|
| 168 |
+
*
|
| 169 |
+
* \param filters Array of filters terminated with
|
| 170 |
+
* .id == LZMA_VLI_UNKNOWN.
|
| 171 |
+
*
|
| 172 |
+
* \return Number of bytes of memory required for the given
|
| 173 |
+
* filter chain when encoding or UINT64_MAX on error.
|
| 174 |
+
*/
|
| 175 |
+
extern LZMA_API(uint64_t) lzma_raw_encoder_memusage(const lzma_filter *filters)
|
| 176 |
+
lzma_nothrow lzma_attr_pure;
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
/**
|
| 180 |
+
* \brief Calculate approximate memory requirements for raw decoder
|
| 181 |
+
*
|
| 182 |
+
* This function can be used to calculate the memory requirements for
|
| 183 |
+
* Block and Stream decoders too because Block and Stream decoders don't
|
| 184 |
+
* need significantly more memory than raw decoder.
|
| 185 |
+
*
|
| 186 |
+
* \param filters Array of filters terminated with
|
| 187 |
+
* .id == LZMA_VLI_UNKNOWN.
|
| 188 |
+
*
|
| 189 |
+
* \return Number of bytes of memory required for the given
|
| 190 |
+
* filter chain when decoding or UINT64_MAX on error.
|
| 191 |
+
*/
|
| 192 |
+
extern LZMA_API(uint64_t) lzma_raw_decoder_memusage(const lzma_filter *filters)
|
| 193 |
+
lzma_nothrow lzma_attr_pure;
|
| 194 |
+
|
| 195 |
+
|
| 196 |
+
/**
|
| 197 |
+
* \brief Initialize raw encoder
|
| 198 |
+
*
|
| 199 |
+
* This function may be useful when implementing custom file formats.
|
| 200 |
+
*
|
| 201 |
+
* The 'action' with lzma_code() can be LZMA_RUN, LZMA_SYNC_FLUSH (if the
|
| 202 |
+
* filter chain supports it), or LZMA_FINISH.
|
| 203 |
+
*
|
| 204 |
+
* \param strm Pointer to lzma_stream that is at least
|
| 205 |
+
* initialized with LZMA_STREAM_INIT.
|
| 206 |
+
* \param filters Array of filters terminated with
|
| 207 |
+
* .id == LZMA_VLI_UNKNOWN.
|
| 208 |
+
*
|
| 209 |
+
* \return Possible lzma_ret values:
|
| 210 |
+
* - LZMA_OK
|
| 211 |
+
* - LZMA_MEM_ERROR
|
| 212 |
+
* - LZMA_OPTIONS_ERROR
|
| 213 |
+
* - LZMA_PROG_ERROR
|
| 214 |
+
*/
|
| 215 |
+
extern LZMA_API(lzma_ret) lzma_raw_encoder(
|
| 216 |
+
lzma_stream *strm, const lzma_filter *filters)
|
| 217 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 218 |
+
|
| 219 |
+
|
| 220 |
+
/**
|
| 221 |
+
* \brief Initialize raw decoder
|
| 222 |
+
*
|
| 223 |
+
* The initialization of raw decoder goes similarly to raw encoder.
|
| 224 |
+
*
|
| 225 |
+
* The 'action' with lzma_code() can be LZMA_RUN or LZMA_FINISH. Using
|
| 226 |
+
* LZMA_FINISH is not required, it is supported just for convenience.
|
| 227 |
+
*
|
| 228 |
+
* \param strm Pointer to lzma_stream that is at least
|
| 229 |
+
* initialized with LZMA_STREAM_INIT.
|
| 230 |
+
* \param filters Array of filters terminated with
|
| 231 |
+
* .id == LZMA_VLI_UNKNOWN.
|
| 232 |
+
*
|
| 233 |
+
* \return Possible lzma_ret values:
|
| 234 |
+
* - LZMA_OK
|
| 235 |
+
* - LZMA_MEM_ERROR
|
| 236 |
+
* - LZMA_OPTIONS_ERROR
|
| 237 |
+
* - LZMA_PROG_ERROR
|
| 238 |
+
*/
|
| 239 |
+
extern LZMA_API(lzma_ret) lzma_raw_decoder(
|
| 240 |
+
lzma_stream *strm, const lzma_filter *filters)
|
| 241 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 242 |
+
|
| 243 |
+
|
| 244 |
+
/**
|
| 245 |
+
* \brief Update the filter chain in the encoder
|
| 246 |
+
*
|
| 247 |
+
* This function may be called after lzma_code() has returned LZMA_STREAM_END
|
| 248 |
+
* when LZMA_FULL_BARRIER, LZMA_FULL_FLUSH, or LZMA_SYNC_FLUSH was used:
|
| 249 |
+
*
|
| 250 |
+
* - After LZMA_FULL_BARRIER or LZMA_FULL_FLUSH: Single-threaded .xz Stream
|
| 251 |
+
* encoder (lzma_stream_encoder()) and (since liblzma 5.4.0) multi-threaded
|
| 252 |
+
* Stream encoder (lzma_stream_encoder_mt()) allow setting a new filter
|
| 253 |
+
* chain to be used for the next Block(s).
|
| 254 |
+
*
|
| 255 |
+
* - After LZMA_SYNC_FLUSH: Raw encoder (lzma_raw_encoder()),
|
| 256 |
+
* Block encoder (lzma_block_encoder()), and single-threaded .xz Stream
|
| 257 |
+
* encoder (lzma_stream_encoder()) allow changing certain filter-specific
|
| 258 |
+
* options in the middle of encoding. The actual filters in the chain
|
| 259 |
+
* (Filter IDs) must not be changed! Currently only the lc, lp, and pb
|
| 260 |
+
* options of LZMA2 (not LZMA1) can be changed this way.
|
| 261 |
+
*
|
| 262 |
+
* - In the future some filters might allow changing some of their options
|
| 263 |
+
* without any barrier or flushing but currently such filters don't exist.
|
| 264 |
+
*
|
| 265 |
+
* This function may also be called when no data has been compressed yet
|
| 266 |
+
* although this is rarely useful. In that case, this function will behave
|
| 267 |
+
* as if LZMA_FULL_FLUSH (Stream encoders) or LZMA_SYNC_FLUSH (Raw or Block
|
| 268 |
+
* encoder) had been used right before calling this function.
|
| 269 |
+
*
|
| 270 |
+
* \param strm Pointer to lzma_stream that is at least
|
| 271 |
+
* initialized with LZMA_STREAM_INIT.
|
| 272 |
+
* \param filters Array of filters terminated with
|
| 273 |
+
* .id == LZMA_VLI_UNKNOWN.
|
| 274 |
+
*
|
| 275 |
+
* \return Possible lzma_ret values:
|
| 276 |
+
* - LZMA_OK
|
| 277 |
+
* - LZMA_MEM_ERROR
|
| 278 |
+
* - LZMA_MEMLIMIT_ERROR
|
| 279 |
+
* - LZMA_OPTIONS_ERROR
|
| 280 |
+
* - LZMA_PROG_ERROR
|
| 281 |
+
*/
|
| 282 |
+
extern LZMA_API(lzma_ret) lzma_filters_update(
|
| 283 |
+
lzma_stream *strm, const lzma_filter *filters) lzma_nothrow;
|
| 284 |
+
|
| 285 |
+
|
| 286 |
+
/**
|
| 287 |
+
* \brief Single-call raw encoder
|
| 288 |
+
*
|
| 289 |
+
* \note There is no function to calculate how big output buffer
|
| 290 |
+
* would surely be big enough. (lzma_stream_buffer_bound()
|
| 291 |
+
* works only for lzma_stream_buffer_encode(); raw encoder
|
| 292 |
+
* won't necessarily meet that bound.)
|
| 293 |
+
*
|
| 294 |
+
* \param filters Array of filters terminated with
|
| 295 |
+
* .id == LZMA_VLI_UNKNOWN.
|
| 296 |
+
* \param allocator lzma_allocator for custom allocator functions.
|
| 297 |
+
* Set to NULL to use malloc() and free().
|
| 298 |
+
* \param in Beginning of the input buffer
|
| 299 |
+
* \param in_size Size of the input buffer
|
| 300 |
+
* \param[out] out Beginning of the output buffer
|
| 301 |
+
* \param[out] out_pos The next byte will be written to out[*out_pos].
|
| 302 |
+
* *out_pos is updated only if encoding succeeds.
|
| 303 |
+
* \param out_size Size of the out buffer; the first byte into
|
| 304 |
+
* which no data is written to is out[out_size].
|
| 305 |
+
*
|
| 306 |
+
* \return Possible lzma_ret values:
|
| 307 |
+
* - LZMA_OK: Encoding was successful.
|
| 308 |
+
* - LZMA_BUF_ERROR: Not enough output buffer space.
|
| 309 |
+
* - LZMA_OPTIONS_ERROR
|
| 310 |
+
* - LZMA_MEM_ERROR
|
| 311 |
+
* - LZMA_DATA_ERROR
|
| 312 |
+
* - LZMA_PROG_ERROR
|
| 313 |
+
*/
|
| 314 |
+
extern LZMA_API(lzma_ret) lzma_raw_buffer_encode(
|
| 315 |
+
const lzma_filter *filters, const lzma_allocator *allocator,
|
| 316 |
+
const uint8_t *in, size_t in_size, uint8_t *out,
|
| 317 |
+
size_t *out_pos, size_t out_size) lzma_nothrow;
|
| 318 |
+
|
| 319 |
+
|
| 320 |
+
/**
|
| 321 |
+
* \brief Single-call raw decoder
|
| 322 |
+
*
|
| 323 |
+
* \param filters Array of filters terminated with
|
| 324 |
+
* .id == LZMA_VLI_UNKNOWN.
|
| 325 |
+
* \param allocator lzma_allocator for custom allocator functions.
|
| 326 |
+
* Set to NULL to use malloc() and free().
|
| 327 |
+
* \param in Beginning of the input buffer
|
| 328 |
+
* \param in_pos The next byte will be read from in[*in_pos].
|
| 329 |
+
* *in_pos is updated only if decoding succeeds.
|
| 330 |
+
* \param in_size Size of the input buffer; the first byte that
|
| 331 |
+
* won't be read is in[in_size].
|
| 332 |
+
* \param[out] out Beginning of the output buffer
|
| 333 |
+
* \param[out] out_pos The next byte will be written to out[*out_pos].
|
| 334 |
+
* *out_pos is updated only if encoding succeeds.
|
| 335 |
+
* \param out_size Size of the out buffer; the first byte into
|
| 336 |
+
* which no data is written to is out[out_size].
|
| 337 |
+
*
|
| 338 |
+
* \return Possible lzma_ret values:
|
| 339 |
+
* - LZMA_OK: Decoding was successful.
|
| 340 |
+
* - LZMA_BUF_ERROR: Not enough output buffer space.
|
| 341 |
+
* - LZMA_OPTIONS_ERROR
|
| 342 |
+
* - LZMA_MEM_ERROR
|
| 343 |
+
* - LZMA_DATA_ERROR
|
| 344 |
+
* - LZMA_PROG_ERROR
|
| 345 |
+
*/
|
| 346 |
+
extern LZMA_API(lzma_ret) lzma_raw_buffer_decode(
|
| 347 |
+
const lzma_filter *filters, const lzma_allocator *allocator,
|
| 348 |
+
const uint8_t *in, size_t *in_pos, size_t in_size,
|
| 349 |
+
uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow;
|
| 350 |
+
|
| 351 |
+
|
| 352 |
+
/**
|
| 353 |
+
* \brief Get the size of the Filter Properties field
|
| 354 |
+
*
|
| 355 |
+
* This function may be useful when implementing custom file formats
|
| 356 |
+
* using the raw encoder and decoder.
|
| 357 |
+
*
|
| 358 |
+
* \note This function validates the Filter ID, but does not
|
| 359 |
+
* necessarily validate the options. Thus, it is possible
|
| 360 |
+
* that this returns LZMA_OK while the following call to
|
| 361 |
+
* lzma_properties_encode() returns LZMA_OPTIONS_ERROR.
|
| 362 |
+
*
|
| 363 |
+
* \param[out] size Pointer to uint32_t to hold the size of the properties
|
| 364 |
+
* \param filter Filter ID and options (the size of the properties may
|
| 365 |
+
* vary depending on the options)
|
| 366 |
+
*
|
| 367 |
+
* \return Possible lzma_ret values:
|
| 368 |
+
* - LZMA_OK
|
| 369 |
+
* - LZMA_OPTIONS_ERROR
|
| 370 |
+
* - LZMA_PROG_ERROR
|
| 371 |
+
*/
|
| 372 |
+
extern LZMA_API(lzma_ret) lzma_properties_size(
|
| 373 |
+
uint32_t *size, const lzma_filter *filter) lzma_nothrow;
|
| 374 |
+
|
| 375 |
+
|
| 376 |
+
/**
|
| 377 |
+
* \brief Encode the Filter Properties field
|
| 378 |
+
*
|
| 379 |
+
* \note Even this function won't validate more options than actually
|
| 380 |
+
* necessary. Thus, it is possible that encoding the properties
|
| 381 |
+
* succeeds but using the same options to initialize the encoder
|
| 382 |
+
* will fail.
|
| 383 |
+
*
|
| 384 |
+
* \note If lzma_properties_size() indicated that the size
|
| 385 |
+
* of the Filter Properties field is zero, calling
|
| 386 |
+
* lzma_properties_encode() is not required, but it
|
| 387 |
+
* won't do any harm either.
|
| 388 |
+
*
|
| 389 |
+
* \param filter Filter ID and options
|
| 390 |
+
* \param[out] props Buffer to hold the encoded options. The size of
|
| 391 |
+
* the buffer must have been already determined with
|
| 392 |
+
* lzma_properties_size().
|
| 393 |
+
*
|
| 394 |
+
* \return Possible lzma_ret values:
|
| 395 |
+
* - LZMA_OK
|
| 396 |
+
* - LZMA_PROG_ERROR
|
| 397 |
+
*/
|
| 398 |
+
extern LZMA_API(lzma_ret) lzma_properties_encode(
|
| 399 |
+
const lzma_filter *filter, uint8_t *props) lzma_nothrow;
|
| 400 |
+
|
| 401 |
+
|
| 402 |
+
/**
|
| 403 |
+
* \brief Decode the Filter Properties field
|
| 404 |
+
*
|
| 405 |
+
* \param filter filter->id must have been set to the correct
|
| 406 |
+
* Filter ID. filter->options doesn't need to be
|
| 407 |
+
* initialized (it's not freed by this function). The
|
| 408 |
+
* decoded options will be stored in filter->options;
|
| 409 |
+
* it's application's responsibility to free it when
|
| 410 |
+
* appropriate. filter->options is set to NULL if
|
| 411 |
+
* there are no properties or if an error occurs.
|
| 412 |
+
* \param allocator lzma_allocator for custom allocator functions.
|
| 413 |
+
* Set to NULL to use malloc() and free().
|
| 414 |
+
* and in case of an error, also free().
|
| 415 |
+
* \param props Input buffer containing the properties.
|
| 416 |
+
* \param props_size Size of the properties. This must be the exact
|
| 417 |
+
* size; giving too much or too little input will
|
| 418 |
+
* return LZMA_OPTIONS_ERROR.
|
| 419 |
+
*
|
| 420 |
+
* \return Possible lzma_ret values:
|
| 421 |
+
* - LZMA_OK
|
| 422 |
+
* - LZMA_OPTIONS_ERROR
|
| 423 |
+
* - LZMA_MEM_ERROR
|
| 424 |
+
*/
|
| 425 |
+
extern LZMA_API(lzma_ret) lzma_properties_decode(
|
| 426 |
+
lzma_filter *filter, const lzma_allocator *allocator,
|
| 427 |
+
const uint8_t *props, size_t props_size) lzma_nothrow;
|
| 428 |
+
|
| 429 |
+
|
| 430 |
+
/**
|
| 431 |
+
* \brief Calculate encoded size of a Filter Flags field
|
| 432 |
+
*
|
| 433 |
+
* Knowing the size of Filter Flags is useful to know when allocating
|
| 434 |
+
* memory to hold the encoded Filter Flags.
|
| 435 |
+
*
|
| 436 |
+
* \note If you need to calculate size of List of Filter Flags,
|
| 437 |
+
* you need to loop over every lzma_filter entry.
|
| 438 |
+
*
|
| 439 |
+
* \param[out] size Pointer to integer to hold the calculated size
|
| 440 |
+
* \param filter Filter ID and associated options whose encoded
|
| 441 |
+
* size is to be calculated
|
| 442 |
+
*
|
| 443 |
+
* \return Possible lzma_ret values:
|
| 444 |
+
* - LZMA_OK: *size set successfully. Note that this doesn't
|
| 445 |
+
* guarantee that filter->options is valid, thus
|
| 446 |
+
* lzma_filter_flags_encode() may still fail.
|
| 447 |
+
* - LZMA_OPTIONS_ERROR: Unknown Filter ID or unsupported options.
|
| 448 |
+
* - LZMA_PROG_ERROR: Invalid options
|
| 449 |
+
*/
|
| 450 |
+
extern LZMA_API(lzma_ret) lzma_filter_flags_size(
|
| 451 |
+
uint32_t *size, const lzma_filter *filter)
|
| 452 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 453 |
+
|
| 454 |
+
|
| 455 |
+
/**
|
| 456 |
+
* \brief Encode Filter Flags into given buffer
|
| 457 |
+
*
|
| 458 |
+
* In contrast to some functions, this doesn't allocate the needed buffer.
|
| 459 |
+
* This is due to how this function is used internally by liblzma.
|
| 460 |
+
*
|
| 461 |
+
* \param filter Filter ID and options to be encoded
|
| 462 |
+
* \param[out] out Beginning of the output buffer
|
| 463 |
+
* \param[out] out_pos out[*out_pos] is the next write position. This
|
| 464 |
+
* is updated by the encoder.
|
| 465 |
+
* \param out_size out[out_size] is the first byte to not write.
|
| 466 |
+
*
|
| 467 |
+
* \return Possible lzma_ret values:
|
| 468 |
+
* - LZMA_OK: Encoding was successful.
|
| 469 |
+
* - LZMA_OPTIONS_ERROR: Invalid or unsupported options.
|
| 470 |
+
* - LZMA_PROG_ERROR: Invalid options or not enough output
|
| 471 |
+
* buffer space (you should have checked it with
|
| 472 |
+
* lzma_filter_flags_size()).
|
| 473 |
+
*/
|
| 474 |
+
extern LZMA_API(lzma_ret) lzma_filter_flags_encode(const lzma_filter *filter,
|
| 475 |
+
uint8_t *out, size_t *out_pos, size_t out_size)
|
| 476 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 477 |
+
|
| 478 |
+
|
| 479 |
+
/**
|
| 480 |
+
* \brief Decode Filter Flags from given buffer
|
| 481 |
+
*
|
| 482 |
+
* The decoded result is stored into *filter. The old value of
|
| 483 |
+
* filter->options is not free()d. If anything other than LZMA_OK
|
| 484 |
+
* is returned, filter->options is set to NULL.
|
| 485 |
+
*
|
| 486 |
+
* \param[out] filter Destination filter. The decoded Filter ID will
|
| 487 |
+
* be stored in filter->id. If options are needed
|
| 488 |
+
* they will be allocated and the pointer will be
|
| 489 |
+
* stored in filter->options.
|
| 490 |
+
* \param allocator lzma_allocator for custom allocator functions.
|
| 491 |
+
* Set to NULL to use malloc() and free().
|
| 492 |
+
* \param in Beginning of the input buffer
|
| 493 |
+
* \param[out] in_pos The next byte will be read from in[*in_pos].
|
| 494 |
+
* *in_pos is updated only if decoding succeeds.
|
| 495 |
+
* \param in_size Size of the input buffer; the first byte that
|
| 496 |
+
* won't be read is in[in_size].
|
| 497 |
+
*
|
| 498 |
+
* \return Possible lzma_ret values:
|
| 499 |
+
* - LZMA_OK
|
| 500 |
+
* - LZMA_OPTIONS_ERROR
|
| 501 |
+
* - LZMA_MEM_ERROR
|
| 502 |
+
* - LZMA_DATA_ERROR
|
| 503 |
+
* - LZMA_PROG_ERROR
|
| 504 |
+
*/
|
| 505 |
+
extern LZMA_API(lzma_ret) lzma_filter_flags_decode(
|
| 506 |
+
lzma_filter *filter, const lzma_allocator *allocator,
|
| 507 |
+
const uint8_t *in, size_t *in_pos, size_t in_size)
|
| 508 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 509 |
+
|
| 510 |
+
|
| 511 |
+
/***********
|
| 512 |
+
* Strings *
|
| 513 |
+
***********/
|
| 514 |
+
|
| 515 |
+
/**
|
| 516 |
+
* \brief Allow or show all filters
|
| 517 |
+
*
|
| 518 |
+
* By default only the filters supported in the .xz format are accept by
|
| 519 |
+
* lzma_str_to_filters() or shown by lzma_str_list_filters().
|
| 520 |
+
*/
|
| 521 |
+
#define LZMA_STR_ALL_FILTERS UINT32_C(0x01)
|
| 522 |
+
|
| 523 |
+
|
| 524 |
+
/**
|
| 525 |
+
* \brief Do not validate the filter chain in lzma_str_to_filters()
|
| 526 |
+
*
|
| 527 |
+
* By default lzma_str_to_filters() can return an error if the filter chain
|
| 528 |
+
* as a whole isn't usable in the .xz format or in the raw encoder or decoder.
|
| 529 |
+
* With this flag, this validation is skipped. This flag doesn't affect the
|
| 530 |
+
* handling of the individual filter options. To allow non-.xz filters also
|
| 531 |
+
* LZMA_STR_ALL_FILTERS is needed.
|
| 532 |
+
*/
|
| 533 |
+
#define LZMA_STR_NO_VALIDATION UINT32_C(0x02)
|
| 534 |
+
|
| 535 |
+
|
| 536 |
+
/**
|
| 537 |
+
* \brief Stringify encoder options
|
| 538 |
+
*
|
| 539 |
+
* Show the filter-specific options that the encoder will use.
|
| 540 |
+
* This may be useful for verbose diagnostic messages.
|
| 541 |
+
*
|
| 542 |
+
* Note that if options were decoded from .xz headers then the encoder options
|
| 543 |
+
* may be undefined. This flag shouldn't be used in such a situation.
|
| 544 |
+
*/
|
| 545 |
+
#define LZMA_STR_ENCODER UINT32_C(0x10)
|
| 546 |
+
|
| 547 |
+
|
| 548 |
+
/**
|
| 549 |
+
* \brief Stringify decoder options
|
| 550 |
+
*
|
| 551 |
+
* Show the filter-specific options that the decoder will use.
|
| 552 |
+
* This may be useful for showing what filter options were decoded
|
| 553 |
+
* from file headers.
|
| 554 |
+
*/
|
| 555 |
+
#define LZMA_STR_DECODER UINT32_C(0x20)
|
| 556 |
+
|
| 557 |
+
|
| 558 |
+
/**
|
| 559 |
+
* \brief Produce xz-compatible getopt_long() syntax
|
| 560 |
+
*
|
| 561 |
+
* That is, "delta:dist=2 lzma2:dict=4MiB,pb=1,lp=1" becomes
|
| 562 |
+
* "--delta=dist=2 --lzma2=dict=4MiB,pb=1,lp=1".
|
| 563 |
+
*
|
| 564 |
+
* This syntax is compatible with xz 5.0.0 as long as the filters and
|
| 565 |
+
* their options are supported too.
|
| 566 |
+
*/
|
| 567 |
+
#define LZMA_STR_GETOPT_LONG UINT32_C(0x40)
|
| 568 |
+
|
| 569 |
+
|
| 570 |
+
/**
|
| 571 |
+
* \brief Use two dashes "--" instead of a space to separate filters
|
| 572 |
+
*
|
| 573 |
+
* That is, "delta:dist=2 lzma2:pb=1,lp=1" becomes
|
| 574 |
+
* "delta:dist=2--lzma2:pb=1,lp=1". This looks slightly odd but this
|
| 575 |
+
* kind of strings should be usable on the command line without quoting.
|
| 576 |
+
* However, it is possible that future versions with new filter options
|
| 577 |
+
* might produce strings that require shell quoting anyway as the exact
|
| 578 |
+
* set of possible characters isn't frozen for now.
|
| 579 |
+
*
|
| 580 |
+
* It is guaranteed that the single quote (') will never be used in
|
| 581 |
+
* filter chain strings (even if LZMA_STR_NO_SPACES isn't used).
|
| 582 |
+
*/
|
| 583 |
+
#define LZMA_STR_NO_SPACES UINT32_C(0x80)
|
| 584 |
+
|
| 585 |
+
|
| 586 |
+
/**
|
| 587 |
+
* \brief Convert a string to a filter chain
|
| 588 |
+
*
|
| 589 |
+
* This tries to make it easier to write applications that allow users
|
| 590 |
+
* to set custom compression options. This only handles the filter
|
| 591 |
+
* configuration (including presets) but not the number of threads,
|
| 592 |
+
* block size, check type, or memory limits.
|
| 593 |
+
*
|
| 594 |
+
* The input string can be either a preset or a filter chain. Presets
|
| 595 |
+
* begin with a digit 0-9 and may be followed by zero or more flags
|
| 596 |
+
* which are lower-case letters. Currently only "e" is supported, matching
|
| 597 |
+
* LZMA_PRESET_EXTREME. For partial xz command line syntax compatibility,
|
| 598 |
+
* a preset string may start with a single dash "-".
|
| 599 |
+
*
|
| 600 |
+
* A filter chain consists of one or more "filtername:opt1=value1,opt2=value2"
|
| 601 |
+
* strings separated by one or more spaces. Leading and trailing spaces are
|
| 602 |
+
* ignored. All names and values must be lower-case. Extra commas in the
|
| 603 |
+
* option list are ignored. The order of filters is significant: when
|
| 604 |
+
* encoding, the uncompressed input data goes to the leftmost filter first.
|
| 605 |
+
* Normally "lzma2" is the last filter in the chain.
|
| 606 |
+
*
|
| 607 |
+
* If one wishes to avoid spaces, for example, to avoid shell quoting,
|
| 608 |
+
* it is possible to use two dashes "--" instead of spaces to separate
|
| 609 |
+
* the filters.
|
| 610 |
+
*
|
| 611 |
+
* For xz command line compatibility, each filter may be prefixed with
|
| 612 |
+
* two dashes "--" and the colon ":" separating the filter name from
|
| 613 |
+
* the options may be replaced with an equals sign "=".
|
| 614 |
+
*
|
| 615 |
+
* By default, only filters that can be used in the .xz format are accepted.
|
| 616 |
+
* To allow all filters (LZMA1) use the flag LZMA_STR_ALL_FILTERS.
|
| 617 |
+
*
|
| 618 |
+
* By default, very basic validation is done for the filter chain as a whole,
|
| 619 |
+
* for example, that LZMA2 is only used as the last filter in the chain.
|
| 620 |
+
* The validation isn't perfect though and it's possible that this function
|
| 621 |
+
* succeeds but using the filter chain for encoding or decoding will still
|
| 622 |
+
* result in LZMA_OPTIONS_ERROR. To disable this validation, use the flag
|
| 623 |
+
* LZMA_STR_NO_VALIDATION.
|
| 624 |
+
*
|
| 625 |
+
* The available filter names and their options are available via
|
| 626 |
+
* lzma_str_list_filters(). See the xz man page for the description
|
| 627 |
+
* of filter names and options.
|
| 628 |
+
*
|
| 629 |
+
* For command line applications, below is an example how an error message
|
| 630 |
+
* can be displayed. Note the use of an empty string for the field width.
|
| 631 |
+
* If "^" was used there it would create an off-by-one error except at
|
| 632 |
+
* the very beginning of the line.
|
| 633 |
+
*
|
| 634 |
+
* \code{.c}
|
| 635 |
+
* const char *str = ...; // From user
|
| 636 |
+
* lzma_filter filters[LZMA_FILTERS_MAX + 1];
|
| 637 |
+
* int pos;
|
| 638 |
+
* const char *msg = lzma_str_to_filters(str, &pos, filters, 0, NULL);
|
| 639 |
+
* if (msg != NULL) {
|
| 640 |
+
* printf("%s: Error in XZ compression options:\n", argv[0]);
|
| 641 |
+
* printf("%s: %s\n", argv[0], str);
|
| 642 |
+
* printf("%s: %*s^\n", argv[0], errpos, "");
|
| 643 |
+
* printf("%s: %s\n", argv[0], msg);
|
| 644 |
+
* }
|
| 645 |
+
* \endcode
|
| 646 |
+
*
|
| 647 |
+
* \param str User-supplied string describing a preset or
|
| 648 |
+
* a filter chain. If a default value is needed and
|
| 649 |
+
* you don't know what would be good, use "6" since
|
| 650 |
+
* that is the default preset in xz too.
|
| 651 |
+
* \param[out] error_pos If this isn't NULL, this value will be set on
|
| 652 |
+
* both success and on all errors. This tells the
|
| 653 |
+
* location of the error in the string. This is
|
| 654 |
+
* an int to make it straightforward to use this
|
| 655 |
+
* as printf() field width. The value is guaranteed
|
| 656 |
+
* to be in the range [0, INT_MAX] even if strlen(str)
|
| 657 |
+
* somehow was greater than INT_MAX.
|
| 658 |
+
* \param[out] filters An array of lzma_filter structures. There must
|
| 659 |
+
* be LZMA_FILTERS_MAX + 1 (that is, five) elements
|
| 660 |
+
* in the array. The old contents are ignored so it
|
| 661 |
+
* doesn't need to be initialized. This array is
|
| 662 |
+
* modified only if this function returns NULL.
|
| 663 |
+
* Once the allocated filter options are no longer
|
| 664 |
+
* needed, lzma_filters_free() can be used to free the
|
| 665 |
+
* options (it doesn't free the filters array itself).
|
| 666 |
+
* \param flags Bitwise-or of zero or more of the flags
|
| 667 |
+
* LZMA_STR_ALL_FILTERS and LZMA_STR_NO_VALIDATION.
|
| 668 |
+
* \param allocator lzma_allocator for custom allocator functions.
|
| 669 |
+
* Set to NULL to use malloc() and free().
|
| 670 |
+
*
|
| 671 |
+
* \return On success, NULL is returned. On error, a statically-allocated
|
| 672 |
+
* error message is returned which together with the error_pos
|
| 673 |
+
* should give some idea what is wrong.
|
| 674 |
+
*/
|
| 675 |
+
extern LZMA_API(const char *) lzma_str_to_filters(
|
| 676 |
+
const char *str, int *error_pos, lzma_filter *filters,
|
| 677 |
+
uint32_t flags, const lzma_allocator *allocator)
|
| 678 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 679 |
+
|
| 680 |
+
|
| 681 |
+
/**
|
| 682 |
+
* \brief Convert a filter chain to a string
|
| 683 |
+
*
|
| 684 |
+
* Use cases:
|
| 685 |
+
*
|
| 686 |
+
* - Verbose output showing the full encoder options to the user
|
| 687 |
+
* (use LZMA_STR_ENCODER in flags)
|
| 688 |
+
*
|
| 689 |
+
* - Showing the filters and options that are required to decode a file
|
| 690 |
+
* (use LZMA_STR_DECODER in flags)
|
| 691 |
+
*
|
| 692 |
+
* - Showing the filter names without any options in informational messages
|
| 693 |
+
* where the technical details aren't important (no flags). In this case
|
| 694 |
+
* the .options in the filters array are ignored and may be NULL even if
|
| 695 |
+
* a filter has a mandatory options structure.
|
| 696 |
+
*
|
| 697 |
+
* Note that even if the filter chain was specified using a preset,
|
| 698 |
+
* the resulting filter chain isn't reversed to a preset. So if you
|
| 699 |
+
* specify "6" to lzma_str_to_filters() then lzma_str_from_filters()
|
| 700 |
+
* will produce a string containing "lzma2".
|
| 701 |
+
*
|
| 702 |
+
* \param[out] str On success *str will be set to point to an
|
| 703 |
+
* allocated string describing the given filter
|
| 704 |
+
* chain. Old value is ignored. On error *str is
|
| 705 |
+
* always set to NULL.
|
| 706 |
+
* \param filters Array of filters terminated with
|
| 707 |
+
* .id == LZMA_VLI_UNKNOWN.
|
| 708 |
+
* \param flags Bitwise-or of zero or more of the flags
|
| 709 |
+
* LZMA_STR_ENCODER, LZMA_STR_DECODER,
|
| 710 |
+
* LZMA_STR_GETOPT_LONG, and LZMA_STR_NO_SPACES.
|
| 711 |
+
* \param allocator lzma_allocator for custom allocator functions.
|
| 712 |
+
* Set to NULL to use malloc() and free().
|
| 713 |
+
*
|
| 714 |
+
* \return Possible lzma_ret values:
|
| 715 |
+
* - LZMA_OK
|
| 716 |
+
* - LZMA_OPTIONS_ERROR: Empty filter chain
|
| 717 |
+
* (filters[0].id == LZMA_VLI_UNKNOWN) or the filter chain
|
| 718 |
+
* includes a Filter ID that is not supported by this function.
|
| 719 |
+
* - LZMA_MEM_ERROR
|
| 720 |
+
* - LZMA_PROG_ERROR
|
| 721 |
+
*/
|
| 722 |
+
extern LZMA_API(lzma_ret) lzma_str_from_filters(
|
| 723 |
+
char **str, const lzma_filter *filters, uint32_t flags,
|
| 724 |
+
const lzma_allocator *allocator)
|
| 725 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 726 |
+
|
| 727 |
+
|
| 728 |
+
/**
|
| 729 |
+
* \brief List available filters and/or their options (for help message)
|
| 730 |
+
*
|
| 731 |
+
* If a filter_id is given then only one line is created which contains the
|
| 732 |
+
* filter name. If LZMA_STR_ENCODER or LZMA_STR_DECODER is used then the
|
| 733 |
+
* options read by the encoder or decoder are printed on the same line.
|
| 734 |
+
*
|
| 735 |
+
* If filter_id is LZMA_VLI_UNKNOWN then all supported .xz-compatible filters
|
| 736 |
+
* are listed:
|
| 737 |
+
*
|
| 738 |
+
* - If neither LZMA_STR_ENCODER nor LZMA_STR_DECODER is used then
|
| 739 |
+
* the supported filter names are listed on a single line separated
|
| 740 |
+
* by spaces.
|
| 741 |
+
*
|
| 742 |
+
* - If LZMA_STR_ENCODER or LZMA_STR_DECODER is used then filters and
|
| 743 |
+
* the supported options are listed one filter per line. There won't
|
| 744 |
+
* be a newline after the last filter.
|
| 745 |
+
*
|
| 746 |
+
* - If LZMA_STR_ALL_FILTERS is used then the list will include also
|
| 747 |
+
* those filters that cannot be used in the .xz format (LZMA1).
|
| 748 |
+
*
|
| 749 |
+
* \param str On success *str will be set to point to an
|
| 750 |
+
* allocated string listing the filters and options.
|
| 751 |
+
* Old value is ignored. On error *str is always set
|
| 752 |
+
* to NULL.
|
| 753 |
+
* \param filter_id Filter ID or LZMA_VLI_UNKNOWN.
|
| 754 |
+
* \param flags Bitwise-or of zero or more of the flags
|
| 755 |
+
* LZMA_STR_ALL_FILTERS, LZMA_STR_ENCODER,
|
| 756 |
+
* LZMA_STR_DECODER, and LZMA_STR_GETOPT_LONG.
|
| 757 |
+
* \param allocator lzma_allocator for custom allocator functions.
|
| 758 |
+
* Set to NULL to use malloc() and free().
|
| 759 |
+
*
|
| 760 |
+
* \return Possible lzma_ret values:
|
| 761 |
+
* - LZMA_OK
|
| 762 |
+
* - LZMA_OPTIONS_ERROR: Unsupported filter_id or flags
|
| 763 |
+
* - LZMA_MEM_ERROR
|
| 764 |
+
* - LZMA_PROG_ERROR
|
| 765 |
+
*/
|
| 766 |
+
extern LZMA_API(lzma_ret) lzma_str_list_filters(
|
| 767 |
+
char **str, lzma_vli filter_id, uint32_t flags,
|
| 768 |
+
const lzma_allocator *allocator)
|
| 769 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
llava_next/include/lzma/hardware.h
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* SPDX-License-Identifier: 0BSD */
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* \file lzma/hardware.h
|
| 5 |
+
* \brief Hardware information
|
| 6 |
+
* \note Never include this file directly. Use <lzma.h> instead.
|
| 7 |
+
*
|
| 8 |
+
* Since liblzma can consume a lot of system resources, it also provides
|
| 9 |
+
* ways to limit the resource usage. Applications linking against liblzma
|
| 10 |
+
* need to do the actual decisions how much resources to let liblzma to use.
|
| 11 |
+
* To ease making these decisions, liblzma provides functions to find out
|
| 12 |
+
* the relevant capabilities of the underlying hardware. Currently there
|
| 13 |
+
* is only a function to find out the amount of RAM, but in the future there
|
| 14 |
+
* will be also a function to detect how many concurrent threads the system
|
| 15 |
+
* can run.
|
| 16 |
+
*
|
| 17 |
+
* \note On some operating systems, these function may temporarily
|
| 18 |
+
* load a shared library or open file descriptor(s) to find out
|
| 19 |
+
* the requested hardware information. Unless the application
|
| 20 |
+
* assumes that specific file descriptors are not touched by
|
| 21 |
+
* other threads, this should have no effect on thread safety.
|
| 22 |
+
* Possible operations involving file descriptors will restart
|
| 23 |
+
* the syscalls if they return EINTR.
|
| 24 |
+
*/
|
| 25 |
+
|
| 26 |
+
/*
|
| 27 |
+
* Author: Lasse Collin
|
| 28 |
+
*/
|
| 29 |
+
|
| 30 |
+
#ifndef LZMA_H_INTERNAL
|
| 31 |
+
# error Never include this file directly. Use <lzma.h> instead.
|
| 32 |
+
#endif
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
/**
|
| 36 |
+
* \brief Get the total amount of physical memory (RAM) in bytes
|
| 37 |
+
*
|
| 38 |
+
* This function may be useful when determining a reasonable memory
|
| 39 |
+
* usage limit for decompressing or how much memory it is OK to use
|
| 40 |
+
* for compressing.
|
| 41 |
+
*
|
| 42 |
+
* \return On success, the total amount of physical memory in bytes
|
| 43 |
+
* is returned. If the amount of RAM cannot be determined,
|
| 44 |
+
* zero is returned. This can happen if an error occurs
|
| 45 |
+
* or if there is no code in liblzma to detect the amount
|
| 46 |
+
* of RAM on the specific operating system.
|
| 47 |
+
*/
|
| 48 |
+
extern LZMA_API(uint64_t) lzma_physmem(void) lzma_nothrow;
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
/**
|
| 52 |
+
* \brief Get the number of processor cores or threads
|
| 53 |
+
*
|
| 54 |
+
* This function may be useful when determining how many threads to use.
|
| 55 |
+
* If the hardware supports more than one thread per CPU core, the number
|
| 56 |
+
* of hardware threads is returned if that information is available.
|
| 57 |
+
*
|
| 58 |
+
* \return On success, the number of available CPU threads or cores is
|
| 59 |
+
* returned. If this information isn't available or an error
|
| 60 |
+
* occurs, zero is returned.
|
| 61 |
+
*/
|
| 62 |
+
extern LZMA_API(uint32_t) lzma_cputhreads(void) lzma_nothrow;
|
llava_next/include/lzma/index.h
ADDED
|
@@ -0,0 +1,882 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* SPDX-License-Identifier: 0BSD */
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* \file lzma/index.h
|
| 5 |
+
* \brief Handling of .xz Index and related information
|
| 6 |
+
* \note Never include this file directly. Use <lzma.h> instead.
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
/*
|
| 10 |
+
* Author: Lasse Collin
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
#ifndef LZMA_H_INTERNAL
|
| 14 |
+
# error Never include this file directly. Use <lzma.h> instead.
|
| 15 |
+
#endif
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
/**
|
| 19 |
+
* \brief Opaque data type to hold the Index(es) and other information
|
| 20 |
+
*
|
| 21 |
+
* lzma_index often holds just one .xz Index and possibly the Stream Flags
|
| 22 |
+
* of the same Stream and size of the Stream Padding field. However,
|
| 23 |
+
* multiple lzma_indexes can be concatenated with lzma_index_cat() and then
|
| 24 |
+
* there may be information about multiple Streams in the same lzma_index.
|
| 25 |
+
*
|
| 26 |
+
* Notes about thread safety: Only one thread may modify lzma_index at
|
| 27 |
+
* a time. All functions that take non-const pointer to lzma_index
|
| 28 |
+
* modify it. As long as no thread is modifying the lzma_index, getting
|
| 29 |
+
* information from the same lzma_index can be done from multiple threads
|
| 30 |
+
* at the same time with functions that take a const pointer to
|
| 31 |
+
* lzma_index or use lzma_index_iter. The same iterator must be used
|
| 32 |
+
* only by one thread at a time, of course, but there can be as many
|
| 33 |
+
* iterators for the same lzma_index as needed.
|
| 34 |
+
*/
|
| 35 |
+
typedef struct lzma_index_s lzma_index;
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
/**
|
| 39 |
+
* \brief Iterator to get information about Blocks and Streams
|
| 40 |
+
*/
|
| 41 |
+
typedef struct {
|
| 42 |
+
struct {
|
| 43 |
+
/**
|
| 44 |
+
* \brief Pointer to Stream Flags
|
| 45 |
+
*
|
| 46 |
+
* This is NULL if Stream Flags have not been set for
|
| 47 |
+
* this Stream with lzma_index_stream_flags().
|
| 48 |
+
*/
|
| 49 |
+
const lzma_stream_flags *flags;
|
| 50 |
+
|
| 51 |
+
/** \private Reserved member. */
|
| 52 |
+
const void *reserved_ptr1;
|
| 53 |
+
|
| 54 |
+
/** \private Reserved member. */
|
| 55 |
+
const void *reserved_ptr2;
|
| 56 |
+
|
| 57 |
+
/** \private Reserved member. */
|
| 58 |
+
const void *reserved_ptr3;
|
| 59 |
+
|
| 60 |
+
/**
|
| 61 |
+
* \brief Stream number in the lzma_index
|
| 62 |
+
*
|
| 63 |
+
* The first Stream is 1.
|
| 64 |
+
*/
|
| 65 |
+
lzma_vli number;
|
| 66 |
+
|
| 67 |
+
/**
|
| 68 |
+
* \brief Number of Blocks in the Stream
|
| 69 |
+
*
|
| 70 |
+
* If this is zero, the block structure below has
|
| 71 |
+
* undefined values.
|
| 72 |
+
*/
|
| 73 |
+
lzma_vli block_count;
|
| 74 |
+
|
| 75 |
+
/**
|
| 76 |
+
* \brief Compressed start offset of this Stream
|
| 77 |
+
*
|
| 78 |
+
* The offset is relative to the beginning of the lzma_index
|
| 79 |
+
* (i.e. usually the beginning of the .xz file).
|
| 80 |
+
*/
|
| 81 |
+
lzma_vli compressed_offset;
|
| 82 |
+
|
| 83 |
+
/**
|
| 84 |
+
* \brief Uncompressed start offset of this Stream
|
| 85 |
+
*
|
| 86 |
+
* The offset is relative to the beginning of the lzma_index
|
| 87 |
+
* (i.e. usually the beginning of the .xz file).
|
| 88 |
+
*/
|
| 89 |
+
lzma_vli uncompressed_offset;
|
| 90 |
+
|
| 91 |
+
/**
|
| 92 |
+
* \brief Compressed size of this Stream
|
| 93 |
+
*
|
| 94 |
+
* This includes all headers except the possible
|
| 95 |
+
* Stream Padding after this Stream.
|
| 96 |
+
*/
|
| 97 |
+
lzma_vli compressed_size;
|
| 98 |
+
|
| 99 |
+
/**
|
| 100 |
+
* \brief Uncompressed size of this Stream
|
| 101 |
+
*/
|
| 102 |
+
lzma_vli uncompressed_size;
|
| 103 |
+
|
| 104 |
+
/**
|
| 105 |
+
* \brief Size of Stream Padding after this Stream
|
| 106 |
+
*
|
| 107 |
+
* If it hasn't been set with lzma_index_stream_padding(),
|
| 108 |
+
* this defaults to zero. Stream Padding is always
|
| 109 |
+
* a multiple of four bytes.
|
| 110 |
+
*/
|
| 111 |
+
lzma_vli padding;
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
/** \private Reserved member. */
|
| 115 |
+
lzma_vli reserved_vli1;
|
| 116 |
+
|
| 117 |
+
/** \private Reserved member. */
|
| 118 |
+
lzma_vli reserved_vli2;
|
| 119 |
+
|
| 120 |
+
/** \private Reserved member. */
|
| 121 |
+
lzma_vli reserved_vli3;
|
| 122 |
+
|
| 123 |
+
/** \private Reserved member. */
|
| 124 |
+
lzma_vli reserved_vli4;
|
| 125 |
+
} stream;
|
| 126 |
+
|
| 127 |
+
struct {
|
| 128 |
+
/**
|
| 129 |
+
* \brief Block number in the file
|
| 130 |
+
*
|
| 131 |
+
* The first Block is 1.
|
| 132 |
+
*/
|
| 133 |
+
lzma_vli number_in_file;
|
| 134 |
+
|
| 135 |
+
/**
|
| 136 |
+
* \brief Compressed start offset of this Block
|
| 137 |
+
*
|
| 138 |
+
* This offset is relative to the beginning of the
|
| 139 |
+
* lzma_index (i.e. usually the beginning of the .xz file).
|
| 140 |
+
* Normally this is where you should seek in the .xz file
|
| 141 |
+
* to start decompressing this Block.
|
| 142 |
+
*/
|
| 143 |
+
lzma_vli compressed_file_offset;
|
| 144 |
+
|
| 145 |
+
/**
|
| 146 |
+
* \brief Uncompressed start offset of this Block
|
| 147 |
+
*
|
| 148 |
+
* This offset is relative to the beginning of the lzma_index
|
| 149 |
+
* (i.e. usually the beginning of the .xz file).
|
| 150 |
+
*
|
| 151 |
+
* When doing random-access reading, it is possible that
|
| 152 |
+
* the target offset is not exactly at Block boundary. One
|
| 153 |
+
* will need to compare the target offset against
|
| 154 |
+
* uncompressed_file_offset or uncompressed_stream_offset,
|
| 155 |
+
* and possibly decode and throw away some amount of data
|
| 156 |
+
* before reaching the target offset.
|
| 157 |
+
*/
|
| 158 |
+
lzma_vli uncompressed_file_offset;
|
| 159 |
+
|
| 160 |
+
/**
|
| 161 |
+
* \brief Block number in this Stream
|
| 162 |
+
*
|
| 163 |
+
* The first Block is 1.
|
| 164 |
+
*/
|
| 165 |
+
lzma_vli number_in_stream;
|
| 166 |
+
|
| 167 |
+
/**
|
| 168 |
+
* \brief Compressed start offset of this Block
|
| 169 |
+
*
|
| 170 |
+
* This offset is relative to the beginning of the Stream
|
| 171 |
+
* containing this Block.
|
| 172 |
+
*/
|
| 173 |
+
lzma_vli compressed_stream_offset;
|
| 174 |
+
|
| 175 |
+
/**
|
| 176 |
+
* \brief Uncompressed start offset of this Block
|
| 177 |
+
*
|
| 178 |
+
* This offset is relative to the beginning of the Stream
|
| 179 |
+
* containing this Block.
|
| 180 |
+
*/
|
| 181 |
+
lzma_vli uncompressed_stream_offset;
|
| 182 |
+
|
| 183 |
+
/**
|
| 184 |
+
* \brief Uncompressed size of this Block
|
| 185 |
+
*
|
| 186 |
+
* You should pass this to the Block decoder if you will
|
| 187 |
+
* decode this Block. It will allow the Block decoder to
|
| 188 |
+
* validate the uncompressed size.
|
| 189 |
+
*/
|
| 190 |
+
lzma_vli uncompressed_size;
|
| 191 |
+
|
| 192 |
+
/**
|
| 193 |
+
* \brief Unpadded size of this Block
|
| 194 |
+
*
|
| 195 |
+
* You should pass this to the Block decoder if you will
|
| 196 |
+
* decode this Block. It will allow the Block decoder to
|
| 197 |
+
* validate the unpadded size.
|
| 198 |
+
*/
|
| 199 |
+
lzma_vli unpadded_size;
|
| 200 |
+
|
| 201 |
+
/**
|
| 202 |
+
* \brief Total compressed size
|
| 203 |
+
*
|
| 204 |
+
* This includes all headers and padding in this Block.
|
| 205 |
+
* This is useful if you need to know how many bytes
|
| 206 |
+
* the Block decoder will actually read.
|
| 207 |
+
*/
|
| 208 |
+
lzma_vli total_size;
|
| 209 |
+
|
| 210 |
+
/** \private Reserved member. */
|
| 211 |
+
lzma_vli reserved_vli1;
|
| 212 |
+
|
| 213 |
+
/** \private Reserved member. */
|
| 214 |
+
lzma_vli reserved_vli2;
|
| 215 |
+
|
| 216 |
+
/** \private Reserved member. */
|
| 217 |
+
lzma_vli reserved_vli3;
|
| 218 |
+
|
| 219 |
+
/** \private Reserved member. */
|
| 220 |
+
lzma_vli reserved_vli4;
|
| 221 |
+
|
| 222 |
+
/** \private Reserved member. */
|
| 223 |
+
const void *reserved_ptr1;
|
| 224 |
+
|
| 225 |
+
/** \private Reserved member. */
|
| 226 |
+
const void *reserved_ptr2;
|
| 227 |
+
|
| 228 |
+
/** \private Reserved member. */
|
| 229 |
+
const void *reserved_ptr3;
|
| 230 |
+
|
| 231 |
+
/** \private Reserved member. */
|
| 232 |
+
const void *reserved_ptr4;
|
| 233 |
+
} block;
|
| 234 |
+
|
| 235 |
+
/**
|
| 236 |
+
* \private Internal data
|
| 237 |
+
*
|
| 238 |
+
* Internal data which is used to store the state of the iterator.
|
| 239 |
+
* The exact format may vary between liblzma versions, so don't
|
| 240 |
+
* touch these in any way.
|
| 241 |
+
*/
|
| 242 |
+
union {
|
| 243 |
+
/** \private Internal member. */
|
| 244 |
+
const void *p;
|
| 245 |
+
|
| 246 |
+
/** \private Internal member. */
|
| 247 |
+
size_t s;
|
| 248 |
+
|
| 249 |
+
/** \private Internal member. */
|
| 250 |
+
lzma_vli v;
|
| 251 |
+
} internal[6];
|
| 252 |
+
} lzma_index_iter;
|
| 253 |
+
|
| 254 |
+
|
| 255 |
+
/**
|
| 256 |
+
* \brief Operation mode for lzma_index_iter_next()
|
| 257 |
+
*/
|
| 258 |
+
typedef enum {
|
| 259 |
+
LZMA_INDEX_ITER_ANY = 0,
|
| 260 |
+
/**<
|
| 261 |
+
* \brief Get the next Block or Stream
|
| 262 |
+
*
|
| 263 |
+
* Go to the next Block if the current Stream has at least
|
| 264 |
+
* one Block left. Otherwise go to the next Stream even if
|
| 265 |
+
* it has no Blocks. If the Stream has no Blocks
|
| 266 |
+
* (lzma_index_iter.stream.block_count == 0),
|
| 267 |
+
* lzma_index_iter.block will have undefined values.
|
| 268 |
+
*/
|
| 269 |
+
|
| 270 |
+
LZMA_INDEX_ITER_STREAM = 1,
|
| 271 |
+
/**<
|
| 272 |
+
* \brief Get the next Stream
|
| 273 |
+
*
|
| 274 |
+
* Go to the next Stream even if the current Stream has
|
| 275 |
+
* unread Blocks left. If the next Stream has at least one
|
| 276 |
+
* Block, the iterator will point to the first Block.
|
| 277 |
+
* If there are no Blocks, lzma_index_iter.block will have
|
| 278 |
+
* undefined values.
|
| 279 |
+
*/
|
| 280 |
+
|
| 281 |
+
LZMA_INDEX_ITER_BLOCK = 2,
|
| 282 |
+
/**<
|
| 283 |
+
* \brief Get the next Block
|
| 284 |
+
*
|
| 285 |
+
* Go to the next Block if the current Stream has at least
|
| 286 |
+
* one Block left. If the current Stream has no Blocks left,
|
| 287 |
+
* the next Stream with at least one Block is located and
|
| 288 |
+
* the iterator will be made to point to the first Block of
|
| 289 |
+
* that Stream.
|
| 290 |
+
*/
|
| 291 |
+
|
| 292 |
+
LZMA_INDEX_ITER_NONEMPTY_BLOCK = 3
|
| 293 |
+
/**<
|
| 294 |
+
* \brief Get the next non-empty Block
|
| 295 |
+
*
|
| 296 |
+
* This is like LZMA_INDEX_ITER_BLOCK except that it will
|
| 297 |
+
* skip Blocks whose Uncompressed Size is zero.
|
| 298 |
+
*/
|
| 299 |
+
|
| 300 |
+
} lzma_index_iter_mode;
|
| 301 |
+
|
| 302 |
+
|
| 303 |
+
/**
|
| 304 |
+
* \brief Mask for return value from lzma_index_checks() for check none
|
| 305 |
+
*
|
| 306 |
+
* \note This and the other CHECK_MASK macros were added in 5.5.1alpha.
|
| 307 |
+
*/
|
| 308 |
+
#define LZMA_INDEX_CHECK_MASK_NONE (UINT32_C(1) << LZMA_CHECK_NONE)
|
| 309 |
+
|
| 310 |
+
/**
|
| 311 |
+
* \brief Mask for return value from lzma_index_checks() for check CRC32
|
| 312 |
+
*/
|
| 313 |
+
#define LZMA_INDEX_CHECK_MASK_CRC32 (UINT32_C(1) << LZMA_CHECK_CRC32)
|
| 314 |
+
|
| 315 |
+
/**
|
| 316 |
+
* \brief Mask for return value from lzma_index_checks() for check CRC64
|
| 317 |
+
*/
|
| 318 |
+
#define LZMA_INDEX_CHECK_MASK_CRC64 (UINT32_C(1) << LZMA_CHECK_CRC64)
|
| 319 |
+
|
| 320 |
+
/**
|
| 321 |
+
* \brief Mask for return value from lzma_index_checks() for check SHA256
|
| 322 |
+
*/
|
| 323 |
+
#define LZMA_INDEX_CHECK_MASK_SHA256 (UINT32_C(1) << LZMA_CHECK_SHA256)
|
| 324 |
+
|
| 325 |
+
/**
|
| 326 |
+
* \brief Calculate memory usage of lzma_index
|
| 327 |
+
*
|
| 328 |
+
* On disk, the size of the Index field depends on both the number of Records
|
| 329 |
+
* stored and the size of the Records (due to variable-length integer
|
| 330 |
+
* encoding). When the Index is kept in lzma_index structure, the memory usage
|
| 331 |
+
* depends only on the number of Records/Blocks stored in the Index(es), and
|
| 332 |
+
* in case of concatenated lzma_indexes, the number of Streams. The size in
|
| 333 |
+
* RAM is almost always significantly bigger than in the encoded form on disk.
|
| 334 |
+
*
|
| 335 |
+
* This function calculates an approximate amount of memory needed to hold
|
| 336 |
+
* the given number of Streams and Blocks in lzma_index structure. This
|
| 337 |
+
* value may vary between CPU architectures and also between liblzma versions
|
| 338 |
+
* if the internal implementation is modified.
|
| 339 |
+
*
|
| 340 |
+
* \param streams Number of Streams
|
| 341 |
+
* \param blocks Number of Blocks
|
| 342 |
+
*
|
| 343 |
+
* \return Approximate memory in bytes needed in a lzma_index structure.
|
| 344 |
+
*/
|
| 345 |
+
extern LZMA_API(uint64_t) lzma_index_memusage(
|
| 346 |
+
lzma_vli streams, lzma_vli blocks) lzma_nothrow;
|
| 347 |
+
|
| 348 |
+
|
| 349 |
+
/**
|
| 350 |
+
* \brief Calculate the memory usage of an existing lzma_index
|
| 351 |
+
*
|
| 352 |
+
* This is a shorthand for lzma_index_memusage(lzma_index_stream_count(i),
|
| 353 |
+
* lzma_index_block_count(i)).
|
| 354 |
+
*
|
| 355 |
+
* \param i Pointer to lzma_index structure
|
| 356 |
+
*
|
| 357 |
+
* \return Approximate memory in bytes used by the lzma_index structure.
|
| 358 |
+
*/
|
| 359 |
+
extern LZMA_API(uint64_t) lzma_index_memused(const lzma_index *i)
|
| 360 |
+
lzma_nothrow;
|
| 361 |
+
|
| 362 |
+
|
| 363 |
+
/**
|
| 364 |
+
* \brief Allocate and initialize a new lzma_index structure
|
| 365 |
+
*
|
| 366 |
+
* \param allocator lzma_allocator for custom allocator functions.
|
| 367 |
+
* Set to NULL to use malloc() and free().
|
| 368 |
+
*
|
| 369 |
+
* \return On success, a pointer to an empty initialized lzma_index is
|
| 370 |
+
* returned. If allocation fails, NULL is returned.
|
| 371 |
+
*/
|
| 372 |
+
extern LZMA_API(lzma_index *) lzma_index_init(const lzma_allocator *allocator)
|
| 373 |
+
lzma_nothrow;
|
| 374 |
+
|
| 375 |
+
|
| 376 |
+
/**
|
| 377 |
+
* \brief Deallocate lzma_index
|
| 378 |
+
*
|
| 379 |
+
* If i is NULL, this does nothing.
|
| 380 |
+
*
|
| 381 |
+
* \param i Pointer to lzma_index structure to deallocate
|
| 382 |
+
* \param allocator lzma_allocator for custom allocator functions.
|
| 383 |
+
* Set to NULL to use malloc() and free().
|
| 384 |
+
*/
|
| 385 |
+
extern LZMA_API(void) lzma_index_end(
|
| 386 |
+
lzma_index *i, const lzma_allocator *allocator) lzma_nothrow;
|
| 387 |
+
|
| 388 |
+
|
| 389 |
+
/**
|
| 390 |
+
* \brief Add a new Block to lzma_index
|
| 391 |
+
*
|
| 392 |
+
* \param i Pointer to a lzma_index structure
|
| 393 |
+
* \param allocator lzma_allocator for custom allocator
|
| 394 |
+
* functions. Set to NULL to use malloc()
|
| 395 |
+
* and free().
|
| 396 |
+
* \param unpadded_size Unpadded Size of a Block. This can be
|
| 397 |
+
* calculated with lzma_block_unpadded_size()
|
| 398 |
+
* after encoding or decoding the Block.
|
| 399 |
+
* \param uncompressed_size Uncompressed Size of a Block. This can be
|
| 400 |
+
* taken directly from lzma_block structure
|
| 401 |
+
* after encoding or decoding the Block.
|
| 402 |
+
*
|
| 403 |
+
* Appending a new Block does not invalidate iterators. For example,
|
| 404 |
+
* if an iterator was pointing to the end of the lzma_index, after
|
| 405 |
+
* lzma_index_append() it is possible to read the next Block with
|
| 406 |
+
* an existing iterator.
|
| 407 |
+
*
|
| 408 |
+
* \return Possible lzma_ret values:
|
| 409 |
+
* - LZMA_OK
|
| 410 |
+
* - LZMA_MEM_ERROR
|
| 411 |
+
* - LZMA_DATA_ERROR: Compressed or uncompressed size of the
|
| 412 |
+
* Stream or size of the Index field would grow too big.
|
| 413 |
+
* - LZMA_PROG_ERROR
|
| 414 |
+
*/
|
| 415 |
+
extern LZMA_API(lzma_ret) lzma_index_append(
|
| 416 |
+
lzma_index *i, const lzma_allocator *allocator,
|
| 417 |
+
lzma_vli unpadded_size, lzma_vli uncompressed_size)
|
| 418 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 419 |
+
|
| 420 |
+
|
| 421 |
+
/**
|
| 422 |
+
* \brief Set the Stream Flags
|
| 423 |
+
*
|
| 424 |
+
* Set the Stream Flags of the last (and typically the only) Stream
|
| 425 |
+
* in lzma_index. This can be useful when reading information from the
|
| 426 |
+
* lzma_index, because to decode Blocks, knowing the integrity check type
|
| 427 |
+
* is needed.
|
| 428 |
+
*
|
| 429 |
+
* \param i Pointer to lzma_index structure
|
| 430 |
+
* \param stream_flags Pointer to lzma_stream_flags structure. This
|
| 431 |
+
* is copied into the internal preallocated
|
| 432 |
+
* structure, so the caller doesn't need to keep
|
| 433 |
+
* the flags' data available after calling this
|
| 434 |
+
* function.
|
| 435 |
+
*
|
| 436 |
+
* \return Possible lzma_ret values:
|
| 437 |
+
* - LZMA_OK
|
| 438 |
+
* - LZMA_OPTIONS_ERROR: Unsupported stream_flags->version.
|
| 439 |
+
* - LZMA_PROG_ERROR
|
| 440 |
+
*/
|
| 441 |
+
extern LZMA_API(lzma_ret) lzma_index_stream_flags(
|
| 442 |
+
lzma_index *i, const lzma_stream_flags *stream_flags)
|
| 443 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 444 |
+
|
| 445 |
+
|
| 446 |
+
/**
|
| 447 |
+
* \brief Get the types of integrity Checks
|
| 448 |
+
*
|
| 449 |
+
* If lzma_index_stream_flags() is used to set the Stream Flags for
|
| 450 |
+
* every Stream, lzma_index_checks() can be used to get a bitmask to
|
| 451 |
+
* indicate which Check types have been used. It can be useful e.g. if
|
| 452 |
+
* showing the Check types to the user.
|
| 453 |
+
*
|
| 454 |
+
* The bitmask is 1 << check_id, e.g. CRC32 is 1 << 1 and SHA-256 is 1 << 10.
|
| 455 |
+
* These masks are defined for convenience as LZMA_INDEX_CHECK_MASK_XXX
|
| 456 |
+
*
|
| 457 |
+
* \param i Pointer to lzma_index structure
|
| 458 |
+
*
|
| 459 |
+
* \return Bitmask indicating which Check types are used in the lzma_index
|
| 460 |
+
*/
|
| 461 |
+
extern LZMA_API(uint32_t) lzma_index_checks(const lzma_index *i)
|
| 462 |
+
lzma_nothrow lzma_attr_pure;
|
| 463 |
+
|
| 464 |
+
|
| 465 |
+
/**
|
| 466 |
+
* \brief Set the amount of Stream Padding
|
| 467 |
+
*
|
| 468 |
+
* Set the amount of Stream Padding of the last (and typically the only)
|
| 469 |
+
* Stream in the lzma_index. This is needed when planning to do random-access
|
| 470 |
+
* reading within multiple concatenated Streams.
|
| 471 |
+
*
|
| 472 |
+
* By default, the amount of Stream Padding is assumed to be zero bytes.
|
| 473 |
+
*
|
| 474 |
+
* \return Possible lzma_ret values:
|
| 475 |
+
* - LZMA_OK
|
| 476 |
+
* - LZMA_DATA_ERROR: The file size would grow too big.
|
| 477 |
+
* - LZMA_PROG_ERROR
|
| 478 |
+
*/
|
| 479 |
+
extern LZMA_API(lzma_ret) lzma_index_stream_padding(
|
| 480 |
+
lzma_index *i, lzma_vli stream_padding)
|
| 481 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 482 |
+
|
| 483 |
+
|
| 484 |
+
/**
|
| 485 |
+
* \brief Get the number of Streams
|
| 486 |
+
*
|
| 487 |
+
* \param i Pointer to lzma_index structure
|
| 488 |
+
*
|
| 489 |
+
* \return Number of Streams in the lzma_index
|
| 490 |
+
*/
|
| 491 |
+
extern LZMA_API(lzma_vli) lzma_index_stream_count(const lzma_index *i)
|
| 492 |
+
lzma_nothrow lzma_attr_pure;
|
| 493 |
+
|
| 494 |
+
|
| 495 |
+
/**
|
| 496 |
+
* \brief Get the number of Blocks
|
| 497 |
+
*
|
| 498 |
+
* This returns the total number of Blocks in lzma_index. To get number
|
| 499 |
+
* of Blocks in individual Streams, use lzma_index_iter.
|
| 500 |
+
*
|
| 501 |
+
* \param i Pointer to lzma_index structure
|
| 502 |
+
*
|
| 503 |
+
* \return Number of blocks in the lzma_index
|
| 504 |
+
*/
|
| 505 |
+
extern LZMA_API(lzma_vli) lzma_index_block_count(const lzma_index *i)
|
| 506 |
+
lzma_nothrow lzma_attr_pure;
|
| 507 |
+
|
| 508 |
+
|
| 509 |
+
/**
|
| 510 |
+
* \brief Get the size of the Index field as bytes
|
| 511 |
+
*
|
| 512 |
+
* This is needed to verify the Backward Size field in the Stream Footer.
|
| 513 |
+
*
|
| 514 |
+
* \param i Pointer to lzma_index structure
|
| 515 |
+
*
|
| 516 |
+
* \return Size in bytes of the Index
|
| 517 |
+
*/
|
| 518 |
+
extern LZMA_API(lzma_vli) lzma_index_size(const lzma_index *i)
|
| 519 |
+
lzma_nothrow lzma_attr_pure;
|
| 520 |
+
|
| 521 |
+
|
| 522 |
+
/**
|
| 523 |
+
* \brief Get the total size of the Stream
|
| 524 |
+
*
|
| 525 |
+
* If multiple lzma_indexes have been combined, this works as if the Blocks
|
| 526 |
+
* were in a single Stream. This is useful if you are going to combine
|
| 527 |
+
* Blocks from multiple Streams into a single new Stream.
|
| 528 |
+
*
|
| 529 |
+
* \param i Pointer to lzma_index structure
|
| 530 |
+
*
|
| 531 |
+
* \return Size in bytes of the Stream (if all Blocks are combined
|
| 532 |
+
* into one Stream).
|
| 533 |
+
*/
|
| 534 |
+
extern LZMA_API(lzma_vli) lzma_index_stream_size(const lzma_index *i)
|
| 535 |
+
lzma_nothrow lzma_attr_pure;
|
| 536 |
+
|
| 537 |
+
|
| 538 |
+
/**
|
| 539 |
+
* \brief Get the total size of the Blocks
|
| 540 |
+
*
|
| 541 |
+
* This doesn't include the Stream Header, Stream Footer, Stream Padding,
|
| 542 |
+
* or Index fields.
|
| 543 |
+
*
|
| 544 |
+
* \param i Pointer to lzma_index structure
|
| 545 |
+
*
|
| 546 |
+
* \return Size in bytes of all Blocks in the Stream(s)
|
| 547 |
+
*/
|
| 548 |
+
extern LZMA_API(lzma_vli) lzma_index_total_size(const lzma_index *i)
|
| 549 |
+
lzma_nothrow lzma_attr_pure;
|
| 550 |
+
|
| 551 |
+
|
| 552 |
+
/**
|
| 553 |
+
* \brief Get the total size of the file
|
| 554 |
+
*
|
| 555 |
+
* When no lzma_indexes have been combined with lzma_index_cat() and there is
|
| 556 |
+
* no Stream Padding, this function is identical to lzma_index_stream_size().
|
| 557 |
+
* If multiple lzma_indexes have been combined, this includes also the headers
|
| 558 |
+
* of each separate Stream and the possible Stream Padding fields.
|
| 559 |
+
*
|
| 560 |
+
* \param i Pointer to lzma_index structure
|
| 561 |
+
*
|
| 562 |
+
* \return Total size of the .xz file in bytes
|
| 563 |
+
*/
|
| 564 |
+
extern LZMA_API(lzma_vli) lzma_index_file_size(const lzma_index *i)
|
| 565 |
+
lzma_nothrow lzma_attr_pure;
|
| 566 |
+
|
| 567 |
+
|
| 568 |
+
/**
|
| 569 |
+
* \brief Get the uncompressed size of the file
|
| 570 |
+
*
|
| 571 |
+
* \param i Pointer to lzma_index structure
|
| 572 |
+
*
|
| 573 |
+
* \return Size in bytes of the uncompressed data in the file
|
| 574 |
+
*/
|
| 575 |
+
extern LZMA_API(lzma_vli) lzma_index_uncompressed_size(const lzma_index *i)
|
| 576 |
+
lzma_nothrow lzma_attr_pure;
|
| 577 |
+
|
| 578 |
+
|
| 579 |
+
/**
|
| 580 |
+
* \brief Initialize an iterator
|
| 581 |
+
*
|
| 582 |
+
* This function associates the iterator with the given lzma_index, and calls
|
| 583 |
+
* lzma_index_iter_rewind() on the iterator.
|
| 584 |
+
*
|
| 585 |
+
* This function doesn't allocate any memory, thus there is no
|
| 586 |
+
* lzma_index_iter_end(). The iterator is valid as long as the
|
| 587 |
+
* associated lzma_index is valid, that is, until lzma_index_end() or
|
| 588 |
+
* using it as source in lzma_index_cat(). Specifically, lzma_index doesn't
|
| 589 |
+
* become invalid if new Blocks are added to it with lzma_index_append() or
|
| 590 |
+
* if it is used as the destination in lzma_index_cat().
|
| 591 |
+
*
|
| 592 |
+
* It is safe to make copies of an initialized lzma_index_iter, for example,
|
| 593 |
+
* to easily restart reading at some particular position.
|
| 594 |
+
*
|
| 595 |
+
* \param iter Pointer to a lzma_index_iter structure
|
| 596 |
+
* \param i lzma_index to which the iterator will be associated
|
| 597 |
+
*/
|
| 598 |
+
extern LZMA_API(void) lzma_index_iter_init(
|
| 599 |
+
lzma_index_iter *iter, const lzma_index *i) lzma_nothrow;
|
| 600 |
+
|
| 601 |
+
|
| 602 |
+
/**
|
| 603 |
+
* \brief Rewind the iterator
|
| 604 |
+
*
|
| 605 |
+
* Rewind the iterator so that next call to lzma_index_iter_next() will
|
| 606 |
+
* return the first Block or Stream.
|
| 607 |
+
*
|
| 608 |
+
* \param iter Pointer to a lzma_index_iter structure
|
| 609 |
+
*/
|
| 610 |
+
extern LZMA_API(void) lzma_index_iter_rewind(lzma_index_iter *iter)
|
| 611 |
+
lzma_nothrow;
|
| 612 |
+
|
| 613 |
+
|
| 614 |
+
/**
|
| 615 |
+
* \brief Get the next Block or Stream
|
| 616 |
+
*
|
| 617 |
+
* \param iter Iterator initialized with lzma_index_iter_init()
|
| 618 |
+
* \param mode Specify what kind of information the caller wants
|
| 619 |
+
* to get. See lzma_index_iter_mode for details.
|
| 620 |
+
*
|
| 621 |
+
* \return lzma_bool:
|
| 622 |
+
* - true if no Block or Stream matching the mode is found.
|
| 623 |
+
* *iter is not updated (failure).
|
| 624 |
+
* - false if the next Block or Stream matching the mode was
|
| 625 |
+
* found. *iter is updated (success).
|
| 626 |
+
*/
|
| 627 |
+
extern LZMA_API(lzma_bool) lzma_index_iter_next(
|
| 628 |
+
lzma_index_iter *iter, lzma_index_iter_mode mode)
|
| 629 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 630 |
+
|
| 631 |
+
|
| 632 |
+
/**
|
| 633 |
+
* \brief Locate a Block
|
| 634 |
+
*
|
| 635 |
+
* If it is possible to seek in the .xz file, it is possible to parse
|
| 636 |
+
* the Index field(s) and use lzma_index_iter_locate() to do random-access
|
| 637 |
+
* reading with granularity of Block size.
|
| 638 |
+
*
|
| 639 |
+
* If the target is smaller than the uncompressed size of the Stream (can be
|
| 640 |
+
* checked with lzma_index_uncompressed_size()):
|
| 641 |
+
* - Information about the Stream and Block containing the requested
|
| 642 |
+
* uncompressed offset is stored into *iter.
|
| 643 |
+
* - Internal state of the iterator is adjusted so that
|
| 644 |
+
* lzma_index_iter_next() can be used to read subsequent Blocks or Streams.
|
| 645 |
+
*
|
| 646 |
+
* If the target is greater than the uncompressed size of the Stream, *iter
|
| 647 |
+
* is not modified.
|
| 648 |
+
*
|
| 649 |
+
* \param iter Iterator that was earlier initialized with
|
| 650 |
+
* lzma_index_iter_init().
|
| 651 |
+
* \param target Uncompressed target offset which the caller would
|
| 652 |
+
* like to locate from the Stream
|
| 653 |
+
*
|
| 654 |
+
* \return lzma_bool:
|
| 655 |
+
* - true if the target is greater than or equal to the
|
| 656 |
+
* uncompressed size of the Stream (failure)
|
| 657 |
+
* - false if the target is smaller than the uncompressed size
|
| 658 |
+
* of the Stream (success)
|
| 659 |
+
*/
|
| 660 |
+
extern LZMA_API(lzma_bool) lzma_index_iter_locate(
|
| 661 |
+
lzma_index_iter *iter, lzma_vli target) lzma_nothrow;
|
| 662 |
+
|
| 663 |
+
|
| 664 |
+
/**
|
| 665 |
+
* \brief Concatenate lzma_indexes
|
| 666 |
+
*
|
| 667 |
+
* Concatenating lzma_indexes is useful when doing random-access reading in
|
| 668 |
+
* multi-Stream .xz file, or when combining multiple Streams into single
|
| 669 |
+
* Stream.
|
| 670 |
+
*
|
| 671 |
+
* \param[out] dest lzma_index after which src is appended
|
| 672 |
+
* \param src lzma_index to be appended after dest. If this
|
| 673 |
+
* function succeeds, the memory allocated for src
|
| 674 |
+
* is freed or moved to be part of dest, and all
|
| 675 |
+
* iterators pointing to src will become invalid.
|
| 676 |
+
* \param allocator lzma_allocator for custom allocator functions.
|
| 677 |
+
* Set to NULL to use malloc() and free().
|
| 678 |
+
*
|
| 679 |
+
* \return Possible lzma_ret values:
|
| 680 |
+
* - LZMA_OK: lzma_indexes were concatenated successfully.
|
| 681 |
+
* src is now a dangling pointer.
|
| 682 |
+
* - LZMA_DATA_ERROR: *dest would grow too big.
|
| 683 |
+
* - LZMA_MEM_ERROR
|
| 684 |
+
* - LZMA_PROG_ERROR
|
| 685 |
+
*/
|
| 686 |
+
extern LZMA_API(lzma_ret) lzma_index_cat(lzma_index *dest, lzma_index *src,
|
| 687 |
+
const lzma_allocator *allocator)
|
| 688 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 689 |
+
|
| 690 |
+
|
| 691 |
+
/**
|
| 692 |
+
* \brief Duplicate lzma_index
|
| 693 |
+
*
|
| 694 |
+
* \param i Pointer to lzma_index structure to be duplicated
|
| 695 |
+
* \param allocator lzma_allocator for custom allocator functions.
|
| 696 |
+
* Set to NULL to use malloc() and free().
|
| 697 |
+
*
|
| 698 |
+
* \return A copy of the lzma_index, or NULL if memory allocation failed.
|
| 699 |
+
*/
|
| 700 |
+
extern LZMA_API(lzma_index *) lzma_index_dup(
|
| 701 |
+
const lzma_index *i, const lzma_allocator *allocator)
|
| 702 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 703 |
+
|
| 704 |
+
|
| 705 |
+
/**
|
| 706 |
+
* \brief Initialize .xz Index encoder
|
| 707 |
+
*
|
| 708 |
+
* \param strm Pointer to properly prepared lzma_stream
|
| 709 |
+
* \param i Pointer to lzma_index which should be encoded.
|
| 710 |
+
*
|
| 711 |
+
* The valid 'action' values for lzma_code() are LZMA_RUN and LZMA_FINISH.
|
| 712 |
+
* It is enough to use only one of them (you can choose freely).
|
| 713 |
+
*
|
| 714 |
+
* \return Possible lzma_ret values:
|
| 715 |
+
* - LZMA_OK: Initialization succeeded, continue with lzma_code().
|
| 716 |
+
* - LZMA_MEM_ERROR
|
| 717 |
+
* - LZMA_PROG_ERROR
|
| 718 |
+
*/
|
| 719 |
+
extern LZMA_API(lzma_ret) lzma_index_encoder(
|
| 720 |
+
lzma_stream *strm, const lzma_index *i)
|
| 721 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 722 |
+
|
| 723 |
+
|
| 724 |
+
/**
|
| 725 |
+
* \brief Initialize .xz Index decoder
|
| 726 |
+
*
|
| 727 |
+
* \param strm Pointer to properly prepared lzma_stream
|
| 728 |
+
* \param[out] i The decoded Index will be made available via
|
| 729 |
+
* this pointer. Initially this function will
|
| 730 |
+
* set *i to NULL (the old value is ignored). If
|
| 731 |
+
* decoding succeeds (lzma_code() returns
|
| 732 |
+
* LZMA_STREAM_END), *i will be set to point
|
| 733 |
+
* to a new lzma_index, which the application
|
| 734 |
+
* has to later free with lzma_index_end().
|
| 735 |
+
* \param memlimit How much memory the resulting lzma_index is
|
| 736 |
+
* allowed to require. liblzma 5.2.3 and earlier
|
| 737 |
+
* don't allow 0 here and return LZMA_PROG_ERROR;
|
| 738 |
+
* later versions treat 0 as if 1 had been specified.
|
| 739 |
+
*
|
| 740 |
+
* Valid 'action' arguments to lzma_code() are LZMA_RUN and LZMA_FINISH.
|
| 741 |
+
* There is no need to use LZMA_FINISH, but it's allowed because it may
|
| 742 |
+
* simplify certain types of applications.
|
| 743 |
+
*
|
| 744 |
+
* \return Possible lzma_ret values:
|
| 745 |
+
* - LZMA_OK: Initialization succeeded, continue with lzma_code().
|
| 746 |
+
* - LZMA_MEM_ERROR
|
| 747 |
+
* - LZMA_PROG_ERROR
|
| 748 |
+
*
|
| 749 |
+
* \note liblzma 5.2.3 and older list also LZMA_MEMLIMIT_ERROR here
|
| 750 |
+
* but that error code has never been possible from this
|
| 751 |
+
* initialization function.
|
| 752 |
+
*/
|
| 753 |
+
extern LZMA_API(lzma_ret) lzma_index_decoder(
|
| 754 |
+
lzma_stream *strm, lzma_index **i, uint64_t memlimit)
|
| 755 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 756 |
+
|
| 757 |
+
|
| 758 |
+
/**
|
| 759 |
+
* \brief Single-call .xz Index encoder
|
| 760 |
+
*
|
| 761 |
+
* \note This function doesn't take allocator argument since all
|
| 762 |
+
* the internal data is allocated on stack.
|
| 763 |
+
*
|
| 764 |
+
* \param i lzma_index to be encoded
|
| 765 |
+
* \param[out] out Beginning of the output buffer
|
| 766 |
+
* \param[out] out_pos The next byte will be written to out[*out_pos].
|
| 767 |
+
* *out_pos is updated only if encoding succeeds.
|
| 768 |
+
* \param out_size Size of the out buffer; the first byte into
|
| 769 |
+
* which no data is written to is out[out_size].
|
| 770 |
+
*
|
| 771 |
+
* \return Possible lzma_ret values:
|
| 772 |
+
* - LZMA_OK: Encoding was successful.
|
| 773 |
+
* - LZMA_BUF_ERROR: Output buffer is too small. Use
|
| 774 |
+
* lzma_index_size() to find out how much output
|
| 775 |
+
* space is needed.
|
| 776 |
+
* - LZMA_PROG_ERROR
|
| 777 |
+
*
|
| 778 |
+
*/
|
| 779 |
+
extern LZMA_API(lzma_ret) lzma_index_buffer_encode(const lzma_index *i,
|
| 780 |
+
uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow;
|
| 781 |
+
|
| 782 |
+
|
| 783 |
+
/**
|
| 784 |
+
* \brief Single-call .xz Index decoder
|
| 785 |
+
*
|
| 786 |
+
* \param[out] i If decoding succeeds, *i will point to a new
|
| 787 |
+
* lzma_index, which the application has to
|
| 788 |
+
* later free with lzma_index_end(). If an error
|
| 789 |
+
* occurs, *i will be NULL. The old value of *i
|
| 790 |
+
* is always ignored and thus doesn't need to be
|
| 791 |
+
* initialized by the caller.
|
| 792 |
+
* \param[out] memlimit Pointer to how much memory the resulting
|
| 793 |
+
* lzma_index is allowed to require. The value
|
| 794 |
+
* pointed by this pointer is modified if and only
|
| 795 |
+
* if LZMA_MEMLIMIT_ERROR is returned.
|
| 796 |
+
* \param allocator lzma_allocator for custom allocator functions.
|
| 797 |
+
* Set to NULL to use malloc() and free().
|
| 798 |
+
* \param in Beginning of the input buffer
|
| 799 |
+
* \param in_pos The next byte will be read from in[*in_pos].
|
| 800 |
+
* *in_pos is updated only if decoding succeeds.
|
| 801 |
+
* \param in_size Size of the input buffer; the first byte that
|
| 802 |
+
* won't be read is in[in_size].
|
| 803 |
+
*
|
| 804 |
+
* \return Possible lzma_ret values:
|
| 805 |
+
* - LZMA_OK: Decoding was successful.
|
| 806 |
+
* - LZMA_MEM_ERROR
|
| 807 |
+
* - LZMA_MEMLIMIT_ERROR: Memory usage limit was reached.
|
| 808 |
+
* The minimum required memlimit value was stored to *memlimit.
|
| 809 |
+
* - LZMA_DATA_ERROR
|
| 810 |
+
* - LZMA_PROG_ERROR
|
| 811 |
+
*/
|
| 812 |
+
extern LZMA_API(lzma_ret) lzma_index_buffer_decode(lzma_index **i,
|
| 813 |
+
uint64_t *memlimit, const lzma_allocator *allocator,
|
| 814 |
+
const uint8_t *in, size_t *in_pos, size_t in_size)
|
| 815 |
+
lzma_nothrow;
|
| 816 |
+
|
| 817 |
+
|
| 818 |
+
/**
|
| 819 |
+
* \brief Initialize a .xz file information decoder
|
| 820 |
+
*
|
| 821 |
+
* This decoder decodes the Stream Header, Stream Footer, Index, and
|
| 822 |
+
* Stream Padding field(s) from the input .xz file and stores the resulting
|
| 823 |
+
* combined index in *dest_index. This information can be used to get the
|
| 824 |
+
* uncompressed file size with lzma_index_uncompressed_size(*dest_index) or,
|
| 825 |
+
* for example, to implement random access reading by locating the Blocks
|
| 826 |
+
* in the Streams.
|
| 827 |
+
*
|
| 828 |
+
* To get the required information from the .xz file, lzma_code() may ask
|
| 829 |
+
* the application to seek in the input file by returning LZMA_SEEK_NEEDED
|
| 830 |
+
* and having the target file position specified in lzma_stream.seek_pos.
|
| 831 |
+
* The number of seeks required depends on the input file and how big buffers
|
| 832 |
+
* the application provides. When possible, the decoder will seek backward
|
| 833 |
+
* and forward in the given buffer to avoid useless seek requests. Thus, if
|
| 834 |
+
* the application provides the whole file at once, no external seeking will
|
| 835 |
+
* be required (that is, lzma_code() won't return LZMA_SEEK_NEEDED).
|
| 836 |
+
*
|
| 837 |
+
* The value in lzma_stream.total_in can be used to estimate how much data
|
| 838 |
+
* liblzma had to read to get the file information. However, due to seeking
|
| 839 |
+
* and the way total_in is updated, the value of total_in will be somewhat
|
| 840 |
+
* inaccurate (a little too big). Thus, total_in is a good estimate but don't
|
| 841 |
+
* expect to see the same exact value for the same file if you change the
|
| 842 |
+
* input buffer size or switch to a different liblzma version.
|
| 843 |
+
*
|
| 844 |
+
* Valid 'action' arguments to lzma_code() are LZMA_RUN and LZMA_FINISH.
|
| 845 |
+
* You only need to use LZMA_RUN; LZMA_FINISH is only supported because it
|
| 846 |
+
* might be convenient for some applications. If you use LZMA_FINISH and if
|
| 847 |
+
* lzma_code() asks the application to seek, remember to reset 'action' back
|
| 848 |
+
* to LZMA_RUN unless you hit the end of the file again.
|
| 849 |
+
*
|
| 850 |
+
* Possible return values from lzma_code():
|
| 851 |
+
* - LZMA_OK: All OK so far, more input needed
|
| 852 |
+
* - LZMA_SEEK_NEEDED: Provide more input starting from the absolute
|
| 853 |
+
* file position strm->seek_pos
|
| 854 |
+
* - LZMA_STREAM_END: Decoding was successful, *dest_index has been set
|
| 855 |
+
* - LZMA_FORMAT_ERROR: The input file is not in the .xz format (the
|
| 856 |
+
* expected magic bytes were not found from the beginning of the file)
|
| 857 |
+
* - LZMA_OPTIONS_ERROR: File looks valid but contains headers that aren't
|
| 858 |
+
* supported by this version of liblzma
|
| 859 |
+
* - LZMA_DATA_ERROR: File is corrupt
|
| 860 |
+
* - LZMA_BUF_ERROR
|
| 861 |
+
* - LZMA_MEM_ERROR
|
| 862 |
+
* - LZMA_MEMLIMIT_ERROR
|
| 863 |
+
* - LZMA_PROG_ERROR
|
| 864 |
+
*
|
| 865 |
+
* \param strm Pointer to a properly prepared lzma_stream
|
| 866 |
+
* \param[out] dest_index Pointer to a pointer where the decoder will put
|
| 867 |
+
* the decoded lzma_index. The old value
|
| 868 |
+
* of *dest_index is ignored (not freed).
|
| 869 |
+
* \param memlimit How much memory the resulting lzma_index is
|
| 870 |
+
* allowed to require. Use UINT64_MAX to
|
| 871 |
+
* effectively disable the limiter.
|
| 872 |
+
* \param file_size Size of the input .xz file
|
| 873 |
+
*
|
| 874 |
+
* \return Possible lzma_ret values:
|
| 875 |
+
* - LZMA_OK
|
| 876 |
+
* - LZMA_MEM_ERROR
|
| 877 |
+
* - LZMA_PROG_ERROR
|
| 878 |
+
*/
|
| 879 |
+
extern LZMA_API(lzma_ret) lzma_file_info_decoder(
|
| 880 |
+
lzma_stream *strm, lzma_index **dest_index,
|
| 881 |
+
uint64_t memlimit, uint64_t file_size)
|
| 882 |
+
lzma_nothrow;
|
llava_next/include/lzma/index_hash.h
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* SPDX-License-Identifier: 0BSD */
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* \file lzma/index_hash.h
|
| 5 |
+
* \brief Validate Index by using a hash function
|
| 6 |
+
* \note Never include this file directly. Use <lzma.h> instead.
|
| 7 |
+
*
|
| 8 |
+
* Hashing makes it possible to use constant amount of memory to validate
|
| 9 |
+
* Index of arbitrary size.
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
/*
|
| 13 |
+
* Author: Lasse Collin
|
| 14 |
+
*/
|
| 15 |
+
|
| 16 |
+
#ifndef LZMA_H_INTERNAL
|
| 17 |
+
# error Never include this file directly. Use <lzma.h> instead.
|
| 18 |
+
#endif
|
| 19 |
+
|
| 20 |
+
/**
|
| 21 |
+
* \brief Opaque data type to hold the Index hash
|
| 22 |
+
*/
|
| 23 |
+
typedef struct lzma_index_hash_s lzma_index_hash;
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
/**
|
| 27 |
+
* \brief Allocate and initialize a new lzma_index_hash structure
|
| 28 |
+
*
|
| 29 |
+
* If index_hash is NULL, this function allocates and initializes a new
|
| 30 |
+
* lzma_index_hash structure and returns a pointer to it. If allocation
|
| 31 |
+
* fails, NULL is returned.
|
| 32 |
+
*
|
| 33 |
+
* If index_hash is non-NULL, this function reinitializes the lzma_index_hash
|
| 34 |
+
* structure and returns the same pointer. In this case, return value cannot
|
| 35 |
+
* be NULL or a different pointer than the index_hash that was given as
|
| 36 |
+
* an argument.
|
| 37 |
+
*
|
| 38 |
+
* \param index_hash Pointer to a lzma_index_hash structure or NULL.
|
| 39 |
+
* \param allocator lzma_allocator for custom allocator functions.
|
| 40 |
+
* Set to NULL to use malloc() and free().
|
| 41 |
+
*
|
| 42 |
+
* \return Initialized lzma_index_hash structure on success or
|
| 43 |
+
* NULL on failure.
|
| 44 |
+
*/
|
| 45 |
+
extern LZMA_API(lzma_index_hash *) lzma_index_hash_init(
|
| 46 |
+
lzma_index_hash *index_hash, const lzma_allocator *allocator)
|
| 47 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
/**
|
| 51 |
+
* \brief Deallocate lzma_index_hash structure
|
| 52 |
+
*
|
| 53 |
+
* \param index_hash Pointer to a lzma_index_hash structure to free.
|
| 54 |
+
* \param allocator lzma_allocator for custom allocator functions.
|
| 55 |
+
* Set to NULL to use malloc() and free().
|
| 56 |
+
*/
|
| 57 |
+
extern LZMA_API(void) lzma_index_hash_end(
|
| 58 |
+
lzma_index_hash *index_hash, const lzma_allocator *allocator)
|
| 59 |
+
lzma_nothrow;
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
/**
|
| 63 |
+
* \brief Add a new Record to an Index hash
|
| 64 |
+
*
|
| 65 |
+
* \param index_hash Pointer to a lzma_index_hash structure
|
| 66 |
+
* \param unpadded_size Unpadded Size of a Block
|
| 67 |
+
* \param uncompressed_size Uncompressed Size of a Block
|
| 68 |
+
*
|
| 69 |
+
* \return Possible lzma_ret values:
|
| 70 |
+
* - LZMA_OK
|
| 71 |
+
* - LZMA_DATA_ERROR: Compressed or uncompressed size of the
|
| 72 |
+
* Stream or size of the Index field would grow too big.
|
| 73 |
+
* - LZMA_PROG_ERROR: Invalid arguments or this function is being
|
| 74 |
+
* used when lzma_index_hash_decode() has already been used.
|
| 75 |
+
*/
|
| 76 |
+
extern LZMA_API(lzma_ret) lzma_index_hash_append(lzma_index_hash *index_hash,
|
| 77 |
+
lzma_vli unpadded_size, lzma_vli uncompressed_size)
|
| 78 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
/**
|
| 82 |
+
* \brief Decode and validate the Index field
|
| 83 |
+
*
|
| 84 |
+
* After telling the sizes of all Blocks with lzma_index_hash_append(),
|
| 85 |
+
* the actual Index field is decoded with this function. Specifically,
|
| 86 |
+
* once decoding of the Index field has been started, no more Records
|
| 87 |
+
* can be added using lzma_index_hash_append().
|
| 88 |
+
*
|
| 89 |
+
* This function doesn't use lzma_stream structure to pass the input data.
|
| 90 |
+
* Instead, the input buffer is specified using three arguments. This is
|
| 91 |
+
* because it matches better the internal APIs of liblzma.
|
| 92 |
+
*
|
| 93 |
+
* \param index_hash Pointer to a lzma_index_hash structure
|
| 94 |
+
* \param in Pointer to the beginning of the input buffer
|
| 95 |
+
* \param[out] in_pos in[*in_pos] is the next byte to process
|
| 96 |
+
* \param in_size in[in_size] is the first byte not to process
|
| 97 |
+
*
|
| 98 |
+
* \return Possible lzma_ret values:
|
| 99 |
+
* - LZMA_OK: So far good, but more input is needed.
|
| 100 |
+
* - LZMA_STREAM_END: Index decoded successfully and it matches
|
| 101 |
+
* the Records given with lzma_index_hash_append().
|
| 102 |
+
* - LZMA_DATA_ERROR: Index is corrupt or doesn't match the
|
| 103 |
+
* information given with lzma_index_hash_append().
|
| 104 |
+
* - LZMA_BUF_ERROR: Cannot progress because *in_pos >= in_size.
|
| 105 |
+
* - LZMA_PROG_ERROR
|
| 106 |
+
*/
|
| 107 |
+
extern LZMA_API(lzma_ret) lzma_index_hash_decode(lzma_index_hash *index_hash,
|
| 108 |
+
const uint8_t *in, size_t *in_pos, size_t in_size)
|
| 109 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
/**
|
| 113 |
+
* \brief Get the size of the Index field as bytes
|
| 114 |
+
*
|
| 115 |
+
* This is needed to verify the Backward Size field in the Stream Footer.
|
| 116 |
+
*
|
| 117 |
+
* \param index_hash Pointer to a lzma_index_hash structure
|
| 118 |
+
*
|
| 119 |
+
* \return Size of the Index field in bytes.
|
| 120 |
+
*/
|
| 121 |
+
extern LZMA_API(lzma_vli) lzma_index_hash_size(
|
| 122 |
+
const lzma_index_hash *index_hash)
|
| 123 |
+
lzma_nothrow lzma_attr_pure;
|
llava_next/include/lzma/lzma12.h
ADDED
|
@@ -0,0 +1,568 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* SPDX-License-Identifier: 0BSD */
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* \file lzma/lzma12.h
|
| 5 |
+
* \brief LZMA1 and LZMA2 filters
|
| 6 |
+
* \note Never include this file directly. Use <lzma.h> instead.
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
/*
|
| 10 |
+
* Author: Lasse Collin
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
#ifndef LZMA_H_INTERNAL
|
| 14 |
+
# error Never include this file directly. Use <lzma.h> instead.
|
| 15 |
+
#endif
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
/**
|
| 19 |
+
* \brief LZMA1 Filter ID (for raw encoder/decoder only, not in .xz)
|
| 20 |
+
*
|
| 21 |
+
* LZMA1 is the very same thing as what was called just LZMA in LZMA Utils,
|
| 22 |
+
* 7-Zip, and LZMA SDK. It's called LZMA1 here to prevent developers from
|
| 23 |
+
* accidentally using LZMA when they actually want LZMA2.
|
| 24 |
+
*/
|
| 25 |
+
#define LZMA_FILTER_LZMA1 LZMA_VLI_C(0x4000000000000001)
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* \brief LZMA1 Filter ID with extended options (for raw encoder/decoder)
|
| 29 |
+
*
|
| 30 |
+
* This is like LZMA_FILTER_LZMA1 but with this ID a few extra options
|
| 31 |
+
* are supported in the lzma_options_lzma structure:
|
| 32 |
+
*
|
| 33 |
+
* - A flag to tell the encoder if the end of payload marker (EOPM) alias
|
| 34 |
+
* end of stream (EOS) marker must be written at the end of the stream.
|
| 35 |
+
* In contrast, LZMA_FILTER_LZMA1 always writes the end marker.
|
| 36 |
+
*
|
| 37 |
+
* - Decoder needs to be told the uncompressed size of the stream
|
| 38 |
+
* or that it is unknown (using the special value UINT64_MAX).
|
| 39 |
+
* If the size is known, a flag can be set to allow the presence of
|
| 40 |
+
* the end marker anyway. In contrast, LZMA_FILTER_LZMA1 always
|
| 41 |
+
* behaves as if the uncompressed size was unknown.
|
| 42 |
+
*
|
| 43 |
+
* This allows handling file formats where LZMA1 streams are used but where
|
| 44 |
+
* the end marker isn't allowed or where it might not (always) be present.
|
| 45 |
+
* This extended LZMA1 functionality is provided as a Filter ID for raw
|
| 46 |
+
* encoder and decoder instead of adding new encoder and decoder initialization
|
| 47 |
+
* functions because this way it is possible to also use extra filters,
|
| 48 |
+
* for example, LZMA_FILTER_X86 in a filter chain with LZMA_FILTER_LZMA1EXT,
|
| 49 |
+
* which might be needed to handle some file formats.
|
| 50 |
+
*/
|
| 51 |
+
#define LZMA_FILTER_LZMA1EXT LZMA_VLI_C(0x4000000000000002)
|
| 52 |
+
|
| 53 |
+
/**
|
| 54 |
+
* \brief LZMA2 Filter ID
|
| 55 |
+
*
|
| 56 |
+
* Usually you want this instead of LZMA1. Compared to LZMA1, LZMA2 adds
|
| 57 |
+
* support for LZMA_SYNC_FLUSH, uncompressed chunks (smaller expansion
|
| 58 |
+
* when trying to compress incompressible data), possibility to change
|
| 59 |
+
* lc/lp/pb in the middle of encoding, and some other internal improvements.
|
| 60 |
+
*/
|
| 61 |
+
#define LZMA_FILTER_LZMA2 LZMA_VLI_C(0x21)
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
/**
|
| 65 |
+
* \brief Match finders
|
| 66 |
+
*
|
| 67 |
+
* Match finder has major effect on both speed and compression ratio.
|
| 68 |
+
* Usually hash chains are faster than binary trees.
|
| 69 |
+
*
|
| 70 |
+
* If you will use LZMA_SYNC_FLUSH often, the hash chains may be a better
|
| 71 |
+
* choice, because binary trees get much higher compression ratio penalty
|
| 72 |
+
* with LZMA_SYNC_FLUSH.
|
| 73 |
+
*
|
| 74 |
+
* The memory usage formulas are only rough estimates, which are closest to
|
| 75 |
+
* reality when dict_size is a power of two. The formulas are more complex
|
| 76 |
+
* in reality, and can also change a little between liblzma versions. Use
|
| 77 |
+
* lzma_raw_encoder_memusage() to get more accurate estimate of memory usage.
|
| 78 |
+
*/
|
| 79 |
+
typedef enum {
|
| 80 |
+
LZMA_MF_HC3 = 0x03,
|
| 81 |
+
/**<
|
| 82 |
+
* \brief Hash Chain with 2- and 3-byte hashing
|
| 83 |
+
*
|
| 84 |
+
* Minimum nice_len: 3
|
| 85 |
+
*
|
| 86 |
+
* Memory usage:
|
| 87 |
+
* - dict_size <= 16 MiB: dict_size * 7.5
|
| 88 |
+
* - dict_size > 16 MiB: dict_size * 5.5 + 64 MiB
|
| 89 |
+
*/
|
| 90 |
+
|
| 91 |
+
LZMA_MF_HC4 = 0x04,
|
| 92 |
+
/**<
|
| 93 |
+
* \brief Hash Chain with 2-, 3-, and 4-byte hashing
|
| 94 |
+
*
|
| 95 |
+
* Minimum nice_len: 4
|
| 96 |
+
*
|
| 97 |
+
* Memory usage:
|
| 98 |
+
* - dict_size <= 32 MiB: dict_size * 7.5
|
| 99 |
+
* - dict_size > 32 MiB: dict_size * 6.5
|
| 100 |
+
*/
|
| 101 |
+
|
| 102 |
+
LZMA_MF_BT2 = 0x12,
|
| 103 |
+
/**<
|
| 104 |
+
* \brief Binary Tree with 2-byte hashing
|
| 105 |
+
*
|
| 106 |
+
* Minimum nice_len: 2
|
| 107 |
+
*
|
| 108 |
+
* Memory usage: dict_size * 9.5
|
| 109 |
+
*/
|
| 110 |
+
|
| 111 |
+
LZMA_MF_BT3 = 0x13,
|
| 112 |
+
/**<
|
| 113 |
+
* \brief Binary Tree with 2- and 3-byte hashing
|
| 114 |
+
*
|
| 115 |
+
* Minimum nice_len: 3
|
| 116 |
+
*
|
| 117 |
+
* Memory usage:
|
| 118 |
+
* - dict_size <= 16 MiB: dict_size * 11.5
|
| 119 |
+
* - dict_size > 16 MiB: dict_size * 9.5 + 64 MiB
|
| 120 |
+
*/
|
| 121 |
+
|
| 122 |
+
LZMA_MF_BT4 = 0x14
|
| 123 |
+
/**<
|
| 124 |
+
* \brief Binary Tree with 2-, 3-, and 4-byte hashing
|
| 125 |
+
*
|
| 126 |
+
* Minimum nice_len: 4
|
| 127 |
+
*
|
| 128 |
+
* Memory usage:
|
| 129 |
+
* - dict_size <= 32 MiB: dict_size * 11.5
|
| 130 |
+
* - dict_size > 32 MiB: dict_size * 10.5
|
| 131 |
+
*/
|
| 132 |
+
} lzma_match_finder;
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
/**
|
| 136 |
+
* \brief Test if given match finder is supported
|
| 137 |
+
*
|
| 138 |
+
* It is safe to call this with a value that isn't listed in
|
| 139 |
+
* lzma_match_finder enumeration; the return value will be false.
|
| 140 |
+
*
|
| 141 |
+
* There is no way to list which match finders are available in this
|
| 142 |
+
* particular liblzma version and build. It would be useless, because
|
| 143 |
+
* a new match finder, which the application developer wasn't aware,
|
| 144 |
+
* could require giving additional options to the encoder that the older
|
| 145 |
+
* match finders don't need.
|
| 146 |
+
*
|
| 147 |
+
* \param match_finder Match finder ID
|
| 148 |
+
*
|
| 149 |
+
* \return lzma_bool:
|
| 150 |
+
* - true if the match finder is supported by this liblzma build.
|
| 151 |
+
* - false otherwise.
|
| 152 |
+
*/
|
| 153 |
+
extern LZMA_API(lzma_bool) lzma_mf_is_supported(lzma_match_finder match_finder)
|
| 154 |
+
lzma_nothrow lzma_attr_const;
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
/**
|
| 158 |
+
* \brief Compression modes
|
| 159 |
+
*
|
| 160 |
+
* This selects the function used to analyze the data produced by the match
|
| 161 |
+
* finder.
|
| 162 |
+
*/
|
| 163 |
+
typedef enum {
|
| 164 |
+
LZMA_MODE_FAST = 1,
|
| 165 |
+
/**<
|
| 166 |
+
* \brief Fast compression
|
| 167 |
+
*
|
| 168 |
+
* Fast mode is usually at its best when combined with
|
| 169 |
+
* a hash chain match finder.
|
| 170 |
+
*/
|
| 171 |
+
|
| 172 |
+
LZMA_MODE_NORMAL = 2
|
| 173 |
+
/**<
|
| 174 |
+
* \brief Normal compression
|
| 175 |
+
*
|
| 176 |
+
* This is usually notably slower than fast mode. Use this
|
| 177 |
+
* together with binary tree match finders to expose the
|
| 178 |
+
* full potential of the LZMA1 or LZMA2 encoder.
|
| 179 |
+
*/
|
| 180 |
+
} lzma_mode;
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
/**
|
| 184 |
+
* \brief Test if given compression mode is supported
|
| 185 |
+
*
|
| 186 |
+
* It is safe to call this with a value that isn't listed in lzma_mode
|
| 187 |
+
* enumeration; the return value will be false.
|
| 188 |
+
*
|
| 189 |
+
* There is no way to list which modes are available in this particular
|
| 190 |
+
* liblzma version and build. It would be useless, because a new compression
|
| 191 |
+
* mode, which the application developer wasn't aware, could require giving
|
| 192 |
+
* additional options to the encoder that the older modes don't need.
|
| 193 |
+
*
|
| 194 |
+
* \param mode Mode ID.
|
| 195 |
+
*
|
| 196 |
+
* \return lzma_bool:
|
| 197 |
+
* - true if the compression mode is supported by this liblzma
|
| 198 |
+
* build.
|
| 199 |
+
* - false otherwise.
|
| 200 |
+
*/
|
| 201 |
+
extern LZMA_API(lzma_bool) lzma_mode_is_supported(lzma_mode mode)
|
| 202 |
+
lzma_nothrow lzma_attr_const;
|
| 203 |
+
|
| 204 |
+
|
| 205 |
+
/**
|
| 206 |
+
* \brief Options specific to the LZMA1 and LZMA2 filters
|
| 207 |
+
*
|
| 208 |
+
* Since LZMA1 and LZMA2 share most of the code, it's simplest to share
|
| 209 |
+
* the options structure too. For encoding, all but the reserved variables
|
| 210 |
+
* need to be initialized unless specifically mentioned otherwise.
|
| 211 |
+
* lzma_lzma_preset() can be used to get a good starting point.
|
| 212 |
+
*
|
| 213 |
+
* For raw decoding, both LZMA1 and LZMA2 need dict_size, preset_dict, and
|
| 214 |
+
* preset_dict_size (if preset_dict != NULL). LZMA1 needs also lc, lp, and pb.
|
| 215 |
+
*/
|
| 216 |
+
typedef struct {
|
| 217 |
+
/**
|
| 218 |
+
* \brief Dictionary size in bytes
|
| 219 |
+
*
|
| 220 |
+
* Dictionary size indicates how many bytes of the recently processed
|
| 221 |
+
* uncompressed data is kept in memory. One method to reduce size of
|
| 222 |
+
* the uncompressed data is to store distance-length pairs, which
|
| 223 |
+
* indicate what data to repeat from the dictionary buffer. Thus,
|
| 224 |
+
* the bigger the dictionary, the better the compression ratio
|
| 225 |
+
* usually is.
|
| 226 |
+
*
|
| 227 |
+
* Maximum size of the dictionary depends on multiple things:
|
| 228 |
+
* - Memory usage limit
|
| 229 |
+
* - Available address space (not a problem on 64-bit systems)
|
| 230 |
+
* - Selected match finder (encoder only)
|
| 231 |
+
*
|
| 232 |
+
* Currently the maximum dictionary size for encoding is 1.5 GiB
|
| 233 |
+
* (i.e. (UINT32_C(1) << 30) + (UINT32_C(1) << 29)) even on 64-bit
|
| 234 |
+
* systems for certain match finder implementation reasons. In the
|
| 235 |
+
* future, there may be match finders that support bigger
|
| 236 |
+
* dictionaries.
|
| 237 |
+
*
|
| 238 |
+
* Decoder already supports dictionaries up to 4 GiB - 1 B (i.e.
|
| 239 |
+
* UINT32_MAX), so increasing the maximum dictionary size of the
|
| 240 |
+
* encoder won't cause problems for old decoders.
|
| 241 |
+
*
|
| 242 |
+
* Because extremely small dictionaries sizes would have unneeded
|
| 243 |
+
* overhead in the decoder, the minimum dictionary size is 4096 bytes.
|
| 244 |
+
*
|
| 245 |
+
* \note When decoding, too big dictionary does no other harm
|
| 246 |
+
* than wasting memory.
|
| 247 |
+
*/
|
| 248 |
+
uint32_t dict_size;
|
| 249 |
+
# define LZMA_DICT_SIZE_MIN UINT32_C(4096)
|
| 250 |
+
# define LZMA_DICT_SIZE_DEFAULT (UINT32_C(1) << 23)
|
| 251 |
+
|
| 252 |
+
/**
|
| 253 |
+
* \brief Pointer to an initial dictionary
|
| 254 |
+
*
|
| 255 |
+
* It is possible to initialize the LZ77 history window using
|
| 256 |
+
* a preset dictionary. It is useful when compressing many
|
| 257 |
+
* similar, relatively small chunks of data independently from
|
| 258 |
+
* each other. The preset dictionary should contain typical
|
| 259 |
+
* strings that occur in the files being compressed. The most
|
| 260 |
+
* probable strings should be near the end of the preset dictionary.
|
| 261 |
+
*
|
| 262 |
+
* This feature should be used only in special situations. For
|
| 263 |
+
* now, it works correctly only with raw encoding and decoding.
|
| 264 |
+
* Currently none of the container formats supported by
|
| 265 |
+
* liblzma allow preset dictionary when decoding, thus if
|
| 266 |
+
* you create a .xz or .lzma file with preset dictionary, it
|
| 267 |
+
* cannot be decoded with the regular decoder functions. In the
|
| 268 |
+
* future, the .xz format will likely get support for preset
|
| 269 |
+
* dictionary though.
|
| 270 |
+
*/
|
| 271 |
+
const uint8_t *preset_dict;
|
| 272 |
+
|
| 273 |
+
/**
|
| 274 |
+
* \brief Size of the preset dictionary
|
| 275 |
+
*
|
| 276 |
+
* Specifies the size of the preset dictionary. If the size is
|
| 277 |
+
* bigger than dict_size, only the last dict_size bytes are
|
| 278 |
+
* processed.
|
| 279 |
+
*
|
| 280 |
+
* This variable is read only when preset_dict is not NULL.
|
| 281 |
+
* If preset_dict is not NULL but preset_dict_size is zero,
|
| 282 |
+
* no preset dictionary is used (identical to only setting
|
| 283 |
+
* preset_dict to NULL).
|
| 284 |
+
*/
|
| 285 |
+
uint32_t preset_dict_size;
|
| 286 |
+
|
| 287 |
+
/**
|
| 288 |
+
* \brief Number of literal context bits
|
| 289 |
+
*
|
| 290 |
+
* How many of the highest bits of the previous uncompressed
|
| 291 |
+
* eight-bit byte (also known as 'literal') are taken into
|
| 292 |
+
* account when predicting the bits of the next literal.
|
| 293 |
+
*
|
| 294 |
+
* E.g. in typical English text, an upper-case letter is
|
| 295 |
+
* often followed by a lower-case letter, and a lower-case
|
| 296 |
+
* letter is usually followed by another lower-case letter.
|
| 297 |
+
* In the US-ASCII character set, the highest three bits are 010
|
| 298 |
+
* for upper-case letters and 011 for lower-case letters.
|
| 299 |
+
* When lc is at least 3, the literal coding can take advantage of
|
| 300 |
+
* this property in the uncompressed data.
|
| 301 |
+
*
|
| 302 |
+
* There is a limit that applies to literal context bits and literal
|
| 303 |
+
* position bits together: lc + lp <= 4. Without this limit the
|
| 304 |
+
* decoding could become very slow, which could have security related
|
| 305 |
+
* results in some cases like email servers doing virus scanning.
|
| 306 |
+
* This limit also simplifies the internal implementation in liblzma.
|
| 307 |
+
*
|
| 308 |
+
* There may be LZMA1 streams that have lc + lp > 4 (maximum possible
|
| 309 |
+
* lc would be 8). It is not possible to decode such streams with
|
| 310 |
+
* liblzma.
|
| 311 |
+
*/
|
| 312 |
+
uint32_t lc;
|
| 313 |
+
# define LZMA_LCLP_MIN 0
|
| 314 |
+
# define LZMA_LCLP_MAX 4
|
| 315 |
+
# define LZMA_LC_DEFAULT 3
|
| 316 |
+
|
| 317 |
+
/**
|
| 318 |
+
* \brief Number of literal position bits
|
| 319 |
+
*
|
| 320 |
+
* lp affects what kind of alignment in the uncompressed data is
|
| 321 |
+
* assumed when encoding literals. A literal is a single 8-bit byte.
|
| 322 |
+
* See pb below for more information about alignment.
|
| 323 |
+
*/
|
| 324 |
+
uint32_t lp;
|
| 325 |
+
# define LZMA_LP_DEFAULT 0
|
| 326 |
+
|
| 327 |
+
/**
|
| 328 |
+
* \brief Number of position bits
|
| 329 |
+
*
|
| 330 |
+
* pb affects what kind of alignment in the uncompressed data is
|
| 331 |
+
* assumed in general. The default means four-byte alignment
|
| 332 |
+
* (2^ pb =2^2=4), which is often a good choice when there's
|
| 333 |
+
* no better guess.
|
| 334 |
+
*
|
| 335 |
+
* When the alignment is known, setting pb accordingly may reduce
|
| 336 |
+
* the file size a little. E.g. with text files having one-byte
|
| 337 |
+
* alignment (US-ASCII, ISO-8859-*, UTF-8), setting pb=0 can
|
| 338 |
+
* improve compression slightly. For UTF-16 text, pb=1 is a good
|
| 339 |
+
* choice. If the alignment is an odd number like 3 bytes, pb=0
|
| 340 |
+
* might be the best choice.
|
| 341 |
+
*
|
| 342 |
+
* Even though the assumed alignment can be adjusted with pb and
|
| 343 |
+
* lp, LZMA1 and LZMA2 still slightly favor 16-byte alignment.
|
| 344 |
+
* It might be worth taking into account when designing file formats
|
| 345 |
+
* that are likely to be often compressed with LZMA1 or LZMA2.
|
| 346 |
+
*/
|
| 347 |
+
uint32_t pb;
|
| 348 |
+
# define LZMA_PB_MIN 0
|
| 349 |
+
# define LZMA_PB_MAX 4
|
| 350 |
+
# define LZMA_PB_DEFAULT 2
|
| 351 |
+
|
| 352 |
+
/** Compression mode */
|
| 353 |
+
lzma_mode mode;
|
| 354 |
+
|
| 355 |
+
/**
|
| 356 |
+
* \brief Nice length of a match
|
| 357 |
+
*
|
| 358 |
+
* This determines how many bytes the encoder compares from the match
|
| 359 |
+
* candidates when looking for the best match. Once a match of at
|
| 360 |
+
* least nice_len bytes long is found, the encoder stops looking for
|
| 361 |
+
* better candidates and encodes the match. (Naturally, if the found
|
| 362 |
+
* match is actually longer than nice_len, the actual length is
|
| 363 |
+
* encoded; it's not truncated to nice_len.)
|
| 364 |
+
*
|
| 365 |
+
* Bigger values usually increase the compression ratio and
|
| 366 |
+
* compression time. For most files, 32 to 128 is a good value,
|
| 367 |
+
* which gives very good compression ratio at good speed.
|
| 368 |
+
*
|
| 369 |
+
* The exact minimum value depends on the match finder. The maximum
|
| 370 |
+
* is 273, which is the maximum length of a match that LZMA1 and
|
| 371 |
+
* LZMA2 can encode.
|
| 372 |
+
*/
|
| 373 |
+
uint32_t nice_len;
|
| 374 |
+
|
| 375 |
+
/** Match finder ID */
|
| 376 |
+
lzma_match_finder mf;
|
| 377 |
+
|
| 378 |
+
/**
|
| 379 |
+
* \brief Maximum search depth in the match finder
|
| 380 |
+
*
|
| 381 |
+
* For every input byte, match finder searches through the hash chain
|
| 382 |
+
* or binary tree in a loop, each iteration going one step deeper in
|
| 383 |
+
* the chain or tree. The searching stops if
|
| 384 |
+
* - a match of at least nice_len bytes long is found;
|
| 385 |
+
* - all match candidates from the hash chain or binary tree have
|
| 386 |
+
* been checked; or
|
| 387 |
+
* - maximum search depth is reached.
|
| 388 |
+
*
|
| 389 |
+
* Maximum search depth is needed to prevent the match finder from
|
| 390 |
+
* wasting too much time in case there are lots of short match
|
| 391 |
+
* candidates. On the other hand, stopping the search before all
|
| 392 |
+
* candidates have been checked can reduce compression ratio.
|
| 393 |
+
*
|
| 394 |
+
* Setting depth to zero tells liblzma to use an automatic default
|
| 395 |
+
* value, that depends on the selected match finder and nice_len.
|
| 396 |
+
* The default is in the range [4, 200] or so (it may vary between
|
| 397 |
+
* liblzma versions).
|
| 398 |
+
*
|
| 399 |
+
* Using a bigger depth value than the default can increase
|
| 400 |
+
* compression ratio in some cases. There is no strict maximum value,
|
| 401 |
+
* but high values (thousands or millions) should be used with care:
|
| 402 |
+
* the encoder could remain fast enough with typical input, but
|
| 403 |
+
* malicious input could cause the match finder to slow down
|
| 404 |
+
* dramatically, possibly creating a denial of service attack.
|
| 405 |
+
*/
|
| 406 |
+
uint32_t depth;
|
| 407 |
+
|
| 408 |
+
/**
|
| 409 |
+
* \brief For LZMA_FILTER_LZMA1EXT: Extended flags
|
| 410 |
+
*
|
| 411 |
+
* This is used only with LZMA_FILTER_LZMA1EXT.
|
| 412 |
+
*
|
| 413 |
+
* Currently only one flag is supported, LZMA_LZMA1EXT_ALLOW_EOPM:
|
| 414 |
+
*
|
| 415 |
+
* - Encoder: If the flag is set, then end marker is written just
|
| 416 |
+
* like it is with LZMA_FILTER_LZMA1. Without this flag the
|
| 417 |
+
* end marker isn't written and the application has to store
|
| 418 |
+
* the uncompressed size somewhere outside the compressed stream.
|
| 419 |
+
* To decompress streams without the end marker, the application
|
| 420 |
+
* has to set the correct uncompressed size in ext_size_low and
|
| 421 |
+
* ext_size_high.
|
| 422 |
+
*
|
| 423 |
+
* - Decoder: If the uncompressed size in ext_size_low and
|
| 424 |
+
* ext_size_high is set to the special value UINT64_MAX
|
| 425 |
+
* (indicating unknown uncompressed size) then this flag is
|
| 426 |
+
* ignored and the end marker must always be present, that is,
|
| 427 |
+
* the behavior is identical to LZMA_FILTER_LZMA1.
|
| 428 |
+
*
|
| 429 |
+
* Otherwise, if this flag isn't set, then the input stream
|
| 430 |
+
* must not have the end marker; if the end marker is detected
|
| 431 |
+
* then it will result in LZMA_DATA_ERROR. This is useful when
|
| 432 |
+
* it is known that the stream must not have the end marker and
|
| 433 |
+
* strict validation is wanted.
|
| 434 |
+
*
|
| 435 |
+
* If this flag is set, then it is autodetected if the end marker
|
| 436 |
+
* is present after the specified number of uncompressed bytes
|
| 437 |
+
* has been decompressed (ext_size_low and ext_size_high). The
|
| 438 |
+
* end marker isn't allowed in any other position. This behavior
|
| 439 |
+
* is useful when uncompressed size is known but the end marker
|
| 440 |
+
* may or may not be present. This is the case, for example,
|
| 441 |
+
* in .7z files (valid .7z files that have the end marker in
|
| 442 |
+
* LZMA1 streams are rare but they do exist).
|
| 443 |
+
*/
|
| 444 |
+
uint32_t ext_flags;
|
| 445 |
+
# define LZMA_LZMA1EXT_ALLOW_EOPM UINT32_C(0x01)
|
| 446 |
+
|
| 447 |
+
/**
|
| 448 |
+
* \brief For LZMA_FILTER_LZMA1EXT: Uncompressed size (low bits)
|
| 449 |
+
*
|
| 450 |
+
* The 64-bit uncompressed size is needed for decompression with
|
| 451 |
+
* LZMA_FILTER_LZMA1EXT. The size is ignored by the encoder.
|
| 452 |
+
*
|
| 453 |
+
* The special value UINT64_MAX indicates that the uncompressed size
|
| 454 |
+
* is unknown and that the end of payload marker (also known as
|
| 455 |
+
* end of stream marker) must be present to indicate the end of
|
| 456 |
+
* the LZMA1 stream. Any other value indicates the expected
|
| 457 |
+
* uncompressed size of the LZMA1 stream. (If LZMA1 was used together
|
| 458 |
+
* with filters that change the size of the data then the uncompressed
|
| 459 |
+
* size of the LZMA1 stream could be different than the final
|
| 460 |
+
* uncompressed size of the filtered stream.)
|
| 461 |
+
*
|
| 462 |
+
* ext_size_low holds the least significant 32 bits of the
|
| 463 |
+
* uncompressed size. The most significant 32 bits must be set
|
| 464 |
+
* in ext_size_high. The macro lzma_set_ext_size(opt_lzma, u64size)
|
| 465 |
+
* can be used to set these members.
|
| 466 |
+
*
|
| 467 |
+
* The 64-bit uncompressed size is split into two uint32_t variables
|
| 468 |
+
* because there were no reserved uint64_t members and using the
|
| 469 |
+
* same options structure for LZMA_FILTER_LZMA1, LZMA_FILTER_LZMA1EXT,
|
| 470 |
+
* and LZMA_FILTER_LZMA2 was otherwise more convenient than having
|
| 471 |
+
* a new options structure for LZMA_FILTER_LZMA1EXT. (Replacing two
|
| 472 |
+
* uint32_t members with one uint64_t changes the ABI on some systems
|
| 473 |
+
* as the alignment of this struct can increase from 4 bytes to 8.)
|
| 474 |
+
*/
|
| 475 |
+
uint32_t ext_size_low;
|
| 476 |
+
|
| 477 |
+
/**
|
| 478 |
+
* \brief For LZMA_FILTER_LZMA1EXT: Uncompressed size (high bits)
|
| 479 |
+
*
|
| 480 |
+
* This holds the most significant 32 bits of the uncompressed size.
|
| 481 |
+
*/
|
| 482 |
+
uint32_t ext_size_high;
|
| 483 |
+
|
| 484 |
+
/*
|
| 485 |
+
* Reserved space to allow possible future extensions without
|
| 486 |
+
* breaking the ABI. You should not touch these, because the names
|
| 487 |
+
* of these variables may change. These are and will never be used
|
| 488 |
+
* with the currently supported options, so it is safe to leave these
|
| 489 |
+
* uninitialized.
|
| 490 |
+
*/
|
| 491 |
+
|
| 492 |
+
/** \private Reserved member. */
|
| 493 |
+
uint32_t reserved_int4;
|
| 494 |
+
|
| 495 |
+
/** \private Reserved member. */
|
| 496 |
+
uint32_t reserved_int5;
|
| 497 |
+
|
| 498 |
+
/** \private Reserved member. */
|
| 499 |
+
uint32_t reserved_int6;
|
| 500 |
+
|
| 501 |
+
/** \private Reserved member. */
|
| 502 |
+
uint32_t reserved_int7;
|
| 503 |
+
|
| 504 |
+
/** \private Reserved member. */
|
| 505 |
+
uint32_t reserved_int8;
|
| 506 |
+
|
| 507 |
+
/** \private Reserved member. */
|
| 508 |
+
lzma_reserved_enum reserved_enum1;
|
| 509 |
+
|
| 510 |
+
/** \private Reserved member. */
|
| 511 |
+
lzma_reserved_enum reserved_enum2;
|
| 512 |
+
|
| 513 |
+
/** \private Reserved member. */
|
| 514 |
+
lzma_reserved_enum reserved_enum3;
|
| 515 |
+
|
| 516 |
+
/** \private Reserved member. */
|
| 517 |
+
lzma_reserved_enum reserved_enum4;
|
| 518 |
+
|
| 519 |
+
/** \private Reserved member. */
|
| 520 |
+
void *reserved_ptr1;
|
| 521 |
+
|
| 522 |
+
/** \private Reserved member. */
|
| 523 |
+
void *reserved_ptr2;
|
| 524 |
+
|
| 525 |
+
} lzma_options_lzma;
|
| 526 |
+
|
| 527 |
+
|
| 528 |
+
/**
|
| 529 |
+
* \brief Macro to set the 64-bit uncompressed size in ext_size_*
|
| 530 |
+
*
|
| 531 |
+
* This might be convenient when decoding using LZMA_FILTER_LZMA1EXT.
|
| 532 |
+
* This isn't used with LZMA_FILTER_LZMA1 or LZMA_FILTER_LZMA2.
|
| 533 |
+
*/
|
| 534 |
+
#define lzma_set_ext_size(opt_lzma2, u64size) \
|
| 535 |
+
do { \
|
| 536 |
+
(opt_lzma2).ext_size_low = (uint32_t)(u64size); \
|
| 537 |
+
(opt_lzma2).ext_size_high = (uint32_t)((uint64_t)(u64size) >> 32); \
|
| 538 |
+
} while (0)
|
| 539 |
+
|
| 540 |
+
|
| 541 |
+
/**
|
| 542 |
+
* \brief Set a compression preset to lzma_options_lzma structure
|
| 543 |
+
*
|
| 544 |
+
* 0 is the fastest and 9 is the slowest. These match the switches -0 .. -9
|
| 545 |
+
* of the xz command line tool. In addition, it is possible to bitwise-or
|
| 546 |
+
* flags to the preset. Currently only LZMA_PRESET_EXTREME is supported.
|
| 547 |
+
* The flags are defined in container.h, because the flags are used also
|
| 548 |
+
* with lzma_easy_encoder().
|
| 549 |
+
*
|
| 550 |
+
* The preset levels are subject to changes between liblzma versions.
|
| 551 |
+
*
|
| 552 |
+
* This function is available only if LZMA1 or LZMA2 encoder has been enabled
|
| 553 |
+
* when building liblzma.
|
| 554 |
+
*
|
| 555 |
+
* If features (like certain match finders) have been disabled at build time,
|
| 556 |
+
* then the function may return success (false) even though the resulting
|
| 557 |
+
* LZMA1/LZMA2 options may not be usable for encoder initialization
|
| 558 |
+
* (LZMA_OPTIONS_ERROR).
|
| 559 |
+
*
|
| 560 |
+
* \param[out] options Pointer to LZMA1 or LZMA2 options to be filled
|
| 561 |
+
* \param preset Preset level bitwse-ORed with preset flags
|
| 562 |
+
*
|
| 563 |
+
* \return lzma_bool:
|
| 564 |
+
* - true if the preset is not supported (failure).
|
| 565 |
+
* - false otherwise (success).
|
| 566 |
+
*/
|
| 567 |
+
extern LZMA_API(lzma_bool) lzma_lzma_preset(
|
| 568 |
+
lzma_options_lzma *options, uint32_t preset) lzma_nothrow;
|
llava_next/include/lzma/stream_flags.h
ADDED
|
@@ -0,0 +1,265 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* SPDX-License-Identifier: 0BSD */
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* \file lzma/stream_flags.h
|
| 5 |
+
* \brief .xz Stream Header and Stream Footer encoder and decoder
|
| 6 |
+
* \note Never include this file directly. Use <lzma.h> instead.
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
/*
|
| 10 |
+
* Author: Lasse Collin
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
#ifndef LZMA_H_INTERNAL
|
| 14 |
+
# error Never include this file directly. Use <lzma.h> instead.
|
| 15 |
+
#endif
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
/**
|
| 19 |
+
* \brief Size of Stream Header and Stream Footer
|
| 20 |
+
*
|
| 21 |
+
* Stream Header and Stream Footer have the same size and they are not
|
| 22 |
+
* going to change even if a newer version of the .xz file format is
|
| 23 |
+
* developed in future.
|
| 24 |
+
*/
|
| 25 |
+
#define LZMA_STREAM_HEADER_SIZE 12
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
/**
|
| 29 |
+
* \brief Options for encoding/decoding Stream Header and Stream Footer
|
| 30 |
+
*/
|
| 31 |
+
typedef struct {
|
| 32 |
+
/**
|
| 33 |
+
* \brief Stream Flags format version
|
| 34 |
+
*
|
| 35 |
+
* To prevent API and ABI breakages if new features are needed in
|
| 36 |
+
* Stream Header or Stream Footer, a version number is used to
|
| 37 |
+
* indicate which members in this structure are in use. For now,
|
| 38 |
+
* version must always be zero. With non-zero version, the
|
| 39 |
+
* lzma_stream_header_encode() and lzma_stream_footer_encode()
|
| 40 |
+
* will return LZMA_OPTIONS_ERROR.
|
| 41 |
+
*
|
| 42 |
+
* lzma_stream_header_decode() and lzma_stream_footer_decode()
|
| 43 |
+
* will always set this to the lowest value that supports all the
|
| 44 |
+
* features indicated by the Stream Flags field. The application
|
| 45 |
+
* must check that the version number set by the decoding functions
|
| 46 |
+
* is supported by the application. Otherwise it is possible that
|
| 47 |
+
* the application will decode the Stream incorrectly.
|
| 48 |
+
*/
|
| 49 |
+
uint32_t version;
|
| 50 |
+
|
| 51 |
+
/**
|
| 52 |
+
* \brief Backward Size
|
| 53 |
+
*
|
| 54 |
+
* Backward Size must be a multiple of four bytes. In this Stream
|
| 55 |
+
* format version, Backward Size is the size of the Index field.
|
| 56 |
+
*
|
| 57 |
+
* Backward Size isn't actually part of the Stream Flags field, but
|
| 58 |
+
* it is convenient to include in this structure anyway. Backward
|
| 59 |
+
* Size is present only in the Stream Footer. There is no need to
|
| 60 |
+
* initialize backward_size when encoding Stream Header.
|
| 61 |
+
*
|
| 62 |
+
* lzma_stream_header_decode() always sets backward_size to
|
| 63 |
+
* LZMA_VLI_UNKNOWN so that it is convenient to use
|
| 64 |
+
* lzma_stream_flags_compare() when both Stream Header and Stream
|
| 65 |
+
* Footer have been decoded.
|
| 66 |
+
*/
|
| 67 |
+
lzma_vli backward_size;
|
| 68 |
+
|
| 69 |
+
/**
|
| 70 |
+
* \brief Minimum value for lzma_stream_flags.backward_size
|
| 71 |
+
*/
|
| 72 |
+
# define LZMA_BACKWARD_SIZE_MIN 4
|
| 73 |
+
|
| 74 |
+
/**
|
| 75 |
+
* \brief Maximum value for lzma_stream_flags.backward_size
|
| 76 |
+
*/
|
| 77 |
+
# define LZMA_BACKWARD_SIZE_MAX (LZMA_VLI_C(1) << 34)
|
| 78 |
+
|
| 79 |
+
/**
|
| 80 |
+
* \brief Check ID
|
| 81 |
+
*
|
| 82 |
+
* This indicates the type of the integrity check calculated from
|
| 83 |
+
* uncompressed data.
|
| 84 |
+
*/
|
| 85 |
+
lzma_check check;
|
| 86 |
+
|
| 87 |
+
/*
|
| 88 |
+
* Reserved space to allow possible future extensions without
|
| 89 |
+
* breaking the ABI. You should not touch these, because the
|
| 90 |
+
* names of these variables may change.
|
| 91 |
+
*
|
| 92 |
+
* (We will never be able to use all of these since Stream Flags
|
| 93 |
+
* is just two bytes plus Backward Size of four bytes. But it's
|
| 94 |
+
* nice to have the proper types when they are needed.)
|
| 95 |
+
*/
|
| 96 |
+
|
| 97 |
+
/** \private Reserved member. */
|
| 98 |
+
lzma_reserved_enum reserved_enum1;
|
| 99 |
+
|
| 100 |
+
/** \private Reserved member. */
|
| 101 |
+
lzma_reserved_enum reserved_enum2;
|
| 102 |
+
|
| 103 |
+
/** \private Reserved member. */
|
| 104 |
+
lzma_reserved_enum reserved_enum3;
|
| 105 |
+
|
| 106 |
+
/** \private Reserved member. */
|
| 107 |
+
lzma_reserved_enum reserved_enum4;
|
| 108 |
+
|
| 109 |
+
/** \private Reserved member. */
|
| 110 |
+
lzma_bool reserved_bool1;
|
| 111 |
+
|
| 112 |
+
/** \private Reserved member. */
|
| 113 |
+
lzma_bool reserved_bool2;
|
| 114 |
+
|
| 115 |
+
/** \private Reserved member. */
|
| 116 |
+
lzma_bool reserved_bool3;
|
| 117 |
+
|
| 118 |
+
/** \private Reserved member. */
|
| 119 |
+
lzma_bool reserved_bool4;
|
| 120 |
+
|
| 121 |
+
/** \private Reserved member. */
|
| 122 |
+
lzma_bool reserved_bool5;
|
| 123 |
+
|
| 124 |
+
/** \private Reserved member. */
|
| 125 |
+
lzma_bool reserved_bool6;
|
| 126 |
+
|
| 127 |
+
/** \private Reserved member. */
|
| 128 |
+
lzma_bool reserved_bool7;
|
| 129 |
+
|
| 130 |
+
/** \private Reserved member. */
|
| 131 |
+
lzma_bool reserved_bool8;
|
| 132 |
+
|
| 133 |
+
/** \private Reserved member. */
|
| 134 |
+
uint32_t reserved_int1;
|
| 135 |
+
|
| 136 |
+
/** \private Reserved member. */
|
| 137 |
+
uint32_t reserved_int2;
|
| 138 |
+
|
| 139 |
+
} lzma_stream_flags;
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
/**
|
| 143 |
+
* \brief Encode Stream Header
|
| 144 |
+
*
|
| 145 |
+
* \param options Stream Header options to be encoded.
|
| 146 |
+
* options->backward_size is ignored and doesn't
|
| 147 |
+
* need to be initialized.
|
| 148 |
+
* \param[out] out Beginning of the output buffer of
|
| 149 |
+
* LZMA_STREAM_HEADER_SIZE bytes.
|
| 150 |
+
*
|
| 151 |
+
* \return Possible lzma_ret values:
|
| 152 |
+
* - LZMA_OK: Encoding was successful.
|
| 153 |
+
* - LZMA_OPTIONS_ERROR: options->version is not supported by
|
| 154 |
+
* this liblzma version.
|
| 155 |
+
* - LZMA_PROG_ERROR: Invalid options.
|
| 156 |
+
*/
|
| 157 |
+
extern LZMA_API(lzma_ret) lzma_stream_header_encode(
|
| 158 |
+
const lzma_stream_flags *options, uint8_t *out)
|
| 159 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
/**
|
| 163 |
+
* \brief Encode Stream Footer
|
| 164 |
+
*
|
| 165 |
+
* \param options Stream Footer options to be encoded.
|
| 166 |
+
* \param[out] out Beginning of the output buffer of
|
| 167 |
+
* LZMA_STREAM_HEADER_SIZE bytes.
|
| 168 |
+
*
|
| 169 |
+
* \return Possible lzma_ret values:
|
| 170 |
+
* - LZMA_OK: Encoding was successful.
|
| 171 |
+
* - LZMA_OPTIONS_ERROR: options->version is not supported by
|
| 172 |
+
* this liblzma version.
|
| 173 |
+
* - LZMA_PROG_ERROR: Invalid options.
|
| 174 |
+
*/
|
| 175 |
+
extern LZMA_API(lzma_ret) lzma_stream_footer_encode(
|
| 176 |
+
const lzma_stream_flags *options, uint8_t *out)
|
| 177 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 178 |
+
|
| 179 |
+
|
| 180 |
+
/**
|
| 181 |
+
* \brief Decode Stream Header
|
| 182 |
+
*
|
| 183 |
+
* options->backward_size is always set to LZMA_VLI_UNKNOWN. This is to
|
| 184 |
+
* help comparing Stream Flags from Stream Header and Stream Footer with
|
| 185 |
+
* lzma_stream_flags_compare().
|
| 186 |
+
*
|
| 187 |
+
* \note When decoding .xz files that contain multiple Streams, it may
|
| 188 |
+
* make sense to print "file format not recognized" only if
|
| 189 |
+
* decoding of the Stream Header of the \a first Stream gives
|
| 190 |
+
* LZMA_FORMAT_ERROR. If non-first Stream Header gives
|
| 191 |
+
* LZMA_FORMAT_ERROR, the message used for LZMA_DATA_ERROR is
|
| 192 |
+
* probably more appropriate.
|
| 193 |
+
* For example, the Stream decoder in liblzma uses
|
| 194 |
+
* LZMA_DATA_ERROR if LZMA_FORMAT_ERROR is returned by
|
| 195 |
+
* lzma_stream_header_decode() when decoding non-first Stream.
|
| 196 |
+
*
|
| 197 |
+
* \param[out] options Target for the decoded Stream Header options.
|
| 198 |
+
* \param in Beginning of the input buffer of
|
| 199 |
+
* LZMA_STREAM_HEADER_SIZE bytes.
|
| 200 |
+
*
|
| 201 |
+
*
|
| 202 |
+
* \return Possible lzma_ret values:
|
| 203 |
+
* - LZMA_OK: Decoding was successful.
|
| 204 |
+
* - LZMA_FORMAT_ERROR: Magic bytes don't match, thus the given
|
| 205 |
+
* buffer cannot be Stream Header.
|
| 206 |
+
* - LZMA_DATA_ERROR: CRC32 doesn't match, thus the header
|
| 207 |
+
* is corrupt.
|
| 208 |
+
* - LZMA_OPTIONS_ERROR: Unsupported options are present
|
| 209 |
+
* in the header.
|
| 210 |
+
*/
|
| 211 |
+
extern LZMA_API(lzma_ret) lzma_stream_header_decode(
|
| 212 |
+
lzma_stream_flags *options, const uint8_t *in)
|
| 213 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 214 |
+
|
| 215 |
+
|
| 216 |
+
/**
|
| 217 |
+
* \brief Decode Stream Footer
|
| 218 |
+
*
|
| 219 |
+
* \note If Stream Header was already decoded successfully, but
|
| 220 |
+
* decoding Stream Footer returns LZMA_FORMAT_ERROR, the
|
| 221 |
+
* application should probably report some other error message
|
| 222 |
+
* than "file format not recognized". The file likely
|
| 223 |
+
* is corrupt (possibly truncated). The Stream decoder in liblzma
|
| 224 |
+
* uses LZMA_DATA_ERROR in this situation.
|
| 225 |
+
*
|
| 226 |
+
* \param[out] options Target for the decoded Stream Footer options.
|
| 227 |
+
* \param in Beginning of the input buffer of
|
| 228 |
+
* LZMA_STREAM_HEADER_SIZE bytes.
|
| 229 |
+
*
|
| 230 |
+
* \return Possible lzma_ret values:
|
| 231 |
+
* - LZMA_OK: Decoding was successful.
|
| 232 |
+
* - LZMA_FORMAT_ERROR: Magic bytes don't match, thus the given
|
| 233 |
+
* buffer cannot be Stream Footer.
|
| 234 |
+
* - LZMA_DATA_ERROR: CRC32 doesn't match, thus the Stream Footer
|
| 235 |
+
* is corrupt.
|
| 236 |
+
* - LZMA_OPTIONS_ERROR: Unsupported options are present
|
| 237 |
+
* in Stream Footer.
|
| 238 |
+
*/
|
| 239 |
+
extern LZMA_API(lzma_ret) lzma_stream_footer_decode(
|
| 240 |
+
lzma_stream_flags *options, const uint8_t *in)
|
| 241 |
+
lzma_nothrow lzma_attr_warn_unused_result;
|
| 242 |
+
|
| 243 |
+
|
| 244 |
+
/**
|
| 245 |
+
* \brief Compare two lzma_stream_flags structures
|
| 246 |
+
*
|
| 247 |
+
* backward_size values are compared only if both are not
|
| 248 |
+
* LZMA_VLI_UNKNOWN.
|
| 249 |
+
*
|
| 250 |
+
* \param a Pointer to lzma_stream_flags structure
|
| 251 |
+
* \param b Pointer to lzma_stream_flags structure
|
| 252 |
+
*
|
| 253 |
+
* \return Possible lzma_ret values:
|
| 254 |
+
* - LZMA_OK: Both are equal. If either had backward_size set
|
| 255 |
+
* to LZMA_VLI_UNKNOWN, backward_size values were not
|
| 256 |
+
* compared or validated.
|
| 257 |
+
* - LZMA_DATA_ERROR: The structures differ.
|
| 258 |
+
* - LZMA_OPTIONS_ERROR: version in either structure is greater
|
| 259 |
+
* than the maximum supported version (currently zero).
|
| 260 |
+
* - LZMA_PROG_ERROR: Invalid value, e.g. invalid check or
|
| 261 |
+
* backward_size.
|
| 262 |
+
*/
|
| 263 |
+
extern LZMA_API(lzma_ret) lzma_stream_flags_compare(
|
| 264 |
+
const lzma_stream_flags *a, const lzma_stream_flags *b)
|
| 265 |
+
lzma_nothrow lzma_attr_pure;
|
llava_next/include/lzma/version.h
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/* SPDX-License-Identifier: 0BSD */
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* \file lzma/version.h
|
| 5 |
+
* \brief Version number
|
| 6 |
+
* \note Never include this file directly. Use <lzma.h> instead.
|
| 7 |
+
*/
|
| 8 |
+
|
| 9 |
+
/*
|
| 10 |
+
* Author: Lasse Collin
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
#ifndef LZMA_H_INTERNAL
|
| 14 |
+
# error Never include this file directly. Use <lzma.h> instead.
|
| 15 |
+
#endif
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
/** \brief Major version number of the liblzma release. */
|
| 19 |
+
#define LZMA_VERSION_MAJOR 5
|
| 20 |
+
|
| 21 |
+
/** \brief Minor version number of the liblzma release. */
|
| 22 |
+
#define LZMA_VERSION_MINOR 6
|
| 23 |
+
|
| 24 |
+
/** \brief Patch version number of the liblzma release. */
|
| 25 |
+
#define LZMA_VERSION_PATCH 4
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* \brief Version stability marker
|
| 29 |
+
*
|
| 30 |
+
* This will always be one of three values:
|
| 31 |
+
* - LZMA_VERSION_STABILITY_ALPHA
|
| 32 |
+
* - LZMA_VERSION_STABILITY_BETA
|
| 33 |
+
* - LZMA_VERSION_STABILITY_STABLE
|
| 34 |
+
*/
|
| 35 |
+
#define LZMA_VERSION_STABILITY LZMA_VERSION_STABILITY_STABLE
|
| 36 |
+
|
| 37 |
+
/** \brief Commit version number of the liblzma release */
|
| 38 |
+
#ifndef LZMA_VERSION_COMMIT
|
| 39 |
+
# define LZMA_VERSION_COMMIT ""
|
| 40 |
+
#endif
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
/*
|
| 44 |
+
* Map symbolic stability levels to integers.
|
| 45 |
+
*/
|
| 46 |
+
#define LZMA_VERSION_STABILITY_ALPHA 0
|
| 47 |
+
#define LZMA_VERSION_STABILITY_BETA 1
|
| 48 |
+
#define LZMA_VERSION_STABILITY_STABLE 2
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
/**
|
| 52 |
+
* \brief Compile-time version number
|
| 53 |
+
*
|
| 54 |
+
* The version number is of format xyyyzzzs where
|
| 55 |
+
* - x = major
|
| 56 |
+
* - yyy = minor
|
| 57 |
+
* - zzz = revision
|
| 58 |
+
* - s indicates stability: 0 = alpha, 1 = beta, 2 = stable
|
| 59 |
+
*
|
| 60 |
+
* The same xyyyzzz triplet is never reused with different stability levels.
|
| 61 |
+
* For example, if 5.1.0alpha has been released, there will never be 5.1.0beta
|
| 62 |
+
* or 5.1.0 stable.
|
| 63 |
+
*
|
| 64 |
+
* \note The version number of liblzma has nothing to with
|
| 65 |
+
* the version number of Igor Pavlov's LZMA SDK.
|
| 66 |
+
*/
|
| 67 |
+
#define LZMA_VERSION (LZMA_VERSION_MAJOR * UINT32_C(10000000) \
|
| 68 |
+
+ LZMA_VERSION_MINOR * UINT32_C(10000) \
|
| 69 |
+
+ LZMA_VERSION_PATCH * UINT32_C(10) \
|
| 70 |
+
+ LZMA_VERSION_STABILITY)
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
/*
|
| 74 |
+
* Macros to construct the compile-time version string
|
| 75 |
+
*/
|
| 76 |
+
#if LZMA_VERSION_STABILITY == LZMA_VERSION_STABILITY_ALPHA
|
| 77 |
+
# define LZMA_VERSION_STABILITY_STRING "alpha"
|
| 78 |
+
#elif LZMA_VERSION_STABILITY == LZMA_VERSION_STABILITY_BETA
|
| 79 |
+
# define LZMA_VERSION_STABILITY_STRING "beta"
|
| 80 |
+
#elif LZMA_VERSION_STABILITY == LZMA_VERSION_STABILITY_STABLE
|
| 81 |
+
# define LZMA_VERSION_STABILITY_STRING ""
|
| 82 |
+
#else
|
| 83 |
+
# error Incorrect LZMA_VERSION_STABILITY
|
| 84 |
+
#endif
|
| 85 |
+
|
| 86 |
+
#define LZMA_VERSION_STRING_C_(major, minor, patch, stability, commit) \
|
| 87 |
+
#major "." #minor "." #patch stability commit
|
| 88 |
+
|
| 89 |
+
#define LZMA_VERSION_STRING_C(major, minor, patch, stability, commit) \
|
| 90 |
+
LZMA_VERSION_STRING_C_(major, minor, patch, stability, commit)
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
/**
|
| 94 |
+
* \brief Compile-time version as a string
|
| 95 |
+
*
|
| 96 |
+
* This can be for example "4.999.5alpha", "4.999.8beta", or "5.0.0" (stable
|
| 97 |
+
* versions don't have any "stable" suffix). In future, a snapshot built
|
| 98 |
+
* from source code repository may include an additional suffix, for example
|
| 99 |
+
* "4.999.8beta-21-g1d92". The commit ID won't be available in numeric form
|
| 100 |
+
* in LZMA_VERSION macro.
|
| 101 |
+
*/
|
| 102 |
+
#define LZMA_VERSION_STRING LZMA_VERSION_STRING_C( \
|
| 103 |
+
LZMA_VERSION_MAJOR, LZMA_VERSION_MINOR, \
|
| 104 |
+
LZMA_VERSION_PATCH, LZMA_VERSION_STABILITY_STRING, \
|
| 105 |
+
LZMA_VERSION_COMMIT)
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
/* #ifndef is needed for use with windres (MinGW-w64 or Cygwin). */
|
| 109 |
+
#ifndef LZMA_H_INTERNAL_RC
|
| 110 |
+
|
| 111 |
+
/**
|
| 112 |
+
* \brief Run-time version number as an integer
|
| 113 |
+
*
|
| 114 |
+
* This allows an application to compare if it was built against the same,
|
| 115 |
+
* older, or newer version of liblzma that is currently running.
|
| 116 |
+
*
|
| 117 |
+
* \return The value of LZMA_VERSION macro at the compile time of liblzma
|
| 118 |
+
*/
|
| 119 |
+
extern LZMA_API(uint32_t) lzma_version_number(void)
|
| 120 |
+
lzma_nothrow lzma_attr_const;
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
/**
|
| 124 |
+
* \brief Run-time version as a string
|
| 125 |
+
*
|
| 126 |
+
* This function may be useful to display which version of liblzma an
|
| 127 |
+
* application is currently using.
|
| 128 |
+
*
|
| 129 |
+
* \return Run-time version of liblzma
|
| 130 |
+
*/
|
| 131 |
+
extern LZMA_API(const char *) lzma_version_string(void)
|
| 132 |
+
lzma_nothrow lzma_attr_const;
|
| 133 |
+
|
| 134 |
+
#endif
|
llava_next/include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
|
|
|
|
|
|
| 1 |
+
/* SPDX-License-Identifier: 0BSD */
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* \file lzma/vli.h
|
| 5 |
+
* \brief Variable-length integer handling
|
| 6 |
+
* \note Never include this file directly. Use <lzma.h> instead.
|
| 7 |
+
*
|
| 8 |
+
* In the .xz format, most integers are encoded in a variable-length
|
| 9 |
+
* representation, which is sometimes called little endian base-128 encoding.
|
| 10 |
+
* This saves space when smaller values are more likely than bigger values.
|
| 11 |
+
*
|
| 12 |
+
* The encoding scheme encodes seven bits to every byte, using minimum
|
| 13 |
+
* number of bytes required to represent the given value. Encodings that use
|
| 14 |
+
* non-minimum number of bytes are invalid, thus every integer has exactly
|
| 15 |
+
* one encoded representation. The maximum number of bits in a VLI is 63,
|
| 16 |
+
* thus the vli argument must be less than or equal to UINT64_MAX / 2. You
|
| 17 |
+
* should use LZMA_VLI_MAX for clarity.
|
| 18 |
+
*/
|
| 19 |
+
|
| 20 |
+
/*
|
| 21 |
+
* Author: Lasse Collin
|
| 22 |
+
*/
|
| 23 |
+
|
| 24 |
+
#ifndef LZMA_H_INTERNAL
|
| 25 |
+
# error Never include this file directly. Use <lzma.h> instead.
|
| 26 |
+
#endif
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
/**
|
| 30 |
+
* \brief Maximum supported value of a variable-length integer
|
| 31 |
+
*/
|
| 32 |
+
#define LZMA_VLI_MAX (UINT64_MAX / 2)
|
| 33 |
+
|
| 34 |
+
/**
|
| 35 |
+
* \brief VLI value to denote that the value is unknown
|
| 36 |
+
*/
|
| 37 |
+
#define LZMA_VLI_UNKNOWN UINT64_MAX
|
| 38 |
+
|
| 39 |
+
/**
|
| 40 |
+
* \brief Maximum supported encoded length of variable length integers
|
| 41 |
+
*/
|
| 42 |
+
#define LZMA_VLI_BYTES_MAX 9
|
| 43 |
+
|
| 44 |
+
/**
|
| 45 |
+
* \brief VLI constant suffix
|
| 46 |
+
*/
|
| 47 |
+
#define LZMA_VLI_C(n) UINT64_C(n)
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
/**
|
| 51 |
+
* \brief Variable-length integer type
|
| 52 |
+
*
|
| 53 |
+
* Valid VLI values are in the range [0, LZMA_VLI_MAX]. Unknown value is
|
| 54 |
+
* indicated with LZMA_VLI_UNKNOWN, which is the maximum value of the
|
| 55 |
+
* underlying integer type.
|
| 56 |
+
*
|
| 57 |
+
* lzma_vli will be uint64_t for the foreseeable future. If a bigger size
|
| 58 |
+
* is needed in the future, it is guaranteed that 2 * LZMA_VLI_MAX will
|
| 59 |
+
* not overflow lzma_vli. This simplifies integer overflow detection.
|
| 60 |
+
*/
|
| 61 |
+
typedef uint64_t lzma_vli;
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
/**
|
| 65 |
+
* \brief Validate a variable-length integer
|
| 66 |
+
*
|
| 67 |
+
* This is useful to test that application has given acceptable values
|
| 68 |
+
* for example in the uncompressed_size and compressed_size variables.
|
| 69 |
+
*
|
| 70 |
+
* \return True if the integer is representable as a VLI or if it
|
| 71 |
+
* indicates an unknown value. False otherwise.
|
| 72 |
+
*/
|
| 73 |
+
#define lzma_vli_is_valid(vli) \
|
| 74 |
+
((vli) <= LZMA_VLI_MAX || (vli) == LZMA_VLI_UNKNOWN)
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
/**
|
| 78 |
+
* \brief Encode a variable-length integer
|
| 79 |
+
*
|
| 80 |
+
* This function has two modes: single-call and multi-call. Single-call mode
|
| 81 |
+
* encodes the whole integer at once; it is an error if the output buffer is
|
| 82 |
+
* too small. Multi-call mode saves the position in *vli_pos, and thus it is
|
| 83 |
+
* possible to continue encoding if the buffer becomes full before the whole
|
| 84 |
+
* integer has been encoded.
|
| 85 |
+
*
|
| 86 |
+
* \param vli Integer to be encoded
|
| 87 |
+
* \param[out] vli_pos How many VLI-encoded bytes have already been written
|
| 88 |
+
* out. When starting to encode a new integer in
|
| 89 |
+
* multi-call mode, *vli_pos must be set to zero.
|
| 90 |
+
* To use single-call encoding, set vli_pos to NULL.
|
| 91 |
+
* \param[out] out Beginning of the output buffer
|
| 92 |
+
* \param[out] out_pos The next byte will be written to out[*out_pos].
|
| 93 |
+
* \param out_size Size of the out buffer; the first byte into
|
| 94 |
+
* which no data is written to is out[out_size].
|
| 95 |
+
*
|
| 96 |
+
* \return Slightly different return values are used in multi-call and
|
| 97 |
+
* single-call modes.
|
| 98 |
+
*
|
| 99 |
+
* Single-call (vli_pos == NULL):
|
| 100 |
+
* - LZMA_OK: Integer successfully encoded.
|
| 101 |
+
* - LZMA_PROG_ERROR: Arguments are not sane. This can be due
|
| 102 |
+
* to too little output space; single-call mode doesn't use
|
| 103 |
+
* LZMA_BUF_ERROR, since the application should have checked
|
| 104 |
+
* the encoded size with lzma_vli_size().
|
| 105 |
+
*
|
| 106 |
+
* Multi-call (vli_pos != NULL):
|
| 107 |
+
* - LZMA_OK: So far all OK, but the integer is not
|
| 108 |
+
* completely written out yet.
|
| 109 |
+
* - LZMA_STREAM_END: Integer successfully encoded.
|
| 110 |
+
* - LZMA_BUF_ERROR: No output space was provided.
|
| 111 |
+
* - LZMA_PROG_ERROR: Arguments are not sane.
|
| 112 |
+
*/
|
| 113 |
+
extern LZMA_API(lzma_ret) lzma_vli_encode(lzma_vli vli, size_t *vli_pos,
|
| 114 |
+
uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow;
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
/**
|
| 118 |
+
* \brief Decode a variable-length integer
|
| 119 |
+
*
|
| 120 |
+
* Like lzma_vli_encode(), this function has single-call and multi-call modes.
|
| 121 |
+
*
|
| 122 |
+
* \param[out] vli Pointer to decoded integer. The decoder will
|
| 123 |
+
* initialize it to zero when *vli_pos == 0, so
|
| 124 |
+
* application isn't required to initialize *vli.
|
| 125 |
+
* \param[out] vli_pos How many bytes have already been decoded. When
|
| 126 |
+
* starting to decode a new integer in multi-call
|
| 127 |
+
* mode, *vli_pos must be initialized to zero. To
|
| 128 |
+
* use single-call decoding, set vli_pos to NULL.
|
| 129 |
+
* \param in Beginning of the input buffer
|
| 130 |
+
* \param[out] in_pos The next byte will be read from in[*in_pos].
|
| 131 |
+
* \param in_size Size of the input buffer; the first byte that
|
| 132 |
+
* won't be read is in[in_size].
|
| 133 |
+
*
|
| 134 |
+
* \return Slightly different return values are used in multi-call and
|
| 135 |
+
* single-call modes.
|
| 136 |
+
*
|
| 137 |
+
* Single-call (vli_pos == NULL):
|
| 138 |
+
* - LZMA_OK: Integer successfully decoded.
|
| 139 |
+
* - LZMA_DATA_ERROR: Integer is corrupt. This includes hitting
|
| 140 |
+
* the end of the input buffer before the whole integer was
|
| 141 |
+
* decoded; providing no input at all will use LZMA_DATA_ERROR.
|
| 142 |
+
* - LZMA_PROG_ERROR: Arguments are not sane.
|
| 143 |
+
*
|
| 144 |
+
* Multi-call (vli_pos != NULL):
|
| 145 |
+
* - LZMA_OK: So far all OK, but the integer is not
|
| 146 |
+
* completely decoded yet.
|
| 147 |
+
* - LZMA_STREAM_END: Integer successfully decoded.
|
| 148 |
+
* - LZMA_DATA_ERROR: Integer is corrupt.
|
| 149 |
+
* - LZMA_BUF_ERROR: No input was provided.
|
| 150 |
+
* - LZMA_PROG_ERROR: Arguments are not sane.
|
| 151 |
+
*/
|
| 152 |
+
extern LZMA_API(lzma_ret) lzma_vli_decode(lzma_vli *vli, size_t *vli_pos,
|
| 153 |
+
const uint8_t *in, size_t *in_pos, size_t in_size)
|
| 154 |
+
lzma_nothrow;
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
/**
|
| 158 |
+
* \brief Get the number of bytes required to encode a VLI
|
| 159 |
+
*
|
| 160 |
+
* \param vli Integer whose encoded size is to be determined
|
| 161 |
+
*
|
| 162 |
+
* \return Number of bytes on success (1-9). If vli isn't valid,
|
| 163 |
+
* zero is returned.
|
| 164 |
+
*/
|
| 165 |
+
extern LZMA_API(uint32_t) lzma_vli_size(lzma_vli vli)
|
| 166 |
+
lzma_nothrow lzma_attr_p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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// * This makes emacs happy -*-Mode: C++;-*-
|
| 2 |
+
/****************************************************************************
|
| 3 |
+
* Copyright 2019-2020,2021 Thomas E. Dickey *
|
| 4 |
+
* Copyright 1998-2005,2011 Free Software Foundation, Inc. *
|
| 5 |
+
* *
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person obtaining a *
|
| 7 |
+
* copy of this software and associated documentation files (the *
|
| 8 |
+
* "Software"), to deal in the Software without restriction, including *
|
| 9 |
+
* without limitation the rights to use, copy, modify, merge, publish, *
|
| 10 |
+
* distribute, distribute with modifications, sublicense, and/or sell *
|
| 11 |
+
* copies of the Software, and to permit persons to whom the Software is *
|
| 12 |
+
* furnished to do so, subject to the following conditions: *
|
| 13 |
+
* *
|
| 14 |
+
* The above copyright notice and this permission notice shall be included *
|
| 15 |
+
* in all copies or substantial portions of the Software. *
|
| 16 |
+
* *
|
| 17 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
|
| 18 |
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
|
| 19 |
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
|
| 20 |
+
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
|
| 21 |
+
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
|
| 22 |
+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
|
| 23 |
+
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
| 24 |
+
* *
|
| 25 |
+
* Except as contained in this notice, the name(s) of the above copyright *
|
| 26 |
+
* holders shall not be used in advertising or otherwise to promote the *
|
| 27 |
+
* sale, use or other dealings in this Software without prior written *
|
| 28 |
+
* authorization. *
|
| 29 |
+
****************************************************************************/
|
| 30 |
+
|
| 31 |
+
/****************************************************************************
|
| 32 |
+
* Author: Juergen Pfeifer, 1997 *
|
| 33 |
+
****************************************************************************/
|
| 34 |
+
|
| 35 |
+
// $Id: cursesapp.h,v 1.18 2021/06/17 21:26:02 tom Exp $
|
| 36 |
+
|
| 37 |
+
#ifndef NCURSES_CURSESAPP_H_incl
|
| 38 |
+
#define NCURSES_CURSESAPP_H_incl
|
| 39 |
+
|
| 40 |
+
#include <ncursesw/cursslk.h>
|
| 41 |
+
|
| 42 |
+
#if (defined(_WIN32) || defined(_WIN64))
|
| 43 |
+
# define NCURSES_CXX_MAIN_NAME cursespp_main
|
| 44 |
+
# define NCURSES_CXX_MAIN \
|
| 45 |
+
int main(int argc, char *argv[]) { \
|
| 46 |
+
return NCURSES_CXX_MAIN_NAME(argc, argv); \
|
| 47 |
+
}
|
| 48 |
+
#else
|
| 49 |
+
# define NCURSES_CXX_MAIN_NAME main
|
| 50 |
+
#endif
|
| 51 |
+
NCURSES_CXX_IMPEXP int NCURSES_CXX_MAIN_NAME(int argc, char *argv[]);
|
| 52 |
+
|
| 53 |
+
class NCURSES_CXX_IMPEXP NCursesApplication {
|
| 54 |
+
public:
|
| 55 |
+
typedef struct _slk_link { // This structure is used to maintain
|
| 56 |
+
struct _slk_link* prev; // a stack of SLKs
|
| 57 |
+
Soft_Label_Key_Set* SLKs;
|
| 58 |
+
} SLK_Link;
|
| 59 |
+
private:
|
| 60 |
+
static int rinit(NCursesWindow& w); // Internal Init function for title
|
| 61 |
+
static NCursesApplication* theApp; // Global ref. to the application
|
| 62 |
+
|
| 63 |
+
static SLK_Link* slk_stack;
|
| 64 |
+
|
| 65 |
+
protected:
|
| 66 |
+
static NCursesWindow* titleWindow; // The Title Window (if any)
|
| 67 |
+
|
| 68 |
+
bool b_Colors; // Is this a color application?
|
| 69 |
+
NCursesWindow* Root_Window; // This is the stdscr equiv.
|
| 70 |
+
|
| 71 |
+
// Initialization of attributes;
|
| 72 |
+
// Rewrite this in your derived class if you prefer other settings
|
| 73 |
+
virtual void init(bool bColors);
|
| 74 |
+
|
| 75 |
+
// The number of lines for the title window. Default is no title window
|
| 76 |
+
// You may rewrite this in your derived class
|
| 77 |
+
virtual int titlesize() const {
|
| 78 |
+
return 0;
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
// This method is called to put something into the title window initially
|
| 82 |
+
// You may rewrite this in your derived class
|
| 83 |
+
virtual void title() {
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
// The layout used for the Soft Label Keys. Default is to have no SLKs.
|
| 87 |
+
// You may rewrite this in your derived class
|
| 88 |
+
virtual Soft_Label_Key_Set::Label_Layout useSLKs() const {
|
| 89 |
+
return Soft_Label_Key_Set::None;
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
// This method is called to initialize the SLKs. Default is nothing.
|
| 93 |
+
// You may rewrite this in your derived class
|
| 94 |
+
virtual void init_labels(Soft_Label_Key_Set& S) const {
|
| 95 |
+
(void) S;
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
// Your derived class must implement this method. The return value must
|
| 99 |
+
// be the exit value of your application.
|
| 100 |
+
virtual int run() = 0;
|
| 101 |
+
|
| 102 |
+
// The constructor is protected, so you may use it in your derived
|
| 103 |
+
// class constructor. The argument tells whether or not you want colors.
|
| 104 |
+
NCursesApplication(bool wantColors = FALSE);
|
| 105 |
+
|
| 106 |
+
NCursesApplication& operator=(const NCursesApplication& rhs)
|
| 107 |
+
{
|
| 108 |
+
if (this != &rhs) {
|
| 109 |
+
*this = rhs;
|
| 110 |
+
}
|
| 111 |
+
return *this;
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
NCursesApplication(const NCursesApplication& rhs)
|
| 115 |
+
: b_Colors(rhs.b_Colors),
|
| 116 |
+
Root_Window(rhs.Root_Window)
|
| 117 |
+
{
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
static NCursesWindow *&getTitleWindow();
|
| 121 |
+
|
| 122 |
+
public:
|
| 123 |
+
virtual ~NCursesApplication() THROWS(NCursesException);
|
| 124 |
+
|
| 125 |
+
// Get a pointer to the current application object
|
| 126 |
+
static NCursesApplication* getApplication();
|
| 127 |
+
|
| 128 |
+
// This method runs the application and returns its exit value
|
| 129 |
+
int operator()(void);
|
| 130 |
+
|
| 131 |
+
// Process the commandline arguments. The default implementation simply
|
| 132 |
+
// ignores them. Your derived class may rewrite this.
|
| 133 |
+
virtual void handleArgs(int argc, char* argv[]) {
|
| 134 |
+
(void) argc;
|
| 135 |
+
(void) argv;
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
// Does this application use colors?
|
| 139 |
+
inline bool useColors() const {
|
| 140 |
+
return b_Colors;
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
// Push the Key Set S onto the SLK Stack. S then becomes the current set
|
| 144 |
+
// of Soft Labelled Keys.
|
| 145 |
+
void push(Soft_Label_Key_Set& S);
|
| 146 |
+
|
| 147 |
+
// Throw away the current set of SLKs and make the previous one the
|
| 148 |
+
// new current set.
|
| 149 |
+
bool pop();
|
| 150 |
+
|
| 151 |
+
// Retrieve the current set of Soft Labelled Keys.
|
| 152 |
+
Soft_Label_Key_Set* top() const;
|
| 153 |
+
|
| 154 |
+
// Attributes to use for menu and forms foregrounds
|
| 155 |
+
virtual chtype foregrounds() const {
|
| 156 |
+
return b_Colors ? static_cast<chtype>(COLOR_PAIR(1)) : A_BOLD;
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
// Attributes to use for menu and forms backgrounds
|
| 160 |
+
virtual chtype backgrounds() const {
|
| 161 |
+
return b_Colors ? static_cast<chtype>(COLOR_PAIR(2)) : A_NORMAL;
|
| 162 |
+
}
|
| 163 |
+
|
| 164 |
+
// Attributes to use for inactive (menu) elements
|
| 165 |
+
virtual chtype inactives() const {
|
| 166 |
+
return b_Colors ? static_cast<chtype>(COLOR_PAIR(3)|A_DIM) : A_DIM;
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
// Attributes to use for (form) labels and SLKs
|
| 170 |
+
virtual chtype labels() const {
|
| 171 |
+
return b_Colors ? static_cast<chtype>(COLOR_PAIR(4)) : A_NORMAL;
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
// Attributes to use for form backgrounds
|
| 175 |
+
virtual chtype dialog_backgrounds() const {
|
| 176 |
+
return b_Colors ? static_cast<chtype>(COLOR_PAIR(4)) : A_NORMAL;
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
// Attributes to use as default for (form) window backgrounds
|
| 180 |
+
virtual chtype window_backgrounds() const {
|
| 181 |
+
return b_Colors ? static_cast<chtype>(COLOR_PAIR(5)) : A_NORMAL;
|
| 182 |
+
}
|
| 183 |
+
|
| 184 |
+
// Attributes to use for the title window
|
| 185 |
+
virtual chtype screen_titles() const {
|
| 186 |
+
return b_Colors ? static_cast<chtype>(COLOR_PAIR(6)) : A_BOLD;
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
};
|
| 190 |
+
|
| 191 |
+
#endif /* NCURSES_CURSESAPP_H_incl */
|
llava_next/include/ncurses/cursesf.h
ADDED
|
@@ -0,0 +1,968 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// * This makes emacs happy -*-Mode: C++;-*-
|
| 2 |
+
// vile:cppmode
|
| 3 |
+
/****************************************************************************
|
| 4 |
+
* Copyright 2019-2021,2022 Thomas E. Dickey *
|
| 5 |
+
* Copyright 1998-2012,2014 Free Software Foundation, Inc. *
|
| 6 |
+
* *
|
| 7 |
+
* Permission is hereby granted, free of charge, to any person obtaining a *
|
| 8 |
+
* copy of this software and associated documentation files (the *
|
| 9 |
+
* "Software"), to deal in the Software without restriction, including *
|
| 10 |
+
* without limitation the rights to use, copy, modify, merge, publish, *
|
| 11 |
+
* distribute, distribute with modifications, sublicense, and/or sell *
|
| 12 |
+
* copies of the Software, and to permit persons to whom the Software is *
|
| 13 |
+
* furnished to do so, subject to the following conditions: *
|
| 14 |
+
* *
|
| 15 |
+
* The above copyright notice and this permission notice shall be included *
|
| 16 |
+
* in all copies or substantial portions of the Software. *
|
| 17 |
+
* *
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
|
| 19 |
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
|
| 20 |
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
|
| 21 |
+
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
|
| 22 |
+
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
|
| 23 |
+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
|
| 24 |
+
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
| 25 |
+
* *
|
| 26 |
+
* Except as contained in this notice, the name(s) of the above copyright *
|
| 27 |
+
* holders shall not be used in advertising or otherwise to promote the *
|
| 28 |
+
* sale, use or other dealings in this Software without prior written *
|
| 29 |
+
* authorization. *
|
| 30 |
+
****************************************************************************/
|
| 31 |
+
|
| 32 |
+
/****************************************************************************
|
| 33 |
+
* Author: Juergen Pfeifer, 1997 *
|
| 34 |
+
****************************************************************************/
|
| 35 |
+
|
| 36 |
+
// $Id: cursesf.h,v 1.39 2022/08/20 20:52:15 tom Exp $
|
| 37 |
+
|
| 38 |
+
#ifndef NCURSES_CURSESF_H_incl
|
| 39 |
+
#define NCURSES_CURSESF_H_incl 1
|
| 40 |
+
|
| 41 |
+
#include <ncursesw/cursesp.h>
|
| 42 |
+
|
| 43 |
+
#ifndef __EXT_QNX
|
| 44 |
+
#include <string.h>
|
| 45 |
+
#endif
|
| 46 |
+
|
| 47 |
+
extern "C" {
|
| 48 |
+
# include <ncursesw/form.h>
|
| 49 |
+
}
|
| 50 |
+
//
|
| 51 |
+
// -------------------------------------------------------------------------
|
| 52 |
+
// The abstract base class for builtin and user defined Fieldtypes.
|
| 53 |
+
// -------------------------------------------------------------------------
|
| 54 |
+
//
|
| 55 |
+
class NCURSES_CXX_IMPEXP NCursesFormField; // forward declaration
|
| 56 |
+
|
| 57 |
+
// Class to represent builtin field types as well as C++ written new
|
| 58 |
+
// fieldtypes (see classes UserDefineFieldType...
|
| 59 |
+
class NCURSES_CXX_IMPEXP NCursesFieldType
|
| 60 |
+
{
|
| 61 |
+
friend class NCursesFormField;
|
| 62 |
+
|
| 63 |
+
protected:
|
| 64 |
+
FIELDTYPE* fieldtype;
|
| 65 |
+
|
| 66 |
+
inline void OnError(int err) const THROW2(NCursesException const, NCursesFormException) {
|
| 67 |
+
if (err!=E_OK)
|
| 68 |
+
THROW(new NCursesFormException (err));
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
NCursesFieldType(FIELDTYPE *f) : fieldtype(f) {
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
virtual ~NCursesFieldType() {}
|
| 75 |
+
|
| 76 |
+
// Set the fields f fieldtype to this one.
|
| 77 |
+
virtual void set(NCursesFormField& f) = 0;
|
| 78 |
+
|
| 79 |
+
public:
|
| 80 |
+
NCursesFieldType()
|
| 81 |
+
: fieldtype(STATIC_CAST(FIELDTYPE*)(0))
|
| 82 |
+
{
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
NCursesFieldType& operator=(const NCursesFieldType& rhs)
|
| 86 |
+
{
|
| 87 |
+
if (this != &rhs) {
|
| 88 |
+
*this = rhs;
|
| 89 |
+
}
|
| 90 |
+
return *this;
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
NCursesFieldType(const NCursesFieldType& rhs)
|
| 94 |
+
: fieldtype(rhs.fieldtype)
|
| 95 |
+
{
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
};
|
| 99 |
+
|
| 100 |
+
//
|
| 101 |
+
// -------------------------------------------------------------------------
|
| 102 |
+
// The class representing a forms field, wrapping the lowlevel FIELD struct
|
| 103 |
+
// -------------------------------------------------------------------------
|
| 104 |
+
//
|
| 105 |
+
class NCURSES_CXX_IMPEXP NCursesFormField
|
| 106 |
+
{
|
| 107 |
+
friend class NCursesForm;
|
| 108 |
+
|
| 109 |
+
protected:
|
| 110 |
+
FIELD *field; // lowlevel structure
|
| 111 |
+
NCursesFieldType* ftype; // Associated field type
|
| 112 |
+
|
| 113 |
+
// Error handler
|
| 114 |
+
inline void OnError (int err) const THROW2(NCursesException const, NCursesFormException) {
|
| 115 |
+
if (err != E_OK)
|
| 116 |
+
THROW(new NCursesFormException (err));
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
public:
|
| 120 |
+
// Create a 'Null' field. Can be used to delimit a field list
|
| 121 |
+
NCursesFormField()
|
| 122 |
+
: field(STATIC_CAST(FIELD*)(0)),
|
| 123 |
+
ftype(STATIC_CAST(NCursesFieldType*)(0))
|
| 124 |
+
{
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
// Create a new field
|
| 128 |
+
NCursesFormField (int rows,
|
| 129 |
+
int ncols,
|
| 130 |
+
int first_row = 0,
|
| 131 |
+
int first_col = 0,
|
| 132 |
+
int offscreen_rows = 0,
|
| 133 |
+
int additional_buffers = 0)
|
| 134 |
+
: field(0),
|
| 135 |
+
ftype(STATIC_CAST(NCursesFieldType*)(0))
|
| 136 |
+
{
|
| 137 |
+
field = ::new_field(rows, ncols, first_row, first_col,
|
| 138 |
+
offscreen_rows, additional_buffers);
|
| 139 |
+
if (!field)
|
| 140 |
+
OnError(errno);
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
NCursesFormField& operator=(const NCursesFormField& rhs)
|
| 144 |
+
{
|
| 145 |
+
if (this != &rhs) {
|
| 146 |
+
*this = rhs;
|
| 147 |
+
}
|
| 148 |
+
return *this;
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
NCursesFormField(const NCursesFormField& rhs)
|
| 152 |
+
: field(rhs.field), ftype(rhs.ftype)
|
| 153 |
+
{
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
virtual ~NCursesFormField () THROWS(NCursesException);
|
| 157 |
+
|
| 158 |
+
// Duplicate the field at a new position
|
| 159 |
+
inline NCursesFormField* dup(int first_row, int first_col)
|
| 160 |
+
{
|
| 161 |
+
NCursesFormField* f = new NCursesFormField();
|
| 162 |
+
if (!f)
|
| 163 |
+
OnError(E_SYSTEM_ERROR);
|
| 164 |
+
else {
|
| 165 |
+
f->ftype = ftype;
|
| 166 |
+
f->field = ::dup_field(field,first_row,first_col);
|
| 167 |
+
if (!f->field)
|
| 168 |
+
OnError(errno);
|
| 169 |
+
}
|
| 170 |
+
return f;
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
// Link the field to a new location
|
| 174 |
+
inline NCursesFormField* link(int first_row, int first_col) {
|
| 175 |
+
NCursesFormField* f = new NCursesFormField();
|
| 176 |
+
if (!f)
|
| 177 |
+
OnError(E_SYSTEM_ERROR);
|
| 178 |
+
else {
|
| 179 |
+
f->ftype = ftype;
|
| 180 |
+
f->field = ::link_field(field,first_row,first_col);
|
| 181 |
+
if (!f->field)
|
| 182 |
+
OnError(errno);
|
| 183 |
+
}
|
| 184 |
+
return f;
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
// Get the lowlevel field representation
|
| 188 |
+
inline FIELD* get_field() const {
|
| 189 |
+
return field;
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
// Retrieve info about the field
|
| 193 |
+
inline void info(int& rows, int& ncols,
|
| 194 |
+
int& first_row, int& first_col,
|
| 195 |
+
int& offscreen_rows, int& additional_buffers) const {
|
| 196 |
+
OnError(::field_info(field, &rows, &ncols,
|
| 197 |
+
&first_row, &first_col,
|
| 198 |
+
&offscreen_rows, &additional_buffers));
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
// Retrieve info about the fields dynamic properties.
|
| 202 |
+
inline void dynamic_info(int& dynamic_rows, int& dynamic_cols,
|
| 203 |
+
int& max_growth) const {
|
| 204 |
+
OnError(::dynamic_field_info(field, &dynamic_rows, &dynamic_cols,
|
| 205 |
+
&max_growth));
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
// For a dynamic field you may set the maximum growth limit.
|
| 209 |
+
// A zero means unlimited growth.
|
| 210 |
+
inline void set_maximum_growth(int growth = 0) {
|
| 211 |
+
OnError(::set_max_field(field,growth));
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
// Move the field to a new position
|
| 215 |
+
inline void move(int row, int col) {
|
| 216 |
+
OnError(::move_field(field,row,col));
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
// Mark the field to start a new page
|
| 220 |
+
inline void new_page(bool pageFlag = FALSE) {
|
| 221 |
+
OnError(::set_new_page(field,pageFlag));
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
// Retrieve whether or not the field starts a new page.
|
| 225 |
+
inline bool is_new_page() const {
|
| 226 |
+
return ::new_page(field);
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
// Set the justification for the field
|
| 230 |
+
inline void set_justification(int just) {
|
| 231 |
+
OnError(::set_field_just(field,just));
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
// Retrieve the fields justification
|
| 235 |
+
inline int justification() const {
|
| 236 |
+
return ::field_just(field);
|
| 237 |
+
}
|
| 238 |
+
// Set the foreground attribute for the field
|
| 239 |
+
inline void set_foreground(chtype foreground) {
|
| 240 |
+
OnError(::set_field_fore(field,foreground));
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
// Retrieve the fields foreground attribute
|
| 244 |
+
inline chtype fore() const {
|
| 245 |
+
return ::field_fore(field);
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
// Set the background attribute for the field
|
| 249 |
+
inline void set_background(chtype background) {
|
| 250 |
+
OnError(::set_field_back(field,background));
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
// Retrieve the fields background attribute
|
| 254 |
+
inline chtype back() const {
|
| 255 |
+
return ::field_back(field);
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
// Set the padding character for the field
|
| 259 |
+
inline void set_pad_character(int padding) {
|
| 260 |
+
OnError(::set_field_pad(field, padding));
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
// Retrieve the fields padding character
|
| 264 |
+
inline int pad() const {
|
| 265 |
+
return ::field_pad(field);
|
| 266 |
+
}
|
| 267 |
+
|
| 268 |
+
// Switch on the fields options
|
| 269 |
+
inline void options_on (Field_Options opts) {
|
| 270 |
+
OnError (::field_opts_on (field, opts));
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
+
// Switch off the fields options
|
| 274 |
+
inline void options_off (Field_Options opts) {
|
| 275 |
+
OnError (::field_opts_off (field, opts));
|
| 276 |
+
}
|
| 277 |
+
|
| 278 |
+
// Retrieve the fields options
|
| 279 |
+
inline Field_Options options () const {
|
| 280 |
+
return ::field_opts (field);
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
// Set the fields options
|
| 284 |
+
inline void set_options (Field_Options opts) {
|
| 285 |
+
OnError (::set_field_opts (field, opts));
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
// Mark the field as changed
|
| 289 |
+
inline void set_changed(bool changeFlag = TRUE) {
|
| 290 |
+
OnError(::set_field_status(field,changeFlag));
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
// Test whether or not the field is marked as changed
|
| 294 |
+
inline bool changed() const {
|
| 295 |
+
return ::field_status(field);
|
| 296 |
+
}
|
| 297 |
+
|
| 298 |
+
// Return the index of the field in the field array of a form
|
| 299 |
+
// or -1 if the field is not associated to a form
|
| 300 |
+
inline int (index)() const {
|
| 301 |
+
return ::field_index(field);
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
+
// Store a value in a fields buffer. The default buffer is nr. 0
|
| 305 |
+
inline void set_value(const char *val, int buffer = 0) {
|
| 306 |
+
OnError(::set_field_buffer(field,buffer,val));
|
| 307 |
+
}
|
| 308 |
+
|
| 309 |
+
// Retrieve the value of a fields buffer. The default buffer is nr. 0
|
| 310 |
+
inline char* value(int buffer = 0) const {
|
| 311 |
+
return ::field_buffer(field,buffer);
|
| 312 |
+
}
|
| 313 |
+
|
| 314 |
+
// Set the validation type of the field.
|
| 315 |
+
inline void set_fieldtype(NCursesFieldType& f) {
|
| 316 |
+
ftype = &f;
|
| 317 |
+
f.set(*this); // A good friend may do that...
|
| 318 |
+
}
|
| 319 |
+
|
| 320 |
+
// Retrieve the validation type of the field.
|
| 321 |
+
inline NCursesFieldType* fieldtype() const {
|
| 322 |
+
return ftype;
|
| 323 |
+
}
|
| 324 |
+
|
| 325 |
+
};
|
| 326 |
+
|
| 327 |
+
// This are the built-in hook functions in this C++ binding. In C++ we use
|
| 328 |
+
// virtual member functions (see below On_..._Init and On_..._Termination)
|
| 329 |
+
// to provide this functionality in an object oriented manner.
|
| 330 |
+
extern "C" {
|
| 331 |
+
void _nc_xx_frm_init(FORM *);
|
| 332 |
+
void _nc_xx_frm_term(FORM *);
|
| 333 |
+
void _nc_xx_fld_init(FORM *);
|
| 334 |
+
void _nc_xx_fld_term(FORM *);
|
| 335 |
+
}
|
| 336 |
+
|
| 337 |
+
//
|
| 338 |
+
// -------------------------------------------------------------------------
|
| 339 |
+
// The class representing a form, wrapping the lowlevel FORM struct
|
| 340 |
+
// -------------------------------------------------------------------------
|
| 341 |
+
//
|
| 342 |
+
class NCURSES_CXX_IMPEXP NCursesForm : public NCursesPanel
|
| 343 |
+
{
|
| 344 |
+
protected:
|
| 345 |
+
FORM* form; // the lowlevel structure
|
| 346 |
+
|
| 347 |
+
private:
|
| 348 |
+
NCursesWindow* sub; // the subwindow object
|
| 349 |
+
bool b_sub_owner; // is this our own subwindow?
|
| 350 |
+
bool b_framed; // has the form a border?
|
| 351 |
+
bool b_autoDelete; // Delete fields when deleting form?
|
| 352 |
+
|
| 353 |
+
NCursesFormField** my_fields; // The array of fields for this form
|
| 354 |
+
|
| 355 |
+
// This structure is used for the form's user data field to link the
|
| 356 |
+
// FORM* to the C++ object and to provide extra space for a user pointer.
|
| 357 |
+
typedef struct {
|
| 358 |
+
void* m_user; // the pointer for the user's data
|
| 359 |
+
const NCursesForm* m_back; // backward pointer to C++ object
|
| 360 |
+
const FORM* m_owner;
|
| 361 |
+
} UserHook;
|
| 362 |
+
|
| 363 |
+
// Get the backward pointer to the C++ object from a FORM
|
| 364 |
+
static inline NCursesForm* getHook(const FORM *f) {
|
| 365 |
+
UserHook* hook = reinterpret_cast<UserHook*>(::form_userptr(f));
|
| 366 |
+
assert(hook != 0 && hook->m_owner==f);
|
| 367 |
+
return const_cast<NCursesForm*>(hook->m_back);
|
| 368 |
+
}
|
| 369 |
+
|
| 370 |
+
friend void _nc_xx_frm_init(FORM *);
|
| 371 |
+
friend void _nc_xx_frm_term(FORM *);
|
| 372 |
+
friend void _nc_xx_fld_init(FORM *);
|
| 373 |
+
friend void _nc_xx_fld_term(FORM *);
|
| 374 |
+
|
| 375 |
+
// Calculate FIELD* array for the menu
|
| 376 |
+
FIELD** mapFields(NCursesFormField* nfields[]);
|
| 377 |
+
|
| 378 |
+
protected:
|
| 379 |
+
// internal routines
|
| 380 |
+
inline void set_user(void *user) {
|
| 381 |
+
UserHook* uptr = reinterpret_cast<UserHook*>(::form_userptr (form));
|
| 382 |
+
assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==form);
|
| 383 |
+
uptr->m_user = user;
|
| 384 |
+
}
|
| 385 |
+
|
| 386 |
+
inline void *get_user() {
|
| 387 |
+
UserHook* uptr = reinterpret_cast<UserHook*>(::form_userptr (form));
|
| 388 |
+
assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==form);
|
| 389 |
+
return uptr->m_user;
|
| 390 |
+
}
|
| 391 |
+
|
| 392 |
+
void InitForm (NCursesFormField* Fields[],
|
| 393 |
+
bool with_frame,
|
| 394 |
+
bool autoDeleteFields);
|
| 395 |
+
|
| 396 |
+
inline void OnError (int err) const THROW2(NCursesException const, NCursesFormException) {
|
| 397 |
+
if (err != E_OK)
|
| 398 |
+
THROW(new NCursesFormException (err));
|
| 399 |
+
}
|
| 400 |
+
|
| 401 |
+
// this wraps the form_driver call.
|
| 402 |
+
virtual int driver (int c) ;
|
| 403 |
+
|
| 404 |
+
// 'Internal' constructor, builds an object without association to a
|
| 405 |
+
// field array.
|
| 406 |
+
NCursesForm( int nlines,
|
| 407 |
+
int ncols,
|
| 408 |
+
int begin_y = 0,
|
| 409 |
+
int begin_x = 0)
|
| 410 |
+
: NCursesPanel(nlines, ncols, begin_y, begin_x),
|
| 411 |
+
form (STATIC_CAST(FORM*)(0)),
|
| 412 |
+
sub(0),
|
| 413 |
+
b_sub_owner(0),
|
| 414 |
+
b_framed(0),
|
| 415 |
+
b_autoDelete(0),
|
| 416 |
+
my_fields(0)
|
| 417 |
+
{
|
| 418 |
+
}
|
| 419 |
+
|
| 420 |
+
public:
|
| 421 |
+
// Create form for the default panel.
|
| 422 |
+
NCursesForm (NCursesFormField* Fields[],
|
| 423 |
+
bool with_frame=FALSE, // reserve space for a frame?
|
| 424 |
+
bool autoDelete_Fields=FALSE) // do automatic cleanup?
|
| 425 |
+
: NCursesPanel(),
|
| 426 |
+
form(0),
|
| 427 |
+
sub(0),
|
| 428 |
+
b_sub_owner(0),
|
| 429 |
+
b_framed(0),
|
| 430 |
+
b_autoDelete(0),
|
| 431 |
+
my_fields(0)
|
| 432 |
+
{
|
| 433 |
+
InitForm(Fields, with_frame, autoDelete_Fields);
|
| 434 |
+
}
|
| 435 |
+
|
| 436 |
+
// Create a form in a panel with the given position and size.
|
| 437 |
+
NCursesForm (NCursesFormField* Fields[],
|
| 438 |
+
int nlines,
|
| 439 |
+
int ncols,
|
| 440 |
+
int begin_y,
|
| 441 |
+
int begin_x,
|
| 442 |
+
bool with_frame=FALSE, // reserve space for a frame?
|
| 443 |
+
bool autoDelete_Fields=FALSE) // do automatic cleanup?
|
| 444 |
+
: NCursesPanel(nlines, ncols, begin_y, begin_x),
|
| 445 |
+
form(0),
|
| 446 |
+
sub(0),
|
| 447 |
+
b_sub_owner(0),
|
| 448 |
+
b_framed(0),
|
| 449 |
+
b_autoDelete(0),
|
| 450 |
+
my_fields(0)
|
| 451 |
+
{
|
| 452 |
+
InitForm(Fields, with_frame, autoDelete_Fields);
|
| 453 |
+
}
|
| 454 |
+
|
| 455 |
+
NCursesForm& operator=(const NCursesForm& rhs)
|
| 456 |
+
{
|
| 457 |
+
if (this != &rhs) {
|
| 458 |
+
*this = rhs;
|
| 459 |
+
NCursesPanel::operator=(rhs);
|
| 460 |
+
}
|
| 461 |
+
return *this;
|
| 462 |
+
}
|
| 463 |
+
|
| 464 |
+
NCursesForm(const NCursesForm& rhs)
|
| 465 |
+
: NCursesPanel(rhs),
|
| 466 |
+
form(rhs.form),
|
| 467 |
+
sub(rhs.sub),
|
| 468 |
+
b_sub_owner(rhs.b_sub_owner),
|
| 469 |
+
b_framed(rhs.b_framed),
|
| 470 |
+
b_autoDelete(rhs.b_autoDelete),
|
| 471 |
+
my_fields(rhs.my_fields)
|
| 472 |
+
{
|
| 473 |
+
}
|
| 474 |
+
|
| 475 |
+
virtual ~NCursesForm() THROWS(NCursesException);
|
| 476 |
+
|
| 477 |
+
// Set the default attributes for the form
|
| 478 |
+
virtual void setDefaultAttributes();
|
| 479 |
+
|
| 480 |
+
// Retrieve current field of the form.
|
| 481 |
+
inline NCursesFormField* current_field() const {
|
| 482 |
+
return my_fields[::field_index(::current_field(form))];
|
| 483 |
+
}
|
| 484 |
+
|
| 485 |
+
// Set the forms subwindow
|
| 486 |
+
void setSubWindow(NCursesWindow& sub);
|
| 487 |
+
|
| 488 |
+
// Set these fields for the form
|
| 489 |
+
inline void setFields(NCursesFormField* Fields[]) {
|
| 490 |
+
OnError(::set_form_fields(form,mapFields(Fields)));
|
| 491 |
+
}
|
| 492 |
+
|
| 493 |
+
// Remove the form from the screen
|
| 494 |
+
inline void unpost (void) {
|
| 495 |
+
OnError (::unpost_form (form));
|
| 496 |
+
}
|
| 497 |
+
|
| 498 |
+
// Post the form to the screen if flag is true, unpost it otherwise
|
| 499 |
+
inline void post(bool flag = TRUE) {
|
| 500 |
+
OnError (flag ? ::post_form(form) : ::unpost_form (form));
|
| 501 |
+
}
|
| 502 |
+
|
| 503 |
+
// Decorations
|
| 504 |
+
inline void frame(const char *title=NULL, const char* btitle=NULL) NCURSES_OVERRIDE {
|
| 505 |
+
if (b_framed)
|
| 506 |
+
NCursesPanel::frame(title,btitle);
|
| 507 |
+
else
|
| 508 |
+
OnError(E_SYSTEM_ERROR);
|
| 509 |
+
}
|
| 510 |
+
|
| 511 |
+
inline void boldframe(const char *title=NULL, const char* btitle=NULL) NCURSES_OVERRIDE {
|
| 512 |
+
if (b_framed)
|
| 513 |
+
NCursesPanel::boldframe(title,btitle);
|
| 514 |
+
else
|
| 515 |
+
OnError(E_SYSTEM_ERROR);
|
| 516 |
+
}
|
| 517 |
+
|
| 518 |
+
inline void label(const char *topLabel, const char *bottomLabel) NCURSES_OVERRIDE {
|
| 519 |
+
if (b_framed)
|
| 520 |
+
NCursesPanel::label(topLabel,bottomLabel);
|
| 521 |
+
else
|
| 522 |
+
OnError(E_SYSTEM_ERROR);
|
| 523 |
+
}
|
| 524 |
+
|
| 525 |
+
// -----
|
| 526 |
+
// Hooks
|
| 527 |
+
// -----
|
| 528 |
+
|
| 529 |
+
// Called after the form gets repositioned in its window.
|
| 530 |
+
// This is especially true if the form is posted.
|
| 531 |
+
virtual void On_Form_Init();
|
| 532 |
+
|
| 533 |
+
// Called before the form gets repositioned in its window.
|
| 534 |
+
// This is especially true if the form is unposted.
|
| 535 |
+
virtual void On_Form_Termination();
|
| 536 |
+
|
| 537 |
+
// Called after the field became the current field
|
| 538 |
+
virtual void On_Field_Init(NCursesFormField& field);
|
| 539 |
+
|
| 540 |
+
// Called before this field is left as current field.
|
| 541 |
+
virtual void On_Field_Termination(NCursesFormField& field);
|
| 542 |
+
|
| 543 |
+
// Calculate required window size for the form.
|
| 544 |
+
void scale(int& rows, int& ncols) const {
|
| 545 |
+
OnError(::scale_form(form,&rows,&ncols));
|
| 546 |
+
}
|
| 547 |
+
|
| 548 |
+
// Retrieve number of fields in the form.
|
| 549 |
+
int count() const {
|
| 550 |
+
return ::field_count(form);
|
| 551 |
+
}
|
| 552 |
+
|
| 553 |
+
// Make the page the current page of the form.
|
| 554 |
+
void set_page(int pageNum) {
|
| 555 |
+
OnError(::set_form_page(form, pageNum));
|
| 556 |
+
}
|
| 557 |
+
|
| 558 |
+
// Retrieve current page number
|
| 559 |
+
int page() const {
|
| 560 |
+
return ::form_page(form);
|
| 561 |
+
}
|
| 562 |
+
|
| 563 |
+
// Switch on the forms options
|
| 564 |
+
inline void options_on (Form_Options opts) {
|
| 565 |
+
OnError (::form_opts_on (form, opts));
|
| 566 |
+
}
|
| 567 |
+
|
| 568 |
+
// Switch off the forms options
|
| 569 |
+
inline void options_off (Form_Options opts) {
|
| 570 |
+
OnError (::form_opts_off (form, opts));
|
| 571 |
+
}
|
| 572 |
+
|
| 573 |
+
// Retrieve the forms options
|
| 574 |
+
inline Form_Options options () const {
|
| 575 |
+
return ::form_opts (form);
|
| 576 |
+
}
|
| 577 |
+
|
| 578 |
+
// Set the forms options
|
| 579 |
+
inline void set_options (Form_Options opts) {
|
| 580 |
+
OnError (::set_form_opts (form, opts));
|
| 581 |
+
}
|
| 582 |
+
|
| 583 |
+
// Are there more data in the current field after the data shown
|
| 584 |
+
inline bool data_ahead() const {
|
| 585 |
+
return ::data_ahead(form);
|
| 586 |
+
}
|
| 587 |
+
|
| 588 |
+
// Are there more data in the current field before the data shown
|
| 589 |
+
inline bool data_behind() const {
|
| 590 |
+
return ::data_behind(form);
|
| 591 |
+
}
|
| 592 |
+
|
| 593 |
+
// Position the cursor to the current field
|
| 594 |
+
inline void position_cursor () {
|
| 595 |
+
OnError (::pos_form_cursor (form));
|
| 596 |
+
}
|
| 597 |
+
// Set the current field
|
| 598 |
+
inline void set_current(NCursesFormField& F) {
|
| 599 |
+
OnError (::set_current_field(form, F.field));
|
| 600 |
+
}
|
| 601 |
+
|
| 602 |
+
// Provide a default key virtualization. Translate the keyboard
|
| 603 |
+
// code c into a form request code.
|
| 604 |
+
// The default implementation provides a hopefully straightforward
|
| 605 |
+
// mapping for the most common keystrokes and form requests.
|
| 606 |
+
virtual int virtualize(int c);
|
| 607 |
+
|
| 608 |
+
// Operators
|
| 609 |
+
inline NCursesFormField* operator[](int i) const {
|
| 610 |
+
if ( (i < 0) || (i >= ::field_count (form)) )
|
| 611 |
+
OnError (E_BAD_ARGUMENT);
|
| 612 |
+
return my_fields[i];
|
| 613 |
+
}
|
| 614 |
+
|
| 615 |
+
// Perform the menu's operation
|
| 616 |
+
// Return the field where you left the form.
|
| 617 |
+
virtual NCursesFormField* operator()(void);
|
| 618 |
+
|
| 619 |
+
// Exception handlers. The default is a Beep.
|
| 620 |
+
virtual void On_Request_Denied(int c) const;
|
| 621 |
+
virtual void On_Invalid_Field(int c) const;
|
| 622 |
+
virtual void On_Unknown_Command(int c) const;
|
| 623 |
+
|
| 624 |
+
};
|
| 625 |
+
|
| 626 |
+
//
|
| 627 |
+
// -------------------------------------------------------------------------
|
| 628 |
+
// This is the typical C++ typesafe way to allow to attach
|
| 629 |
+
// user data to a field of a form. Its assumed that the user
|
| 630 |
+
// data belongs to some class T. Use T as template argument
|
| 631 |
+
// to create a UserField.
|
| 632 |
+
// -------------------------------------------------------------------------
|
| 633 |
+
template<class T> class NCURSES_CXX_IMPEXP NCursesUserField : public NCursesFormField
|
| 634 |
+
{
|
| 635 |
+
public:
|
| 636 |
+
NCursesUserField (int rows,
|
| 637 |
+
int ncols,
|
| 638 |
+
int first_row = 0,
|
| 639 |
+
int first_col = 0,
|
| 640 |
+
const T* p_UserData = STATIC_CAST(T*)(0),
|
| 641 |
+
int offscreen_rows = 0,
|
| 642 |
+
int additional_buffers = 0)
|
| 643 |
+
: NCursesFormField (rows, ncols,
|
| 644 |
+
first_row, first_col,
|
| 645 |
+
offscreen_rows, additional_buffers) {
|
| 646 |
+
if (field)
|
| 647 |
+
OnError(::set_field_userptr(field, STATIC_CAST(void *)(p_UserData)));
|
| 648 |
+
}
|
| 649 |
+
|
| 650 |
+
virtual ~NCursesUserField() THROWS(NCursesException) {};
|
| 651 |
+
|
| 652 |
+
inline const T* UserData (void) const {
|
| 653 |
+
return reinterpret_cast<const T*>(::field_userptr (field));
|
| 654 |
+
}
|
| 655 |
+
|
| 656 |
+
inline virtual void setUserData(const T* p_UserData) {
|
| 657 |
+
if (field)
|
| 658 |
+
OnError (::set_field_userptr (field, STATIC_CAST(void *)(p_UserData)));
|
| 659 |
+
}
|
| 660 |
+
};
|
| 661 |
+
//
|
| 662 |
+
// -------------------------------------------------------------------------
|
| 663 |
+
// The same mechanism is used to attach user data to a form
|
| 664 |
+
// -------------------------------------------------------------------------
|
| 665 |
+
//
|
| 666 |
+
template<class T> class NCURSES_CXX_IMPEXP NCursesUserForm : public NCursesForm
|
| 667 |
+
{
|
| 668 |
+
protected:
|
| 669 |
+
// 'Internal' constructor, builds an object without association to a
|
| 670 |
+
// field array.
|
| 671 |
+
NCursesUserForm( int nlines,
|
| 672 |
+
int ncols,
|
| 673 |
+
int begin_y = 0,
|
| 674 |
+
int begin_x = 0,
|
| 675 |
+
const T* p_UserData = STATIC_CAST(T*)(0))
|
| 676 |
+
: NCursesForm(nlines,ncols,begin_y,begin_x) {
|
| 677 |
+
if (form)
|
| 678 |
+
set_user (const_cast<void *>(reinterpret_cast<const void*>
|
| 679 |
+
(p_UserData)));
|
| 680 |
+
}
|
| 681 |
+
|
| 682 |
+
public:
|
| 683 |
+
NCursesUserForm (NCursesFormField* Fields[],
|
| 684 |
+
const T* p_UserData = STATIC_CAST(T*)(0),
|
| 685 |
+
bool with_frame=FALSE,
|
| 686 |
+
bool autoDelete_Fields=FALSE)
|
| 687 |
+
: NCursesForm (&Fields, with_frame, autoDelete_Fields) {
|
| 688 |
+
if (form)
|
| 689 |
+
set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
|
| 690 |
+
};
|
| 691 |
+
|
| 692 |
+
NCursesUserForm (NCursesFormField* Fields[],
|
| 693 |
+
int nlines,
|
| 694 |
+
int ncols,
|
| 695 |
+
int begin_y = 0,
|
| 696 |
+
int begin_x = 0,
|
| 697 |
+
const T* p_UserData = STATIC_CAST(T*)(0),
|
| 698 |
+
bool with_frame=FALSE,
|
| 699 |
+
bool autoDelete_Fields=FALSE)
|
| 700 |
+
: NCursesForm (&Fields, nlines, ncols, begin_y, begin_x,
|
| 701 |
+
with_frame, autoDelete_Fields) {
|
| 702 |
+
if (form)
|
| 703 |
+
set_user (const_cast<void *>(reinterpret_cast<const void*>
|
| 704 |
+
(p_UserData)));
|
| 705 |
+
};
|
| 706 |
+
|
| 707 |
+
virtual ~NCursesUserForm() THROWS(NCursesException) {
|
| 708 |
+
};
|
| 709 |
+
|
| 710 |
+
inline T* UserData (void) {
|
| 711 |
+
return reinterpret_cast<T*>(get_user ());
|
| 712 |
+
};
|
| 713 |
+
|
| 714 |
+
inline virtual void setUserData (const T* p_UserData) {
|
| 715 |
+
if (form)
|
| 716 |
+
set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
|
| 717 |
+
}
|
| 718 |
+
|
| 719 |
+
};
|
| 720 |
+
//
|
| 721 |
+
// -------------------------------------------------------------------------
|
| 722 |
+
// Builtin Fieldtypes
|
| 723 |
+
// -------------------------------------------------------------------------
|
| 724 |
+
//
|
| 725 |
+
class NCURSES_CXX_IMPEXP Alpha_Field : public NCursesFieldType
|
| 726 |
+
{
|
| 727 |
+
private:
|
| 728 |
+
int min_field_width;
|
| 729 |
+
|
| 730 |
+
void set(NCursesFormField& f) NCURSES_OVERRIDE {
|
| 731 |
+
OnError(::set_field_type(f.get_field(),fieldtype,min_field_width));
|
| 732 |
+
}
|
| 733 |
+
|
| 734 |
+
public:
|
| 735 |
+
explicit Alpha_Field(int width)
|
| 736 |
+
: NCursesFieldType(TYPE_ALPHA),
|
| 737 |
+
min_field_width(width) {
|
| 738 |
+
}
|
| 739 |
+
};
|
| 740 |
+
|
| 741 |
+
class NCURSES_CXX_IMPEXP Alphanumeric_Field : public NCursesFieldType
|
| 742 |
+
{
|
| 743 |
+
private:
|
| 744 |
+
int min_field_width;
|
| 745 |
+
|
| 746 |
+
void set(NCursesFormField& f) NCURSES_OVERRIDE {
|
| 747 |
+
OnError(::set_field_type(f.get_field(),fieldtype,min_field_width));
|
| 748 |
+
}
|
| 749 |
+
|
| 750 |
+
public:
|
| 751 |
+
explicit Alphanumeric_Field(int width)
|
| 752 |
+
: NCursesFieldType(TYPE_ALNUM),
|
| 753 |
+
min_field_width(width) {
|
| 754 |
+
}
|
| 755 |
+
};
|
| 756 |
+
|
| 757 |
+
class NCURSES_CXX_IMPEXP Integer_Field : public NCursesFieldType
|
| 758 |
+
{
|
| 759 |
+
private:
|
| 760 |
+
int precision;
|
| 761 |
+
long lower_limit, upper_limit;
|
| 762 |
+
|
| 763 |
+
void set(NCursesFormField& f) NCURSES_OVERRIDE {
|
| 764 |
+
OnError(::set_field_type(f.get_field(),fieldtype,
|
| 765 |
+
precision,lower_limit,upper_limit));
|
| 766 |
+
}
|
| 767 |
+
|
| 768 |
+
public:
|
| 769 |
+
Integer_Field(int prec, long low=0L, long high=0L)
|
| 770 |
+
: NCursesFieldType(TYPE_INTEGER),
|
| 771 |
+
precision(prec), lower_limit(low), upper_limit(high) {
|
| 772 |
+
}
|
| 773 |
+
};
|
| 774 |
+
|
| 775 |
+
class NCURSES_CXX_IMPEXP Numeric_Field : public NCursesFieldType
|
| 776 |
+
{
|
| 777 |
+
private:
|
| 778 |
+
int precision;
|
| 779 |
+
double lower_limit, upper_limit;
|
| 780 |
+
|
| 781 |
+
void set(NCursesFormField& f) NCURSES_OVERRIDE {
|
| 782 |
+
OnError(::set_field_type(f.get_field(),fieldtype,
|
| 783 |
+
precision,lower_limit,upper_limit));
|
| 784 |
+
}
|
| 785 |
+
|
| 786 |
+
public:
|
| 787 |
+
Numeric_Field(int prec, double low=0.0, double high=0.0)
|
| 788 |
+
: NCursesFieldType(TYPE_NUMERIC),
|
| 789 |
+
precision(prec), lower_limit(low), upper_limit(high) {
|
| 790 |
+
}
|
| 791 |
+
};
|
| 792 |
+
|
| 793 |
+
class NCURSES_CXX_IMPEXP Regular_Expression_Field : public NCursesFieldType
|
| 794 |
+
{
|
| 795 |
+
private:
|
| 796 |
+
char* regex;
|
| 797 |
+
|
| 798 |
+
void set(NCursesFormField& f) NCURSES_OVERRIDE {
|
| 799 |
+
OnError(::set_field_type(f.get_field(),fieldtype,regex));
|
| 800 |
+
}
|
| 801 |
+
|
| 802 |
+
void copy_regex(const char *source)
|
| 803 |
+
{
|
| 804 |
+
regex = new char[1 + ::strlen(source)];
|
| 805 |
+
(::strcpy)(regex, source);
|
| 806 |
+
}
|
| 807 |
+
|
| 808 |
+
public:
|
| 809 |
+
explicit Regular_Expression_Field(const char *expr)
|
| 810 |
+
: NCursesFieldType(TYPE_REGEXP),
|
| 811 |
+
regex(NULL)
|
| 812 |
+
{
|
| 813 |
+
copy_regex(expr);
|
| 814 |
+
}
|
| 815 |
+
|
| 816 |
+
Regular_Expression_Field& operator=(const Regular_Expression_Field& rhs)
|
| 817 |
+
{
|
| 818 |
+
if (this != &rhs) {
|
| 819 |
+
*this = rhs;
|
| 820 |
+
copy_regex(rhs.regex);
|
| 821 |
+
NCursesFieldType::operator=(rhs);
|
| 822 |
+
}
|
| 823 |
+
return *this;
|
| 824 |
+
}
|
| 825 |
+
|
| 826 |
+
Regular_Expression_Field(const Regular_Expression_Field& rhs)
|
| 827 |
+
: NCursesFieldType(rhs),
|
| 828 |
+
regex(NULL)
|
| 829 |
+
{
|
| 830 |
+
copy_regex(rhs.regex);
|
| 831 |
+
}
|
| 832 |
+
|
| 833 |
+
~Regular_Expression_Field() {
|
| 834 |
+
delete[] regex;
|
| 835 |
+
}
|
| 836 |
+
};
|
| 837 |
+
|
| 838 |
+
class NCURSES_CXX_IMPEXP Enumeration_Field : public NCursesFieldType
|
| 839 |
+
{
|
| 840 |
+
private:
|
| 841 |
+
const char** list;
|
| 842 |
+
int case_sensitive;
|
| 843 |
+
int non_unique_matches;
|
| 844 |
+
|
| 845 |
+
void set(NCursesFormField& f) NCURSES_OVERRIDE {
|
| 846 |
+
OnError(::set_field_type(f.get_field(),fieldtype,
|
| 847 |
+
list,case_sensitive,non_unique_matches));
|
| 848 |
+
}
|
| 849 |
+
public:
|
| 850 |
+
Enumeration_Field(const char* enums[],
|
| 851 |
+
bool case_sens=FALSE,
|
| 852 |
+
bool non_unique=FALSE)
|
| 853 |
+
: NCursesFieldType(TYPE_ENUM),
|
| 854 |
+
list(enums),
|
| 855 |
+
case_sensitive(case_sens ? -1 : 0),
|
| 856 |
+
non_unique_matches(non_unique ? -1 : 0) {
|
| 857 |
+
}
|
| 858 |
+
|
| 859 |
+
Enumeration_Field& operator=(const Enumeration_Field& rhs)
|
| 860 |
+
{
|
| 861 |
+
if (this != &rhs) {
|
| 862 |
+
*this = rhs;
|
| 863 |
+
NCursesFieldType::operator=(rhs);
|
| 864 |
+
}
|
| 865 |
+
return *this;
|
| 866 |
+
}
|
| 867 |
+
|
| 868 |
+
Enumeration_Field(const Enumeration_Field& rhs)
|
| 869 |
+
: NCursesFieldType(rhs),
|
| 870 |
+
list(rhs.list),
|
| 871 |
+
case_sensitive(rhs.case_sensitive),
|
| 872 |
+
non_unique_matches(rhs.non_unique_matches)
|
| 873 |
+
{
|
| 874 |
+
}
|
| 875 |
+
};
|
| 876 |
+
|
| 877 |
+
class NCURSES_CXX_IMPEXP IPV4_Address_Field : public NCursesFieldType
|
| 878 |
+
{
|
| 879 |
+
private:
|
| 880 |
+
void set(NCursesFormField& f) NCURSES_OVERRIDE {
|
| 881 |
+
OnError(::set_field_type(f.get_field(),fieldtype));
|
| 882 |
+
}
|
| 883 |
+
|
| 884 |
+
public:
|
| 885 |
+
IPV4_Address_Field() : NCursesFieldType(TYPE_IPV4) {
|
| 886 |
+
}
|
| 887 |
+
};
|
| 888 |
+
|
| 889 |
+
extern "C" {
|
| 890 |
+
bool _nc_xx_fld_fcheck(FIELD *, const void*);
|
| 891 |
+
bool _nc_xx_fld_ccheck(int c, const void *);
|
| 892 |
+
void* _nc_xx_fld_makearg(va_list*);
|
| 893 |
+
}
|
| 894 |
+
|
| 895 |
+
//
|
| 896 |
+
// -------------------------------------------------------------------------
|
| 897 |
+
// Abstract base class for User-Defined Fieldtypes
|
| 898 |
+
// -------------------------------------------------------------------------
|
| 899 |
+
//
|
| 900 |
+
class NCURSES_CXX_IMPEXP UserDefinedFieldType : public NCursesFieldType
|
| 901 |
+
{
|
| 902 |
+
friend class UDF_Init; // Internal helper to set up statics
|
| 903 |
+
private:
|
| 904 |
+
// For all C++ defined fieldtypes we need only one generic lowlevel
|
| 905 |
+
// FIELDTYPE* element.
|
| 906 |
+
static FIELDTYPE* generic_fieldtype;
|
| 907 |
+
|
| 908 |
+
protected:
|
| 909 |
+
// This are the functions required by the low level libforms functions
|
| 910 |
+
// to construct a fieldtype.
|
| 911 |
+
friend bool _nc_xx_fld_fcheck(FIELD *, const void*);
|
| 912 |
+
friend bool _nc_xx_fld_ccheck(int c, const void *);
|
| 913 |
+
friend void* _nc_xx_fld_makearg(va_list*);
|
| 914 |
+
|
| 915 |
+
void set(NCursesFormField& f) NCURSES_OVERRIDE {
|
| 916 |
+
OnError(::set_field_type(f.get_field(),fieldtype,&f));
|
| 917 |
+
}
|
| 918 |
+
|
| 919 |
+
protected:
|
| 920 |
+
// Redefine this function to do a field validation. The argument
|
| 921 |
+
// is a reference to the field you should validate.
|
| 922 |
+
virtual bool field_check(NCursesFormField& f) = 0;
|
| 923 |
+
|
| 924 |
+
// Redefine this function to do a character validation. The argument
|
| 925 |
+
// is the character to be validated.
|
| 926 |
+
virtual bool char_check (int c) = 0;
|
| 927 |
+
|
| 928 |
+
public:
|
| 929 |
+
UserDefinedFieldType();
|
| 930 |
+
};
|
| 931 |
+
|
| 932 |
+
extern "C" {
|
| 933 |
+
bool _nc_xx_next_choice(FIELD*, const void *);
|
| 934 |
+
bool _nc_xx_prev_choice(FIELD*, const void *);
|
| 935 |
+
}
|
| 936 |
+
|
| 937 |
+
//
|
| 938 |
+
// -------------------------------------------------------------------------
|
| 939 |
+
// Abstract base class for User-Defined Fieldtypes with Choice functions
|
| 940 |
+
// -------------------------------------------------------------------------
|
| 941 |
+
//
|
| 942 |
+
class NCURSES_CXX_IMPEXP UserDefinedFieldType_With_Choice : public UserDefinedFieldType
|
| 943 |
+
{
|
| 944 |
+
friend class UDF_Init; // Internal helper to set up statics
|
| 945 |
+
private:
|
| 946 |
+
// For all C++ defined fieldtypes with choice functions we need only one
|
| 947 |
+
// generic lowlevel FIELDTYPE* element.
|
| 948 |
+
static FIELDTYPE* generic_fieldtype_with_choice;
|
| 949 |
+
|
| 950 |
+
// This are the functions required by the low level libforms functions
|
| 951 |
+
// to construct a fieldtype with choice functions.
|
| 952 |
+
friend bool _nc_xx_next_choice(FIELD*, const void *);
|
| 953 |
+
friend bool _nc_xx_prev_choice(FIELD*, const void *);
|
| 954 |
+
|
| 955 |
+
protected:
|
| 956 |
+
// Redefine this function to do the retrieval of the next choice value.
|
| 957 |
+
// The argument is a reference to the field tobe examined.
|
| 958 |
+
virtual bool next (NCursesFormField& f) = 0;
|
| 959 |
+
|
| 960 |
+
// Redefine this function to do the retrieval of the previous choice value.
|
| 961 |
+
// The argument is a reference to the field tobe examined.
|
| 962 |
+
virtual bool previous(NCursesFormField& f) = 0;
|
| 963 |
+
|
| 964 |
+
public:
|
| 965 |
+
UserDefinedFieldType_With_Choice();
|
| 966 |
+
};
|
| 967 |
+
|
| 968 |
+
#endif /* NCURSES_CURSESF_H_incl */
|
llava_next/include/ncurses/cursesm.h
ADDED
|
@@ -0,0 +1,674 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// * This makes emacs happy -*-Mode: C++;-*-
|
| 2 |
+
/****************************************************************************
|
| 3 |
+
* Copyright 2019-2020,2022 Thomas E. Dickey *
|
| 4 |
+
* Copyright 1998-2012,2014 Free Software Foundation, Inc. *
|
| 5 |
+
* *
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person obtaining a *
|
| 7 |
+
* copy of this software and associated documentation files (the *
|
| 8 |
+
* "Software"), to deal in the Software without restriction, including *
|
| 9 |
+
* without limitation the rights to use, copy, modify, merge, publish, *
|
| 10 |
+
* distribute, distribute with modifications, sublicense, and/or sell *
|
| 11 |
+
* copies of the Software, and to permit persons to whom the Software is *
|
| 12 |
+
* furnished to do so, subject to the following conditions: *
|
| 13 |
+
* *
|
| 14 |
+
* The above copyright notice and this permission notice shall be included *
|
| 15 |
+
* in all copies or substantial portions of the Software. *
|
| 16 |
+
* *
|
| 17 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
|
| 18 |
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
|
| 19 |
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
|
| 20 |
+
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
|
| 21 |
+
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
|
| 22 |
+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
|
| 23 |
+
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
| 24 |
+
* *
|
| 25 |
+
* Except as contained in this notice, the name(s) of the above copyright *
|
| 26 |
+
* holders shall not be used in advertising or otherwise to promote the *
|
| 27 |
+
* sale, use or other dealings in this Software without prior written *
|
| 28 |
+
* authorization. *
|
| 29 |
+
****************************************************************************/
|
| 30 |
+
|
| 31 |
+
/****************************************************************************
|
| 32 |
+
* Author: Juergen Pfeifer, 1997 *
|
| 33 |
+
****************************************************************************/
|
| 34 |
+
|
| 35 |
+
// $Id: cursesm.h,v 1.35 2022/08/20 20:52:15 tom Exp $
|
| 36 |
+
|
| 37 |
+
#ifndef NCURSES_CURSESM_H_incl
|
| 38 |
+
#define NCURSES_CURSESM_H_incl 1
|
| 39 |
+
|
| 40 |
+
#include <ncursesw/cursesp.h>
|
| 41 |
+
|
| 42 |
+
extern "C" {
|
| 43 |
+
# include <ncursesw/menu.h>
|
| 44 |
+
}
|
| 45 |
+
//
|
| 46 |
+
// -------------------------------------------------------------------------
|
| 47 |
+
// This wraps the ITEM type of <ncursesw/menu.h>
|
| 48 |
+
// -------------------------------------------------------------------------
|
| 49 |
+
//
|
| 50 |
+
class NCURSES_CXX_IMPEXP NCursesMenuItem
|
| 51 |
+
{
|
| 52 |
+
friend class NCursesMenu;
|
| 53 |
+
|
| 54 |
+
protected:
|
| 55 |
+
ITEM *item;
|
| 56 |
+
|
| 57 |
+
inline void OnError (int err) const THROW2(NCursesException const, NCursesMenuException) {
|
| 58 |
+
if (err != E_OK)
|
| 59 |
+
THROW(new NCursesMenuException (err));
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
public:
|
| 63 |
+
NCursesMenuItem (const char* p_name = NULL,
|
| 64 |
+
const char* p_descript = NULL)
|
| 65 |
+
: item(0)
|
| 66 |
+
{
|
| 67 |
+
item = p_name ? ::new_item (p_name, p_descript) : STATIC_CAST(ITEM*)(0);
|
| 68 |
+
if (p_name && !item)
|
| 69 |
+
OnError (E_SYSTEM_ERROR);
|
| 70 |
+
}
|
| 71 |
+
// Create an item. If you pass both parameters as NULL, a delimiting
|
| 72 |
+
// item is constructed which can be used to terminate a list of
|
| 73 |
+
// NCursesMenu objects.
|
| 74 |
+
|
| 75 |
+
NCursesMenuItem& operator=(const NCursesMenuItem& rhs)
|
| 76 |
+
{
|
| 77 |
+
if (this != &rhs) {
|
| 78 |
+
*this = rhs;
|
| 79 |
+
}
|
| 80 |
+
return *this;
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
NCursesMenuItem(const NCursesMenuItem& rhs)
|
| 84 |
+
: item(0)
|
| 85 |
+
{
|
| 86 |
+
(void) rhs;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
virtual ~NCursesMenuItem () THROWS(NCursesException);
|
| 90 |
+
// Release the items memory
|
| 91 |
+
|
| 92 |
+
inline const char* name () const {
|
| 93 |
+
return ::item_name (item);
|
| 94 |
+
}
|
| 95 |
+
// Name of the item
|
| 96 |
+
|
| 97 |
+
inline const char* description () const {
|
| 98 |
+
return ::item_description (item);
|
| 99 |
+
}
|
| 100 |
+
// Description of the item
|
| 101 |
+
|
| 102 |
+
inline int (index) (void) const {
|
| 103 |
+
return ::item_index (item);
|
| 104 |
+
}
|
| 105 |
+
// Index of the item in an item array (or -1)
|
| 106 |
+
|
| 107 |
+
inline void options_on (Item_Options opts) {
|
| 108 |
+
OnError (::item_opts_on (item, opts));
|
| 109 |
+
}
|
| 110 |
+
// Switch on the items options
|
| 111 |
+
|
| 112 |
+
inline void options_off (Item_Options opts) {
|
| 113 |
+
OnError (::item_opts_off (item, opts));
|
| 114 |
+
}
|
| 115 |
+
// Switch off the item's option
|
| 116 |
+
|
| 117 |
+
inline Item_Options options () const {
|
| 118 |
+
return ::item_opts (item);
|
| 119 |
+
}
|
| 120 |
+
// Retrieve the items options
|
| 121 |
+
|
| 122 |
+
inline void set_options (Item_Options opts) {
|
| 123 |
+
OnError (::set_item_opts (item, opts));
|
| 124 |
+
}
|
| 125 |
+
// Set the items options
|
| 126 |
+
|
| 127 |
+
inline void set_value (bool f) {
|
| 128 |
+
OnError (::set_item_value (item,f));
|
| 129 |
+
}
|
| 130 |
+
// Set/Reset the items selection state
|
| 131 |
+
|
| 132 |
+
inline bool value () const {
|
| 133 |
+
return ::item_value (item);
|
| 134 |
+
}
|
| 135 |
+
// Retrieve the items selection state
|
| 136 |
+
|
| 137 |
+
inline bool visible () const {
|
| 138 |
+
return ::item_visible (item);
|
| 139 |
+
}
|
| 140 |
+
// Retrieve visibility of the item
|
| 141 |
+
|
| 142 |
+
virtual bool action();
|
| 143 |
+
// Perform an action associated with this item; you may use this in an
|
| 144 |
+
// user supplied driver for a menu; you may derive from this class and
|
| 145 |
+
// overload action() to supply items with different actions.
|
| 146 |
+
// If an action returns true, the menu will be exited. The default action
|
| 147 |
+
// is to do nothing.
|
| 148 |
+
};
|
| 149 |
+
|
| 150 |
+
// Prototype for an items callback function.
|
| 151 |
+
typedef bool ITEMCALLBACK(NCursesMenuItem&);
|
| 152 |
+
|
| 153 |
+
// If you don't like to create a child class for individual items to
|
| 154 |
+
// overload action(), you may use this class and provide a callback
|
| 155 |
+
// function pointer for items.
|
| 156 |
+
class NCURSES_CXX_IMPEXP NCursesMenuCallbackItem : public NCursesMenuItem
|
| 157 |
+
{
|
| 158 |
+
private:
|
| 159 |
+
ITEMCALLBACK* p_fct;
|
| 160 |
+
|
| 161 |
+
public:
|
| 162 |
+
NCursesMenuCallbackItem(ITEMCALLBACK* fct = NULL,
|
| 163 |
+
const char* p_name = NULL,
|
| 164 |
+
const char* p_descript = NULL )
|
| 165 |
+
: NCursesMenuItem (p_name, p_descript),
|
| 166 |
+
p_fct (fct) {
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
NCursesMenuCallbackItem& operator=(const NCursesMenuCallbackItem& rhs)
|
| 170 |
+
{
|
| 171 |
+
if (this != &rhs) {
|
| 172 |
+
*this = rhs;
|
| 173 |
+
}
|
| 174 |
+
return *this;
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
NCursesMenuCallbackItem(const NCursesMenuCallbackItem& rhs)
|
| 178 |
+
: NCursesMenuItem(rhs),
|
| 179 |
+
p_fct(0)
|
| 180 |
+
{
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
virtual ~NCursesMenuCallbackItem() THROWS(NCursesException);
|
| 184 |
+
|
| 185 |
+
bool action() NCURSES_OVERRIDE;
|
| 186 |
+
};
|
| 187 |
+
|
| 188 |
+
// This are the built-in hook functions in this C++ binding. In C++ we use
|
| 189 |
+
// virtual member functions (see below On_..._Init and On_..._Termination)
|
| 190 |
+
// to provide this functionality in an object oriented manner.
|
| 191 |
+
extern "C" {
|
| 192 |
+
void _nc_xx_mnu_init(MENU *);
|
| 193 |
+
void _nc_xx_mnu_term(MENU *);
|
| 194 |
+
void _nc_xx_itm_init(MENU *);
|
| 195 |
+
void _nc_xx_itm_term(MENU *);
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
//
|
| 199 |
+
// -------------------------------------------------------------------------
|
| 200 |
+
// This wraps the MENU type of <ncursesw/menu.h>
|
| 201 |
+
// -------------------------------------------------------------------------
|
| 202 |
+
//
|
| 203 |
+
class NCURSES_CXX_IMPEXP NCursesMenu : public NCursesPanel
|
| 204 |
+
{
|
| 205 |
+
protected:
|
| 206 |
+
MENU *menu;
|
| 207 |
+
|
| 208 |
+
private:
|
| 209 |
+
NCursesWindow* sub; // the subwindow object
|
| 210 |
+
bool b_sub_owner; // is this our own subwindow?
|
| 211 |
+
bool b_framed; // has the menu a border?
|
| 212 |
+
bool b_autoDelete; // Delete items when deleting menu?
|
| 213 |
+
|
| 214 |
+
NCursesMenuItem** my_items; // The array of items for this menu
|
| 215 |
+
|
| 216 |
+
// This structure is used for the menu's user data field to link the
|
| 217 |
+
// MENU* to the C++ object and to provide extra space for a user pointer.
|
| 218 |
+
typedef struct {
|
| 219 |
+
void* m_user; // the pointer for the user's data
|
| 220 |
+
const NCursesMenu* m_back; // backward pointer to C++ object
|
| 221 |
+
const MENU* m_owner;
|
| 222 |
+
} UserHook;
|
| 223 |
+
|
| 224 |
+
// Get the backward pointer to the C++ object from a MENU
|
| 225 |
+
static inline NCursesMenu* getHook(const MENU *m) {
|
| 226 |
+
UserHook* hook = STATIC_CAST(UserHook*)(::menu_userptr(m));
|
| 227 |
+
assert(hook != 0 && hook->m_owner==m);
|
| 228 |
+
return const_cast<NCursesMenu*>(hook->m_back);
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
friend void _nc_xx_mnu_init(MENU *);
|
| 232 |
+
friend void _nc_xx_mnu_term(MENU *);
|
| 233 |
+
friend void _nc_xx_itm_init(MENU *);
|
| 234 |
+
friend void _nc_xx_itm_term(MENU *);
|
| 235 |
+
|
| 236 |
+
// Calculate ITEM* array for the menu
|
| 237 |
+
ITEM** mapItems(NCursesMenuItem* nitems[]);
|
| 238 |
+
|
| 239 |
+
protected:
|
| 240 |
+
// internal routines
|
| 241 |
+
inline void set_user(void *user) {
|
| 242 |
+
UserHook* uptr = STATIC_CAST(UserHook*)(::menu_userptr (menu));
|
| 243 |
+
assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==menu);
|
| 244 |
+
uptr->m_user = user;
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
inline void *get_user() {
|
| 248 |
+
UserHook* uptr = STATIC_CAST(UserHook*)(::menu_userptr (menu));
|
| 249 |
+
assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==menu);
|
| 250 |
+
return uptr->m_user;
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
void InitMenu (NCursesMenuItem* menu[],
|
| 254 |
+
bool with_frame,
|
| 255 |
+
bool autoDeleteItems);
|
| 256 |
+
|
| 257 |
+
inline void OnError (int err) const THROW2(NCursesException const, NCursesMenuException) {
|
| 258 |
+
if (err != E_OK)
|
| 259 |
+
THROW(new NCursesMenuException (this, err));
|
| 260 |
+
}
|
| 261 |
+
|
| 262 |
+
// this wraps the menu_driver call.
|
| 263 |
+
virtual int driver (int c) ;
|
| 264 |
+
|
| 265 |
+
// 'Internal' constructor to create a menu without association to
|
| 266 |
+
// an array of items.
|
| 267 |
+
NCursesMenu( int nlines,
|
| 268 |
+
int ncols,
|
| 269 |
+
int begin_y = 0,
|
| 270 |
+
int begin_x = 0)
|
| 271 |
+
: NCursesPanel(nlines,ncols,begin_y,begin_x),
|
| 272 |
+
menu (STATIC_CAST(MENU*)(0)),
|
| 273 |
+
sub(0),
|
| 274 |
+
b_sub_owner(0),
|
| 275 |
+
b_framed(0),
|
| 276 |
+
b_autoDelete(0),
|
| 277 |
+
my_items(0)
|
| 278 |
+
{
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
public:
|
| 282 |
+
// Make a full window size menu
|
| 283 |
+
NCursesMenu (NCursesMenuItem* Items[],
|
| 284 |
+
bool with_frame=FALSE, // Reserve space for a frame?
|
| 285 |
+
bool autoDelete_Items=FALSE) // Autocleanup of Items?
|
| 286 |
+
: NCursesPanel(),
|
| 287 |
+
menu(0),
|
| 288 |
+
sub(0),
|
| 289 |
+
b_sub_owner(0),
|
| 290 |
+
b_framed(0),
|
| 291 |
+
b_autoDelete(0),
|
| 292 |
+
my_items(0)
|
| 293 |
+
{
|
| 294 |
+
InitMenu(Items, with_frame, autoDelete_Items);
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
// Make a menu with a window of this size.
|
| 298 |
+
NCursesMenu (NCursesMenuItem* Items[],
|
| 299 |
+
int nlines,
|
| 300 |
+
int ncols,
|
| 301 |
+
int begin_y = 0,
|
| 302 |
+
int begin_x = 0,
|
| 303 |
+
bool with_frame=FALSE, // Reserve space for a frame?
|
| 304 |
+
bool autoDelete_Items=FALSE) // Autocleanup of Items?
|
| 305 |
+
: NCursesPanel(nlines, ncols, begin_y, begin_x),
|
| 306 |
+
menu(0),
|
| 307 |
+
sub(0),
|
| 308 |
+
b_sub_owner(0),
|
| 309 |
+
b_framed(0),
|
| 310 |
+
b_autoDelete(0),
|
| 311 |
+
my_items(0)
|
| 312 |
+
{
|
| 313 |
+
InitMenu(Items, with_frame, autoDelete_Items);
|
| 314 |
+
}
|
| 315 |
+
|
| 316 |
+
NCursesMenu& operator=(const NCursesMenu& rhs)
|
| 317 |
+
{
|
| 318 |
+
if (this != &rhs) {
|
| 319 |
+
*this = rhs;
|
| 320 |
+
NCursesPanel::operator=(rhs);
|
| 321 |
+
}
|
| 322 |
+
return *this;
|
| 323 |
+
}
|
| 324 |
+
|
| 325 |
+
NCursesMenu(const NCursesMenu& rhs)
|
| 326 |
+
: NCursesPanel(rhs),
|
| 327 |
+
menu(rhs.menu),
|
| 328 |
+
sub(rhs.sub),
|
| 329 |
+
b_sub_owner(rhs.b_sub_owner),
|
| 330 |
+
b_framed(rhs.b_framed),
|
| 331 |
+
b_autoDelete(rhs.b_autoDelete),
|
| 332 |
+
my_items(rhs.my_items)
|
| 333 |
+
{
|
| 334 |
+
}
|
| 335 |
+
|
| 336 |
+
virtual ~NCursesMenu () THROWS(NCursesException);
|
| 337 |
+
|
| 338 |
+
// Retrieve the menus subwindow
|
| 339 |
+
inline NCursesWindow& subWindow() const {
|
| 340 |
+
assert(sub!=NULL);
|
| 341 |
+
return *sub;
|
| 342 |
+
}
|
| 343 |
+
|
| 344 |
+
// Set the menus subwindow
|
| 345 |
+
void setSubWindow(NCursesWindow& sub);
|
| 346 |
+
|
| 347 |
+
// Set these items for the menu
|
| 348 |
+
inline void setItems(NCursesMenuItem* Items[]) {
|
| 349 |
+
OnError(::set_menu_items(menu,mapItems(Items)));
|
| 350 |
+
}
|
| 351 |
+
|
| 352 |
+
// Remove the menu from the screen
|
| 353 |
+
inline void unpost (void) {
|
| 354 |
+
OnError (::unpost_menu (menu));
|
| 355 |
+
}
|
| 356 |
+
|
| 357 |
+
// Post the menu to the screen if flag is true, unpost it otherwise
|
| 358 |
+
inline void post(bool flag = TRUE) {
|
| 359 |
+
flag ? OnError (::post_menu(menu)) : OnError (::unpost_menu (menu));
|
| 360 |
+
}
|
| 361 |
+
|
| 362 |
+
// Get the number of rows and columns for this menu
|
| 363 |
+
inline void scale (int& mrows, int& mcols) const {
|
| 364 |
+
OnError (::scale_menu (menu, &mrows, &mcols));
|
| 365 |
+
}
|
| 366 |
+
|
| 367 |
+
// Set the format of this menu
|
| 368 |
+
inline void set_format(int mrows, int mcols) {
|
| 369 |
+
OnError (::set_menu_format(menu, mrows, mcols));
|
| 370 |
+
}
|
| 371 |
+
|
| 372 |
+
// Get the format of this menu
|
| 373 |
+
inline void menu_format(int& rows,int& ncols) {
|
| 374 |
+
::menu_format(menu,&rows,&ncols);
|
| 375 |
+
}
|
| 376 |
+
|
| 377 |
+
// Items of the menu
|
| 378 |
+
inline NCursesMenuItem* items() const {
|
| 379 |
+
return *my_items;
|
| 380 |
+
}
|
| 381 |
+
|
| 382 |
+
// Get the number of items in this menu
|
| 383 |
+
inline int count() const {
|
| 384 |
+
return ::item_count(menu);
|
| 385 |
+
}
|
| 386 |
+
|
| 387 |
+
// Get the current item (i.e. the one the cursor is located)
|
| 388 |
+
inline NCursesMenuItem* current_item() const {
|
| 389 |
+
return my_items[::item_index(::current_item(menu))];
|
| 390 |
+
}
|
| 391 |
+
|
| 392 |
+
// Get the marker string
|
| 393 |
+
inline const char* mark() const {
|
| 394 |
+
return ::menu_mark(menu);
|
| 395 |
+
}
|
| 396 |
+
|
| 397 |
+
// Set the marker string
|
| 398 |
+
inline void set_mark(const char *marker) {
|
| 399 |
+
OnError (::set_menu_mark (menu, marker));
|
| 400 |
+
}
|
| 401 |
+
|
| 402 |
+
// Get the name of the request code c
|
| 403 |
+
inline static const char* request_name(int c) {
|
| 404 |
+
return ::menu_request_name(c);
|
| 405 |
+
}
|
| 406 |
+
|
| 407 |
+
// Get the current pattern
|
| 408 |
+
inline char* pattern() const {
|
| 409 |
+
return ::menu_pattern(menu);
|
| 410 |
+
}
|
| 411 |
+
|
| 412 |
+
// true if there is a pattern match, false otherwise.
|
| 413 |
+
bool set_pattern (const char *pat);
|
| 414 |
+
|
| 415 |
+
// set the default attributes for the menu
|
| 416 |
+
// i.e. set fore, back and grey attribute
|
| 417 |
+
virtual void setDefaultAttributes();
|
| 418 |
+
|
| 419 |
+
// Get the menus background attributes
|
| 420 |
+
inline chtype back() const {
|
| 421 |
+
return ::menu_back(menu);
|
| 422 |
+
}
|
| 423 |
+
|
| 424 |
+
// Get the menus foreground attributes
|
| 425 |
+
inline chtype fore() const {
|
| 426 |
+
return ::menu_fore(menu);
|
| 427 |
+
}
|
| 428 |
+
|
| 429 |
+
// Get the menus grey attributes (used for unselectable items)
|
| 430 |
+
inline chtype grey() const {
|
| 431 |
+
return ::menu_grey(menu);
|
| 432 |
+
}
|
| 433 |
+
|
| 434 |
+
// Set the menus background attributes
|
| 435 |
+
inline chtype set_background(chtype a) {
|
| 436 |
+
return ::set_menu_back(menu,a);
|
| 437 |
+
}
|
| 438 |
+
|
| 439 |
+
// Set the menus foreground attributes
|
| 440 |
+
inline chtype set_foreground(chtype a) {
|
| 441 |
+
return ::set_menu_fore(menu,a);
|
| 442 |
+
}
|
| 443 |
+
|
| 444 |
+
// Set the menus grey attributes (used for unselectable items)
|
| 445 |
+
inline chtype set_grey(chtype a) {
|
| 446 |
+
return ::set_menu_grey(menu,a);
|
| 447 |
+
}
|
| 448 |
+
|
| 449 |
+
inline void options_on (Menu_Options opts) {
|
| 450 |
+
OnError (::menu_opts_on (menu,opts));
|
| 451 |
+
}
|
| 452 |
+
|
| 453 |
+
inline void options_off(Menu_Options opts) {
|
| 454 |
+
OnError (::menu_opts_off(menu,opts));
|
| 455 |
+
}
|
| 456 |
+
|
| 457 |
+
inline Menu_Options options() const {
|
| 458 |
+
return ::menu_opts(menu);
|
| 459 |
+
}
|
| 460 |
+
|
| 461 |
+
inline void set_options (Menu_Options opts) {
|
| 462 |
+
OnError (::set_menu_opts (menu,opts));
|
| 463 |
+
}
|
| 464 |
+
|
| 465 |
+
inline int pad() const {
|
| 466 |
+
return ::menu_pad(menu);
|
| 467 |
+
}
|
| 468 |
+
|
| 469 |
+
inline void set_pad (int padch) {
|
| 470 |
+
OnError (::set_menu_pad (menu, padch));
|
| 471 |
+
}
|
| 472 |
+
|
| 473 |
+
// Position the cursor to the current item
|
| 474 |
+
inline void position_cursor () const {
|
| 475 |
+
OnError (::pos_menu_cursor (menu));
|
| 476 |
+
}
|
| 477 |
+
|
| 478 |
+
// Set the current item
|
| 479 |
+
inline void set_current(NCursesMenuItem& I) {
|
| 480 |
+
OnError (::set_current_item(menu, I.item));
|
| 481 |
+
}
|
| 482 |
+
|
| 483 |
+
// Get the current top row of the menu
|
| 484 |
+
inline int top_row (void) const {
|
| 485 |
+
return ::top_row (menu);
|
| 486 |
+
}
|
| 487 |
+
|
| 488 |
+
// Set the current top row of the menu
|
| 489 |
+
inline void set_top_row (int row) {
|
| 490 |
+
OnError (::set_top_row (menu, row));
|
| 491 |
+
}
|
| 492 |
+
|
| 493 |
+
// spacing control
|
| 494 |
+
// Set the spacing for the menu
|
| 495 |
+
inline void setSpacing(int spc_description,
|
| 496 |
+
int spc_rows,
|
| 497 |
+
int spc_columns) {
|
| 498 |
+
OnError(::set_menu_spacing(menu,
|
| 499 |
+
spc_description,
|
| 500 |
+
spc_rows,
|
| 501 |
+
spc_columns));
|
| 502 |
+
}
|
| 503 |
+
|
| 504 |
+
// Get the spacing info for the menu
|
| 505 |
+
inline void Spacing(int& spc_description,
|
| 506 |
+
int& spc_rows,
|
| 507 |
+
int& spc_columns) const {
|
| 508 |
+
OnError(::menu_spacing(menu,
|
| 509 |
+
&spc_description,
|
| 510 |
+
&spc_rows,
|
| 511 |
+
&spc_columns));
|
| 512 |
+
}
|
| 513 |
+
|
| 514 |
+
// Decorations
|
| 515 |
+
inline void frame(const char *title=NULL, const char* btitle=NULL) NCURSES_OVERRIDE {
|
| 516 |
+
if (b_framed)
|
| 517 |
+
NCursesPanel::frame(title,btitle);
|
| 518 |
+
else
|
| 519 |
+
OnError(E_SYSTEM_ERROR);
|
| 520 |
+
}
|
| 521 |
+
|
| 522 |
+
inline void boldframe(const char *title=NULL, const char* btitle=NULL) NCURSES_OVERRIDE {
|
| 523 |
+
if (b_framed)
|
| 524 |
+
NCursesPanel::boldframe(title,btitle);
|
| 525 |
+
else
|
| 526 |
+
OnError(E_SYSTEM_ERROR);
|
| 527 |
+
}
|
| 528 |
+
|
| 529 |
+
inline void label(const char *topLabel, const char *bottomLabel) NCURSES_OVERRIDE {
|
| 530 |
+
if (b_framed)
|
| 531 |
+
NCursesPanel::label(topLabel,bottomLabel);
|
| 532 |
+
else
|
| 533 |
+
OnError(E_SYSTEM_ERROR);
|
| 534 |
+
}
|
| 535 |
+
|
| 536 |
+
// -----
|
| 537 |
+
// Hooks
|
| 538 |
+
// -----
|
| 539 |
+
|
| 540 |
+
// Called after the menu gets repositioned in its window.
|
| 541 |
+
// This is especially true if the menu is posted.
|
| 542 |
+
virtual void On_Menu_Init();
|
| 543 |
+
|
| 544 |
+
// Called before the menu gets repositioned in its window.
|
| 545 |
+
// This is especially true if the menu is unposted.
|
| 546 |
+
virtual void On_Menu_Termination();
|
| 547 |
+
|
| 548 |
+
// Called after the item became the current item
|
| 549 |
+
virtual void On_Item_Init(NCursesMenuItem& item);
|
| 550 |
+
|
| 551 |
+
// Called before this item is left as current item.
|
| 552 |
+
virtual void On_Item_Termination(NCursesMenuItem& item);
|
| 553 |
+
|
| 554 |
+
// Provide a default key virtualization. Translate the keyboard
|
| 555 |
+
// code c into a menu request code.
|
| 556 |
+
// The default implementation provides a hopefully straightforward
|
| 557 |
+
// mapping for the most common keystrokes and menu requests.
|
| 558 |
+
virtual int virtualize(int c);
|
| 559 |
+
|
| 560 |
+
|
| 561 |
+
// Operators
|
| 562 |
+
inline NCursesMenuItem* operator[](int i) const {
|
| 563 |
+
if ( (i < 0) || (i >= ::item_count (menu)) )
|
| 564 |
+
OnError (E_BAD_ARGUMENT);
|
| 565 |
+
return (my_items[i]);
|
| 566 |
+
}
|
| 567 |
+
|
| 568 |
+
// Perform the menu's operation
|
| 569 |
+
// Return the item where you left the selection mark for a single
|
| 570 |
+
// selection menu, or NULL for a multivalued menu.
|
| 571 |
+
virtual NCursesMenuItem* operator()(void);
|
| 572 |
+
|
| 573 |
+
// --------------------
|
| 574 |
+
// Exception handlers
|
| 575 |
+
// Called by operator()
|
| 576 |
+
// --------------------
|
| 577 |
+
|
| 578 |
+
// Called if the request is denied
|
| 579 |
+
virtual void On_Request_Denied(int c) const;
|
| 580 |
+
|
| 581 |
+
// Called if the item is not selectable
|
| 582 |
+
virtual void On_Not_Selectable(int c) const;
|
| 583 |
+
|
| 584 |
+
// Called if pattern doesn't match
|
| 585 |
+
virtual void On_No_Match(int c) const;
|
| 586 |
+
|
| 587 |
+
// Called if the command is unknown
|
| 588 |
+
virtual void On_Unknown_Command(int c) const;
|
| 589 |
+
|
| 590 |
+
};
|
| 591 |
+
//
|
| 592 |
+
// -------------------------------------------------------------------------
|
| 593 |
+
// This is the typical C++ typesafe way to allow to attach
|
| 594 |
+
// user data to an item of a menu. Its assumed that the user
|
| 595 |
+
// data belongs to some class T. Use T as template argument
|
| 596 |
+
// to create a UserItem.
|
| 597 |
+
// -------------------------------------------------------------------------
|
| 598 |
+
//
|
| 599 |
+
template<class T> class NCURSES_CXX_IMPEXP NCursesUserItem : public NCursesMenuItem
|
| 600 |
+
{
|
| 601 |
+
public:
|
| 602 |
+
NCursesUserItem (const char* p_name,
|
| 603 |
+
const char* p_descript = NULL,
|
| 604 |
+
const T* p_UserData = STATIC_CAST(T*)(0))
|
| 605 |
+
: NCursesMenuItem (p_name, p_descript) {
|
| 606 |
+
if (item)
|
| 607 |
+
OnError (::set_item_userptr (item, const_cast<void *>(reinterpret_cast<const void*>(p_UserData))));
|
| 608 |
+
}
|
| 609 |
+
|
| 610 |
+
virtual ~NCursesUserItem() THROWS(NCursesException) {}
|
| 611 |
+
|
| 612 |
+
inline const T* UserData (void) const {
|
| 613 |
+
return reinterpret_cast<const T*>(::item_userptr (item));
|
| 614 |
+
};
|
| 615 |
+
|
| 616 |
+
inline virtual void setUserData(const T* p_UserData) {
|
| 617 |
+
if (item)
|
| 618 |
+
OnError (::set_item_userptr (item, const_cast<void *>(reinterpret_cast<const void *>(p_UserData))));
|
| 619 |
+
}
|
| 620 |
+
};
|
| 621 |
+
//
|
| 622 |
+
// -------------------------------------------------------------------------
|
| 623 |
+
// The same mechanism is used to attach user data to a menu
|
| 624 |
+
// -------------------------------------------------------------------------
|
| 625 |
+
//
|
| 626 |
+
template<class T> class NCURSES_CXX_IMPEXP NCursesUserMenu : public NCursesMenu
|
| 627 |
+
{
|
| 628 |
+
protected:
|
| 629 |
+
NCursesUserMenu( int nlines,
|
| 630 |
+
int ncols,
|
| 631 |
+
int begin_y = 0,
|
| 632 |
+
int begin_x = 0,
|
| 633 |
+
const T* p_UserData = STATIC_CAST(T*)(0))
|
| 634 |
+
: NCursesMenu(nlines,ncols,begin_y,begin_x) {
|
| 635 |
+
if (menu)
|
| 636 |
+
set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
|
| 637 |
+
}
|
| 638 |
+
|
| 639 |
+
public:
|
| 640 |
+
NCursesUserMenu (NCursesMenuItem* Items[],
|
| 641 |
+
const T* p_UserData = STATIC_CAST(T*)(0),
|
| 642 |
+
bool with_frame=FALSE,
|
| 643 |
+
bool autoDelete_Items=FALSE)
|
| 644 |
+
: NCursesMenu (&Items, with_frame, autoDelete_Items) {
|
| 645 |
+
if (menu)
|
| 646 |
+
set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
|
| 647 |
+
};
|
| 648 |
+
|
| 649 |
+
NCursesUserMenu (NCursesMenuItem* Items[],
|
| 650 |
+
int nlines,
|
| 651 |
+
int ncols,
|
| 652 |
+
int begin_y = 0,
|
| 653 |
+
int begin_x = 0,
|
| 654 |
+
const T* p_UserData = STATIC_CAST(T*)(0),
|
| 655 |
+
bool with_frame=FALSE)
|
| 656 |
+
: NCursesMenu (&Items, nlines, ncols, begin_y, begin_x, with_frame) {
|
| 657 |
+
if (menu)
|
| 658 |
+
set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
|
| 659 |
+
};
|
| 660 |
+
|
| 661 |
+
virtual ~NCursesUserMenu() THROWS(NCursesException) {
|
| 662 |
+
};
|
| 663 |
+
|
| 664 |
+
inline T* UserData (void) {
|
| 665 |
+
return reinterpret_cast<T*>(get_user ());
|
| 666 |
+
};
|
| 667 |
+
|
| 668 |
+
inline virtual void setUserData (const T* p_UserData) {
|
| 669 |
+
if (menu)
|
| 670 |
+
set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
|
| 671 |
+
}
|
| 672 |
+
};
|
| 673 |
+
|
| 674 |
+
#endif /* NCURSES_CURSESM_H_incl */
|
llava_next/include/ncurses/cursesp.h
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// * This makes emacs happy -*-Mode: C++;-*-
|
| 2 |
+
// vile:cppmode
|
| 3 |
+
/****************************************************************************
|
| 4 |
+
* Copyright 2019-2021,2022 Thomas E. Dickey *
|
| 5 |
+
* Copyright 1998-2012,2014 Free Software Foundation, Inc. *
|
| 6 |
+
* *
|
| 7 |
+
* Permission is hereby granted, free of charge, to any person obtaining a *
|
| 8 |
+
* copy of this software and associated documentation files (the *
|
| 9 |
+
* "Software"), to deal in the Software without restriction, including *
|
| 10 |
+
* without limitation the rights to use, copy, modify, merge, publish, *
|
| 11 |
+
* distribute, distribute with modifications, sublicense, and/or sell *
|
| 12 |
+
* copies of the Software, and to permit persons to whom the Software is *
|
| 13 |
+
* furnished to do so, subject to the following conditions: *
|
| 14 |
+
* *
|
| 15 |
+
* The above copyright notice and this permission notice shall be included *
|
| 16 |
+
* in all copies or substantial portions of the Software. *
|
| 17 |
+
* *
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
|
| 19 |
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
|
| 20 |
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
|
| 21 |
+
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
|
| 22 |
+
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
|
| 23 |
+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
|
| 24 |
+
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
| 25 |
+
* *
|
| 26 |
+
* Except as contained in this notice, the name(s) of the above copyright *
|
| 27 |
+
* holders shall not be used in advertising or otherwise to promote the *
|
| 28 |
+
* sale, use or other dealings in this Software without prior written *
|
| 29 |
+
* authorization. *
|
| 30 |
+
****************************************************************************/
|
| 31 |
+
|
| 32 |
+
/****************************************************************************
|
| 33 |
+
* Author: Juergen Pfeifer, 1997 *
|
| 34 |
+
****************************************************************************/
|
| 35 |
+
|
| 36 |
+
#ifndef NCURSES_CURSESP_H_incl
|
| 37 |
+
#define NCURSES_CURSESP_H_incl 1
|
| 38 |
+
|
| 39 |
+
// $Id: cursesp.h,v 1.36 2022/08/20 20:52:15 tom Exp $
|
| 40 |
+
|
| 41 |
+
#include <ncursesw/cursesw.h>
|
| 42 |
+
|
| 43 |
+
extern "C" {
|
| 44 |
+
# include <ncursesw/panel.h>
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
class NCURSES_CXX_IMPEXP NCursesPanel
|
| 48 |
+
: public NCursesWindow
|
| 49 |
+
{
|
| 50 |
+
protected:
|
| 51 |
+
PANEL *p;
|
| 52 |
+
static NCursesPanel *dummy;
|
| 53 |
+
|
| 54 |
+
private:
|
| 55 |
+
// This structure is used for the panel's user data field to link the
|
| 56 |
+
// PANEL* to the C++ object and to provide extra space for a user pointer.
|
| 57 |
+
typedef struct {
|
| 58 |
+
void* m_user; // the pointer for the user's data
|
| 59 |
+
const NCursesPanel* m_back; // backward pointer to C++ object
|
| 60 |
+
const PANEL* m_owner; // the panel itself
|
| 61 |
+
} UserHook;
|
| 62 |
+
|
| 63 |
+
inline UserHook *UserPointer()
|
| 64 |
+
{
|
| 65 |
+
UserHook* uptr = reinterpret_cast<UserHook*>(
|
| 66 |
+
const_cast<void *>(::panel_userptr (p)));
|
| 67 |
+
return uptr;
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
void init(); // Initialize the panel object
|
| 71 |
+
|
| 72 |
+
protected:
|
| 73 |
+
void set_user(void *user)
|
| 74 |
+
{
|
| 75 |
+
UserHook* uptr = UserPointer();
|
| 76 |
+
if (uptr != 0 && uptr->m_back==this && uptr->m_owner==p) {
|
| 77 |
+
uptr->m_user = user;
|
| 78 |
+
}
|
| 79 |
+
}
|
| 80 |
+
// Set the user pointer of the panel.
|
| 81 |
+
|
| 82 |
+
void *get_user()
|
| 83 |
+
{
|
| 84 |
+
UserHook* uptr = UserPointer();
|
| 85 |
+
void *result = 0;
|
| 86 |
+
if (uptr != 0 && uptr->m_back==this && uptr->m_owner==p)
|
| 87 |
+
result = uptr->m_user;
|
| 88 |
+
return result;
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
void OnError (int err) const THROW2(NCursesException const, NCursesPanelException)
|
| 92 |
+
{
|
| 93 |
+
if (err==ERR)
|
| 94 |
+
THROW(new NCursesPanelException (this, err));
|
| 95 |
+
}
|
| 96 |
+
// If err is equal to the curses error indicator ERR, an error handler
|
| 97 |
+
// is called.
|
| 98 |
+
|
| 99 |
+
// Get a keystroke. Default implementation calls getch()
|
| 100 |
+
virtual int getKey(void);
|
| 101 |
+
|
| 102 |
+
public:
|
| 103 |
+
NCursesPanel(int nlines,
|
| 104 |
+
int ncols,
|
| 105 |
+
int begin_y = 0,
|
| 106 |
+
int begin_x = 0)
|
| 107 |
+
: NCursesWindow(nlines,ncols,begin_y,begin_x), p(0)
|
| 108 |
+
{
|
| 109 |
+
init();
|
| 110 |
+
}
|
| 111 |
+
// Create a panel with this size starting at the requested position.
|
| 112 |
+
|
| 113 |
+
NCursesPanel()
|
| 114 |
+
: NCursesWindow(::stdscr), p(0)
|
| 115 |
+
{
|
| 116 |
+
init();
|
| 117 |
+
}
|
| 118 |
+
// This constructor creates the default Panel associated with the
|
| 119 |
+
// ::stdscr window
|
| 120 |
+
|
| 121 |
+
NCursesPanel& operator=(const NCursesPanel& rhs)
|
| 122 |
+
{
|
| 123 |
+
if (this != &rhs) {
|
| 124 |
+
*this = rhs;
|
| 125 |
+
NCursesWindow::operator=(rhs);
|
| 126 |
+
}
|
| 127 |
+
return *this;
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
NCursesPanel(const NCursesPanel& rhs)
|
| 131 |
+
: NCursesWindow(rhs),
|
| 132 |
+
p(rhs.p)
|
| 133 |
+
{
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
virtual ~NCursesPanel() THROWS(NCursesException);
|
| 137 |
+
|
| 138 |
+
// basic manipulation
|
| 139 |
+
inline void hide()
|
| 140 |
+
{
|
| 141 |
+
OnError (::hide_panel(p));
|
| 142 |
+
}
|
| 143 |
+
// Hide the panel. It stays in the stack but becomes invisible.
|
| 144 |
+
|
| 145 |
+
inline void show()
|
| 146 |
+
{
|
| 147 |
+
OnError (::show_panel(p));
|
| 148 |
+
}
|
| 149 |
+
// Show the panel, i.e. make it visible.
|
| 150 |
+
|
| 151 |
+
inline void top()
|
| 152 |
+
{
|
| 153 |
+
OnError (::top_panel(p));
|
| 154 |
+
}
|
| 155 |
+
// Make this panel the top panel in the stack.
|
| 156 |
+
|
| 157 |
+
inline void bottom()
|
| 158 |
+
{
|
| 159 |
+
OnError (::bottom_panel(p));
|
| 160 |
+
}
|
| 161 |
+
// Make this panel the bottom panel in the stack.
|
| 162 |
+
// N.B.: The panel associated with ::stdscr is always on the bottom. So
|
| 163 |
+
// actually bottom() makes the panel the first above ::stdscr.
|
| 164 |
+
|
| 165 |
+
virtual int mvwin(int y, int x) NCURSES_OVERRIDE
|
| 166 |
+
{
|
| 167 |
+
OnError(::move_panel(p, y, x));
|
| 168 |
+
return OK;
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
inline bool hidden() const
|
| 172 |
+
{
|
| 173 |
+
return (::panel_hidden (p) ? TRUE : FALSE);
|
| 174 |
+
}
|
| 175 |
+
// Return TRUE if the panel is hidden, FALSE otherwise.
|
| 176 |
+
|
| 177 |
+
/* The functions panel_above() and panel_below() are not reflected in
|
| 178 |
+
the NCursesPanel class. The reason for this is, that we cannot
|
| 179 |
+
assume that a panel retrieved by those operations is one wrapped
|
| 180 |
+
by a C++ class. Although this situation might be handled, we also
|
| 181 |
+
need a reverse mapping from PANEL to NCursesPanel which needs some
|
| 182 |
+
redesign of the low level stuff. At the moment, we define them in the
|
| 183 |
+
interface but they will always produce an error. */
|
| 184 |
+
inline NCursesPanel& above() const
|
| 185 |
+
{
|
| 186 |
+
OnError(ERR);
|
| 187 |
+
return *dummy;
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
inline NCursesPanel& below() const
|
| 191 |
+
{
|
| 192 |
+
OnError(ERR);
|
| 193 |
+
return *dummy;
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
// Those two are rewrites of the corresponding virtual members of
|
| 197 |
+
// NCursesWindow
|
| 198 |
+
virtual int refresh() NCURSES_OVERRIDE;
|
| 199 |
+
// Propagate all panel changes to the virtual screen and update the
|
| 200 |
+
// physical screen.
|
| 201 |
+
|
| 202 |
+
virtual int noutrefresh() NCURSES_OVERRIDE;
|
| 203 |
+
// Propagate all panel changes to the virtual screen.
|
| 204 |
+
|
| 205 |
+
static void redraw();
|
| 206 |
+
// Redraw all panels.
|
| 207 |
+
|
| 208 |
+
// decorations
|
| 209 |
+
virtual void frame(const char* title=NULL,
|
| 210 |
+
const char* btitle=NULL);
|
| 211 |
+
// Put a frame around the panel and put the title centered in the top line
|
| 212 |
+
// and btitle in the bottom line.
|
| 213 |
+
|
| 214 |
+
virtual void boldframe(const char* title=NULL,
|
| 215 |
+
const char* btitle=NULL);
|
| 216 |
+
// Same as frame(), but use highlighted attributes.
|
| 217 |
+
|
| 218 |
+
virtual void label(const char* topLabel,
|
| 219 |
+
const char* bottomLabel);
|
| 220 |
+
// Put the title centered in the top line and btitle in the bottom line.
|
| 221 |
+
|
| 222 |
+
virtual void centertext(int row,const char* label);
|
| 223 |
+
// Put the label text centered in the specified row.
|
| 224 |
+
};
|
| 225 |
+
|
| 226 |
+
/* We use templates to provide a typesafe mechanism to associate
|
| 227 |
+
* user data with a panel. A NCursesUserPanel<T> is a panel
|
| 228 |
+
* associated with some user data of type T.
|
| 229 |
+
*/
|
| 230 |
+
template<class T> class NCursesUserPanel : public NCursesPanel
|
| 231 |
+
{
|
| 232 |
+
public:
|
| 233 |
+
NCursesUserPanel (int nlines,
|
| 234 |
+
int ncols,
|
| 235 |
+
int begin_y = 0,
|
| 236 |
+
int begin_x = 0,
|
| 237 |
+
const T* p_UserData = STATIC_CAST(T*)(0))
|
| 238 |
+
: NCursesPanel (nlines, ncols, begin_y, begin_x)
|
| 239 |
+
{
|
| 240 |
+
if (p)
|
| 241 |
+
set_user (const_cast<void *>(reinterpret_cast<const void*>
|
| 242 |
+
(p_UserData)));
|
| 243 |
+
};
|
| 244 |
+
// This creates an user panel of the requested size with associated
|
| 245 |
+
// user data pointed to by p_UserData.
|
| 246 |
+
|
| 247 |
+
explicit NCursesUserPanel(const T* p_UserData = STATIC_CAST(T*)(0)) : NCursesPanel()
|
| 248 |
+
{
|
| 249 |
+
if (p)
|
| 250 |
+
set_user(const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
|
| 251 |
+
};
|
| 252 |
+
// This creates an user panel associated with the ::stdscr and user data
|
| 253 |
+
// pointed to by p_UserData.
|
| 254 |
+
|
| 255 |
+
virtual ~NCursesUserPanel() THROWS(NCursesException) {};
|
| 256 |
+
|
| 257 |
+
T* UserData (void)
|
| 258 |
+
{
|
| 259 |
+
return reinterpret_cast<T*>(get_user ());
|
| 260 |
+
};
|
| 261 |
+
// Retrieve the user data associated with the panel.
|
| 262 |
+
|
| 263 |
+
virtual void setUserData (const T* p_UserData)
|
| 264 |
+
{
|
| 265 |
+
if (p)
|
| 266 |
+
set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
|
| 267 |
+
}
|
| 268 |
+
// Associate the user panel with the user data pointed to by p_UserData.
|
| 269 |
+
};
|
| 270 |
+
|
| 271 |
+
#endif /* NCURSES_CURSESP_H_incl */
|
llava_next/include/ncurses/cursesw.h
ADDED
|
@@ -0,0 +1,1581 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// * This makes emacs happy -*-Mode: C++;-*-
|
| 2 |
+
// vile:cppmode
|
| 3 |
+
/****************************************************************************
|
| 4 |
+
* Copyright 2019-2021,2022 Thomas E. Dickey *
|
| 5 |
+
* Copyright 1998-2014,2017 Free Software Foundation, Inc. *
|
| 6 |
+
* *
|
| 7 |
+
* Permission is hereby granted, free of charge, to any person obtaining a *
|
| 8 |
+
* copy of this software and associated documentation files (the *
|
| 9 |
+
* "Software"), to deal in the Software without restriction, including *
|
| 10 |
+
* without limitation the rights to use, copy, modify, merge, publish, *
|
| 11 |
+
* distribute, distribute with modifications, sublicense, and/or sell *
|
| 12 |
+
* copies of the Software, and to permit persons to whom the Software is *
|
| 13 |
+
* furnished to do so, subject to the following conditions: *
|
| 14 |
+
* *
|
| 15 |
+
* The above copyright notice and this permission notice shall be included *
|
| 16 |
+
* in all copies or substantial portions of the Software. *
|
| 17 |
+
* *
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
|
| 19 |
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
|
| 20 |
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
|
| 21 |
+
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
|
| 22 |
+
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
|
| 23 |
+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
|
| 24 |
+
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
| 25 |
+
* *
|
| 26 |
+
* Except as contained in this notice, the name(s) of the above copyright *
|
| 27 |
+
* holders shall not be used in advertising or otherwise to promote the *
|
| 28 |
+
* sale, use or other dealings in this Software without prior written *
|
| 29 |
+
* authorization. *
|
| 30 |
+
****************************************************************************/
|
| 31 |
+
|
| 32 |
+
#ifndef NCURSES_CURSESW_H_incl
|
| 33 |
+
#define NCURSES_CURSESW_H_incl 1
|
| 34 |
+
|
| 35 |
+
// $Id: cursesw.h,v 1.59 2022/08/20 20:52:15 tom Exp $
|
| 36 |
+
|
| 37 |
+
extern "C" {
|
| 38 |
+
# include <ncursesw/curses.h>
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
#if defined(BUILDING_NCURSES_CXX)
|
| 42 |
+
# define NCURSES_CXX_IMPEXP NCURSES_EXPORT_GENERAL_EXPORT
|
| 43 |
+
#else
|
| 44 |
+
# define NCURSES_CXX_IMPEXP NCURSES_EXPORT_GENERAL_IMPORT
|
| 45 |
+
#endif
|
| 46 |
+
|
| 47 |
+
#define NCURSES_CXX_WRAPPED_VAR(type,name) extern NCURSES_CXX_IMPEXP type NCURSES_PUBLIC_VAR(name)(void)
|
| 48 |
+
|
| 49 |
+
#define NCURSES_CXX_EXPORT(type) NCURSES_CXX_IMPEXP type NCURSES_API
|
| 50 |
+
#define NCURSES_CXX_EXPORT_VAR(type) NCURSES_CXX_IMPEXP type
|
| 51 |
+
|
| 52 |
+
#include <ncursesw/etip.h>
|
| 53 |
+
|
| 54 |
+
/* SCO 3.2v4 curses.h includes term.h, which defines lines as a macro.
|
| 55 |
+
Undefine it here, because NCursesWindow uses lines as a method. */
|
| 56 |
+
#undef lines
|
| 57 |
+
|
| 58 |
+
/* "Convert" macros to inlines. We'll define it as another symbol to avoid
|
| 59 |
+
* conflict with library symbols.
|
| 60 |
+
*/
|
| 61 |
+
#undef UNDEF
|
| 62 |
+
#define UNDEF(name) CUR_ ##name
|
| 63 |
+
|
| 64 |
+
#ifdef addch
|
| 65 |
+
inline int UNDEF(addch)(chtype ch) { return addch(ch); }
|
| 66 |
+
#undef addch
|
| 67 |
+
#define addch UNDEF(addch)
|
| 68 |
+
#endif
|
| 69 |
+
|
| 70 |
+
#ifdef addchstr
|
| 71 |
+
inline int UNDEF(addchstr)(chtype *at) { return addchstr(at); }
|
| 72 |
+
#undef addchstr
|
| 73 |
+
#define addchstr UNDEF(addchstr)
|
| 74 |
+
#endif
|
| 75 |
+
|
| 76 |
+
#ifdef addnstr
|
| 77 |
+
inline int UNDEF(addnstr)(const char *str, int n)
|
| 78 |
+
{ return addnstr(str, n); }
|
| 79 |
+
#undef addnstr
|
| 80 |
+
#define addnstr UNDEF(addnstr)
|
| 81 |
+
#endif
|
| 82 |
+
|
| 83 |
+
#ifdef addstr
|
| 84 |
+
inline int UNDEF(addstr)(const char * str) { return addstr(str); }
|
| 85 |
+
#undef addstr
|
| 86 |
+
#define addstr UNDEF(addstr)
|
| 87 |
+
#endif
|
| 88 |
+
|
| 89 |
+
#ifdef attroff
|
| 90 |
+
inline int UNDEF(attroff)(chtype at) { return attroff(at); }
|
| 91 |
+
#undef attroff
|
| 92 |
+
#define attroff UNDEF(attroff)
|
| 93 |
+
#endif
|
| 94 |
+
|
| 95 |
+
#ifdef attron
|
| 96 |
+
inline int UNDEF(attron)(chtype at) { return attron(at); }
|
| 97 |
+
#undef attron
|
| 98 |
+
#define attron UNDEF(attron)
|
| 99 |
+
#endif
|
| 100 |
+
|
| 101 |
+
#ifdef attrset
|
| 102 |
+
inline chtype UNDEF(attrset)(chtype at) { return attrset(at); }
|
| 103 |
+
#undef attrset
|
| 104 |
+
#define attrset UNDEF(attrset)
|
| 105 |
+
#endif
|
| 106 |
+
|
| 107 |
+
#ifdef bkgd
|
| 108 |
+
inline int UNDEF(bkgd)(chtype ch) { return bkgd(ch); }
|
| 109 |
+
#undef bkgd
|
| 110 |
+
#define bkgd UNDEF(bkgd)
|
| 111 |
+
#endif
|
| 112 |
+
|
| 113 |
+
#ifdef bkgdset
|
| 114 |
+
inline void UNDEF(bkgdset)(chtype ch) { bkgdset(ch); }
|
| 115 |
+
#undef bkgdset
|
| 116 |
+
#define bkgdset UNDEF(bkgdset)
|
| 117 |
+
#endif
|
| 118 |
+
|
| 119 |
+
#ifdef border
|
| 120 |
+
inline int UNDEF(border)(chtype ls, chtype rs, chtype ts, chtype bs, chtype tl, chtype tr, chtype bl, chtype br)
|
| 121 |
+
{ return border(ls, rs, ts, bs, tl, tr, bl, br); }
|
| 122 |
+
#undef border
|
| 123 |
+
#define border UNDEF(border)
|
| 124 |
+
#endif
|
| 125 |
+
|
| 126 |
+
#ifdef box
|
| 127 |
+
inline int UNDEF(box)(WINDOW *win, int v, int h) { return box(win, v, h); }
|
| 128 |
+
#undef box
|
| 129 |
+
#define box UNDEF(box)
|
| 130 |
+
#endif
|
| 131 |
+
|
| 132 |
+
#ifdef chgat
|
| 133 |
+
inline int UNDEF(chgat)(int n, attr_t attr, NCURSES_PAIRS_T color, const void *opts) {
|
| 134 |
+
return chgat(n, attr, color, opts); }
|
| 135 |
+
#undef chgat
|
| 136 |
+
#define chgat UNDEF(chgat)
|
| 137 |
+
#endif
|
| 138 |
+
|
| 139 |
+
#ifdef clear
|
| 140 |
+
inline int UNDEF(clear)() { return clear(); }
|
| 141 |
+
#undef clear
|
| 142 |
+
#define clear UNDEF(clear)
|
| 143 |
+
#endif
|
| 144 |
+
|
| 145 |
+
#ifdef clearok
|
| 146 |
+
inline int UNDEF(clearok)(WINDOW* win, bool bf) { return clearok(win, bf); }
|
| 147 |
+
#undef clearok
|
| 148 |
+
#define clearok UNDEF(clearok)
|
| 149 |
+
#else
|
| 150 |
+
extern "C" NCURSES_IMPEXP int NCURSES_API clearok(WINDOW*, bool);
|
| 151 |
+
#endif
|
| 152 |
+
|
| 153 |
+
#ifdef clrtobot
|
| 154 |
+
inline int UNDEF(clrtobot)() { return clrtobot(); }
|
| 155 |
+
#undef clrtobot
|
| 156 |
+
#define clrtobot UNDEF(clrtobot)
|
| 157 |
+
#endif
|
| 158 |
+
|
| 159 |
+
#ifdef clrtoeol
|
| 160 |
+
inline int UNDEF(clrtoeol)() { return clrtoeol(); }
|
| 161 |
+
#undef clrtoeol
|
| 162 |
+
#define clrtoeol UNDEF(clrtoeol)
|
| 163 |
+
#endif
|
| 164 |
+
|
| 165 |
+
#ifdef color_set
|
| 166 |
+
inline chtype UNDEF(color_set)(NCURSES_PAIRS_T p, void* opts) { return color_set(p, opts); }
|
| 167 |
+
#undef color_set
|
| 168 |
+
#define color_set UNDEF(color_set)
|
| 169 |
+
#endif
|
| 170 |
+
|
| 171 |
+
#ifdef crmode
|
| 172 |
+
inline int UNDEF(crmode)(void) { return crmode(); }
|
| 173 |
+
#undef crmode
|
| 174 |
+
#define crmode UNDEF(crmode)
|
| 175 |
+
#endif
|
| 176 |
+
|
| 177 |
+
#ifdef delch
|
| 178 |
+
inline int UNDEF(delch)() { return delch(); }
|
| 179 |
+
#undef delch
|
| 180 |
+
#define delch UNDEF(delch)
|
| 181 |
+
#endif
|
| 182 |
+
|
| 183 |
+
#ifdef deleteln
|
| 184 |
+
inline int UNDEF(deleteln)() { return deleteln(); }
|
| 185 |
+
#undef deleteln
|
| 186 |
+
#define deleteln UNDEF(deleteln)
|
| 187 |
+
#endif
|
| 188 |
+
|
| 189 |
+
#ifdef echochar
|
| 190 |
+
inline int UNDEF(echochar)(chtype ch) { return echochar(ch); }
|
| 191 |
+
#undef echochar
|
| 192 |
+
#define echochar UNDEF(echochar)
|
| 193 |
+
#endif
|
| 194 |
+
|
| 195 |
+
#ifdef erase
|
| 196 |
+
inline int UNDEF(erase)() { return erase(); }
|
| 197 |
+
#undef erase
|
| 198 |
+
#define erase UNDEF(erase)
|
| 199 |
+
#endif
|
| 200 |
+
|
| 201 |
+
#ifdef fixterm
|
| 202 |
+
inline int UNDEF(fixterm)(void) { return fixterm(); }
|
| 203 |
+
#undef fixterm
|
| 204 |
+
#define fixterm UNDEF(fixterm)
|
| 205 |
+
#endif
|
| 206 |
+
|
| 207 |
+
#ifdef flushok
|
| 208 |
+
inline int UNDEF(flushok)(WINDOW* _win, bool _bf) {
|
| 209 |
+
return flushok(_win, _bf); }
|
| 210 |
+
#undef flushok
|
| 211 |
+
#define flushok UNDEF(flushok)
|
| 212 |
+
#else
|
| 213 |
+
#define _no_flushok
|
| 214 |
+
#endif
|
| 215 |
+
|
| 216 |
+
#ifdef getattrs
|
| 217 |
+
inline int UNDEF(getattrs)(WINDOW *win) { return getattrs(win); }
|
| 218 |
+
#undef getattrs
|
| 219 |
+
#define getattrs UNDEF(getattrs)
|
| 220 |
+
#endif
|
| 221 |
+
|
| 222 |
+
#ifdef getbegyx
|
| 223 |
+
inline void UNDEF(getbegyx)(WINDOW* win, int& y, int& x) { getbegyx(win, y, x); }
|
| 224 |
+
#undef getbegyx
|
| 225 |
+
#define getbegyx UNDEF(getbegyx)
|
| 226 |
+
#endif
|
| 227 |
+
|
| 228 |
+
#ifdef getbkgd
|
| 229 |
+
inline chtype UNDEF(getbkgd)(const WINDOW *win) { return getbkgd(win); }
|
| 230 |
+
#undef getbkgd
|
| 231 |
+
#define getbkgd UNDEF(getbkgd)
|
| 232 |
+
#endif
|
| 233 |
+
|
| 234 |
+
#ifdef getch
|
| 235 |
+
inline int UNDEF(getch)() { return getch(); }
|
| 236 |
+
#undef getch
|
| 237 |
+
#define getch UNDEF(getch)
|
| 238 |
+
#endif
|
| 239 |
+
|
| 240 |
+
#ifdef getmaxyx
|
| 241 |
+
inline void UNDEF(getmaxyx)(WINDOW* win, int& y, int& x) { getmaxyx(win, y, x); }
|
| 242 |
+
#undef getmaxyx
|
| 243 |
+
#define getmaxyx UNDEF(getmaxyx)
|
| 244 |
+
#endif
|
| 245 |
+
|
| 246 |
+
#ifdef getnstr
|
| 247 |
+
inline int UNDEF(getnstr)(char *_str, int n) { return getnstr(_str, n); }
|
| 248 |
+
#undef getnstr
|
| 249 |
+
#define getnstr UNDEF(getnstr)
|
| 250 |
+
#endif
|
| 251 |
+
|
| 252 |
+
#ifdef getparyx
|
| 253 |
+
inline void UNDEF(getparyx)(WINDOW* win, int& y, int& x) { getparyx(win, y, x); }
|
| 254 |
+
#undef getparyx
|
| 255 |
+
#define getparyx UNDEF(getparyx)
|
| 256 |
+
#endif
|
| 257 |
+
|
| 258 |
+
#ifdef getstr
|
| 259 |
+
inline int UNDEF(getstr)(char *_str) { return getstr(_str); }
|
| 260 |
+
#undef getstr
|
| 261 |
+
#define getstr UNDEF(getstr)
|
| 262 |
+
#endif
|
| 263 |
+
|
| 264 |
+
#ifdef getyx
|
| 265 |
+
inline void UNDEF(getyx)(const WINDOW* win, int& y, int& x) {
|
| 266 |
+
getyx(win, y, x); }
|
| 267 |
+
#undef getyx
|
| 268 |
+
#define getyx UNDEF(getyx)
|
| 269 |
+
#endif
|
| 270 |
+
|
| 271 |
+
#ifdef hline
|
| 272 |
+
inline int UNDEF(hline)(chtype ch, int n) { return hline(ch, n); }
|
| 273 |
+
#undef hline
|
| 274 |
+
#define hline UNDEF(hline)
|
| 275 |
+
#endif
|
| 276 |
+
|
| 277 |
+
#ifdef inch
|
| 278 |
+
inline chtype UNDEF(inch)() { return inch(); }
|
| 279 |
+
#undef inch
|
| 280 |
+
#define inch UNDEF(inch)
|
| 281 |
+
#endif
|
| 282 |
+
|
| 283 |
+
#ifdef inchstr
|
| 284 |
+
inline int UNDEF(inchstr)(chtype *str) { return inchstr(str); }
|
| 285 |
+
#undef inchstr
|
| 286 |
+
#define inchstr UNDEF(inchstr)
|
| 287 |
+
#endif
|
| 288 |
+
|
| 289 |
+
#ifdef innstr
|
| 290 |
+
inline int UNDEF(innstr)(char *_str, int n) { return innstr(_str, n); }
|
| 291 |
+
#undef innstr
|
| 292 |
+
#define innstr UNDEF(innstr)
|
| 293 |
+
#endif
|
| 294 |
+
|
| 295 |
+
#ifdef insch
|
| 296 |
+
inline int UNDEF(insch)(chtype c) { return insch(c); }
|
| 297 |
+
#undef insch
|
| 298 |
+
#define insch UNDEF(insch)
|
| 299 |
+
#endif
|
| 300 |
+
|
| 301 |
+
#ifdef insdelln
|
| 302 |
+
inline int UNDEF(insdelln)(int n) { return insdelln(n); }
|
| 303 |
+
#undef insdelln
|
| 304 |
+
#define insdelln UNDEF(insdelln)
|
| 305 |
+
#endif
|
| 306 |
+
|
| 307 |
+
#ifdef insertln
|
| 308 |
+
inline int UNDEF(insertln)() { return insertln(); }
|
| 309 |
+
#undef insertln
|
| 310 |
+
#define insertln UNDEF(insertln)
|
| 311 |
+
#endif
|
| 312 |
+
|
| 313 |
+
#ifdef insnstr
|
| 314 |
+
inline int UNDEF(insnstr)(const char *_str, int n) {
|
| 315 |
+
return insnstr(_str, n); }
|
| 316 |
+
#undef insnstr
|
| 317 |
+
#define insnstr UNDEF(insnstr)
|
| 318 |
+
#endif
|
| 319 |
+
|
| 320 |
+
#ifdef insstr
|
| 321 |
+
inline int UNDEF(insstr)(const char *_str) {
|
| 322 |
+
return insstr(_str); }
|
| 323 |
+
#undef insstr
|
| 324 |
+
#define insstr UNDEF(insstr)
|
| 325 |
+
#endif
|
| 326 |
+
|
| 327 |
+
#ifdef instr
|
| 328 |
+
inline int UNDEF(instr)(char *_str) { return instr(_str); }
|
| 329 |
+
#undef instr
|
| 330 |
+
#define instr UNDEF(instr)
|
| 331 |
+
#endif
|
| 332 |
+
|
| 333 |
+
#ifdef intrflush
|
| 334 |
+
inline void UNDEF(intrflush)(WINDOW *win, bool bf) { intrflush(); }
|
| 335 |
+
#undef intrflush
|
| 336 |
+
#define intrflush UNDEF(intrflush)
|
| 337 |
+
#endif
|
| 338 |
+
|
| 339 |
+
#ifdef is_linetouched
|
| 340 |
+
inline int UNDEF(is_linetouched)(WINDOW *w, int l) { return is_linetouched(w,l); }
|
| 341 |
+
#undef is_linetouched
|
| 342 |
+
#define is_linetouched UNDEF(is_linetouched)
|
| 343 |
+
#endif
|
| 344 |
+
|
| 345 |
+
#ifdef leaveok
|
| 346 |
+
inline int UNDEF(leaveok)(WINDOW* win, bool bf) { return leaveok(win, bf); }
|
| 347 |
+
#undef leaveok
|
| 348 |
+
#define leaveok UNDEF(leaveok)
|
| 349 |
+
#else
|
| 350 |
+
extern "C" NCURSES_IMPEXP int NCURSES_API leaveok(WINDOW* win, bool bf);
|
| 351 |
+
#endif
|
| 352 |
+
|
| 353 |
+
#ifdef move
|
| 354 |
+
inline int UNDEF(move)(int x, int y) { return move(x, y); }
|
| 355 |
+
#undef move
|
| 356 |
+
#define move UNDEF(move)
|
| 357 |
+
#endif
|
| 358 |
+
|
| 359 |
+
#ifdef mvaddch
|
| 360 |
+
inline int UNDEF(mvaddch)(int y, int x, chtype ch)
|
| 361 |
+
{ return mvaddch(y, x, ch); }
|
| 362 |
+
#undef mvaddch
|
| 363 |
+
#define mvaddch UNDEF(mvaddch)
|
| 364 |
+
#endif
|
| 365 |
+
|
| 366 |
+
#ifdef mvaddnstr
|
| 367 |
+
inline int UNDEF(mvaddnstr)(int y, int x, const char *str, int n)
|
| 368 |
+
{ return mvaddnstr(y, x, str, n); }
|
| 369 |
+
#undef mvaddnstr
|
| 370 |
+
#define mvaddnstr UNDEF(mvaddnstr)
|
| 371 |
+
#endif
|
| 372 |
+
|
| 373 |
+
#ifdef mvaddstr
|
| 374 |
+
inline int UNDEF(mvaddstr)(int y, int x, const char * str)
|
| 375 |
+
{ return mvaddstr(y, x, str); }
|
| 376 |
+
#undef mvaddstr
|
| 377 |
+
#define mvaddstr UNDEF(mvaddstr)
|
| 378 |
+
#endif
|
| 379 |
+
|
| 380 |
+
#ifdef mvchgat
|
| 381 |
+
inline int UNDEF(mvchgat)(int y, int x, int n,
|
| 382 |
+
attr_t attr, NCURSES_PAIRS_T color, const void *opts) {
|
| 383 |
+
return mvchgat(y, x, n, attr, color, opts); }
|
| 384 |
+
#undef mvchgat
|
| 385 |
+
#define mvchgat UNDEF(mvchgat)
|
| 386 |
+
#endif
|
| 387 |
+
|
| 388 |
+
#ifdef mvdelch
|
| 389 |
+
inline int UNDEF(mvdelch)(int y, int x) { return mvdelch(y, x);}
|
| 390 |
+
#undef mvdelch
|
| 391 |
+
#define mvdelch UNDEF(mvdelch)
|
| 392 |
+
#endif
|
| 393 |
+
|
| 394 |
+
#ifdef mvgetch
|
| 395 |
+
inline int UNDEF(mvgetch)(int y, int x) { return mvgetch(y, x);}
|
| 396 |
+
#undef mvgetch
|
| 397 |
+
#define mvgetch UNDEF(mvgetch)
|
| 398 |
+
#endif
|
| 399 |
+
|
| 400 |
+
#ifdef mvgetnstr
|
| 401 |
+
inline int UNDEF(mvgetnstr)(int y, int x, char *str, int n) {
|
| 402 |
+
return mvgetnstr(y, x, str, n);}
|
| 403 |
+
#undef mvgetnstr
|
| 404 |
+
#define mvgetnstr UNDEF(mvgetnstr)
|
| 405 |
+
#endif
|
| 406 |
+
|
| 407 |
+
#ifdef mvgetstr
|
| 408 |
+
inline int UNDEF(mvgetstr)(int y, int x, char *str) {return mvgetstr(y, x, str);}
|
| 409 |
+
#undef mvgetstr
|
| 410 |
+
#define mvgetstr UNDEF(mvgetstr)
|
| 411 |
+
#endif
|
| 412 |
+
|
| 413 |
+
#ifdef mvinch
|
| 414 |
+
inline chtype UNDEF(mvinch)(int y, int x) { return mvinch(y, x);}
|
| 415 |
+
#undef mvinch
|
| 416 |
+
#define mvinch UNDEF(mvinch)
|
| 417 |
+
#endif
|
| 418 |
+
|
| 419 |
+
#ifdef mvinnstr
|
| 420 |
+
inline int UNDEF(mvinnstr)(int y, int x, char *_str, int n) {
|
| 421 |
+
return mvinnstr(y, x, _str, n); }
|
| 422 |
+
#undef mvinnstr
|
| 423 |
+
#define mvinnstr UNDEF(mvinnstr)
|
| 424 |
+
#endif
|
| 425 |
+
|
| 426 |
+
#ifdef mvinsch
|
| 427 |
+
inline int UNDEF(mvinsch)(int y, int x, chtype c)
|
| 428 |
+
{ return mvinsch(y, x, c); }
|
| 429 |
+
#undef mvinsch
|
| 430 |
+
#define mvinsch UNDEF(mvinsch)
|
| 431 |
+
#endif
|
| 432 |
+
|
| 433 |
+
#ifdef mvinsnstr
|
| 434 |
+
inline int UNDEF(mvinsnstr)(int y, int x, const char *_str, int n) {
|
| 435 |
+
return mvinsnstr(y, x, _str, n); }
|
| 436 |
+
#undef mvinsnstr
|
| 437 |
+
#define mvinsnstr UNDEF(mvinsnstr)
|
| 438 |
+
#endif
|
| 439 |
+
|
| 440 |
+
#ifdef mvinsstr
|
| 441 |
+
inline int UNDEF(mvinsstr)(int y, int x, const char *_str) {
|
| 442 |
+
return mvinsstr(y, x, _str); }
|
| 443 |
+
#undef mvinsstr
|
| 444 |
+
#define mvinsstr UNDEF(mvinsstr)
|
| 445 |
+
#endif
|
| 446 |
+
|
| 447 |
+
#ifdef mvwaddch
|
| 448 |
+
inline int UNDEF(mvwaddch)(WINDOW *win, int y, int x, const chtype ch)
|
| 449 |
+
{ return mvwaddch(win, y, x, ch); }
|
| 450 |
+
#undef mvwaddch
|
| 451 |
+
#define mvwaddch UNDEF(mvwaddch)
|
| 452 |
+
#endif
|
| 453 |
+
|
| 454 |
+
#ifdef mvwaddchnstr
|
| 455 |
+
inline int UNDEF(mvwaddchnstr)(WINDOW *win, int y, int x, const chtype *str, int n)
|
| 456 |
+
{ return mvwaddchnstr(win, y, x, str, n); }
|
| 457 |
+
#undef mvwaddchnstr
|
| 458 |
+
#define mvwaddchnstr UNDEF(mvwaddchnstr)
|
| 459 |
+
#endif
|
| 460 |
+
|
| 461 |
+
#ifdef mvwaddchstr
|
| 462 |
+
inline int UNDEF(mvwaddchstr)(WINDOW *win, int y, int x, const chtype *str)
|
| 463 |
+
{ return mvwaddchstr(win, y, x, str); }
|
| 464 |
+
#undef mvwaddchstr
|
| 465 |
+
#define mvwaddchstr UNDEF(mvwaddchstr)
|
| 466 |
+
#endif
|
| 467 |
+
|
| 468 |
+
#ifdef mvwaddnstr
|
| 469 |
+
inline int UNDEF(mvwaddnstr)(WINDOW *win, int y, int x, const char *str, int n)
|
| 470 |
+
{ return mvwaddnstr(win, y, x, str, n); }
|
| 471 |
+
#undef mvwaddnstr
|
| 472 |
+
#define mvwaddnstr UNDEF(mvwaddnstr)
|
| 473 |
+
#endif
|
| 474 |
+
|
| 475 |
+
#ifdef mvwaddstr
|
| 476 |
+
inline int UNDEF(mvwaddstr)(WINDOW *win, int y, int x, const char * str)
|
| 477 |
+
{ return mvwaddstr(win, y, x, str); }
|
| 478 |
+
#undef mvwaddstr
|
| 479 |
+
#define mvwaddstr UNDEF(mvwaddstr)
|
| 480 |
+
#endif
|
| 481 |
+
|
| 482 |
+
#ifdef mvwchgat
|
| 483 |
+
inline int UNDEF(mvwchgat)(WINDOW *win, int y, int x, int n,
|
| 484 |
+
attr_t attr, NCURSES_PAIRS_T color, const void *opts) {
|
| 485 |
+
return mvwchgat(win, y, x, n, attr, color, opts); }
|
| 486 |
+
#undef mvwchgat
|
| 487 |
+
#define mvwchgat UNDEF(mvwchgat)
|
| 488 |
+
#endif
|
| 489 |
+
|
| 490 |
+
#ifdef mvwdelch
|
| 491 |
+
inline int UNDEF(mvwdelch)(WINDOW *win, int y, int x)
|
| 492 |
+
{ return mvwdelch(win, y, x); }
|
| 493 |
+
#undef mvwdelch
|
| 494 |
+
#define mvwdelch UNDEF(mvwdelch)
|
| 495 |
+
#endif
|
| 496 |
+
|
| 497 |
+
#ifdef mvwgetch
|
| 498 |
+
inline int UNDEF(mvwgetch)(WINDOW *win, int y, int x) { return mvwgetch(win, y, x);}
|
| 499 |
+
#undef mvwgetch
|
| 500 |
+
#define mvwgetch UNDEF(mvwgetch)
|
| 501 |
+
#endif
|
| 502 |
+
|
| 503 |
+
#ifdef mvwgetnstr
|
| 504 |
+
inline int UNDEF(mvwgetnstr)(WINDOW *win, int y, int x, char *str, int n)
|
| 505 |
+
{return mvwgetnstr(win, y, x, str, n);}
|
| 506 |
+
#undef mvwgetnstr
|
| 507 |
+
#define mvwgetnstr UNDEF(mvwgetnstr)
|
| 508 |
+
#endif
|
| 509 |
+
|
| 510 |
+
#ifdef mvwgetstr
|
| 511 |
+
inline int UNDEF(mvwgetstr)(WINDOW *win, int y, int x, char *str)
|
| 512 |
+
{return mvwgetstr(win, y, x, str);}
|
| 513 |
+
#undef mvwgetstr
|
| 514 |
+
#define mvwgetstr UNDEF(mvwgetstr)
|
| 515 |
+
#endif
|
| 516 |
+
|
| 517 |
+
#ifdef mvwhline
|
| 518 |
+
inline int UNDEF(mvwhline)(WINDOW *win, int y, int x, chtype c, int n) {
|
| 519 |
+
return mvwhline(win, y, x, c, n); }
|
| 520 |
+
#undef mvwhline
|
| 521 |
+
#define mvwhline UNDEF(mvwhline)
|
| 522 |
+
#endif
|
| 523 |
+
|
| 524 |
+
#ifdef mvwinch
|
| 525 |
+
inline chtype UNDEF(mvwinch)(WINDOW *win, int y, int x) {
|
| 526 |
+
return mvwinch(win, y, x);}
|
| 527 |
+
#undef mvwinch
|
| 528 |
+
#define mvwinch UNDEF(mvwinch)
|
| 529 |
+
#endif
|
| 530 |
+
|
| 531 |
+
#ifdef mvwinchnstr
|
| 532 |
+
inline int UNDEF(mvwinchnstr)(WINDOW *win, int y, int x, chtype *str, int n) { return mvwinchnstr(win, y, x, str, n); }
|
| 533 |
+
#undef mvwinchnstr
|
| 534 |
+
#define mvwinchnstr UNDEF(mvwinchnstr)
|
| 535 |
+
#endif
|
| 536 |
+
|
| 537 |
+
#ifdef mvwinchstr
|
| 538 |
+
inline int UNDEF(mvwinchstr)(WINDOW *win, int y, int x, chtype *str) { return mvwinchstr(win, y, x, str); }
|
| 539 |
+
#undef mvwinchstr
|
| 540 |
+
#define mvwinchstr UNDEF(mvwinchstr)
|
| 541 |
+
#endif
|
| 542 |
+
|
| 543 |
+
#ifdef mvwinnstr
|
| 544 |
+
inline int UNDEF(mvwinnstr)(WINDOW *win, int y, int x, char *_str, int n) {
|
| 545 |
+
return mvwinnstr(win, y, x, _str, n); }
|
| 546 |
+
#undef mvwinnstr
|
| 547 |
+
#define mvwinnstr UNDEF(mvwinnstr)
|
| 548 |
+
#endif
|
| 549 |
+
|
| 550 |
+
#ifdef mvwinsch
|
| 551 |
+
inline int UNDEF(mvwinsch)(WINDOW *win, int y, int x, chtype c)
|
| 552 |
+
{ return mvwinsch(win, y, x, c); }
|
| 553 |
+
#undef mvwinsch
|
| 554 |
+
#define mvwinsch UNDEF(mvwinsch)
|
| 555 |
+
#endif
|
| 556 |
+
|
| 557 |
+
#ifdef mvwinsnstr
|
| 558 |
+
inline int UNDEF(mvwinsnstr)(WINDOW *w, int y, int x, const char *_str, int n) {
|
| 559 |
+
return mvwinsnstr(w, y, x, _str, n); }
|
| 560 |
+
#undef mvwinsnstr
|
| 561 |
+
#define mvwinsnstr UNDEF(mvwinsnstr)
|
| 562 |
+
#endif
|
| 563 |
+
|
| 564 |
+
#ifdef mvwinsstr
|
| 565 |
+
inline int UNDEF(mvwinsstr)(WINDOW *w, int y, int x, const char *_str) {
|
| 566 |
+
return mvwinsstr(w, y, x, _str); }
|
| 567 |
+
#undef mvwinsstr
|
| 568 |
+
#define mvwinsstr UNDEF(mvwinsstr)
|
| 569 |
+
#endif
|
| 570 |
+
|
| 571 |
+
#ifdef mvwvline
|
| 572 |
+
inline int UNDEF(mvwvline)(WINDOW *win, int y, int x, chtype c, int n) {
|
| 573 |
+
return mvwvline(win, y, x, c, n); }
|
| 574 |
+
#undef mvwvline
|
| 575 |
+
#define mvwvline UNDEF(mvwvline)
|
| 576 |
+
#endif
|
| 577 |
+
|
| 578 |
+
#ifdef napms
|
| 579 |
+
inline void UNDEF(napms)(unsigned long x) { napms(x); }
|
| 580 |
+
#undef napms
|
| 581 |
+
#define napms UNDEF(napms)
|
| 582 |
+
#endif
|
| 583 |
+
|
| 584 |
+
#ifdef nocrmode
|
| 585 |
+
inline int UNDEF(nocrmode)(void) { return nocrmode(); }
|
| 586 |
+
#undef nocrmode
|
| 587 |
+
#define nocrmode UNDEF(nocrmode)
|
| 588 |
+
#endif
|
| 589 |
+
|
| 590 |
+
#ifdef nodelay
|
| 591 |
+
inline void UNDEF(nodelay)() { nodelay(); }
|
| 592 |
+
#undef nodelay
|
| 593 |
+
#define nodelay UNDEF(nodelay)
|
| 594 |
+
#endif
|
| 595 |
+
|
| 596 |
+
#ifdef redrawwin
|
| 597 |
+
inline int UNDEF(redrawwin)(WINDOW *win) { return redrawwin(win); }
|
| 598 |
+
#undef redrawwin
|
| 599 |
+
#define redrawwin UNDEF(redrawwin)
|
| 600 |
+
#endif
|
| 601 |
+
|
| 602 |
+
#ifdef refresh
|
| 603 |
+
inline int UNDEF(refresh)() { return refresh(); }
|
| 604 |
+
#undef refresh
|
| 605 |
+
#define refresh UNDEF(refresh)
|
| 606 |
+
#endif
|
| 607 |
+
|
| 608 |
+
#ifdef resetterm
|
| 609 |
+
inline int UNDEF(resetterm)(void) { return resetterm(); }
|
| 610 |
+
#undef resetterm
|
| 611 |
+
#define resetterm UNDEF(resetterm)
|
| 612 |
+
#endif
|
| 613 |
+
|
| 614 |
+
#ifdef saveterm
|
| 615 |
+
inline int UNDEF(saveterm)(void) { return saveterm(); }
|
| 616 |
+
#undef saveterm
|
| 617 |
+
#define saveterm UNDEF(saveterm)
|
| 618 |
+
#endif
|
| 619 |
+
|
| 620 |
+
#ifdef scrl
|
| 621 |
+
inline int UNDEF(scrl)(int l) { return scrl(l); }
|
| 622 |
+
#undef scrl
|
| 623 |
+
#define scrl UNDEF(scrl)
|
| 624 |
+
#endif
|
| 625 |
+
|
| 626 |
+
#ifdef scroll
|
| 627 |
+
inline int UNDEF(scroll)(WINDOW *win) { return scroll(win); }
|
| 628 |
+
#undef scroll
|
| 629 |
+
#define scroll UNDEF(scroll)
|
| 630 |
+
#endif
|
| 631 |
+
|
| 632 |
+
#ifdef scrollok
|
| 633 |
+
inline int UNDEF(scrollok)(WINDOW* win, bool bf) { return scrollok(win, bf); }
|
| 634 |
+
#undef scrollok
|
| 635 |
+
#define scrollok UNDEF(scrollok)
|
| 636 |
+
#else
|
| 637 |
+
#if defined(__NCURSES_H)
|
| 638 |
+
extern "C" NCURSES_IMPEXP int NCURSES_API scrollok(WINDOW*, bool);
|
| 639 |
+
#else
|
| 640 |
+
extern "C" NCURSES_IMPEXP int NCURSES_API scrollok(WINDOW*, char);
|
| 641 |
+
#endif
|
| 642 |
+
#endif
|
| 643 |
+
|
| 644 |
+
#ifdef setscrreg
|
| 645 |
+
inline int UNDEF(setscrreg)(int t, int b) { return setscrreg(t, b); }
|
| 646 |
+
#undef setscrreg
|
| 647 |
+
#define setscrreg UNDEF(setscrreg)
|
| 648 |
+
#endif
|
| 649 |
+
|
| 650 |
+
#ifdef standend
|
| 651 |
+
inline int UNDEF(standend)() { return standend(); }
|
| 652 |
+
#undef standend
|
| 653 |
+
#define standend UNDEF(standend)
|
| 654 |
+
#endif
|
| 655 |
+
|
| 656 |
+
#ifdef standout
|
| 657 |
+
inline int UNDEF(standout)() { return standout(); }
|
| 658 |
+
#undef standout
|
| 659 |
+
#define standout UNDEF(standout)
|
| 660 |
+
#endif
|
| 661 |
+
|
| 662 |
+
#ifdef subpad
|
| 663 |
+
inline WINDOW *UNDEF(subpad)(WINDOW *p, int l, int c, int y, int x)
|
| 664 |
+
{ return derwin(p, l, c, y, x); }
|
| 665 |
+
#undef subpad
|
| 666 |
+
#define subpad UNDEF(subpad)
|
| 667 |
+
#endif
|
| 668 |
+
|
| 669 |
+
#ifdef timeout
|
| 670 |
+
inline void UNDEF(timeout)(int delay) { timeout(delay); }
|
| 671 |
+
#undef timeout
|
| 672 |
+
#define timeout UNDEF(timeout)
|
| 673 |
+
#endif
|
| 674 |
+
|
| 675 |
+
#ifdef touchline
|
| 676 |
+
inline int UNDEF(touchline)(WINDOW *win, int s, int c)
|
| 677 |
+
{ return touchline(win, s, c); }
|
| 678 |
+
#undef touchline
|
| 679 |
+
#define touchline UNDEF(touchline)
|
| 680 |
+
#endif
|
| 681 |
+
|
| 682 |
+
#ifdef touchwin
|
| 683 |
+
inline int UNDEF(touchwin)(WINDOW *win) { return touchwin(win); }
|
| 684 |
+
#undef touchwin
|
| 685 |
+
#define touchwin UNDEF(touchwin)
|
| 686 |
+
#endif
|
| 687 |
+
|
| 688 |
+
#ifdef untouchwin
|
| 689 |
+
inline int UNDEF(untouchwin)(WINDOW *win) { return untouchwin(win); }
|
| 690 |
+
#undef untouchwin
|
| 691 |
+
#define untouchwin UNDEF(untouchwin)
|
| 692 |
+
#endif
|
| 693 |
+
|
| 694 |
+
#ifdef vline
|
| 695 |
+
inline int UNDEF(vline)(chtype ch, int n) { return vline(ch, n); }
|
| 696 |
+
#undef vline
|
| 697 |
+
#define vline UNDEF(vline)
|
| 698 |
+
#endif
|
| 699 |
+
|
| 700 |
+
#ifdef waddchstr
|
| 701 |
+
inline int UNDEF(waddchstr)(WINDOW *win, chtype *at) { return waddchstr(win, at); }
|
| 702 |
+
#undef waddchstr
|
| 703 |
+
#define waddchstr UNDEF(waddchstr)
|
| 704 |
+
#endif
|
| 705 |
+
|
| 706 |
+
#ifdef waddstr
|
| 707 |
+
inline int UNDEF(waddstr)(WINDOW *win, char *str) { return waddstr(win, str); }
|
| 708 |
+
#undef waddstr
|
| 709 |
+
#define waddstr UNDEF(waddstr)
|
| 710 |
+
#endif
|
| 711 |
+
|
| 712 |
+
#ifdef wattroff
|
| 713 |
+
inline int UNDEF(wattroff)(WINDOW *win, int att) { return wattroff(win, att); }
|
| 714 |
+
#undef wattroff
|
| 715 |
+
#define wattroff UNDEF(wattroff)
|
| 716 |
+
#endif
|
| 717 |
+
|
| 718 |
+
#ifdef wattrset
|
| 719 |
+
inline int UNDEF(wattrset)(WINDOW *win, int att) { return wattrset(win, att); }
|
| 720 |
+
#undef wattrset
|
| 721 |
+
#define wattrset UNDEF(wattrset)
|
| 722 |
+
#endif
|
| 723 |
+
|
| 724 |
+
#ifdef winch
|
| 725 |
+
inline chtype UNDEF(winch)(const WINDOW* win) { return winch(win); }
|
| 726 |
+
#undef winch
|
| 727 |
+
#define winch UNDEF(winch)
|
| 728 |
+
#endif
|
| 729 |
+
|
| 730 |
+
#ifdef winchnstr
|
| 731 |
+
inline int UNDEF(winchnstr)(WINDOW *win, chtype *str, int n) { return winchnstr(win, str, n); }
|
| 732 |
+
#undef winchnstr
|
| 733 |
+
#define winchnstr UNDEF(winchnstr)
|
| 734 |
+
#endif
|
| 735 |
+
|
| 736 |
+
#ifdef winchstr
|
| 737 |
+
inline int UNDEF(winchstr)(WINDOW *win, chtype *str) { return winchstr(win, str); }
|
| 738 |
+
#undef winchstr
|
| 739 |
+
#define winchstr UNDEF(winchstr)
|
| 740 |
+
#endif
|
| 741 |
+
|
| 742 |
+
#ifdef winsstr
|
| 743 |
+
inline int UNDEF(winsstr)(WINDOW *w, const char *_str) {
|
| 744 |
+
return winsstr(w, _str); }
|
| 745 |
+
#undef winsstr
|
| 746 |
+
#define winsstr UNDEF(winsstr)
|
| 747 |
+
#endif
|
| 748 |
+
|
| 749 |
+
#ifdef wstandend
|
| 750 |
+
inline int UNDEF(wstandend)(WINDOW *win) { return wstandend(win); }
|
| 751 |
+
#undef wstandend
|
| 752 |
+
#define wstandend UNDEF(wstandend)
|
| 753 |
+
#endif
|
| 754 |
+
|
| 755 |
+
#ifdef wstandout
|
| 756 |
+
inline int UNDEF(wstandout)(WINDOW *win) { return wstandout(win); }
|
| 757 |
+
#undef wstandout
|
| 758 |
+
#define wstandout UNDEF(wstandout)
|
| 759 |
+
#endif
|
| 760 |
+
|
| 761 |
+
/*
|
| 762 |
+
*
|
| 763 |
+
* C++ class for windows.
|
| 764 |
+
*
|
| 765 |
+
*/
|
| 766 |
+
|
| 767 |
+
extern "C" int _nc_ripoffline(int, int (*init)(WINDOW*, int));
|
| 768 |
+
extern "C" int _nc_xx_ripoff_init(WINDOW *, int);
|
| 769 |
+
extern "C" int _nc_has_mouse(void);
|
| 770 |
+
|
| 771 |
+
class NCURSES_CXX_IMPEXP NCursesWindow
|
| 772 |
+
{
|
| 773 |
+
friend class NCursesMenu;
|
| 774 |
+
friend class NCursesForm;
|
| 775 |
+
|
| 776 |
+
private:
|
| 777 |
+
static bool b_initialized;
|
| 778 |
+
static void initialize();
|
| 779 |
+
void constructing();
|
| 780 |
+
friend int _nc_xx_ripoff_init(WINDOW *, int);
|
| 781 |
+
|
| 782 |
+
void set_keyboard();
|
| 783 |
+
|
| 784 |
+
NCURSES_COLOR_T getcolor(int getback) const;
|
| 785 |
+
NCURSES_PAIRS_T getPair() const;
|
| 786 |
+
|
| 787 |
+
static int setpalette(NCURSES_COLOR_T fore, NCURSES_COLOR_T back, NCURSES_PAIRS_T pair);
|
| 788 |
+
static int colorInitialized;
|
| 789 |
+
|
| 790 |
+
// This private constructor is only used during the initialization
|
| 791 |
+
// of windows generated by ripoffline() calls.
|
| 792 |
+
NCursesWindow(WINDOW* win, int ncols);
|
| 793 |
+
|
| 794 |
+
protected:
|
| 795 |
+
virtual void err_handler(const char *) const THROWS(NCursesException);
|
| 796 |
+
// Signal an error with the given message text.
|
| 797 |
+
|
| 798 |
+
static long count; // count of all active windows:
|
| 799 |
+
// We rely on the c++ promise that
|
| 800 |
+
// all otherwise uninitialized
|
| 801 |
+
// static class vars are set to 0
|
| 802 |
+
|
| 803 |
+
WINDOW* w; // the curses WINDOW
|
| 804 |
+
|
| 805 |
+
bool alloced; // TRUE if we own the WINDOW
|
| 806 |
+
|
| 807 |
+
NCursesWindow* par; // parent, if subwindow
|
| 808 |
+
NCursesWindow* subwins; // head of subwindows list
|
| 809 |
+
NCursesWindow* sib; // next subwindow of parent
|
| 810 |
+
|
| 811 |
+
void kill_subwindows(); // disable all subwindows
|
| 812 |
+
// Destroy all subwindows.
|
| 813 |
+
|
| 814 |
+
/* Only for use by derived classes. They are then in charge to
|
| 815 |
+
fill the member variables correctly. */
|
| 816 |
+
NCursesWindow();
|
| 817 |
+
|
| 818 |
+
public:
|
| 819 |
+
explicit NCursesWindow(WINDOW* window); // useful only for stdscr
|
| 820 |
+
|
| 821 |
+
NCursesWindow(int nlines, // number of lines
|
| 822 |
+
int ncols, // number of columns
|
| 823 |
+
int begin_y, // line origin
|
| 824 |
+
int begin_x); // col origin
|
| 825 |
+
|
| 826 |
+
NCursesWindow(NCursesWindow& par,// parent window
|
| 827 |
+
int nlines, // number of lines
|
| 828 |
+
int ncols, // number of columns
|
| 829 |
+
int begin_y, // absolute or relative
|
| 830 |
+
int begin_x, // origins:
|
| 831 |
+
char absrel = 'a');// if `a', begin_y & begin_x are
|
| 832 |
+
// absolute screen pos, else if `r', they are relative to par origin
|
| 833 |
+
|
| 834 |
+
NCursesWindow(NCursesWindow& par,// parent window
|
| 835 |
+
bool do_box = TRUE);
|
| 836 |
+
// this is the very common case that we want to create the subwindow that
|
| 837 |
+
// is two lines and two columns smaller and begins at (1,1).
|
| 838 |
+
// We may automatically request the box around it.
|
| 839 |
+
|
| 840 |
+
NCursesWindow& operator=(const NCursesWindow& rhs)
|
| 841 |
+
{
|
| 842 |
+
if (this != &rhs)
|
| 843 |
+
*this = rhs;
|
| 844 |
+
return *this;
|
| 845 |
+
}
|
| 846 |
+
|
| 847 |
+
NCursesWindow(const NCursesWindow& rhs)
|
| 848 |
+
: w(rhs.w), alloced(rhs.alloced), par(rhs.par), subwins(rhs.subwins), sib(rhs.sib)
|
| 849 |
+
{
|
| 850 |
+
}
|
| 851 |
+
|
| 852 |
+
virtual ~NCursesWindow() THROWS(NCursesException);
|
| 853 |
+
|
| 854 |
+
NCursesWindow Clone();
|
| 855 |
+
// Make an exact copy of the window.
|
| 856 |
+
|
| 857 |
+
// Initialization.
|
| 858 |
+
static void useColors(void);
|
| 859 |
+
// Call this routine very early if you want to have colors.
|
| 860 |
+
|
| 861 |
+
static int ripoffline(int ripoff_lines,
|
| 862 |
+
int (*init)(NCursesWindow& win));
|
| 863 |
+
// This function is used to generate a window of ripped-of lines.
|
| 864 |
+
// If the argument is positive, lines are removed from the top, if it
|
| 865 |
+
// is negative lines are removed from the bottom. This enhances the
|
| 866 |
+
// lowlevel ripoffline() function because it uses the internal
|
| 867 |
+
// implementation that allows to remove more than just a single line.
|
| 868 |
+
// This function must be called before any other ncurses function. The
|
| 869 |
+
// creation of the window is deferred until ncurses gets initialized.
|
| 870 |
+
// The initialization function is then called.
|
| 871 |
+
|
| 872 |
+
// -------------------------------------------------------------------------
|
| 873 |
+
// terminal status
|
| 874 |
+
// -------------------------------------------------------------------------
|
| 875 |
+
int lines() const { initialize(); return LINES; }
|
| 876 |
+
// Number of lines on terminal, *not* window
|
| 877 |
+
|
| 878 |
+
int cols() const { initialize(); return COLS; }
|
| 879 |
+
// Number of cols on terminal, *not* window
|
| 880 |
+
|
| 881 |
+
int tabsize() const { initialize(); return TABSIZE; }
|
| 882 |
+
// Size of a tab on terminal, *not* window
|
| 883 |
+
|
| 884 |
+
static int NumberOfColors();
|
| 885 |
+
// Number of available colors
|
| 886 |
+
|
| 887 |
+
int colors() const { return NumberOfColors(); }
|
| 888 |
+
// Number of available colors
|
| 889 |
+
|
| 890 |
+
// -------------------------------------------------------------------------
|
| 891 |
+
// window status
|
| 892 |
+
// -------------------------------------------------------------------------
|
| 893 |
+
int height() const { return maxy() + 1; }
|
| 894 |
+
// Number of lines in this window
|
| 895 |
+
|
| 896 |
+
int width() const { return maxx() + 1; }
|
| 897 |
+
// Number of columns in this window
|
| 898 |
+
|
| 899 |
+
int begx() const { return getbegx(w); }
|
| 900 |
+
// Column of top left corner relative to stdscr
|
| 901 |
+
|
| 902 |
+
int begy() const { return getbegy(w); }
|
| 903 |
+
// Line of top left corner relative to stdscr
|
| 904 |
+
|
| 905 |
+
int curx() const { return getcurx(w); }
|
| 906 |
+
// Column of top left corner relative to stdscr
|
| 907 |
+
|
| 908 |
+
int cury() const { return getcury(w); }
|
| 909 |
+
// Line of top left corner relative to stdscr
|
| 910 |
+
|
| 911 |
+
int maxx() const { return getmaxx(w) == ERR ? ERR : getmaxx(w)-1; }
|
| 912 |
+
// Largest x coord in window
|
| 913 |
+
|
| 914 |
+
int maxy() const { return getmaxy(w) == ERR ? ERR : getmaxy(w)-1; }
|
| 915 |
+
// Largest y coord in window
|
| 916 |
+
|
| 917 |
+
NCURSES_PAIRS_T getcolor() const;
|
| 918 |
+
// Actual color pair
|
| 919 |
+
|
| 920 |
+
NCURSES_COLOR_T foreground() const { return getcolor(0); }
|
| 921 |
+
// Actual foreground color
|
| 922 |
+
|
| 923 |
+
NCURSES_COLOR_T background() const { return getcolor(1); }
|
| 924 |
+
// Actual background color
|
| 925 |
+
|
| 926 |
+
int setpalette(NCURSES_COLOR_T fore, NCURSES_COLOR_T back);
|
| 927 |
+
// Set color palette entry
|
| 928 |
+
|
| 929 |
+
int setcolor(NCURSES_PAIRS_T pair);
|
| 930 |
+
// Set actually used palette entry
|
| 931 |
+
|
| 932 |
+
// -------------------------------------------------------------------------
|
| 933 |
+
// window positioning
|
| 934 |
+
// -------------------------------------------------------------------------
|
| 935 |
+
virtual int mvwin(int begin_y, int begin_x) {
|
| 936 |
+
return ::mvwin(w, begin_y, begin_x); }
|
| 937 |
+
// Move window to new position with the new position as top left corner.
|
| 938 |
+
// This is virtual because it is redefined in NCursesPanel.
|
| 939 |
+
|
| 940 |
+
// -------------------------------------------------------------------------
|
| 941 |
+
// coordinate positioning
|
| 942 |
+
// -------------------------------------------------------------------------
|
| 943 |
+
int move(int y, int x) { return ::wmove(w, y, x); }
|
| 944 |
+
// Move cursor the this position
|
| 945 |
+
|
| 946 |
+
void getyx(int& y, int& x) const { ::getyx(w, y, x); }
|
| 947 |
+
// Get current position of the cursor
|
| 948 |
+
|
| 949 |
+
void getbegyx(int& y, int& x) const { ::getbegyx(w, y, x); }
|
| 950 |
+
// Get beginning of the window
|
| 951 |
+
|
| 952 |
+
void getmaxyx(int& y, int& x) const { ::getmaxyx(w, y, x); }
|
| 953 |
+
// Get size of the window
|
| 954 |
+
|
| 955 |
+
void getparyx(int& y, int& x) const { ::getparyx(w, y, x); }
|
| 956 |
+
// Get parent's beginning of the window
|
| 957 |
+
|
| 958 |
+
int mvcur(int oldrow, int oldcol, int newrow, int newcol) const {
|
| 959 |
+
return ::mvcur(oldrow, oldcol, newrow, newcol); }
|
| 960 |
+
// Perform lowlevel cursor motion that takes effect immediately.
|
| 961 |
+
|
| 962 |
+
// -------------------------------------------------------------------------
|
| 963 |
+
// input
|
| 964 |
+
// -------------------------------------------------------------------------
|
| 965 |
+
int getch() { return ::wgetch(w); }
|
| 966 |
+
// Get a keystroke from the window.
|
| 967 |
+
|
| 968 |
+
int getch(int y, int x) { return ::mvwgetch(w, y, x); }
|
| 969 |
+
// Move cursor to position and get a keystroke from the window
|
| 970 |
+
|
| 971 |
+
int getstr(char* str, int n=-1) {
|
| 972 |
+
return ::wgetnstr(w, str, n); }
|
| 973 |
+
// Read a series of characters into str until a newline or carriage return
|
| 974 |
+
// is received. Read at most n characters. If n is negative, the limit is
|
| 975 |
+
// ignored.
|
| 976 |
+
|
| 977 |
+
int getstr(int y, int x, char* str, int n=-1) {
|
| 978 |
+
return ::mvwgetnstr(w, y, x, str, n); }
|
| 979 |
+
// Move the cursor to the requested position and then perform the getstr()
|
| 980 |
+
// as described above.
|
| 981 |
+
|
| 982 |
+
int instr(char *s, int n=-1) { return ::winnstr(w, s, n); }
|
| 983 |
+
// Get a string of characters from the window into the buffer s. Retrieve
|
| 984 |
+
// at most n characters, if n is negative retrieve all characters up to the
|
| 985 |
+
// end of the current line. Attributes are stripped from the characters.
|
| 986 |
+
|
| 987 |
+
int instr(int y, int x, char *s, int n=-1) {
|
| 988 |
+
return ::mvwinnstr(w, y, x, s, n); }
|
| 989 |
+
// Move the cursor to the requested position and then perform the instr()
|
| 990 |
+
// as described above.
|
| 991 |
+
|
| 992 |
+
int scanw(const char* fmt, ...)
|
| 993 |
+
// Perform a scanw function from the window.
|
| 994 |
+
#if __GNUG__ >= 2
|
| 995 |
+
__attribute__ ((format (scanf, 2, 3)));
|
| 996 |
+
#else
|
| 997 |
+
;
|
| 998 |
+
#endif
|
| 999 |
+
|
| 1000 |
+
int scanw(const char*, va_list);
|
| 1001 |
+
// Perform a scanw function from the window.
|
| 1002 |
+
|
| 1003 |
+
int scanw(int y, int x, const char* fmt, ...)
|
| 1004 |
+
// Move the cursor to the requested position and then perform a scanw
|
| 1005 |
+
// from the window.
|
| 1006 |
+
#if __GNUG__ >= 2
|
| 1007 |
+
__attribute__ ((format (scanf, 4, 5)));
|
| 1008 |
+
#else
|
| 1009 |
+
;
|
| 1010 |
+
#endif
|
| 1011 |
+
|
| 1012 |
+
int scanw(int y, int x, const char* fmt, va_list);
|
| 1013 |
+
// Move the cursor to the requested position and then perform a scanw
|
| 1014 |
+
// from the window.
|
| 1015 |
+
|
| 1016 |
+
// -------------------------------------------------------------------------
|
| 1017 |
+
// output
|
| 1018 |
+
// -------------------------------------------------------------------------
|
| 1019 |
+
int addch(const chtype ch) { return ::waddch(w, ch); }
|
| 1020 |
+
// Put attributed character to the window.
|
| 1021 |
+
|
| 1022 |
+
int addch(int y, int x, const chtype ch) {
|
| 1023 |
+
return ::mvwaddch(w, y, x, ch); }
|
| 1024 |
+
// Move cursor to the requested position and then put attributed character
|
| 1025 |
+
// to the window.
|
| 1026 |
+
|
| 1027 |
+
int echochar(const chtype ch) { return ::wechochar(w, ch); }
|
| 1028 |
+
// Put attributed character to the window and refresh it immediately.
|
| 1029 |
+
|
| 1030 |
+
int addstr(const char* str, int n=-1) {
|
| 1031 |
+
return ::waddnstr(w, str, n); }
|
| 1032 |
+
// Write the string str to the window, stop writing if the terminating
|
| 1033 |
+
// NUL or the limit n is reached. If n is negative, it is ignored.
|
| 1034 |
+
|
| 1035 |
+
int addstr(int y, int x, const char * str, int n=-1) {
|
| 1036 |
+
return ::mvwaddnstr(w, y, x, str, n); }
|
| 1037 |
+
// Move the cursor to the requested position and then perform the addchstr
|
| 1038 |
+
// as described above.
|
| 1039 |
+
|
| 1040 |
+
int addchstr(const chtype* str, int n=-1) {
|
| 1041 |
+
return ::waddchnstr(w, str, n); }
|
| 1042 |
+
// Write the string str to the window, stop writing if the terminating
|
| 1043 |
+
// NUL or the limit n is reached. If n is negative, it is ignored.
|
| 1044 |
+
|
| 1045 |
+
int addchstr(int y, int x, const chtype * str, int n=-1) {
|
| 1046 |
+
return ::mvwaddchnstr(w, y, x, str, n); }
|
| 1047 |
+
// Move the cursor to the requested position and then perform the addchstr
|
| 1048 |
+
// as described above.
|
| 1049 |
+
|
| 1050 |
+
int printw(const char* fmt, ...)
|
| 1051 |
+
// Do a formatted print to the window.
|
| 1052 |
+
#if (__GNUG__ >= 2) && !defined(printf)
|
| 1053 |
+
__attribute__ ((format (printf, 2, 3)));
|
| 1054 |
+
#else
|
| 1055 |
+
;
|
| 1056 |
+
#endif
|
| 1057 |
+
|
| 1058 |
+
int printw(int y, int x, const char * fmt, ...)
|
| 1059 |
+
// Move the cursor and then do a formatted print to the window.
|
| 1060 |
+
#if (__GNUG__ >= 2) && !defined(printf)
|
| 1061 |
+
__attribute__ ((format (printf, 4, 5)));
|
| 1062 |
+
#else
|
| 1063 |
+
;
|
| 1064 |
+
#endif
|
| 1065 |
+
|
| 1066 |
+
int printw(const char* fmt, va_list args);
|
| 1067 |
+
// Do a formatted print to the window.
|
| 1068 |
+
|
| 1069 |
+
int printw(int y, int x, const char * fmt, va_list args);
|
| 1070 |
+
// Move the cursor and then do a formatted print to the window.
|
| 1071 |
+
|
| 1072 |
+
chtype inch() const { return ::winch(w); }
|
| 1073 |
+
// Retrieve attributed character under the current cursor position.
|
| 1074 |
+
|
| 1075 |
+
chtype inch(int y, int x) { return ::mvwinch(w, y, x); }
|
| 1076 |
+
// Move cursor to requested position and then retrieve attributed character
|
| 1077 |
+
// at this position.
|
| 1078 |
+
|
| 1079 |
+
int inchstr(chtype* str, int n=-1) {
|
| 1080 |
+
return ::winchnstr(w, str, n); }
|
| 1081 |
+
// Read the string str from the window, stop reading if the terminating
|
| 1082 |
+
// NUL or the limit n is reached. If n is negative, it is ignored.
|
| 1083 |
+
|
| 1084 |
+
int inchstr(int y, int x, chtype * str, int n=-1) {
|
| 1085 |
+
return ::mvwinchnstr(w, y, x, str, n); }
|
| 1086 |
+
// Move the cursor to the requested position and then perform the inchstr
|
| 1087 |
+
// as described above.
|
| 1088 |
+
|
| 1089 |
+
int insch(chtype ch) { return ::winsch(w, ch); }
|
| 1090 |
+
// Insert attributed character into the window before current cursor
|
| 1091 |
+
// position.
|
| 1092 |
+
|
| 1093 |
+
int insch(int y, int x, chtype ch) {
|
| 1094 |
+
return ::mvwinsch(w, y, x, ch); }
|
| 1095 |
+
// Move cursor to requested position and then insert the attributed
|
| 1096 |
+
// character before that position.
|
| 1097 |
+
|
| 1098 |
+
int insertln() { return ::winsdelln(w, 1); }
|
| 1099 |
+
// Insert an empty line above the current line.
|
| 1100 |
+
|
| 1101 |
+
int insdelln(int n=1) { return ::winsdelln(w, n); }
|
| 1102 |
+
// If n>0 insert that many lines above the current line. If n<0 delete
|
| 1103 |
+
// that many lines beginning with the current line.
|
| 1104 |
+
|
| 1105 |
+
int insstr(const char *s, int n=-1) {
|
| 1106 |
+
return ::winsnstr(w, s, n); }
|
| 1107 |
+
// Insert the string into the window before the current cursor position.
|
| 1108 |
+
// Insert stops at end of string or when the limit n is reached. If n is
|
| 1109 |
+
// negative, it is ignored.
|
| 1110 |
+
|
| 1111 |
+
int insstr(int y, int x, const char *s, int n=-1) {
|
| 1112 |
+
return ::mvwinsnstr(w, y, x, s, n); }
|
| 1113 |
+
// Move the cursor to the requested position and then perform the insstr()
|
| 1114 |
+
// as described above.
|
| 1115 |
+
|
| 1116 |
+
int attron (chtype at) { return ::wattron (w, at); }
|
| 1117 |
+
// Switch on the window attributes;
|
| 1118 |
+
|
| 1119 |
+
int attroff(chtype at) { return ::wattroff(w, static_cast<int>(at)); }
|
| 1120 |
+
// Switch off the window attributes;
|
| 1121 |
+
|
| 1122 |
+
int attrset(chtype at) { return ::wattrset(w, static_cast<int>(at)); }
|
| 1123 |
+
// Set the window attributes;
|
| 1124 |
+
|
| 1125 |
+
chtype attrget() { return ::getattrs(w); }
|
| 1126 |
+
// Get the window attributes;
|
| 1127 |
+
|
| 1128 |
+
int color_set(NCURSES_PAIRS_T color_pair_number, void* opts=NULL) {
|
| 1129 |
+
return ::wcolor_set(w, color_pair_number, opts); }
|
| 1130 |
+
// Set the window color attribute;
|
| 1131 |
+
|
| 1132 |
+
int chgat(int n, attr_t attr, NCURSES_PAIRS_T color, const void *opts=NULL) {
|
| 1133 |
+
return ::wchgat(w, n, attr, color, opts); }
|
| 1134 |
+
// Change the attributes of the next n characters in the current line. If
|
| 1135 |
+
// n is negative or greater than the number of remaining characters in the
|
| 1136 |
+
// line, the attributes will be changed up to the end of the line.
|
| 1137 |
+
|
| 1138 |
+
int chgat(int y, int x,
|
| 1139 |
+
int n, attr_t attr, NCURSES_PAIRS_T color, const void *opts=NULL) {
|
| 1140 |
+
return ::mvwchgat(w, y, x, n, attr, color, opts); }
|
| 1141 |
+
// Move the cursor to the requested position and then perform chgat() as
|
| 1142 |
+
// described above.
|
| 1143 |
+
|
| 1144 |
+
// -------------------------------------------------------------------------
|
| 1145 |
+
// background
|
| 1146 |
+
// -------------------------------------------------------------------------
|
| 1147 |
+
chtype getbkgd() const { return ::getbkgd(w); }
|
| 1148 |
+
// Get current background setting.
|
| 1149 |
+
|
| 1150 |
+
int bkgd(const chtype ch) { return ::wbkgd(w, ch); }
|
| 1151 |
+
// Set the background property and apply it to the window.
|
| 1152 |
+
|
| 1153 |
+
void bkgdset(chtype ch) { ::wbkgdset(w, ch); }
|
| 1154 |
+
// Set the background property.
|
| 1155 |
+
|
| 1156 |
+
// -------------------------------------------------------------------------
|
| 1157 |
+
// borders
|
| 1158 |
+
// -------------------------------------------------------------------------
|
| 1159 |
+
int box(chtype vert=0, chtype hor=0) {
|
| 1160 |
+
return ::wborder(w, vert, vert, hor, hor, 0, 0, 0, 0); }
|
| 1161 |
+
// Draw a box around the window with the given vertical and horizontal
|
| 1162 |
+
// drawing characters. If you specify a zero as character, curses will try
|
| 1163 |
+
// to find a "nice" character.
|
| 1164 |
+
|
| 1165 |
+
int border(chtype left=0, chtype right=0,
|
| 1166 |
+
chtype top =0, chtype bottom=0,
|
| 1167 |
+
chtype top_left =0, chtype top_right=0,
|
| 1168 |
+
chtype bottom_left =0, chtype bottom_right=0) {
|
| 1169 |
+
return ::wborder(w, left, right, top, bottom, top_left, top_right,
|
| 1170 |
+
bottom_left, bottom_right); }
|
| 1171 |
+
// Draw a border around the window with the given characters for the
|
| 1172 |
+
// various parts of the border. If you pass zero for a character, curses
|
| 1173 |
+
// will try to find "nice" characters.
|
| 1174 |
+
|
| 1175 |
+
// -------------------------------------------------------------------------
|
| 1176 |
+
// lines and boxes
|
| 1177 |
+
// -------------------------------------------------------------------------
|
| 1178 |
+
int hline(int len, chtype ch=0) { return ::whline(w, ch, len); }
|
| 1179 |
+
// Draw a horizontal line of len characters with the given character. If
|
| 1180 |
+
// you pass zero for the character, curses will try to find a "nice" one.
|
| 1181 |
+
|
| 1182 |
+
int hline(int y, int x, int len, chtype ch=0) {
|
| 1183 |
+
return ::mvwhline(w, y, x, ch, len); }
|
| 1184 |
+
// Move the cursor to the requested position and then draw a horizontal line.
|
| 1185 |
+
|
| 1186 |
+
int vline(int len, chtype ch=0) { return ::wvline(w, ch, len); }
|
| 1187 |
+
// Draw a vertical line of len characters with the given character. If
|
| 1188 |
+
// you pass zero for the character, curses will try to find a "nice" one.
|
| 1189 |
+
|
| 1190 |
+
int vline(int y, int x, int len, chtype ch=0) {
|
| 1191 |
+
return ::mvwvline(w, y, x, ch, len); }
|
| 1192 |
+
// Move the cursor to the requested position and then draw a vertical line.
|
| 1193 |
+
|
| 1194 |
+
// -------------------------------------------------------------------------
|
| 1195 |
+
// erasure
|
| 1196 |
+
// -------------------------------------------------------------------------
|
| 1197 |
+
int erase() { return ::werase(w); }
|
| 1198 |
+
// Erase the window.
|
| 1199 |
+
|
| 1200 |
+
int clear() { return ::wclear(w); }
|
| 1201 |
+
// Clear the window.
|
| 1202 |
+
|
| 1203 |
+
int clearok(bool bf) { return ::clearok(w, bf); }
|
| 1204 |
+
// Set/Reset the clear flag. If set, the next refresh() will clear the
|
| 1205 |
+
// screen.
|
| 1206 |
+
|
| 1207 |
+
int clrtobot() { return ::wclrtobot(w); }
|
| 1208 |
+
// Clear to the end of the window.
|
| 1209 |
+
|
| 1210 |
+
int clrtoeol() { return ::wclrtoeol(w); }
|
| 1211 |
+
// Clear to the end of the line.
|
| 1212 |
+
|
| 1213 |
+
int delch() { return ::wdelch(w); }
|
| 1214 |
+
// Delete character under the cursor.
|
| 1215 |
+
|
| 1216 |
+
int delch(int y, int x) { return ::mvwdelch(w, y, x); }
|
| 1217 |
+
// Move cursor to requested position and delete the character under the
|
| 1218 |
+
// cursor.
|
| 1219 |
+
|
| 1220 |
+
int deleteln() { return ::winsdelln(w, -1); }
|
| 1221 |
+
// Delete the current line.
|
| 1222 |
+
|
| 1223 |
+
// -------------------------------------------------------------------------
|
| 1224 |
+
// screen control
|
| 1225 |
+
// -------------------------------------------------------------------------
|
| 1226 |
+
int scroll(int amount=1) { return ::wscrl(w, amount); }
|
| 1227 |
+
// Scroll amount lines. If amount is positive, scroll up, otherwise
|
| 1228 |
+
// scroll down.
|
| 1229 |
+
|
| 1230 |
+
int scrollok(bool bf) { return ::scrollok(w, bf); }
|
| 1231 |
+
// If bf is TRUE, window scrolls if cursor is moved off the bottom
|
| 1232 |
+
// edge of the window or a scrolling region, otherwise the cursor is left
|
| 1233 |
+
// at the bottom line.
|
| 1234 |
+
|
| 1235 |
+
int setscrreg(int from, int to) {
|
| 1236 |
+
return ::wsetscrreg(w, from, to); }
|
| 1237 |
+
// Define a soft scrolling region.
|
| 1238 |
+
|
| 1239 |
+
int idlok(bool bf) { return ::idlok(w, bf); }
|
| 1240 |
+
// If bf is TRUE, use insert/delete line hardware support if possible.
|
| 1241 |
+
// Otherwise do it in software.
|
| 1242 |
+
|
| 1243 |
+
void idcok(bool bf) { ::idcok(w, bf); }
|
| 1244 |
+
// If bf is TRUE, use insert/delete character hardware support if possible.
|
| 1245 |
+
// Otherwise do it in software.
|
| 1246 |
+
|
| 1247 |
+
int touchline(int s, int c) { return ::touchline(w, s, c); }
|
| 1248 |
+
// Mark the given lines as modified.
|
| 1249 |
+
|
| 1250 |
+
int touchwin() { return ::wtouchln(w, 0, height(), 1); }
|
| 1251 |
+
// Mark the whole window as modified.
|
| 1252 |
+
|
| 1253 |
+
int untouchwin() { return ::wtouchln(w, 0, height(), 0); }
|
| 1254 |
+
// Mark the whole window as unmodified.
|
| 1255 |
+
|
| 1256 |
+
int touchln(int s, int cnt, bool changed=TRUE) {
|
| 1257 |
+
return ::wtouchln(w, s, cnt, static_cast<int>(changed ? 1 : 0)); }
|
| 1258 |
+
// Mark cnt lines beginning from line s as changed or unchanged, depending
|
| 1259 |
+
// on the value of the changed flag.
|
| 1260 |
+
|
| 1261 |
+
bool is_linetouched(int line) const {
|
| 1262 |
+
return (::is_linetouched(w, line) == TRUE ? TRUE:FALSE); }
|
| 1263 |
+
// Return TRUE if line is marked as changed, FALSE otherwise
|
| 1264 |
+
|
| 1265 |
+
bool is_wintouched() const {
|
| 1266 |
+
return (::is_wintouched(w) ? TRUE:FALSE); }
|
| 1267 |
+
// Return TRUE if window is marked as changed, FALSE otherwise
|
| 1268 |
+
|
| 1269 |
+
int leaveok(bool bf) { return ::leaveok(w, bf); }
|
| 1270 |
+
// If bf is TRUE, curses will leave the cursor after an update wherever
|
| 1271 |
+
// it is after the update.
|
| 1272 |
+
|
| 1273 |
+
int redrawln(int from, int n) { return ::wredrawln(w, from, n); }
|
| 1274 |
+
// Redraw n lines starting from the requested line
|
| 1275 |
+
|
| 1276 |
+
int redrawwin() { return ::wredrawln(w, 0, height()); }
|
| 1277 |
+
// Redraw the whole window
|
| 1278 |
+
|
| 1279 |
+
int doupdate() { return ::doupdate(); }
|
| 1280 |
+
// Do all outputs to make the physical screen looking like the virtual one
|
| 1281 |
+
|
| 1282 |
+
void syncdown() { ::wsyncdown(w); }
|
| 1283 |
+
// Propagate the changes down to all descendant windows
|
| 1284 |
+
|
| 1285 |
+
void syncup() { ::wsyncup(w); }
|
| 1286 |
+
// Propagate the changes up in the hierarchy
|
| 1287 |
+
|
| 1288 |
+
void cursyncup() { ::wcursyncup(w); }
|
| 1289 |
+
// Position the cursor in all ancestor windows corresponding to our setting
|
| 1290 |
+
|
| 1291 |
+
int syncok(bool bf) { return ::syncok(w, bf); }
|
| 1292 |
+
// If called with bf=TRUE, syncup() is called whenever the window is changed
|
| 1293 |
+
|
| 1294 |
+
#ifndef _no_flushok
|
| 1295 |
+
int flushok(bool bf) { return ::flushok(w, bf); }
|
| 1296 |
+
#endif
|
| 1297 |
+
|
| 1298 |
+
void immedok(bool bf) { ::immedok(w, bf); }
|
| 1299 |
+
// If called with bf=TRUE, any change in the window will cause an
|
| 1300 |
+
// automatic immediate refresh()
|
| 1301 |
+
|
| 1302 |
+
int intrflush(bool bf) { return ::intrflush(w, bf); }
|
| 1303 |
+
|
| 1304 |
+
int keypad(bool bf) { return ::keypad(w, bf); }
|
| 1305 |
+
// If called with bf=TRUE, the application will interpret function keys.
|
| 1306 |
+
|
| 1307 |
+
int nodelay(bool bf) { return ::nodelay(w, bf); }
|
| 1308 |
+
|
| 1309 |
+
int meta(bool bf) { return ::meta(w, bf); }
|
| 1310 |
+
// If called with bf=TRUE, keys may generate 8-Bit characters. Otherwise
|
| 1311 |
+
// 7-Bit characters are generated.
|
| 1312 |
+
|
| 1313 |
+
int standout() { return ::wstandout(w); }
|
| 1314 |
+
// Enable "standout" attributes
|
| 1315 |
+
|
| 1316 |
+
int standend() { return ::wstandend(w); }
|
| 1317 |
+
// Disable "standout" attributes
|
| 1318 |
+
|
| 1319 |
+
// -------------------------------------------------------------------------
|
| 1320 |
+
// The next two are virtual, because we redefine them in the
|
| 1321 |
+
// NCursesPanel class.
|
| 1322 |
+
// -------------------------------------------------------------------------
|
| 1323 |
+
virtual int refresh() { return ::wrefresh(w); }
|
| 1324 |
+
// Propagate the changes in this window to the virtual screen and call
|
| 1325 |
+
// doupdate(). This is redefined in NCursesPanel.
|
| 1326 |
+
|
| 1327 |
+
virtual int noutrefresh() { return ::wnoutrefresh(w); }
|
| 1328 |
+
// Propagate the changes in this window to the virtual screen. This is
|
| 1329 |
+
// redefined in NCursesPanel.
|
| 1330 |
+
|
| 1331 |
+
// -------------------------------------------------------------------------
|
| 1332 |
+
// multiple window control
|
| 1333 |
+
// -------------------------------------------------------------------------
|
| 1334 |
+
int overlay(NCursesWindow& win) {
|
| 1335 |
+
return ::overlay(w, win.w); }
|
| 1336 |
+
// Overlay this window over win.
|
| 1337 |
+
|
| 1338 |
+
int overwrite(NCursesWindow& win) {
|
| 1339 |
+
return ::overwrite(w, win.w); }
|
| 1340 |
+
// Overwrite win with this window.
|
| 1341 |
+
|
| 1342 |
+
int copywin(NCursesWindow& win,
|
| 1343 |
+
int sminrow, int smincol,
|
| 1344 |
+
int dminrow, int dmincol,
|
| 1345 |
+
int dmaxrow, int dmaxcol, bool overlaywin=TRUE) {
|
| 1346 |
+
return ::copywin(w, win.w, sminrow, smincol, dminrow, dmincol,
|
| 1347 |
+
dmaxrow, dmaxcol, static_cast<int>(overlaywin ? 1 : 0)); }
|
| 1348 |
+
// Overlay or overwrite the rectangle in win given by dminrow,dmincol,
|
| 1349 |
+
// dmaxrow,dmaxcol with the rectangle in this window beginning at
|
| 1350 |
+
// sminrow,smincol.
|
| 1351 |
+
|
| 1352 |
+
// -------------------------------------------------------------------------
|
| 1353 |
+
// Extended functions
|
| 1354 |
+
// -------------------------------------------------------------------------
|
| 1355 |
+
#if defined(NCURSES_EXT_FUNCS) && (NCURSES_EXT_FUNCS != 0)
|
| 1356 |
+
int wresize(int newLines, int newColumns) {
|
| 1357 |
+
return ::wresize(w, newLines, newColumns); }
|
| 1358 |
+
#endif
|
| 1359 |
+
|
| 1360 |
+
// -------------------------------------------------------------------------
|
| 1361 |
+
// Mouse related
|
| 1362 |
+
// -------------------------------------------------------------------------
|
| 1363 |
+
bool has_mouse() const;
|
| 1364 |
+
// Return TRUE if terminal supports a mouse, FALSE otherwise
|
| 1365 |
+
|
| 1366 |
+
// -------------------------------------------------------------------------
|
| 1367 |
+
// traversal support
|
| 1368 |
+
// -------------------------------------------------------------------------
|
| 1369 |
+
NCursesWindow* child() { return subwins; }
|
| 1370 |
+
// Get the first child window.
|
| 1371 |
+
|
| 1372 |
+
NCursesWindow* sibling() { return sib; }
|
| 1373 |
+
// Get the next child of my parent.
|
| 1374 |
+
|
| 1375 |
+
NCursesWindow* parent() { return par; }
|
| 1376 |
+
// Get my parent.
|
| 1377 |
+
|
| 1378 |
+
bool isDescendant(NCursesWindow& win);
|
| 1379 |
+
// Return TRUE if win is a descendant of this.
|
| 1380 |
+
};
|
| 1381 |
+
|
| 1382 |
+
// -------------------------------------------------------------------------
|
| 1383 |
+
// We leave this here for compatibility reasons.
|
| 1384 |
+
// -------------------------------------------------------------------------
|
| 1385 |
+
class NCURSES_CXX_IMPEXP NCursesColorWindow : public NCursesWindow
|
| 1386 |
+
{
|
| 1387 |
+
public:
|
| 1388 |
+
explicit NCursesColorWindow(WINDOW* &window) // useful only for stdscr
|
| 1389 |
+
: NCursesWindow(window) {
|
| 1390 |
+
useColors(); }
|
| 1391 |
+
|
| 1392 |
+
NCursesColorWindow(int nlines, // number of lines
|
| 1393 |
+
int ncols, // number of columns
|
| 1394 |
+
int begin_y, // line origin
|
| 1395 |
+
int begin_x) // col origin
|
| 1396 |
+
: NCursesWindow(nlines, ncols, begin_y, begin_x) {
|
| 1397 |
+
useColors(); }
|
| 1398 |
+
|
| 1399 |
+
NCursesColorWindow(NCursesWindow& parentWin,// parent window
|
| 1400 |
+
int nlines, // number of lines
|
| 1401 |
+
int ncols, // number of columns
|
| 1402 |
+
int begin_y, // absolute or relative
|
| 1403 |
+
int begin_x, // origins:
|
| 1404 |
+
char absrel = 'a') // if `a', by & bx are
|
| 1405 |
+
: NCursesWindow(parentWin,
|
| 1406 |
+
nlines, ncols, // absolute screen pos,
|
| 1407 |
+
begin_y, begin_x, // else if `r', they are
|
| 1408 |
+
absrel ) { // relative to par origin
|
| 1409 |
+
useColors(); }
|
| 1410 |
+
};
|
| 1411 |
+
|
| 1412 |
+
// These enum definitions really belong inside the NCursesPad class, but only
|
| 1413 |
+
// recent compilers support that feature.
|
| 1414 |
+
|
| 1415 |
+
typedef enum {
|
| 1416 |
+
REQ_PAD_REFRESH = KEY_MAX + 1,
|
| 1417 |
+
REQ_PAD_UP,
|
| 1418 |
+
REQ_PAD_DOWN,
|
| 1419 |
+
REQ_PAD_LEFT,
|
| 1420 |
+
REQ_PAD_RIGHT,
|
| 1421 |
+
REQ_PAD_EXIT
|
| 1422 |
+
} Pad_Request;
|
| 1423 |
+
|
| 1424 |
+
const Pad_Request PAD_LOW = REQ_PAD_REFRESH; // lowest op-code
|
| 1425 |
+
const Pad_Request PAD_HIGH = REQ_PAD_EXIT; // highest op-code
|
| 1426 |
+
|
| 1427 |
+
// -------------------------------------------------------------------------
|
| 1428 |
+
// Pad Support. We allow an association of a pad with a "real" window
|
| 1429 |
+
// through which the pad may be viewed.
|
| 1430 |
+
// -------------------------------------------------------------------------
|
| 1431 |
+
class NCURSES_CXX_IMPEXP NCursesPad : public NCursesWindow
|
| 1432 |
+
{
|
| 1433 |
+
private:
|
| 1434 |
+
NCursesWindow* viewWin; // the "viewport" window
|
| 1435 |
+
NCursesWindow* viewSub; // the "viewport" subwindow
|
| 1436 |
+
|
| 1437 |
+
int h_gridsize, v_gridsize;
|
| 1438 |
+
|
| 1439 |
+
protected:
|
| 1440 |
+
int min_row, min_col; // top left row/col of the pads display area
|
| 1441 |
+
|
| 1442 |
+
NCursesWindow* Win(void) const {
|
| 1443 |
+
// Get the window into which the pad should be copied (if any)
|
| 1444 |
+
return (viewSub?viewSub:(viewWin?viewWin:0));
|
| 1445 |
+
}
|
| 1446 |
+
|
| 1447 |
+
NCursesWindow* getWindow(void) const {
|
| 1448 |
+
return viewWin;
|
| 1449 |
+
}
|
| 1450 |
+
|
| 1451 |
+
NCursesWindow* getSubWindow(void) const {
|
| 1452 |
+
return viewSub;
|
| 1453 |
+
}
|
| 1454 |
+
|
| 1455 |
+
virtual int driver (int key); // Virtualize keystroke key
|
| 1456 |
+
// The driver translates the keystroke c into an Pad_Request
|
| 1457 |
+
|
| 1458 |
+
virtual void OnUnknownOperation(int pad_req) {
|
| 1459 |
+
(void) pad_req;
|
| 1460 |
+
::beep();
|
| 1461 |
+
}
|
| 1462 |
+
// This is called if the driver returns an unknown op-code
|
| 1463 |
+
|
| 1464 |
+
virtual void OnNavigationError(int pad_req) {
|
| 1465 |
+
(void) pad_req;
|
| 1466 |
+
::beep();
|
| 1467 |
+
}
|
| 1468 |
+
// This is called if a navigation request couldn't be satisfied
|
| 1469 |
+
|
| 1470 |
+
virtual void OnOperation(int pad_req) {
|
| 1471 |
+
(void) pad_req;
|
| 1472 |
+
};
|
| 1473 |
+
// OnOperation is called if a Pad_Operation was executed and just before
|
| 1474 |
+
// the refresh() operation is done.
|
| 1475 |
+
|
| 1476 |
+
public:
|
| 1477 |
+
NCursesPad(int nlines, int ncols);
|
| 1478 |
+
// create a pad with the given size
|
| 1479 |
+
|
| 1480 |
+
NCursesPad& operator=(const NCursesPad& rhs)
|
| 1481 |
+
{
|
| 1482 |
+
if (this != &rhs) {
|
| 1483 |
+
*this = rhs;
|
| 1484 |
+
NCursesWindow::operator=(rhs);
|
| 1485 |
+
}
|
| 1486 |
+
return *this;
|
| 1487 |
+
}
|
| 1488 |
+
|
| 1489 |
+
NCursesPad(const NCursesPad& rhs)
|
| 1490 |
+
: NCursesWindow(rhs),
|
| 1491 |
+
viewWin(rhs.viewWin),
|
| 1492 |
+
viewSub(rhs.viewSub),
|
| 1493 |
+
h_gridsize(rhs.h_gridsize),
|
| 1494 |
+
v_gridsize(rhs.v_gridsize),
|
| 1495 |
+
min_row(rhs.min_row),
|
| 1496 |
+
min_col(rhs.min_col)
|
| 1497 |
+
{
|
| 1498 |
+
}
|
| 1499 |
+
|
| 1500 |
+
virtual ~NCursesPad() THROWS(NCursesException) {}
|
| 1501 |
+
|
| 1502 |
+
int echochar(const chtype ch) { return ::pechochar(w, ch); }
|
| 1503 |
+
// Put the attributed character onto the pad and immediately do a
|
| 1504 |
+
// prefresh().
|
| 1505 |
+
|
| 1506 |
+
int refresh() NCURSES_OVERRIDE;
|
| 1507 |
+
// If a viewport is defined the pad is displayed in this window, otherwise
|
| 1508 |
+
// this is a noop.
|
| 1509 |
+
|
| 1510 |
+
int refresh(int pminrow, int pmincol,
|
| 1511 |
+
int sminrow, int smincol,
|
| 1512 |
+
int smaxrow, int smaxcol) {
|
| 1513 |
+
return ::prefresh(w, pminrow, pmincol,
|
| 1514 |
+
sminrow, smincol, smaxrow, smaxcol);
|
| 1515 |
+
}
|
| 1516 |
+
// The coordinates sminrow,smincol,smaxrow,smaxcol describe a rectangle
|
| 1517 |
+
// on the screen. <b>refresh</b> copies a rectangle of this size beginning
|
| 1518 |
+
// with top left corner pminrow,pmincol onto the screen and calls doupdate().
|
| 1519 |
+
|
| 1520 |
+
int noutrefresh() NCURSES_OVERRIDE;
|
| 1521 |
+
// If a viewport is defined the pad is displayed in this window, otherwise
|
| 1522 |
+
// this is a noop.
|
| 1523 |
+
|
| 1524 |
+
int noutrefresh(int pminrow, int pmincol,
|
| 1525 |
+
int sminrow, int smincol,
|
| 1526 |
+
int smaxrow, int smaxcol) {
|
| 1527 |
+
return ::pnoutrefresh(w, pminrow, pmincol,
|
| 1528 |
+
sminrow, smincol, smaxrow, smaxcol);
|
| 1529 |
+
}
|
| 1530 |
+
// Does the same as refresh() but without calling doupdate().
|
| 1531 |
+
|
| 1532 |
+
virtual void setWindow(NCursesWindow& view, int v_grid = 1, int h_grid = 1);
|
| 1533 |
+
// Add the window "view" as viewing window to the pad.
|
| 1534 |
+
|
| 1535 |
+
virtual void setSubWindow(NCursesWindow& sub);
|
| 1536 |
+
// Use the subwindow "sub" of the viewport window for the actual viewing.
|
| 1537 |
+
// The full viewport window is usually used to provide some decorations
|
| 1538 |
+
// like frames, titles etc.
|
| 1539 |
+
|
| 1540 |
+
virtual void operator() (void);
|
| 1541 |
+
// Perform Pad's operation
|
| 1542 |
+
};
|
| 1543 |
+
|
| 1544 |
+
// A FramedPad is constructed always with a viewport window. This viewport
|
| 1545 |
+
// will be framed (by a box() command) and the interior of the box is the
|
| 1546 |
+
// viewport subwindow. On the frame we display scrollbar sliders.
|
| 1547 |
+
class NCURSES_CXX_IMPEXP NCursesFramedPad : public NCursesPad
|
| 1548 |
+
{
|
| 1549 |
+
protected:
|
| 1550 |
+
virtual void OnOperation(int pad_req) NCURSES_OVERRIDE;
|
| 1551 |
+
|
| 1552 |
+
public:
|
| 1553 |
+
NCursesFramedPad(NCursesWindow& win, int nlines, int ncols,
|
| 1554 |
+
int v_grid = 1, int h_grid = 1)
|
| 1555 |
+
: NCursesPad(nlines, ncols) {
|
| 1556 |
+
NCursesPad::setWindow(win, v_grid, h_grid);
|
| 1557 |
+
NCursesPad::setSubWindow(*(new NCursesWindow(win)));
|
| 1558 |
+
}
|
| 1559 |
+
// Construct the FramedPad with the given Window win as viewport.
|
| 1560 |
+
|
| 1561 |
+
virtual ~NCursesFramedPad() THROWS(NCursesException) {
|
| 1562 |
+
delete getSubWindow();
|
| 1563 |
+
}
|
| 1564 |
+
|
| 1565 |
+
void setWindow(NCursesWindow& view, int v_grid = 1, int h_grid = 1) NCURSES_OVERRIDE {
|
| 1566 |
+
(void) view;
|
| 1567 |
+
(void) v_grid;
|
| 1568 |
+
(void) h_grid;
|
| 1569 |
+
err_handler("Operation not allowed");
|
| 1570 |
+
}
|
| 1571 |
+
// Disable this call; the viewport is already defined
|
| 1572 |
+
|
| 1573 |
+
void setSubWindow(NCursesWindow& sub) NCURSES_OVERRIDE {
|
| 1574 |
+
(void) sub;
|
| 1575 |
+
err_handler("Operation not allowed");
|
| 1576 |
+
}
|
| 1577 |
+
// Disable this call; the viewport subwindow is already defined
|
| 1578 |
+
|
| 1579 |
+
};
|
| 1580 |
+
|
| 1581 |
+
#endif /* NCURSES_CURSESW_H_incl */
|
llava_next/include/ncurses/cursslk.h
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// * this is for making emacs happy: -*-Mode: C++;-*-
|
| 2 |
+
// vile:cppmode
|
| 3 |
+
/****************************************************************************
|
| 4 |
+
* Copyright 2019-2020,2021 Thomas E. Dickey *
|
| 5 |
+
* Copyright 1998-2003,2005 Free Software Foundation, Inc. *
|
| 6 |
+
* *
|
| 7 |
+
* Permission is hereby granted, free of charge, to any person obtaining a *
|
| 8 |
+
* copy of this software and associated documentation files (the *
|
| 9 |
+
* "Software"), to deal in the Software without restriction, including *
|
| 10 |
+
* without limitation the rights to use, copy, modify, merge, publish, *
|
| 11 |
+
* distribute, distribute with modifications, sublicense, and/or sell *
|
| 12 |
+
* copies of the Software, and to permit persons to whom the Software is *
|
| 13 |
+
* furnished to do so, subject to the following conditions: *
|
| 14 |
+
* *
|
| 15 |
+
* The above copyright notice and this permission notice shall be included *
|
| 16 |
+
* in all copies or substantial portions of the Software. *
|
| 17 |
+
* *
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
|
| 19 |
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
|
| 20 |
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
|
| 21 |
+
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
|
| 22 |
+
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
|
| 23 |
+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
|
| 24 |
+
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
| 25 |
+
* *
|
| 26 |
+
* Except as contained in this notice, the name(s) of the above copyright *
|
| 27 |
+
* holders shall not be used in advertising or otherwise to promote the *
|
| 28 |
+
* sale, use or other dealings in this Software without prior written *
|
| 29 |
+
* authorization. *
|
| 30 |
+
****************************************************************************/
|
| 31 |
+
|
| 32 |
+
/****************************************************************************
|
| 33 |
+
* Author: Juergen Pfeifer, 1997 *
|
| 34 |
+
****************************************************************************/
|
| 35 |
+
|
| 36 |
+
// $Id: cursslk.h,v 1.19 2021/04/17 18:11:08 tom Exp $
|
| 37 |
+
|
| 38 |
+
#ifndef NCURSES_CURSSLK_H_incl
|
| 39 |
+
#define NCURSES_CURSSLK_H_incl
|
| 40 |
+
|
| 41 |
+
#include <ncursesw/cursesw.h>
|
| 42 |
+
|
| 43 |
+
class NCURSES_CXX_IMPEXP Soft_Label_Key_Set {
|
| 44 |
+
public:
|
| 45 |
+
// This inner class represents the attributes of a Soft Label Key (SLK)
|
| 46 |
+
class NCURSES_CXX_IMPEXP Soft_Label_Key {
|
| 47 |
+
friend class Soft_Label_Key_Set;
|
| 48 |
+
public:
|
| 49 |
+
typedef enum { Left=0, Center=1, Right=2 } Justification;
|
| 50 |
+
|
| 51 |
+
private:
|
| 52 |
+
char *label; // The Text of the Label
|
| 53 |
+
Justification format; // The Justification
|
| 54 |
+
int num; // The number of the Label
|
| 55 |
+
|
| 56 |
+
Soft_Label_Key() : label(NULL), format(Left), num(-1) {
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
virtual ~Soft_Label_Key() {
|
| 60 |
+
delete[] label;
|
| 61 |
+
};
|
| 62 |
+
|
| 63 |
+
public:
|
| 64 |
+
// Set the text of the Label
|
| 65 |
+
Soft_Label_Key& operator=(char *text);
|
| 66 |
+
|
| 67 |
+
// Set the Justification of the Label
|
| 68 |
+
Soft_Label_Key& operator=(Justification just) {
|
| 69 |
+
format = just;
|
| 70 |
+
return *this;
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
// Retrieve the text of the label
|
| 74 |
+
inline char* operator()(void) const {
|
| 75 |
+
return label;
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
Soft_Label_Key& operator=(const Soft_Label_Key& rhs)
|
| 79 |
+
{
|
| 80 |
+
if (this != &rhs) {
|
| 81 |
+
*this = rhs;
|
| 82 |
+
}
|
| 83 |
+
return *this;
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
Soft_Label_Key(const Soft_Label_Key& rhs)
|
| 87 |
+
: label(NULL),
|
| 88 |
+
format(rhs.format),
|
| 89 |
+
num(rhs.num)
|
| 90 |
+
{
|
| 91 |
+
*this = rhs.label;
|
| 92 |
+
}
|
| 93 |
+
};
|
| 94 |
+
|
| 95 |
+
public:
|
| 96 |
+
typedef enum {
|
| 97 |
+
None = -1,
|
| 98 |
+
Three_Two_Three = 0,
|
| 99 |
+
Four_Four = 1,
|
| 100 |
+
PC_Style = 2,
|
| 101 |
+
PC_Style_With_Index = 3
|
| 102 |
+
} Label_Layout;
|
| 103 |
+
|
| 104 |
+
private:
|
| 105 |
+
static long count; // Number of Key Sets
|
| 106 |
+
static Label_Layout format; // Layout of the Key Sets
|
| 107 |
+
static int num_labels; // Number Of Labels in Key Sets
|
| 108 |
+
bool b_attrInit; // Are attributes initialized
|
| 109 |
+
|
| 110 |
+
Soft_Label_Key *slk_array; // The array of SLK's
|
| 111 |
+
|
| 112 |
+
// Init the Key Set
|
| 113 |
+
void init();
|
| 114 |
+
|
| 115 |
+
// Activate or Deactivate Label# i, Label counting starts with 1!
|
| 116 |
+
void activate_label(int i, bool bf=TRUE);
|
| 117 |
+
|
| 118 |
+
// Activate of Deactivate all Labels
|
| 119 |
+
void activate_labels(bool bf);
|
| 120 |
+
|
| 121 |
+
protected:
|
| 122 |
+
inline void Error (const char* msg) const THROWS(NCursesException) {
|
| 123 |
+
THROW(new NCursesException (msg));
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
// Remove SLK's from screen
|
| 127 |
+
void clear() {
|
| 128 |
+
if (ERR==::slk_clear())
|
| 129 |
+
Error("slk_clear");
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
// Restore them
|
| 133 |
+
void restore() {
|
| 134 |
+
if (ERR==::slk_restore())
|
| 135 |
+
Error("slk_restore");
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
public:
|
| 139 |
+
|
| 140 |
+
// Construct a Key Set, use the most comfortable layout as default.
|
| 141 |
+
// You must create a Soft_Label_Key_Set before you create any object of
|
| 142 |
+
// the NCursesWindow, NCursesPanel or derived classes. (Actually before
|
| 143 |
+
// ::initscr() is called).
|
| 144 |
+
explicit Soft_Label_Key_Set(Label_Layout fmt);
|
| 145 |
+
|
| 146 |
+
// This constructor assumes, that you already constructed a Key Set
|
| 147 |
+
// with a layout by the constructor above. This layout will be reused.
|
| 148 |
+
Soft_Label_Key_Set();
|
| 149 |
+
|
| 150 |
+
Soft_Label_Key_Set& operator=(const Soft_Label_Key_Set& rhs)
|
| 151 |
+
{
|
| 152 |
+
if (this != &rhs) {
|
| 153 |
+
*this = rhs;
|
| 154 |
+
init(); // allocate a new slk_array[]
|
| 155 |
+
}
|
| 156 |
+
return *this;
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
Soft_Label_Key_Set(const Soft_Label_Key_Set& rhs)
|
| 160 |
+
: b_attrInit(rhs.b_attrInit),
|
| 161 |
+
slk_array(NULL)
|
| 162 |
+
{
|
| 163 |
+
init(); // allocate a new slk_array[]
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
virtual ~Soft_Label_Key_Set() THROWS(NCursesException);
|
| 167 |
+
|
| 168 |
+
// Get Label# i. Label counting starts with 1!
|
| 169 |
+
Soft_Label_Key& operator[](int i);
|
| 170 |
+
|
| 171 |
+
// Retrieve number of Labels
|
| 172 |
+
int labels() const;
|
| 173 |
+
|
| 174 |
+
// Refresh the SLK portion of the screen
|
| 175 |
+
inline void refresh() {
|
| 176 |
+
if (ERR==::slk_refresh())
|
| 177 |
+
Error("slk_refresh");
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
// Mark the SLK portion of the screen for refresh, defer actual refresh
|
| 181 |
+
// until next update call.
|
| 182 |
+
inline void noutrefresh() {
|
| 183 |
+
if (ERR==::slk_noutrefresh())
|
| 184 |
+
Error("slk_noutrefresh");
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
// Mark the whole SLK portion of the screen as modified
|
| 188 |
+
inline void touch() {
|
| 189 |
+
if (ERR==::slk_touch())
|
| 190 |
+
Error("slk_touch");
|
| 191 |
+
}
|
| 192 |
+
|
| 193 |
+
// Activate Label# i
|
| 194 |
+
inline void show(int i) {
|
| 195 |
+
activate_label(i,FALSE);
|
| 196 |
+
activate_label(i,TRUE);
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
// Hide Label# i
|
| 200 |
+
inline void hide(int i) {
|
| 201 |
+
activate_label(i,FALSE);
|
| 202 |
+
}
|
| 203 |
+
|
| 204 |
+
// Show all Labels
|
| 205 |
+
inline void show() {
|
| 206 |
+
activate_labels(FALSE);
|
| 207 |
+
activate_labels(TRUE);
|
| 208 |
+
}
|
| 209 |
+
|
| 210 |
+
// Hide all Labels
|
| 211 |
+
inline void hide() {
|
| 212 |
+
activate_labels(FALSE);
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
inline void attron(attr_t attrs) {
|
| 216 |
+
if (ERR==::slk_attron(attrs))
|
| 217 |
+
Error("slk_attron");
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
inline void attroff(attr_t attrs) {
|
| 221 |
+
if (ERR==::slk_attroff(attrs))
|
| 222 |
+
Error("slk_attroff");
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
inline void attrset(attr_t attrs) {
|
| 226 |
+
if (ERR==::slk_attrset(attrs))
|
| 227 |
+
Error("slk_attrset");
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
inline void color(short color_pair_number) {
|
| 231 |
+
if (ERR==::slk_color(color_pair_number))
|
| 232 |
+
Error("slk_color");
|
| 233 |
+
}
|
| 234 |
+
|
| 235 |
+
inline attr_t attr() const {
|
| 236 |
+
return ::slk_attr();
|
| 237 |
+
}
|
| 238 |
+
};
|
| 239 |
+
|
| 240 |
+
#endif /* NCURSES_CURSSLK_H_incl */
|
llava_next/include/ncurses/eti.h
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/****************************************************************************
|
| 2 |
+
* Copyright 2020 Thomas E. Dickey *
|
| 3 |
+
* Copyright 1998-2002,2003 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: Juergen Pfeifer, 1995,1997 *
|
| 32 |
+
****************************************************************************/
|
| 33 |
+
|
| 34 |
+
/* $Id: eti.h,v 1.9 2020/02/02 23:34:34 tom Exp $ */
|
| 35 |
+
|
| 36 |
+
#ifndef NCURSES_ETI_H_incl
|
| 37 |
+
#define NCURSES_ETI_H_incl 1
|
| 38 |
+
|
| 39 |
+
#define E_OK (0)
|
| 40 |
+
#define E_SYSTEM_ERROR (-1)
|
| 41 |
+
#define E_BAD_ARGUMENT (-2)
|
| 42 |
+
#define E_POSTED (-3)
|
| 43 |
+
#define E_CONNECTED (-4)
|
| 44 |
+
#define E_BAD_STATE (-5)
|
| 45 |
+
#define E_NO_ROOM (-6)
|
| 46 |
+
#define E_NOT_POSTED (-7)
|
| 47 |
+
#define E_UNKNOWN_COMMAND (-8)
|
| 48 |
+
#define E_NO_MATCH (-9)
|
| 49 |
+
#define E_NOT_SELECTABLE (-10)
|
| 50 |
+
#define E_NOT_CONNECTED (-11)
|
| 51 |
+
#define E_REQUEST_DENIED (-12)
|
| 52 |
+
#define E_INVALID_FIELD (-13)
|
| 53 |
+
#define E_CURRENT (-14)
|
| 54 |
+
|
| 55 |
+
#endif
|
llava_next/include/ncurses/etip.h
ADDED
|
@@ -0,0 +1,406 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// * This makes emacs happy -*-Mode: C++;-*-
|
| 2 |
+
/****************************************************************************
|
| 3 |
+
* Copyright 2018-2021,2022 Thomas E. Dickey *
|
| 4 |
+
* Copyright 1998-2012,2017 Free Software Foundation, Inc. *
|
| 5 |
+
* *
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person obtaining a *
|
| 7 |
+
* copy of this software and associated documentation files (the *
|
| 8 |
+
* "Software"), to deal in the Software without restriction, including *
|
| 9 |
+
* without limitation the rights to use, copy, modify, merge, publish, *
|
| 10 |
+
* distribute, distribute with modifications, sublicense, and/or sell *
|
| 11 |
+
* copies of the Software, and to permit persons to whom the Software is *
|
| 12 |
+
* furnished to do so, subject to the following conditions: *
|
| 13 |
+
* *
|
| 14 |
+
* The above copyright notice and this permission notice shall be included *
|
| 15 |
+
* in all copies or substantial portions of the Software. *
|
| 16 |
+
* *
|
| 17 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
|
| 18 |
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
|
| 19 |
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
|
| 20 |
+
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
|
| 21 |
+
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
|
| 22 |
+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
|
| 23 |
+
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
| 24 |
+
* *
|
| 25 |
+
* Except as contained in this notice, the name(s) of the above copyright *
|
| 26 |
+
* holders shall not be used in advertising or otherwise to promote the *
|
| 27 |
+
* sale, use or other dealings in this Software without prior written *
|
| 28 |
+
* authorization. *
|
| 29 |
+
****************************************************************************/
|
| 30 |
+
|
| 31 |
+
/****************************************************************************
|
| 32 |
+
* Author: Juergen Pfeifer, 1997 *
|
| 33 |
+
****************************************************************************/
|
| 34 |
+
|
| 35 |
+
// $Id: etip.h.in,v 1.50 2022/08/20 20:50:00 tom Exp $
|
| 36 |
+
|
| 37 |
+
#ifndef NCURSES_ETIP_H_incl
|
| 38 |
+
#define NCURSES_ETIP_H_incl 1
|
| 39 |
+
|
| 40 |
+
// These are substituted at configure/build time
|
| 41 |
+
#ifndef HAVE_BUILTIN_H
|
| 42 |
+
#define HAVE_BUILTIN_H 0
|
| 43 |
+
#endif
|
| 44 |
+
|
| 45 |
+
#ifndef HAVE_GXX_BUILTIN_H
|
| 46 |
+
#define HAVE_GXX_BUILTIN_H 0
|
| 47 |
+
#endif
|
| 48 |
+
|
| 49 |
+
#ifndef HAVE_GPP_BUILTIN_H
|
| 50 |
+
#define HAVE_GPP_BUILTIN_H 0
|
| 51 |
+
#endif
|
| 52 |
+
|
| 53 |
+
#ifndef HAVE_IOSTREAM
|
| 54 |
+
#define HAVE_IOSTREAM 1
|
| 55 |
+
#endif
|
| 56 |
+
|
| 57 |
+
#ifndef HAVE_TYPEINFO
|
| 58 |
+
#define HAVE_TYPEINFO 1
|
| 59 |
+
#endif
|
| 60 |
+
|
| 61 |
+
#ifndef HAVE_VALUES_H
|
| 62 |
+
#define HAVE_VALUES_H 0
|
| 63 |
+
#endif
|
| 64 |
+
|
| 65 |
+
#ifndef ETIP_NEEDS_MATH_H
|
| 66 |
+
#define ETIP_NEEDS_MATH_H 0
|
| 67 |
+
#endif
|
| 68 |
+
|
| 69 |
+
#ifndef ETIP_NEEDS_MATH_EXCEPTION
|
| 70 |
+
#define ETIP_NEEDS_MATH_EXCEPTION 0
|
| 71 |
+
#endif
|
| 72 |
+
|
| 73 |
+
#ifndef CPP_HAS_OVERRIDE
|
| 74 |
+
#define CPP_HAS_OVERRIDE 0
|
| 75 |
+
#endif
|
| 76 |
+
|
| 77 |
+
#ifndef CPP_HAS_PARAM_INIT
|
| 78 |
+
#define CPP_HAS_PARAM_INIT 0
|
| 79 |
+
#endif
|
| 80 |
+
|
| 81 |
+
#ifndef CPP_HAS_STATIC_CAST
|
| 82 |
+
#define CPP_HAS_STATIC_CAST 1
|
| 83 |
+
#endif
|
| 84 |
+
|
| 85 |
+
#ifndef IOSTREAM_NAMESPACE
|
| 86 |
+
#define IOSTREAM_NAMESPACE 1
|
| 87 |
+
#endif
|
| 88 |
+
|
| 89 |
+
#ifdef __GNUG__
|
| 90 |
+
# if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
|
| 91 |
+
# if HAVE_TYPEINFO
|
| 92 |
+
# include <typeinfo>
|
| 93 |
+
# endif
|
| 94 |
+
# endif
|
| 95 |
+
#endif
|
| 96 |
+
|
| 97 |
+
#if defined(__GNUG__)
|
| 98 |
+
# if HAVE_BUILTIN_H || HAVE_GXX_BUILTIN_H || HAVE_GPP_BUILTIN_H
|
| 99 |
+
# if ETIP_NEEDS_MATH_H
|
| 100 |
+
# if ETIP_NEEDS_MATH_EXCEPTION
|
| 101 |
+
# undef exception
|
| 102 |
+
# define exception math_exception
|
| 103 |
+
# endif
|
| 104 |
+
# include <math.h>
|
| 105 |
+
# endif
|
| 106 |
+
# undef exception
|
| 107 |
+
# define exception builtin_exception
|
| 108 |
+
# if HAVE_GPP_BUILTIN_H
|
| 109 |
+
# include <gpp/builtin.h>
|
| 110 |
+
# elif HAVE_GXX_BUILTIN_H
|
| 111 |
+
# include <g++/builtin.h>
|
| 112 |
+
# else
|
| 113 |
+
# include <builtin.h>
|
| 114 |
+
# endif
|
| 115 |
+
# undef exception
|
| 116 |
+
# endif
|
| 117 |
+
#elif defined (__SUNPRO_CC)
|
| 118 |
+
# include <generic.h>
|
| 119 |
+
#endif
|
| 120 |
+
|
| 121 |
+
#include <ncursesw/curses.h>
|
| 122 |
+
|
| 123 |
+
extern "C" {
|
| 124 |
+
#if HAVE_VALUES_H
|
| 125 |
+
# include <values.h>
|
| 126 |
+
#endif
|
| 127 |
+
|
| 128 |
+
#include <assert.h>
|
| 129 |
+
#include <ncursesw/eti.h>
|
| 130 |
+
#include <errno.h>
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
// Language features
|
| 134 |
+
#if CPP_HAS_OVERRIDE
|
| 135 |
+
#define NCURSES_OVERRIDE override
|
| 136 |
+
#else
|
| 137 |
+
#define NCURSES_OVERRIDE /*nothing*/
|
| 138 |
+
#endif
|
| 139 |
+
|
| 140 |
+
#if CPP_HAS_PARAM_INIT
|
| 141 |
+
#define NCURSES_PARAM_INIT(value) = value
|
| 142 |
+
#else
|
| 143 |
+
#define NCURSES_PARAM_INIT(value) /*nothing*/
|
| 144 |
+
#endif
|
| 145 |
+
|
| 146 |
+
#if CPP_HAS_STATIC_CAST
|
| 147 |
+
#define STATIC_CAST(s) static_cast<s>
|
| 148 |
+
#else
|
| 149 |
+
#define STATIC_CAST(s) (s)
|
| 150 |
+
#endif
|
| 151 |
+
|
| 152 |
+
#ifndef NCURSES_CXX_IMPEXP
|
| 153 |
+
#define NCURSES_CXX_IMPEXP /* nothing */
|
| 154 |
+
#endif
|
| 155 |
+
|
| 156 |
+
// Forward Declarations
|
| 157 |
+
class NCURSES_CXX_IMPEXP NCursesPanel;
|
| 158 |
+
class NCURSES_CXX_IMPEXP NCursesMenu;
|
| 159 |
+
class NCURSES_CXX_IMPEXP NCursesForm;
|
| 160 |
+
|
| 161 |
+
class NCURSES_CXX_IMPEXP NCursesException
|
| 162 |
+
{
|
| 163 |
+
public:
|
| 164 |
+
const char *message;
|
| 165 |
+
int errorno;
|
| 166 |
+
|
| 167 |
+
NCursesException (const char* msg, int err)
|
| 168 |
+
: message(msg), errorno (err)
|
| 169 |
+
{};
|
| 170 |
+
|
| 171 |
+
explicit NCursesException (const char* msg)
|
| 172 |
+
: message(msg), errorno (E_SYSTEM_ERROR)
|
| 173 |
+
{};
|
| 174 |
+
|
| 175 |
+
NCursesException& operator=(const NCursesException& rhs)
|
| 176 |
+
{
|
| 177 |
+
message = rhs.message;
|
| 178 |
+
errorno = rhs.errorno;
|
| 179 |
+
return *this;
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
NCursesException(const NCursesException& rhs)
|
| 183 |
+
: message(rhs.message), errorno(rhs.errorno)
|
| 184 |
+
{
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
virtual const char *classname() const {
|
| 188 |
+
return "NCursesWindow";
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
virtual ~NCursesException()
|
| 192 |
+
{
|
| 193 |
+
}
|
| 194 |
+
};
|
| 195 |
+
|
| 196 |
+
class NCURSES_CXX_IMPEXP NCursesPanelException : public NCursesException
|
| 197 |
+
{
|
| 198 |
+
public:
|
| 199 |
+
const NCursesPanel* p;
|
| 200 |
+
|
| 201 |
+
NCursesPanelException (const char *msg, int err) :
|
| 202 |
+
NCursesException (msg, err),
|
| 203 |
+
p (0)
|
| 204 |
+
{};
|
| 205 |
+
|
| 206 |
+
NCursesPanelException (const NCursesPanel* panel,
|
| 207 |
+
const char *msg,
|
| 208 |
+
int err) :
|
| 209 |
+
NCursesException (msg, err),
|
| 210 |
+
p (panel)
|
| 211 |
+
{};
|
| 212 |
+
|
| 213 |
+
explicit NCursesPanelException (int err) :
|
| 214 |
+
NCursesException ("panel library error", err),
|
| 215 |
+
p (0)
|
| 216 |
+
{};
|
| 217 |
+
|
| 218 |
+
NCursesPanelException (const NCursesPanel* panel,
|
| 219 |
+
int err) :
|
| 220 |
+
NCursesException ("panel library error", err),
|
| 221 |
+
p (panel)
|
| 222 |
+
{};
|
| 223 |
+
|
| 224 |
+
NCursesPanelException& operator=(const NCursesPanelException& rhs)
|
| 225 |
+
{
|
| 226 |
+
if (this != &rhs) {
|
| 227 |
+
NCursesException::operator=(rhs);
|
| 228 |
+
p = rhs.p;
|
| 229 |
+
}
|
| 230 |
+
return *this;
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
NCursesPanelException(const NCursesPanelException& rhs)
|
| 234 |
+
: NCursesException(rhs), p(rhs.p)
|
| 235 |
+
{
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
virtual const char *classname() const NCURSES_OVERRIDE {
|
| 239 |
+
return "NCursesPanel";
|
| 240 |
+
}
|
| 241 |
+
|
| 242 |
+
virtual ~NCursesPanelException()
|
| 243 |
+
{
|
| 244 |
+
}
|
| 245 |
+
};
|
| 246 |
+
|
| 247 |
+
class NCURSES_CXX_IMPEXP NCursesMenuException : public NCursesException
|
| 248 |
+
{
|
| 249 |
+
public:
|
| 250 |
+
const NCursesMenu* m;
|
| 251 |
+
|
| 252 |
+
NCursesMenuException (const char *msg, int err) :
|
| 253 |
+
NCursesException (msg, err),
|
| 254 |
+
m (0)
|
| 255 |
+
{};
|
| 256 |
+
|
| 257 |
+
NCursesMenuException (const NCursesMenu* menu,
|
| 258 |
+
const char *msg,
|
| 259 |
+
int err) :
|
| 260 |
+
NCursesException (msg, err),
|
| 261 |
+
m (menu)
|
| 262 |
+
{};
|
| 263 |
+
|
| 264 |
+
explicit NCursesMenuException (int err) :
|
| 265 |
+
NCursesException ("menu library error", err),
|
| 266 |
+
m (0)
|
| 267 |
+
{};
|
| 268 |
+
|
| 269 |
+
NCursesMenuException (const NCursesMenu* menu,
|
| 270 |
+
int err) :
|
| 271 |
+
NCursesException ("menu library error", err),
|
| 272 |
+
m (menu)
|
| 273 |
+
{};
|
| 274 |
+
|
| 275 |
+
NCursesMenuException& operator=(const NCursesMenuException& rhs)
|
| 276 |
+
{
|
| 277 |
+
if (this != &rhs) {
|
| 278 |
+
NCursesException::operator=(rhs);
|
| 279 |
+
m = rhs.m;
|
| 280 |
+
}
|
| 281 |
+
return *this;
|
| 282 |
+
}
|
| 283 |
+
|
| 284 |
+
NCursesMenuException(const NCursesMenuException& rhs)
|
| 285 |
+
: NCursesException(rhs), m(rhs.m)
|
| 286 |
+
{
|
| 287 |
+
}
|
| 288 |
+
|
| 289 |
+
virtual const char *classname() const NCURSES_OVERRIDE {
|
| 290 |
+
return "NCursesMenu";
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
virtual ~NCursesMenuException()
|
| 294 |
+
{
|
| 295 |
+
}
|
| 296 |
+
};
|
| 297 |
+
|
| 298 |
+
class NCURSES_CXX_IMPEXP NCursesFormException : public NCursesException
|
| 299 |
+
{
|
| 300 |
+
public:
|
| 301 |
+
const NCursesForm* f;
|
| 302 |
+
|
| 303 |
+
NCursesFormException (const char *msg, int err) :
|
| 304 |
+
NCursesException (msg, err),
|
| 305 |
+
f (0)
|
| 306 |
+
{};
|
| 307 |
+
|
| 308 |
+
NCursesFormException (const NCursesForm* form,
|
| 309 |
+
const char *msg,
|
| 310 |
+
int err) :
|
| 311 |
+
NCursesException (msg, err),
|
| 312 |
+
f (form)
|
| 313 |
+
{};
|
| 314 |
+
|
| 315 |
+
explicit NCursesFormException (int err) :
|
| 316 |
+
NCursesException ("form library error", err),
|
| 317 |
+
f (0)
|
| 318 |
+
{};
|
| 319 |
+
|
| 320 |
+
NCursesFormException (const NCursesForm* form,
|
| 321 |
+
int err) :
|
| 322 |
+
NCursesException ("form library error", err),
|
| 323 |
+
f (form)
|
| 324 |
+
{};
|
| 325 |
+
|
| 326 |
+
NCursesFormException& operator=(const NCursesFormException& rhs)
|
| 327 |
+
{
|
| 328 |
+
if (this != &rhs) {
|
| 329 |
+
NCursesException::operator=(rhs);
|
| 330 |
+
f = rhs.f;
|
| 331 |
+
}
|
| 332 |
+
return *this;
|
| 333 |
+
}
|
| 334 |
+
|
| 335 |
+
NCursesFormException(const NCursesFormException& rhs)
|
| 336 |
+
: NCursesException(rhs), f(rhs.f)
|
| 337 |
+
{
|
| 338 |
+
}
|
| 339 |
+
|
| 340 |
+
virtual const char *classname() const NCURSES_OVERRIDE {
|
| 341 |
+
return "NCursesForm";
|
| 342 |
+
}
|
| 343 |
+
|
| 344 |
+
virtual ~NCursesFormException()
|
| 345 |
+
{
|
| 346 |
+
}
|
| 347 |
+
};
|
| 348 |
+
|
| 349 |
+
#if !((defined(__GNUG__) && defined(__EXCEPTIONS) && (__GNUG__ < 7)) || defined(__SUNPRO_CC))
|
| 350 |
+
# if HAVE_IOSTREAM
|
| 351 |
+
# include <iostream>
|
| 352 |
+
# if IOSTREAM_NAMESPACE
|
| 353 |
+
using std::cerr;
|
| 354 |
+
using std::endl;
|
| 355 |
+
# endif
|
| 356 |
+
# else
|
| 357 |
+
# include <iostream.h>
|
| 358 |
+
# endif
|
| 359 |
+
#endif
|
| 360 |
+
|
| 361 |
+
inline void THROW(const NCursesException *e) {
|
| 362 |
+
#if defined(__GNUG__) && defined(__EXCEPTIONS)
|
| 363 |
+
# if ((__GNUG__ <= 2) && (__GNUC_MINOR__ < 8))
|
| 364 |
+
(*lib_error_handler)(e ? e->classname() : "", e ? e->message : "");
|
| 365 |
+
# elif (__GNUG__ >= 7)
|
| 366 |
+
// g++ 7.0 warns about deprecation, but lacks the predefined symbols
|
| 367 |
+
::endwin();
|
| 368 |
+
std::cerr << "Found a problem - goodbye" << std::endl;
|
| 369 |
+
exit(EXIT_FAILURE);
|
| 370 |
+
# else
|
| 371 |
+
# define CPP_HAS_TRY_CATCH 1
|
| 372 |
+
# endif
|
| 373 |
+
#elif defined(__SUNPRO_CC)
|
| 374 |
+
# if !defined(__SUNPRO_CC_COMPAT) || (__SUNPRO_CC_COMPAT < 5)
|
| 375 |
+
genericerror(1, ((e != 0) ? (char *)(e->message) : ""));
|
| 376 |
+
# else
|
| 377 |
+
# define CPP_HAS_TRY_CATCH 1
|
| 378 |
+
# endif
|
| 379 |
+
#else
|
| 380 |
+
if (e)
|
| 381 |
+
cerr << e->message << endl;
|
| 382 |
+
exit(0);
|
| 383 |
+
#endif
|
| 384 |
+
|
| 385 |
+
#ifndef CPP_HAS_TRY_CATCH
|
| 386 |
+
#define CPP_HAS_TRY_CATCH 0
|
| 387 |
+
#define NCURSES_CPP_TRY /* nothing */
|
| 388 |
+
#define NCURSES_CPP_CATCH(e) if (false)
|
| 389 |
+
#define THROWS(s) /* nothing */
|
| 390 |
+
#define THROW2(s,t) /* nothing */
|
| 391 |
+
#elif CPP_HAS_TRY_CATCH
|
| 392 |
+
throw *e;
|
| 393 |
+
#define NCURSES_CPP_TRY try
|
| 394 |
+
#define NCURSES_CPP_CATCH(e) catch(e)
|
| 395 |
+
#if defined(__cpp_noexcept_function_type) && (__cpp_noexcept_function_type >= 201510)
|
| 396 |
+
// C++17 deprecates the usage of throw().
|
| 397 |
+
#define THROWS(s) /* nothing */
|
| 398 |
+
#define THROW2(s,t) /* nothing */
|
| 399 |
+
#else
|
| 400 |
+
#define THROWS(s) throw(s)
|
| 401 |
+
#define THROW2(s,t) throw(s,t)
|
| 402 |
+
#endif
|
| 403 |
+
#endif
|
| 404 |
+
}
|
| 405 |
+
|
| 406 |
+
#endif /* NCURSES_ETIP_H_incl */
|
llava_next/include/ncurses/form.h
ADDED
|
@@ -0,0 +1,460 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/****************************************************************************
|
| 2 |
+
* Copyright 2018-2019-2020,2021 Thomas E. Dickey *
|
| 3 |
+
* Copyright 1998-2016,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: Juergen Pfeifer, 1995,1997 *
|
| 32 |
+
****************************************************************************/
|
| 33 |
+
|
| 34 |
+
/* $Id: form.h,v 0.32 2021/06/17 21:26:02 tom Exp $ */
|
| 35 |
+
|
| 36 |
+
#ifndef FORM_H
|
| 37 |
+
#define FORM_H
|
| 38 |
+
/* *INDENT-OFF*/
|
| 39 |
+
|
| 40 |
+
#include <ncursesw/curses.h>
|
| 41 |
+
#include <ncursesw/eti.h>
|
| 42 |
+
|
| 43 |
+
#ifdef __cplusplus
|
| 44 |
+
extern "C" {
|
| 45 |
+
#endif
|
| 46 |
+
|
| 47 |
+
#if defined(BUILDING_FORM)
|
| 48 |
+
# define FORM_IMPEXP NCURSES_EXPORT_GENERAL_EXPORT
|
| 49 |
+
#else
|
| 50 |
+
# define FORM_IMPEXP NCURSES_EXPORT_GENERAL_IMPORT
|
| 51 |
+
#endif
|
| 52 |
+
|
| 53 |
+
#define FORM_WRAPPED_VAR(type,name) extern FORM_IMPEXP type NCURSES_PUBLIC_VAR(name)(void)
|
| 54 |
+
|
| 55 |
+
#define FORM_EXPORT(type) FORM_IMPEXP type NCURSES_API
|
| 56 |
+
#define FORM_EXPORT_VAR(type) FORM_IMPEXP type
|
| 57 |
+
|
| 58 |
+
#ifndef FORM_PRIV_H
|
| 59 |
+
typedef void *FIELD_CELL;
|
| 60 |
+
#endif
|
| 61 |
+
|
| 62 |
+
#ifndef NCURSES_FIELD_INTERNALS
|
| 63 |
+
#define NCURSES_FIELD_INTERNALS /* nothing */
|
| 64 |
+
#endif
|
| 65 |
+
|
| 66 |
+
typedef int Form_Options;
|
| 67 |
+
typedef int Field_Options;
|
| 68 |
+
|
| 69 |
+
/**********
|
| 70 |
+
* _PAGE *
|
| 71 |
+
**********/
|
| 72 |
+
|
| 73 |
+
typedef struct pagenode
|
| 74 |
+
#if !NCURSES_OPAQUE_FORM
|
| 75 |
+
{
|
| 76 |
+
short pmin; /* index of first field on page */
|
| 77 |
+
short pmax; /* index of last field on page */
|
| 78 |
+
short smin; /* index of top leftmost field on page */
|
| 79 |
+
short smax; /* index of bottom rightmost field on page */
|
| 80 |
+
}
|
| 81 |
+
#endif /* !NCURSES_OPAQUE_FORM */
|
| 82 |
+
_PAGE;
|
| 83 |
+
|
| 84 |
+
/**********
|
| 85 |
+
* FIELD *
|
| 86 |
+
**********/
|
| 87 |
+
|
| 88 |
+
typedef struct fieldnode
|
| 89 |
+
#if 1 /* not yet: !NCURSES_OPAQUE_FORM */
|
| 90 |
+
{
|
| 91 |
+
unsigned short status; /* flags */
|
| 92 |
+
short rows; /* size in rows */
|
| 93 |
+
short cols; /* size in cols */
|
| 94 |
+
short frow; /* first row */
|
| 95 |
+
short fcol; /* first col */
|
| 96 |
+
int drows; /* dynamic rows */
|
| 97 |
+
int dcols; /* dynamic cols */
|
| 98 |
+
int maxgrow; /* maximum field growth */
|
| 99 |
+
int nrow; /* off-screen rows */
|
| 100 |
+
short nbuf; /* additional buffers */
|
| 101 |
+
short just; /* justification */
|
| 102 |
+
short page; /* page on form */
|
| 103 |
+
short index; /* into form -> field */
|
| 104 |
+
int pad; /* pad character */
|
| 105 |
+
chtype fore; /* foreground attribute */
|
| 106 |
+
chtype back; /* background attribute */
|
| 107 |
+
Field_Options opts; /* options */
|
| 108 |
+
struct fieldnode * snext; /* sorted order pointer */
|
| 109 |
+
struct fieldnode * sprev; /* sorted order pointer */
|
| 110 |
+
struct fieldnode * link; /* linked field chain */
|
| 111 |
+
struct formnode * form; /* containing form */
|
| 112 |
+
struct typenode * type; /* field type */
|
| 113 |
+
void * arg; /* argument for type */
|
| 114 |
+
FIELD_CELL * buf; /* field buffers */
|
| 115 |
+
void * usrptr; /* user pointer */
|
| 116 |
+
/*
|
| 117 |
+
* The wide-character configuration requires extra information. Because
|
| 118 |
+
* there are existing applications that manipulate the members of FIELD
|
| 119 |
+
* directly, we cannot make the struct opaque, except by changing the ABI.
|
| 120 |
+
* Offsets of members up to this point are the same in the narrow- and
|
| 121 |
+
* wide-character configuration. But note that the type of buf depends on
|
| 122 |
+
* the configuration, and is made opaque for that reason.
|
| 123 |
+
*/
|
| 124 |
+
NCURSES_FIELD_INTERNALS
|
| 125 |
+
}
|
| 126 |
+
#endif /* NCURSES_OPAQUE_FORM */
|
| 127 |
+
FIELD;
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
/*********
|
| 131 |
+
* FORM *
|
| 132 |
+
*********/
|
| 133 |
+
|
| 134 |
+
typedef struct formnode
|
| 135 |
+
#if 1 /* not yet: !NCURSES_OPAQUE_FORM */
|
| 136 |
+
{
|
| 137 |
+
unsigned short status; /* flags */
|
| 138 |
+
short rows; /* size in rows */
|
| 139 |
+
short cols; /* size in cols */
|
| 140 |
+
int currow; /* current row in field window */
|
| 141 |
+
int curcol; /* current col in field window */
|
| 142 |
+
int toprow; /* in scrollable field window */
|
| 143 |
+
int begincol; /* in horiz. scrollable field */
|
| 144 |
+
short maxfield; /* number of fields */
|
| 145 |
+
short maxpage; /* number of pages */
|
| 146 |
+
short curpage; /* index into page */
|
| 147 |
+
Form_Options opts; /* options */
|
| 148 |
+
WINDOW * win; /* window */
|
| 149 |
+
WINDOW * sub; /* subwindow */
|
| 150 |
+
WINDOW * w; /* window for current field */
|
| 151 |
+
FIELD ** field; /* field [maxfield] */
|
| 152 |
+
FIELD * current; /* current field */
|
| 153 |
+
_PAGE * page; /* page [maxpage] */
|
| 154 |
+
void * usrptr; /* user pointer */
|
| 155 |
+
|
| 156 |
+
void (*forminit)(struct formnode *);
|
| 157 |
+
void (*formterm)(struct formnode *);
|
| 158 |
+
void (*fieldinit)(struct formnode *);
|
| 159 |
+
void (*fieldterm)(struct formnode *);
|
| 160 |
+
|
| 161 |
+
}
|
| 162 |
+
#endif /* !NCURSES_OPAQUE_FORM */
|
| 163 |
+
FORM;
|
| 164 |
+
|
| 165 |
+
|
| 166 |
+
/**************
|
| 167 |
+
* FIELDTYPE *
|
| 168 |
+
**************/
|
| 169 |
+
|
| 170 |
+
typedef struct typenode
|
| 171 |
+
#if !NCURSES_OPAQUE_FORM
|
| 172 |
+
{
|
| 173 |
+
unsigned short status; /* flags */
|
| 174 |
+
long ref; /* reference count */
|
| 175 |
+
struct typenode * left; /* ptr to operand for | */
|
| 176 |
+
struct typenode * right; /* ptr to operand for | */
|
| 177 |
+
|
| 178 |
+
void* (*makearg)(va_list *); /* make fieldtype arg */
|
| 179 |
+
void* (*copyarg)(const void *); /* copy fieldtype arg */
|
| 180 |
+
void (*freearg)(void *); /* free fieldtype arg */
|
| 181 |
+
|
| 182 |
+
#if NCURSES_INTEROP_FUNCS
|
| 183 |
+
union {
|
| 184 |
+
bool (*ofcheck)(FIELD *,const void *); /* field validation */
|
| 185 |
+
bool (*gfcheck)(FORM*,FIELD *,const void*); /* generic field validation */
|
| 186 |
+
} fieldcheck;
|
| 187 |
+
union {
|
| 188 |
+
bool (*occheck)(int,const void *); /* character validation */
|
| 189 |
+
bool (*gccheck)(int,FORM*,
|
| 190 |
+
FIELD*,const void*); /* generic char validation */
|
| 191 |
+
} charcheck;
|
| 192 |
+
union {
|
| 193 |
+
bool (*onext)(FIELD *,const void *); /* enumerate next value */
|
| 194 |
+
bool (*gnext)(FORM*,FIELD*,const void*); /* generic enumerate next */
|
| 195 |
+
} enum_next;
|
| 196 |
+
union {
|
| 197 |
+
bool (*oprev)(FIELD *,const void *); /* enumerate prev value */
|
| 198 |
+
bool (*gprev)(FORM*,FIELD*,const void*); /* generic enumerate prev */
|
| 199 |
+
} enum_prev;
|
| 200 |
+
void* (*genericarg)(void*); /* Alternate Arg method */
|
| 201 |
+
#else
|
| 202 |
+
bool (*fcheck)(FIELD *,const void *); /* field validation */
|
| 203 |
+
bool (*ccheck)(int,const void *); /* character validation */
|
| 204 |
+
|
| 205 |
+
bool (*next)(FIELD *,const void *); /* enumerate next value */
|
| 206 |
+
bool (*prev)(FIELD *,const void *); /* enumerate prev value */
|
| 207 |
+
#endif
|
| 208 |
+
}
|
| 209 |
+
#endif /* !NCURSES_OPAQUE_FORM */
|
| 210 |
+
FIELDTYPE;
|
| 211 |
+
|
| 212 |
+
typedef void (*Form_Hook)(FORM *);
|
| 213 |
+
|
| 214 |
+
/***************************
|
| 215 |
+
* miscellaneous #defines *
|
| 216 |
+
***************************/
|
| 217 |
+
|
| 218 |
+
/* field justification */
|
| 219 |
+
#define NO_JUSTIFICATION (0)
|
| 220 |
+
#define JUSTIFY_LEFT (1)
|
| 221 |
+
#define JUSTIFY_CENTER (2)
|
| 222 |
+
#define JUSTIFY_RIGHT (3)
|
| 223 |
+
|
| 224 |
+
/* field options */
|
| 225 |
+
#define O_VISIBLE (0x0001U)
|
| 226 |
+
#define O_ACTIVE (0x0002U)
|
| 227 |
+
#define O_PUBLIC (0x0004U)
|
| 228 |
+
#define O_EDIT (0x0008U)
|
| 229 |
+
#define O_WRAP (0x0010U)
|
| 230 |
+
#define O_BLANK (0x0020U)
|
| 231 |
+
#define O_AUTOSKIP (0x0040U)
|
| 232 |
+
#define O_NULLOK (0x0080U)
|
| 233 |
+
#define O_PASSOK (0x0100U)
|
| 234 |
+
#define O_STATIC (0x0200U)
|
| 235 |
+
#define O_DYNAMIC_JUSTIFY (0x0400U) /* ncurses extension */
|
| 236 |
+
#define O_NO_LEFT_STRIP (0x0800U) /* ncurses extension */
|
| 237 |
+
#define O_EDGE_INSERT_STAY (0x1000U) /* ncurses extension */
|
| 238 |
+
#define O_INPUT_LIMIT (0x2000U) /* ncurses extension */
|
| 239 |
+
|
| 240 |
+
/* form options */
|
| 241 |
+
#define O_NL_OVERLOAD (0x0001U)
|
| 242 |
+
#define O_BS_OVERLOAD (0x0002U)
|
| 243 |
+
|
| 244 |
+
/* form driver commands */
|
| 245 |
+
#define REQ_NEXT_PAGE (KEY_MAX + 1) /* move to next page */
|
| 246 |
+
#define REQ_PREV_PAGE (KEY_MAX + 2) /* move to previous page */
|
| 247 |
+
#define REQ_FIRST_PAGE (KEY_MAX + 3) /* move to first page */
|
| 248 |
+
#define REQ_LAST_PAGE (KEY_MAX + 4) /* move to last page */
|
| 249 |
+
|
| 250 |
+
#define REQ_NEXT_FIELD (KEY_MAX + 5) /* move to next field */
|
| 251 |
+
#define REQ_PREV_FIELD (KEY_MAX + 6) /* move to previous field */
|
| 252 |
+
#define REQ_FIRST_FIELD (KEY_MAX + 7) /* move to first field */
|
| 253 |
+
#define REQ_LAST_FIELD (KEY_MAX + 8) /* move to last field */
|
| 254 |
+
#define REQ_SNEXT_FIELD (KEY_MAX + 9) /* move to sorted next field */
|
| 255 |
+
#define REQ_SPREV_FIELD (KEY_MAX + 10) /* move to sorted prev field */
|
| 256 |
+
#define REQ_SFIRST_FIELD (KEY_MAX + 11) /* move to sorted first field */
|
| 257 |
+
#define REQ_SLAST_FIELD (KEY_MAX + 12) /* move to sorted last field */
|
| 258 |
+
#define REQ_LEFT_FIELD (KEY_MAX + 13) /* move to left to field */
|
| 259 |
+
#define REQ_RIGHT_FIELD (KEY_MAX + 14) /* move to right to field */
|
| 260 |
+
#define REQ_UP_FIELD (KEY_MAX + 15) /* move to up to field */
|
| 261 |
+
#define REQ_DOWN_FIELD (KEY_MAX + 16) /* move to down to field */
|
| 262 |
+
|
| 263 |
+
#define REQ_NEXT_CHAR (KEY_MAX + 17) /* move to next char in field */
|
| 264 |
+
#define REQ_PREV_CHAR (KEY_MAX + 18) /* move to prev char in field */
|
| 265 |
+
#define REQ_NEXT_LINE (KEY_MAX + 19) /* move to next line in field */
|
| 266 |
+
#define REQ_PREV_LINE (KEY_MAX + 20) /* move to prev line in field */
|
| 267 |
+
#define REQ_NEXT_WORD (KEY_MAX + 21) /* move to next word in field */
|
| 268 |
+
#define REQ_PREV_WORD (KEY_MAX + 22) /* move to prev word in field */
|
| 269 |
+
#define REQ_BEG_FIELD (KEY_MAX + 23) /* move to first char in field */
|
| 270 |
+
#define REQ_END_FIELD (KEY_MAX + 24) /* move after last char in fld */
|
| 271 |
+
#define REQ_BEG_LINE (KEY_MAX + 25) /* move to beginning of line */
|
| 272 |
+
#define REQ_END_LINE (KEY_MAX + 26) /* move after last char in line */
|
| 273 |
+
#define REQ_LEFT_CHAR (KEY_MAX + 27) /* move left in field */
|
| 274 |
+
#define REQ_RIGHT_CHAR (KEY_MAX + 28) /* move right in field */
|
| 275 |
+
#define REQ_UP_CHAR (KEY_MAX + 29) /* move up in field */
|
| 276 |
+
#define REQ_DOWN_CHAR (KEY_MAX + 30) /* move down in field */
|
| 277 |
+
|
| 278 |
+
#define REQ_NEW_LINE (KEY_MAX + 31) /* insert/overlay new line */
|
| 279 |
+
#define REQ_INS_CHAR (KEY_MAX + 32) /* insert blank char at cursor */
|
| 280 |
+
#define REQ_INS_LINE (KEY_MAX + 33) /* insert blank line at cursor */
|
| 281 |
+
#define REQ_DEL_CHAR (KEY_MAX + 34) /* delete char at cursor */
|
| 282 |
+
#define REQ_DEL_PREV (KEY_MAX + 35) /* delete char before cursor */
|
| 283 |
+
#define REQ_DEL_LINE (KEY_MAX + 36) /* delete line at cursor */
|
| 284 |
+
#define REQ_DEL_WORD (KEY_MAX + 37) /* delete word at cursor */
|
| 285 |
+
#define REQ_CLR_EOL (KEY_MAX + 38) /* clear to end of line */
|
| 286 |
+
#define REQ_CLR_EOF (KEY_MAX + 39) /* clear to end of field */
|
| 287 |
+
#define REQ_CLR_FIELD (KEY_MAX + 40) /* clear entire field */
|
| 288 |
+
#define REQ_OVL_MODE (KEY_MAX + 41) /* begin overlay mode */
|
| 289 |
+
#define REQ_INS_MODE (KEY_MAX + 42) /* begin insert mode */
|
| 290 |
+
#define REQ_SCR_FLINE (KEY_MAX + 43) /* scroll field forward a line */
|
| 291 |
+
#define REQ_SCR_BLINE (KEY_MAX + 44) /* scroll field backward a line */
|
| 292 |
+
#define REQ_SCR_FPAGE (KEY_MAX + 45) /* scroll field forward a page */
|
| 293 |
+
#define REQ_SCR_BPAGE (KEY_MAX + 46) /* scroll field backward a page */
|
| 294 |
+
#define REQ_SCR_FHPAGE (KEY_MAX + 47) /* scroll field forward half page */
|
| 295 |
+
#define REQ_SCR_BHPAGE (KEY_MAX + 48) /* scroll field backward half page */
|
| 296 |
+
#define REQ_SCR_FCHAR (KEY_MAX + 49) /* horizontal scroll char */
|
| 297 |
+
#define REQ_SCR_BCHAR (KEY_MAX + 50) /* horizontal scroll char */
|
| 298 |
+
#define REQ_SCR_HFLINE (KEY_MAX + 51) /* horizontal scroll line */
|
| 299 |
+
#define REQ_SCR_HBLINE (KEY_MAX + 52) /* horizontal scroll line */
|
| 300 |
+
#define REQ_SCR_HFHALF (KEY_MAX + 53) /* horizontal scroll half line */
|
| 301 |
+
#define REQ_SCR_HBHALF (KEY_MAX + 54) /* horizontal scroll half line */
|
| 302 |
+
|
| 303 |
+
#define REQ_VALIDATION (KEY_MAX + 55) /* validate field */
|
| 304 |
+
#define REQ_NEXT_CHOICE (KEY_MAX + 56) /* display next field choice */
|
| 305 |
+
#define REQ_PREV_CHOICE (KEY_MAX + 57) /* display prev field choice */
|
| 306 |
+
|
| 307 |
+
#define MIN_FORM_COMMAND (KEY_MAX + 1) /* used by form_driver */
|
| 308 |
+
#define MAX_FORM_COMMAND (KEY_MAX + 57) /* used by form_driver */
|
| 309 |
+
|
| 310 |
+
#if defined(MAX_COMMAND)
|
| 311 |
+
# if (MAX_FORM_COMMAND > MAX_COMMAND)
|
| 312 |
+
# error Something is wrong -- MAX_FORM_COMMAND is greater than MAX_COMMAND
|
| 313 |
+
# elif (MAX_COMMAND != (KEY_MAX + 128))
|
| 314 |
+
# error Something is wrong -- MAX_COMMAND is already inconsistently defined.
|
| 315 |
+
# endif
|
| 316 |
+
#else
|
| 317 |
+
# define MAX_COMMAND (KEY_MAX + 128)
|
| 318 |
+
#endif
|
| 319 |
+
|
| 320 |
+
/*************************
|
| 321 |
+
* standard field types *
|
| 322 |
+
*************************/
|
| 323 |
+
extern FORM_EXPORT_VAR(FIELDTYPE *) TYPE_ALPHA;
|
| 324 |
+
extern FORM_EXPORT_VAR(FIELDTYPE *) TYPE_ALNUM;
|
| 325 |
+
extern FORM_EXPORT_VAR(FIELDTYPE *) TYPE_ENUM;
|
| 326 |
+
extern FORM_EXPORT_VAR(FIELDTYPE *) TYPE_INTEGER;
|
| 327 |
+
extern FORM_EXPORT_VAR(FIELDTYPE *) TYPE_NUMERIC;
|
| 328 |
+
extern FORM_EXPORT_VAR(FIELDTYPE *) TYPE_REGEXP;
|
| 329 |
+
|
| 330 |
+
/************************************
|
| 331 |
+
* built-in additional field types *
|
| 332 |
+
* They are not defined in SVr4 *
|
| 333 |
+
************************************/
|
| 334 |
+
extern FORM_EXPORT_VAR(FIELDTYPE *) TYPE_IPV4; /* Internet IP Version 4 address */
|
| 335 |
+
|
| 336 |
+
/***********************
|
| 337 |
+
* FIELDTYPE routines *
|
| 338 |
+
***********************/
|
| 339 |
+
extern FORM_EXPORT(FIELDTYPE *) new_fieldtype (
|
| 340 |
+
bool (* const field_check)(FIELD *,const void *),
|
| 341 |
+
bool (* const char_check)(int,const void *));
|
| 342 |
+
extern FORM_EXPORT(FIELDTYPE *) link_fieldtype(
|
| 343 |
+
FIELDTYPE *, FIELDTYPE *);
|
| 344 |
+
|
| 345 |
+
extern FORM_EXPORT(int) free_fieldtype (FIELDTYPE *);
|
| 346 |
+
extern FORM_EXPORT(int) set_fieldtype_arg (FIELDTYPE *,
|
| 347 |
+
void * (* const make_arg)(va_list *),
|
| 348 |
+
void * (* const copy_arg)(const void *),
|
| 349 |
+
void (* const free_arg)(void *));
|
| 350 |
+
extern FORM_EXPORT(int) set_fieldtype_choice (FIELDTYPE *,
|
| 351 |
+
bool (* const next_choice)(FIELD *,const void *),
|
| 352 |
+
bool (* const prev_choice)(FIELD *,const void *));
|
| 353 |
+
|
| 354 |
+
/*******************
|
| 355 |
+
* FIELD routines *
|
| 356 |
+
*******************/
|
| 357 |
+
extern FORM_EXPORT(FIELD *) new_field (int,int,int,int,int,int);
|
| 358 |
+
extern FORM_EXPORT(FIELD *) dup_field (FIELD *,int,int);
|
| 359 |
+
extern FORM_EXPORT(FIELD *) link_field (FIELD *,int,int);
|
| 360 |
+
|
| 361 |
+
extern FORM_EXPORT(int) free_field (FIELD *);
|
| 362 |
+
extern FORM_EXPORT(int) field_info (const FIELD *,int *,int *,int *,int *,int *,int *);
|
| 363 |
+
extern FORM_EXPORT(int) dynamic_field_info (const FIELD *,int *,int *,int *);
|
| 364 |
+
extern FORM_EXPORT(int) set_max_field ( FIELD *,int);
|
| 365 |
+
extern FORM_EXPORT(int) move_field (FIELD *,int,int);
|
| 366 |
+
extern FORM_EXPORT(int) set_field_type (FIELD *,FIELDTYPE *,...);
|
| 367 |
+
extern FORM_EXPORT(int) set_new_page (FIELD *,bool);
|
| 368 |
+
extern FORM_EXPORT(int) set_field_just (FIELD *,int);
|
| 369 |
+
extern FORM_EXPORT(int) field_just (const FIELD *);
|
| 370 |
+
extern FORM_EXPORT(int) set_field_fore (FIELD *,chtype);
|
| 371 |
+
extern FORM_EXPORT(int) set_field_back (FIELD *,chtype);
|
| 372 |
+
extern FORM_EXPORT(int) set_field_pad (FIELD *,int);
|
| 373 |
+
extern FORM_EXPORT(int) field_pad (const FIELD *);
|
| 374 |
+
extern FORM_EXPORT(int) set_field_buffer (FIELD *,int,const char *);
|
| 375 |
+
extern FORM_EXPORT(int) set_field_status (FIELD *,bool);
|
| 376 |
+
extern FORM_EXPORT(int) set_field_userptr (FIELD *, void *);
|
| 377 |
+
extern FORM_EXPORT(int) set_field_opts (FIELD *,Field_Options);
|
| 378 |
+
extern FORM_EXPORT(int) field_opts_on (FIELD *,Field_Options);
|
| 379 |
+
extern FORM_EXPORT(int) field_opts_off (FIELD *,Field_Options);
|
| 380 |
+
|
| 381 |
+
extern FORM_EXPORT(chtype) field_fore (const FIELD *);
|
| 382 |
+
extern FORM_EXPORT(chtype) field_back (const FIELD *);
|
| 383 |
+
|
| 384 |
+
extern FORM_EXPORT(bool) new_page (const FIELD *);
|
| 385 |
+
extern FORM_EXPORT(bool) field_status (const FIELD *);
|
| 386 |
+
|
| 387 |
+
extern FORM_EXPORT(void *) field_arg (const FIELD *);
|
| 388 |
+
|
| 389 |
+
extern FORM_EXPORT(void *) field_userptr (const FIELD *);
|
| 390 |
+
|
| 391 |
+
extern FORM_EXPORT(FIELDTYPE *) field_type (const FIELD *);
|
| 392 |
+
|
| 393 |
+
extern FORM_EXPORT(char *) field_buffer (const FIELD *,int);
|
| 394 |
+
|
| 395 |
+
extern FORM_EXPORT(Field_Options) field_opts (const FIELD *);
|
| 396 |
+
|
| 397 |
+
/******************
|
| 398 |
+
* FORM routines *
|
| 399 |
+
******************/
|
| 400 |
+
|
| 401 |
+
extern FORM_EXPORT(FORM *) new_form (FIELD **);
|
| 402 |
+
|
| 403 |
+
extern FORM_EXPORT(FIELD **) form_fields (const FORM *);
|
| 404 |
+
extern FORM_EXPORT(FIELD *) current_field (const FORM *);
|
| 405 |
+
|
| 406 |
+
extern FORM_EXPORT(WINDOW *) form_win (const FORM *);
|
| 407 |
+
extern FORM_EXPORT(WINDOW *) form_sub (const FORM *);
|
| 408 |
+
|
| 409 |
+
extern FORM_EXPORT(Form_Hook) form_init (const FORM *);
|
| 410 |
+
extern FORM_EXPORT(Form_Hook) form_term (const FORM *);
|
| 411 |
+
extern FORM_EXPORT(Form_Hook) field_init (const FORM *);
|
| 412 |
+
extern FORM_EXPORT(Form_Hook) field_term (const FORM *);
|
| 413 |
+
|
| 414 |
+
extern FORM_EXPORT(int) free_form (FORM *);
|
| 415 |
+
extern FORM_EXPORT(int) set_form_fields (FORM *,FIELD **);
|
| 416 |
+
extern FORM_EXPORT(int) field_count (const FORM *);
|
| 417 |
+
extern FORM_EXPORT(int) set_form_win (FORM *,WINDOW *);
|
| 418 |
+
extern FORM_EXPORT(int) set_form_sub (FORM *,WINDOW *);
|
| 419 |
+
extern FORM_EXPORT(int) set_current_field (FORM *,FIELD *);
|
| 420 |
+
extern FORM_EXPORT(int) unfocus_current_field (FORM *);
|
| 421 |
+
extern FORM_EXPORT(int) field_index (const FIELD *);
|
| 422 |
+
extern FORM_EXPORT(int) set_form_page (FORM *,int);
|
| 423 |
+
extern FORM_EXPORT(int) form_page (const FORM *);
|
| 424 |
+
extern FORM_EXPORT(int) scale_form (const FORM *,int *,int *);
|
| 425 |
+
extern FORM_EXPORT(int) set_form_init (FORM *,Form_Hook);
|
| 426 |
+
extern FORM_EXPORT(int) set_form_term (FORM *,Form_Hook);
|
| 427 |
+
extern FORM_EXPORT(int) set_field_init (FORM *,Form_Hook);
|
| 428 |
+
extern FORM_EXPORT(int) set_field_term (FORM *,Form_Hook);
|
| 429 |
+
extern FORM_EXPORT(int) post_form (FORM *);
|
| 430 |
+
extern FORM_EXPORT(int) unpost_form (FORM *);
|
| 431 |
+
extern FORM_EXPORT(int) pos_form_cursor (FORM *);
|
| 432 |
+
extern FORM_EXPORT(int) form_driver (FORM *,int);
|
| 433 |
+
# if NCURSES_WIDECHAR
|
| 434 |
+
extern FORM_EXPORT(int) form_driver_w (FORM *,int,wchar_t);
|
| 435 |
+
# endif
|
| 436 |
+
extern FORM_EXPORT(int) set_form_userptr (FORM *,void *);
|
| 437 |
+
extern FORM_EXPORT(int) set_form_opts (FORM *,Form_Options);
|
| 438 |
+
extern FORM_EXPORT(int) form_opts_on (FORM *,Form_Options);
|
| 439 |
+
extern FORM_EXPORT(int) form_opts_off (FORM *,Form_Options);
|
| 440 |
+
extern FORM_EXPORT(int) form_request_by_name (const char *);
|
| 441 |
+
|
| 442 |
+
extern FORM_EXPORT(const char *) form_request_name (int);
|
| 443 |
+
|
| 444 |
+
extern FORM_EXPORT(void *) form_userptr (const FORM *);
|
| 445 |
+
|
| 446 |
+
extern FORM_EXPORT(Form_Options) form_opts (const FORM *);
|
| 447 |
+
|
| 448 |
+
extern FORM_EXPORT(bool) data_ahead (const FORM *);
|
| 449 |
+
extern FORM_EXPORT(bool) data_behind (const FORM *);
|
| 450 |
+
|
| 451 |
+
#if NCURSES_SP_FUNCS
|
| 452 |
+
extern FORM_EXPORT(FORM *) NCURSES_SP_NAME(new_form) (SCREEN*, FIELD **);
|
| 453 |
+
#endif
|
| 454 |
+
|
| 455 |
+
#ifdef __cplusplus
|
| 456 |
+
}
|
| 457 |
+
#endif
|
| 458 |
+
/* *INDENT-ON*/
|
| 459 |
+
|
| 460 |
+
#endif /* FORM_H */
|
llava_next/include/ncurses/menu.h
ADDED
|
@@ -0,0 +1,281 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/****************************************************************************
|
| 2 |
+
* Copyright 2020 Thomas E. Dickey *
|
| 3 |
+
* Copyright 1998-2016,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: Juergen Pfeifer, 1995,1997 *
|
| 32 |
+
****************************************************************************/
|
| 33 |
+
|
| 34 |
+
/* $Id: menu.h,v 1.26 2020/12/12 00:38:02 tom Exp $ */
|
| 35 |
+
|
| 36 |
+
#ifndef ETI_MENU
|
| 37 |
+
#define ETI_MENU
|
| 38 |
+
|
| 39 |
+
#ifdef AMIGA
|
| 40 |
+
#define TEXT TEXT_ncurses
|
| 41 |
+
#endif
|
| 42 |
+
|
| 43 |
+
#include <ncursesw/curses.h>
|
| 44 |
+
#include <ncursesw/eti.h>
|
| 45 |
+
|
| 46 |
+
#ifdef __cplusplus
|
| 47 |
+
extern "C"
|
| 48 |
+
{
|
| 49 |
+
#endif
|
| 50 |
+
|
| 51 |
+
#if defined(BUILDING_MENU)
|
| 52 |
+
# define MENU_IMPEXP NCURSES_EXPORT_GENERAL_EXPORT
|
| 53 |
+
#else
|
| 54 |
+
# define MENU_IMPEXP NCURSES_EXPORT_GENERAL_IMPORT
|
| 55 |
+
#endif
|
| 56 |
+
|
| 57 |
+
#define MENU_WRAPPED_VAR(type,name) extern MENU_IMPEXP type NCURSES_PUBLIC_VAR(name)(void)
|
| 58 |
+
|
| 59 |
+
#define MENU_EXPORT(type) MENU_IMPEXP type NCURSES_API
|
| 60 |
+
#define MENU_EXPORT_VAR(type) MENU_IMPEXP type
|
| 61 |
+
|
| 62 |
+
typedef int Menu_Options;
|
| 63 |
+
typedef int Item_Options;
|
| 64 |
+
|
| 65 |
+
/* Menu options: */
|
| 66 |
+
#define O_ONEVALUE (0x01)
|
| 67 |
+
#define O_SHOWDESC (0x02)
|
| 68 |
+
#define O_ROWMAJOR (0x04)
|
| 69 |
+
#define O_IGNORECASE (0x08)
|
| 70 |
+
#define O_SHOWMATCH (0x10)
|
| 71 |
+
#define O_NONCYCLIC (0x20)
|
| 72 |
+
#define O_MOUSE_MENU (0x40)
|
| 73 |
+
|
| 74 |
+
/* Item options: */
|
| 75 |
+
#define O_SELECTABLE (0x01)
|
| 76 |
+
|
| 77 |
+
#if !NCURSES_OPAQUE_MENU
|
| 78 |
+
typedef struct
|
| 79 |
+
{
|
| 80 |
+
const char *str;
|
| 81 |
+
unsigned short length;
|
| 82 |
+
}
|
| 83 |
+
TEXT;
|
| 84 |
+
#endif /* !NCURSES_OPAQUE_MENU */
|
| 85 |
+
|
| 86 |
+
struct tagMENU;
|
| 87 |
+
|
| 88 |
+
typedef struct tagITEM
|
| 89 |
+
#if !NCURSES_OPAQUE_MENU
|
| 90 |
+
{
|
| 91 |
+
TEXT name; /* name of menu item */
|
| 92 |
+
TEXT description; /* description of item, optional in display */
|
| 93 |
+
struct tagMENU *imenu; /* Pointer to parent menu */
|
| 94 |
+
void *userptr; /* Pointer to user defined per item data */
|
| 95 |
+
Item_Options opt; /* Item options */
|
| 96 |
+
short index; /* Item number if connected to a menu */
|
| 97 |
+
short y; /* y and x location of item in menu */
|
| 98 |
+
short x;
|
| 99 |
+
bool value; /* Selection value */
|
| 100 |
+
|
| 101 |
+
struct tagITEM *left; /* neighbor items */
|
| 102 |
+
struct tagITEM *right;
|
| 103 |
+
struct tagITEM *up;
|
| 104 |
+
struct tagITEM *down;
|
| 105 |
+
|
| 106 |
+
}
|
| 107 |
+
#endif /* !NCURSES_OPAQUE_MENU */
|
| 108 |
+
ITEM;
|
| 109 |
+
|
| 110 |
+
typedef void (*Menu_Hook) (struct tagMENU *);
|
| 111 |
+
|
| 112 |
+
typedef struct tagMENU
|
| 113 |
+
#if 1 /* not yet: !NCURSES_OPAQUE_MENU */
|
| 114 |
+
{
|
| 115 |
+
short height; /* Nr. of chars high */
|
| 116 |
+
short width; /* Nr. of chars wide */
|
| 117 |
+
short rows; /* Nr. of items high */
|
| 118 |
+
short cols; /* Nr. of items wide */
|
| 119 |
+
short frows; /* Nr. of formatted items high */
|
| 120 |
+
short fcols; /* Nr. of formatted items wide */
|
| 121 |
+
short arows; /* Nr. of items high (actual) */
|
| 122 |
+
short namelen; /* Max. name length */
|
| 123 |
+
short desclen; /* Max. description length */
|
| 124 |
+
short marklen; /* Length of mark, if any */
|
| 125 |
+
short itemlen; /* Length of one item */
|
| 126 |
+
short spc_desc; /* Spacing for descriptor */
|
| 127 |
+
short spc_cols; /* Spacing for columns */
|
| 128 |
+
short spc_rows; /* Spacing for rows */
|
| 129 |
+
char *pattern; /* Buffer to store match chars */
|
| 130 |
+
short pindex; /* Index into pattern buffer */
|
| 131 |
+
WINDOW *win; /* Window containing menu */
|
| 132 |
+
WINDOW *sub; /* Subwindow for menu display */
|
| 133 |
+
WINDOW *userwin; /* User's window */
|
| 134 |
+
WINDOW *usersub; /* User's subwindow */
|
| 135 |
+
ITEM **items; /* array of items */
|
| 136 |
+
short nitems; /* Nr. of items in menu */
|
| 137 |
+
ITEM *curitem; /* Current item */
|
| 138 |
+
short toprow; /* Top row of menu */
|
| 139 |
+
chtype fore; /* Selection attribute */
|
| 140 |
+
chtype back; /* Nonselection attribute */
|
| 141 |
+
chtype grey; /* Inactive attribute */
|
| 142 |
+
unsigned char pad; /* Pad character */
|
| 143 |
+
|
| 144 |
+
Menu_Hook menuinit; /* User hooks */
|
| 145 |
+
Menu_Hook menuterm;
|
| 146 |
+
Menu_Hook iteminit;
|
| 147 |
+
Menu_Hook itemterm;
|
| 148 |
+
|
| 149 |
+
void *userptr; /* Pointer to menus user data */
|
| 150 |
+
char *mark; /* Pointer to marker string */
|
| 151 |
+
|
| 152 |
+
Menu_Options opt; /* Menu options */
|
| 153 |
+
unsigned short status; /* Internal state of menu */
|
| 154 |
+
}
|
| 155 |
+
#endif /* !NCURSES_OPAQUE_MENU */
|
| 156 |
+
MENU;
|
| 157 |
+
|
| 158 |
+
/* Define keys */
|
| 159 |
+
|
| 160 |
+
#define REQ_LEFT_ITEM (KEY_MAX + 1)
|
| 161 |
+
#define REQ_RIGHT_ITEM (KEY_MAX + 2)
|
| 162 |
+
#define REQ_UP_ITEM (KEY_MAX + 3)
|
| 163 |
+
#define REQ_DOWN_ITEM (KEY_MAX + 4)
|
| 164 |
+
#define REQ_SCR_ULINE (KEY_MAX + 5)
|
| 165 |
+
#define REQ_SCR_DLINE (KEY_MAX + 6)
|
| 166 |
+
#define REQ_SCR_DPAGE (KEY_MAX + 7)
|
| 167 |
+
#define REQ_SCR_UPAGE (KEY_MAX + 8)
|
| 168 |
+
#define REQ_FIRST_ITEM (KEY_MAX + 9)
|
| 169 |
+
#define REQ_LAST_ITEM (KEY_MAX + 10)
|
| 170 |
+
#define REQ_NEXT_ITEM (KEY_MAX + 11)
|
| 171 |
+
#define REQ_PREV_ITEM (KEY_MAX + 12)
|
| 172 |
+
#define REQ_TOGGLE_ITEM (KEY_MAX + 13)
|
| 173 |
+
#define REQ_CLEAR_PATTERN (KEY_MAX + 14)
|
| 174 |
+
#define REQ_BACK_PATTERN (KEY_MAX + 15)
|
| 175 |
+
#define REQ_NEXT_MATCH (KEY_MAX + 16)
|
| 176 |
+
#define REQ_PREV_MATCH (KEY_MAX + 17)
|
| 177 |
+
|
| 178 |
+
#define MIN_MENU_COMMAND (KEY_MAX + 1)
|
| 179 |
+
#define MAX_MENU_COMMAND (KEY_MAX + 17)
|
| 180 |
+
|
| 181 |
+
/*
|
| 182 |
+
* Some AT&T code expects MAX_COMMAND to be out-of-band not
|
| 183 |
+
* just for menu commands but for forms ones as well.
|
| 184 |
+
*/
|
| 185 |
+
#if defined(MAX_COMMAND)
|
| 186 |
+
# if (MAX_MENU_COMMAND > MAX_COMMAND)
|
| 187 |
+
# error Something is wrong -- MAX_MENU_COMMAND is greater than MAX_COMMAND
|
| 188 |
+
# elif (MAX_COMMAND != (KEY_MAX + 128))
|
| 189 |
+
# error Something is wrong -- MAX_COMMAND is already inconsistently defined.
|
| 190 |
+
# endif
|
| 191 |
+
#else
|
| 192 |
+
# define MAX_COMMAND (KEY_MAX + 128)
|
| 193 |
+
#endif
|
| 194 |
+
|
| 195 |
+
/* --------- prototypes for libmenu functions ----------------------------- */
|
| 196 |
+
|
| 197 |
+
extern MENU_EXPORT(ITEM **) menu_items(const MENU *);
|
| 198 |
+
extern MENU_EXPORT(ITEM *) current_item(const MENU *);
|
| 199 |
+
extern MENU_EXPORT(ITEM *) new_item(const char *, const char *);
|
| 200 |
+
|
| 201 |
+
extern MENU_EXPORT(MENU *) new_menu(ITEM **);
|
| 202 |
+
|
| 203 |
+
extern MENU_EXPORT(Item_Options) item_opts(const ITEM *);
|
| 204 |
+
extern MENU_EXPORT(Menu_Options) menu_opts(const MENU *);
|
| 205 |
+
|
| 206 |
+
extern MENU_EXPORT(Menu_Hook) item_init(const MENU *);
|
| 207 |
+
extern MENU_EXPORT(Menu_Hook) item_term(const MENU *);
|
| 208 |
+
extern MENU_EXPORT(Menu_Hook) menu_init(const MENU *);
|
| 209 |
+
extern MENU_EXPORT(Menu_Hook) menu_term(const MENU *);
|
| 210 |
+
|
| 211 |
+
extern MENU_EXPORT(WINDOW *) menu_sub(const MENU *);
|
| 212 |
+
extern MENU_EXPORT(WINDOW *) menu_win(const MENU *);
|
| 213 |
+
|
| 214 |
+
extern MENU_EXPORT(const char *) item_description(const ITEM *);
|
| 215 |
+
extern MENU_EXPORT(const char *) item_name(const ITEM *);
|
| 216 |
+
extern MENU_EXPORT(const char *) menu_mark(const MENU *);
|
| 217 |
+
extern MENU_EXPORT(const char *) menu_request_name(int);
|
| 218 |
+
|
| 219 |
+
extern MENU_EXPORT(char *) menu_pattern(const MENU *);
|
| 220 |
+
|
| 221 |
+
extern MENU_EXPORT(void *) menu_userptr(const MENU *);
|
| 222 |
+
extern MENU_EXPORT(void *) item_userptr(const ITEM *);
|
| 223 |
+
|
| 224 |
+
extern MENU_EXPORT(chtype) menu_back(const MENU *);
|
| 225 |
+
extern MENU_EXPORT(chtype) menu_fore(const MENU *);
|
| 226 |
+
extern MENU_EXPORT(chtype) menu_grey(const MENU *);
|
| 227 |
+
|
| 228 |
+
extern MENU_EXPORT(int) free_item(ITEM *);
|
| 229 |
+
extern MENU_EXPORT(int) free_menu(MENU *);
|
| 230 |
+
extern MENU_EXPORT(int) item_count(const MENU *);
|
| 231 |
+
extern MENU_EXPORT(int) item_index(const ITEM *);
|
| 232 |
+
extern MENU_EXPORT(int) item_opts_off(ITEM *, Item_Options);
|
| 233 |
+
extern MENU_EXPORT(int) item_opts_on(ITEM *, Item_Options);
|
| 234 |
+
extern MENU_EXPORT(int) menu_driver(MENU *, int);
|
| 235 |
+
extern MENU_EXPORT(int) menu_opts_off(MENU *, Menu_Options);
|
| 236 |
+
extern MENU_EXPORT(int) menu_opts_on(MENU *, Menu_Options);
|
| 237 |
+
extern MENU_EXPORT(int) menu_pad(const MENU *);
|
| 238 |
+
extern MENU_EXPORT(int) pos_menu_cursor(const MENU *);
|
| 239 |
+
extern MENU_EXPORT(int) post_menu(MENU *);
|
| 240 |
+
extern MENU_EXPORT(int) scale_menu(const MENU *, int *, int *);
|
| 241 |
+
extern MENU_EXPORT(int) set_current_item(MENU *menu, ITEM *item);
|
| 242 |
+
extern MENU_EXPORT(int) set_item_init(MENU *, Menu_Hook);
|
| 243 |
+
extern MENU_EXPORT(int) set_item_opts(ITEM *, Item_Options);
|
| 244 |
+
extern MENU_EXPORT(int) set_item_term(MENU *, Menu_Hook);
|
| 245 |
+
extern MENU_EXPORT(int) set_item_userptr(ITEM *, void *);
|
| 246 |
+
extern MENU_EXPORT(int) set_item_value(ITEM *, bool);
|
| 247 |
+
extern MENU_EXPORT(int) set_menu_back(MENU *, chtype);
|
| 248 |
+
extern MENU_EXPORT(int) set_menu_fore(MENU *, chtype);
|
| 249 |
+
extern MENU_EXPORT(int) set_menu_format(MENU *, int, int);
|
| 250 |
+
extern MENU_EXPORT(int) set_menu_grey(MENU *, chtype);
|
| 251 |
+
extern MENU_EXPORT(int) set_menu_init(MENU *, Menu_Hook);
|
| 252 |
+
extern MENU_EXPORT(int) set_menu_items(MENU *, ITEM **);
|
| 253 |
+
extern MENU_EXPORT(int) set_menu_mark(MENU *, const char *);
|
| 254 |
+
extern MENU_EXPORT(int) set_menu_opts(MENU *, Menu_Options);
|
| 255 |
+
extern MENU_EXPORT(int) set_menu_pad(MENU *, int);
|
| 256 |
+
extern MENU_EXPORT(int) set_menu_pattern(MENU *, const char *);
|
| 257 |
+
extern MENU_EXPORT(int) set_menu_sub(MENU *, WINDOW *);
|
| 258 |
+
extern MENU_EXPORT(int) set_menu_term(MENU *, Menu_Hook);
|
| 259 |
+
extern MENU_EXPORT(int) set_menu_userptr(MENU *, void *);
|
| 260 |
+
extern MENU_EXPORT(int) set_menu_win(MENU *, WINDOW *);
|
| 261 |
+
extern MENU_EXPORT(int) set_top_row(MENU *, int);
|
| 262 |
+
extern MENU_EXPORT(int) top_row(const MENU *);
|
| 263 |
+
extern MENU_EXPORT(int) unpost_menu(MENU *);
|
| 264 |
+
extern MENU_EXPORT(int) menu_request_by_name(const char *);
|
| 265 |
+
extern MENU_EXPORT(int) set_menu_spacing(MENU *, int, int, int);
|
| 266 |
+
extern MENU_EXPORT(int) menu_spacing(const MENU *, int *, int *, int *);
|
| 267 |
+
|
| 268 |
+
extern MENU_EXPORT(bool) item_value(const ITEM *);
|
| 269 |
+
extern MENU_EXPORT(bool) item_visible(const ITEM *);
|
| 270 |
+
|
| 271 |
+
extern MENU_EXPORT(void) menu_format(const MENU *, int *, int *);
|
| 272 |
+
|
| 273 |
+
#if NCURSES_SP_FUNCS
|
| 274 |
+
extern MENU_EXPORT(MENU *) NCURSES_SP_NAME(new_menu) (SCREEN *, ITEM **);
|
| 275 |
+
#endif
|
| 276 |
+
|
| 277 |
+
#ifdef __cplusplus
|
| 278 |
+
}
|
| 279 |
+
#endif
|
| 280 |
+
|
| 281 |
+
#endif /* ETI_MENU */
|
llava_next/include/ncurses/nc_tparm.h
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/****************************************************************************
|
| 2 |
+
* Copyright 2018,2020 Thomas E. Dickey *
|
| 3 |
+
* Copyright 2006-2012,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 2006 *
|
| 32 |
+
****************************************************************************/
|
| 33 |
+
|
| 34 |
+
/* $Id: nc_tparm.h,v 1.11 2020/05/27 23:33:31 tom Exp $ */
|
| 35 |
+
|
| 36 |
+
#ifndef NC_TPARM_included
|
| 37 |
+
#define NC_TPARM_included 1
|
| 38 |
+
|
| 39 |
+
#include <ncurses_cfg.h>
|
| 40 |
+
#include <ncursesw/curses.h>
|
| 41 |
+
|
| 42 |
+
/*
|
| 43 |
+
* Cast parameters past the formatting-string for tparm() to match the
|
| 44 |
+
* assumption of the varargs code.
|
| 45 |
+
*/
|
| 46 |
+
#ifndef TPARM_ARG
|
| 47 |
+
#ifdef NCURSES_TPARM_ARG
|
| 48 |
+
#define TPARM_ARG NCURSES_TPARM_ARG
|
| 49 |
+
#else
|
| 50 |
+
#define TPARM_ARG long
|
| 51 |
+
#endif
|
| 52 |
+
#endif /* TPARAM_ARG */
|
| 53 |
+
|
| 54 |
+
#define TPARM_N(n) (TPARM_ARG)(n)
|
| 55 |
+
|
| 56 |
+
#define TPARM_9(a,b,c,d,e,f,g,h,i,j) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e),TPARM_N(f),TPARM_N(g),TPARM_N(h),TPARM_N(i),TPARM_N(j))
|
| 57 |
+
|
| 58 |
+
#if NCURSES_TPARM_VARARGS
|
| 59 |
+
#define TPARM_8(a,b,c,d,e,f,g,h,i) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e),TPARM_N(f),TPARM_N(g),TPARM_N(h),TPARM_N(i))
|
| 60 |
+
#define TPARM_7(a,b,c,d,e,f,g,h) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e),TPARM_N(f),TPARM_N(g),TPARM_N(h))
|
| 61 |
+
#define TPARM_6(a,b,c,d,e,f,g) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e),TPARM_N(f),TPARM_N(g))
|
| 62 |
+
#define TPARM_5(a,b,c,d,e,f) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e),TPARM_N(f))
|
| 63 |
+
#define TPARM_4(a,b,c,d,e) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e))
|
| 64 |
+
#define TPARM_3(a,b,c,d) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d))
|
| 65 |
+
#define TPARM_2(a,b,c) tparm(a,TPARM_N(b),TPARM_N(c))
|
| 66 |
+
#define TPARM_1(a,b) tparm(a,TPARM_N(b))
|
| 67 |
+
#define TPARM_0(a) tparm(a)
|
| 68 |
+
#else
|
| 69 |
+
#define TPARM_8(a,b,c,d,e,f,g,h,i) TPARM_9(a,b,c,d,e,f,g,h,i,0)
|
| 70 |
+
#define TPARM_7(a,b,c,d,e,f,g,h) TPARM_8(a,b,c,d,e,f,g,h,0)
|
| 71 |
+
#define TPARM_6(a,b,c,d,e,f,g) TPARM_7(a,b,c,d,e,f,g,0)
|
| 72 |
+
#define TPARM_5(a,b,c,d,e,f) TPARM_6(a,b,c,d,e,f,0)
|
| 73 |
+
#define TPARM_4(a,b,c,d,e) TPARM_5(a,b,c,d,e,0)
|
| 74 |
+
#define TPARM_3(a,b,c,d) TPARM_4(a,b,c,d,0)
|
| 75 |
+
#define TPARM_2(a,b,c) TPARM_3(a,b,c,0)
|
| 76 |
+
#define TPARM_1(a,b) TPARM_2(a,b,0)
|
| 77 |
+
#define TPARM_0(a) TPARM_1(a,0)
|
| 78 |
+
#endif
|
| 79 |
+
|
| 80 |
+
#ifdef NCURSES_INTERNALS
|
| 81 |
+
#define TIPARM_1(s,a) _nc_tiparm(1,s,a)
|
| 82 |
+
#define TIPARM_2(s,a,b) _nc_tiparm(2,s,a,b)
|
| 83 |
+
#define TIPARM_3(s,a,b,c) _nc_tiparm(3,s,a,b,c)
|
| 84 |
+
#define TIPARM_4(s,a,b,c,d) _nc_tiparm(4,s,a,b,c,d)
|
| 85 |
+
#define TIPARM_5(s,a,b,c,d,e) _nc_tiparm(5,s,a,b,c,d,e)
|
| 86 |
+
#define TIPARM_6(s,a,b,c,d,e,f) _nc_tiparm(6,s,a,b,c,d,e,f)
|
| 87 |
+
#define TIPARM_7(s,a,b,c,d,e,f,g) _nc_tiparm(7,s,a,b,c,d,e,f,g)
|
| 88 |
+
#define TIPARM_8(s,a,b,c,d,e,f,g,h) _nc_tiparm(8,s,a,b,c,d,e,f,g,h)
|
| 89 |
+
#define TIPARM_9(s,a,b,c,d,e,f,g,h,i) _nc_tiparm(9,s,a,b,c,d,e,f,g,h,i)
|
| 90 |
+
#endif
|
| 91 |
+
|
| 92 |
+
#endif /* NC_TPARM_included */
|
llava_next/include/ncurses/ncurses.h
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
llava_next/include/ncurses/ncurses_dll.h
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/****************************************************************************
|
| 2 |
+
* Copyright 2018,2020 Thomas E. Dickey *
|
| 3 |
+
* Copyright 2009,2014 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 |
+
/* $Id: ncurses_dll.h.in,v 1.17 2020/09/05 17:58:47 juergen Exp $ */
|
| 30 |
+
|
| 31 |
+
#ifndef NCURSES_DLL_H_incl
|
| 32 |
+
#define NCURSES_DLL_H_incl 1
|
| 33 |
+
|
| 34 |
+
/*
|
| 35 |
+
* MinGW gcc (unlike MSYS2 and Cygwin) should define _WIN32 and possibly _WIN64.
|
| 36 |
+
*/
|
| 37 |
+
#if defined(__MINGW64__)
|
| 38 |
+
|
| 39 |
+
#ifndef _WIN64
|
| 40 |
+
#define _WIN64 1
|
| 41 |
+
#endif
|
| 42 |
+
|
| 43 |
+
#elif defined(__MINGW32__)
|
| 44 |
+
|
| 45 |
+
#ifndef _WIN32
|
| 46 |
+
#define _WIN32 1
|
| 47 |
+
#endif
|
| 48 |
+
|
| 49 |
+
/* 2014-08-02 workaround for broken MinGW compiler.
|
| 50 |
+
* Oddly, only TRACE is mapped to trace - the other -D's are okay.
|
| 51 |
+
* suggest TDM as an alternative.
|
| 52 |
+
*/
|
| 53 |
+
#if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
|
| 54 |
+
|
| 55 |
+
#ifdef trace
|
| 56 |
+
#undef trace
|
| 57 |
+
#define TRACE
|
| 58 |
+
#endif
|
| 59 |
+
|
| 60 |
+
#endif /* broken compiler */
|
| 61 |
+
|
| 62 |
+
#endif /* MingW */
|
| 63 |
+
|
| 64 |
+
/*
|
| 65 |
+
* For reentrant code, we map the various global variables into SCREEN by
|
| 66 |
+
* using functions to access them.
|
| 67 |
+
*/
|
| 68 |
+
#define NCURSES_PUBLIC_VAR(name) _nc_##name
|
| 69 |
+
|
| 70 |
+
#if defined(BUILDING_NCURSES)
|
| 71 |
+
# define NCURSES_IMPEXP NCURSES_EXPORT_GENERAL_EXPORT
|
| 72 |
+
#else
|
| 73 |
+
# define NCURSES_IMPEXP NCURSES_EXPORT_GENERAL_IMPORT
|
| 74 |
+
#endif
|
| 75 |
+
|
| 76 |
+
#define NCURSES_WRAPPED_VAR(type,name) extern NCURSES_IMPEXP type NCURSES_PUBLIC_VAR(name)(void)
|
| 77 |
+
|
| 78 |
+
#define NCURSES_EXPORT(type) NCURSES_IMPEXP type NCURSES_API
|
| 79 |
+
#define NCURSES_EXPORT_VAR(type) NCURSES_IMPEXP type
|
| 80 |
+
|
| 81 |
+
/*
|
| 82 |
+
* These symbols hide dllimport/dllexport, for compilers which care about it.
|
| 83 |
+
*/
|
| 84 |
+
#if defined(__CYGWIN__) || (defined(_WIN32) || defined(_WIN64))
|
| 85 |
+
# if defined(NCURSES_STATIC) /* "static" here only implies "not-a-DLL" */
|
| 86 |
+
# define NCURSES_EXPORT_GENERAL_IMPORT
|
| 87 |
+
# define NCURSES_EXPORT_GENERAL_EXPORT
|
| 88 |
+
# else
|
| 89 |
+
# define NCURSES_EXPORT_GENERAL_IMPORT __declspec(dllimport)
|
| 90 |
+
# define NCURSES_EXPORT_GENERAL_EXPORT __declspec(dllexport)
|
| 91 |
+
# endif
|
| 92 |
+
# define NCURSES_API __cdecl
|
| 93 |
+
#else
|
| 94 |
+
# define NCURSES_EXPORT_GENERAL_IMPORT
|
| 95 |
+
# define NCURSES_EXPORT_GENERAL_EXPORT
|
| 96 |
+
# define NCURSES_API /* FIXME: __attribute__ ((cdecl)) is only available on x86 */
|
| 97 |
+
#endif
|
| 98 |
+
|
| 99 |
+
#endif /* NCURSES_DLL_H_incl */
|
llava_next/include/ncurses/panel.h
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/****************************************************************************
|
| 2 |
+
* Copyright 2020 Thomas E. Dickey *
|
| 3 |
+
* Copyright 1998-2009,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: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1995 *
|
| 32 |
+
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
|
| 33 |
+
* and: Juergen Pfeifer 1996-1999,2008 *
|
| 34 |
+
****************************************************************************/
|
| 35 |
+
|
| 36 |
+
/* $Id: panel.h,v 1.14 2020/07/04 20:38:43 tom Exp $ */
|
| 37 |
+
|
| 38 |
+
/* panel.h -- interface file for panels library */
|
| 39 |
+
|
| 40 |
+
#ifndef NCURSES_PANEL_H_incl
|
| 41 |
+
#define NCURSES_PANEL_H_incl 1
|
| 42 |
+
|
| 43 |
+
#include <ncursesw/curses.h>
|
| 44 |
+
|
| 45 |
+
typedef struct panel
|
| 46 |
+
#if !NCURSES_OPAQUE_PANEL
|
| 47 |
+
{
|
| 48 |
+
WINDOW *win;
|
| 49 |
+
struct panel *below;
|
| 50 |
+
struct panel *above;
|
| 51 |
+
NCURSES_CONST void *user;
|
| 52 |
+
}
|
| 53 |
+
#endif /* !NCURSES_OPAQUE_PANEL */
|
| 54 |
+
PANEL;
|
| 55 |
+
|
| 56 |
+
#if defined(__cplusplus)
|
| 57 |
+
extern "C" {
|
| 58 |
+
#endif
|
| 59 |
+
|
| 60 |
+
#if defined(BUILDING_PANEL)
|
| 61 |
+
# define PANEL_IMPEXP NCURSES_EXPORT_GENERAL_EXPORT
|
| 62 |
+
#else
|
| 63 |
+
# define PANEL_IMPEXP NCURSES_EXPORT_GENERAL_IMPORT
|
| 64 |
+
#endif
|
| 65 |
+
|
| 66 |
+
#define PANEL_WRAPPED_VAR(type,name) extern PANEL_IMPEXP type NCURSES_PUBLIC_VAR(name)(void)
|
| 67 |
+
|
| 68 |
+
#define PANEL_EXPORT(type) PANEL_IMPEXP type NCURSES_API
|
| 69 |
+
#define PANEL_EXPORT_VAR(type) PANEL_IMPEXP type
|
| 70 |
+
|
| 71 |
+
extern PANEL_EXPORT(WINDOW*) panel_window (const PANEL *);
|
| 72 |
+
extern PANEL_EXPORT(void) update_panels (void);
|
| 73 |
+
extern PANEL_EXPORT(int) hide_panel (PANEL *);
|
| 74 |
+
extern PANEL_EXPORT(int) show_panel (PANEL *);
|
| 75 |
+
extern PANEL_EXPORT(int) del_panel (PANEL *);
|
| 76 |
+
extern PANEL_EXPORT(int) top_panel (PANEL *);
|
| 77 |
+
extern PANEL_EXPORT(int) bottom_panel (PANEL *);
|
| 78 |
+
extern PANEL_EXPORT(PANEL*) new_panel (WINDOW *);
|
| 79 |
+
extern PANEL_EXPORT(PANEL*) panel_above (const PANEL *);
|
| 80 |
+
extern PANEL_EXPORT(PANEL*) panel_below (const PANEL *);
|
| 81 |
+
extern PANEL_EXPORT(int) set_panel_userptr (PANEL *, NCURSES_CONST void *);
|
| 82 |
+
extern PANEL_EXPORT(NCURSES_CONST void*) panel_userptr (const PANEL *);
|
| 83 |
+
extern PANEL_EXPORT(int) move_panel (PANEL *, int, int);
|
| 84 |
+
extern PANEL_EXPORT(int) replace_panel (PANEL *,WINDOW *);
|
| 85 |
+
extern PANEL_EXPORT(int) panel_hidden (const PANEL *);
|
| 86 |
+
|
| 87 |
+
#if NCURSES_SP_FUNCS
|
| 88 |
+
extern PANEL_EXPORT(PANEL *) ground_panel(SCREEN *);
|
| 89 |
+
extern PANEL_EXPORT(PANEL *) ceiling_panel(SCREEN *);
|
| 90 |
+
|
| 91 |
+
extern PANEL_EXPORT(void) NCURSES_SP_NAME(update_panels) (SCREEN*);
|
| 92 |
+
#endif
|
| 93 |
+
|
| 94 |
+
#if defined(__cplusplus)
|
| 95 |
+
}
|
| 96 |
+
#endif
|
| 97 |
+
|
| 98 |
+
#endif /* NCURSES_PANEL_H_incl */
|
| 99 |
+
|
| 100 |
+
/* end of panel.h */
|
llava_next/include/ncurses/term.h
ADDED
|
@@ -0,0 +1,893 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 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: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 */
|
| 32 |
+
/* and: Eric S. Raymond <esr@snark.thyrsus.com> */
|
| 33 |
+
/* and: Thomas E. Dickey 1995-on */
|
| 34 |
+
/****************************************************************************/
|
| 35 |
+
|
| 36 |
+
/* $Id: MKterm.h.awk.in,v 1.82 2021/09/24 17:02:46 tom Exp $ */
|
| 37 |
+
|
| 38 |
+
/*
|
| 39 |
+
** term.h -- Definition of struct term
|
| 40 |
+
*/
|
| 41 |
+
|
| 42 |
+
#ifndef NCURSES_TERM_H_incl
|
| 43 |
+
#define NCURSES_TERM_H_incl 1
|
| 44 |
+
|
| 45 |
+
#undef NCURSES_VERSION
|
| 46 |
+
#define NCURSES_VERSION "6.4"
|
| 47 |
+
|
| 48 |
+
#include <ncursesw/ncurses_dll.h>
|
| 49 |
+
|
| 50 |
+
#ifdef __cplusplus
|
| 51 |
+
extern "C" {
|
| 52 |
+
#endif
|
| 53 |
+
|
| 54 |
+
/* Make this file self-contained by providing defaults for the HAVE_TERMIO[S]_H
|
| 55 |
+
* definition (based on the system for which this was configured).
|
| 56 |
+
*/
|
| 57 |
+
|
| 58 |
+
#ifndef __NCURSES_H
|
| 59 |
+
|
| 60 |
+
typedef struct screen SCREEN;
|
| 61 |
+
|
| 62 |
+
#if 1
|
| 63 |
+
#undef NCURSES_SP_FUNCS
|
| 64 |
+
#define NCURSES_SP_FUNCS 20221231
|
| 65 |
+
#undef NCURSES_SP_NAME
|
| 66 |
+
#define NCURSES_SP_NAME(name) name##_sp
|
| 67 |
+
|
| 68 |
+
/* Define the sp-funcs helper function */
|
| 69 |
+
#undef NCURSES_SP_OUTC
|
| 70 |
+
#define NCURSES_SP_OUTC NCURSES_SP_NAME(NCURSES_OUTC)
|
| 71 |
+
typedef int (*NCURSES_SP_OUTC)(SCREEN*, int);
|
| 72 |
+
#endif
|
| 73 |
+
|
| 74 |
+
#endif /* __NCURSES_H */
|
| 75 |
+
|
| 76 |
+
#undef NCURSES_CONST
|
| 77 |
+
#define NCURSES_CONST const
|
| 78 |
+
|
| 79 |
+
#undef NCURSES_SBOOL
|
| 80 |
+
#define NCURSES_SBOOL char
|
| 81 |
+
|
| 82 |
+
#undef NCURSES_USE_DATABASE
|
| 83 |
+
#define NCURSES_USE_DATABASE 1
|
| 84 |
+
|
| 85 |
+
#undef NCURSES_USE_TERMCAP
|
| 86 |
+
#define NCURSES_USE_TERMCAP 1
|
| 87 |
+
|
| 88 |
+
#undef NCURSES_XNAMES
|
| 89 |
+
#define NCURSES_XNAMES 1
|
| 90 |
+
|
| 91 |
+
/* We will use these symbols to hide differences between
|
| 92 |
+
* termios/termio/sgttyb interfaces.
|
| 93 |
+
*/
|
| 94 |
+
#undef TTY
|
| 95 |
+
#undef SET_TTY
|
| 96 |
+
#undef GET_TTY
|
| 97 |
+
|
| 98 |
+
/* Assume POSIX termio if we have the header and function */
|
| 99 |
+
/* #if HAVE_TERMIOS_H && HAVE_TCGETATTR */
|
| 100 |
+
#if 1 && 1
|
| 101 |
+
|
| 102 |
+
#undef TERMIOS
|
| 103 |
+
#define TERMIOS 1
|
| 104 |
+
|
| 105 |
+
#include <termios.h>
|
| 106 |
+
#define TTY struct termios
|
| 107 |
+
|
| 108 |
+
#else /* !HAVE_TERMIOS_H */
|
| 109 |
+
|
| 110 |
+
/* #if HAVE_TERMIO_H */
|
| 111 |
+
#if 1
|
| 112 |
+
|
| 113 |
+
#undef TERMIOS
|
| 114 |
+
#define TERMIOS 1
|
| 115 |
+
|
| 116 |
+
#include <termio.h>
|
| 117 |
+
#define TTY struct termio
|
| 118 |
+
|
| 119 |
+
#else /* !HAVE_TERMIO_H */
|
| 120 |
+
|
| 121 |
+
#if (defined(_WIN32) || defined(_WIN64))
|
| 122 |
+
#if 0
|
| 123 |
+
#include <ncursesw/win32_curses.h>
|
| 124 |
+
#define TTY struct winconmode
|
| 125 |
+
#else
|
| 126 |
+
#include <ncursesw/ncurses_mingw.h>
|
| 127 |
+
#define TTY struct termios
|
| 128 |
+
#endif
|
| 129 |
+
#else
|
| 130 |
+
#undef TERMIOS
|
| 131 |
+
#include <sgtty.h>
|
| 132 |
+
#include <sys/ioctl.h>
|
| 133 |
+
#define TTY struct sgttyb
|
| 134 |
+
#endif /* MINGW32 */
|
| 135 |
+
#endif /* HAVE_TERMIO_H */
|
| 136 |
+
|
| 137 |
+
#endif /* HAVE_TERMIOS_H */
|
| 138 |
+
|
| 139 |
+
#ifdef TERMIOS
|
| 140 |
+
#define GET_TTY(fd, buf) tcgetattr(fd, buf)
|
| 141 |
+
#define SET_TTY(fd, buf) tcsetattr(fd, TCSADRAIN, buf)
|
| 142 |
+
#elif 0 && (defined(_WIN32) || defined(_WIN64))
|
| 143 |
+
#define GET_TTY(fd, buf) _nc_console_getmode(_nc_console_fd2handle(fd),buf)
|
| 144 |
+
#define SET_TTY(fd, buf) _nc_console_setmode(_nc_console_fd2handle(fd),buf)
|
| 145 |
+
#else
|
| 146 |
+
#define GET_TTY(fd, buf) gtty(fd, buf)
|
| 147 |
+
#define SET_TTY(fd, buf) stty(fd, buf)
|
| 148 |
+
#endif
|
| 149 |
+
|
| 150 |
+
#ifndef GCC_NORETURN
|
| 151 |
+
#define GCC_NORETURN /* nothing */
|
| 152 |
+
#endif
|
| 153 |
+
|
| 154 |
+
#define NAMESIZE 256
|
| 155 |
+
|
| 156 |
+
/* The cast works because TERMTYPE is the first data in TERMINAL */
|
| 157 |
+
#define CUR ((TERMTYPE *)(cur_term))->
|
| 158 |
+
|
| 159 |
+
#define auto_left_margin CUR Booleans[0]
|
| 160 |
+
#define auto_right_margin CUR Booleans[1]
|
| 161 |
+
#define no_esc_ctlc CUR Booleans[2]
|
| 162 |
+
#define ceol_standout_glitch CUR Booleans[3]
|
| 163 |
+
#define eat_newline_glitch CUR Booleans[4]
|
| 164 |
+
#define erase_overstrike CUR Booleans[5]
|
| 165 |
+
#define generic_type CUR Booleans[6]
|
| 166 |
+
#define hard_copy CUR Booleans[7]
|
| 167 |
+
#define has_meta_key CUR Booleans[8]
|
| 168 |
+
#define has_status_line CUR Booleans[9]
|
| 169 |
+
#define insert_null_glitch CUR Booleans[10]
|
| 170 |
+
#define memory_above CUR Booleans[11]
|
| 171 |
+
#define memory_below CUR Booleans[12]
|
| 172 |
+
#define move_insert_mode CUR Booleans[13]
|
| 173 |
+
#define move_standout_mode CUR Booleans[14]
|
| 174 |
+
#define over_strike CUR Booleans[15]
|
| 175 |
+
#define status_line_esc_ok CUR Booleans[16]
|
| 176 |
+
#define dest_tabs_magic_smso CUR Booleans[17]
|
| 177 |
+
#define tilde_glitch CUR Booleans[18]
|
| 178 |
+
#define transparent_underline CUR Booleans[19]
|
| 179 |
+
#define xon_xoff CUR Booleans[20]
|
| 180 |
+
#define needs_xon_xoff CUR Booleans[21]
|
| 181 |
+
#define prtr_silent CUR Booleans[22]
|
| 182 |
+
#define hard_cursor CUR Booleans[23]
|
| 183 |
+
#define non_rev_rmcup CUR Booleans[24]
|
| 184 |
+
#define no_pad_char CUR Booleans[25]
|
| 185 |
+
#define non_dest_scroll_region CUR Booleans[26]
|
| 186 |
+
#define can_change CUR Booleans[27]
|
| 187 |
+
#define back_color_erase CUR Booleans[28]
|
| 188 |
+
#define hue_lightness_saturation CUR Booleans[29]
|
| 189 |
+
#define col_addr_glitch CUR Booleans[30]
|
| 190 |
+
#define cr_cancels_micro_mode CUR Booleans[31]
|
| 191 |
+
#define has_print_wheel CUR Booleans[32]
|
| 192 |
+
#define row_addr_glitch CUR Booleans[33]
|
| 193 |
+
#define semi_auto_right_margin CUR Booleans[34]
|
| 194 |
+
#define cpi_changes_res CUR Booleans[35]
|
| 195 |
+
#define lpi_changes_res CUR Booleans[36]
|
| 196 |
+
#define columns CUR Numbers[0]
|
| 197 |
+
#define init_tabs CUR Numbers[1]
|
| 198 |
+
#define lines CUR Numbers[2]
|
| 199 |
+
#define lines_of_memory CUR Numbers[3]
|
| 200 |
+
#define magic_cookie_glitch CUR Numbers[4]
|
| 201 |
+
#define padding_baud_rate CUR Numbers[5]
|
| 202 |
+
#define virtual_terminal CUR Numbers[6]
|
| 203 |
+
#define width_status_line CUR Numbers[7]
|
| 204 |
+
#define num_labels CUR Numbers[8]
|
| 205 |
+
#define label_height CUR Numbers[9]
|
| 206 |
+
#define label_width CUR Numbers[10]
|
| 207 |
+
#define max_attributes CUR Numbers[11]
|
| 208 |
+
#define maximum_windows CUR Numbers[12]
|
| 209 |
+
#define max_colors CUR Numbers[13]
|
| 210 |
+
#define max_pairs CUR Numbers[14]
|
| 211 |
+
#define no_color_video CUR Numbers[15]
|
| 212 |
+
#define buffer_capacity CUR Numbers[16]
|
| 213 |
+
#define dot_vert_spacing CUR Numbers[17]
|
| 214 |
+
#define dot_horz_spacing CUR Numbers[18]
|
| 215 |
+
#define max_micro_address CUR Numbers[19]
|
| 216 |
+
#define max_micro_jump CUR Numbers[20]
|
| 217 |
+
#define micro_col_size CUR Numbers[21]
|
| 218 |
+
#define micro_line_size CUR Numbers[22]
|
| 219 |
+
#define number_of_pins CUR Numbers[23]
|
| 220 |
+
#define output_res_char CUR Numbers[24]
|
| 221 |
+
#define output_res_line CUR Numbers[25]
|
| 222 |
+
#define output_res_horz_inch CUR Numbers[26]
|
| 223 |
+
#define output_res_vert_inch CUR Numbers[27]
|
| 224 |
+
#define print_rate CUR Numbers[28]
|
| 225 |
+
#define wide_char_size CUR Numbers[29]
|
| 226 |
+
#define buttons CUR Numbers[30]
|
| 227 |
+
#define bit_image_entwining CUR Numbers[31]
|
| 228 |
+
#define bit_image_type CUR Numbers[32]
|
| 229 |
+
#define back_tab CUR Strings[0]
|
| 230 |
+
#define bell CUR Strings[1]
|
| 231 |
+
#define carriage_return CUR Strings[2]
|
| 232 |
+
#define change_scroll_region CUR Strings[3]
|
| 233 |
+
#define clear_all_tabs CUR Strings[4]
|
| 234 |
+
#define clear_screen CUR Strings[5]
|
| 235 |
+
#define clr_eol CUR Strings[6]
|
| 236 |
+
#define clr_eos CUR Strings[7]
|
| 237 |
+
#define column_address CUR Strings[8]
|
| 238 |
+
#define command_character CUR Strings[9]
|
| 239 |
+
#define cursor_address CUR Strings[10]
|
| 240 |
+
#define cursor_down CUR Strings[11]
|
| 241 |
+
#define cursor_home CUR Strings[12]
|
| 242 |
+
#define cursor_invisible CUR Strings[13]
|
| 243 |
+
#define cursor_left CUR Strings[14]
|
| 244 |
+
#define cursor_mem_address CUR Strings[15]
|
| 245 |
+
#define cursor_normal CUR Strings[16]
|
| 246 |
+
#define cursor_right CUR Strings[17]
|
| 247 |
+
#define cursor_to_ll CUR Strings[18]
|
| 248 |
+
#define cursor_up CUR Strings[19]
|
| 249 |
+
#define cursor_visible CUR Strings[20]
|
| 250 |
+
#define delete_character CUR Strings[21]
|
| 251 |
+
#define delete_line CUR Strings[22]
|
| 252 |
+
#define dis_status_line CUR Strings[23]
|
| 253 |
+
#define down_half_line CUR Strings[24]
|
| 254 |
+
#define enter_alt_charset_mode CUR Strings[25]
|
| 255 |
+
#define enter_blink_mode CUR Strings[26]
|
| 256 |
+
#define enter_bold_mode CUR Strings[27]
|
| 257 |
+
#define enter_ca_mode CUR Strings[28]
|
| 258 |
+
#define enter_delete_mode CUR Strings[29]
|
| 259 |
+
#define enter_dim_mode CUR Strings[30]
|
| 260 |
+
#define enter_insert_mode CUR Strings[31]
|
| 261 |
+
#define enter_secure_mode CUR Strings[32]
|
| 262 |
+
#define enter_protected_mode CUR Strings[33]
|
| 263 |
+
#define enter_reverse_mode CUR Strings[34]
|
| 264 |
+
#define enter_standout_mode CUR Strings[35]
|
| 265 |
+
#define enter_underline_mode CUR Strings[36]
|
| 266 |
+
#define erase_chars CUR Strings[37]
|
| 267 |
+
#define exit_alt_charset_mode CUR Strings[38]
|
| 268 |
+
#define exit_attribute_mode CUR Strings[39]
|
| 269 |
+
#define exit_ca_mode CUR Strings[40]
|
| 270 |
+
#define exit_delete_mode CUR Strings[41]
|
| 271 |
+
#define exit_insert_mode CUR Strings[42]
|
| 272 |
+
#define exit_standout_mode CUR Strings[43]
|
| 273 |
+
#define exit_underline_mode CUR Strings[44]
|
| 274 |
+
#define flash_screen CUR Strings[45]
|
| 275 |
+
#define form_feed CUR Strings[46]
|
| 276 |
+
#define from_status_line CUR Strings[47]
|
| 277 |
+
#define init_1string CUR Strings[48]
|
| 278 |
+
#define init_2string CUR Strings[49]
|
| 279 |
+
#define init_3string CUR Strings[50]
|
| 280 |
+
#define init_file CUR Strings[51]
|
| 281 |
+
#define insert_character CUR Strings[52]
|
| 282 |
+
#define insert_line CUR Strings[53]
|
| 283 |
+
#define insert_padding CUR Strings[54]
|
| 284 |
+
#define key_backspace CUR Strings[55]
|
| 285 |
+
#define key_catab CUR Strings[56]
|
| 286 |
+
#define key_clear CUR Strings[57]
|
| 287 |
+
#define key_ctab CUR Strings[58]
|
| 288 |
+
#define key_dc CUR Strings[59]
|
| 289 |
+
#define key_dl CUR Strings[60]
|
| 290 |
+
#define key_down CUR Strings[61]
|
| 291 |
+
#define key_eic CUR Strings[62]
|
| 292 |
+
#define key_eol CUR Strings[63]
|
| 293 |
+
#define key_eos CUR Strings[64]
|
| 294 |
+
#define key_f0 CUR Strings[65]
|
| 295 |
+
#define key_f1 CUR Strings[66]
|
| 296 |
+
#define key_f10 CUR Strings[67]
|
| 297 |
+
#define key_f2 CUR Strings[68]
|
| 298 |
+
#define key_f3 CUR Strings[69]
|
| 299 |
+
#define key_f4 CUR Strings[70]
|
| 300 |
+
#define key_f5 CUR Strings[71]
|
| 301 |
+
#define key_f6 CUR Strings[72]
|
| 302 |
+
#define key_f7 CUR Strings[73]
|
| 303 |
+
#define key_f8 CUR Strings[74]
|
| 304 |
+
#define key_f9 CUR Strings[75]
|
| 305 |
+
#define key_home CUR Strings[76]
|
| 306 |
+
#define key_ic CUR Strings[77]
|
| 307 |
+
#define key_il CUR Strings[78]
|
| 308 |
+
#define key_left CUR Strings[79]
|
| 309 |
+
#define key_ll CUR Strings[80]
|
| 310 |
+
#define key_npage CUR Strings[81]
|
| 311 |
+
#define key_ppage CUR Strings[82]
|
| 312 |
+
#define key_right CUR Strings[83]
|
| 313 |
+
#define key_sf CUR Strings[84]
|
| 314 |
+
#define key_sr CUR Strings[85]
|
| 315 |
+
#define key_stab CUR Strings[86]
|
| 316 |
+
#define key_up CUR Strings[87]
|
| 317 |
+
#define keypad_local CUR Strings[88]
|
| 318 |
+
#define keypad_xmit CUR Strings[89]
|
| 319 |
+
#define lab_f0 CUR Strings[90]
|
| 320 |
+
#define lab_f1 CUR Strings[91]
|
| 321 |
+
#define lab_f10 CUR Strings[92]
|
| 322 |
+
#define lab_f2 CUR Strings[93]
|
| 323 |
+
#define lab_f3 CUR Strings[94]
|
| 324 |
+
#define lab_f4 CUR Strings[95]
|
| 325 |
+
#define lab_f5 CUR Strings[96]
|
| 326 |
+
#define lab_f6 CUR Strings[97]
|
| 327 |
+
#define lab_f7 CUR Strings[98]
|
| 328 |
+
#define lab_f8 CUR Strings[99]
|
| 329 |
+
#define lab_f9 CUR Strings[100]
|
| 330 |
+
#define meta_off CUR Strings[101]
|
| 331 |
+
#define meta_on CUR Strings[102]
|
| 332 |
+
#define newline CUR Strings[103]
|
| 333 |
+
#define pad_char CUR Strings[104]
|
| 334 |
+
#define parm_dch CUR Strings[105]
|
| 335 |
+
#define parm_delete_line CUR Strings[106]
|
| 336 |
+
#define parm_down_cursor CUR Strings[107]
|
| 337 |
+
#define parm_ich CUR Strings[108]
|
| 338 |
+
#define parm_index CUR Strings[109]
|
| 339 |
+
#define parm_insert_line CUR Strings[110]
|
| 340 |
+
#define parm_left_cursor CUR Strings[111]
|
| 341 |
+
#define parm_right_cursor CUR Strings[112]
|
| 342 |
+
#define parm_rindex CUR Strings[113]
|
| 343 |
+
#define parm_up_cursor CUR Strings[114]
|
| 344 |
+
#define pkey_key CUR Strings[115]
|
| 345 |
+
#define pkey_local CUR Strings[116]
|
| 346 |
+
#define pkey_xmit CUR Strings[117]
|
| 347 |
+
#define print_screen CUR Strings[118]
|
| 348 |
+
#define prtr_off CUR Strings[119]
|
| 349 |
+
#define prtr_on CUR Strings[120]
|
| 350 |
+
#define repeat_char CUR Strings[121]
|
| 351 |
+
#define reset_1string CUR Strings[122]
|
| 352 |
+
#define reset_2string CUR Strings[123]
|
| 353 |
+
#define reset_3string CUR Strings[124]
|
| 354 |
+
#define reset_file CUR Strings[125]
|
| 355 |
+
#define restore_cursor CUR Strings[126]
|
| 356 |
+
#define row_address CUR Strings[127]
|
| 357 |
+
#define save_cursor CUR Strings[128]
|
| 358 |
+
#define scroll_forward CUR Strings[129]
|
| 359 |
+
#define scroll_reverse CUR Strings[130]
|
| 360 |
+
#define set_attributes CUR Strings[131]
|
| 361 |
+
#define set_tab CUR Strings[132]
|
| 362 |
+
#define set_window CUR Strings[133]
|
| 363 |
+
#define tab CUR Strings[134]
|
| 364 |
+
#define to_status_line CUR Strings[135]
|
| 365 |
+
#define underline_char CUR Strings[136]
|
| 366 |
+
#define up_half_line CUR Strings[137]
|
| 367 |
+
#define init_prog CUR Strings[138]
|
| 368 |
+
#define key_a1 CUR Strings[139]
|
| 369 |
+
#define key_a3 CUR Strings[140]
|
| 370 |
+
#define key_b2 CUR Strings[141]
|
| 371 |
+
#define key_c1 CUR Strings[142]
|
| 372 |
+
#define key_c3 CUR Strings[143]
|
| 373 |
+
#define prtr_non CUR Strings[144]
|
| 374 |
+
#define char_padding CUR Strings[145]
|
| 375 |
+
#define acs_chars CUR Strings[146]
|
| 376 |
+
#define plab_norm CUR Strings[147]
|
| 377 |
+
#define key_btab CUR Strings[148]
|
| 378 |
+
#define enter_xon_mode CUR Strings[149]
|
| 379 |
+
#define exit_xon_mode CUR Strings[150]
|
| 380 |
+
#define enter_am_mode CUR Strings[151]
|
| 381 |
+
#define exit_am_mode CUR Strings[152]
|
| 382 |
+
#define xon_character CUR Strings[153]
|
| 383 |
+
#define xoff_character CUR Strings[154]
|
| 384 |
+
#define ena_acs CUR Strings[155]
|
| 385 |
+
#define label_on CUR Strings[156]
|
| 386 |
+
#define label_off CUR Strings[157]
|
| 387 |
+
#define key_beg CUR Strings[158]
|
| 388 |
+
#define key_cancel CUR Strings[159]
|
| 389 |
+
#define key_close CUR Strings[160]
|
| 390 |
+
#define key_command CUR Strings[161]
|
| 391 |
+
#define key_copy CUR Strings[162]
|
| 392 |
+
#define key_create CUR Strings[163]
|
| 393 |
+
#define key_end CUR Strings[164]
|
| 394 |
+
#define key_enter CUR Strings[165]
|
| 395 |
+
#define key_exit CUR Strings[166]
|
| 396 |
+
#define key_find CUR Strings[167]
|
| 397 |
+
#define key_help CUR Strings[168]
|
| 398 |
+
#define key_mark CUR Strings[169]
|
| 399 |
+
#define key_message CUR Strings[170]
|
| 400 |
+
#define key_move CUR Strings[171]
|
| 401 |
+
#define key_next CUR Strings[172]
|
| 402 |
+
#define key_open CUR Strings[173]
|
| 403 |
+
#define key_options CUR Strings[174]
|
| 404 |
+
#define key_previous CUR Strings[175]
|
| 405 |
+
#define key_print CUR Strings[176]
|
| 406 |
+
#define key_redo CUR Strings[177]
|
| 407 |
+
#define key_reference CUR Strings[178]
|
| 408 |
+
#define key_refresh CUR Strings[179]
|
| 409 |
+
#define key_replace CUR Strings[180]
|
| 410 |
+
#define key_restart CUR Strings[181]
|
| 411 |
+
#define key_resume CUR Strings[182]
|
| 412 |
+
#define key_save CUR Strings[183]
|
| 413 |
+
#define key_suspend CUR Strings[184]
|
| 414 |
+
#define key_undo CUR Strings[185]
|
| 415 |
+
#define key_sbeg CUR Strings[186]
|
| 416 |
+
#define key_scancel CUR Strings[187]
|
| 417 |
+
#define key_scommand CUR Strings[188]
|
| 418 |
+
#define key_scopy CUR Strings[189]
|
| 419 |
+
#define key_screate CUR Strings[190]
|
| 420 |
+
#define key_sdc CUR Strings[191]
|
| 421 |
+
#define key_sdl CUR Strings[192]
|
| 422 |
+
#define key_select CUR Strings[193]
|
| 423 |
+
#define key_send CUR Strings[194]
|
| 424 |
+
#define key_seol CUR Strings[195]
|
| 425 |
+
#define key_sexit CUR Strings[196]
|
| 426 |
+
#define key_sfind CUR Strings[197]
|
| 427 |
+
#define key_shelp CUR Strings[198]
|
| 428 |
+
#define key_shome CUR Strings[199]
|
| 429 |
+
#define key_sic CUR Strings[200]
|
| 430 |
+
#define key_sleft CUR Strings[201]
|
| 431 |
+
#define key_smessage CUR Strings[202]
|
| 432 |
+
#define key_smove CUR Strings[203]
|
| 433 |
+
#define key_snext CUR Strings[204]
|
| 434 |
+
#define key_soptions CUR Strings[205]
|
| 435 |
+
#define key_sprevious CUR Strings[206]
|
| 436 |
+
#define key_sprint CUR Strings[207]
|
| 437 |
+
#define key_sredo CUR Strings[208]
|
| 438 |
+
#define key_sreplace CUR Strings[209]
|
| 439 |
+
#define key_sright CUR Strings[210]
|
| 440 |
+
#define key_srsume CUR Strings[211]
|
| 441 |
+
#define key_ssave CUR Strings[212]
|
| 442 |
+
#define key_ssuspend CUR Strings[213]
|
| 443 |
+
#define key_sundo CUR Strings[214]
|
| 444 |
+
#define req_for_input CUR Strings[215]
|
| 445 |
+
#define key_f11 CUR Strings[216]
|
| 446 |
+
#define key_f12 CUR Strings[217]
|
| 447 |
+
#define key_f13 CUR Strings[218]
|
| 448 |
+
#define key_f14 CUR Strings[219]
|
| 449 |
+
#define key_f15 CUR Strings[220]
|
| 450 |
+
#define key_f16 CUR Strings[221]
|
| 451 |
+
#define key_f17 CUR Strings[222]
|
| 452 |
+
#define key_f18 CUR Strings[223]
|
| 453 |
+
#define key_f19 CUR Strings[224]
|
| 454 |
+
#define key_f20 CUR Strings[225]
|
| 455 |
+
#define key_f21 CUR Strings[226]
|
| 456 |
+
#define key_f22 CUR Strings[227]
|
| 457 |
+
#define key_f23 CUR Strings[228]
|
| 458 |
+
#define key_f24 CUR Strings[229]
|
| 459 |
+
#define key_f25 CUR Strings[230]
|
| 460 |
+
#define key_f26 CUR Strings[231]
|
| 461 |
+
#define key_f27 CUR Strings[232]
|
| 462 |
+
#define key_f28 CUR Strings[233]
|
| 463 |
+
#define key_f29 CUR Strings[234]
|
| 464 |
+
#define key_f30 CUR Strings[235]
|
| 465 |
+
#define key_f31 CUR Strings[236]
|
| 466 |
+
#define key_f32 CUR Strings[237]
|
| 467 |
+
#define key_f33 CUR Strings[238]
|
| 468 |
+
#define key_f34 CUR Strings[239]
|
| 469 |
+
#define key_f35 CUR Strings[240]
|
| 470 |
+
#define key_f36 CUR Strings[241]
|
| 471 |
+
#define key_f37 CUR Strings[242]
|
| 472 |
+
#define key_f38 CUR Strings[243]
|
| 473 |
+
#define key_f39 CUR Strings[244]
|
| 474 |
+
#define key_f40 CUR Strings[245]
|
| 475 |
+
#define key_f41 CUR Strings[246]
|
| 476 |
+
#define key_f42 CUR Strings[247]
|
| 477 |
+
#define key_f43 CUR Strings[248]
|
| 478 |
+
#define key_f44 CUR Strings[249]
|
| 479 |
+
#define key_f45 CUR Strings[250]
|
| 480 |
+
#define key_f46 CUR Strings[251]
|
| 481 |
+
#define key_f47 CUR Strings[252]
|
| 482 |
+
#define key_f48 CUR Strings[253]
|
| 483 |
+
#define key_f49 CUR Strings[254]
|
| 484 |
+
#define key_f50 CUR Strings[255]
|
| 485 |
+
#define key_f51 CUR Strings[256]
|
| 486 |
+
#define key_f52 CUR Strings[257]
|
| 487 |
+
#define key_f53 CUR Strings[258]
|
| 488 |
+
#define key_f54 CUR Strings[259]
|
| 489 |
+
#define key_f55 CUR Strings[260]
|
| 490 |
+
#define key_f56 CUR Strings[261]
|
| 491 |
+
#define key_f57 CUR Strings[262]
|
| 492 |
+
#define key_f58 CUR Strings[263]
|
| 493 |
+
#define key_f59 CUR Strings[264]
|
| 494 |
+
#define key_f60 CUR Strings[265]
|
| 495 |
+
#define key_f61 CUR Strings[266]
|
| 496 |
+
#define key_f62 CUR Strings[267]
|
| 497 |
+
#define key_f63 CUR Strings[268]
|
| 498 |
+
#define clr_bol CUR Strings[269]
|
| 499 |
+
#define clear_margins CUR Strings[270]
|
| 500 |
+
#define set_left_margin CUR Strings[271]
|
| 501 |
+
#define set_right_margin CUR Strings[272]
|
| 502 |
+
#define label_format CUR Strings[273]
|
| 503 |
+
#define set_clock CUR Strings[274]
|
| 504 |
+
#define display_clock CUR Strings[275]
|
| 505 |
+
#define remove_clock CUR Strings[276]
|
| 506 |
+
#define create_window CUR Strings[277]
|
| 507 |
+
#define goto_window CUR Strings[278]
|
| 508 |
+
#define hangup CUR Strings[279]
|
| 509 |
+
#define dial_phone CUR Strings[280]
|
| 510 |
+
#define quick_dial CUR Strings[281]
|
| 511 |
+
#define tone CUR Strings[282]
|
| 512 |
+
#define pulse CUR Strings[283]
|
| 513 |
+
#define flash_hook CUR Strings[284]
|
| 514 |
+
#define fixed_pause CUR Strings[285]
|
| 515 |
+
#define wait_tone CUR Strings[286]
|
| 516 |
+
#define user0 CUR Strings[287]
|
| 517 |
+
#define user1 CUR Strings[288]
|
| 518 |
+
#define user2 CUR Strings[289]
|
| 519 |
+
#define user3 CUR Strings[290]
|
| 520 |
+
#define user4 CUR Strings[291]
|
| 521 |
+
#define user5 CUR Strings[292]
|
| 522 |
+
#define user6 CUR Strings[293]
|
| 523 |
+
#define user7 CUR Strings[294]
|
| 524 |
+
#define user8 CUR Strings[295]
|
| 525 |
+
#define user9 CUR Strings[296]
|
| 526 |
+
#define orig_pair CUR Strings[297]
|
| 527 |
+
#define orig_colors CUR Strings[298]
|
| 528 |
+
#define initialize_color CUR Strings[299]
|
| 529 |
+
#define initialize_pair CUR Strings[300]
|
| 530 |
+
#define set_color_pair CUR Strings[301]
|
| 531 |
+
#define set_foreground CUR Strings[302]
|
| 532 |
+
#define set_background CUR Strings[303]
|
| 533 |
+
#define change_char_pitch CUR Strings[304]
|
| 534 |
+
#define change_line_pitch CUR Strings[305]
|
| 535 |
+
#define change_res_horz CUR Strings[306]
|
| 536 |
+
#define change_res_vert CUR Strings[307]
|
| 537 |
+
#define define_char CUR Strings[308]
|
| 538 |
+
#define enter_doublewide_mode CUR Strings[309]
|
| 539 |
+
#define enter_draft_quality CUR Strings[310]
|
| 540 |
+
#define enter_italics_mode CUR Strings[311]
|
| 541 |
+
#define enter_leftward_mode CUR Strings[312]
|
| 542 |
+
#define enter_micro_mode CUR Strings[313]
|
| 543 |
+
#define enter_near_letter_quality CUR Strings[314]
|
| 544 |
+
#define enter_normal_quality CUR Strings[315]
|
| 545 |
+
#define enter_shadow_mode CUR Strings[316]
|
| 546 |
+
#define enter_subscript_mode CUR Strings[317]
|
| 547 |
+
#define enter_superscript_mode CUR Strings[318]
|
| 548 |
+
#define enter_upward_mode CUR Strings[319]
|
| 549 |
+
#define exit_doublewide_mode CUR Strings[320]
|
| 550 |
+
#define exit_italics_mode CUR Strings[321]
|
| 551 |
+
#define exit_leftward_mode CUR Strings[322]
|
| 552 |
+
#define exit_micro_mode CUR Strings[323]
|
| 553 |
+
#define exit_shadow_mode CUR Strings[324]
|
| 554 |
+
#define exit_subscript_mode CUR Strings[325]
|
| 555 |
+
#define exit_superscript_mode CUR Strings[326]
|
| 556 |
+
#define exit_upward_mode CUR Strings[327]
|
| 557 |
+
#define micro_column_address CUR Strings[328]
|
| 558 |
+
#define micro_down CUR Strings[329]
|
| 559 |
+
#define micro_left CUR Strings[330]
|
| 560 |
+
#define micro_right CUR Strings[331]
|
| 561 |
+
#define micro_row_address CUR Strings[332]
|
| 562 |
+
#define micro_up CUR Strings[333]
|
| 563 |
+
#define order_of_pins CUR Strings[334]
|
| 564 |
+
#define parm_down_micro CUR Strings[335]
|
| 565 |
+
#define parm_left_micro CUR Strings[336]
|
| 566 |
+
#define parm_right_micro CUR Strings[337]
|
| 567 |
+
#define parm_up_micro CUR Strings[338]
|
| 568 |
+
#define select_char_set CUR Strings[339]
|
| 569 |
+
#define set_bottom_margin CUR Strings[340]
|
| 570 |
+
#define set_bottom_margin_parm CUR Strings[341]
|
| 571 |
+
#define set_left_margin_parm CUR Strings[342]
|
| 572 |
+
#define set_right_margin_parm CUR Strings[343]
|
| 573 |
+
#define set_top_margin CUR Strings[344]
|
| 574 |
+
#define set_top_margin_parm CUR Strings[345]
|
| 575 |
+
#define start_bit_image CUR Strings[346]
|
| 576 |
+
#define start_char_set_def CUR Strings[347]
|
| 577 |
+
#define stop_bit_image CUR Strings[348]
|
| 578 |
+
#define stop_char_set_def CUR Strings[349]
|
| 579 |
+
#define subscript_characters CUR Strings[350]
|
| 580 |
+
#define superscript_characters CUR Strings[351]
|
| 581 |
+
#define these_cause_cr CUR Strings[352]
|
| 582 |
+
#define zero_motion CUR Strings[353]
|
| 583 |
+
#define char_set_names CUR Strings[354]
|
| 584 |
+
#define key_mouse CUR Strings[355]
|
| 585 |
+
#define mouse_info CUR Strings[356]
|
| 586 |
+
#define req_mouse_pos CUR Strings[357]
|
| 587 |
+
#define get_mouse CUR Strings[358]
|
| 588 |
+
#define set_a_foreground CUR Strings[359]
|
| 589 |
+
#define set_a_background CUR Strings[360]
|
| 590 |
+
#define pkey_plab CUR Strings[361]
|
| 591 |
+
#define device_type CUR Strings[362]
|
| 592 |
+
#define code_set_init CUR Strings[363]
|
| 593 |
+
#define set0_des_seq CUR Strings[364]
|
| 594 |
+
#define set1_des_seq CUR Strings[365]
|
| 595 |
+
#define set2_des_seq CUR Strings[366]
|
| 596 |
+
#define set3_des_seq CUR Strings[367]
|
| 597 |
+
#define set_lr_margin CUR Strings[368]
|
| 598 |
+
#define set_tb_margin CUR Strings[369]
|
| 599 |
+
#define bit_image_repeat CUR Strings[370]
|
| 600 |
+
#define bit_image_newline CUR Strings[371]
|
| 601 |
+
#define bit_image_carriage_return CUR Strings[372]
|
| 602 |
+
#define color_names CUR Strings[373]
|
| 603 |
+
#define define_bit_image_region CUR Strings[374]
|
| 604 |
+
#define end_bit_image_region CUR Strings[375]
|
| 605 |
+
#define set_color_band CUR Strings[376]
|
| 606 |
+
#define set_page_length CUR Strings[377]
|
| 607 |
+
#define display_pc_char CUR Strings[378]
|
| 608 |
+
#define enter_pc_charset_mode CUR Strings[379]
|
| 609 |
+
#define exit_pc_charset_mode CUR Strings[380]
|
| 610 |
+
#define enter_scancode_mode CUR Strings[381]
|
| 611 |
+
#define exit_scancode_mode CUR Strings[382]
|
| 612 |
+
#define pc_term_options CUR Strings[383]
|
| 613 |
+
#define scancode_escape CUR Strings[384]
|
| 614 |
+
#define alt_scancode_esc CUR Strings[385]
|
| 615 |
+
#define enter_horizontal_hl_mode CUR Strings[386]
|
| 616 |
+
#define enter_left_hl_mode CUR Strings[387]
|
| 617 |
+
#define enter_low_hl_mode CUR Strings[388]
|
| 618 |
+
#define enter_right_hl_mode CUR Strings[389]
|
| 619 |
+
#define enter_top_hl_mode CUR Strings[390]
|
| 620 |
+
#define enter_vertical_hl_mode CUR Strings[391]
|
| 621 |
+
#define set_a_attributes CUR Strings[392]
|
| 622 |
+
#define set_pglen_inch CUR Strings[393]
|
| 623 |
+
|
| 624 |
+
#define BOOLWRITE 37
|
| 625 |
+
#define NUMWRITE 33
|
| 626 |
+
#define STRWRITE 394
|
| 627 |
+
|
| 628 |
+
/* older synonyms for some capabilities */
|
| 629 |
+
#define beehive_glitch no_esc_ctlc
|
| 630 |
+
#define teleray_glitch dest_tabs_magic_smso
|
| 631 |
+
|
| 632 |
+
/* HPUX-11 uses this name rather than the standard one */
|
| 633 |
+
#ifndef micro_char_size
|
| 634 |
+
#define micro_char_size micro_col_size
|
| 635 |
+
#endif
|
| 636 |
+
|
| 637 |
+
#ifdef __INTERNAL_CAPS_VISIBLE
|
| 638 |
+
#define termcap_init2 CUR Strings[394]
|
| 639 |
+
#define termcap_reset CUR Strings[395]
|
| 640 |
+
#define magic_cookie_glitch_ul CUR Numbers[33]
|
| 641 |
+
#define backspaces_with_bs CUR Booleans[37]
|
| 642 |
+
#define crt_no_scrolling CUR Booleans[38]
|
| 643 |
+
#define no_correctly_working_cr CUR Booleans[39]
|
| 644 |
+
#define carriage_return_delay CUR Numbers[34]
|
| 645 |
+
#define new_line_delay CUR Numbers[35]
|
| 646 |
+
#define linefeed_if_not_lf CUR Strings[396]
|
| 647 |
+
#define backspace_if_not_bs CUR Strings[397]
|
| 648 |
+
#define gnu_has_meta_key CUR Booleans[40]
|
| 649 |
+
#define linefeed_is_newline CUR Booleans[41]
|
| 650 |
+
#define backspace_delay CUR Numbers[36]
|
| 651 |
+
#define horizontal_tab_delay CUR Numbers[37]
|
| 652 |
+
#define number_of_function_keys CUR Numbers[38]
|
| 653 |
+
#define other_non_function_keys CUR Strings[398]
|
| 654 |
+
#define arrow_key_map CUR Strings[399]
|
| 655 |
+
#define has_hardware_tabs CUR Booleans[42]
|
| 656 |
+
#define return_does_clr_eol CUR Booleans[43]
|
| 657 |
+
#define acs_ulcorner CUR Strings[400]
|
| 658 |
+
#define acs_llcorner CUR Strings[401]
|
| 659 |
+
#define acs_urcorner CUR Strings[402]
|
| 660 |
+
#define acs_lrcorner CUR Strings[403]
|
| 661 |
+
#define acs_ltee CUR Strings[404]
|
| 662 |
+
#define acs_rtee CUR Strings[405]
|
| 663 |
+
#define acs_btee CUR Strings[406]
|
| 664 |
+
#define acs_ttee CUR Strings[407]
|
| 665 |
+
#define acs_hline CUR Strings[408]
|
| 666 |
+
#define acs_vline CUR Strings[409]
|
| 667 |
+
#define acs_plus CUR Strings[410]
|
| 668 |
+
#define memory_lock CUR Strings[411]
|
| 669 |
+
#define memory_unlock CUR Strings[412]
|
| 670 |
+
#define box_chars_1 CUR Strings[413]
|
| 671 |
+
#endif /* __INTERNAL_CAPS_VISIBLE */
|
| 672 |
+
|
| 673 |
+
|
| 674 |
+
/*
|
| 675 |
+
* Predefined terminfo array sizes
|
| 676 |
+
*/
|
| 677 |
+
#define BOOLCOUNT 44
|
| 678 |
+
#define NUMCOUNT 39
|
| 679 |
+
#define STRCOUNT 414
|
| 680 |
+
|
| 681 |
+
/* used by code for comparing entries */
|
| 682 |
+
#define acs_chars_index 146
|
| 683 |
+
|
| 684 |
+
typedef struct termtype { /* in-core form of terminfo data */
|
| 685 |
+
char *term_names; /* str_table offset of term names */
|
| 686 |
+
char *str_table; /* pointer to string table */
|
| 687 |
+
NCURSES_SBOOL *Booleans; /* array of boolean values */
|
| 688 |
+
short *Numbers; /* array of integer values */
|
| 689 |
+
char **Strings; /* array of string offsets */
|
| 690 |
+
|
| 691 |
+
#if NCURSES_XNAMES
|
| 692 |
+
char *ext_str_table; /* pointer to extended string table */
|
| 693 |
+
char **ext_Names; /* corresponding names */
|
| 694 |
+
|
| 695 |
+
unsigned short num_Booleans;/* count total Booleans */
|
| 696 |
+
unsigned short num_Numbers; /* count total Numbers */
|
| 697 |
+
unsigned short num_Strings; /* count total Strings */
|
| 698 |
+
|
| 699 |
+
unsigned short ext_Booleans;/* count extensions to Booleans */
|
| 700 |
+
unsigned short ext_Numbers; /* count extensions to Numbers */
|
| 701 |
+
unsigned short ext_Strings; /* count extensions to Strings */
|
| 702 |
+
#endif /* NCURSES_XNAMES */
|
| 703 |
+
|
| 704 |
+
} TERMTYPE;
|
| 705 |
+
|
| 706 |
+
/*
|
| 707 |
+
* The only reason these structures are visible is for read-only use.
|
| 708 |
+
* Programs which modify the data are not, never were, portable across
|
| 709 |
+
* curses implementations.
|
| 710 |
+
*
|
| 711 |
+
* The first field in TERMINAL is used in macros.
|
| 712 |
+
* The remaining fields are private.
|
| 713 |
+
*/
|
| 714 |
+
#ifdef NCURSES_INTERNALS
|
| 715 |
+
|
| 716 |
+
#undef TERMINAL
|
| 717 |
+
#define TERMINAL struct term
|
| 718 |
+
TERMINAL;
|
| 719 |
+
|
| 720 |
+
typedef struct termtype2 { /* in-core form of terminfo data */
|
| 721 |
+
char *term_names; /* str_table offset of term names */
|
| 722 |
+
char *str_table; /* pointer to string table */
|
| 723 |
+
NCURSES_SBOOL *Booleans; /* array of boolean values */
|
| 724 |
+
int *Numbers; /* array of integer values */
|
| 725 |
+
char **Strings; /* array of string offsets */
|
| 726 |
+
|
| 727 |
+
#if NCURSES_XNAMES
|
| 728 |
+
char *ext_str_table; /* pointer to extended string table */
|
| 729 |
+
char **ext_Names; /* corresponding names */
|
| 730 |
+
|
| 731 |
+
unsigned short num_Booleans;/* count total Booleans */
|
| 732 |
+
unsigned short num_Numbers; /* count total Numbers */
|
| 733 |
+
unsigned short num_Strings; /* count total Strings */
|
| 734 |
+
|
| 735 |
+
unsigned short ext_Booleans;/* count extensions to Booleans */
|
| 736 |
+
unsigned short ext_Numbers; /* count extensions to Numbers */
|
| 737 |
+
unsigned short ext_Strings; /* count extensions to Strings */
|
| 738 |
+
#endif /* NCURSES_XNAMES */
|
| 739 |
+
|
| 740 |
+
} TERMTYPE2;
|
| 741 |
+
#else
|
| 742 |
+
|
| 743 |
+
typedef struct term { /* describe an actual terminal */
|
| 744 |
+
TERMTYPE type; /* terminal type description */
|
| 745 |
+
} TERMINAL;
|
| 746 |
+
|
| 747 |
+
#endif /* NCURSES_INTERNALS */
|
| 748 |
+
|
| 749 |
+
|
| 750 |
+
#if 0 && !0
|
| 751 |
+
extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;
|
| 752 |
+
#elif 0
|
| 753 |
+
NCURSES_WRAPPED_VAR(TERMINAL *, cur_term);
|
| 754 |
+
#define cur_term NCURSES_PUBLIC_VAR(cur_term())
|
| 755 |
+
#else
|
| 756 |
+
extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;
|
| 757 |
+
#endif
|
| 758 |
+
|
| 759 |
+
#if 0 || 0
|
| 760 |
+
NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolnames);
|
| 761 |
+
NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolcodes);
|
| 762 |
+
NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolfnames);
|
| 763 |
+
NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numnames);
|
| 764 |
+
NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numcodes);
|
| 765 |
+
NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numfnames);
|
| 766 |
+
NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strnames);
|
| 767 |
+
NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strcodes);
|
| 768 |
+
NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strfnames);
|
| 769 |
+
|
| 770 |
+
#define boolnames NCURSES_PUBLIC_VAR(boolnames())
|
| 771 |
+
#define boolcodes NCURSES_PUBLIC_VAR(boolcodes())
|
| 772 |
+
#define boolfnames NCURSES_PUBLIC_VAR(boolfnames())
|
| 773 |
+
#define numnames NCURSES_PUBLIC_VAR(numnames())
|
| 774 |
+
#define numcodes NCURSES_PUBLIC_VAR(numcodes())
|
| 775 |
+
#define numfnames NCURSES_PUBLIC_VAR(numfnames())
|
| 776 |
+
#define strnames NCURSES_PUBLIC_VAR(strnames())
|
| 777 |
+
#define strcodes NCURSES_PUBLIC_VAR(strcodes())
|
| 778 |
+
#define strfnames NCURSES_PUBLIC_VAR(strfnames())
|
| 779 |
+
|
| 780 |
+
#else
|
| 781 |
+
|
| 782 |
+
extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolnames[];
|
| 783 |
+
extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolcodes[];
|
| 784 |
+
extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolfnames[];
|
| 785 |
+
extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numnames[];
|
| 786 |
+
extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numcodes[];
|
| 787 |
+
extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numfnames[];
|
| 788 |
+
extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strnames[];
|
| 789 |
+
extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strcodes[];
|
| 790 |
+
extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strfnames[];
|
| 791 |
+
|
| 792 |
+
#endif
|
| 793 |
+
|
| 794 |
+
/*
|
| 795 |
+
* These entrypoints are used only by the ncurses utilities such as tic.
|
| 796 |
+
*/
|
| 797 |
+
#ifdef NCURSES_INTERNALS
|
| 798 |
+
|
| 799 |
+
extern NCURSES_EXPORT(int) _nc_set_tty_mode (TTY *buf);
|
| 800 |
+
extern NCURSES_EXPORT(int) _nc_read_entry2 (const char * const, char * const, TERMTYPE2 *const);
|
| 801 |
+
extern NCURSES_EXPORT(int) _nc_read_file_entry (const char *const, TERMTYPE2 *);
|
| 802 |
+
extern NCURSES_EXPORT(int) _nc_read_termtype (TERMTYPE2 *, char *, int);
|
| 803 |
+
extern NCURSES_EXPORT(char *) _nc_first_name (const char *const);
|
| 804 |
+
extern NCURSES_EXPORT(int) _nc_name_match (const char *const, const char *const, const char *const);
|
| 805 |
+
extern NCURSES_EXPORT(char *) _nc_tiparm(int, const char *, ...);
|
| 806 |
+
|
| 807 |
+
#endif /* NCURSES_INTERNALS */
|
| 808 |
+
|
| 809 |
+
|
| 810 |
+
/*
|
| 811 |
+
* These entrypoints are used by tack 1.07.
|
| 812 |
+
*/
|
| 813 |
+
extern NCURSES_EXPORT(const TERMTYPE *) _nc_fallback (const char *);
|
| 814 |
+
extern NCURSES_EXPORT(int) _nc_read_entry (const char * const, char * const, TERMTYPE *const);
|
| 815 |
+
|
| 816 |
+
/*
|
| 817 |
+
* Normal entry points
|
| 818 |
+
*/
|
| 819 |
+
extern NCURSES_EXPORT(TERMINAL *) set_curterm (TERMINAL *);
|
| 820 |
+
extern NCURSES_EXPORT(int) del_curterm (TERMINAL *);
|
| 821 |
+
|
| 822 |
+
/* miscellaneous entry points */
|
| 823 |
+
extern NCURSES_EXPORT(int) restartterm (NCURSES_CONST char *, int, int *);
|
| 824 |
+
extern NCURSES_EXPORT(int) setupterm (const char *,int,int *);
|
| 825 |
+
|
| 826 |
+
/* terminfo entry points, also declared in curses.h */
|
| 827 |
+
#if !defined(__NCURSES_H)
|
| 828 |
+
extern NCURSES_EXPORT(char *) tigetstr (const char *);
|
| 829 |
+
extern NCURSES_EXPORT_VAR(char) ttytype[];
|
| 830 |
+
extern NCURSES_EXPORT(int) putp (const char *);
|
| 831 |
+
extern NCURSES_EXPORT(int) tigetflag (const char *);
|
| 832 |
+
extern NCURSES_EXPORT(int) tigetnum (const char *);
|
| 833 |
+
|
| 834 |
+
#if 1 /* NCURSES_TPARM_VARARGS */
|
| 835 |
+
extern NCURSES_EXPORT(char *) tparm (const char *, ...); /* special */
|
| 836 |
+
#else
|
| 837 |
+
extern NCURSES_EXPORT(char *) tparm (const char *, long,long,long,long,long,long,long,long,long); /* special */
|
| 838 |
+
#endif
|
| 839 |
+
|
| 840 |
+
extern NCURSES_EXPORT(char *) tiparm (const char *, ...); /* special */
|
| 841 |
+
|
| 842 |
+
#endif /* __NCURSES_H */
|
| 843 |
+
|
| 844 |
+
/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */
|
| 845 |
+
#if !defined(NCURSES_TERMCAP_H_incl)
|
| 846 |
+
extern NCURSES_EXPORT(char *) tgetstr (const char *, char **);
|
| 847 |
+
extern NCURSES_EXPORT(char *) tgoto (const char *, int, int);
|
| 848 |
+
extern NCURSES_EXPORT(int) tgetent (char *, const char *);
|
| 849 |
+
extern NCURSES_EXPORT(int) tgetflag (const char *);
|
| 850 |
+
extern NCURSES_EXPORT(int) tgetnum (const char *);
|
| 851 |
+
extern NCURSES_EXPORT(int) tputs (const char *, int, int (*)(int));
|
| 852 |
+
#endif /* NCURSES_TERMCAP_H_incl */
|
| 853 |
+
|
| 854 |
+
/*
|
| 855 |
+
* Include curses.h before term.h to enable these extensions.
|
| 856 |
+
*/
|
| 857 |
+
#if defined(NCURSES_SP_FUNCS) && (NCURSES_SP_FUNCS != 0)
|
| 858 |
+
|
| 859 |
+
extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tigetstr) (SCREEN*, const char *);
|
| 860 |
+
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(putp) (SCREEN*, const char *);
|
| 861 |
+
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tigetflag) (SCREEN*, const char *);
|
| 862 |
+
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tigetnum) (SCREEN*, const char *);
|
| 863 |
+
|
| 864 |
+
#if 1 /* NCURSES_TPARM_VARARGS */
|
| 865 |
+
extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tparm) (SCREEN*, const char *, ...); /* special */
|
| 866 |
+
#else
|
| 867 |
+
extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tparm) (SCREEN*, const char *, long,long,long,long,long,long,long,long,long); /* special */
|
| 868 |
+
#endif
|
| 869 |
+
|
| 870 |
+
/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */
|
| 871 |
+
extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tgetstr) (SCREEN*, const char *, char **);
|
| 872 |
+
extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tgoto) (SCREEN*, const char *, int, int);
|
| 873 |
+
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tgetent) (SCREEN*, char *, const char *);
|
| 874 |
+
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tgetflag) (SCREEN*, const char *);
|
| 875 |
+
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tgetnum) (SCREEN*, const char *);
|
| 876 |
+
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tputs) (SCREEN*, const char *, int, NCURSES_SP_OUTC);
|
| 877 |
+
|
| 878 |
+
extern NCURSES_EXPORT(TERMINAL *) NCURSES_SP_NAME(set_curterm) (SCREEN*, TERMINAL *);
|
| 879 |
+
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(del_curterm) (SCREEN*, TERMINAL *);
|
| 880 |
+
|
| 881 |
+
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(restartterm) (SCREEN*, NCURSES_CONST char *, int, int *);
|
| 882 |
+
#endif /* NCURSES_SP_FUNCS */
|
| 883 |
+
|
| 884 |
+
/*
|
| 885 |
+
* Debugging features.
|
| 886 |
+
*/
|
| 887 |
+
extern GCC_NORETURN NCURSES_EXPORT(void) exit_terminfo(int);
|
| 888 |
+
|
| 889 |
+
#ifdef __cplusplus
|
| 890 |
+
}
|
| 891 |
+
#endif
|
| 892 |
+
|
| 893 |
+
#endif /* NCURSES_TERM_H_incl */
|
llava_next/include/ncurses/term_entry.h
ADDED
|
@@ -0,0 +1,239 @@
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/****************************************************************************
|
| 2 |
+
* Copyright 2018-2021,2022 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: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
|
| 32 |
+
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
|
| 33 |
+
* and: Thomas E. Dickey 1998-on *
|
| 34 |
+
****************************************************************************/
|
| 35 |
+
|
| 36 |
+
/* $Id: term_entry.h,v 1.63 2022/09/24 15:04:59 tom Exp $ */
|
| 37 |
+
|
| 38 |
+
/*
|
| 39 |
+
* term_entry.h -- interface to entry-manipulation code
|
| 40 |
+
*/
|
| 41 |
+
|
| 42 |
+
#ifndef NCURSES_TERM_ENTRY_H_incl
|
| 43 |
+
#define NCURSES_TERM_ENTRY_H_incl 1
|
| 44 |
+
/* *INDENT-OFF* */
|
| 45 |
+
|
| 46 |
+
#ifdef __cplusplus
|
| 47 |
+
extern "C" {
|
| 48 |
+
#endif
|
| 49 |
+
|
| 50 |
+
#include <ncursesw/curses.h>
|
| 51 |
+
#include <ncursesw/term.h>
|
| 52 |
+
|
| 53 |
+
/*
|
| 54 |
+
* These macros may be used by programs that know about TERMTYPE:
|
| 55 |
+
*/
|
| 56 |
+
#if NCURSES_XNAMES
|
| 57 |
+
#define NUM_BOOLEANS(tp) (tp)->num_Booleans
|
| 58 |
+
#define NUM_NUMBERS(tp) (tp)->num_Numbers
|
| 59 |
+
#define NUM_STRINGS(tp) (tp)->num_Strings
|
| 60 |
+
#define EXT_NAMES(tp,i,limit,index,table) (i >= limit) ? tp->ext_Names[index] : table[i]
|
| 61 |
+
#else
|
| 62 |
+
#define NUM_BOOLEANS(tp) BOOLCOUNT
|
| 63 |
+
#define NUM_NUMBERS(tp) NUMCOUNT
|
| 64 |
+
#define NUM_STRINGS(tp) STRCOUNT
|
| 65 |
+
#define EXT_NAMES(tp,i,limit,index,table) table[i]
|
| 66 |
+
#endif
|
| 67 |
+
|
| 68 |
+
#define NUM_EXT_NAMES(tp) (unsigned) ((tp)->ext_Booleans + (tp)->ext_Numbers + (tp)->ext_Strings)
|
| 69 |
+
|
| 70 |
+
#define for_each_boolean(n,tp) for(n = 0; n < NUM_BOOLEANS(tp); n++)
|
| 71 |
+
#define for_each_number(n,tp) for(n = 0; n < NUM_NUMBERS(tp); n++)
|
| 72 |
+
#define for_each_string(n,tp) for(n = 0; n < NUM_STRINGS(tp); n++)
|
| 73 |
+
|
| 74 |
+
#if NCURSES_XNAMES
|
| 75 |
+
#define for_each_ext_boolean(n,tp) for(n = BOOLCOUNT; (int) n < (int) NUM_BOOLEANS(tp); n++)
|
| 76 |
+
#define for_each_ext_number(n,tp) for(n = NUMCOUNT; (int) n < (int) NUM_NUMBERS(tp); n++)
|
| 77 |
+
#define for_each_ext_string(n,tp) for(n = STRCOUNT; (int) n < (int) NUM_STRINGS(tp); n++)
|
| 78 |
+
#endif
|
| 79 |
+
|
| 80 |
+
#define ExtBoolname(tp,i,names) EXT_NAMES(tp, i, BOOLCOUNT, (i - (tp->num_Booleans - tp->ext_Booleans)), names)
|
| 81 |
+
#define ExtNumname(tp,i,names) EXT_NAMES(tp, i, NUMCOUNT, (i - (tp->num_Numbers - tp->ext_Numbers)) + tp->ext_Booleans, names)
|
| 82 |
+
#define ExtStrname(tp,i,names) EXT_NAMES(tp, i, STRCOUNT, (i - (tp->num_Strings - tp->ext_Strings)) + (tp->ext_Numbers + tp->ext_Booleans), names)
|
| 83 |
+
|
| 84 |
+
/*
|
| 85 |
+
* The remaining type-definitions and macros are used only internally by the
|
| 86 |
+
* ncurses utilities.
|
| 87 |
+
*/
|
| 88 |
+
#ifdef NCURSES_INTERNALS
|
| 89 |
+
|
| 90 |
+
/*
|
| 91 |
+
* see db_iterator.c - this enumeration lists the places searched for a
|
| 92 |
+
* terminal description and defines the order in which they are searched.
|
| 93 |
+
*/
|
| 94 |
+
typedef enum {
|
| 95 |
+
dbdTIC = 0, /* special, used by tic when writing entry */
|
| 96 |
+
#if NCURSES_USE_DATABASE
|
| 97 |
+
dbdEnvOnce, /* the $TERMINFO environment variable */
|
| 98 |
+
dbdHome, /* $HOME/.terminfo */
|
| 99 |
+
dbdEnvList, /* the $TERMINFO_DIRS environment variable */
|
| 100 |
+
dbdCfgList, /* the compiled-in TERMINFO_DIRS value */
|
| 101 |
+
dbdCfgOnce, /* the compiled-in TERMINFO value */
|
| 102 |
+
#endif
|
| 103 |
+
#if NCURSES_USE_TERMCAP
|
| 104 |
+
dbdEnvOnce2, /* the $TERMCAP environment variable */
|
| 105 |
+
dbdEnvList2, /* the $TERMPATH environment variable */
|
| 106 |
+
dbdCfgList2, /* the compiled-in TERMPATH */
|
| 107 |
+
#endif
|
| 108 |
+
dbdLAST
|
| 109 |
+
} DBDIRS;
|
| 110 |
+
|
| 111 |
+
#define MAX_USES 32
|
| 112 |
+
#define MAX_CROSSLINKS 16
|
| 113 |
+
|
| 114 |
+
typedef struct entry ENTRY;
|
| 115 |
+
|
| 116 |
+
typedef struct {
|
| 117 |
+
char *name;
|
| 118 |
+
ENTRY *link;
|
| 119 |
+
long line;
|
| 120 |
+
} ENTRY_USES;
|
| 121 |
+
|
| 122 |
+
struct entry {
|
| 123 |
+
TERMTYPE2 tterm;
|
| 124 |
+
unsigned nuses;
|
| 125 |
+
ENTRY_USES uses[MAX_USES];
|
| 126 |
+
int ncrosslinks;
|
| 127 |
+
ENTRY *crosslinks[MAX_CROSSLINKS];
|
| 128 |
+
long cstart;
|
| 129 |
+
long cend;
|
| 130 |
+
long startline;
|
| 131 |
+
ENTRY *next;
|
| 132 |
+
ENTRY *last;
|
| 133 |
+
};
|
| 134 |
+
|
| 135 |
+
extern NCURSES_EXPORT_VAR(ENTRY *) _nc_head;
|
| 136 |
+
extern NCURSES_EXPORT_VAR(ENTRY *) _nc_tail;
|
| 137 |
+
#define for_entry_list(qp) for (qp = _nc_head; qp; qp = qp->next)
|
| 138 |
+
#define for_entry_list2(qp,q0) for (qp = q0; qp; qp = qp->next)
|
| 139 |
+
|
| 140 |
+
#define MAX_LINE 132
|
| 141 |
+
|
| 142 |
+
#define NULLHOOK (bool(*)(ENTRY *))0
|
| 143 |
+
|
| 144 |
+
/*
|
| 145 |
+
* Note that WANTED and PRESENT are not simple inverses! If a capability
|
| 146 |
+
* has been explicitly cancelled, it is not considered WANTED.
|
| 147 |
+
*/
|
| 148 |
+
#define WANTED(s) ((s) == ABSENT_STRING)
|
| 149 |
+
#define PRESENT(s) (((s) != ABSENT_STRING) && ((s) != CANCELLED_STRING))
|
| 150 |
+
|
| 151 |
+
#define ANDMISSING(p,q) \
|
| 152 |
+
{ \
|
| 153 |
+
if (PRESENT(p) && !PRESENT(q)) \
|
| 154 |
+
_nc_warning(#p " but no " #q); \
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
#define PAIRED(p,q) \
|
| 158 |
+
{ \
|
| 159 |
+
if (PRESENT(q) && !PRESENT(p)) \
|
| 160 |
+
_nc_warning(#q " but no " #p); \
|
| 161 |
+
if (PRESENT(p) && !PRESENT(q)) \
|
| 162 |
+
_nc_warning(#p " but no " #q); \
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
/*
|
| 166 |
+
* These entrypoints are used only by the ncurses utilities such as tic.
|
| 167 |
+
*/
|
| 168 |
+
|
| 169 |
+
/* alloc_entry.c: elementary allocation code */
|
| 170 |
+
extern NCURSES_EXPORT(ENTRY *) _nc_copy_entry (ENTRY *oldp);
|
| 171 |
+
extern NCURSES_EXPORT(char *) _nc_save_str (const char *const);
|
| 172 |
+
extern NCURSES_EXPORT(void) _nc_init_entry (ENTRY *const);
|
| 173 |
+
extern NCURSES_EXPORT(void) _nc_merge_entry (ENTRY *const, ENTRY *const);
|
| 174 |
+
extern NCURSES_EXPORT(void) _nc_wrap_entry (ENTRY *const, bool);
|
| 175 |
+
|
| 176 |
+
/* alloc_ttype.c: elementary allocation code */
|
| 177 |
+
extern NCURSES_EXPORT(void) _nc_align_termtype (TERMTYPE2 *, TERMTYPE2 *);
|
| 178 |
+
|
| 179 |
+
/* free_ttype.c: elementary allocation code */
|
| 180 |
+
extern NCURSES_EXPORT(void) _nc_free_termtype1 (TERMTYPE *);
|
| 181 |
+
extern NCURSES_EXPORT(void) _nc_free_termtype2 (TERMTYPE2 *);
|
| 182 |
+
|
| 183 |
+
/* lib_termcap.c: trim sgr0 string for termcap users */
|
| 184 |
+
extern NCURSES_EXPORT(char *) _nc_trim_sgr0 (TERMTYPE2 *);
|
| 185 |
+
|
| 186 |
+
/* parse_entry.c: entry-parsing code */
|
| 187 |
+
#if NCURSES_XNAMES
|
| 188 |
+
extern NCURSES_EXPORT_VAR(bool) _nc_user_definable;
|
| 189 |
+
extern NCURSES_EXPORT_VAR(bool) _nc_disable_period;
|
| 190 |
+
#endif
|
| 191 |
+
extern NCURSES_EXPORT(int) _nc_parse_entry (ENTRY *, int, bool);
|
| 192 |
+
extern NCURSES_EXPORT(int) _nc_capcmp (const char *, const char *);
|
| 193 |
+
|
| 194 |
+
/* write_entry.c: writing an entry to the file system */
|
| 195 |
+
extern NCURSES_EXPORT(void) _nc_set_writedir (const char *);
|
| 196 |
+
extern NCURSES_EXPORT(void) _nc_write_entry (TERMTYPE2 *const);
|
| 197 |
+
extern NCURSES_EXPORT(int) _nc_write_object (TERMTYPE2 *, char *, unsigned *, unsigned);
|
| 198 |
+
|
| 199 |
+
/* comp_parse.c: entry list handling */
|
| 200 |
+
extern NCURSES_EXPORT(void) _nc_read_entry_source (FILE*, char*, int, bool, bool (*)(ENTRY*));
|
| 201 |
+
extern NCURSES_EXPORT(bool) _nc_entry_match (char *, char *);
|
| 202 |
+
extern NCURSES_EXPORT(int) _nc_resolve_uses (bool); /* obs 20040705 */
|
| 203 |
+
extern NCURSES_EXPORT(int) _nc_resolve_uses2 (bool, bool);
|
| 204 |
+
extern NCURSES_EXPORT(void) _nc_free_entries (ENTRY *);
|
| 205 |
+
extern NCURSES_IMPEXP void (NCURSES_API *_nc_check_termtype)(TERMTYPE *); /* obs 20040705 */
|
| 206 |
+
extern NCURSES_IMPEXP void (NCURSES_API *_nc_check_termtype2)(TERMTYPE2 *, bool);
|
| 207 |
+
|
| 208 |
+
/* trace_xnames.c */
|
| 209 |
+
extern NCURSES_EXPORT(void) _nc_trace_xnames (TERMTYPE *);
|
| 210 |
+
|
| 211 |
+
#endif /* NCURSES_INTERNALS */
|
| 212 |
+
|
| 213 |
+
/*
|
| 214 |
+
* These entrypoints were used by tack before 1.08.
|
| 215 |
+
*/
|
| 216 |
+
|
| 217 |
+
#undef NCURSES_TACK_1_08
|
| 218 |
+
#ifdef NCURSES_INTERNALS
|
| 219 |
+
#define NCURSES_TACK_1_08 /* nothing */
|
| 220 |
+
#else
|
| 221 |
+
#define NCURSES_TACK_1_08 GCC_DEPRECATED("upgrade to tack 1.08")
|
| 222 |
+
#endif
|
| 223 |
+
|
| 224 |
+
/* alloc_ttype.c: elementary allocation code */
|
| 225 |
+
extern NCURSES_EXPORT(void) _nc_copy_termtype (TERMTYPE *, const TERMTYPE *) NCURSES_TACK_1_08;
|
| 226 |
+
|
| 227 |
+
/* lib_acs.c */
|
| 228 |
+
extern NCURSES_EXPORT(void) _nc_init_acs (void) NCURSES_TACK_1_08; /* corresponds to traditional 'init_acs()' */
|
| 229 |
+
|
| 230 |
+
/* free_ttype.c: elementary allocation code */
|
| 231 |
+
extern NCURSES_EXPORT(void) _nc_free_termtype (TERMTYPE *) NCURSES_TACK_1_08;
|
| 232 |
+
|
| 233 |
+
#ifdef __cplusplus
|
| 234 |
+
}
|
| 235 |
+
#endif
|
| 236 |
+
|
| 237 |
+
/* *INDENT-ON* */
|
| 238 |
+
|
| 239 |
+
#endif /* NCURSES_TERM_ENTRY_H_incl */
|
llava_next/include/ncurses/termcap.h
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/****************************************************************************
|
| 2 |
+
* Copyright 2018-2020,2021 Thomas E. Dickey *
|
| 3 |
+
* Copyright 1998-2000,2001 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: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
|
| 32 |
+
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
|
| 33 |
+
****************************************************************************/
|
| 34 |
+
|
| 35 |
+
/* $Id: termcap.h.in,v 1.20 2021/06/17 21:26:02 tom Exp $ */
|
| 36 |
+
|
| 37 |
+
#ifndef NCURSES_TERMCAP_H_incl
|
| 38 |
+
#define NCURSES_TERMCAP_H_incl 1
|
| 39 |
+
|
| 40 |
+
#undef NCURSES_VERSION
|
| 41 |
+
#define NCURSES_VERSION "6.4"
|
| 42 |
+
|
| 43 |
+
#include <ncursesw/ncurses_dll.h>
|
| 44 |
+
|
| 45 |
+
#ifdef __cplusplus
|
| 46 |
+
extern "C"
|
| 47 |
+
{
|
| 48 |
+
#endif /* __cplusplus */
|
| 49 |
+
|
| 50 |
+
#include <sys/types.h>
|
| 51 |
+
|
| 52 |
+
#undef NCURSES_OSPEED
|
| 53 |
+
#define NCURSES_OSPEED short
|
| 54 |
+
|
| 55 |
+
extern NCURSES_EXPORT_VAR(char) PC;
|
| 56 |
+
extern NCURSES_EXPORT_VAR(char *) UP;
|
| 57 |
+
extern NCURSES_EXPORT_VAR(char *) BC;
|
| 58 |
+
extern NCURSES_EXPORT_VAR(NCURSES_OSPEED) ospeed;
|
| 59 |
+
|
| 60 |
+
#if !defined(NCURSES_TERM_H_incl)
|
| 61 |
+
extern NCURSES_EXPORT(char *) tgetstr (const char *, char **);
|
| 62 |
+
extern NCURSES_EXPORT(char *) tgoto (const char *, int, int);
|
| 63 |
+
extern NCURSES_EXPORT(int) tgetent (char *, const char *);
|
| 64 |
+
extern NCURSES_EXPORT(int) tgetflag (const char *);
|
| 65 |
+
extern NCURSES_EXPORT(int) tgetnum (const char *);
|
| 66 |
+
extern NCURSES_EXPORT(int) tputs (const char *, int, int (*)(int));
|
| 67 |
+
#endif
|
| 68 |
+
|
| 69 |
+
#ifdef __cplusplus
|
| 70 |
+
}
|
| 71 |
+
#endif
|
| 72 |
+
|
| 73 |
+
#endif /* NCURSES_TERMCAP_H_incl */
|
llava_next/include/ncurses/tic.h
ADDED
|
@@ -0,0 +1,396 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
| 1 |
+
/****************************************************************************
|
| 2 |
+
* Copyright 2018-2021,2022 Thomas E. Dickey *
|
| 3 |
+
* Copyright 1998-2012,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: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
|
| 32 |
+
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
|
| 33 |
+
* and: Thomas E. Dickey 1996 on *
|
| 34 |
+
****************************************************************************/
|
| 35 |
+
|
| 36 |
+
/*
|
| 37 |
+
* $Id: tic.h,v 1.86 2022/09/17 16:01:45 tom Exp $
|
| 38 |
+
* tic.h - Global variables and structures for the terminfo compiler.
|
| 39 |
+
*/
|
| 40 |
+
|
| 41 |
+
#ifndef __TIC_H
|
| 42 |
+
#define __TIC_H
|
| 43 |
+
/* *INDENT-OFF* */
|
| 44 |
+
#ifdef __cplusplus
|
| 45 |
+
extern "C" {
|
| 46 |
+
#endif
|
| 47 |
+
|
| 48 |
+
#include <ncurses_cfg.h>
|
| 49 |
+
|
| 50 |
+
#include <ncursesw/curses.h> /* for the _tracef() prototype, ERR/OK, bool defs */
|
| 51 |
+
|
| 52 |
+
/*
|
| 53 |
+
** The format of SVr2 compiled terminfo files is as follows:
|
| 54 |
+
**
|
| 55 |
+
** Header (12 bytes), containing information given below
|
| 56 |
+
** Names Section, containing the names of the terminal
|
| 57 |
+
** Boolean Section, containing the values of all of the
|
| 58 |
+
** boolean capabilities
|
| 59 |
+
** A null byte may be inserted here to make
|
| 60 |
+
** sure that the Number Section begins on an
|
| 61 |
+
** even word boundary.
|
| 62 |
+
** Number Section, containing the values of all of the numeric
|
| 63 |
+
** capabilities, each as a short integer
|
| 64 |
+
** String Section, containing short integer offsets into the
|
| 65 |
+
** String Table, one per string capability
|
| 66 |
+
** String Table, containing the actual characters of the string
|
| 67 |
+
** capabilities.
|
| 68 |
+
**
|
| 69 |
+
** In the SVr2 format, "short" means signed 16-bit numbers, which is sometimes
|
| 70 |
+
** inconvenient. The numbers are signed, to provide for absent and canceled
|
| 71 |
+
** values. ncurses6.1 introduced an extension to this compiled format, by
|
| 72 |
+
** making the Number Section a list of signed 32-bit integers.
|
| 73 |
+
**
|
| 74 |
+
** NOTE that all short integers in the file are stored using VAX/PDP-style
|
| 75 |
+
** byte-order, i.e., least-significant byte first.
|
| 76 |
+
**
|
| 77 |
+
** There is no structure definition here because it would only confuse
|
| 78 |
+
** matters. Terminfo format is a raw byte layout, not a structure
|
| 79 |
+
** dump. If you happen to be on a little-endian machine with 16-bit
|
| 80 |
+
** shorts that requires no padding between short members in a struct,
|
| 81 |
+
** then there is a natural C structure that captures the header, but
|
| 82 |
+
** not very helpfully.
|
| 83 |
+
*/
|
| 84 |
+
|
| 85 |
+
#define MAGIC 0432 /* first two bytes of a compiled entry */
|
| 86 |
+
#define MAGIC2 01036 /* first two bytes of a compiled 32-bit entry */
|
| 87 |
+
|
| 88 |
+
#undef BYTE
|
| 89 |
+
#define BYTE(p,n) (unsigned char)((p)[n])
|
| 90 |
+
|
| 91 |
+
#define IS_NEG1(p) ((BYTE(p,0) == 0377) && (BYTE(p,1) == 0377))
|
| 92 |
+
#define IS_NEG2(p) ((BYTE(p,0) == 0376) && (BYTE(p,1) == 0377))
|
| 93 |
+
#define LOW_MSB(p) (BYTE(p,0) + 256*BYTE(p,1))
|
| 94 |
+
|
| 95 |
+
#define IS_TIC_MAGIC(p) (LOW_MSB(p) == MAGIC || LOW_MSB(p) == MAGIC2)
|
| 96 |
+
|
| 97 |
+
#define quick_prefix(s) (!strncmp((s), "b64:", (size_t)4) || !strncmp((s), "hex:", (size_t)4))
|
| 98 |
+
|
| 99 |
+
/*
|
| 100 |
+
* The "maximum" here is misleading; XSI guarantees minimum values, which a
|
| 101 |
+
* given implementation may exceed.
|
| 102 |
+
*/
|
| 103 |
+
#define MAX_NAME_SIZE 512 /* maximum legal name field size (XSI:127) */
|
| 104 |
+
#define MAX_ENTRY_SIZE1 4096 /* maximum legal entry size (SVr2) */
|
| 105 |
+
#define MAX_ENTRY_SIZE2 32768 /* maximum legal entry size (ncurses6.1) */
|
| 106 |
+
|
| 107 |
+
#if NCURSES_EXT_COLORS && HAVE_INIT_EXTENDED_COLOR
|
| 108 |
+
#define MAX_ENTRY_SIZE MAX_ENTRY_SIZE2
|
| 109 |
+
#else
|
| 110 |
+
#define MAX_ENTRY_SIZE MAX_ENTRY_SIZE1
|
| 111 |
+
#endif
|
| 112 |
+
|
| 113 |
+
/*
|
| 114 |
+
* The maximum size of individual name or alias is guaranteed in XSI to be at
|
| 115 |
+
* least 14, since that corresponds to the older filename lengths. Newer
|
| 116 |
+
* systems allow longer aliases, though not many terminal descriptions are
|
| 117 |
+
* written to use them. The MAX_ALIAS symbol is used for warnings.
|
| 118 |
+
*/
|
| 119 |
+
#if HAVE_LONG_FILE_NAMES
|
| 120 |
+
#define MAX_ALIAS 32 /* smaller than POSIX minimum for PATH_MAX */
|
| 121 |
+
#else
|
| 122 |
+
#define MAX_ALIAS 14 /* SVr3 filename length */
|
| 123 |
+
#endif
|
| 124 |
+
|
| 125 |
+
/* location of user's personal info directory */
|
| 126 |
+
#define PRIVATE_INFO "%s/.terminfo" /* plug getenv("HOME") into %s */
|
| 127 |
+
|
| 128 |
+
/*
|
| 129 |
+
* Some traces are designed to be used via tic's verbose option (and similar in
|
| 130 |
+
* infocmp and toe) rather than the 'trace()' function. So we use the bits
|
| 131 |
+
* above the normal trace() parameter as a debug-level.
|
| 132 |
+
*/
|
| 133 |
+
|
| 134 |
+
#define MAX_DEBUG_LEVEL 15
|
| 135 |
+
#define DEBUG_LEVEL(n) ((n) << TRACE_SHIFT)
|
| 136 |
+
|
| 137 |
+
#define set_trace_level(n) \
|
| 138 |
+
_nc_tracing &= TRACE_MAXIMUM, \
|
| 139 |
+
_nc_tracing |= DEBUG_LEVEL(n)
|
| 140 |
+
|
| 141 |
+
#ifdef TRACE
|
| 142 |
+
#define DEBUG(n, a) if (_nc_tracing >= DEBUG_LEVEL(n)) _tracef a
|
| 143 |
+
#else
|
| 144 |
+
#define DEBUG(n, a) /*nothing*/
|
| 145 |
+
#endif
|
| 146 |
+
|
| 147 |
+
/*
|
| 148 |
+
* These are the types of tokens returned by the scanner. The first
|
| 149 |
+
* three are also used in the hash table of capability names. The scanner
|
| 150 |
+
* returns one of these values after loading the specifics into the global
|
| 151 |
+
* structure curr_token.
|
| 152 |
+
*/
|
| 153 |
+
|
| 154 |
+
#define BOOLEAN 0 /* Boolean capability */
|
| 155 |
+
#define NUMBER 1 /* Numeric capability */
|
| 156 |
+
#define STRING 2 /* String-valued capability */
|
| 157 |
+
#define CANCEL 3 /* Capability to be cancelled in following tc's */
|
| 158 |
+
#define NAMES 4 /* The names for a terminal type */
|
| 159 |
+
#define UNDEF 5 /* Undefined */
|
| 160 |
+
|
| 161 |
+
#define NO_PUSHBACK -1 /* used in pushtype to indicate no pushback */
|
| 162 |
+
|
| 163 |
+
/*
|
| 164 |
+
* The global structure in which the specific parts of a
|
| 165 |
+
* scanned token are returned.
|
| 166 |
+
*/
|
| 167 |
+
|
| 168 |
+
struct token
|
| 169 |
+
{
|
| 170 |
+
char *tk_name; /* name of capability */
|
| 171 |
+
int tk_valnumber; /* value of capability (if a number) */
|
| 172 |
+
char *tk_valstring; /* value of capability (if a string) */
|
| 173 |
+
};
|
| 174 |
+
|
| 175 |
+
/*
|
| 176 |
+
* Offsets to string capabilities, with the corresponding functionkey codes.
|
| 177 |
+
*/
|
| 178 |
+
struct tinfo_fkeys {
|
| 179 |
+
unsigned offset;
|
| 180 |
+
chtype code;
|
| 181 |
+
};
|
| 182 |
+
|
| 183 |
+
typedef short HashValue;
|
| 184 |
+
|
| 185 |
+
/*
|
| 186 |
+
* The file comp_captab.c contains an array of these structures, one per
|
| 187 |
+
* possible capability. These are indexed by a hash table array of pointers to
|
| 188 |
+
* the same structures for use by the parser.
|
| 189 |
+
*/
|
| 190 |
+
struct name_table_entry
|
| 191 |
+
{
|
| 192 |
+
const char *nte_name; /* name to hash on */
|
| 193 |
+
int nte_type; /* BOOLEAN, NUMBER or STRING */
|
| 194 |
+
HashValue nte_index; /* index of associated variable in its array */
|
| 195 |
+
HashValue nte_link; /* index in table of next hash, or -1 */
|
| 196 |
+
};
|
| 197 |
+
|
| 198 |
+
/*
|
| 199 |
+
* Use this structure to hide differences between terminfo and termcap tables.
|
| 200 |
+
*/
|
| 201 |
+
typedef struct {
|
| 202 |
+
unsigned table_size;
|
| 203 |
+
const HashValue *table_data;
|
| 204 |
+
HashValue (*hash_of)(const char *);
|
| 205 |
+
int (*compare_names)(const char *, const char *);
|
| 206 |
+
} HashData;
|
| 207 |
+
|
| 208 |
+
struct alias
|
| 209 |
+
{
|
| 210 |
+
const char *from;
|
| 211 |
+
const char *to;
|
| 212 |
+
const char *source;
|
| 213 |
+
};
|
| 214 |
+
|
| 215 |
+
#define NOTFOUND ((struct name_table_entry *) 0)
|
| 216 |
+
|
| 217 |
+
/*
|
| 218 |
+
* The file comp_userdefs.c contains an array of these structures, one per
|
| 219 |
+
* possible capability. These are indexed by a hash table array of pointers to
|
| 220 |
+
* the same structures for use by the parser.
|
| 221 |
+
*/
|
| 222 |
+
struct user_table_entry
|
| 223 |
+
{
|
| 224 |
+
const char *ute_name; /* name to hash on */
|
| 225 |
+
int ute_type; /* mask (BOOLEAN, NUMBER, STRING) */
|
| 226 |
+
unsigned ute_argc; /* number of parameters */
|
| 227 |
+
unsigned ute_args; /* bit-mask for string parameters */
|
| 228 |
+
HashValue ute_index; /* index of associated variable in its array */
|
| 229 |
+
HashValue ute_link; /* index in table of next hash, or -1 */
|
| 230 |
+
};
|
| 231 |
+
|
| 232 |
+
/*
|
| 233 |
+
* The casts are required for correct sign-propagation with systems such as
|
| 234 |
+
* AIX, IRIX64, Solaris which default to unsigned characters. The C standard
|
| 235 |
+
* leaves this detail unspecified.
|
| 236 |
+
*/
|
| 237 |
+
|
| 238 |
+
/* out-of-band values for representing absent capabilities */
|
| 239 |
+
#define ABSENT_BOOLEAN ((signed char)-1) /* 255 */
|
| 240 |
+
#define ABSENT_NUMERIC (-1)
|
| 241 |
+
#define ABSENT_STRING (char *)0
|
| 242 |
+
|
| 243 |
+
/* out-of-band values for representing cancels */
|
| 244 |
+
#define CANCELLED_BOOLEAN ((signed char)-2) /* 254 */
|
| 245 |
+
#define CANCELLED_NUMERIC (-2)
|
| 246 |
+
#define CANCELLED_STRING (char *)(-1)
|
| 247 |
+
|
| 248 |
+
#define VALID_BOOLEAN(s) ((unsigned char)(s) <= 1) /* reject "-1" */
|
| 249 |
+
#define VALID_NUMERIC(s) ((s) >= 0)
|
| 250 |
+
#define VALID_STRING(s) ((s) != CANCELLED_STRING && (s) != ABSENT_STRING)
|
| 251 |
+
|
| 252 |
+
/* termcap entries longer than this may break old binaries */
|
| 253 |
+
#define MAX_TERMCAP_LENGTH 1023
|
| 254 |
+
|
| 255 |
+
/* this is a documented limitation of terminfo */
|
| 256 |
+
#define MAX_TERMINFO_LENGTH 4096
|
| 257 |
+
|
| 258 |
+
#ifndef TERMINFO
|
| 259 |
+
#define TERMINFO "/usr/share/terminfo"
|
| 260 |
+
#endif
|
| 261 |
+
|
| 262 |
+
#ifdef NCURSES_TERM_ENTRY_H_incl
|
| 263 |
+
|
| 264 |
+
/*
|
| 265 |
+
* These entrypoints are used only by the ncurses utilities such as tic.
|
| 266 |
+
*/
|
| 267 |
+
#ifdef NCURSES_INTERNALS
|
| 268 |
+
/* access.c */
|
| 269 |
+
extern NCURSES_EXPORT(unsigned) _nc_pathlast (const char *);
|
| 270 |
+
extern NCURSES_EXPORT(bool) _nc_is_abs_path (const char *);
|
| 271 |
+
extern NCURSES_EXPORT(bool) _nc_is_dir_path (const char *);
|
| 272 |
+
extern NCURSES_EXPORT(bool) _nc_is_file_path (const char *);
|
| 273 |
+
extern NCURSES_EXPORT(char *) _nc_basename (char *);
|
| 274 |
+
extern NCURSES_EXPORT(char *) _nc_rootname (char *);
|
| 275 |
+
|
| 276 |
+
/* comp_captab.c */
|
| 277 |
+
extern NCURSES_EXPORT(const struct name_table_entry *) _nc_get_table (bool);
|
| 278 |
+
extern NCURSES_EXPORT(const HashData *) _nc_get_hash_info (bool);
|
| 279 |
+
extern NCURSES_EXPORT(const struct alias *) _nc_get_alias_table (bool);
|
| 280 |
+
|
| 281 |
+
/* comp_hash.c: name lookup */
|
| 282 |
+
extern NCURSES_EXPORT(struct name_table_entry const *) _nc_find_type_entry
|
| 283 |
+
(const char *, int, bool);
|
| 284 |
+
extern NCURSES_EXPORT(struct user_table_entry const *) _nc_find_user_entry
|
| 285 |
+
(const char *);
|
| 286 |
+
|
| 287 |
+
/* comp_scan.c: lexical analysis */
|
| 288 |
+
extern NCURSES_EXPORT(int) _nc_get_token (bool);
|
| 289 |
+
extern NCURSES_EXPORT(void) _nc_panic_mode (char);
|
| 290 |
+
extern NCURSES_EXPORT(void) _nc_push_token (int);
|
| 291 |
+
extern NCURSES_EXPORT_VAR(int) _nc_curr_col;
|
| 292 |
+
extern NCURSES_EXPORT_VAR(int) _nc_curr_line;
|
| 293 |
+
extern NCURSES_EXPORT_VAR(int) _nc_syntax;
|
| 294 |
+
extern NCURSES_EXPORT_VAR(int) _nc_strict_bsd;
|
| 295 |
+
extern NCURSES_EXPORT_VAR(long) _nc_comment_end;
|
| 296 |
+
extern NCURSES_EXPORT_VAR(long) _nc_comment_start;
|
| 297 |
+
extern NCURSES_EXPORT_VAR(long) _nc_curr_file_pos;
|
| 298 |
+
extern NCURSES_EXPORT_VAR(long) _nc_start_line;
|
| 299 |
+
#define SYN_TERMINFO 0
|
| 300 |
+
#define SYN_TERMCAP 1
|
| 301 |
+
|
| 302 |
+
/* comp_error.c: warning & abort messages */
|
| 303 |
+
extern NCURSES_EXPORT(const char *) _nc_get_source (void);
|
| 304 |
+
extern GCC_NORETURN NCURSES_EXPORT(void) _nc_err_abort (const char *const,...) GCC_PRINTFLIKE(1,2);
|
| 305 |
+
extern NCURSES_EXPORT(void) _nc_get_type (char *name);
|
| 306 |
+
extern NCURSES_EXPORT(void) _nc_set_source (const char *const);
|
| 307 |
+
extern NCURSES_EXPORT(void) _nc_set_type (const char *const);
|
| 308 |
+
extern GCC_NORETURN NCURSES_EXPORT(void) _nc_syserr_abort (const char *const,...) GCC_PRINTFLIKE(1,2);
|
| 309 |
+
extern NCURSES_EXPORT(void) _nc_warning (const char *const,...) GCC_PRINTFLIKE(1,2);
|
| 310 |
+
extern NCURSES_EXPORT_VAR(bool) _nc_suppress_warnings;
|
| 311 |
+
|
| 312 |
+
/* comp_scan.c */
|
| 313 |
+
extern NCURSES_EXPORT_VAR(struct token) _nc_curr_token;
|
| 314 |
+
|
| 315 |
+
/* comp_userdefs.c */
|
| 316 |
+
NCURSES_EXPORT(const struct user_table_entry *) _nc_get_userdefs_table (void);
|
| 317 |
+
NCURSES_EXPORT(const HashData *) _nc_get_hash_user (void);
|
| 318 |
+
|
| 319 |
+
/* captoinfo.c: capability conversion */
|
| 320 |
+
extern NCURSES_EXPORT(char *) _nc_captoinfo (const char *, const char *, int const);
|
| 321 |
+
extern NCURSES_EXPORT(char *) _nc_infotocap (const char *, const char *, int const);
|
| 322 |
+
|
| 323 |
+
/* home_terminfo.c */
|
| 324 |
+
extern NCURSES_EXPORT(char *) _nc_home_terminfo (void);
|
| 325 |
+
|
| 326 |
+
/* init_keytry.c */
|
| 327 |
+
#if BROKEN_LINKER
|
| 328 |
+
#define _nc_tinfo_fkeys _nc_tinfo_fkeysf()
|
| 329 |
+
extern NCURSES_EXPORT(const struct tinfo_fkeys *) _nc_tinfo_fkeysf (void);
|
| 330 |
+
#else
|
| 331 |
+
extern NCURSES_EXPORT_VAR(const struct tinfo_fkeys) _nc_tinfo_fkeys[];
|
| 332 |
+
#endif
|
| 333 |
+
|
| 334 |
+
/* lib_tparm.c */
|
| 335 |
+
#define NUM_PARM 9
|
| 336 |
+
|
| 337 |
+
extern NCURSES_EXPORT_VAR(int) _nc_tparm_err;
|
| 338 |
+
|
| 339 |
+
extern NCURSES_EXPORT(int) _nc_tparm_analyze(TERMINAL *, const char *, char **, int *);
|
| 340 |
+
extern NCURSES_EXPORT(void) _nc_reset_tparm(TERMINAL *);
|
| 341 |
+
|
| 342 |
+
/* lib_trace.c */
|
| 343 |
+
extern NCURSES_EXPORT_VAR(unsigned) _nc_tracing;
|
| 344 |
+
extern NCURSES_EXPORT(const char *) _nc_visbuf (const char *);
|
| 345 |
+
extern NCURSES_EXPORT(const char *) _nc_visbuf2 (int, const char *);
|
| 346 |
+
|
| 347 |
+
/* lib_tputs.c */
|
| 348 |
+
extern NCURSES_EXPORT_VAR(int) _nc_nulls_sent; /* Add one for every null sent */
|
| 349 |
+
|
| 350 |
+
/* comp_main.c: compiler main */
|
| 351 |
+
extern const char * _nc_progname;
|
| 352 |
+
|
| 353 |
+
/* db_iterator.c */
|
| 354 |
+
extern NCURSES_EXPORT(const char *) _nc_next_db(DBDIRS *, int *);
|
| 355 |
+
extern NCURSES_EXPORT(const char *) _nc_tic_dir (const char *);
|
| 356 |
+
extern NCURSES_EXPORT(void) _nc_first_db(DBDIRS *, int *);
|
| 357 |
+
extern NCURSES_EXPORT(void) _nc_last_db(void);
|
| 358 |
+
|
| 359 |
+
/* write_entry.c */
|
| 360 |
+
extern NCURSES_EXPORT(int) _nc_tic_written (void);
|
| 361 |
+
|
| 362 |
+
#endif /* NCURSES_INTERNALS */
|
| 363 |
+
|
| 364 |
+
/*
|
| 365 |
+
* These entrypoints were used by tack before 1.08.
|
| 366 |
+
*/
|
| 367 |
+
|
| 368 |
+
#undef NCURSES_TACK_1_08
|
| 369 |
+
#ifdef NCURSES_INTERNALS
|
| 370 |
+
#define NCURSES_TACK_1_08 /* nothing */
|
| 371 |
+
#else
|
| 372 |
+
#define NCURSES_TACK_1_08 GCC_DEPRECATED("upgrade to tack 1.08")
|
| 373 |
+
#endif
|
| 374 |
+
|
| 375 |
+
/* comp_hash.c: name lookup */
|
| 376 |
+
extern NCURSES_EXPORT(struct name_table_entry const *) _nc_find_entry
|
| 377 |
+
(const char *, const HashValue *) NCURSES_TACK_1_08;
|
| 378 |
+
extern NCURSES_EXPORT(const HashValue *) _nc_get_hash_table (bool) NCURSES_TACK_1_08;
|
| 379 |
+
|
| 380 |
+
/* comp_scan.c: lexical analysis */
|
| 381 |
+
extern NCURSES_EXPORT(void) _nc_reset_input (FILE *, char *) NCURSES_TACK_1_08;
|
| 382 |
+
|
| 383 |
+
/* comp_expand.c: expand string into readable form */
|
| 384 |
+
extern NCURSES_EXPORT(char *) _nc_tic_expand (const char *, bool, int) NCURSES_TACK_1_08;
|
| 385 |
+
|
| 386 |
+
/* comp_scan.c: decode string from readable form */
|
| 387 |
+
extern NCURSES_EXPORT(int) _nc_trans_string (char *, char *) NCURSES_TACK_1_08;
|
| 388 |
+
|
| 389 |
+
#endif /* NCURSES_TERM_ENTRY_H_incl */
|
| 390 |
+
|
| 391 |
+
#ifdef __cplusplus
|
| 392 |
+
}
|
| 393 |
+
#endif
|
| 394 |
+
|
| 395 |
+
/* *INDENT-ON* */
|
| 396 |
+
#endif /* __TIC_H */
|
llava_next/include/ncurses/unctrl.h
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/****************************************************************************
|
| 2 |
+
* Copyright 2020 Thomas E. Dickey *
|
| 3 |
+
* Copyright 1998-2001,2009 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: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
|
| 32 |
+
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
|
| 33 |
+
****************************************************************************/
|
| 34 |
+
|
| 35 |
+
/*
|
| 36 |
+
* unctrl.h
|
| 37 |
+
*
|
| 38 |
+
* Display a printable version of a control character.
|
| 39 |
+
* Control characters are displayed in caret notation (^x), DELETE is displayed
|
| 40 |
+
* as ^?. Printable characters are displayed as is.
|
| 41 |
+
*/
|
| 42 |
+
|
| 43 |
+
/* $Id: unctrl.h.in,v 1.12 2020/02/02 23:34:34 tom Exp $ */
|
| 44 |
+
|
| 45 |
+
#ifndef NCURSES_UNCTRL_H_incl
|
| 46 |
+
#define NCURSES_UNCTRL_H_incl 1
|
| 47 |
+
|
| 48 |
+
#undef NCURSES_VERSION
|
| 49 |
+
#define NCURSES_VERSION "6.4"
|
| 50 |
+
|
| 51 |
+
#ifdef __cplusplus
|
| 52 |
+
extern "C" {
|
| 53 |
+
#endif
|
| 54 |
+
|
| 55 |
+
#include <ncursesw/curses.h>
|
| 56 |
+
|
| 57 |
+
#undef unctrl
|
| 58 |
+
NCURSES_EXPORT(NCURSES_CONST char *) unctrl (chtype);
|
| 59 |
+
|
| 60 |
+
#if 1
|
| 61 |
+
NCURSES_EXPORT(NCURSES_CONST char *) NCURSES_SP_NAME(unctrl) (SCREEN*, chtype);
|
| 62 |
+
#endif
|
| 63 |
+
|
| 64 |
+
#ifdef __cplusplus
|
| 65 |
+
}
|
| 66 |
+
#endif
|
| 67 |
+
|
| 68 |
+
#endif /* NCURSES_UNCTRL_H_incl */
|
llava_next/include/ncursesw/curses.h
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
llava_next/include/ncursesw/cursesf.h
ADDED
|
@@ -0,0 +1,968 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// * This makes emacs happy -*-Mode: C++;-*-
|
| 2 |
+
// vile:cppmode
|
| 3 |
+
/****************************************************************************
|
| 4 |
+
* Copyright 2019-2021,2022 Thomas E. Dickey *
|
| 5 |
+
* Copyright 1998-2012,2014 Free Software Foundation, Inc. *
|
| 6 |
+
* *
|
| 7 |
+
* Permission is hereby granted, free of charge, to any person obtaining a *
|
| 8 |
+
* copy of this software and associated documentation files (the *
|
| 9 |
+
* "Software"), to deal in the Software without restriction, including *
|
| 10 |
+
* without limitation the rights to use, copy, modify, merge, publish, *
|
| 11 |
+
* distribute, distribute with modifications, sublicense, and/or sell *
|
| 12 |
+
* copies of the Software, and to permit persons to whom the Software is *
|
| 13 |
+
* furnished to do so, subject to the following conditions: *
|
| 14 |
+
* *
|
| 15 |
+
* The above copyright notice and this permission notice shall be included *
|
| 16 |
+
* in all copies or substantial portions of the Software. *
|
| 17 |
+
* *
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
|
| 19 |
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
|
| 20 |
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
|
| 21 |
+
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
|
| 22 |
+
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
|
| 23 |
+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
|
| 24 |
+
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
| 25 |
+
* *
|
| 26 |
+
* Except as contained in this notice, the name(s) of the above copyright *
|
| 27 |
+
* holders shall not be used in advertising or otherwise to promote the *
|
| 28 |
+
* sale, use or other dealings in this Software without prior written *
|
| 29 |
+
* authorization. *
|
| 30 |
+
****************************************************************************/
|
| 31 |
+
|
| 32 |
+
/****************************************************************************
|
| 33 |
+
* Author: Juergen Pfeifer, 1997 *
|
| 34 |
+
****************************************************************************/
|
| 35 |
+
|
| 36 |
+
// $Id: cursesf.h,v 1.39 2022/08/20 20:52:15 tom Exp $
|
| 37 |
+
|
| 38 |
+
#ifndef NCURSES_CURSESF_H_incl
|
| 39 |
+
#define NCURSES_CURSESF_H_incl 1
|
| 40 |
+
|
| 41 |
+
#include <ncursesw/cursesp.h>
|
| 42 |
+
|
| 43 |
+
#ifndef __EXT_QNX
|
| 44 |
+
#include <string.h>
|
| 45 |
+
#endif
|
| 46 |
+
|
| 47 |
+
extern "C" {
|
| 48 |
+
# include <ncursesw/form.h>
|
| 49 |
+
}
|
| 50 |
+
//
|
| 51 |
+
// -------------------------------------------------------------------------
|
| 52 |
+
// The abstract base class for builtin and user defined Fieldtypes.
|
| 53 |
+
// -------------------------------------------------------------------------
|
| 54 |
+
//
|
| 55 |
+
class NCURSES_CXX_IMPEXP NCursesFormField; // forward declaration
|
| 56 |
+
|
| 57 |
+
// Class to represent builtin field types as well as C++ written new
|
| 58 |
+
// fieldtypes (see classes UserDefineFieldType...
|
| 59 |
+
class NCURSES_CXX_IMPEXP NCursesFieldType
|
| 60 |
+
{
|
| 61 |
+
friend class NCursesFormField;
|
| 62 |
+
|
| 63 |
+
protected:
|
| 64 |
+
FIELDTYPE* fieldtype;
|
| 65 |
+
|
| 66 |
+
inline void OnError(int err) const THROW2(NCursesException const, NCursesFormException) {
|
| 67 |
+
if (err!=E_OK)
|
| 68 |
+
THROW(new NCursesFormException (err));
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
NCursesFieldType(FIELDTYPE *f) : fieldtype(f) {
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
virtual ~NCursesFieldType() {}
|
| 75 |
+
|
| 76 |
+
// Set the fields f fieldtype to this one.
|
| 77 |
+
virtual void set(NCursesFormField& f) = 0;
|
| 78 |
+
|
| 79 |
+
public:
|
| 80 |
+
NCursesFieldType()
|
| 81 |
+
: fieldtype(STATIC_CAST(FIELDTYPE*)(0))
|
| 82 |
+
{
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
NCursesFieldType& operator=(const NCursesFieldType& rhs)
|
| 86 |
+
{
|
| 87 |
+
if (this != &rhs) {
|
| 88 |
+
*this = rhs;
|
| 89 |
+
}
|
| 90 |
+
return *this;
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
NCursesFieldType(const NCursesFieldType& rhs)
|
| 94 |
+
: fieldtype(rhs.fieldtype)
|
| 95 |
+
{
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
};
|
| 99 |
+
|
| 100 |
+
//
|
| 101 |
+
// -------------------------------------------------------------------------
|
| 102 |
+
// The class representing a forms field, wrapping the lowlevel FIELD struct
|
| 103 |
+
// -------------------------------------------------------------------------
|
| 104 |
+
//
|
| 105 |
+
class NCURSES_CXX_IMPEXP NCursesFormField
|
| 106 |
+
{
|
| 107 |
+
friend class NCursesForm;
|
| 108 |
+
|
| 109 |
+
protected:
|
| 110 |
+
FIELD *field; // lowlevel structure
|
| 111 |
+
NCursesFieldType* ftype; // Associated field type
|
| 112 |
+
|
| 113 |
+
// Error handler
|
| 114 |
+
inline void OnError (int err) const THROW2(NCursesException const, NCursesFormException) {
|
| 115 |
+
if (err != E_OK)
|
| 116 |
+
THROW(new NCursesFormException (err));
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
public:
|
| 120 |
+
// Create a 'Null' field. Can be used to delimit a field list
|
| 121 |
+
NCursesFormField()
|
| 122 |
+
: field(STATIC_CAST(FIELD*)(0)),
|
| 123 |
+
ftype(STATIC_CAST(NCursesFieldType*)(0))
|
| 124 |
+
{
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
// Create a new field
|
| 128 |
+
NCursesFormField (int rows,
|
| 129 |
+
int ncols,
|
| 130 |
+
int first_row = 0,
|
| 131 |
+
int first_col = 0,
|
| 132 |
+
int offscreen_rows = 0,
|
| 133 |
+
int additional_buffers = 0)
|
| 134 |
+
: field(0),
|
| 135 |
+
ftype(STATIC_CAST(NCursesFieldType*)(0))
|
| 136 |
+
{
|
| 137 |
+
field = ::new_field(rows, ncols, first_row, first_col,
|
| 138 |
+
offscreen_rows, additional_buffers);
|
| 139 |
+
if (!field)
|
| 140 |
+
OnError(errno);
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
NCursesFormField& operator=(const NCursesFormField& rhs)
|
| 144 |
+
{
|
| 145 |
+
if (this != &rhs) {
|
| 146 |
+
*this = rhs;
|
| 147 |
+
}
|
| 148 |
+
return *this;
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
NCursesFormField(const NCursesFormField& rhs)
|
| 152 |
+
: field(rhs.field), ftype(rhs.ftype)
|
| 153 |
+
{
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
virtual ~NCursesFormField () THROWS(NCursesException);
|
| 157 |
+
|
| 158 |
+
// Duplicate the field at a new position
|
| 159 |
+
inline NCursesFormField* dup(int first_row, int first_col)
|
| 160 |
+
{
|
| 161 |
+
NCursesFormField* f = new NCursesFormField();
|
| 162 |
+
if (!f)
|
| 163 |
+
OnError(E_SYSTEM_ERROR);
|
| 164 |
+
else {
|
| 165 |
+
f->ftype = ftype;
|
| 166 |
+
f->field = ::dup_field(field,first_row,first_col);
|
| 167 |
+
if (!f->field)
|
| 168 |
+
OnError(errno);
|
| 169 |
+
}
|
| 170 |
+
return f;
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
// Link the field to a new location
|
| 174 |
+
inline NCursesFormField* link(int first_row, int first_col) {
|
| 175 |
+
NCursesFormField* f = new NCursesFormField();
|
| 176 |
+
if (!f)
|
| 177 |
+
OnError(E_SYSTEM_ERROR);
|
| 178 |
+
else {
|
| 179 |
+
f->ftype = ftype;
|
| 180 |
+
f->field = ::link_field(field,first_row,first_col);
|
| 181 |
+
if (!f->field)
|
| 182 |
+
OnError(errno);
|
| 183 |
+
}
|
| 184 |
+
return f;
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
// Get the lowlevel field representation
|
| 188 |
+
inline FIELD* get_field() const {
|
| 189 |
+
return field;
|
| 190 |
+
}
|
| 191 |
+
|
| 192 |
+
// Retrieve info about the field
|
| 193 |
+
inline void info(int& rows, int& ncols,
|
| 194 |
+
int& first_row, int& first_col,
|
| 195 |
+
int& offscreen_rows, int& additional_buffers) const {
|
| 196 |
+
OnError(::field_info(field, &rows, &ncols,
|
| 197 |
+
&first_row, &first_col,
|
| 198 |
+
&offscreen_rows, &additional_buffers));
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
// Retrieve info about the fields dynamic properties.
|
| 202 |
+
inline void dynamic_info(int& dynamic_rows, int& dynamic_cols,
|
| 203 |
+
int& max_growth) const {
|
| 204 |
+
OnError(::dynamic_field_info(field, &dynamic_rows, &dynamic_cols,
|
| 205 |
+
&max_growth));
|
| 206 |
+
}
|
| 207 |
+
|
| 208 |
+
// For a dynamic field you may set the maximum growth limit.
|
| 209 |
+
// A zero means unlimited growth.
|
| 210 |
+
inline void set_maximum_growth(int growth = 0) {
|
| 211 |
+
OnError(::set_max_field(field,growth));
|
| 212 |
+
}
|
| 213 |
+
|
| 214 |
+
// Move the field to a new position
|
| 215 |
+
inline void move(int row, int col) {
|
| 216 |
+
OnError(::move_field(field,row,col));
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
// Mark the field to start a new page
|
| 220 |
+
inline void new_page(bool pageFlag = FALSE) {
|
| 221 |
+
OnError(::set_new_page(field,pageFlag));
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
// Retrieve whether or not the field starts a new page.
|
| 225 |
+
inline bool is_new_page() const {
|
| 226 |
+
return ::new_page(field);
|
| 227 |
+
}
|
| 228 |
+
|
| 229 |
+
// Set the justification for the field
|
| 230 |
+
inline void set_justification(int just) {
|
| 231 |
+
OnError(::set_field_just(field,just));
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
// Retrieve the fields justification
|
| 235 |
+
inline int justification() const {
|
| 236 |
+
return ::field_just(field);
|
| 237 |
+
}
|
| 238 |
+
// Set the foreground attribute for the field
|
| 239 |
+
inline void set_foreground(chtype foreground) {
|
| 240 |
+
OnError(::set_field_fore(field,foreground));
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
// Retrieve the fields foreground attribute
|
| 244 |
+
inline chtype fore() const {
|
| 245 |
+
return ::field_fore(field);
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
// Set the background attribute for the field
|
| 249 |
+
inline void set_background(chtype background) {
|
| 250 |
+
OnError(::set_field_back(field,background));
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
// Retrieve the fields background attribute
|
| 254 |
+
inline chtype back() const {
|
| 255 |
+
return ::field_back(field);
|
| 256 |
+
}
|
| 257 |
+
|
| 258 |
+
// Set the padding character for the field
|
| 259 |
+
inline void set_pad_character(int padding) {
|
| 260 |
+
OnError(::set_field_pad(field, padding));
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
// Retrieve the fields padding character
|
| 264 |
+
inline int pad() const {
|
| 265 |
+
return ::field_pad(field);
|
| 266 |
+
}
|
| 267 |
+
|
| 268 |
+
// Switch on the fields options
|
| 269 |
+
inline void options_on (Field_Options opts) {
|
| 270 |
+
OnError (::field_opts_on (field, opts));
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
+
// Switch off the fields options
|
| 274 |
+
inline void options_off (Field_Options opts) {
|
| 275 |
+
OnError (::field_opts_off (field, opts));
|
| 276 |
+
}
|
| 277 |
+
|
| 278 |
+
// Retrieve the fields options
|
| 279 |
+
inline Field_Options options () const {
|
| 280 |
+
return ::field_opts (field);
|
| 281 |
+
}
|
| 282 |
+
|
| 283 |
+
// Set the fields options
|
| 284 |
+
inline void set_options (Field_Options opts) {
|
| 285 |
+
OnError (::set_field_opts (field, opts));
|
| 286 |
+
}
|
| 287 |
+
|
| 288 |
+
// Mark the field as changed
|
| 289 |
+
inline void set_changed(bool changeFlag = TRUE) {
|
| 290 |
+
OnError(::set_field_status(field,changeFlag));
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
// Test whether or not the field is marked as changed
|
| 294 |
+
inline bool changed() const {
|
| 295 |
+
return ::field_status(field);
|
| 296 |
+
}
|
| 297 |
+
|
| 298 |
+
// Return the index of the field in the field array of a form
|
| 299 |
+
// or -1 if the field is not associated to a form
|
| 300 |
+
inline int (index)() const {
|
| 301 |
+
return ::field_index(field);
|
| 302 |
+
}
|
| 303 |
+
|
| 304 |
+
// Store a value in a fields buffer. The default buffer is nr. 0
|
| 305 |
+
inline void set_value(const char *val, int buffer = 0) {
|
| 306 |
+
OnError(::set_field_buffer(field,buffer,val));
|
| 307 |
+
}
|
| 308 |
+
|
| 309 |
+
// Retrieve the value of a fields buffer. The default buffer is nr. 0
|
| 310 |
+
inline char* value(int buffer = 0) const {
|
| 311 |
+
return ::field_buffer(field,buffer);
|
| 312 |
+
}
|
| 313 |
+
|
| 314 |
+
// Set the validation type of the field.
|
| 315 |
+
inline void set_fieldtype(NCursesFieldType& f) {
|
| 316 |
+
ftype = &f;
|
| 317 |
+
f.set(*this); // A good friend may do that...
|
| 318 |
+
}
|
| 319 |
+
|
| 320 |
+
// Retrieve the validation type of the field.
|
| 321 |
+
inline NCursesFieldType* fieldtype() const {
|
| 322 |
+
return ftype;
|
| 323 |
+
}
|
| 324 |
+
|
| 325 |
+
};
|
| 326 |
+
|
| 327 |
+
// This are the built-in hook functions in this C++ binding. In C++ we use
|
| 328 |
+
// virtual member functions (see below On_..._Init and On_..._Termination)
|
| 329 |
+
// to provide this functionality in an object oriented manner.
|
| 330 |
+
extern "C" {
|
| 331 |
+
void _nc_xx_frm_init(FORM *);
|
| 332 |
+
void _nc_xx_frm_term(FORM *);
|
| 333 |
+
void _nc_xx_fld_init(FORM *);
|
| 334 |
+
void _nc_xx_fld_term(FORM *);
|
| 335 |
+
}
|
| 336 |
+
|
| 337 |
+
//
|
| 338 |
+
// -------------------------------------------------------------------------
|
| 339 |
+
// The class representing a form, wrapping the lowlevel FORM struct
|
| 340 |
+
// -------------------------------------------------------------------------
|
| 341 |
+
//
|
| 342 |
+
class NCURSES_CXX_IMPEXP NCursesForm : public NCursesPanel
|
| 343 |
+
{
|
| 344 |
+
protected:
|
| 345 |
+
FORM* form; // the lowlevel structure
|
| 346 |
+
|
| 347 |
+
private:
|
| 348 |
+
NCursesWindow* sub; // the subwindow object
|
| 349 |
+
bool b_sub_owner; // is this our own subwindow?
|
| 350 |
+
bool b_framed; // has the form a border?
|
| 351 |
+
bool b_autoDelete; // Delete fields when deleting form?
|
| 352 |
+
|
| 353 |
+
NCursesFormField** my_fields; // The array of fields for this form
|
| 354 |
+
|
| 355 |
+
// This structure is used for the form's user data field to link the
|
| 356 |
+
// FORM* to the C++ object and to provide extra space for a user pointer.
|
| 357 |
+
typedef struct {
|
| 358 |
+
void* m_user; // the pointer for the user's data
|
| 359 |
+
const NCursesForm* m_back; // backward pointer to C++ object
|
| 360 |
+
const FORM* m_owner;
|
| 361 |
+
} UserHook;
|
| 362 |
+
|
| 363 |
+
// Get the backward pointer to the C++ object from a FORM
|
| 364 |
+
static inline NCursesForm* getHook(const FORM *f) {
|
| 365 |
+
UserHook* hook = reinterpret_cast<UserHook*>(::form_userptr(f));
|
| 366 |
+
assert(hook != 0 && hook->m_owner==f);
|
| 367 |
+
return const_cast<NCursesForm*>(hook->m_back);
|
| 368 |
+
}
|
| 369 |
+
|
| 370 |
+
friend void _nc_xx_frm_init(FORM *);
|
| 371 |
+
friend void _nc_xx_frm_term(FORM *);
|
| 372 |
+
friend void _nc_xx_fld_init(FORM *);
|
| 373 |
+
friend void _nc_xx_fld_term(FORM *);
|
| 374 |
+
|
| 375 |
+
// Calculate FIELD* array for the menu
|
| 376 |
+
FIELD** mapFields(NCursesFormField* nfields[]);
|
| 377 |
+
|
| 378 |
+
protected:
|
| 379 |
+
// internal routines
|
| 380 |
+
inline void set_user(void *user) {
|
| 381 |
+
UserHook* uptr = reinterpret_cast<UserHook*>(::form_userptr (form));
|
| 382 |
+
assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==form);
|
| 383 |
+
uptr->m_user = user;
|
| 384 |
+
}
|
| 385 |
+
|
| 386 |
+
inline void *get_user() {
|
| 387 |
+
UserHook* uptr = reinterpret_cast<UserHook*>(::form_userptr (form));
|
| 388 |
+
assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==form);
|
| 389 |
+
return uptr->m_user;
|
| 390 |
+
}
|
| 391 |
+
|
| 392 |
+
void InitForm (NCursesFormField* Fields[],
|
| 393 |
+
bool with_frame,
|
| 394 |
+
bool autoDeleteFields);
|
| 395 |
+
|
| 396 |
+
inline void OnError (int err) const THROW2(NCursesException const, NCursesFormException) {
|
| 397 |
+
if (err != E_OK)
|
| 398 |
+
THROW(new NCursesFormException (err));
|
| 399 |
+
}
|
| 400 |
+
|
| 401 |
+
// this wraps the form_driver call.
|
| 402 |
+
virtual int driver (int c) ;
|
| 403 |
+
|
| 404 |
+
// 'Internal' constructor, builds an object without association to a
|
| 405 |
+
// field array.
|
| 406 |
+
NCursesForm( int nlines,
|
| 407 |
+
int ncols,
|
| 408 |
+
int begin_y = 0,
|
| 409 |
+
int begin_x = 0)
|
| 410 |
+
: NCursesPanel(nlines, ncols, begin_y, begin_x),
|
| 411 |
+
form (STATIC_CAST(FORM*)(0)),
|
| 412 |
+
sub(0),
|
| 413 |
+
b_sub_owner(0),
|
| 414 |
+
b_framed(0),
|
| 415 |
+
b_autoDelete(0),
|
| 416 |
+
my_fields(0)
|
| 417 |
+
{
|
| 418 |
+
}
|
| 419 |
+
|
| 420 |
+
public:
|
| 421 |
+
// Create form for the default panel.
|
| 422 |
+
NCursesForm (NCursesFormField* Fields[],
|
| 423 |
+
bool with_frame=FALSE, // reserve space for a frame?
|
| 424 |
+
bool autoDelete_Fields=FALSE) // do automatic cleanup?
|
| 425 |
+
: NCursesPanel(),
|
| 426 |
+
form(0),
|
| 427 |
+
sub(0),
|
| 428 |
+
b_sub_owner(0),
|
| 429 |
+
b_framed(0),
|
| 430 |
+
b_autoDelete(0),
|
| 431 |
+
my_fields(0)
|
| 432 |
+
{
|
| 433 |
+
InitForm(Fields, with_frame, autoDelete_Fields);
|
| 434 |
+
}
|
| 435 |
+
|
| 436 |
+
// Create a form in a panel with the given position and size.
|
| 437 |
+
NCursesForm (NCursesFormField* Fields[],
|
| 438 |
+
int nlines,
|
| 439 |
+
int ncols,
|
| 440 |
+
int begin_y,
|
| 441 |
+
int begin_x,
|
| 442 |
+
bool with_frame=FALSE, // reserve space for a frame?
|
| 443 |
+
bool autoDelete_Fields=FALSE) // do automatic cleanup?
|
| 444 |
+
: NCursesPanel(nlines, ncols, begin_y, begin_x),
|
| 445 |
+
form(0),
|
| 446 |
+
sub(0),
|
| 447 |
+
b_sub_owner(0),
|
| 448 |
+
b_framed(0),
|
| 449 |
+
b_autoDelete(0),
|
| 450 |
+
my_fields(0)
|
| 451 |
+
{
|
| 452 |
+
InitForm(Fields, with_frame, autoDelete_Fields);
|
| 453 |
+
}
|
| 454 |
+
|
| 455 |
+
NCursesForm& operator=(const NCursesForm& rhs)
|
| 456 |
+
{
|
| 457 |
+
if (this != &rhs) {
|
| 458 |
+
*this = rhs;
|
| 459 |
+
NCursesPanel::operator=(rhs);
|
| 460 |
+
}
|
| 461 |
+
return *this;
|
| 462 |
+
}
|
| 463 |
+
|
| 464 |
+
NCursesForm(const NCursesForm& rhs)
|
| 465 |
+
: NCursesPanel(rhs),
|
| 466 |
+
form(rhs.form),
|
| 467 |
+
sub(rhs.sub),
|
| 468 |
+
b_sub_owner(rhs.b_sub_owner),
|
| 469 |
+
b_framed(rhs.b_framed),
|
| 470 |
+
b_autoDelete(rhs.b_autoDelete),
|
| 471 |
+
my_fields(rhs.my_fields)
|
| 472 |
+
{
|
| 473 |
+
}
|
| 474 |
+
|
| 475 |
+
virtual ~NCursesForm() THROWS(NCursesException);
|
| 476 |
+
|
| 477 |
+
// Set the default attributes for the form
|
| 478 |
+
virtual void setDefaultAttributes();
|
| 479 |
+
|
| 480 |
+
// Retrieve current field of the form.
|
| 481 |
+
inline NCursesFormField* current_field() const {
|
| 482 |
+
return my_fields[::field_index(::current_field(form))];
|
| 483 |
+
}
|
| 484 |
+
|
| 485 |
+
// Set the forms subwindow
|
| 486 |
+
void setSubWindow(NCursesWindow& sub);
|
| 487 |
+
|
| 488 |
+
// Set these fields for the form
|
| 489 |
+
inline void setFields(NCursesFormField* Fields[]) {
|
| 490 |
+
OnError(::set_form_fields(form,mapFields(Fields)));
|
| 491 |
+
}
|
| 492 |
+
|
| 493 |
+
// Remove the form from the screen
|
| 494 |
+
inline void unpost (void) {
|
| 495 |
+
OnError (::unpost_form (form));
|
| 496 |
+
}
|
| 497 |
+
|
| 498 |
+
// Post the form to the screen if flag is true, unpost it otherwise
|
| 499 |
+
inline void post(bool flag = TRUE) {
|
| 500 |
+
OnError (flag ? ::post_form(form) : ::unpost_form (form));
|
| 501 |
+
}
|
| 502 |
+
|
| 503 |
+
// Decorations
|
| 504 |
+
inline void frame(const char *title=NULL, const char* btitle=NULL) NCURSES_OVERRIDE {
|
| 505 |
+
if (b_framed)
|
| 506 |
+
NCursesPanel::frame(title,btitle);
|
| 507 |
+
else
|
| 508 |
+
OnError(E_SYSTEM_ERROR);
|
| 509 |
+
}
|
| 510 |
+
|
| 511 |
+
inline void boldframe(const char *title=NULL, const char* btitle=NULL) NCURSES_OVERRIDE {
|
| 512 |
+
if (b_framed)
|
| 513 |
+
NCursesPanel::boldframe(title,btitle);
|
| 514 |
+
else
|
| 515 |
+
OnError(E_SYSTEM_ERROR);
|
| 516 |
+
}
|
| 517 |
+
|
| 518 |
+
inline void label(const char *topLabel, const char *bottomLabel) NCURSES_OVERRIDE {
|
| 519 |
+
if (b_framed)
|
| 520 |
+
NCursesPanel::label(topLabel,bottomLabel);
|
| 521 |
+
else
|
| 522 |
+
OnError(E_SYSTEM_ERROR);
|
| 523 |
+
}
|
| 524 |
+
|
| 525 |
+
// -----
|
| 526 |
+
// Hooks
|
| 527 |
+
// -----
|
| 528 |
+
|
| 529 |
+
// Called after the form gets repositioned in its window.
|
| 530 |
+
// This is especially true if the form is posted.
|
| 531 |
+
virtual void On_Form_Init();
|
| 532 |
+
|
| 533 |
+
// Called before the form gets repositioned in its window.
|
| 534 |
+
// This is especially true if the form is unposted.
|
| 535 |
+
virtual void On_Form_Termination();
|
| 536 |
+
|
| 537 |
+
// Called after the field became the current field
|
| 538 |
+
virtual void On_Field_Init(NCursesFormField& field);
|
| 539 |
+
|
| 540 |
+
// Called before this field is left as current field.
|
| 541 |
+
virtual void On_Field_Termination(NCursesFormField& field);
|
| 542 |
+
|
| 543 |
+
// Calculate required window size for the form.
|
| 544 |
+
void scale(int& rows, int& ncols) const {
|
| 545 |
+
OnError(::scale_form(form,&rows,&ncols));
|
| 546 |
+
}
|
| 547 |
+
|
| 548 |
+
// Retrieve number of fields in the form.
|
| 549 |
+
int count() const {
|
| 550 |
+
return ::field_count(form);
|
| 551 |
+
}
|
| 552 |
+
|
| 553 |
+
// Make the page the current page of the form.
|
| 554 |
+
void set_page(int pageNum) {
|
| 555 |
+
OnError(::set_form_page(form, pageNum));
|
| 556 |
+
}
|
| 557 |
+
|
| 558 |
+
// Retrieve current page number
|
| 559 |
+
int page() const {
|
| 560 |
+
return ::form_page(form);
|
| 561 |
+
}
|
| 562 |
+
|
| 563 |
+
// Switch on the forms options
|
| 564 |
+
inline void options_on (Form_Options opts) {
|
| 565 |
+
OnError (::form_opts_on (form, opts));
|
| 566 |
+
}
|
| 567 |
+
|
| 568 |
+
// Switch off the forms options
|
| 569 |
+
inline void options_off (Form_Options opts) {
|
| 570 |
+
OnError (::form_opts_off (form, opts));
|
| 571 |
+
}
|
| 572 |
+
|
| 573 |
+
// Retrieve the forms options
|
| 574 |
+
inline Form_Options options () const {
|
| 575 |
+
return ::form_opts (form);
|
| 576 |
+
}
|
| 577 |
+
|
| 578 |
+
// Set the forms options
|
| 579 |
+
inline void set_options (Form_Options opts) {
|
| 580 |
+
OnError (::set_form_opts (form, opts));
|
| 581 |
+
}
|
| 582 |
+
|
| 583 |
+
// Are there more data in the current field after the data shown
|
| 584 |
+
inline bool data_ahead() const {
|
| 585 |
+
return ::data_ahead(form);
|
| 586 |
+
}
|
| 587 |
+
|
| 588 |
+
// Are there more data in the current field before the data shown
|
| 589 |
+
inline bool data_behind() const {
|
| 590 |
+
return ::data_behind(form);
|
| 591 |
+
}
|
| 592 |
+
|
| 593 |
+
// Position the cursor to the current field
|
| 594 |
+
inline void position_cursor () {
|
| 595 |
+
OnError (::pos_form_cursor (form));
|
| 596 |
+
}
|
| 597 |
+
// Set the current field
|
| 598 |
+
inline void set_current(NCursesFormField& F) {
|
| 599 |
+
OnError (::set_current_field(form, F.field));
|
| 600 |
+
}
|
| 601 |
+
|
| 602 |
+
// Provide a default key virtualization. Translate the keyboard
|
| 603 |
+
// code c into a form request code.
|
| 604 |
+
// The default implementation provides a hopefully straightforward
|
| 605 |
+
// mapping for the most common keystrokes and form requests.
|
| 606 |
+
virtual int virtualize(int c);
|
| 607 |
+
|
| 608 |
+
// Operators
|
| 609 |
+
inline NCursesFormField* operator[](int i) const {
|
| 610 |
+
if ( (i < 0) || (i >= ::field_count (form)) )
|
| 611 |
+
OnError (E_BAD_ARGUMENT);
|
| 612 |
+
return my_fields[i];
|
| 613 |
+
}
|
| 614 |
+
|
| 615 |
+
// Perform the menu's operation
|
| 616 |
+
// Return the field where you left the form.
|
| 617 |
+
virtual NCursesFormField* operator()(void);
|
| 618 |
+
|
| 619 |
+
// Exception handlers. The default is a Beep.
|
| 620 |
+
virtual void On_Request_Denied(int c) const;
|
| 621 |
+
virtual void On_Invalid_Field(int c) const;
|
| 622 |
+
virtual void On_Unknown_Command(int c) const;
|
| 623 |
+
|
| 624 |
+
};
|
| 625 |
+
|
| 626 |
+
//
|
| 627 |
+
// -------------------------------------------------------------------------
|
| 628 |
+
// This is the typical C++ typesafe way to allow to attach
|
| 629 |
+
// user data to a field of a form. Its assumed that the user
|
| 630 |
+
// data belongs to some class T. Use T as template argument
|
| 631 |
+
// to create a UserField.
|
| 632 |
+
// -------------------------------------------------------------------------
|
| 633 |
+
template<class T> class NCURSES_CXX_IMPEXP NCursesUserField : public NCursesFormField
|
| 634 |
+
{
|
| 635 |
+
public:
|
| 636 |
+
NCursesUserField (int rows,
|
| 637 |
+
int ncols,
|
| 638 |
+
int first_row = 0,
|
| 639 |
+
int first_col = 0,
|
| 640 |
+
const T* p_UserData = STATIC_CAST(T*)(0),
|
| 641 |
+
int offscreen_rows = 0,
|
| 642 |
+
int additional_buffers = 0)
|
| 643 |
+
: NCursesFormField (rows, ncols,
|
| 644 |
+
first_row, first_col,
|
| 645 |
+
offscreen_rows, additional_buffers) {
|
| 646 |
+
if (field)
|
| 647 |
+
OnError(::set_field_userptr(field, STATIC_CAST(void *)(p_UserData)));
|
| 648 |
+
}
|
| 649 |
+
|
| 650 |
+
virtual ~NCursesUserField() THROWS(NCursesException) {};
|
| 651 |
+
|
| 652 |
+
inline const T* UserData (void) const {
|
| 653 |
+
return reinterpret_cast<const T*>(::field_userptr (field));
|
| 654 |
+
}
|
| 655 |
+
|
| 656 |
+
inline virtual void setUserData(const T* p_UserData) {
|
| 657 |
+
if (field)
|
| 658 |
+
OnError (::set_field_userptr (field, STATIC_CAST(void *)(p_UserData)));
|
| 659 |
+
}
|
| 660 |
+
};
|
| 661 |
+
//
|
| 662 |
+
// -------------------------------------------------------------------------
|
| 663 |
+
// The same mechanism is used to attach user data to a form
|
| 664 |
+
// -------------------------------------------------------------------------
|
| 665 |
+
//
|
| 666 |
+
template<class T> class NCURSES_CXX_IMPEXP NCursesUserForm : public NCursesForm
|
| 667 |
+
{
|
| 668 |
+
protected:
|
| 669 |
+
// 'Internal' constructor, builds an object without association to a
|
| 670 |
+
// field array.
|
| 671 |
+
NCursesUserForm( int nlines,
|
| 672 |
+
int ncols,
|
| 673 |
+
int begin_y = 0,
|
| 674 |
+
int begin_x = 0,
|
| 675 |
+
const T* p_UserData = STATIC_CAST(T*)(0))
|
| 676 |
+
: NCursesForm(nlines,ncols,begin_y,begin_x) {
|
| 677 |
+
if (form)
|
| 678 |
+
set_user (const_cast<void *>(reinterpret_cast<const void*>
|
| 679 |
+
(p_UserData)));
|
| 680 |
+
}
|
| 681 |
+
|
| 682 |
+
public:
|
| 683 |
+
NCursesUserForm (NCursesFormField* Fields[],
|
| 684 |
+
const T* p_UserData = STATIC_CAST(T*)(0),
|
| 685 |
+
bool with_frame=FALSE,
|
| 686 |
+
bool autoDelete_Fields=FALSE)
|
| 687 |
+
: NCursesForm (&Fields, with_frame, autoDelete_Fields) {
|
| 688 |
+
if (form)
|
| 689 |
+
set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
|
| 690 |
+
};
|
| 691 |
+
|
| 692 |
+
NCursesUserForm (NCursesFormField* Fields[],
|
| 693 |
+
int nlines,
|
| 694 |
+
int ncols,
|
| 695 |
+
int begin_y = 0,
|
| 696 |
+
int begin_x = 0,
|
| 697 |
+
const T* p_UserData = STATIC_CAST(T*)(0),
|
| 698 |
+
bool with_frame=FALSE,
|
| 699 |
+
bool autoDelete_Fields=FALSE)
|
| 700 |
+
: NCursesForm (&Fields, nlines, ncols, begin_y, begin_x,
|
| 701 |
+
with_frame, autoDelete_Fields) {
|
| 702 |
+
if (form)
|
| 703 |
+
set_user (const_cast<void *>(reinterpret_cast<const void*>
|
| 704 |
+
(p_UserData)));
|
| 705 |
+
};
|
| 706 |
+
|
| 707 |
+
virtual ~NCursesUserForm() THROWS(NCursesException) {
|
| 708 |
+
};
|
| 709 |
+
|
| 710 |
+
inline T* UserData (void) {
|
| 711 |
+
return reinterpret_cast<T*>(get_user ());
|
| 712 |
+
};
|
| 713 |
+
|
| 714 |
+
inline virtual void setUserData (const T* p_UserData) {
|
| 715 |
+
if (form)
|
| 716 |
+
set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
|
| 717 |
+
}
|
| 718 |
+
|
| 719 |
+
};
|
| 720 |
+
//
|
| 721 |
+
// -------------------------------------------------------------------------
|
| 722 |
+
// Builtin Fieldtypes
|
| 723 |
+
// -------------------------------------------------------------------------
|
| 724 |
+
//
|
| 725 |
+
class NCURSES_CXX_IMPEXP Alpha_Field : public NCursesFieldType
|
| 726 |
+
{
|
| 727 |
+
private:
|
| 728 |
+
int min_field_width;
|
| 729 |
+
|
| 730 |
+
void set(NCursesFormField& f) NCURSES_OVERRIDE {
|
| 731 |
+
OnError(::set_field_type(f.get_field(),fieldtype,min_field_width));
|
| 732 |
+
}
|
| 733 |
+
|
| 734 |
+
public:
|
| 735 |
+
explicit Alpha_Field(int width)
|
| 736 |
+
: NCursesFieldType(TYPE_ALPHA),
|
| 737 |
+
min_field_width(width) {
|
| 738 |
+
}
|
| 739 |
+
};
|
| 740 |
+
|
| 741 |
+
class NCURSES_CXX_IMPEXP Alphanumeric_Field : public NCursesFieldType
|
| 742 |
+
{
|
| 743 |
+
private:
|
| 744 |
+
int min_field_width;
|
| 745 |
+
|
| 746 |
+
void set(NCursesFormField& f) NCURSES_OVERRIDE {
|
| 747 |
+
OnError(::set_field_type(f.get_field(),fieldtype,min_field_width));
|
| 748 |
+
}
|
| 749 |
+
|
| 750 |
+
public:
|
| 751 |
+
explicit Alphanumeric_Field(int width)
|
| 752 |
+
: NCursesFieldType(TYPE_ALNUM),
|
| 753 |
+
min_field_width(width) {
|
| 754 |
+
}
|
| 755 |
+
};
|
| 756 |
+
|
| 757 |
+
class NCURSES_CXX_IMPEXP Integer_Field : public NCursesFieldType
|
| 758 |
+
{
|
| 759 |
+
private:
|
| 760 |
+
int precision;
|
| 761 |
+
long lower_limit, upper_limit;
|
| 762 |
+
|
| 763 |
+
void set(NCursesFormField& f) NCURSES_OVERRIDE {
|
| 764 |
+
OnError(::set_field_type(f.get_field(),fieldtype,
|
| 765 |
+
precision,lower_limit,upper_limit));
|
| 766 |
+
}
|
| 767 |
+
|
| 768 |
+
public:
|
| 769 |
+
Integer_Field(int prec, long low=0L, long high=0L)
|
| 770 |
+
: NCursesFieldType(TYPE_INTEGER),
|
| 771 |
+
precision(prec), lower_limit(low), upper_limit(high) {
|
| 772 |
+
}
|
| 773 |
+
};
|
| 774 |
+
|
| 775 |
+
class NCURSES_CXX_IMPEXP Numeric_Field : public NCursesFieldType
|
| 776 |
+
{
|
| 777 |
+
private:
|
| 778 |
+
int precision;
|
| 779 |
+
double lower_limit, upper_limit;
|
| 780 |
+
|
| 781 |
+
void set(NCursesFormField& f) NCURSES_OVERRIDE {
|
| 782 |
+
OnError(::set_field_type(f.get_field(),fieldtype,
|
| 783 |
+
precision,lower_limit,upper_limit));
|
| 784 |
+
}
|
| 785 |
+
|
| 786 |
+
public:
|
| 787 |
+
Numeric_Field(int prec, double low=0.0, double high=0.0)
|
| 788 |
+
: NCursesFieldType(TYPE_NUMERIC),
|
| 789 |
+
precision(prec), lower_limit(low), upper_limit(high) {
|
| 790 |
+
}
|
| 791 |
+
};
|
| 792 |
+
|
| 793 |
+
class NCURSES_CXX_IMPEXP Regular_Expression_Field : public NCursesFieldType
|
| 794 |
+
{
|
| 795 |
+
private:
|
| 796 |
+
char* regex;
|
| 797 |
+
|
| 798 |
+
void set(NCursesFormField& f) NCURSES_OVERRIDE {
|
| 799 |
+
OnError(::set_field_type(f.get_field(),fieldtype,regex));
|
| 800 |
+
}
|
| 801 |
+
|
| 802 |
+
void copy_regex(const char *source)
|
| 803 |
+
{
|
| 804 |
+
regex = new char[1 + ::strlen(source)];
|
| 805 |
+
(::strcpy)(regex, source);
|
| 806 |
+
}
|
| 807 |
+
|
| 808 |
+
public:
|
| 809 |
+
explicit Regular_Expression_Field(const char *expr)
|
| 810 |
+
: NCursesFieldType(TYPE_REGEXP),
|
| 811 |
+
regex(NULL)
|
| 812 |
+
{
|
| 813 |
+
copy_regex(expr);
|
| 814 |
+
}
|
| 815 |
+
|
| 816 |
+
Regular_Expression_Field& operator=(const Regular_Expression_Field& rhs)
|
| 817 |
+
{
|
| 818 |
+
if (this != &rhs) {
|
| 819 |
+
*this = rhs;
|
| 820 |
+
copy_regex(rhs.regex);
|
| 821 |
+
NCursesFieldType::operator=(rhs);
|
| 822 |
+
}
|
| 823 |
+
return *this;
|
| 824 |
+
}
|
| 825 |
+
|
| 826 |
+
Regular_Expression_Field(const Regular_Expression_Field& rhs)
|
| 827 |
+
: NCursesFieldType(rhs),
|
| 828 |
+
regex(NULL)
|
| 829 |
+
{
|
| 830 |
+
copy_regex(rhs.regex);
|
| 831 |
+
}
|
| 832 |
+
|
| 833 |
+
~Regular_Expression_Field() {
|
| 834 |
+
delete[] regex;
|
| 835 |
+
}
|
| 836 |
+
};
|
| 837 |
+
|
| 838 |
+
class NCURSES_CXX_IMPEXP Enumeration_Field : public NCursesFieldType
|
| 839 |
+
{
|
| 840 |
+
private:
|
| 841 |
+
const char** list;
|
| 842 |
+
int case_sensitive;
|
| 843 |
+
int non_unique_matches;
|
| 844 |
+
|
| 845 |
+
void set(NCursesFormField& f) NCURSES_OVERRIDE {
|
| 846 |
+
OnError(::set_field_type(f.get_field(),fieldtype,
|
| 847 |
+
list,case_sensitive,non_unique_matches));
|
| 848 |
+
}
|
| 849 |
+
public:
|
| 850 |
+
Enumeration_Field(const char* enums[],
|
| 851 |
+
bool case_sens=FALSE,
|
| 852 |
+
bool non_unique=FALSE)
|
| 853 |
+
: NCursesFieldType(TYPE_ENUM),
|
| 854 |
+
list(enums),
|
| 855 |
+
case_sensitive(case_sens ? -1 : 0),
|
| 856 |
+
non_unique_matches(non_unique ? -1 : 0) {
|
| 857 |
+
}
|
| 858 |
+
|
| 859 |
+
Enumeration_Field& operator=(const Enumeration_Field& rhs)
|
| 860 |
+
{
|
| 861 |
+
if (this != &rhs) {
|
| 862 |
+
*this = rhs;
|
| 863 |
+
NCursesFieldType::operator=(rhs);
|
| 864 |
+
}
|
| 865 |
+
return *this;
|
| 866 |
+
}
|
| 867 |
+
|
| 868 |
+
Enumeration_Field(const Enumeration_Field& rhs)
|
| 869 |
+
: NCursesFieldType(rhs),
|
| 870 |
+
list(rhs.list),
|
| 871 |
+
case_sensitive(rhs.case_sensitive),
|
| 872 |
+
non_unique_matches(rhs.non_unique_matches)
|
| 873 |
+
{
|
| 874 |
+
}
|
| 875 |
+
};
|
| 876 |
+
|
| 877 |
+
class NCURSES_CXX_IMPEXP IPV4_Address_Field : public NCursesFieldType
|
| 878 |
+
{
|
| 879 |
+
private:
|
| 880 |
+
void set(NCursesFormField& f) NCURSES_OVERRIDE {
|
| 881 |
+
OnError(::set_field_type(f.get_field(),fieldtype));
|
| 882 |
+
}
|
| 883 |
+
|
| 884 |
+
public:
|
| 885 |
+
IPV4_Address_Field() : NCursesFieldType(TYPE_IPV4) {
|
| 886 |
+
}
|
| 887 |
+
};
|
| 888 |
+
|
| 889 |
+
extern "C" {
|
| 890 |
+
bool _nc_xx_fld_fcheck(FIELD *, const void*);
|
| 891 |
+
bool _nc_xx_fld_ccheck(int c, const void *);
|
| 892 |
+
void* _nc_xx_fld_makearg(va_list*);
|
| 893 |
+
}
|
| 894 |
+
|
| 895 |
+
//
|
| 896 |
+
// -------------------------------------------------------------------------
|
| 897 |
+
// Abstract base class for User-Defined Fieldtypes
|
| 898 |
+
// -------------------------------------------------------------------------
|
| 899 |
+
//
|
| 900 |
+
class NCURSES_CXX_IMPEXP UserDefinedFieldType : public NCursesFieldType
|
| 901 |
+
{
|
| 902 |
+
friend class UDF_Init; // Internal helper to set up statics
|
| 903 |
+
private:
|
| 904 |
+
// For all C++ defined fieldtypes we need only one generic lowlevel
|
| 905 |
+
// FIELDTYPE* element.
|
| 906 |
+
static FIELDTYPE* generic_fieldtype;
|
| 907 |
+
|
| 908 |
+
protected:
|
| 909 |
+
// This are the functions required by the low level libforms functions
|
| 910 |
+
// to construct a fieldtype.
|
| 911 |
+
friend bool _nc_xx_fld_fcheck(FIELD *, const void*);
|
| 912 |
+
friend bool _nc_xx_fld_ccheck(int c, const void *);
|
| 913 |
+
friend void* _nc_xx_fld_makearg(va_list*);
|
| 914 |
+
|
| 915 |
+
void set(NCursesFormField& f) NCURSES_OVERRIDE {
|
| 916 |
+
OnError(::set_field_type(f.get_field(),fieldtype,&f));
|
| 917 |
+
}
|
| 918 |
+
|
| 919 |
+
protected:
|
| 920 |
+
// Redefine this function to do a field validation. The argument
|
| 921 |
+
// is a reference to the field you should validate.
|
| 922 |
+
virtual bool field_check(NCursesFormField& f) = 0;
|
| 923 |
+
|
| 924 |
+
// Redefine this function to do a character validation. The argument
|
| 925 |
+
// is the character to be validated.
|
| 926 |
+
virtual bool char_check (int c) = 0;
|
| 927 |
+
|
| 928 |
+
public:
|
| 929 |
+
UserDefinedFieldType();
|
| 930 |
+
};
|
| 931 |
+
|
| 932 |
+
extern "C" {
|
| 933 |
+
bool _nc_xx_next_choice(FIELD*, const void *);
|
| 934 |
+
bool _nc_xx_prev_choice(FIELD*, const void *);
|
| 935 |
+
}
|
| 936 |
+
|
| 937 |
+
//
|
| 938 |
+
// -------------------------------------------------------------------------
|
| 939 |
+
// Abstract base class for User-Defined Fieldtypes with Choice functions
|
| 940 |
+
// -------------------------------------------------------------------------
|
| 941 |
+
//
|
| 942 |
+
class NCURSES_CXX_IMPEXP UserDefinedFieldType_With_Choice : public UserDefinedFieldType
|
| 943 |
+
{
|
| 944 |
+
friend class UDF_Init; // Internal helper to set up statics
|
| 945 |
+
private:
|
| 946 |
+
// For all C++ defined fieldtypes with choice functions we need only one
|
| 947 |
+
// generic lowlevel FIELDTYPE* element.
|
| 948 |
+
static FIELDTYPE* generic_fieldtype_with_choice;
|
| 949 |
+
|
| 950 |
+
// This are the functions required by the low level libforms functions
|
| 951 |
+
// to construct a fieldtype with choice functions.
|
| 952 |
+
friend bool _nc_xx_next_choice(FIELD*, const void *);
|
| 953 |
+
friend bool _nc_xx_prev_choice(FIELD*, const void *);
|
| 954 |
+
|
| 955 |
+
protected:
|
| 956 |
+
// Redefine this function to do the retrieval of the next choice value.
|
| 957 |
+
// The argument is a reference to the field tobe examined.
|
| 958 |
+
virtual bool next (NCursesFormField& f) = 0;
|
| 959 |
+
|
| 960 |
+
// Redefine this function to do the retrieval of the previous choice value.
|
| 961 |
+
// The argument is a reference to the field tobe examined.
|
| 962 |
+
virtual bool previous(NCursesFormField& f) = 0;
|
| 963 |
+
|
| 964 |
+
public:
|
| 965 |
+
UserDefinedFieldType_With_Choice();
|
| 966 |
+
};
|
| 967 |
+
|
| 968 |
+
#endif /* NCURSES_CURSESF_H_incl */
|
llava_next/include/ncursesw/cursesm.h
ADDED
|
@@ -0,0 +1,674 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// * This makes emacs happy -*-Mode: C++;-*-
|
| 2 |
+
/****************************************************************************
|
| 3 |
+
* Copyright 2019-2020,2022 Thomas E. Dickey *
|
| 4 |
+
* Copyright 1998-2012,2014 Free Software Foundation, Inc. *
|
| 5 |
+
* *
|
| 6 |
+
* Permission is hereby granted, free of charge, to any person obtaining a *
|
| 7 |
+
* copy of this software and associated documentation files (the *
|
| 8 |
+
* "Software"), to deal in the Software without restriction, including *
|
| 9 |
+
* without limitation the rights to use, copy, modify, merge, publish, *
|
| 10 |
+
* distribute, distribute with modifications, sublicense, and/or sell *
|
| 11 |
+
* copies of the Software, and to permit persons to whom the Software is *
|
| 12 |
+
* furnished to do so, subject to the following conditions: *
|
| 13 |
+
* *
|
| 14 |
+
* The above copyright notice and this permission notice shall be included *
|
| 15 |
+
* in all copies or substantial portions of the Software. *
|
| 16 |
+
* *
|
| 17 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
|
| 18 |
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
|
| 19 |
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
|
| 20 |
+
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
|
| 21 |
+
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
|
| 22 |
+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
|
| 23 |
+
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
| 24 |
+
* *
|
| 25 |
+
* Except as contained in this notice, the name(s) of the above copyright *
|
| 26 |
+
* holders shall not be used in advertising or otherwise to promote the *
|
| 27 |
+
* sale, use or other dealings in this Software without prior written *
|
| 28 |
+
* authorization. *
|
| 29 |
+
****************************************************************************/
|
| 30 |
+
|
| 31 |
+
/****************************************************************************
|
| 32 |
+
* Author: Juergen Pfeifer, 1997 *
|
| 33 |
+
****************************************************************************/
|
| 34 |
+
|
| 35 |
+
// $Id: cursesm.h,v 1.35 2022/08/20 20:52:15 tom Exp $
|
| 36 |
+
|
| 37 |
+
#ifndef NCURSES_CURSESM_H_incl
|
| 38 |
+
#define NCURSES_CURSESM_H_incl 1
|
| 39 |
+
|
| 40 |
+
#include <ncursesw/cursesp.h>
|
| 41 |
+
|
| 42 |
+
extern "C" {
|
| 43 |
+
# include <ncursesw/menu.h>
|
| 44 |
+
}
|
| 45 |
+
//
|
| 46 |
+
// -------------------------------------------------------------------------
|
| 47 |
+
// This wraps the ITEM type of <ncursesw/menu.h>
|
| 48 |
+
// -------------------------------------------------------------------------
|
| 49 |
+
//
|
| 50 |
+
class NCURSES_CXX_IMPEXP NCursesMenuItem
|
| 51 |
+
{
|
| 52 |
+
friend class NCursesMenu;
|
| 53 |
+
|
| 54 |
+
protected:
|
| 55 |
+
ITEM *item;
|
| 56 |
+
|
| 57 |
+
inline void OnError (int err) const THROW2(NCursesException const, NCursesMenuException) {
|
| 58 |
+
if (err != E_OK)
|
| 59 |
+
THROW(new NCursesMenuException (err));
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
public:
|
| 63 |
+
NCursesMenuItem (const char* p_name = NULL,
|
| 64 |
+
const char* p_descript = NULL)
|
| 65 |
+
: item(0)
|
| 66 |
+
{
|
| 67 |
+
item = p_name ? ::new_item (p_name, p_descript) : STATIC_CAST(ITEM*)(0);
|
| 68 |
+
if (p_name && !item)
|
| 69 |
+
OnError (E_SYSTEM_ERROR);
|
| 70 |
+
}
|
| 71 |
+
// Create an item. If you pass both parameters as NULL, a delimiting
|
| 72 |
+
// item is constructed which can be used to terminate a list of
|
| 73 |
+
// NCursesMenu objects.
|
| 74 |
+
|
| 75 |
+
NCursesMenuItem& operator=(const NCursesMenuItem& rhs)
|
| 76 |
+
{
|
| 77 |
+
if (this != &rhs) {
|
| 78 |
+
*this = rhs;
|
| 79 |
+
}
|
| 80 |
+
return *this;
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
NCursesMenuItem(const NCursesMenuItem& rhs)
|
| 84 |
+
: item(0)
|
| 85 |
+
{
|
| 86 |
+
(void) rhs;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
virtual ~NCursesMenuItem () THROWS(NCursesException);
|
| 90 |
+
// Release the items memory
|
| 91 |
+
|
| 92 |
+
inline const char* name () const {
|
| 93 |
+
return ::item_name (item);
|
| 94 |
+
}
|
| 95 |
+
// Name of the item
|
| 96 |
+
|
| 97 |
+
inline const char* description () const {
|
| 98 |
+
return ::item_description (item);
|
| 99 |
+
}
|
| 100 |
+
// Description of the item
|
| 101 |
+
|
| 102 |
+
inline int (index) (void) const {
|
| 103 |
+
return ::item_index (item);
|
| 104 |
+
}
|
| 105 |
+
// Index of the item in an item array (or -1)
|
| 106 |
+
|
| 107 |
+
inline void options_on (Item_Options opts) {
|
| 108 |
+
OnError (::item_opts_on (item, opts));
|
| 109 |
+
}
|
| 110 |
+
// Switch on the items options
|
| 111 |
+
|
| 112 |
+
inline void options_off (Item_Options opts) {
|
| 113 |
+
OnError (::item_opts_off (item, opts));
|
| 114 |
+
}
|
| 115 |
+
// Switch off the item's option
|
| 116 |
+
|
| 117 |
+
inline Item_Options options () const {
|
| 118 |
+
return ::item_opts (item);
|
| 119 |
+
}
|
| 120 |
+
// Retrieve the items options
|
| 121 |
+
|
| 122 |
+
inline void set_options (Item_Options opts) {
|
| 123 |
+
OnError (::set_item_opts (item, opts));
|
| 124 |
+
}
|
| 125 |
+
// Set the items options
|
| 126 |
+
|
| 127 |
+
inline void set_value (bool f) {
|
| 128 |
+
OnError (::set_item_value (item,f));
|
| 129 |
+
}
|
| 130 |
+
// Set/Reset the items selection state
|
| 131 |
+
|
| 132 |
+
inline bool value () const {
|
| 133 |
+
return ::item_value (item);
|
| 134 |
+
}
|
| 135 |
+
// Retrieve the items selection state
|
| 136 |
+
|
| 137 |
+
inline bool visible () const {
|
| 138 |
+
return ::item_visible (item);
|
| 139 |
+
}
|
| 140 |
+
// Retrieve visibility of the item
|
| 141 |
+
|
| 142 |
+
virtual bool action();
|
| 143 |
+
// Perform an action associated with this item; you may use this in an
|
| 144 |
+
// user supplied driver for a menu; you may derive from this class and
|
| 145 |
+
// overload action() to supply items with different actions.
|
| 146 |
+
// If an action returns true, the menu will be exited. The default action
|
| 147 |
+
// is to do nothing.
|
| 148 |
+
};
|
| 149 |
+
|
| 150 |
+
// Prototype for an items callback function.
|
| 151 |
+
typedef bool ITEMCALLBACK(NCursesMenuItem&);
|
| 152 |
+
|
| 153 |
+
// If you don't like to create a child class for individual items to
|
| 154 |
+
// overload action(), you may use this class and provide a callback
|
| 155 |
+
// function pointer for items.
|
| 156 |
+
class NCURSES_CXX_IMPEXP NCursesMenuCallbackItem : public NCursesMenuItem
|
| 157 |
+
{
|
| 158 |
+
private:
|
| 159 |
+
ITEMCALLBACK* p_fct;
|
| 160 |
+
|
| 161 |
+
public:
|
| 162 |
+
NCursesMenuCallbackItem(ITEMCALLBACK* fct = NULL,
|
| 163 |
+
const char* p_name = NULL,
|
| 164 |
+
const char* p_descript = NULL )
|
| 165 |
+
: NCursesMenuItem (p_name, p_descript),
|
| 166 |
+
p_fct (fct) {
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
NCursesMenuCallbackItem& operator=(const NCursesMenuCallbackItem& rhs)
|
| 170 |
+
{
|
| 171 |
+
if (this != &rhs) {
|
| 172 |
+
*this = rhs;
|
| 173 |
+
}
|
| 174 |
+
return *this;
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
NCursesMenuCallbackItem(const NCursesMenuCallbackItem& rhs)
|
| 178 |
+
: NCursesMenuItem(rhs),
|
| 179 |
+
p_fct(0)
|
| 180 |
+
{
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
virtual ~NCursesMenuCallbackItem() THROWS(NCursesException);
|
| 184 |
+
|
| 185 |
+
bool action() NCURSES_OVERRIDE;
|
| 186 |
+
};
|
| 187 |
+
|
| 188 |
+
// This are the built-in hook functions in this C++ binding. In C++ we use
|
| 189 |
+
// virtual member functions (see below On_..._Init and On_..._Termination)
|
| 190 |
+
// to provide this functionality in an object oriented manner.
|
| 191 |
+
extern "C" {
|
| 192 |
+
void _nc_xx_mnu_init(MENU *);
|
| 193 |
+
void _nc_xx_mnu_term(MENU *);
|
| 194 |
+
void _nc_xx_itm_init(MENU *);
|
| 195 |
+
void _nc_xx_itm_term(MENU *);
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
//
|
| 199 |
+
// -------------------------------------------------------------------------
|
| 200 |
+
// This wraps the MENU type of <ncursesw/menu.h>
|
| 201 |
+
// -------------------------------------------------------------------------
|
| 202 |
+
//
|
| 203 |
+
class NCURSES_CXX_IMPEXP NCursesMenu : public NCursesPanel
|
| 204 |
+
{
|
| 205 |
+
protected:
|
| 206 |
+
MENU *menu;
|
| 207 |
+
|
| 208 |
+
private:
|
| 209 |
+
NCursesWindow* sub; // the subwindow object
|
| 210 |
+
bool b_sub_owner; // is this our own subwindow?
|
| 211 |
+
bool b_framed; // has the menu a border?
|
| 212 |
+
bool b_autoDelete; // Delete items when deleting menu?
|
| 213 |
+
|
| 214 |
+
NCursesMenuItem** my_items; // The array of items for this menu
|
| 215 |
+
|
| 216 |
+
// This structure is used for the menu's user data field to link the
|
| 217 |
+
// MENU* to the C++ object and to provide extra space for a user pointer.
|
| 218 |
+
typedef struct {
|
| 219 |
+
void* m_user; // the pointer for the user's data
|
| 220 |
+
const NCursesMenu* m_back; // backward pointer to C++ object
|
| 221 |
+
const MENU* m_owner;
|
| 222 |
+
} UserHook;
|
| 223 |
+
|
| 224 |
+
// Get the backward pointer to the C++ object from a MENU
|
| 225 |
+
static inline NCursesMenu* getHook(const MENU *m) {
|
| 226 |
+
UserHook* hook = STATIC_CAST(UserHook*)(::menu_userptr(m));
|
| 227 |
+
assert(hook != 0 && hook->m_owner==m);
|
| 228 |
+
return const_cast<NCursesMenu*>(hook->m_back);
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
friend void _nc_xx_mnu_init(MENU *);
|
| 232 |
+
friend void _nc_xx_mnu_term(MENU *);
|
| 233 |
+
friend void _nc_xx_itm_init(MENU *);
|
| 234 |
+
friend void _nc_xx_itm_term(MENU *);
|
| 235 |
+
|
| 236 |
+
// Calculate ITEM* array for the menu
|
| 237 |
+
ITEM** mapItems(NCursesMenuItem* nitems[]);
|
| 238 |
+
|
| 239 |
+
protected:
|
| 240 |
+
// internal routines
|
| 241 |
+
inline void set_user(void *user) {
|
| 242 |
+
UserHook* uptr = STATIC_CAST(UserHook*)(::menu_userptr (menu));
|
| 243 |
+
assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==menu);
|
| 244 |
+
uptr->m_user = user;
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
inline void *get_user() {
|
| 248 |
+
UserHook* uptr = STATIC_CAST(UserHook*)(::menu_userptr (menu));
|
| 249 |
+
assert (uptr != 0 && uptr->m_back==this && uptr->m_owner==menu);
|
| 250 |
+
return uptr->m_user;
|
| 251 |
+
}
|
| 252 |
+
|
| 253 |
+
void InitMenu (NCursesMenuItem* menu[],
|
| 254 |
+
bool with_frame,
|
| 255 |
+
bool autoDeleteItems);
|
| 256 |
+
|
| 257 |
+
inline void OnError (int err) const THROW2(NCursesException const, NCursesMenuException) {
|
| 258 |
+
if (err != E_OK)
|
| 259 |
+
THROW(new NCursesMenuException (this, err));
|
| 260 |
+
}
|
| 261 |
+
|
| 262 |
+
// this wraps the menu_driver call.
|
| 263 |
+
virtual int driver (int c) ;
|
| 264 |
+
|
| 265 |
+
// 'Internal' constructor to create a menu without association to
|
| 266 |
+
// an array of items.
|
| 267 |
+
NCursesMenu( int nlines,
|
| 268 |
+
int ncols,
|
| 269 |
+
int begin_y = 0,
|
| 270 |
+
int begin_x = 0)
|
| 271 |
+
: NCursesPanel(nlines,ncols,begin_y,begin_x),
|
| 272 |
+
menu (STATIC_CAST(MENU*)(0)),
|
| 273 |
+
sub(0),
|
| 274 |
+
b_sub_owner(0),
|
| 275 |
+
b_framed(0),
|
| 276 |
+
b_autoDelete(0),
|
| 277 |
+
my_items(0)
|
| 278 |
+
{
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
public:
|
| 282 |
+
// Make a full window size menu
|
| 283 |
+
NCursesMenu (NCursesMenuItem* Items[],
|
| 284 |
+
bool with_frame=FALSE, // Reserve space for a frame?
|
| 285 |
+
bool autoDelete_Items=FALSE) // Autocleanup of Items?
|
| 286 |
+
: NCursesPanel(),
|
| 287 |
+
menu(0),
|
| 288 |
+
sub(0),
|
| 289 |
+
b_sub_owner(0),
|
| 290 |
+
b_framed(0),
|
| 291 |
+
b_autoDelete(0),
|
| 292 |
+
my_items(0)
|
| 293 |
+
{
|
| 294 |
+
InitMenu(Items, with_frame, autoDelete_Items);
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
// Make a menu with a window of this size.
|
| 298 |
+
NCursesMenu (NCursesMenuItem* Items[],
|
| 299 |
+
int nlines,
|
| 300 |
+
int ncols,
|
| 301 |
+
int begin_y = 0,
|
| 302 |
+
int begin_x = 0,
|
| 303 |
+
bool with_frame=FALSE, // Reserve space for a frame?
|
| 304 |
+
bool autoDelete_Items=FALSE) // Autocleanup of Items?
|
| 305 |
+
: NCursesPanel(nlines, ncols, begin_y, begin_x),
|
| 306 |
+
menu(0),
|
| 307 |
+
sub(0),
|
| 308 |
+
b_sub_owner(0),
|
| 309 |
+
b_framed(0),
|
| 310 |
+
b_autoDelete(0),
|
| 311 |
+
my_items(0)
|
| 312 |
+
{
|
| 313 |
+
InitMenu(Items, with_frame, autoDelete_Items);
|
| 314 |
+
}
|
| 315 |
+
|
| 316 |
+
NCursesMenu& operator=(const NCursesMenu& rhs)
|
| 317 |
+
{
|
| 318 |
+
if (this != &rhs) {
|
| 319 |
+
*this = rhs;
|
| 320 |
+
NCursesPanel::operator=(rhs);
|
| 321 |
+
}
|
| 322 |
+
return *this;
|
| 323 |
+
}
|
| 324 |
+
|
| 325 |
+
NCursesMenu(const NCursesMenu& rhs)
|
| 326 |
+
: NCursesPanel(rhs),
|
| 327 |
+
menu(rhs.menu),
|
| 328 |
+
sub(rhs.sub),
|
| 329 |
+
b_sub_owner(rhs.b_sub_owner),
|
| 330 |
+
b_framed(rhs.b_framed),
|
| 331 |
+
b_autoDelete(rhs.b_autoDelete),
|
| 332 |
+
my_items(rhs.my_items)
|
| 333 |
+
{
|
| 334 |
+
}
|
| 335 |
+
|
| 336 |
+
virtual ~NCursesMenu () THROWS(NCursesException);
|
| 337 |
+
|
| 338 |
+
// Retrieve the menus subwindow
|
| 339 |
+
inline NCursesWindow& subWindow() const {
|
| 340 |
+
assert(sub!=NULL);
|
| 341 |
+
return *sub;
|
| 342 |
+
}
|
| 343 |
+
|
| 344 |
+
// Set the menus subwindow
|
| 345 |
+
void setSubWindow(NCursesWindow& sub);
|
| 346 |
+
|
| 347 |
+
// Set these items for the menu
|
| 348 |
+
inline void setItems(NCursesMenuItem* Items[]) {
|
| 349 |
+
OnError(::set_menu_items(menu,mapItems(Items)));
|
| 350 |
+
}
|
| 351 |
+
|
| 352 |
+
// Remove the menu from the screen
|
| 353 |
+
inline void unpost (void) {
|
| 354 |
+
OnError (::unpost_menu (menu));
|
| 355 |
+
}
|
| 356 |
+
|
| 357 |
+
// Post the menu to the screen if flag is true, unpost it otherwise
|
| 358 |
+
inline void post(bool flag = TRUE) {
|
| 359 |
+
flag ? OnError (::post_menu(menu)) : OnError (::unpost_menu (menu));
|
| 360 |
+
}
|
| 361 |
+
|
| 362 |
+
// Get the number of rows and columns for this menu
|
| 363 |
+
inline void scale (int& mrows, int& mcols) const {
|
| 364 |
+
OnError (::scale_menu (menu, &mrows, &mcols));
|
| 365 |
+
}
|
| 366 |
+
|
| 367 |
+
// Set the format of this menu
|
| 368 |
+
inline void set_format(int mrows, int mcols) {
|
| 369 |
+
OnError (::set_menu_format(menu, mrows, mcols));
|
| 370 |
+
}
|
| 371 |
+
|
| 372 |
+
// Get the format of this menu
|
| 373 |
+
inline void menu_format(int& rows,int& ncols) {
|
| 374 |
+
::menu_format(menu,&rows,&ncols);
|
| 375 |
+
}
|
| 376 |
+
|
| 377 |
+
// Items of the menu
|
| 378 |
+
inline NCursesMenuItem* items() const {
|
| 379 |
+
return *my_items;
|
| 380 |
+
}
|
| 381 |
+
|
| 382 |
+
// Get the number of items in this menu
|
| 383 |
+
inline int count() const {
|
| 384 |
+
return ::item_count(menu);
|
| 385 |
+
}
|
| 386 |
+
|
| 387 |
+
// Get the current item (i.e. the one the cursor is located)
|
| 388 |
+
inline NCursesMenuItem* current_item() const {
|
| 389 |
+
return my_items[::item_index(::current_item(menu))];
|
| 390 |
+
}
|
| 391 |
+
|
| 392 |
+
// Get the marker string
|
| 393 |
+
inline const char* mark() const {
|
| 394 |
+
return ::menu_mark(menu);
|
| 395 |
+
}
|
| 396 |
+
|
| 397 |
+
// Set the marker string
|
| 398 |
+
inline void set_mark(const char *marker) {
|
| 399 |
+
OnError (::set_menu_mark (menu, marker));
|
| 400 |
+
}
|
| 401 |
+
|
| 402 |
+
// Get the name of the request code c
|
| 403 |
+
inline static const char* request_name(int c) {
|
| 404 |
+
return ::menu_request_name(c);
|
| 405 |
+
}
|
| 406 |
+
|
| 407 |
+
// Get the current pattern
|
| 408 |
+
inline char* pattern() const {
|
| 409 |
+
return ::menu_pattern(menu);
|
| 410 |
+
}
|
| 411 |
+
|
| 412 |
+
// true if there is a pattern match, false otherwise.
|
| 413 |
+
bool set_pattern (const char *pat);
|
| 414 |
+
|
| 415 |
+
// set the default attributes for the menu
|
| 416 |
+
// i.e. set fore, back and grey attribute
|
| 417 |
+
virtual void setDefaultAttributes();
|
| 418 |
+
|
| 419 |
+
// Get the menus background attributes
|
| 420 |
+
inline chtype back() const {
|
| 421 |
+
return ::menu_back(menu);
|
| 422 |
+
}
|
| 423 |
+
|
| 424 |
+
// Get the menus foreground attributes
|
| 425 |
+
inline chtype fore() const {
|
| 426 |
+
return ::menu_fore(menu);
|
| 427 |
+
}
|
| 428 |
+
|
| 429 |
+
// Get the menus grey attributes (used for unselectable items)
|
| 430 |
+
inline chtype grey() const {
|
| 431 |
+
return ::menu_grey(menu);
|
| 432 |
+
}
|
| 433 |
+
|
| 434 |
+
// Set the menus background attributes
|
| 435 |
+
inline chtype set_background(chtype a) {
|
| 436 |
+
return ::set_menu_back(menu,a);
|
| 437 |
+
}
|
| 438 |
+
|
| 439 |
+
// Set the menus foreground attributes
|
| 440 |
+
inline chtype set_foreground(chtype a) {
|
| 441 |
+
return ::set_menu_fore(menu,a);
|
| 442 |
+
}
|
| 443 |
+
|
| 444 |
+
// Set the menus grey attributes (used for unselectable items)
|
| 445 |
+
inline chtype set_grey(chtype a) {
|
| 446 |
+
return ::set_menu_grey(menu,a);
|
| 447 |
+
}
|
| 448 |
+
|
| 449 |
+
inline void options_on (Menu_Options opts) {
|
| 450 |
+
OnError (::menu_opts_on (menu,opts));
|
| 451 |
+
}
|
| 452 |
+
|
| 453 |
+
inline void options_off(Menu_Options opts) {
|
| 454 |
+
OnError (::menu_opts_off(menu,opts));
|
| 455 |
+
}
|
| 456 |
+
|
| 457 |
+
inline Menu_Options options() const {
|
| 458 |
+
return ::menu_opts(menu);
|
| 459 |
+
}
|
| 460 |
+
|
| 461 |
+
inline void set_options (Menu_Options opts) {
|
| 462 |
+
OnError (::set_menu_opts (menu,opts));
|
| 463 |
+
}
|
| 464 |
+
|
| 465 |
+
inline int pad() const {
|
| 466 |
+
return ::menu_pad(menu);
|
| 467 |
+
}
|
| 468 |
+
|
| 469 |
+
inline void set_pad (int padch) {
|
| 470 |
+
OnError (::set_menu_pad (menu, padch));
|
| 471 |
+
}
|
| 472 |
+
|
| 473 |
+
// Position the cursor to the current item
|
| 474 |
+
inline void position_cursor () const {
|
| 475 |
+
OnError (::pos_menu_cursor (menu));
|
| 476 |
+
}
|
| 477 |
+
|
| 478 |
+
// Set the current item
|
| 479 |
+
inline void set_current(NCursesMenuItem& I) {
|
| 480 |
+
OnError (::set_current_item(menu, I.item));
|
| 481 |
+
}
|
| 482 |
+
|
| 483 |
+
// Get the current top row of the menu
|
| 484 |
+
inline int top_row (void) const {
|
| 485 |
+
return ::top_row (menu);
|
| 486 |
+
}
|
| 487 |
+
|
| 488 |
+
// Set the current top row of the menu
|
| 489 |
+
inline void set_top_row (int row) {
|
| 490 |
+
OnError (::set_top_row (menu, row));
|
| 491 |
+
}
|
| 492 |
+
|
| 493 |
+
// spacing control
|
| 494 |
+
// Set the spacing for the menu
|
| 495 |
+
inline void setSpacing(int spc_description,
|
| 496 |
+
int spc_rows,
|
| 497 |
+
int spc_columns) {
|
| 498 |
+
OnError(::set_menu_spacing(menu,
|
| 499 |
+
spc_description,
|
| 500 |
+
spc_rows,
|
| 501 |
+
spc_columns));
|
| 502 |
+
}
|
| 503 |
+
|
| 504 |
+
// Get the spacing info for the menu
|
| 505 |
+
inline void Spacing(int& spc_description,
|
| 506 |
+
int& spc_rows,
|
| 507 |
+
int& spc_columns) const {
|
| 508 |
+
OnError(::menu_spacing(menu,
|
| 509 |
+
&spc_description,
|
| 510 |
+
&spc_rows,
|
| 511 |
+
&spc_columns));
|
| 512 |
+
}
|
| 513 |
+
|
| 514 |
+
// Decorations
|
| 515 |
+
inline void frame(const char *title=NULL, const char* btitle=NULL) NCURSES_OVERRIDE {
|
| 516 |
+
if (b_framed)
|
| 517 |
+
NCursesPanel::frame(title,btitle);
|
| 518 |
+
else
|
| 519 |
+
OnError(E_SYSTEM_ERROR);
|
| 520 |
+
}
|
| 521 |
+
|
| 522 |
+
inline void boldframe(const char *title=NULL, const char* btitle=NULL) NCURSES_OVERRIDE {
|
| 523 |
+
if (b_framed)
|
| 524 |
+
NCursesPanel::boldframe(title,btitle);
|
| 525 |
+
else
|
| 526 |
+
OnError(E_SYSTEM_ERROR);
|
| 527 |
+
}
|
| 528 |
+
|
| 529 |
+
inline void label(const char *topLabel, const char *bottomLabel) NCURSES_OVERRIDE {
|
| 530 |
+
if (b_framed)
|
| 531 |
+
NCursesPanel::label(topLabel,bottomLabel);
|
| 532 |
+
else
|
| 533 |
+
OnError(E_SYSTEM_ERROR);
|
| 534 |
+
}
|
| 535 |
+
|
| 536 |
+
// -----
|
| 537 |
+
// Hooks
|
| 538 |
+
// -----
|
| 539 |
+
|
| 540 |
+
// Called after the menu gets repositioned in its window.
|
| 541 |
+
// This is especially true if the menu is posted.
|
| 542 |
+
virtual void On_Menu_Init();
|
| 543 |
+
|
| 544 |
+
// Called before the menu gets repositioned in its window.
|
| 545 |
+
// This is especially true if the menu is unposted.
|
| 546 |
+
virtual void On_Menu_Termination();
|
| 547 |
+
|
| 548 |
+
// Called after the item became the current item
|
| 549 |
+
virtual void On_Item_Init(NCursesMenuItem& item);
|
| 550 |
+
|
| 551 |
+
// Called before this item is left as current item.
|
| 552 |
+
virtual void On_Item_Termination(NCursesMenuItem& item);
|
| 553 |
+
|
| 554 |
+
// Provide a default key virtualization. Translate the keyboard
|
| 555 |
+
// code c into a menu request code.
|
| 556 |
+
// The default implementation provides a hopefully straightforward
|
| 557 |
+
// mapping for the most common keystrokes and menu requests.
|
| 558 |
+
virtual int virtualize(int c);
|
| 559 |
+
|
| 560 |
+
|
| 561 |
+
// Operators
|
| 562 |
+
inline NCursesMenuItem* operator[](int i) const {
|
| 563 |
+
if ( (i < 0) || (i >= ::item_count (menu)) )
|
| 564 |
+
OnError (E_BAD_ARGUMENT);
|
| 565 |
+
return (my_items[i]);
|
| 566 |
+
}
|
| 567 |
+
|
| 568 |
+
// Perform the menu's operation
|
| 569 |
+
// Return the item where you left the selection mark for a single
|
| 570 |
+
// selection menu, or NULL for a multivalued menu.
|
| 571 |
+
virtual NCursesMenuItem* operator()(void);
|
| 572 |
+
|
| 573 |
+
// --------------------
|
| 574 |
+
// Exception handlers
|
| 575 |
+
// Called by operator()
|
| 576 |
+
// --------------------
|
| 577 |
+
|
| 578 |
+
// Called if the request is denied
|
| 579 |
+
virtual void On_Request_Denied(int c) const;
|
| 580 |
+
|
| 581 |
+
// Called if the item is not selectable
|
| 582 |
+
virtual void On_Not_Selectable(int c) const;
|
| 583 |
+
|
| 584 |
+
// Called if pattern doesn't match
|
| 585 |
+
virtual void On_No_Match(int c) const;
|
| 586 |
+
|
| 587 |
+
// Called if the command is unknown
|
| 588 |
+
virtual void On_Unknown_Command(int c) const;
|
| 589 |
+
|
| 590 |
+
};
|
| 591 |
+
//
|
| 592 |
+
// -------------------------------------------------------------------------
|
| 593 |
+
// This is the typical C++ typesafe way to allow to attach
|
| 594 |
+
// user data to an item of a menu. Its assumed that the user
|
| 595 |
+
// data belongs to some class T. Use T as template argument
|
| 596 |
+
// to create a UserItem.
|
| 597 |
+
// -------------------------------------------------------------------------
|
| 598 |
+
//
|
| 599 |
+
template<class T> class NCURSES_CXX_IMPEXP NCursesUserItem : public NCursesMenuItem
|
| 600 |
+
{
|
| 601 |
+
public:
|
| 602 |
+
NCursesUserItem (const char* p_name,
|
| 603 |
+
const char* p_descript = NULL,
|
| 604 |
+
const T* p_UserData = STATIC_CAST(T*)(0))
|
| 605 |
+
: NCursesMenuItem (p_name, p_descript) {
|
| 606 |
+
if (item)
|
| 607 |
+
OnError (::set_item_userptr (item, const_cast<void *>(reinterpret_cast<const void*>(p_UserData))));
|
| 608 |
+
}
|
| 609 |
+
|
| 610 |
+
virtual ~NCursesUserItem() THROWS(NCursesException) {}
|
| 611 |
+
|
| 612 |
+
inline const T* UserData (void) const {
|
| 613 |
+
return reinterpret_cast<const T*>(::item_userptr (item));
|
| 614 |
+
};
|
| 615 |
+
|
| 616 |
+
inline virtual void setUserData(const T* p_UserData) {
|
| 617 |
+
if (item)
|
| 618 |
+
OnError (::set_item_userptr (item, const_cast<void *>(reinterpret_cast<const void *>(p_UserData))));
|
| 619 |
+
}
|
| 620 |
+
};
|
| 621 |
+
//
|
| 622 |
+
// -------------------------------------------------------------------------
|
| 623 |
+
// The same mechanism is used to attach user data to a menu
|
| 624 |
+
// -------------------------------------------------------------------------
|
| 625 |
+
//
|
| 626 |
+
template<class T> class NCURSES_CXX_IMPEXP NCursesUserMenu : public NCursesMenu
|
| 627 |
+
{
|
| 628 |
+
protected:
|
| 629 |
+
NCursesUserMenu( int nlines,
|
| 630 |
+
int ncols,
|
| 631 |
+
int begin_y = 0,
|
| 632 |
+
int begin_x = 0,
|
| 633 |
+
const T* p_UserData = STATIC_CAST(T*)(0))
|
| 634 |
+
: NCursesMenu(nlines,ncols,begin_y,begin_x) {
|
| 635 |
+
if (menu)
|
| 636 |
+
set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
|
| 637 |
+
}
|
| 638 |
+
|
| 639 |
+
public:
|
| 640 |
+
NCursesUserMenu (NCursesMenuItem* Items[],
|
| 641 |
+
const T* p_UserData = STATIC_CAST(T*)(0),
|
| 642 |
+
bool with_frame=FALSE,
|
| 643 |
+
bool autoDelete_Items=FALSE)
|
| 644 |
+
: NCursesMenu (&Items, with_frame, autoDelete_Items) {
|
| 645 |
+
if (menu)
|
| 646 |
+
set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
|
| 647 |
+
};
|
| 648 |
+
|
| 649 |
+
NCursesUserMenu (NCursesMenuItem* Items[],
|
| 650 |
+
int nlines,
|
| 651 |
+
int ncols,
|
| 652 |
+
int begin_y = 0,
|
| 653 |
+
int begin_x = 0,
|
| 654 |
+
const T* p_UserData = STATIC_CAST(T*)(0),
|
| 655 |
+
bool with_frame=FALSE)
|
| 656 |
+
: NCursesMenu (&Items, nlines, ncols, begin_y, begin_x, with_frame) {
|
| 657 |
+
if (menu)
|
| 658 |
+
set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
|
| 659 |
+
};
|
| 660 |
+
|
| 661 |
+
virtual ~NCursesUserMenu() THROWS(NCursesException) {
|
| 662 |
+
};
|
| 663 |
+
|
| 664 |
+
inline T* UserData (void) {
|
| 665 |
+
return reinterpret_cast<T*>(get_user ());
|
| 666 |
+
};
|
| 667 |
+
|
| 668 |
+
inline virtual void setUserData (const T* p_UserData) {
|
| 669 |
+
if (menu)
|
| 670 |
+
set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
|
| 671 |
+
}
|
| 672 |
+
};
|
| 673 |
+
|
| 674 |
+
#endif /* NCURSES_CURSESM_H_incl */
|
llava_next/include/ncursesw/cursesp.h
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// * This makes emacs happy -*-Mode: C++;-*-
|
| 2 |
+
// vile:cppmode
|
| 3 |
+
/****************************************************************************
|
| 4 |
+
* Copyright 2019-2021,2022 Thomas E. Dickey *
|
| 5 |
+
* Copyright 1998-2012,2014 Free Software Foundation, Inc. *
|
| 6 |
+
* *
|
| 7 |
+
* Permission is hereby granted, free of charge, to any person obtaining a *
|
| 8 |
+
* copy of this software and associated documentation files (the *
|
| 9 |
+
* "Software"), to deal in the Software without restriction, including *
|
| 10 |
+
* without limitation the rights to use, copy, modify, merge, publish, *
|
| 11 |
+
* distribute, distribute with modifications, sublicense, and/or sell *
|
| 12 |
+
* copies of the Software, and to permit persons to whom the Software is *
|
| 13 |
+
* furnished to do so, subject to the following conditions: *
|
| 14 |
+
* *
|
| 15 |
+
* The above copyright notice and this permission notice shall be included *
|
| 16 |
+
* in all copies or substantial portions of the Software. *
|
| 17 |
+
* *
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
|
| 19 |
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
|
| 20 |
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
|
| 21 |
+
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
|
| 22 |
+
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
|
| 23 |
+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
|
| 24 |
+
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
| 25 |
+
* *
|
| 26 |
+
* Except as contained in this notice, the name(s) of the above copyright *
|
| 27 |
+
* holders shall not be used in advertising or otherwise to promote the *
|
| 28 |
+
* sale, use or other dealings in this Software without prior written *
|
| 29 |
+
* authorization. *
|
| 30 |
+
****************************************************************************/
|
| 31 |
+
|
| 32 |
+
/****************************************************************************
|
| 33 |
+
* Author: Juergen Pfeifer, 1997 *
|
| 34 |
+
****************************************************************************/
|
| 35 |
+
|
| 36 |
+
#ifndef NCURSES_CURSESP_H_incl
|
| 37 |
+
#define NCURSES_CURSESP_H_incl 1
|
| 38 |
+
|
| 39 |
+
// $Id: cursesp.h,v 1.36 2022/08/20 20:52:15 tom Exp $
|
| 40 |
+
|
| 41 |
+
#include <ncursesw/cursesw.h>
|
| 42 |
+
|
| 43 |
+
extern "C" {
|
| 44 |
+
# include <ncursesw/panel.h>
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
class NCURSES_CXX_IMPEXP NCursesPanel
|
| 48 |
+
: public NCursesWindow
|
| 49 |
+
{
|
| 50 |
+
protected:
|
| 51 |
+
PANEL *p;
|
| 52 |
+
static NCursesPanel *dummy;
|
| 53 |
+
|
| 54 |
+
private:
|
| 55 |
+
// This structure is used for the panel's user data field to link the
|
| 56 |
+
// PANEL* to the C++ object and to provide extra space for a user pointer.
|
| 57 |
+
typedef struct {
|
| 58 |
+
void* m_user; // the pointer for the user's data
|
| 59 |
+
const NCursesPanel* m_back; // backward pointer to C++ object
|
| 60 |
+
const PANEL* m_owner; // the panel itself
|
| 61 |
+
} UserHook;
|
| 62 |
+
|
| 63 |
+
inline UserHook *UserPointer()
|
| 64 |
+
{
|
| 65 |
+
UserHook* uptr = reinterpret_cast<UserHook*>(
|
| 66 |
+
const_cast<void *>(::panel_userptr (p)));
|
| 67 |
+
return uptr;
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
void init(); // Initialize the panel object
|
| 71 |
+
|
| 72 |
+
protected:
|
| 73 |
+
void set_user(void *user)
|
| 74 |
+
{
|
| 75 |
+
UserHook* uptr = UserPointer();
|
| 76 |
+
if (uptr != 0 && uptr->m_back==this && uptr->m_owner==p) {
|
| 77 |
+
uptr->m_user = user;
|
| 78 |
+
}
|
| 79 |
+
}
|
| 80 |
+
// Set the user pointer of the panel.
|
| 81 |
+
|
| 82 |
+
void *get_user()
|
| 83 |
+
{
|
| 84 |
+
UserHook* uptr = UserPointer();
|
| 85 |
+
void *result = 0;
|
| 86 |
+
if (uptr != 0 && uptr->m_back==this && uptr->m_owner==p)
|
| 87 |
+
result = uptr->m_user;
|
| 88 |
+
return result;
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
void OnError (int err) const THROW2(NCursesException const, NCursesPanelException)
|
| 92 |
+
{
|
| 93 |
+
if (err==ERR)
|
| 94 |
+
THROW(new NCursesPanelException (this, err));
|
| 95 |
+
}
|
| 96 |
+
// If err is equal to the curses error indicator ERR, an error handler
|
| 97 |
+
// is called.
|
| 98 |
+
|
| 99 |
+
// Get a keystroke. Default implementation calls getch()
|
| 100 |
+
virtual int getKey(void);
|
| 101 |
+
|
| 102 |
+
public:
|
| 103 |
+
NCursesPanel(int nlines,
|
| 104 |
+
int ncols,
|
| 105 |
+
int begin_y = 0,
|
| 106 |
+
int begin_x = 0)
|
| 107 |
+
: NCursesWindow(nlines,ncols,begin_y,begin_x), p(0)
|
| 108 |
+
{
|
| 109 |
+
init();
|
| 110 |
+
}
|
| 111 |
+
// Create a panel with this size starting at the requested position.
|
| 112 |
+
|
| 113 |
+
NCursesPanel()
|
| 114 |
+
: NCursesWindow(::stdscr), p(0)
|
| 115 |
+
{
|
| 116 |
+
init();
|
| 117 |
+
}
|
| 118 |
+
// This constructor creates the default Panel associated with the
|
| 119 |
+
// ::stdscr window
|
| 120 |
+
|
| 121 |
+
NCursesPanel& operator=(const NCursesPanel& rhs)
|
| 122 |
+
{
|
| 123 |
+
if (this != &rhs) {
|
| 124 |
+
*this = rhs;
|
| 125 |
+
NCursesWindow::operator=(rhs);
|
| 126 |
+
}
|
| 127 |
+
return *this;
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
NCursesPanel(const NCursesPanel& rhs)
|
| 131 |
+
: NCursesWindow(rhs),
|
| 132 |
+
p(rhs.p)
|
| 133 |
+
{
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
virtual ~NCursesPanel() THROWS(NCursesException);
|
| 137 |
+
|
| 138 |
+
// basic manipulation
|
| 139 |
+
inline void hide()
|
| 140 |
+
{
|
| 141 |
+
OnError (::hide_panel(p));
|
| 142 |
+
}
|
| 143 |
+
// Hide the panel. It stays in the stack but becomes invisible.
|
| 144 |
+
|
| 145 |
+
inline void show()
|
| 146 |
+
{
|
| 147 |
+
OnError (::show_panel(p));
|
| 148 |
+
}
|
| 149 |
+
// Show the panel, i.e. make it visible.
|
| 150 |
+
|
| 151 |
+
inline void top()
|
| 152 |
+
{
|
| 153 |
+
OnError (::top_panel(p));
|
| 154 |
+
}
|
| 155 |
+
// Make this panel the top panel in the stack.
|
| 156 |
+
|
| 157 |
+
inline void bottom()
|
| 158 |
+
{
|
| 159 |
+
OnError (::bottom_panel(p));
|
| 160 |
+
}
|
| 161 |
+
// Make this panel the bottom panel in the stack.
|
| 162 |
+
// N.B.: The panel associated with ::stdscr is always on the bottom. So
|
| 163 |
+
// actually bottom() makes the panel the first above ::stdscr.
|
| 164 |
+
|
| 165 |
+
virtual int mvwin(int y, int x) NCURSES_OVERRIDE
|
| 166 |
+
{
|
| 167 |
+
OnError(::move_panel(p, y, x));
|
| 168 |
+
return OK;
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
inline bool hidden() const
|
| 172 |
+
{
|
| 173 |
+
return (::panel_hidden (p) ? TRUE : FALSE);
|
| 174 |
+
}
|
| 175 |
+
// Return TRUE if the panel is hidden, FALSE otherwise.
|
| 176 |
+
|
| 177 |
+
/* The functions panel_above() and panel_below() are not reflected in
|
| 178 |
+
the NCursesPanel class. The reason for this is, that we cannot
|
| 179 |
+
assume that a panel retrieved by those operations is one wrapped
|
| 180 |
+
by a C++ class. Although this situation might be handled, we also
|
| 181 |
+
need a reverse mapping from PANEL to NCursesPanel which needs some
|
| 182 |
+
redesign of the low level stuff. At the moment, we define them in the
|
| 183 |
+
interface but they will always produce an error. */
|
| 184 |
+
inline NCursesPanel& above() const
|
| 185 |
+
{
|
| 186 |
+
OnError(ERR);
|
| 187 |
+
return *dummy;
|
| 188 |
+
}
|
| 189 |
+
|
| 190 |
+
inline NCursesPanel& below() const
|
| 191 |
+
{
|
| 192 |
+
OnError(ERR);
|
| 193 |
+
return *dummy;
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
// Those two are rewrites of the corresponding virtual members of
|
| 197 |
+
// NCursesWindow
|
| 198 |
+
virtual int refresh() NCURSES_OVERRIDE;
|
| 199 |
+
// Propagate all panel changes to the virtual screen and update the
|
| 200 |
+
// physical screen.
|
| 201 |
+
|
| 202 |
+
virtual int noutrefresh() NCURSES_OVERRIDE;
|
| 203 |
+
// Propagate all panel changes to the virtual screen.
|
| 204 |
+
|
| 205 |
+
static void redraw();
|
| 206 |
+
// Redraw all panels.
|
| 207 |
+
|
| 208 |
+
// decorations
|
| 209 |
+
virtual void frame(const char* title=NULL,
|
| 210 |
+
const char* btitle=NULL);
|
| 211 |
+
// Put a frame around the panel and put the title centered in the top line
|
| 212 |
+
// and btitle in the bottom line.
|
| 213 |
+
|
| 214 |
+
virtual void boldframe(const char* title=NULL,
|
| 215 |
+
const char* btitle=NULL);
|
| 216 |
+
// Same as frame(), but use highlighted attributes.
|
| 217 |
+
|
| 218 |
+
virtual void label(const char* topLabel,
|
| 219 |
+
const char* bottomLabel);
|
| 220 |
+
// Put the title centered in the top line and btitle in the bottom line.
|
| 221 |
+
|
| 222 |
+
virtual void centertext(int row,const char* label);
|
| 223 |
+
// Put the label text centered in the specified row.
|
| 224 |
+
};
|
| 225 |
+
|
| 226 |
+
/* We use templates to provide a typesafe mechanism to associate
|
| 227 |
+
* user data with a panel. A NCursesUserPanel<T> is a panel
|
| 228 |
+
* associated with some user data of type T.
|
| 229 |
+
*/
|
| 230 |
+
template<class T> class NCursesUserPanel : public NCursesPanel
|
| 231 |
+
{
|
| 232 |
+
public:
|
| 233 |
+
NCursesUserPanel (int nlines,
|
| 234 |
+
int ncols,
|
| 235 |
+
int begin_y = 0,
|
| 236 |
+
int begin_x = 0,
|
| 237 |
+
const T* p_UserData = STATIC_CAST(T*)(0))
|
| 238 |
+
: NCursesPanel (nlines, ncols, begin_y, begin_x)
|
| 239 |
+
{
|
| 240 |
+
if (p)
|
| 241 |
+
set_user (const_cast<void *>(reinterpret_cast<const void*>
|
| 242 |
+
(p_UserData)));
|
| 243 |
+
};
|
| 244 |
+
// This creates an user panel of the requested size with associated
|
| 245 |
+
// user data pointed to by p_UserData.
|
| 246 |
+
|
| 247 |
+
explicit NCursesUserPanel(const T* p_UserData = STATIC_CAST(T*)(0)) : NCursesPanel()
|
| 248 |
+
{
|
| 249 |
+
if (p)
|
| 250 |
+
set_user(const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
|
| 251 |
+
};
|
| 252 |
+
// This creates an user panel associated with the ::stdscr and user data
|
| 253 |
+
// pointed to by p_UserData.
|
| 254 |
+
|
| 255 |
+
virtual ~NCursesUserPanel() THROWS(NCursesException) {};
|
| 256 |
+
|
| 257 |
+
T* UserData (void)
|
| 258 |
+
{
|
| 259 |
+
return reinterpret_cast<T*>(get_user ());
|
| 260 |
+
};
|
| 261 |
+
// Retrieve the user data associated with the panel.
|
| 262 |
+
|
| 263 |
+
virtual void setUserData (const T* p_UserData)
|
| 264 |
+
{
|
| 265 |
+
if (p)
|
| 266 |
+
set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
|
| 267 |
+
}
|
| 268 |
+
// Associate the user panel with the user data pointed to by p_UserData.
|
| 269 |
+
};
|
| 270 |
+
|
| 271 |
+
#endif /* NCURSES_CURSESP_H_incl */
|
llava_next/include/ncursesw/cursesw.h
ADDED
|
@@ -0,0 +1,1581 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// * This makes emacs happy -*-Mode: C++;-*-
|
| 2 |
+
// vile:cppmode
|
| 3 |
+
/****************************************************************************
|
| 4 |
+
* Copyright 2019-2021,2022 Thomas E. Dickey *
|
| 5 |
+
* Copyright 1998-2014,2017 Free Software Foundation, Inc. *
|
| 6 |
+
* *
|
| 7 |
+
* Permission is hereby granted, free of charge, to any person obtaining a *
|
| 8 |
+
* copy of this software and associated documentation files (the *
|
| 9 |
+
* "Software"), to deal in the Software without restriction, including *
|
| 10 |
+
* without limitation the rights to use, copy, modify, merge, publish, *
|
| 11 |
+
* distribute, distribute with modifications, sublicense, and/or sell *
|
| 12 |
+
* copies of the Software, and to permit persons to whom the Software is *
|
| 13 |
+
* furnished to do so, subject to the following conditions: *
|
| 14 |
+
* *
|
| 15 |
+
* The above copyright notice and this permission notice shall be included *
|
| 16 |
+
* in all copies or substantial portions of the Software. *
|
| 17 |
+
* *
|
| 18 |
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
|
| 19 |
+
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
|
| 20 |
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
|
| 21 |
+
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
|
| 22 |
+
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
|
| 23 |
+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
|
| 24 |
+
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
| 25 |
+
* *
|
| 26 |
+
* Except as contained in this notice, the name(s) of the above copyright *
|
| 27 |
+
* holders shall not be used in advertising or otherwise to promote the *
|
| 28 |
+
* sale, use or other dealings in this Software without prior written *
|
| 29 |
+
* authorization. *
|
| 30 |
+
****************************************************************************/
|
| 31 |
+
|
| 32 |
+
#ifndef NCURSES_CURSESW_H_incl
|
| 33 |
+
#define NCURSES_CURSESW_H_incl 1
|
| 34 |
+
|
| 35 |
+
// $Id: cursesw.h,v 1.59 2022/08/20 20:52:15 tom Exp $
|
| 36 |
+
|
| 37 |
+
extern "C" {
|
| 38 |
+
# include <ncursesw/curses.h>
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
#if defined(BUILDING_NCURSES_CXX)
|
| 42 |
+
# define NCURSES_CXX_IMPEXP NCURSES_EXPORT_GENERAL_EXPORT
|
| 43 |
+
#else
|
| 44 |
+
# define NCURSES_CXX_IMPEXP NCURSES_EXPORT_GENERAL_IMPORT
|
| 45 |
+
#endif
|
| 46 |
+
|
| 47 |
+
#define NCURSES_CXX_WRAPPED_VAR(type,name) extern NCURSES_CXX_IMPEXP type NCURSES_PUBLIC_VAR(name)(void)
|
| 48 |
+
|
| 49 |
+
#define NCURSES_CXX_EXPORT(type) NCURSES_CXX_IMPEXP type NCURSES_API
|
| 50 |
+
#define NCURSES_CXX_EXPORT_VAR(type) NCURSES_CXX_IMPEXP type
|
| 51 |
+
|
| 52 |
+
#include <ncursesw/etip.h>
|
| 53 |
+
|
| 54 |
+
/* SCO 3.2v4 curses.h includes term.h, which defines lines as a macro.
|
| 55 |
+
Undefine it here, because NCursesWindow uses lines as a method. */
|
| 56 |
+
#undef lines
|
| 57 |
+
|
| 58 |
+
/* "Convert" macros to inlines. We'll define it as another symbol to avoid
|
| 59 |
+
* conflict with library symbols.
|
| 60 |
+
*/
|
| 61 |
+
#undef UNDEF
|
| 62 |
+
#define UNDEF(name) CUR_ ##name
|
| 63 |
+
|
| 64 |
+
#ifdef addch
|
| 65 |
+
inline int UNDEF(addch)(chtype ch) { return addch(ch); }
|
| 66 |
+
#undef addch
|
| 67 |
+
#define addch UNDEF(addch)
|
| 68 |
+
#endif
|
| 69 |
+
|
| 70 |
+
#ifdef addchstr
|
| 71 |
+
inline int UNDEF(addchstr)(chtype *at) { return addchstr(at); }
|
| 72 |
+
#undef addchstr
|
| 73 |
+
#define addchstr UNDEF(addchstr)
|
| 74 |
+
#endif
|
| 75 |
+
|
| 76 |
+
#ifdef addnstr
|
| 77 |
+
inline int UNDEF(addnstr)(const char *str, int n)
|
| 78 |
+
{ return addnstr(str, n); }
|
| 79 |
+
#undef addnstr
|
| 80 |
+
#define addnstr UNDEF(addnstr)
|
| 81 |
+
#endif
|
| 82 |
+
|
| 83 |
+
#ifdef addstr
|
| 84 |
+
inline int UNDEF(addstr)(const char * str) { return addstr(str); }
|
| 85 |
+
#undef addstr
|
| 86 |
+
#define addstr UNDEF(addstr)
|
| 87 |
+
#endif
|
| 88 |
+
|
| 89 |
+
#ifdef attroff
|
| 90 |
+
inline int UNDEF(attroff)(chtype at) { return attroff(at); }
|
| 91 |
+
#undef attroff
|
| 92 |
+
#define attroff UNDEF(attroff)
|
| 93 |
+
#endif
|
| 94 |
+
|
| 95 |
+
#ifdef attron
|
| 96 |
+
inline int UNDEF(attron)(chtype at) { return attron(at); }
|
| 97 |
+
#undef attron
|
| 98 |
+
#define attron UNDEF(attron)
|
| 99 |
+
#endif
|
| 100 |
+
|
| 101 |
+
#ifdef attrset
|
| 102 |
+
inline chtype UNDEF(attrset)(chtype at) { return attrset(at); }
|
| 103 |
+
#undef attrset
|
| 104 |
+
#define attrset UNDEF(attrset)
|
| 105 |
+
#endif
|
| 106 |
+
|
| 107 |
+
#ifdef bkgd
|
| 108 |
+
inline int UNDEF(bkgd)(chtype ch) { return bkgd(ch); }
|
| 109 |
+
#undef bkgd
|
| 110 |
+
#define bkgd UNDEF(bkgd)
|
| 111 |
+
#endif
|
| 112 |
+
|
| 113 |
+
#ifdef bkgdset
|
| 114 |
+
inline void UNDEF(bkgdset)(chtype ch) { bkgdset(ch); }
|
| 115 |
+
#undef bkgdset
|
| 116 |
+
#define bkgdset UNDEF(bkgdset)
|
| 117 |
+
#endif
|
| 118 |
+
|
| 119 |
+
#ifdef border
|
| 120 |
+
inline int UNDEF(border)(chtype ls, chtype rs, chtype ts, chtype bs, chtype tl, chtype tr, chtype bl, chtype br)
|
| 121 |
+
{ return border(ls, rs, ts, bs, tl, tr, bl, br); }
|
| 122 |
+
#undef border
|
| 123 |
+
#define border UNDEF(border)
|
| 124 |
+
#endif
|
| 125 |
+
|
| 126 |
+
#ifdef box
|
| 127 |
+
inline int UNDEF(box)(WINDOW *win, int v, int h) { return box(win, v, h); }
|
| 128 |
+
#undef box
|
| 129 |
+
#define box UNDEF(box)
|
| 130 |
+
#endif
|
| 131 |
+
|
| 132 |
+
#ifdef chgat
|
| 133 |
+
inline int UNDEF(chgat)(int n, attr_t attr, NCURSES_PAIRS_T color, const void *opts) {
|
| 134 |
+
return chgat(n, attr, color, opts); }
|
| 135 |
+
#undef chgat
|
| 136 |
+
#define chgat UNDEF(chgat)
|
| 137 |
+
#endif
|
| 138 |
+
|
| 139 |
+
#ifdef clear
|
| 140 |
+
inline int UNDEF(clear)() { return clear(); }
|
| 141 |
+
#undef clear
|
| 142 |
+
#define clear UNDEF(clear)
|
| 143 |
+
#endif
|
| 144 |
+
|
| 145 |
+
#ifdef clearok
|
| 146 |
+
inline int UNDEF(clearok)(WINDOW* win, bool bf) { return clearok(win, bf); }
|
| 147 |
+
#undef clearok
|
| 148 |
+
#define clearok UNDEF(clearok)
|
| 149 |
+
#else
|
| 150 |
+
extern "C" NCURSES_IMPEXP int NCURSES_API clearok(WINDOW*, bool);
|
| 151 |
+
#endif
|
| 152 |
+
|
| 153 |
+
#ifdef clrtobot
|
| 154 |
+
inline int UNDEF(clrtobot)() { return clrtobot(); }
|
| 155 |
+
#undef clrtobot
|
| 156 |
+
#define clrtobot UNDEF(clrtobot)
|
| 157 |
+
#endif
|
| 158 |
+
|
| 159 |
+
#ifdef clrtoeol
|
| 160 |
+
inline int UNDEF(clrtoeol)() { return clrtoeol(); }
|
| 161 |
+
#undef clrtoeol
|
| 162 |
+
#define clrtoeol UNDEF(clrtoeol)
|
| 163 |
+
#endif
|
| 164 |
+
|
| 165 |
+
#ifdef color_set
|
| 166 |
+
inline chtype UNDEF(color_set)(NCURSES_PAIRS_T p, void* opts) { return color_set(p, opts); }
|
| 167 |
+
#undef color_set
|
| 168 |
+
#define color_set UNDEF(color_set)
|
| 169 |
+
#endif
|
| 170 |
+
|
| 171 |
+
#ifdef crmode
|
| 172 |
+
inline int UNDEF(crmode)(void) { return crmode(); }
|
| 173 |
+
#undef crmode
|
| 174 |
+
#define crmode UNDEF(crmode)
|
| 175 |
+
#endif
|
| 176 |
+
|
| 177 |
+
#ifdef delch
|
| 178 |
+
inline int UNDEF(delch)() { return delch(); }
|
| 179 |
+
#undef delch
|
| 180 |
+
#define delch UNDEF(delch)
|
| 181 |
+
#endif
|
| 182 |
+
|
| 183 |
+
#ifdef deleteln
|
| 184 |
+
inline int UNDEF(deleteln)() { return deleteln(); }
|
| 185 |
+
#undef deleteln
|
| 186 |
+
#define deleteln UNDEF(deleteln)
|
| 187 |
+
#endif
|
| 188 |
+
|
| 189 |
+
#ifdef echochar
|
| 190 |
+
inline int UNDEF(echochar)(chtype ch) { return echochar(ch); }
|
| 191 |
+
#undef echochar
|
| 192 |
+
#define echochar UNDEF(echochar)
|
| 193 |
+
#endif
|
| 194 |
+
|
| 195 |
+
#ifdef erase
|
| 196 |
+
inline int UNDEF(erase)() { return erase(); }
|
| 197 |
+
#undef erase
|
| 198 |
+
#define erase UNDEF(erase)
|
| 199 |
+
#endif
|
| 200 |
+
|
| 201 |
+
#ifdef fixterm
|
| 202 |
+
inline int UNDEF(fixterm)(void) { return fixterm(); }
|
| 203 |
+
#undef fixterm
|
| 204 |
+
#define fixterm UNDEF(fixterm)
|
| 205 |
+
#endif
|
| 206 |
+
|
| 207 |
+
#ifdef flushok
|
| 208 |
+
inline int UNDEF(flushok)(WINDOW* _win, bool _bf) {
|
| 209 |
+
return flushok(_win, _bf); }
|
| 210 |
+
#undef flushok
|
| 211 |
+
#define flushok UNDEF(flushok)
|
| 212 |
+
#else
|
| 213 |
+
#define _no_flushok
|
| 214 |
+
#endif
|
| 215 |
+
|
| 216 |
+
#ifdef getattrs
|
| 217 |
+
inline int UNDEF(getattrs)(WINDOW *win) { return getattrs(win); }
|
| 218 |
+
#undef getattrs
|
| 219 |
+
#define getattrs UNDEF(getattrs)
|
| 220 |
+
#endif
|
| 221 |
+
|
| 222 |
+
#ifdef getbegyx
|
| 223 |
+
inline void UNDEF(getbegyx)(WINDOW* win, int& y, int& x) { getbegyx(win, y, x); }
|
| 224 |
+
#undef getbegyx
|
| 225 |
+
#define getbegyx UNDEF(getbegyx)
|
| 226 |
+
#endif
|
| 227 |
+
|
| 228 |
+
#ifdef getbkgd
|
| 229 |
+
inline chtype UNDEF(getbkgd)(const WINDOW *win) { return getbkgd(win); }
|
| 230 |
+
#undef getbkgd
|
| 231 |
+
#define getbkgd UNDEF(getbkgd)
|
| 232 |
+
#endif
|
| 233 |
+
|
| 234 |
+
#ifdef getch
|
| 235 |
+
inline int UNDEF(getch)() { return getch(); }
|
| 236 |
+
#undef getch
|
| 237 |
+
#define getch UNDEF(getch)
|
| 238 |
+
#endif
|
| 239 |
+
|
| 240 |
+
#ifdef getmaxyx
|
| 241 |
+
inline void UNDEF(getmaxyx)(WINDOW* win, int& y, int& x) { getmaxyx(win, y, x); }
|
| 242 |
+
#undef getmaxyx
|
| 243 |
+
#define getmaxyx UNDEF(getmaxyx)
|
| 244 |
+
#endif
|
| 245 |
+
|
| 246 |
+
#ifdef getnstr
|
| 247 |
+
inline int UNDEF(getnstr)(char *_str, int n) { return getnstr(_str, n); }
|
| 248 |
+
#undef getnstr
|
| 249 |
+
#define getnstr UNDEF(getnstr)
|
| 250 |
+
#endif
|
| 251 |
+
|
| 252 |
+
#ifdef getparyx
|
| 253 |
+
inline void UNDEF(getparyx)(WINDOW* win, int& y, int& x) { getparyx(win, y, x); }
|
| 254 |
+
#undef getparyx
|
| 255 |
+
#define getparyx UNDEF(getparyx)
|
| 256 |
+
#endif
|
| 257 |
+
|
| 258 |
+
#ifdef getstr
|
| 259 |
+
inline int UNDEF(getstr)(char *_str) { return getstr(_str); }
|
| 260 |
+
#undef getstr
|
| 261 |
+
#define getstr UNDEF(getstr)
|
| 262 |
+
#endif
|
| 263 |
+
|
| 264 |
+
#ifdef getyx
|
| 265 |
+
inline void UNDEF(getyx)(const WINDOW* win, int& y, int& x) {
|
| 266 |
+
getyx(win, y, x); }
|
| 267 |
+
#undef getyx
|
| 268 |
+
#define getyx UNDEF(getyx)
|
| 269 |
+
#endif
|
| 270 |
+
|
| 271 |
+
#ifdef hline
|
| 272 |
+
inline int UNDEF(hline)(chtype ch, int n) { return hline(ch, n); }
|
| 273 |
+
#undef hline
|
| 274 |
+
#define hline UNDEF(hline)
|
| 275 |
+
#endif
|
| 276 |
+
|
| 277 |
+
#ifdef inch
|
| 278 |
+
inline chtype UNDEF(inch)() { return inch(); }
|
| 279 |
+
#undef inch
|
| 280 |
+
#define inch UNDEF(inch)
|
| 281 |
+
#endif
|
| 282 |
+
|
| 283 |
+
#ifdef inchstr
|
| 284 |
+
inline int UNDEF(inchstr)(chtype *str) { return inchstr(str); }
|
| 285 |
+
#undef inchstr
|
| 286 |
+
#define inchstr UNDEF(inchstr)
|
| 287 |
+
#endif
|
| 288 |
+
|
| 289 |
+
#ifdef innstr
|
| 290 |
+
inline int UNDEF(innstr)(char *_str, int n) { return innstr(_str, n); }
|
| 291 |
+
#undef innstr
|
| 292 |
+
#define innstr UNDEF(innstr)
|
| 293 |
+
#endif
|
| 294 |
+
|
| 295 |
+
#ifdef insch
|
| 296 |
+
inline int UNDEF(insch)(chtype c) { return insch(c); }
|
| 297 |
+
#undef insch
|
| 298 |
+
#define insch UNDEF(insch)
|
| 299 |
+
#endif
|
| 300 |
+
|
| 301 |
+
#ifdef insdelln
|
| 302 |
+
inline int UNDEF(insdelln)(int n) { return insdelln(n); }
|
| 303 |
+
#undef insdelln
|
| 304 |
+
#define insdelln UNDEF(insdelln)
|
| 305 |
+
#endif
|
| 306 |
+
|
| 307 |
+
#ifdef insertln
|
| 308 |
+
inline int UNDEF(insertln)() { return insertln(); }
|
| 309 |
+
#undef insertln
|
| 310 |
+
#define insertln UNDEF(insertln)
|
| 311 |
+
#endif
|
| 312 |
+
|
| 313 |
+
#ifdef insnstr
|
| 314 |
+
inline int UNDEF(insnstr)(const char *_str, int n) {
|
| 315 |
+
return insnstr(_str, n); }
|
| 316 |
+
#undef insnstr
|
| 317 |
+
#define insnstr UNDEF(insnstr)
|
| 318 |
+
#endif
|
| 319 |
+
|
| 320 |
+
#ifdef insstr
|
| 321 |
+
inline int UNDEF(insstr)(const char *_str) {
|
| 322 |
+
return insstr(_str); }
|
| 323 |
+
#undef insstr
|
| 324 |
+
#define insstr UNDEF(insstr)
|
| 325 |
+
#endif
|
| 326 |
+
|
| 327 |
+
#ifdef instr
|
| 328 |
+
inline int UNDEF(instr)(char *_str) { return instr(_str); }
|
| 329 |
+
#undef instr
|
| 330 |
+
#define instr UNDEF(instr)
|
| 331 |
+
#endif
|
| 332 |
+
|
| 333 |
+
#ifdef intrflush
|
| 334 |
+
inline void UNDEF(intrflush)(WINDOW *win, bool bf) { intrflush(); }
|
| 335 |
+
#undef intrflush
|
| 336 |
+
#define intrflush UNDEF(intrflush)
|
| 337 |
+
#endif
|
| 338 |
+
|
| 339 |
+
#ifdef is_linetouched
|
| 340 |
+
inline int UNDEF(is_linetouched)(WINDOW *w, int l) { return is_linetouched(w,l); }
|
| 341 |
+
#undef is_linetouched
|
| 342 |
+
#define is_linetouched UNDEF(is_linetouched)
|
| 343 |
+
#endif
|
| 344 |
+
|
| 345 |
+
#ifdef leaveok
|
| 346 |
+
inline int UNDEF(leaveok)(WINDOW* win, bool bf) { return leaveok(win, bf); }
|
| 347 |
+
#undef leaveok
|
| 348 |
+
#define leaveok UNDEF(leaveok)
|
| 349 |
+
#else
|
| 350 |
+
extern "C" NCURSES_IMPEXP int NCURSES_API leaveok(WINDOW* win, bool bf);
|
| 351 |
+
#endif
|
| 352 |
+
|
| 353 |
+
#ifdef move
|
| 354 |
+
inline int UNDEF(move)(int x, int y) { return move(x, y); }
|
| 355 |
+
#undef move
|
| 356 |
+
#define move UNDEF(move)
|
| 357 |
+
#endif
|
| 358 |
+
|
| 359 |
+
#ifdef mvaddch
|
| 360 |
+
inline int UNDEF(mvaddch)(int y, int x, chtype ch)
|
| 361 |
+
{ return mvaddch(y, x, ch); }
|
| 362 |
+
#undef mvaddch
|
| 363 |
+
#define mvaddch UNDEF(mvaddch)
|
| 364 |
+
#endif
|
| 365 |
+
|
| 366 |
+
#ifdef mvaddnstr
|
| 367 |
+
inline int UNDEF(mvaddnstr)(int y, int x, const char *str, int n)
|
| 368 |
+
{ return mvaddnstr(y, x, str, n); }
|
| 369 |
+
#undef mvaddnstr
|
| 370 |
+
#define mvaddnstr UNDEF(mvaddnstr)
|
| 371 |
+
#endif
|
| 372 |
+
|
| 373 |
+
#ifdef mvaddstr
|
| 374 |
+
inline int UNDEF(mvaddstr)(int y, int x, const char * str)
|
| 375 |
+
{ return mvaddstr(y, x, str); }
|
| 376 |
+
#undef mvaddstr
|
| 377 |
+
#define mvaddstr UNDEF(mvaddstr)
|
| 378 |
+
#endif
|
| 379 |
+
|
| 380 |
+
#ifdef mvchgat
|
| 381 |
+
inline int UNDEF(mvchgat)(int y, int x, int n,
|
| 382 |
+
attr_t attr, NCURSES_PAIRS_T color, const void *opts) {
|
| 383 |
+
return mvchgat(y, x, n, attr, color, opts); }
|
| 384 |
+
#undef mvchgat
|
| 385 |
+
#define mvchgat UNDEF(mvchgat)
|
| 386 |
+
#endif
|
| 387 |
+
|
| 388 |
+
#ifdef mvdelch
|
| 389 |
+
inline int UNDEF(mvdelch)(int y, int x) { return mvdelch(y, x);}
|
| 390 |
+
#undef mvdelch
|
| 391 |
+
#define mvdelch UNDEF(mvdelch)
|
| 392 |
+
#endif
|
| 393 |
+
|
| 394 |
+
#ifdef mvgetch
|
| 395 |
+
inline int UNDEF(mvgetch)(int y, int x) { return mvgetch(y, x);}
|
| 396 |
+
#undef mvgetch
|
| 397 |
+
#define mvgetch UNDEF(mvgetch)
|
| 398 |
+
#endif
|
| 399 |
+
|
| 400 |
+
#ifdef mvgetnstr
|
| 401 |
+
inline int UNDEF(mvgetnstr)(int y, int x, char *str, int n) {
|
| 402 |
+
return mvgetnstr(y, x, str, n);}
|
| 403 |
+
#undef mvgetnstr
|
| 404 |
+
#define mvgetnstr UNDEF(mvgetnstr)
|
| 405 |
+
#endif
|
| 406 |
+
|
| 407 |
+
#ifdef mvgetstr
|
| 408 |
+
inline int UNDEF(mvgetstr)(int y, int x, char *str) {return mvgetstr(y, x, str);}
|
| 409 |
+
#undef mvgetstr
|
| 410 |
+
#define mvgetstr UNDEF(mvgetstr)
|
| 411 |
+
#endif
|
| 412 |
+
|
| 413 |
+
#ifdef mvinch
|
| 414 |
+
inline chtype UNDEF(mvinch)(int y, int x) { return mvinch(y, x);}
|
| 415 |
+
#undef mvinch
|
| 416 |
+
#define mvinch UNDEF(mvinch)
|
| 417 |
+
#endif
|
| 418 |
+
|
| 419 |
+
#ifdef mvinnstr
|
| 420 |
+
inline int UNDEF(mvinnstr)(int y, int x, char *_str, int n) {
|
| 421 |
+
return mvinnstr(y, x, _str, n); }
|
| 422 |
+
#undef mvinnstr
|
| 423 |
+
#define mvinnstr UNDEF(mvinnstr)
|
| 424 |
+
#endif
|
| 425 |
+
|
| 426 |
+
#ifdef mvinsch
|
| 427 |
+
inline int UNDEF(mvinsch)(int y, int x, chtype c)
|
| 428 |
+
{ return mvinsch(y, x, c); }
|
| 429 |
+
#undef mvinsch
|
| 430 |
+
#define mvinsch UNDEF(mvinsch)
|
| 431 |
+
#endif
|
| 432 |
+
|
| 433 |
+
#ifdef mvinsnstr
|
| 434 |
+
inline int UNDEF(mvinsnstr)(int y, int x, const char *_str, int n) {
|
| 435 |
+
return mvinsnstr(y, x, _str, n); }
|
| 436 |
+
#undef mvinsnstr
|
| 437 |
+
#define mvinsnstr UNDEF(mvinsnstr)
|
| 438 |
+
#endif
|
| 439 |
+
|
| 440 |
+
#ifdef mvinsstr
|
| 441 |
+
inline int UNDEF(mvinsstr)(int y, int x, const char *_str) {
|
| 442 |
+
return mvinsstr(y, x, _str); }
|
| 443 |
+
#undef mvinsstr
|
| 444 |
+
#define mvinsstr UNDEF(mvinsstr)
|
| 445 |
+
#endif
|
| 446 |
+
|
| 447 |
+
#ifdef mvwaddch
|
| 448 |
+
inline int UNDEF(mvwaddch)(WINDOW *win, int y, int x, const chtype ch)
|
| 449 |
+
{ return mvwaddch(win, y, x, ch); }
|
| 450 |
+
#undef mvwaddch
|
| 451 |
+
#define mvwaddch UNDEF(mvwaddch)
|
| 452 |
+
#endif
|
| 453 |
+
|
| 454 |
+
#ifdef mvwaddchnstr
|
| 455 |
+
inline int UNDEF(mvwaddchnstr)(WINDOW *win, int y, int x, const chtype *str, int n)
|
| 456 |
+
{ return mvwaddchnstr(win, y, x, str, n); }
|
| 457 |
+
#undef mvwaddchnstr
|
| 458 |
+
#define mvwaddchnstr UNDEF(mvwaddchnstr)
|
| 459 |
+
#endif
|
| 460 |
+
|
| 461 |
+
#ifdef mvwaddchstr
|
| 462 |
+
inline int UNDEF(mvwaddchstr)(WINDOW *win, int y, int x, const chtype *str)
|
| 463 |
+
{ return mvwaddchstr(win, y, x, str); }
|
| 464 |
+
#undef mvwaddchstr
|
| 465 |
+
#define mvwaddchstr UNDEF(mvwaddchstr)
|
| 466 |
+
#endif
|
| 467 |
+
|
| 468 |
+
#ifdef mvwaddnstr
|
| 469 |
+
inline int UNDEF(mvwaddnstr)(WINDOW *win, int y, int x, const char *str, int n)
|
| 470 |
+
{ return mvwaddnstr(win, y, x, str, n); }
|
| 471 |
+
#undef mvwaddnstr
|
| 472 |
+
#define mvwaddnstr UNDEF(mvwaddnstr)
|
| 473 |
+
#endif
|
| 474 |
+
|
| 475 |
+
#ifdef mvwaddstr
|
| 476 |
+
inline int UNDEF(mvwaddstr)(WINDOW *win, int y, int x, const char * str)
|
| 477 |
+
{ return mvwaddstr(win, y, x, str); }
|
| 478 |
+
#undef mvwaddstr
|
| 479 |
+
#define mvwaddstr UNDEF(mvwaddstr)
|
| 480 |
+
#endif
|
| 481 |
+
|
| 482 |
+
#ifdef mvwchgat
|
| 483 |
+
inline int UNDEF(mvwchgat)(WINDOW *win, int y, int x, int n,
|
| 484 |
+
attr_t attr, NCURSES_PAIRS_T color, const void *opts) {
|
| 485 |
+
return mvwchgat(win, y, x, n, attr, color, opts); }
|
| 486 |
+
#undef mvwchgat
|
| 487 |
+
#define mvwchgat UNDEF(mvwchgat)
|
| 488 |
+
#endif
|
| 489 |
+
|
| 490 |
+
#ifdef mvwdelch
|
| 491 |
+
inline int UNDEF(mvwdelch)(WINDOW *win, int y, int x)
|
| 492 |
+
{ return mvwdelch(win, y, x); }
|
| 493 |
+
#undef mvwdelch
|
| 494 |
+
#define mvwdelch UNDEF(mvwdelch)
|
| 495 |
+
#endif
|
| 496 |
+
|
| 497 |
+
#ifdef mvwgetch
|
| 498 |
+
inline int UNDEF(mvwgetch)(WINDOW *win, int y, int x) { return mvwgetch(win, y, x);}
|
| 499 |
+
#undef mvwgetch
|
| 500 |
+
#define mvwgetch UNDEF(mvwgetch)
|
| 501 |
+
#endif
|
| 502 |
+
|
| 503 |
+
#ifdef mvwgetnstr
|
| 504 |
+
inline int UNDEF(mvwgetnstr)(WINDOW *win, int y, int x, char *str, int n)
|
| 505 |
+
{return mvwgetnstr(win, y, x, str, n);}
|
| 506 |
+
#undef mvwgetnstr
|
| 507 |
+
#define mvwgetnstr UNDEF(mvwgetnstr)
|
| 508 |
+
#endif
|
| 509 |
+
|
| 510 |
+
#ifdef mvwgetstr
|
| 511 |
+
inline int UNDEF(mvwgetstr)(WINDOW *win, int y, int x, char *str)
|
| 512 |
+
{return mvwgetstr(win, y, x, str);}
|
| 513 |
+
#undef mvwgetstr
|
| 514 |
+
#define mvwgetstr UNDEF(mvwgetstr)
|
| 515 |
+
#endif
|
| 516 |
+
|
| 517 |
+
#ifdef mvwhline
|
| 518 |
+
inline int UNDEF(mvwhline)(WINDOW *win, int y, int x, chtype c, int n) {
|
| 519 |
+
return mvwhline(win, y, x, c, n); }
|
| 520 |
+
#undef mvwhline
|
| 521 |
+
#define mvwhline UNDEF(mvwhline)
|
| 522 |
+
#endif
|
| 523 |
+
|
| 524 |
+
#ifdef mvwinch
|
| 525 |
+
inline chtype UNDEF(mvwinch)(WINDOW *win, int y, int x) {
|
| 526 |
+
return mvwinch(win, y, x);}
|
| 527 |
+
#undef mvwinch
|
| 528 |
+
#define mvwinch UNDEF(mvwinch)
|
| 529 |
+
#endif
|
| 530 |
+
|
| 531 |
+
#ifdef mvwinchnstr
|
| 532 |
+
inline int UNDEF(mvwinchnstr)(WINDOW *win, int y, int x, chtype *str, int n) { return mvwinchnstr(win, y, x, str, n); }
|
| 533 |
+
#undef mvwinchnstr
|
| 534 |
+
#define mvwinchnstr UNDEF(mvwinchnstr)
|
| 535 |
+
#endif
|
| 536 |
+
|
| 537 |
+
#ifdef mvwinchstr
|
| 538 |
+
inline int UNDEF(mvwinchstr)(WINDOW *win, int y, int x, chtype *str) { return mvwinchstr(win, y, x, str); }
|
| 539 |
+
#undef mvwinchstr
|
| 540 |
+
#define mvwinchstr UNDEF(mvwinchstr)
|
| 541 |
+
#endif
|
| 542 |
+
|
| 543 |
+
#ifdef mvwinnstr
|
| 544 |
+
inline int UNDEF(mvwinnstr)(WINDOW *win, int y, int x, char *_str, int n) {
|
| 545 |
+
return mvwinnstr(win, y, x, _str, n); }
|
| 546 |
+
#undef mvwinnstr
|
| 547 |
+
#define mvwinnstr UNDEF(mvwinnstr)
|
| 548 |
+
#endif
|
| 549 |
+
|
| 550 |
+
#ifdef mvwinsch
|
| 551 |
+
inline int UNDEF(mvwinsch)(WINDOW *win, int y, int x, chtype c)
|
| 552 |
+
{ return mvwinsch(win, y, x, c); }
|
| 553 |
+
#undef mvwinsch
|
| 554 |
+
#define mvwinsch UNDEF(mvwinsch)
|
| 555 |
+
#endif
|
| 556 |
+
|
| 557 |
+
#ifdef mvwinsnstr
|
| 558 |
+
inline int UNDEF(mvwinsnstr)(WINDOW *w, int y, int x, const char *_str, int n) {
|
| 559 |
+
return mvwinsnstr(w, y, x, _str, n); }
|
| 560 |
+
#undef mvwinsnstr
|
| 561 |
+
#define mvwinsnstr UNDEF(mvwinsnstr)
|
| 562 |
+
#endif
|
| 563 |
+
|
| 564 |
+
#ifdef mvwinsstr
|
| 565 |
+
inline int UNDEF(mvwinsstr)(WINDOW *w, int y, int x, const char *_str) {
|
| 566 |
+
return mvwinsstr(w, y, x, _str); }
|
| 567 |
+
#undef mvwinsstr
|
| 568 |
+
#define mvwinsstr UNDEF(mvwinsstr)
|
| 569 |
+
#endif
|
| 570 |
+
|
| 571 |
+
#ifdef mvwvline
|
| 572 |
+
inline int UNDEF(mvwvline)(WINDOW *win, int y, int x, chtype c, int n) {
|
| 573 |
+
return mvwvline(win, y, x, c, n); }
|
| 574 |
+
#undef mvwvline
|
| 575 |
+
#define mvwvline UNDEF(mvwvline)
|
| 576 |
+
#endif
|
| 577 |
+
|
| 578 |
+
#ifdef napms
|
| 579 |
+
inline void UNDEF(napms)(unsigned long x) { napms(x); }
|
| 580 |
+
#undef napms
|
| 581 |
+
#define napms UNDEF(napms)
|
| 582 |
+
#endif
|
| 583 |
+
|
| 584 |
+
#ifdef nocrmode
|
| 585 |
+
inline int UNDEF(nocrmode)(void) { return nocrmode(); }
|
| 586 |
+
#undef nocrmode
|
| 587 |
+
#define nocrmode UNDEF(nocrmode)
|
| 588 |
+
#endif
|
| 589 |
+
|
| 590 |
+
#ifdef nodelay
|
| 591 |
+
inline void UNDEF(nodelay)() { nodelay(); }
|
| 592 |
+
#undef nodelay
|
| 593 |
+
#define nodelay UNDEF(nodelay)
|
| 594 |
+
#endif
|
| 595 |
+
|
| 596 |
+
#ifdef redrawwin
|
| 597 |
+
inline int UNDEF(redrawwin)(WINDOW *win) { return redrawwin(win); }
|
| 598 |
+
#undef redrawwin
|
| 599 |
+
#define redrawwin UNDEF(redrawwin)
|
| 600 |
+
#endif
|
| 601 |
+
|
| 602 |
+
#ifdef refresh
|
| 603 |
+
inline int UNDEF(refresh)() { return refresh(); }
|
| 604 |
+
#undef refresh
|
| 605 |
+
#define refresh UNDEF(refresh)
|
| 606 |
+
#endif
|
| 607 |
+
|
| 608 |
+
#ifdef resetterm
|
| 609 |
+
inline int UNDEF(resetterm)(void) { return resetterm(); }
|
| 610 |
+
#undef resetterm
|
| 611 |
+
#define resetterm UNDEF(resetterm)
|
| 612 |
+
#endif
|
| 613 |
+
|
| 614 |
+
#ifdef saveterm
|
| 615 |
+
inline int UNDEF(saveterm)(void) { return saveterm(); }
|
| 616 |
+
#undef saveterm
|
| 617 |
+
#define saveterm UNDEF(saveterm)
|
| 618 |
+
#endif
|
| 619 |
+
|
| 620 |
+
#ifdef scrl
|
| 621 |
+
inline int UNDEF(scrl)(int l) { return scrl(l); }
|
| 622 |
+
#undef scrl
|
| 623 |
+
#define scrl UNDEF(scrl)
|
| 624 |
+
#endif
|
| 625 |
+
|
| 626 |
+
#ifdef scroll
|
| 627 |
+
inline int UNDEF(scroll)(WINDOW *win) { return scroll(win); }
|
| 628 |
+
#undef scroll
|
| 629 |
+
#define scroll UNDEF(scroll)
|
| 630 |
+
#endif
|
| 631 |
+
|
| 632 |
+
#ifdef scrollok
|
| 633 |
+
inline int UNDEF(scrollok)(WINDOW* win, bool bf) { return scrollok(win, bf); }
|
| 634 |
+
#undef scrollok
|
| 635 |
+
#define scrollok UNDEF(scrollok)
|
| 636 |
+
#else
|
| 637 |
+
#if defined(__NCURSES_H)
|
| 638 |
+
extern "C" NCURSES_IMPEXP int NCURSES_API scrollok(WINDOW*, bool);
|
| 639 |
+
#else
|
| 640 |
+
extern "C" NCURSES_IMPEXP int NCURSES_API scrollok(WINDOW*, char);
|
| 641 |
+
#endif
|
| 642 |
+
#endif
|
| 643 |
+
|
| 644 |
+
#ifdef setscrreg
|
| 645 |
+
inline int UNDEF(setscrreg)(int t, int b) { return setscrreg(t, b); }
|
| 646 |
+
#undef setscrreg
|
| 647 |
+
#define setscrreg UNDEF(setscrreg)
|
| 648 |
+
#endif
|
| 649 |
+
|
| 650 |
+
#ifdef standend
|
| 651 |
+
inline int UNDEF(standend)() { return standend(); }
|
| 652 |
+
#undef standend
|
| 653 |
+
#define standend UNDEF(standend)
|
| 654 |
+
#endif
|
| 655 |
+
|
| 656 |
+
#ifdef standout
|
| 657 |
+
inline int UNDEF(standout)() { return standout(); }
|
| 658 |
+
#undef standout
|
| 659 |
+
#define standout UNDEF(standout)
|
| 660 |
+
#endif
|
| 661 |
+
|
| 662 |
+
#ifdef subpad
|
| 663 |
+
inline WINDOW *UNDEF(subpad)(WINDOW *p, int l, int c, int y, int x)
|
| 664 |
+
{ return derwin(p, l, c, y, x); }
|
| 665 |
+
#undef subpad
|
| 666 |
+
#define subpad UNDEF(subpad)
|
| 667 |
+
#endif
|
| 668 |
+
|
| 669 |
+
#ifdef timeout
|
| 670 |
+
inline void UNDEF(timeout)(int delay) { timeout(delay); }
|
| 671 |
+
#undef timeout
|
| 672 |
+
#define timeout UNDEF(timeout)
|
| 673 |
+
#endif
|
| 674 |
+
|
| 675 |
+
#ifdef touchline
|
| 676 |
+
inline int UNDEF(touchline)(WINDOW *win, int s, int c)
|
| 677 |
+
{ return touchline(win, s, c); }
|
| 678 |
+
#undef touchline
|
| 679 |
+
#define touchline UNDEF(touchline)
|
| 680 |
+
#endif
|
| 681 |
+
|
| 682 |
+
#ifdef touchwin
|
| 683 |
+
inline int UNDEF(touchwin)(WINDOW *win) { return touchwin(win); }
|
| 684 |
+
#undef touchwin
|
| 685 |
+
#define touchwin UNDEF(touchwin)
|
| 686 |
+
#endif
|
| 687 |
+
|
| 688 |
+
#ifdef untouchwin
|
| 689 |
+
inline int UNDEF(untouchwin)(WINDOW *win) { return untouchwin(win); }
|
| 690 |
+
#undef untouchwin
|
| 691 |
+
#define untouchwin UNDEF(untouchwin)
|
| 692 |
+
#endif
|
| 693 |
+
|
| 694 |
+
#ifdef vline
|
| 695 |
+
inline int UNDEF(vline)(chtype ch, int n) { return vline(ch, n); }
|
| 696 |
+
#undef vline
|
| 697 |
+
#define vline UNDEF(vline)
|
| 698 |
+
#endif
|
| 699 |
+
|
| 700 |
+
#ifdef waddchstr
|
| 701 |
+
inline int UNDEF(waddchstr)(WINDOW *win, chtype *at) { return waddchstr(win, at); }
|
| 702 |
+
#undef waddchstr
|
| 703 |
+
#define waddchstr UNDEF(waddchstr)
|
| 704 |
+
#endif
|
| 705 |
+
|
| 706 |
+
#ifdef waddstr
|
| 707 |
+
inline int UNDEF(waddstr)(WINDOW *win, char *str) { return waddstr(win, str); }
|
| 708 |
+
#undef waddstr
|
| 709 |
+
#define waddstr UNDEF(waddstr)
|
| 710 |
+
#endif
|
| 711 |
+
|
| 712 |
+
#ifdef wattroff
|
| 713 |
+
inline int UNDEF(wattroff)(WINDOW *win, int att) { return wattroff(win, att); }
|
| 714 |
+
#undef wattroff
|
| 715 |
+
#define wattroff UNDEF(wattroff)
|
| 716 |
+
#endif
|
| 717 |
+
|
| 718 |
+
#ifdef wattrset
|
| 719 |
+
inline int UNDEF(wattrset)(WINDOW *win, int att) { return wattrset(win, att); }
|
| 720 |
+
#undef wattrset
|
| 721 |
+
#define wattrset UNDEF(wattrset)
|
| 722 |
+
#endif
|
| 723 |
+
|
| 724 |
+
#ifdef winch
|
| 725 |
+
inline chtype UNDEF(winch)(const WINDOW* win) { return winch(win); }
|
| 726 |
+
#undef winch
|
| 727 |
+
#define winch UNDEF(winch)
|
| 728 |
+
#endif
|
| 729 |
+
|
| 730 |
+
#ifdef winchnstr
|
| 731 |
+
inline int UNDEF(winchnstr)(WINDOW *win, chtype *str, int n) { return winchnstr(win, str, n); }
|
| 732 |
+
#undef winchnstr
|
| 733 |
+
#define winchnstr UNDEF(winchnstr)
|
| 734 |
+
#endif
|
| 735 |
+
|
| 736 |
+
#ifdef winchstr
|
| 737 |
+
inline int UNDEF(winchstr)(WINDOW *win, chtype *str) { return winchstr(win, str); }
|
| 738 |
+
#undef winchstr
|
| 739 |
+
#define winchstr UNDEF(winchstr)
|
| 740 |
+
#endif
|
| 741 |
+
|
| 742 |
+
#ifdef winsstr
|
| 743 |
+
inline int UNDEF(winsstr)(WINDOW *w, const char *_str) {
|
| 744 |
+
return winsstr(w, _str); }
|
| 745 |
+
#undef winsstr
|
| 746 |
+
#define winsstr UNDEF(winsstr)
|
| 747 |
+
#endif
|
| 748 |
+
|
| 749 |
+
#ifdef wstandend
|
| 750 |
+
inline int UNDEF(wstandend)(WINDOW *win) { return wstandend(win); }
|
| 751 |
+
#undef wstandend
|
| 752 |
+
#define wstandend UNDEF(wstandend)
|
| 753 |
+
#endif
|
| 754 |
+
|
| 755 |
+
#ifdef wstandout
|
| 756 |
+
inline int UNDEF(wstandout)(WINDOW *win) { return wstandout(win); }
|
| 757 |
+
#undef wstandout
|
| 758 |
+
#define wstandout UNDEF(wstandout)
|
| 759 |
+
#endif
|
| 760 |
+
|
| 761 |
+
/*
|
| 762 |
+
*
|
| 763 |
+
* C++ class for windows.
|
| 764 |
+
*
|
| 765 |
+
*/
|
| 766 |
+
|
| 767 |
+
extern "C" int _nc_ripoffline(int, int (*init)(WINDOW*, int));
|
| 768 |
+
extern "C" int _nc_xx_ripoff_init(WINDOW *, int);
|
| 769 |
+
extern "C" int _nc_has_mouse(void);
|
| 770 |
+
|
| 771 |
+
class NCURSES_CXX_IMPEXP NCursesWindow
|
| 772 |
+
{
|
| 773 |
+
friend class NCursesMenu;
|
| 774 |
+
friend class NCursesForm;
|
| 775 |
+
|
| 776 |
+
private:
|
| 777 |
+
static bool b_initialized;
|
| 778 |
+
static void initialize();
|
| 779 |
+
void constructing();
|
| 780 |
+
friend int _nc_xx_ripoff_init(WINDOW *, int);
|
| 781 |
+
|
| 782 |
+
void set_keyboard();
|
| 783 |
+
|
| 784 |
+
NCURSES_COLOR_T getcolor(int getback) const;
|
| 785 |
+
NCURSES_PAIRS_T getPair() const;
|
| 786 |
+
|
| 787 |
+
static int setpalette(NCURSES_COLOR_T fore, NCURSES_COLOR_T back, NCURSES_PAIRS_T pair);
|
| 788 |
+
static int colorInitialized;
|
| 789 |
+
|
| 790 |
+
// This private constructor is only used during the initialization
|
| 791 |
+
// of windows generated by ripoffline() calls.
|
| 792 |
+
NCursesWindow(WINDOW* win, int ncols);
|
| 793 |
+
|
| 794 |
+
protected:
|
| 795 |
+
virtual void err_handler(const char *) const THROWS(NCursesException);
|
| 796 |
+
// Signal an error with the given message text.
|
| 797 |
+
|
| 798 |
+
static long count; // count of all active windows:
|
| 799 |
+
// We rely on the c++ promise that
|
| 800 |
+
// all otherwise uninitialized
|
| 801 |
+
// static class vars are set to 0
|
| 802 |
+
|
| 803 |
+
WINDOW* w; // the curses WINDOW
|
| 804 |
+
|
| 805 |
+
bool alloced; // TRUE if we own the WINDOW
|
| 806 |
+
|
| 807 |
+
NCursesWindow* par; // parent, if subwindow
|
| 808 |
+
NCursesWindow* subwins; // head of subwindows list
|
| 809 |
+
NCursesWindow* sib; // next subwindow of parent
|
| 810 |
+
|
| 811 |
+
void kill_subwindows(); // disable all subwindows
|
| 812 |
+
// Destroy all subwindows.
|
| 813 |
+
|
| 814 |
+
/* Only for use by derived classes. They are then in charge to
|
| 815 |
+
fill the member variables correctly. */
|
| 816 |
+
NCursesWindow();
|
| 817 |
+
|
| 818 |
+
public:
|
| 819 |
+
explicit NCursesWindow(WINDOW* window); // useful only for stdscr
|
| 820 |
+
|
| 821 |
+
NCursesWindow(int nlines, // number of lines
|
| 822 |
+
int ncols, // number of columns
|
| 823 |
+
int begin_y, // line origin
|
| 824 |
+
int begin_x); // col origin
|
| 825 |
+
|
| 826 |
+
NCursesWindow(NCursesWindow& par,// parent window
|
| 827 |
+
int nlines, // number of lines
|
| 828 |
+
int ncols, // number of columns
|
| 829 |
+
int begin_y, // absolute or relative
|
| 830 |
+
int begin_x, // origins:
|
| 831 |
+
char absrel = 'a');// if `a', begin_y & begin_x are
|
| 832 |
+
// absolute screen pos, else if `r', they are relative to par origin
|
| 833 |
+
|
| 834 |
+
NCursesWindow(NCursesWindow& par,// parent window
|
| 835 |
+
bool do_box = TRUE);
|
| 836 |
+
// this is the very common case that we want to create the subwindow that
|
| 837 |
+
// is two lines and two columns smaller and begins at (1,1).
|
| 838 |
+
// We may automatically request the box around it.
|
| 839 |
+
|
| 840 |
+
NCursesWindow& operator=(const NCursesWindow& rhs)
|
| 841 |
+
{
|
| 842 |
+
if (this != &rhs)
|
| 843 |
+
*this = rhs;
|
| 844 |
+
return *this;
|
| 845 |
+
}
|
| 846 |
+
|
| 847 |
+
NCursesWindow(const NCursesWindow& rhs)
|
| 848 |
+
: w(rhs.w), alloced(rhs.alloced), par(rhs.par), subwins(rhs.subwins), sib(rhs.sib)
|
| 849 |
+
{
|
| 850 |
+
}
|
| 851 |
+
|
| 852 |
+
virtual ~NCursesWindow() THROWS(NCursesException);
|
| 853 |
+
|
| 854 |
+
NCursesWindow Clone();
|
| 855 |
+
// Make an exact copy of the window.
|
| 856 |
+
|
| 857 |
+
// Initialization.
|
| 858 |
+
static void useColors(void);
|
| 859 |
+
// Call this routine very early if you want to have colors.
|
| 860 |
+
|
| 861 |
+
static int ripoffline(int ripoff_lines,
|
| 862 |
+
int (*init)(NCursesWindow& win));
|
| 863 |
+
// This function is used to generate a window of ripped-of lines.
|
| 864 |
+
// If the argument is positive, lines are removed from the top, if it
|
| 865 |
+
// is negative lines are removed from the bottom. This enhances the
|
| 866 |
+
// lowlevel ripoffline() function because it uses the internal
|
| 867 |
+
// implementation that allows to remove more than just a single line.
|
| 868 |
+
// This function must be called before any other ncurses function. The
|
| 869 |
+
// creation of the window is deferred until ncurses gets initialized.
|
| 870 |
+
// The initialization function is then called.
|
| 871 |
+
|
| 872 |
+
// -------------------------------------------------------------------------
|
| 873 |
+
// terminal status
|
| 874 |
+
// -------------------------------------------------------------------------
|
| 875 |
+
int lines() const { initialize(); return LINES; }
|
| 876 |
+
// Number of lines on terminal, *not* window
|
| 877 |
+
|
| 878 |
+
int cols() const { initialize(); return COLS; }
|
| 879 |
+
// Number of cols on terminal, *not* window
|
| 880 |
+
|
| 881 |
+
int tabsize() const { initialize(); return TABSIZE; }
|
| 882 |
+
// Size of a tab on terminal, *not* window
|
| 883 |
+
|
| 884 |
+
static int NumberOfColors();
|
| 885 |
+
// Number of available colors
|
| 886 |
+
|
| 887 |
+
int colors() const { return NumberOfColors(); }
|
| 888 |
+
// Number of available colors
|
| 889 |
+
|
| 890 |
+
// -------------------------------------------------------------------------
|
| 891 |
+
// window status
|
| 892 |
+
// -------------------------------------------------------------------------
|
| 893 |
+
int height() const { return maxy() + 1; }
|
| 894 |
+
// Number of lines in this window
|
| 895 |
+
|
| 896 |
+
int width() const { return maxx() + 1; }
|
| 897 |
+
// Number of columns in this window
|
| 898 |
+
|
| 899 |
+
int begx() const { return getbegx(w); }
|
| 900 |
+
// Column of top left corner relative to stdscr
|
| 901 |
+
|
| 902 |
+
int begy() const { return getbegy(w); }
|
| 903 |
+
// Line of top left corner relative to stdscr
|
| 904 |
+
|
| 905 |
+
int curx() const { return getcurx(w); }
|
| 906 |
+
// Column of top left corner relative to stdscr
|
| 907 |
+
|
| 908 |
+
int cury() const { return getcury(w); }
|
| 909 |
+
// Line of top left corner relative to stdscr
|
| 910 |
+
|
| 911 |
+
int maxx() const { return getmaxx(w) == ERR ? ERR : getmaxx(w)-1; }
|
| 912 |
+
// Largest x coord in window
|
| 913 |
+
|
| 914 |
+
int maxy() const { return getmaxy(w) == ERR ? ERR : getmaxy(w)-1; }
|
| 915 |
+
// Largest y coord in window
|
| 916 |
+
|
| 917 |
+
NCURSES_PAIRS_T getcolor() const;
|
| 918 |
+
// Actual color pair
|
| 919 |
+
|
| 920 |
+
NCURSES_COLOR_T foreground() const { return getcolor(0); }
|
| 921 |
+
// Actual foreground color
|
| 922 |
+
|
| 923 |
+
NCURSES_COLOR_T background() const { return getcolor(1); }
|
| 924 |
+
// Actual background color
|
| 925 |
+
|
| 926 |
+
int setpalette(NCURSES_COLOR_T fore, NCURSES_COLOR_T back);
|
| 927 |
+
// Set color palette entry
|
| 928 |
+
|
| 929 |
+
int setcolor(NCURSES_PAIRS_T pair);
|
| 930 |
+
// Set actually used palette entry
|
| 931 |
+
|
| 932 |
+
// -------------------------------------------------------------------------
|
| 933 |
+
// window positioning
|
| 934 |
+
// -------------------------------------------------------------------------
|
| 935 |
+
virtual int mvwin(int begin_y, int begin_x) {
|
| 936 |
+
return ::mvwin(w, begin_y, begin_x); }
|
| 937 |
+
// Move window to new position with the new position as top left corner.
|
| 938 |
+
// This is virtual because it is redefined in NCursesPanel.
|
| 939 |
+
|
| 940 |
+
// -------------------------------------------------------------------------
|
| 941 |
+
// coordinate positioning
|
| 942 |
+
// -------------------------------------------------------------------------
|
| 943 |
+
int move(int y, int x) { return ::wmove(w, y, x); }
|
| 944 |
+
// Move cursor the this position
|
| 945 |
+
|
| 946 |
+
void getyx(int& y, int& x) const { ::getyx(w, y, x); }
|
| 947 |
+
// Get current position of the cursor
|
| 948 |
+
|
| 949 |
+
void getbegyx(int& y, int& x) const { ::getbegyx(w, y, x); }
|
| 950 |
+
// Get beginning of the window
|
| 951 |
+
|
| 952 |
+
void getmaxyx(int& y, int& x) const { ::getmaxyx(w, y, x); }
|
| 953 |
+
// Get size of the window
|
| 954 |
+
|
| 955 |
+
void getparyx(int& y, int& x) const { ::getparyx(w, y, x); }
|
| 956 |
+
// Get parent's beginning of the window
|
| 957 |
+
|
| 958 |
+
int mvcur(int oldrow, int oldcol, int newrow, int newcol) const {
|
| 959 |
+
return ::mvcur(oldrow, oldcol, newrow, newcol); }
|
| 960 |
+
// Perform lowlevel cursor motion that takes effect immediately.
|
| 961 |
+
|
| 962 |
+
// -------------------------------------------------------------------------
|
| 963 |
+
// input
|
| 964 |
+
// -------------------------------------------------------------------------
|
| 965 |
+
int getch() { return ::wgetch(w); }
|
| 966 |
+
// Get a keystroke from the window.
|
| 967 |
+
|
| 968 |
+
int getch(int y, int x) { return ::mvwgetch(w, y, x); }
|
| 969 |
+
// Move cursor to position and get a keystroke from the window
|
| 970 |
+
|
| 971 |
+
int getstr(char* str, int n=-1) {
|
| 972 |
+
return ::wgetnstr(w, str, n); }
|
| 973 |
+
// Read a series of characters into str until a newline or carriage return
|
| 974 |
+
// is received. Read at most n characters. If n is negative, the limit is
|
| 975 |
+
// ignored.
|
| 976 |
+
|
| 977 |
+
int getstr(int y, int x, char* str, int n=-1) {
|
| 978 |
+
return ::mvwgetnstr(w, y, x, str, n); }
|
| 979 |
+
// Move the cursor to the requested position and then perform the getstr()
|
| 980 |
+
// as described above.
|
| 981 |
+
|
| 982 |
+
int instr(char *s, int n=-1) { return ::winnstr(w, s, n); }
|
| 983 |
+
// Get a string of characters from the window into the buffer s. Retrieve
|
| 984 |
+
// at most n characters, if n is negative retrieve all characters up to the
|
| 985 |
+
// end of the current line. Attributes are stripped from the characters.
|
| 986 |
+
|
| 987 |
+
int instr(int y, int x, char *s, int n=-1) {
|
| 988 |
+
return ::mvwinnstr(w, y, x, s, n); }
|
| 989 |
+
// Move the cursor to the requested position and then perform the instr()
|
| 990 |
+
// as described above.
|
| 991 |
+
|
| 992 |
+
int scanw(const char* fmt, ...)
|
| 993 |
+
// Perform a scanw function from the window.
|
| 994 |
+
#if __GNUG__ >= 2
|
| 995 |
+
__attribute__ ((format (scanf, 2, 3)));
|
| 996 |
+
#else
|
| 997 |
+
;
|
| 998 |
+
#endif
|
| 999 |
+
|
| 1000 |
+
int scanw(const char*, va_list);
|
| 1001 |
+
// Perform a scanw function from the window.
|
| 1002 |
+
|
| 1003 |
+
int scanw(int y, int x, const char* fmt, ...)
|
| 1004 |
+
// Move the cursor to the requested position and then perform a scanw
|
| 1005 |
+
// from the window.
|
| 1006 |
+
#if __GNUG__ >= 2
|
| 1007 |
+
__attribute__ ((format (scanf, 4, 5)));
|
| 1008 |
+
#else
|
| 1009 |
+
;
|
| 1010 |
+
#endif
|
| 1011 |
+
|
| 1012 |
+
int scanw(int y, int x, const char* fmt, va_list);
|
| 1013 |
+
// Move the cursor to the requested position and then perform a scanw
|
| 1014 |
+
// from the window.
|
| 1015 |
+
|
| 1016 |
+
// -------------------------------------------------------------------------
|
| 1017 |
+
// output
|
| 1018 |
+
// -------------------------------------------------------------------------
|
| 1019 |
+
int addch(const chtype ch) { return ::waddch(w, ch); }
|
| 1020 |
+
// Put attributed character to the window.
|
| 1021 |
+
|
| 1022 |
+
int addch(int y, int x, const chtype ch) {
|
| 1023 |
+
return ::mvwaddch(w, y, x, ch); }
|
| 1024 |
+
// Move cursor to the requested position and then put attributed character
|
| 1025 |
+
// to the window.
|
| 1026 |
+
|
| 1027 |
+
int echochar(const chtype ch) { return ::wechochar(w, ch); }
|
| 1028 |
+
// Put attributed character to the window and refresh it immediately.
|
| 1029 |
+
|
| 1030 |
+
int addstr(const char* str, int n=-1) {
|
| 1031 |
+
return ::waddnstr(w, str, n); }
|
| 1032 |
+
// Write the string str to the window, stop writing if the terminating
|
| 1033 |
+
// NUL or the limit n is reached. If n is negative, it is ignored.
|
| 1034 |
+
|
| 1035 |
+
int addstr(int y, int x, const char * str, int n=-1) {
|
| 1036 |
+
return ::mvwaddnstr(w, y, x, str, n); }
|
| 1037 |
+
// Move the cursor to the requested position and then perform the addchstr
|
| 1038 |
+
// as described above.
|
| 1039 |
+
|
| 1040 |
+
int addchstr(const chtype* str, int n=-1) {
|
| 1041 |
+
return ::waddchnstr(w, str, n); }
|
| 1042 |
+
// Write the string str to the window, stop writing if the terminating
|
| 1043 |
+
// NUL or the limit n is reached. If n is negative, it is ignored.
|
| 1044 |
+
|
| 1045 |
+
int addchstr(int y, int x, const chtype * str, int n=-1) {
|
| 1046 |
+
return ::mvwaddchnstr(w, y, x, str, n); }
|
| 1047 |
+
// Move the cursor to the requested position and then perform the addchstr
|
| 1048 |
+
// as described above.
|
| 1049 |
+
|
| 1050 |
+
int printw(const char* fmt, ...)
|
| 1051 |
+
// Do a formatted print to the window.
|
| 1052 |
+
#if (__GNUG__ >= 2) && !defined(printf)
|
| 1053 |
+
__attribute__ ((format (printf, 2, 3)));
|
| 1054 |
+
#else
|
| 1055 |
+
;
|
| 1056 |
+
#endif
|
| 1057 |
+
|
| 1058 |
+
int printw(int y, int x, const char * fmt, ...)
|
| 1059 |
+
// Move the cursor and then do a formatted print to the window.
|
| 1060 |
+
#if (__GNUG__ >= 2) && !defined(printf)
|
| 1061 |
+
__attribute__ ((format (printf, 4, 5)));
|
| 1062 |
+
#else
|
| 1063 |
+
;
|
| 1064 |
+
#endif
|
| 1065 |
+
|
| 1066 |
+
int printw(const char* fmt, va_list args);
|
| 1067 |
+
// Do a formatted print to the window.
|
| 1068 |
+
|
| 1069 |
+
int printw(int y, int x, const char * fmt, va_list args);
|
| 1070 |
+
// Move the cursor and then do a formatted print to the window.
|
| 1071 |
+
|
| 1072 |
+
chtype inch() const { return ::winch(w); }
|
| 1073 |
+
// Retrieve attributed character under the current cursor position.
|
| 1074 |
+
|
| 1075 |
+
chtype inch(int y, int x) { return ::mvwinch(w, y, x); }
|
| 1076 |
+
// Move cursor to requested position and then retrieve attributed character
|
| 1077 |
+
// at this position.
|
| 1078 |
+
|
| 1079 |
+
int inchstr(chtype* str, int n=-1) {
|
| 1080 |
+
return ::winchnstr(w, str, n); }
|
| 1081 |
+
// Read the string str from the window, stop reading if the terminating
|
| 1082 |
+
// NUL or the limit n is reached. If n is negative, it is ignored.
|
| 1083 |
+
|
| 1084 |
+
int inchstr(int y, int x, chtype * str, int n=-1) {
|
| 1085 |
+
return ::mvwinchnstr(w, y, x, str, n); }
|
| 1086 |
+
// Move the cursor to the requested position and then perform the inchstr
|
| 1087 |
+
// as described above.
|
| 1088 |
+
|
| 1089 |
+
int insch(chtype ch) { return ::winsch(w, ch); }
|
| 1090 |
+
// Insert attributed character into the window before current cursor
|
| 1091 |
+
// position.
|
| 1092 |
+
|
| 1093 |
+
int insch(int y, int x, chtype ch) {
|
| 1094 |
+
return ::mvwinsch(w, y, x, ch); }
|
| 1095 |
+
// Move cursor to requested position and then insert the attributed
|
| 1096 |
+
// character before that position.
|
| 1097 |
+
|
| 1098 |
+
int insertln() { return ::winsdelln(w, 1); }
|
| 1099 |
+
// Insert an empty line above the current line.
|
| 1100 |
+
|
| 1101 |
+
int insdelln(int n=1) { return ::winsdelln(w, n); }
|
| 1102 |
+
// If n>0 insert that many lines above the current line. If n<0 delete
|
| 1103 |
+
// that many lines beginning with the current line.
|
| 1104 |
+
|
| 1105 |
+
int insstr(const char *s, int n=-1) {
|
| 1106 |
+
return ::winsnstr(w, s, n); }
|
| 1107 |
+
// Insert the string into the window before the current cursor position.
|
| 1108 |
+
// Insert stops at end of string or when the limit n is reached. If n is
|
| 1109 |
+
// negative, it is ignored.
|
| 1110 |
+
|
| 1111 |
+
int insstr(int y, int x, const char *s, int n=-1) {
|
| 1112 |
+
return ::mvwinsnstr(w, y, x, s, n); }
|
| 1113 |
+
// Move the cursor to the requested position and then perform the insstr()
|
| 1114 |
+
// as described above.
|
| 1115 |
+
|
| 1116 |
+
int attron (chtype at) { return ::wattron (w, at); }
|
| 1117 |
+
// Switch on the window attributes;
|
| 1118 |
+
|
| 1119 |
+
int attroff(chtype at) { return ::wattroff(w, static_cast<int>(at)); }
|
| 1120 |
+
// Switch off the window attributes;
|
| 1121 |
+
|
| 1122 |
+
int attrset(chtype at) { return ::wattrset(w, static_cast<int>(at)); }
|
| 1123 |
+
// Set the window attributes;
|
| 1124 |
+
|
| 1125 |
+
chtype attrget() { return ::getattrs(w); }
|
| 1126 |
+
// Get the window attributes;
|
| 1127 |
+
|
| 1128 |
+
int color_set(NCURSES_PAIRS_T color_pair_number, void* opts=NULL) {
|
| 1129 |
+
return ::wcolor_set(w, color_pair_number, opts); }
|
| 1130 |
+
// Set the window color attribute;
|
| 1131 |
+
|
| 1132 |
+
int chgat(int n, attr_t attr, NCURSES_PAIRS_T color, const void *opts=NULL) {
|
| 1133 |
+
return ::wchgat(w, n, attr, color, opts); }
|
| 1134 |
+
// Change the attributes of the next n characters in the current line. If
|
| 1135 |
+
// n is negative or greater than the number of remaining characters in the
|
| 1136 |
+
// line, the attributes will be changed up to the end of the line.
|
| 1137 |
+
|
| 1138 |
+
int chgat(int y, int x,
|
| 1139 |
+
int n, attr_t attr, NCURSES_PAIRS_T color, const void *opts=NULL) {
|
| 1140 |
+
return ::mvwchgat(w, y, x, n, attr, color, opts); }
|
| 1141 |
+
// Move the cursor to the requested position and then perform chgat() as
|
| 1142 |
+
// described above.
|
| 1143 |
+
|
| 1144 |
+
// -------------------------------------------------------------------------
|
| 1145 |
+
// background
|
| 1146 |
+
// -------------------------------------------------------------------------
|
| 1147 |
+
chtype getbkgd() const { return ::getbkgd(w); }
|
| 1148 |
+
// Get current background setting.
|
| 1149 |
+
|
| 1150 |
+
int bkgd(const chtype ch) { return ::wbkgd(w, ch); }
|
| 1151 |
+
// Set the background property and apply it to the window.
|
| 1152 |
+
|
| 1153 |
+
void bkgdset(chtype ch) { ::wbkgdset(w, ch); }
|
| 1154 |
+
// Set the background property.
|
| 1155 |
+
|
| 1156 |
+
// -------------------------------------------------------------------------
|
| 1157 |
+
// borders
|
| 1158 |
+
// -------------------------------------------------------------------------
|
| 1159 |
+
int box(chtype vert=0, chtype hor=0) {
|
| 1160 |
+
return ::wborder(w, vert, vert, hor, hor, 0, 0, 0, 0); }
|
| 1161 |
+
// Draw a box around the window with the given vertical and horizontal
|
| 1162 |
+
// drawing characters. If you specify a zero as character, curses will try
|
| 1163 |
+
// to find a "nice" character.
|
| 1164 |
+
|
| 1165 |
+
int border(chtype left=0, chtype right=0,
|
| 1166 |
+
chtype top =0, chtype bottom=0,
|
| 1167 |
+
chtype top_left =0, chtype top_right=0,
|
| 1168 |
+
chtype bottom_left =0, chtype bottom_right=0) {
|
| 1169 |
+
return ::wborder(w, left, right, top, bottom, top_left, top_right,
|
| 1170 |
+
bottom_left, bottom_right); }
|
| 1171 |
+
// Draw a border around the window with the given characters for the
|
| 1172 |
+
// various parts of the border. If you pass zero for a character, curses
|
| 1173 |
+
// will try to find "nice" characters.
|
| 1174 |
+
|
| 1175 |
+
// -------------------------------------------------------------------------
|
| 1176 |
+
// lines and boxes
|
| 1177 |
+
// -------------------------------------------------------------------------
|
| 1178 |
+
int hline(int len, chtype ch=0) { return ::whline(w, ch, len); }
|
| 1179 |
+
// Draw a horizontal line of len characters with the given character. If
|
| 1180 |
+
// you pass zero for the character, curses will try to find a "nice" one.
|
| 1181 |
+
|
| 1182 |
+
int hline(int y, int x, int len, chtype ch=0) {
|
| 1183 |
+
return ::mvwhline(w, y, x, ch, len); }
|
| 1184 |
+
// Move the cursor to the requested position and then draw a horizontal line.
|
| 1185 |
+
|
| 1186 |
+
int vline(int len, chtype ch=0) { return ::wvline(w, ch, len); }
|
| 1187 |
+
// Draw a vertical line of len characters with the given character. If
|
| 1188 |
+
// you pass zero for the character, curses will try to find a "nice" one.
|
| 1189 |
+
|
| 1190 |
+
int vline(int y, int x, int len, chtype ch=0) {
|
| 1191 |
+
return ::mvwvline(w, y, x, ch, len); }
|
| 1192 |
+
// Move the cursor to the requested position and then draw a vertical line.
|
| 1193 |
+
|
| 1194 |
+
// -------------------------------------------------------------------------
|
| 1195 |
+
// erasure
|
| 1196 |
+
// -------------------------------------------------------------------------
|
| 1197 |
+
int erase() { return ::werase(w); }
|
| 1198 |
+
// Erase the window.
|
| 1199 |
+
|
| 1200 |
+
int clear() { return ::wclear(w); }
|
| 1201 |
+
// Clear the window.
|
| 1202 |
+
|
| 1203 |
+
int clearok(bool bf) { return ::clearok(w, bf); }
|
| 1204 |
+
// Set/Reset the clear flag. If set, the next refresh() will clear the
|
| 1205 |
+
// screen.
|
| 1206 |
+
|
| 1207 |
+
int clrtobot() { return ::wclrtobot(w); }
|
| 1208 |
+
// Clear to the end of the window.
|
| 1209 |
+
|
| 1210 |
+
int clrtoeol() { return ::wclrtoeol(w); }
|
| 1211 |
+
// Clear to the end of the line.
|
| 1212 |
+
|
| 1213 |
+
int delch() { return ::wdelch(w); }
|
| 1214 |
+
// Delete character under the cursor.
|
| 1215 |
+
|
| 1216 |
+
int delch(int y, int x) { return ::mvwdelch(w, y, x); }
|
| 1217 |
+
// Move cursor to requested position and delete the character under the
|
| 1218 |
+
// cursor.
|
| 1219 |
+
|
| 1220 |
+
int deleteln() { return ::winsdelln(w, -1); }
|
| 1221 |
+
// Delete the current line.
|
| 1222 |
+
|
| 1223 |
+
// -------------------------------------------------------------------------
|
| 1224 |
+
// screen control
|
| 1225 |
+
// -------------------------------------------------------------------------
|
| 1226 |
+
int scroll(int amount=1) { return ::wscrl(w, amount); }
|
| 1227 |
+
// Scroll amount lines. If amount is positive, scroll up, otherwise
|
| 1228 |
+
// scroll down.
|
| 1229 |
+
|
| 1230 |
+
int scrollok(bool bf) { return ::scrollok(w, bf); }
|
| 1231 |
+
// If bf is TRUE, window scrolls if cursor is moved off the bottom
|
| 1232 |
+
// edge of the window or a scrolling region, otherwise the cursor is left
|
| 1233 |
+
// at the bottom line.
|
| 1234 |
+
|
| 1235 |
+
int setscrreg(int from, int to) {
|
| 1236 |
+
return ::wsetscrreg(w, from, to); }
|
| 1237 |
+
// Define a soft scrolling region.
|
| 1238 |
+
|
| 1239 |
+
int idlok(bool bf) { return ::idlok(w, bf); }
|
| 1240 |
+
// If bf is TRUE, use insert/delete line hardware support if possible.
|
| 1241 |
+
// Otherwise do it in software.
|
| 1242 |
+
|
| 1243 |
+
void idcok(bool bf) { ::idcok(w, bf); }
|
| 1244 |
+
// If bf is TRUE, use insert/delete character hardware support if possible.
|
| 1245 |
+
// Otherwise do it in software.
|
| 1246 |
+
|
| 1247 |
+
int touchline(int s, int c) { return ::touchline(w, s, c); }
|
| 1248 |
+
// Mark the given lines as modified.
|
| 1249 |
+
|
| 1250 |
+
int touchwin() { return ::wtouchln(w, 0, height(), 1); }
|
| 1251 |
+
// Mark the whole window as modified.
|
| 1252 |
+
|
| 1253 |
+
int untouchwin() { return ::wtouchln(w, 0, height(), 0); }
|
| 1254 |
+
// Mark the whole window as unmodified.
|
| 1255 |
+
|
| 1256 |
+
int touchln(int s, int cnt, bool changed=TRUE) {
|
| 1257 |
+
return ::wtouchln(w, s, cnt, static_cast<int>(changed ? 1 : 0)); }
|
| 1258 |
+
// Mark cnt lines beginning from line s as changed or unchanged, depending
|
| 1259 |
+
// on the value of the changed flag.
|
| 1260 |
+
|
| 1261 |
+
bool is_linetouched(int line) const {
|
| 1262 |
+
return (::is_linetouched(w, line) == TRUE ? TRUE:FALSE); }
|
| 1263 |
+
// Return TRUE if line is marked as changed, FALSE otherwise
|
| 1264 |
+
|
| 1265 |
+
bool is_wintouched() const {
|
| 1266 |
+
return (::is_wintouched(w) ? TRUE:FALSE); }
|
| 1267 |
+
// Return TRUE if window is marked as changed, FALSE otherwise
|
| 1268 |
+
|
| 1269 |
+
int leaveok(bool bf) { return ::leaveok(w, bf); }
|
| 1270 |
+
// If bf is TRUE, curses will leave the cursor after an update wherever
|
| 1271 |
+
// it is after the update.
|
| 1272 |
+
|
| 1273 |
+
int redrawln(int from, int n) { return ::wredrawln(w, from, n); }
|
| 1274 |
+
// Redraw n lines starting from the requested line
|
| 1275 |
+
|
| 1276 |
+
int redrawwin() { return ::wredrawln(w, 0, height()); }
|
| 1277 |
+
// Redraw the whole window
|
| 1278 |
+
|
| 1279 |
+
int doupdate() { return ::doupdate(); }
|
| 1280 |
+
// Do all outputs to make the physical screen looking like the virtual one
|
| 1281 |
+
|
| 1282 |
+
void syncdown() { ::wsyncdown(w); }
|
| 1283 |
+
// Propagate the changes down to all descendant windows
|
| 1284 |
+
|
| 1285 |
+
void syncup() { ::wsyncup(w); }
|
| 1286 |
+
// Propagate the changes up in the hierarchy
|
| 1287 |
+
|
| 1288 |
+
void cursyncup() { ::wcursyncup(w); }
|
| 1289 |
+
// Position the cursor in all ancestor windows corresponding to our setting
|
| 1290 |
+
|
| 1291 |
+
int syncok(bool bf) { return ::syncok(w, bf); }
|
| 1292 |
+
// If called with bf=TRUE, syncup() is called whenever the window is changed
|
| 1293 |
+
|
| 1294 |
+
#ifndef _no_flushok
|
| 1295 |
+
int flushok(bool bf) { return ::flushok(w, bf); }
|
| 1296 |
+
#endif
|
| 1297 |
+
|
| 1298 |
+
void immedok(bool bf) { ::immedok(w, bf); }
|
| 1299 |
+
// If called with bf=TRUE, any change in the window will cause an
|
| 1300 |
+
// automatic immediate refresh()
|
| 1301 |
+
|
| 1302 |
+
int intrflush(bool bf) { return ::intrflush(w, bf); }
|
| 1303 |
+
|
| 1304 |
+
int keypad(bool bf) { return ::keypad(w, bf); }
|
| 1305 |
+
// If called with bf=TRUE, the application will interpret function keys.
|
| 1306 |
+
|
| 1307 |
+
int nodelay(bool bf) { return ::nodelay(w, bf); }
|
| 1308 |
+
|
| 1309 |
+
int meta(bool bf) { return ::meta(w, bf); }
|
| 1310 |
+
// If called with bf=TRUE, keys may generate 8-Bit characters. Otherwise
|
| 1311 |
+
// 7-Bit characters are generated.
|
| 1312 |
+
|
| 1313 |
+
int standout() { return ::wstandout(w); }
|
| 1314 |
+
// Enable "standout" attributes
|
| 1315 |
+
|
| 1316 |
+
int standend() { return ::wstandend(w); }
|
| 1317 |
+
// Disable "standout" attributes
|
| 1318 |
+
|
| 1319 |
+
// -------------------------------------------------------------------------
|
| 1320 |
+
// The next two are virtual, because we redefine them in the
|
| 1321 |
+
// NCursesPanel class.
|
| 1322 |
+
// -------------------------------------------------------------------------
|
| 1323 |
+
virtual int refresh() { return ::wrefresh(w); }
|
| 1324 |
+
// Propagate the changes in this window to the virtual screen and call
|
| 1325 |
+
// doupdate(). This is redefined in NCursesPanel.
|
| 1326 |
+
|
| 1327 |
+
virtual int noutrefresh() { return ::wnoutrefresh(w); }
|
| 1328 |
+
// Propagate the changes in this window to the virtual screen. This is
|
| 1329 |
+
// redefined in NCursesPanel.
|
| 1330 |
+
|
| 1331 |
+
// -------------------------------------------------------------------------
|
| 1332 |
+
// multiple window control
|
| 1333 |
+
// -------------------------------------------------------------------------
|
| 1334 |
+
int overlay(NCursesWindow& win) {
|
| 1335 |
+
return ::overlay(w, win.w); }
|
| 1336 |
+
// Overlay this window over win.
|
| 1337 |
+
|
| 1338 |
+
int overwrite(NCursesWindow& win) {
|
| 1339 |
+
return ::overwrite(w, win.w); }
|
| 1340 |
+
// Overwrite win with this window.
|
| 1341 |
+
|
| 1342 |
+
int copywin(NCursesWindow& win,
|
| 1343 |
+
int sminrow, int smincol,
|
| 1344 |
+
int dminrow, int dmincol,
|
| 1345 |
+
int dmaxrow, int dmaxcol, bool overlaywin=TRUE) {
|
| 1346 |
+
return ::copywin(w, win.w, sminrow, smincol, dminrow, dmincol,
|
| 1347 |
+
dmaxrow, dmaxcol, static_cast<int>(overlaywin ? 1 : 0)); }
|
| 1348 |
+
// Overlay or overwrite the rectangle in win given by dminrow,dmincol,
|
| 1349 |
+
// dmaxrow,dmaxcol with the rectangle in this window beginning at
|
| 1350 |
+
// sminrow,smincol.
|
| 1351 |
+
|
| 1352 |
+
// -------------------------------------------------------------------------
|
| 1353 |
+
// Extended functions
|
| 1354 |
+
// -------------------------------------------------------------------------
|
| 1355 |
+
#if defined(NCURSES_EXT_FUNCS) && (NCURSES_EXT_FUNCS != 0)
|
| 1356 |
+
int wresize(int newLines, int newColumns) {
|
| 1357 |
+
return ::wresize(w, newLines, newColumns); }
|
| 1358 |
+
#endif
|
| 1359 |
+
|
| 1360 |
+
// -------------------------------------------------------------------------
|
| 1361 |
+
// Mouse related
|
| 1362 |
+
// -------------------------------------------------------------------------
|
| 1363 |
+
bool has_mouse() const;
|
| 1364 |
+
// Return TRUE if terminal supports a mouse, FALSE otherwise
|
| 1365 |
+
|
| 1366 |
+
// -------------------------------------------------------------------------
|
| 1367 |
+
// traversal support
|
| 1368 |
+
// -------------------------------------------------------------------------
|
| 1369 |
+
NCursesWindow* child() { return subwins; }
|
| 1370 |
+
// Get the first child window.
|
| 1371 |
+
|
| 1372 |
+
NCursesWindow* sibling() { return sib; }
|
| 1373 |
+
// Get the next child of my parent.
|
| 1374 |
+
|
| 1375 |
+
NCursesWindow* parent() { return par; }
|
| 1376 |
+
// Get my parent.
|
| 1377 |
+
|
| 1378 |
+
bool isDescendant(NCursesWindow& win);
|
| 1379 |
+
// Return TRUE if win is a descendant of this.
|
| 1380 |
+
};
|
| 1381 |
+
|
| 1382 |
+
// -------------------------------------------------------------------------
|
| 1383 |
+
// We leave this here for compatibility reasons.
|
| 1384 |
+
// -------------------------------------------------------------------------
|
| 1385 |
+
class NCURSES_CXX_IMPEXP NCursesColorWindow : public NCursesWindow
|
| 1386 |
+
{
|
| 1387 |
+
public:
|
| 1388 |
+
explicit NCursesColorWindow(WINDOW* &window) // useful only for stdscr
|
| 1389 |
+
: NCursesWindow(window) {
|
| 1390 |
+
useColors(); }
|
| 1391 |
+
|
| 1392 |
+
NCursesColorWindow(int nlines, // number of lines
|
| 1393 |
+
int ncols, // number of columns
|
| 1394 |
+
int begin_y, // line origin
|
| 1395 |
+
int begin_x) // col origin
|
| 1396 |
+
: NCursesWindow(nlines, ncols, begin_y, begin_x) {
|
| 1397 |
+
useColors(); }
|
| 1398 |
+
|
| 1399 |
+
NCursesColorWindow(NCursesWindow& parentWin,// parent window
|
| 1400 |
+
int nlines, // number of lines
|
| 1401 |
+
int ncols, // number of columns
|
| 1402 |
+
int begin_y, // absolute or relative
|
| 1403 |
+
int begin_x, // origins:
|
| 1404 |
+
char absrel = 'a') // if `a', by & bx are
|
| 1405 |
+
: NCursesWindow(parentWin,
|
| 1406 |
+
nlines, ncols, // absolute screen pos,
|
| 1407 |
+
begin_y, begin_x, // else if `r', they are
|
| 1408 |
+
absrel ) { // relative to par origin
|
| 1409 |
+
useColors(); }
|
| 1410 |
+
};
|
| 1411 |
+
|
| 1412 |
+
// These enum definitions really belong inside the NCursesPad class, but only
|
| 1413 |
+
// recent compilers support that feature.
|
| 1414 |
+
|
| 1415 |
+
typedef enum {
|
| 1416 |
+
REQ_PAD_REFRESH = KEY_MAX + 1,
|
| 1417 |
+
REQ_PAD_UP,
|
| 1418 |
+
REQ_PAD_DOWN,
|
| 1419 |
+
REQ_PAD_LEFT,
|
| 1420 |
+
REQ_PAD_RIGHT,
|
| 1421 |
+
REQ_PAD_EXIT
|
| 1422 |
+
} Pad_Request;
|
| 1423 |
+
|
| 1424 |
+
const Pad_Request PAD_LOW = REQ_PAD_REFRESH; // lowest op-code
|
| 1425 |
+
const Pad_Request PAD_HIGH = REQ_PAD_EXIT; // highest op-code
|
| 1426 |
+
|
| 1427 |
+
// -------------------------------------------------------------------------
|
| 1428 |
+
// Pad Support. We allow an association of a pad with a "real" window
|
| 1429 |
+
// through which the pad may be viewed.
|
| 1430 |
+
// -------------------------------------------------------------------------
|
| 1431 |
+
class NCURSES_CXX_IMPEXP NCursesPad : public NCursesWindow
|
| 1432 |
+
{
|
| 1433 |
+
private:
|
| 1434 |
+
NCursesWindow* viewWin; // the "viewport" window
|
| 1435 |
+
NCursesWindow* viewSub; // the "viewport" subwindow
|
| 1436 |
+
|
| 1437 |
+
int h_gridsize, v_gridsize;
|
| 1438 |
+
|
| 1439 |
+
protected:
|
| 1440 |
+
int min_row, min_col; // top left row/col of the pads display area
|
| 1441 |
+
|
| 1442 |
+
NCursesWindow* Win(void) const {
|
| 1443 |
+
// Get the window into which the pad should be copied (if any)
|
| 1444 |
+
return (viewSub?viewSub:(viewWin?viewWin:0));
|
| 1445 |
+
}
|
| 1446 |
+
|
| 1447 |
+
NCursesWindow* getWindow(void) const {
|
| 1448 |
+
return viewWin;
|
| 1449 |
+
}
|
| 1450 |
+
|
| 1451 |
+
NCursesWindow* getSubWindow(void) const {
|
| 1452 |
+
return viewSub;
|
| 1453 |
+
}
|
| 1454 |
+
|
| 1455 |
+
virtual int driver (int key); // Virtualize keystroke key
|
| 1456 |
+
// The driver translates the keystroke c into an Pad_Request
|
| 1457 |
+
|
| 1458 |
+
virtual void OnUnknownOperation(int pad_req) {
|
| 1459 |
+
(void) pad_req;
|
| 1460 |
+
::beep();
|
| 1461 |
+
}
|
| 1462 |
+
// This is called if the driver returns an unknown op-code
|
| 1463 |
+
|
| 1464 |
+
virtual void OnNavigationError(int pad_req) {
|
| 1465 |
+
(void) pad_req;
|
| 1466 |
+
::beep();
|
| 1467 |
+
}
|
| 1468 |
+
// This is called if a navigation request couldn't be satisfied
|
| 1469 |
+
|
| 1470 |
+
virtual void OnOperation(int pad_req) {
|
| 1471 |
+
(void) pad_req;
|
| 1472 |
+
};
|
| 1473 |
+
// OnOperation is called if a Pad_Operation was executed and just before
|
| 1474 |
+
// the refresh() operation is done.
|
| 1475 |
+
|
| 1476 |
+
public:
|
| 1477 |
+
NCursesPad(int nlines, int ncols);
|
| 1478 |
+
// create a pad with the given size
|
| 1479 |
+
|
| 1480 |
+
NCursesPad& operator=(const NCursesPad& rhs)
|
| 1481 |
+
{
|
| 1482 |
+
if (this != &rhs) {
|
| 1483 |
+
*this = rhs;
|
| 1484 |
+
NCursesWindow::operator=(rhs);
|
| 1485 |
+
}
|
| 1486 |
+
return *this;
|
| 1487 |
+
}
|
| 1488 |
+
|
| 1489 |
+
NCursesPad(const NCursesPad& rhs)
|
| 1490 |
+
: NCursesWindow(rhs),
|
| 1491 |
+
viewWin(rhs.viewWin),
|
| 1492 |
+
viewSub(rhs.viewSub),
|
| 1493 |
+
h_gridsize(rhs.h_gridsize),
|
| 1494 |
+
v_gridsize(rhs.v_gridsize),
|
| 1495 |
+
min_row(rhs.min_row),
|
| 1496 |
+
min_col(rhs.min_col)
|
| 1497 |
+
{
|
| 1498 |
+
}
|
| 1499 |
+
|
| 1500 |
+
virtual ~NCursesPad() THROWS(NCursesException) {}
|
| 1501 |
+
|
| 1502 |
+
int echochar(const chtype ch) { return ::pechochar(w, ch); }
|
| 1503 |
+
// Put the attributed character onto the pad and immediately do a
|
| 1504 |
+
// prefresh().
|
| 1505 |
+
|
| 1506 |
+
int refresh() NCURSES_OVERRIDE;
|
| 1507 |
+
// If a viewport is defined the pad is displayed in this window, otherwise
|
| 1508 |
+
// this is a noop.
|
| 1509 |
+
|
| 1510 |
+
int refresh(int pminrow, int pmincol,
|
| 1511 |
+
int sminrow, int smincol,
|
| 1512 |
+
int smaxrow, int smaxcol) {
|
| 1513 |
+
return ::prefresh(w, pminrow, pmincol,
|
| 1514 |
+
sminrow, smincol, smaxrow, smaxcol);
|
| 1515 |
+
}
|
| 1516 |
+
// The coordinates sminrow,smincol,smaxrow,smaxcol describe a rectangle
|
| 1517 |
+
// on the screen. <b>refresh</b> copies a rectangle of this size beginning
|
| 1518 |
+
// with top left corner pminrow,pmincol onto the screen and calls doupdate().
|
| 1519 |
+
|
| 1520 |
+
int noutrefresh() NCURSES_OVERRIDE;
|
| 1521 |
+
// If a viewport is defined the pad is displayed in this window, otherwise
|
| 1522 |
+
// this is a noop.
|
| 1523 |
+
|
| 1524 |
+
int noutrefresh(int pminrow, int pmincol,
|
| 1525 |
+
int sminrow, int smincol,
|
| 1526 |
+
int smaxrow, int smaxcol) {
|
| 1527 |
+
return ::pnoutrefresh(w, pminrow, pmincol,
|
| 1528 |
+
sminrow, smincol, smaxrow, smaxcol);
|
| 1529 |
+
}
|
| 1530 |
+
// Does the same as refresh() but without calling doupdate().
|
| 1531 |
+
|
| 1532 |
+
virtual void setWindow(NCursesWindow& view, int v_grid = 1, int h_grid = 1);
|
| 1533 |
+
// Add the window "view" as viewing window to the pad.
|
| 1534 |
+
|
| 1535 |
+
virtual void setSubWindow(NCursesWindow& sub);
|
| 1536 |
+
// Use the subwindow "sub" of the viewport window for the actual viewing.
|
| 1537 |
+
// The full viewport window is usually used to provide some decorations
|
| 1538 |
+
// like frames, titles etc.
|
| 1539 |
+
|
| 1540 |
+
virtual void operator() (void);
|
| 1541 |
+
// Perform Pad's operation
|
| 1542 |
+
};
|
| 1543 |
+
|
| 1544 |
+
// A FramedPad is constructed always with a viewport window. This viewport
|
| 1545 |
+
// will be framed (by a box() command) and the interior of the box is the
|
| 1546 |
+
// viewport subwindow. On the frame we display scrollbar sliders.
|
| 1547 |
+
class NCURSES_CXX_IMPEXP NCursesFramedPad : public NCursesPad
|
| 1548 |
+
{
|
| 1549 |
+
protected:
|
| 1550 |
+
virtual void OnOperation(int pad_req) NCURSES_OVERRIDE;
|
| 1551 |
+
|
| 1552 |
+
public:
|
| 1553 |
+
NCursesFramedPad(NCursesWindow& win, int nlines, int ncols,
|
| 1554 |
+
int v_grid = 1, int h_grid = 1)
|
| 1555 |
+
: NCursesPad(nlines, ncols) {
|
| 1556 |
+
NCursesPad::setWindow(win, v_grid, h_grid);
|
| 1557 |
+
NCursesPad::setSubWindow(*(new NCursesWindow(win)));
|
| 1558 |
+
}
|
| 1559 |
+
// Construct the FramedPad with the given Window win as viewport.
|
| 1560 |
+
|
| 1561 |
+
virtual ~NCursesFramedPad() THROWS(NCursesException) {
|
| 1562 |
+
delete getSubWindow();
|
| 1563 |
+
}
|
| 1564 |
+
|
| 1565 |
+
void setWindow(NCursesWindow& view, int v_grid = 1, int h_grid = 1) NCURSES_OVERRIDE {
|
| 1566 |
+
(void) view;
|
| 1567 |
+
(void) v_grid;
|
| 1568 |
+
(void) h_grid;
|
| 1569 |
+
err_handler("Operation not allowed");
|
| 1570 |
+
}
|
| 1571 |
+
// Disable this call; the viewport is already defined
|
| 1572 |
+
|
| 1573 |
+
void setSubWindow(NCursesWindow& sub) NCURSES_OVERRIDE {
|
| 1574 |
+
(void) sub;
|
| 1575 |
+
err_handler("Operation not allowed");
|
| 1576 |
+
}
|
| 1577 |
+
// Disable this call; the viewport subwindow is already defined
|
| 1578 |
+
|
| 1579 |
+
};
|
| 1580 |
+
|
| 1581 |
+
#endif /* NCURSES_CURSESW_H_incl */
|
llava_next/include/ncursesw/form.h
ADDED
|
@@ -0,0 +1,460 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/****************************************************************************
|
| 2 |
+
* Copyright 2018-2019-2020,2021 Thomas E. Dickey *
|
| 3 |
+
* Copyright 1998-2016,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: Juergen Pfeifer, 1995,1997 *
|
| 32 |
+
****************************************************************************/
|
| 33 |
+
|
| 34 |
+
/* $Id: form.h,v 0.32 2021/06/17 21:26:02 tom Exp $ */
|
| 35 |
+
|
| 36 |
+
#ifndef FORM_H
|
| 37 |
+
#define FORM_H
|
| 38 |
+
/* *INDENT-OFF*/
|
| 39 |
+
|
| 40 |
+
#include <ncursesw/curses.h>
|
| 41 |
+
#include <ncursesw/eti.h>
|
| 42 |
+
|
| 43 |
+
#ifdef __cplusplus
|
| 44 |
+
extern "C" {
|
| 45 |
+
#endif
|
| 46 |
+
|
| 47 |
+
#if defined(BUILDING_FORM)
|
| 48 |
+
# define FORM_IMPEXP NCURSES_EXPORT_GENERAL_EXPORT
|
| 49 |
+
#else
|
| 50 |
+
# define FORM_IMPEXP NCURSES_EXPORT_GENERAL_IMPORT
|
| 51 |
+
#endif
|
| 52 |
+
|
| 53 |
+
#define FORM_WRAPPED_VAR(type,name) extern FORM_IMPEXP type NCURSES_PUBLIC_VAR(name)(void)
|
| 54 |
+
|
| 55 |
+
#define FORM_EXPORT(type) FORM_IMPEXP type NCURSES_API
|
| 56 |
+
#define FORM_EXPORT_VAR(type) FORM_IMPEXP type
|
| 57 |
+
|
| 58 |
+
#ifndef FORM_PRIV_H
|
| 59 |
+
typedef void *FIELD_CELL;
|
| 60 |
+
#endif
|
| 61 |
+
|
| 62 |
+
#ifndef NCURSES_FIELD_INTERNALS
|
| 63 |
+
#define NCURSES_FIELD_INTERNALS /* nothing */
|
| 64 |
+
#endif
|
| 65 |
+
|
| 66 |
+
typedef int Form_Options;
|
| 67 |
+
typedef int Field_Options;
|
| 68 |
+
|
| 69 |
+
/**********
|
| 70 |
+
* _PAGE *
|
| 71 |
+
**********/
|
| 72 |
+
|
| 73 |
+
typedef struct pagenode
|
| 74 |
+
#if !NCURSES_OPAQUE_FORM
|
| 75 |
+
{
|
| 76 |
+
short pmin; /* index of first field on page */
|
| 77 |
+
short pmax; /* index of last field on page */
|
| 78 |
+
short smin; /* index of top leftmost field on page */
|
| 79 |
+
short smax; /* index of bottom rightmost field on page */
|
| 80 |
+
}
|
| 81 |
+
#endif /* !NCURSES_OPAQUE_FORM */
|
| 82 |
+
_PAGE;
|
| 83 |
+
|
| 84 |
+
/**********
|
| 85 |
+
* FIELD *
|
| 86 |
+
**********/
|
| 87 |
+
|
| 88 |
+
typedef struct fieldnode
|
| 89 |
+
#if 1 /* not yet: !NCURSES_OPAQUE_FORM */
|
| 90 |
+
{
|
| 91 |
+
unsigned short status; /* flags */
|
| 92 |
+
short rows; /* size in rows */
|
| 93 |
+
short cols; /* size in cols */
|
| 94 |
+
short frow; /* first row */
|
| 95 |
+
short fcol; /* first col */
|
| 96 |
+
int drows; /* dynamic rows */
|
| 97 |
+
int dcols; /* dynamic cols */
|
| 98 |
+
int maxgrow; /* maximum field growth */
|
| 99 |
+
int nrow; /* off-screen rows */
|
| 100 |
+
short nbuf; /* additional buffers */
|
| 101 |
+
short just; /* justification */
|
| 102 |
+
short page; /* page on form */
|
| 103 |
+
short index; /* into form -> field */
|
| 104 |
+
int pad; /* pad character */
|
| 105 |
+
chtype fore; /* foreground attribute */
|
| 106 |
+
chtype back; /* background attribute */
|
| 107 |
+
Field_Options opts; /* options */
|
| 108 |
+
struct fieldnode * snext; /* sorted order pointer */
|
| 109 |
+
struct fieldnode * sprev; /* sorted order pointer */
|
| 110 |
+
struct fieldnode * link; /* linked field chain */
|
| 111 |
+
struct formnode * form; /* containing form */
|
| 112 |
+
struct typenode * type; /* field type */
|
| 113 |
+
void * arg; /* argument for type */
|
| 114 |
+
FIELD_CELL * buf; /* field buffers */
|
| 115 |
+
void * usrptr; /* user pointer */
|
| 116 |
+
/*
|
| 117 |
+
* The wide-character configuration requires extra information. Because
|
| 118 |
+
* there are existing applications that manipulate the members of FIELD
|
| 119 |
+
* directly, we cannot make the struct opaque, except by changing the ABI.
|
| 120 |
+
* Offsets of members up to this point are the same in the narrow- and
|
| 121 |
+
* wide-character configuration. But note that the type of buf depends on
|
| 122 |
+
* the configuration, and is made opaque for that reason.
|
| 123 |
+
*/
|
| 124 |
+
NCURSES_FIELD_INTERNALS
|
| 125 |
+
}
|
| 126 |
+
#endif /* NCURSES_OPAQUE_FORM */
|
| 127 |
+
FIELD;
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
/*********
|
| 131 |
+
* FORM *
|
| 132 |
+
*********/
|
| 133 |
+
|
| 134 |
+
typedef struct formnode
|
| 135 |
+
#if 1 /* not yet: !NCURSES_OPAQUE_FORM */
|
| 136 |
+
{
|
| 137 |
+
unsigned short status; /* flags */
|
| 138 |
+
short rows; /* size in rows */
|
| 139 |
+
short cols; /* size in cols */
|
| 140 |
+
int currow; /* current row in field window */
|
| 141 |
+
int curcol; /* current col in field window */
|
| 142 |
+
int toprow; /* in scrollable field window */
|
| 143 |
+
int begincol; /* in horiz. scrollable field */
|
| 144 |
+
short maxfield; /* number of fields */
|
| 145 |
+
short maxpage; /* number of pages */
|
| 146 |
+
short curpage; /* index into page */
|
| 147 |
+
Form_Options opts; /* options */
|
| 148 |
+
WINDOW * win; /* window */
|
| 149 |
+
WINDOW * sub; /* subwindow */
|
| 150 |
+
WINDOW * w; /* window for current field */
|
| 151 |
+
FIELD ** field; /* field [maxfield] */
|
| 152 |
+
FIELD * current; /* current field */
|
| 153 |
+
_PAGE * page; /* page [maxpage] */
|
| 154 |
+
void * usrptr; /* user pointer */
|
| 155 |
+
|
| 156 |
+
void (*forminit)(struct formnode *);
|
| 157 |
+
void (*formterm)(struct formnode *);
|
| 158 |
+
void (*fieldinit)(struct formnode *);
|
| 159 |
+
void (*fieldterm)(struct formnode *);
|
| 160 |
+
|
| 161 |
+
}
|
| 162 |
+
#endif /* !NCURSES_OPAQUE_FORM */
|
| 163 |
+
FORM;
|
| 164 |
+
|
| 165 |
+
|
| 166 |
+
/**************
|
| 167 |
+
* FIELDTYPE *
|
| 168 |
+
**************/
|
| 169 |
+
|
| 170 |
+
typedef struct typenode
|
| 171 |
+
#if !NCURSES_OPAQUE_FORM
|
| 172 |
+
{
|
| 173 |
+
unsigned short status; /* flags */
|
| 174 |
+
long ref; /* reference count */
|
| 175 |
+
struct typenode * left; /* ptr to operand for | */
|
| 176 |
+
struct typenode * right; /* ptr to operand for | */
|
| 177 |
+
|
| 178 |
+
void* (*makearg)(va_list *); /* make fieldtype arg */
|
| 179 |
+
void* (*copyarg)(const void *); /* copy fieldtype arg */
|
| 180 |
+
void (*freearg)(void *); /* free fieldtype arg */
|
| 181 |
+
|
| 182 |
+
#if NCURSES_INTEROP_FUNCS
|
| 183 |
+
union {
|
| 184 |
+
bool (*ofcheck)(FIELD *,const void *); /* field validation */
|
| 185 |
+
bool (*gfcheck)(FORM*,FIELD *,const void*); /* generic field validation */
|
| 186 |
+
} fieldcheck;
|
| 187 |
+
union {
|
| 188 |
+
bool (*occheck)(int,const void *); /* character validation */
|
| 189 |
+
bool (*gccheck)(int,FORM*,
|
| 190 |
+
FIELD*,const void*); /* generic char validation */
|
| 191 |
+
} charcheck;
|
| 192 |
+
union {
|
| 193 |
+
bool (*onext)(FIELD *,const void *); /* enumerate next value */
|
| 194 |
+
bool (*gnext)(FORM*,FIELD*,const void*); /* generic enumerate next */
|
| 195 |
+
} enum_next;
|
| 196 |
+
union {
|
| 197 |
+
bool (*oprev)(FIELD *,const void *); /* enumerate prev value */
|
| 198 |
+
bool (*gprev)(FORM*,FIELD*,const void*); /* generic enumerate prev */
|
| 199 |
+
} enum_prev;
|
| 200 |
+
void* (*genericarg)(void*); /* Alternate Arg method */
|
| 201 |
+
#else
|
| 202 |
+
bool (*fcheck)(FIELD *,const void *); /* field validation */
|
| 203 |
+
bool (*ccheck)(int,const void *); /* character validation */
|
| 204 |
+
|
| 205 |
+
bool (*next)(FIELD *,const void *); /* enumerate next value */
|
| 206 |
+
bool (*prev)(FIELD *,const void *); /* enumerate prev value */
|
| 207 |
+
#endif
|
| 208 |
+
}
|
| 209 |
+
#endif /* !NCURSES_OPAQUE_FORM */
|
| 210 |
+
FIELDTYPE;
|
| 211 |
+
|
| 212 |
+
typedef void (*Form_Hook)(FORM *);
|
| 213 |
+
|
| 214 |
+
/***************************
|
| 215 |
+
* miscellaneous #defines *
|
| 216 |
+
***************************/
|
| 217 |
+
|
| 218 |
+
/* field justification */
|
| 219 |
+
#define NO_JUSTIFICATION (0)
|
| 220 |
+
#define JUSTIFY_LEFT (1)
|
| 221 |
+
#define JUSTIFY_CENTER (2)
|
| 222 |
+
#define JUSTIFY_RIGHT (3)
|
| 223 |
+
|
| 224 |
+
/* field options */
|
| 225 |
+
#define O_VISIBLE (0x0001U)
|
| 226 |
+
#define O_ACTIVE (0x0002U)
|
| 227 |
+
#define O_PUBLIC (0x0004U)
|
| 228 |
+
#define O_EDIT (0x0008U)
|
| 229 |
+
#define O_WRAP (0x0010U)
|
| 230 |
+
#define O_BLANK (0x0020U)
|
| 231 |
+
#define O_AUTOSKIP (0x0040U)
|
| 232 |
+
#define O_NULLOK (0x0080U)
|
| 233 |
+
#define O_PASSOK (0x0100U)
|
| 234 |
+
#define O_STATIC (0x0200U)
|
| 235 |
+
#define O_DYNAMIC_JUSTIFY (0x0400U) /* ncurses extension */
|
| 236 |
+
#define O_NO_LEFT_STRIP (0x0800U) /* ncurses extension */
|
| 237 |
+
#define O_EDGE_INSERT_STAY (0x1000U) /* ncurses extension */
|
| 238 |
+
#define O_INPUT_LIMIT (0x2000U) /* ncurses extension */
|
| 239 |
+
|
| 240 |
+
/* form options */
|
| 241 |
+
#define O_NL_OVERLOAD (0x0001U)
|
| 242 |
+
#define O_BS_OVERLOAD (0x0002U)
|
| 243 |
+
|
| 244 |
+
/* form driver commands */
|
| 245 |
+
#define REQ_NEXT_PAGE (KEY_MAX + 1) /* move to next page */
|
| 246 |
+
#define REQ_PREV_PAGE (KEY_MAX + 2) /* move to previous page */
|
| 247 |
+
#define REQ_FIRST_PAGE (KEY_MAX + 3) /* move to first page */
|
| 248 |
+
#define REQ_LAST_PAGE (KEY_MAX + 4) /* move to last page */
|
| 249 |
+
|
| 250 |
+
#define REQ_NEXT_FIELD (KEY_MAX + 5) /* move to next field */
|
| 251 |
+
#define REQ_PREV_FIELD (KEY_MAX + 6) /* move to previous field */
|
| 252 |
+
#define REQ_FIRST_FIELD (KEY_MAX + 7) /* move to first field */
|
| 253 |
+
#define REQ_LAST_FIELD (KEY_MAX + 8) /* move to last field */
|
| 254 |
+
#define REQ_SNEXT_FIELD (KEY_MAX + 9) /* move to sorted next field */
|
| 255 |
+
#define REQ_SPREV_FIELD (KEY_MAX + 10) /* move to sorted prev field */
|
| 256 |
+
#define REQ_SFIRST_FIELD (KEY_MAX + 11) /* move to sorted first field */
|
| 257 |
+
#define REQ_SLAST_FIELD (KEY_MAX + 12) /* move to sorted last field */
|
| 258 |
+
#define REQ_LEFT_FIELD (KEY_MAX + 13) /* move to left to field */
|
| 259 |
+
#define REQ_RIGHT_FIELD (KEY_MAX + 14) /* move to right to field */
|
| 260 |
+
#define REQ_UP_FIELD (KEY_MAX + 15) /* move to up to field */
|
| 261 |
+
#define REQ_DOWN_FIELD (KEY_MAX + 16) /* move to down to field */
|
| 262 |
+
|
| 263 |
+
#define REQ_NEXT_CHAR (KEY_MAX + 17) /* move to next char in field */
|
| 264 |
+
#define REQ_PREV_CHAR (KEY_MAX + 18) /* move to prev char in field */
|
| 265 |
+
#define REQ_NEXT_LINE (KEY_MAX + 19) /* move to next line in field */
|
| 266 |
+
#define REQ_PREV_LINE (KEY_MAX + 20) /* move to prev line in field */
|
| 267 |
+
#define REQ_NEXT_WORD (KEY_MAX + 21) /* move to next word in field */
|
| 268 |
+
#define REQ_PREV_WORD (KEY_MAX + 22) /* move to prev word in field */
|
| 269 |
+
#define REQ_BEG_FIELD (KEY_MAX + 23) /* move to first char in field */
|
| 270 |
+
#define REQ_END_FIELD (KEY_MAX + 24) /* move after last char in fld */
|
| 271 |
+
#define REQ_BEG_LINE (KEY_MAX + 25) /* move to beginning of line */
|
| 272 |
+
#define REQ_END_LINE (KEY_MAX + 26) /* move after last char in line */
|
| 273 |
+
#define REQ_LEFT_CHAR (KEY_MAX + 27) /* move left in field */
|
| 274 |
+
#define REQ_RIGHT_CHAR (KEY_MAX + 28) /* move right in field */
|
| 275 |
+
#define REQ_UP_CHAR (KEY_MAX + 29) /* move up in field */
|
| 276 |
+
#define REQ_DOWN_CHAR (KEY_MAX + 30) /* move down in field */
|
| 277 |
+
|
| 278 |
+
#define REQ_NEW_LINE (KEY_MAX + 31) /* insert/overlay new line */
|
| 279 |
+
#define REQ_INS_CHAR (KEY_MAX + 32) /* insert blank char at cursor */
|
| 280 |
+
#define REQ_INS_LINE (KEY_MAX + 33) /* insert blank line at cursor */
|
| 281 |
+
#define REQ_DEL_CHAR (KEY_MAX + 34) /* delete char at cursor */
|
| 282 |
+
#define REQ_DEL_PREV (KEY_MAX + 35) /* delete char before cursor */
|
| 283 |
+
#define REQ_DEL_LINE (KEY_MAX + 36) /* delete line at cursor */
|
| 284 |
+
#define REQ_DEL_WORD (KEY_MAX + 37) /* delete word at cursor */
|
| 285 |
+
#define REQ_CLR_EOL (KEY_MAX + 38) /* clear to end of line */
|
| 286 |
+
#define REQ_CLR_EOF (KEY_MAX + 39) /* clear to end of field */
|
| 287 |
+
#define REQ_CLR_FIELD (KEY_MAX + 40) /* clear entire field */
|
| 288 |
+
#define REQ_OVL_MODE (KEY_MAX + 41) /* begin overlay mode */
|
| 289 |
+
#define REQ_INS_MODE (KEY_MAX + 42) /* begin insert mode */
|
| 290 |
+
#define REQ_SCR_FLINE (KEY_MAX + 43) /* scroll field forward a line */
|
| 291 |
+
#define REQ_SCR_BLINE (KEY_MAX + 44) /* scroll field backward a line */
|
| 292 |
+
#define REQ_SCR_FPAGE (KEY_MAX + 45) /* scroll field forward a page */
|
| 293 |
+
#define REQ_SCR_BPAGE (KEY_MAX + 46) /* scroll field backward a page */
|
| 294 |
+
#define REQ_SCR_FHPAGE (KEY_MAX + 47) /* scroll field forward half page */
|
| 295 |
+
#define REQ_SCR_BHPAGE (KEY_MAX + 48) /* scroll field backward half page */
|
| 296 |
+
#define REQ_SCR_FCHAR (KEY_MAX + 49) /* horizontal scroll char */
|
| 297 |
+
#define REQ_SCR_BCHAR (KEY_MAX + 50) /* horizontal scroll char */
|
| 298 |
+
#define REQ_SCR_HFLINE (KEY_MAX + 51) /* horizontal scroll line */
|
| 299 |
+
#define REQ_SCR_HBLINE (KEY_MAX + 52) /* horizontal scroll line */
|
| 300 |
+
#define REQ_SCR_HFHALF (KEY_MAX + 53) /* horizontal scroll half line */
|
| 301 |
+
#define REQ_SCR_HBHALF (KEY_MAX + 54) /* horizontal scroll half line */
|
| 302 |
+
|
| 303 |
+
#define REQ_VALIDATION (KEY_MAX + 55) /* validate field */
|
| 304 |
+
#define REQ_NEXT_CHOICE (KEY_MAX + 56) /* display next field choice */
|
| 305 |
+
#define REQ_PREV_CHOICE (KEY_MAX + 57) /* display prev field choice */
|
| 306 |
+
|
| 307 |
+
#define MIN_FORM_COMMAND (KEY_MAX + 1) /* used by form_driver */
|
| 308 |
+
#define MAX_FORM_COMMAND (KEY_MAX + 57) /* used by form_driver */
|
| 309 |
+
|
| 310 |
+
#if defined(MAX_COMMAND)
|
| 311 |
+
# if (MAX_FORM_COMMAND > MAX_COMMAND)
|
| 312 |
+
# error Something is wrong -- MAX_FORM_COMMAND is greater than MAX_COMMAND
|
| 313 |
+
# elif (MAX_COMMAND != (KEY_MAX + 128))
|
| 314 |
+
# error Something is wrong -- MAX_COMMAND is already inconsistently defined.
|
| 315 |
+
# endif
|
| 316 |
+
#else
|
| 317 |
+
# define MAX_COMMAND (KEY_MAX + 128)
|
| 318 |
+
#endif
|
| 319 |
+
|
| 320 |
+
/*************************
|
| 321 |
+
* standard field types *
|
| 322 |
+
*************************/
|
| 323 |
+
extern FORM_EXPORT_VAR(FIELDTYPE *) TYPE_ALPHA;
|
| 324 |
+
extern FORM_EXPORT_VAR(FIELDTYPE *) TYPE_ALNUM;
|
| 325 |
+
extern FORM_EXPORT_VAR(FIELDTYPE *) TYPE_ENUM;
|
| 326 |
+
extern FORM_EXPORT_VAR(FIELDTYPE *) TYPE_INTEGER;
|
| 327 |
+
extern FORM_EXPORT_VAR(FIELDTYPE *) TYPE_NUMERIC;
|
| 328 |
+
extern FORM_EXPORT_VAR(FIELDTYPE *) TYPE_REGEXP;
|
| 329 |
+
|
| 330 |
+
/************************************
|
| 331 |
+
* built-in additional field types *
|
| 332 |
+
* They are not defined in SVr4 *
|
| 333 |
+
************************************/
|
| 334 |
+
extern FORM_EXPORT_VAR(FIELDTYPE *) TYPE_IPV4; /* Internet IP Version 4 address */
|
| 335 |
+
|
| 336 |
+
/***********************
|
| 337 |
+
* FIELDTYPE routines *
|
| 338 |
+
***********************/
|
| 339 |
+
extern FORM_EXPORT(FIELDTYPE *) new_fieldtype (
|
| 340 |
+
bool (* const field_check)(FIELD *,const void *),
|
| 341 |
+
bool (* const char_check)(int,const void *));
|
| 342 |
+
extern FORM_EXPORT(FIELDTYPE *) link_fieldtype(
|
| 343 |
+
FIELDTYPE *, FIELDTYPE *);
|
| 344 |
+
|
| 345 |
+
extern FORM_EXPORT(int) free_fieldtype (FIELDTYPE *);
|
| 346 |
+
extern FORM_EXPORT(int) set_fieldtype_arg (FIELDTYPE *,
|
| 347 |
+
void * (* const make_arg)(va_list *),
|
| 348 |
+
void * (* const copy_arg)(const void *),
|
| 349 |
+
void (* const free_arg)(void *));
|
| 350 |
+
extern FORM_EXPORT(int) set_fieldtype_choice (FIELDTYPE *,
|
| 351 |
+
bool (* const next_choice)(FIELD *,const void *),
|
| 352 |
+
bool (* const prev_choice)(FIELD *,const void *));
|
| 353 |
+
|
| 354 |
+
/*******************
|
| 355 |
+
* FIELD routines *
|
| 356 |
+
*******************/
|
| 357 |
+
extern FORM_EXPORT(FIELD *) new_field (int,int,int,int,int,int);
|
| 358 |
+
extern FORM_EXPORT(FIELD *) dup_field (FIELD *,int,int);
|
| 359 |
+
extern FORM_EXPORT(FIELD *) link_field (FIELD *,int,int);
|
| 360 |
+
|
| 361 |
+
extern FORM_EXPORT(int) free_field (FIELD *);
|
| 362 |
+
extern FORM_EXPORT(int) field_info (const FIELD *,int *,int *,int *,int *,int *,int *);
|
| 363 |
+
extern FORM_EXPORT(int) dynamic_field_info (const FIELD *,int *,int *,int *);
|
| 364 |
+
extern FORM_EXPORT(int) set_max_field ( FIELD *,int);
|
| 365 |
+
extern FORM_EXPORT(int) move_field (FIELD *,int,int);
|
| 366 |
+
extern FORM_EXPORT(int) set_field_type (FIELD *,FIELDTYPE *,...);
|
| 367 |
+
extern FORM_EXPORT(int) set_new_page (FIELD *,bool);
|
| 368 |
+
extern FORM_EXPORT(int) set_field_just (FIELD *,int);
|
| 369 |
+
extern FORM_EXPORT(int) field_just (const FIELD *);
|
| 370 |
+
extern FORM_EXPORT(int) set_field_fore (FIELD *,chtype);
|
| 371 |
+
extern FORM_EXPORT(int) set_field_back (FIELD *,chtype);
|
| 372 |
+
extern FORM_EXPORT(int) set_field_pad (FIELD *,int);
|
| 373 |
+
extern FORM_EXPORT(int) field_pad (const FIELD *);
|
| 374 |
+
extern FORM_EXPORT(int) set_field_buffer (FIELD *,int,const char *);
|
| 375 |
+
extern FORM_EXPORT(int) set_field_status (FIELD *,bool);
|
| 376 |
+
extern FORM_EXPORT(int) set_field_userptr (FIELD *, void *);
|
| 377 |
+
extern FORM_EXPORT(int) set_field_opts (FIELD *,Field_Options);
|
| 378 |
+
extern FORM_EXPORT(int) field_opts_on (FIELD *,Field_Options);
|
| 379 |
+
extern FORM_EXPORT(int) field_opts_off (FIELD *,Field_Options);
|
| 380 |
+
|
| 381 |
+
extern FORM_EXPORT(chtype) field_fore (const FIELD *);
|
| 382 |
+
extern FORM_EXPORT(chtype) field_back (const FIELD *);
|
| 383 |
+
|
| 384 |
+
extern FORM_EXPORT(bool) new_page (const FIELD *);
|
| 385 |
+
extern FORM_EXPORT(bool) field_status (const FIELD *);
|
| 386 |
+
|
| 387 |
+
extern FORM_EXPORT(void *) field_arg (const FIELD *);
|
| 388 |
+
|
| 389 |
+
extern FORM_EXPORT(void *) field_userptr (const FIELD *);
|
| 390 |
+
|
| 391 |
+
extern FORM_EXPORT(FIELDTYPE *) field_type (const FIELD *);
|
| 392 |
+
|
| 393 |
+
extern FORM_EXPORT(char *) field_buffer (const FIELD *,int);
|
| 394 |
+
|
| 395 |
+
extern FORM_EXPORT(Field_Options) field_opts (const FIELD *);
|
| 396 |
+
|
| 397 |
+
/******************
|
| 398 |
+
* FORM routines *
|
| 399 |
+
******************/
|
| 400 |
+
|
| 401 |
+
extern FORM_EXPORT(FORM *) new_form (FIELD **);
|
| 402 |
+
|
| 403 |
+
extern FORM_EXPORT(FIELD **) form_fields (const FORM *);
|
| 404 |
+
extern FORM_EXPORT(FIELD *) current_field (const FORM *);
|
| 405 |
+
|
| 406 |
+
extern FORM_EXPORT(WINDOW *) form_win (const FORM *);
|
| 407 |
+
extern FORM_EXPORT(WINDOW *) form_sub (const FORM *);
|
| 408 |
+
|
| 409 |
+
extern FORM_EXPORT(Form_Hook) form_init (const FORM *);
|
| 410 |
+
extern FORM_EXPORT(Form_Hook) form_term (const FORM *);
|
| 411 |
+
extern FORM_EXPORT(Form_Hook) field_init (const FORM *);
|
| 412 |
+
extern FORM_EXPORT(Form_Hook) field_term (const FORM *);
|
| 413 |
+
|
| 414 |
+
extern FORM_EXPORT(int) free_form (FORM *);
|
| 415 |
+
extern FORM_EXPORT(int) set_form_fields (FORM *,FIELD **);
|
| 416 |
+
extern FORM_EXPORT(int) field_count (const FORM *);
|
| 417 |
+
extern FORM_EXPORT(int) set_form_win (FORM *,WINDOW *);
|
| 418 |
+
extern FORM_EXPORT(int) set_form_sub (FORM *,WINDOW *);
|
| 419 |
+
extern FORM_EXPORT(int) set_current_field (FORM *,FIELD *);
|
| 420 |
+
extern FORM_EXPORT(int) unfocus_current_field (FORM *);
|
| 421 |
+
extern FORM_EXPORT(int) field_index (const FIELD *);
|
| 422 |
+
extern FORM_EXPORT(int) set_form_page (FORM *,int);
|
| 423 |
+
extern FORM_EXPORT(int) form_page (const FORM *);
|
| 424 |
+
extern FORM_EXPORT(int) scale_form (const FORM *,int *,int *);
|
| 425 |
+
extern FORM_EXPORT(int) set_form_init (FORM *,Form_Hook);
|
| 426 |
+
extern FORM_EXPORT(int) set_form_term (FORM *,Form_Hook);
|
| 427 |
+
extern FORM_EXPORT(int) set_field_init (FORM *,Form_Hook);
|
| 428 |
+
extern FORM_EXPORT(int) set_field_term (FORM *,Form_Hook);
|
| 429 |
+
extern FORM_EXPORT(int) post_form (FORM *);
|
| 430 |
+
extern FORM_EXPORT(int) unpost_form (FORM *);
|
| 431 |
+
extern FORM_EXPORT(int) pos_form_cursor (FORM *);
|
| 432 |
+
extern FORM_EXPORT(int) form_driver (FORM *,int);
|
| 433 |
+
# if NCURSES_WIDECHAR
|
| 434 |
+
extern FORM_EXPORT(int) form_driver_w (FORM *,int,wchar_t);
|
| 435 |
+
# endif
|
| 436 |
+
extern FORM_EXPORT(int) set_form_userptr (FORM *,void *);
|
| 437 |
+
extern FORM_EXPORT(int) set_form_opts (FORM *,Form_Options);
|
| 438 |
+
extern FORM_EXPORT(int) form_opts_on (FORM *,Form_Options);
|
| 439 |
+
extern FORM_EXPORT(int) form_opts_off (FORM *,Form_Options);
|
| 440 |
+
extern FORM_EXPORT(int) form_request_by_name (const char *);
|
| 441 |
+
|
| 442 |
+
extern FORM_EXPORT(const char *) form_request_name (int);
|
| 443 |
+
|
| 444 |
+
extern FORM_EXPORT(void *) form_userptr (const FORM *);
|
| 445 |
+
|
| 446 |
+
extern FORM_EXPORT(Form_Options) form_opts (const FORM *);
|
| 447 |
+
|
| 448 |
+
extern FORM_EXPORT(bool) data_ahead (const FORM *);
|
| 449 |
+
extern FORM_EXPORT(bool) data_behind (const FORM *);
|
| 450 |
+
|
| 451 |
+
#if NCURSES_SP_FUNCS
|
| 452 |
+
extern FORM_EXPORT(FORM *) NCURSES_SP_NAME(new_form) (SCREEN*, FIELD **);
|
| 453 |
+
#endif
|
| 454 |
+
|
| 455 |
+
#ifdef __cplusplus
|
| 456 |
+
}
|
| 457 |
+
#endif
|
| 458 |
+
/* *INDENT-ON*/
|
| 459 |
+
|
| 460 |
+
#endif /* FORM_H */
|
llava_next/include/ncursesw/nc_tparm.h
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/****************************************************************************
|
| 2 |
+
* Copyright 2018,2020 Thomas E. Dickey *
|
| 3 |
+
* Copyright 2006-2012,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 2006 *
|
| 32 |
+
****************************************************************************/
|
| 33 |
+
|
| 34 |
+
/* $Id: nc_tparm.h,v 1.11 2020/05/27 23:33:31 tom Exp $ */
|
| 35 |
+
|
| 36 |
+
#ifndef NC_TPARM_included
|
| 37 |
+
#define NC_TPARM_included 1
|
| 38 |
+
|
| 39 |
+
#include <ncurses_cfg.h>
|
| 40 |
+
#include <ncursesw/curses.h>
|
| 41 |
+
|
| 42 |
+
/*
|
| 43 |
+
* Cast parameters past the formatting-string for tparm() to match the
|
| 44 |
+
* assumption of the varargs code.
|
| 45 |
+
*/
|
| 46 |
+
#ifndef TPARM_ARG
|
| 47 |
+
#ifdef NCURSES_TPARM_ARG
|
| 48 |
+
#define TPARM_ARG NCURSES_TPARM_ARG
|
| 49 |
+
#else
|
| 50 |
+
#define TPARM_ARG long
|
| 51 |
+
#endif
|
| 52 |
+
#endif /* TPARAM_ARG */
|
| 53 |
+
|
| 54 |
+
#define TPARM_N(n) (TPARM_ARG)(n)
|
| 55 |
+
|
| 56 |
+
#define TPARM_9(a,b,c,d,e,f,g,h,i,j) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e),TPARM_N(f),TPARM_N(g),TPARM_N(h),TPARM_N(i),TPARM_N(j))
|
| 57 |
+
|
| 58 |
+
#if NCURSES_TPARM_VARARGS
|
| 59 |
+
#define TPARM_8(a,b,c,d,e,f,g,h,i) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e),TPARM_N(f),TPARM_N(g),TPARM_N(h),TPARM_N(i))
|
| 60 |
+
#define TPARM_7(a,b,c,d,e,f,g,h) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e),TPARM_N(f),TPARM_N(g),TPARM_N(h))
|
| 61 |
+
#define TPARM_6(a,b,c,d,e,f,g) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e),TPARM_N(f),TPARM_N(g))
|
| 62 |
+
#define TPARM_5(a,b,c,d,e,f) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e),TPARM_N(f))
|
| 63 |
+
#define TPARM_4(a,b,c,d,e) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d),TPARM_N(e))
|
| 64 |
+
#define TPARM_3(a,b,c,d) tparm(a,TPARM_N(b),TPARM_N(c),TPARM_N(d))
|
| 65 |
+
#define TPARM_2(a,b,c) tparm(a,TPARM_N(b),TPARM_N(c))
|
| 66 |
+
#define TPARM_1(a,b) tparm(a,TPARM_N(b))
|
| 67 |
+
#define TPARM_0(a) tparm(a)
|
| 68 |
+
#else
|
| 69 |
+
#define TPARM_8(a,b,c,d,e,f,g,h,i) TPARM_9(a,b,c,d,e,f,g,h,i,0)
|
| 70 |
+
#define TPARM_7(a,b,c,d,e,f,g,h) TPARM_8(a,b,c,d,e,f,g,h,0)
|
| 71 |
+
#define TPARM_6(a,b,c,d,e,f,g) TPARM_7(a,b,c,d,e,f,g,0)
|
| 72 |
+
#define TPARM_5(a,b,c,d,e,f) TPARM_6(a,b,c,d,e,f,0)
|
| 73 |
+
#define TPARM_4(a,b,c,d,e) TPARM_5(a,b,c,d,e,0)
|
| 74 |
+
#define TPARM_3(a,b,c,d) TPARM_4(a,b,c,d,0)
|
| 75 |
+
#define TPARM_2(a,b,c) TPARM_3(a,b,c,0)
|
| 76 |
+
#define TPARM_1(a,b) TPARM_2(a,b,0)
|
| 77 |
+
#define TPARM_0(a) TPARM_1(a,0)
|
| 78 |
+
#endif
|
| 79 |
+
|
| 80 |
+
#ifdef NCURSES_INTERNALS
|
| 81 |
+
#define TIPARM_1(s,a) _nc_tiparm(1,s,a)
|
| 82 |
+
#define TIPARM_2(s,a,b) _nc_tiparm(2,s,a,b)
|
| 83 |
+
#define TIPARM_3(s,a,b,c) _nc_tiparm(3,s,a,b,c)
|
| 84 |
+
#define TIPARM_4(s,a,b,c,d) _nc_tiparm(4,s,a,b,c,d)
|
| 85 |
+
#define TIPARM_5(s,a,b,c,d,e) _nc_tiparm(5,s,a,b,c,d,e)
|
| 86 |
+
#define TIPARM_6(s,a,b,c,d,e,f) _nc_tiparm(6,s,a,b,c,d,e,f)
|
| 87 |
+
#define TIPARM_7(s,a,b,c,d,e,f,g) _nc_tiparm(7,s,a,b,c,d,e,f,g)
|
| 88 |
+
#define TIPARM_8(s,a,b,c,d,e,f,g,h) _nc_tiparm(8,s,a,b,c,d,e,f,g,h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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/****************************************************************************
|
| 2 |
+
* Copyright 2018-2020,2021 Thomas E. Dickey *
|
| 3 |
+
* Copyright 1998-2013,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: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 */
|
| 32 |
+
/* and: Eric S. Raymond <esr@snark.thyrsus.com> */
|
| 33 |
+
/* and: Thomas E. Dickey 1995-on */
|
| 34 |
+
/****************************************************************************/
|
| 35 |
+
|
| 36 |
+
/* $Id: MKterm.h.awk.in,v 1.82 2021/09/24 17:02:46 tom Exp $ */
|
| 37 |
+
|
| 38 |
+
/*
|
| 39 |
+
** term.h -- Definition of struct term
|
| 40 |
+
*/
|
| 41 |
+
|
| 42 |
+
#ifndef NCURSES_TERM_H_incl
|
| 43 |
+
#define NCURSES_TERM_H_incl 1
|
| 44 |
+
|
| 45 |
+
#undef NCURSES_VERSION
|
| 46 |
+
#define NCURSES_VERSION "6.4"
|
| 47 |
+
|
| 48 |
+
#include <ncursesw/ncurses_dll.h>
|
| 49 |
+
|
| 50 |
+
#ifdef __cplusplus
|
| 51 |
+
extern "C" {
|
| 52 |
+
#endif
|
| 53 |
+
|
| 54 |
+
/* Make this file self-contained by providing defaults for the HAVE_TERMIO[S]_H
|
| 55 |
+
* definition (based on the system for which this was configured).
|
| 56 |
+
*/
|
| 57 |
+
|
| 58 |
+
#ifndef __NCURSES_H
|
| 59 |
+
|
| 60 |
+
typedef struct screen SCREEN;
|
| 61 |
+
|
| 62 |
+
#if 1
|
| 63 |
+
#undef NCURSES_SP_FUNCS
|
| 64 |
+
#define NCURSES_SP_FUNCS 20221231
|
| 65 |
+
#undef NCURSES_SP_NAME
|
| 66 |
+
#define NCURSES_SP_NAME(name) name##_sp
|
| 67 |
+
|
| 68 |
+
/* Define the sp-funcs helper function */
|
| 69 |
+
#undef NCURSES_SP_OUTC
|
| 70 |
+
#define NCURSES_SP_OUTC NCURSES_SP_NAME(NCURSES_OUTC)
|
| 71 |
+
typedef int (*NCURSES_SP_OUTC)(SCREEN*, int);
|
| 72 |
+
#endif
|
| 73 |
+
|
| 74 |
+
#endif /* __NCURSES_H */
|
| 75 |
+
|
| 76 |
+
#undef NCURSES_CONST
|
| 77 |
+
#define NCURSES_CONST const
|
| 78 |
+
|
| 79 |
+
#undef NCURSES_SBOOL
|
| 80 |
+
#define NCURSES_SBOOL char
|
| 81 |
+
|
| 82 |
+
#undef NCURSES_USE_DATABASE
|
| 83 |
+
#define NCURSES_USE_DATABASE 1
|
| 84 |
+
|
| 85 |
+
#undef NCURSES_USE_TERMCAP
|
| 86 |
+
#define NCURSES_USE_TERMCAP 1
|
| 87 |
+
|
| 88 |
+
#undef NCURSES_XNAMES
|
| 89 |
+
#define NCURSES_XNAMES 1
|
| 90 |
+
|
| 91 |
+
/* We will use these symbols to hide differences between
|
| 92 |
+
* termios/termio/sgttyb interfaces.
|
| 93 |
+
*/
|
| 94 |
+
#undef TTY
|
| 95 |
+
#undef SET_TTY
|
| 96 |
+
#undef GET_TTY
|
| 97 |
+
|
| 98 |
+
/* Assume POSIX termio if we have the header and function */
|
| 99 |
+
/* #if HAVE_TERMIOS_H && HAVE_TCGETATTR */
|
| 100 |
+
#if 1 && 1
|
| 101 |
+
|
| 102 |
+
#undef TERMIOS
|
| 103 |
+
#define TERMIOS 1
|
| 104 |
+
|
| 105 |
+
#include <termios.h>
|
| 106 |
+
#define TTY struct termios
|
| 107 |
+
|
| 108 |
+
#else /* !HAVE_TERMIOS_H */
|
| 109 |
+
|
| 110 |
+
/* #if HAVE_TERMIO_H */
|
| 111 |
+
#if 1
|
| 112 |
+
|
| 113 |
+
#undef TERMIOS
|
| 114 |
+
#define TERMIOS 1
|
| 115 |
+
|
| 116 |
+
#include <termio.h>
|
| 117 |
+
#define TTY struct termio
|
| 118 |
+
|
| 119 |
+
#else /* !HAVE_TERMIO_H */
|
| 120 |
+
|
| 121 |
+
#if (defined(_WIN32) || defined(_WIN64))
|
| 122 |
+
#if 0
|
| 123 |
+
#include <ncursesw/win32_curses.h>
|
| 124 |
+
#define TTY struct winconmode
|
| 125 |
+
#else
|
| 126 |
+
#include <ncursesw/ncurses_mingw.h>
|
| 127 |
+
#define TTY struct termios
|
| 128 |
+
#endif
|
| 129 |
+
#else
|
| 130 |
+
#undef TERMIOS
|
| 131 |
+
#include <sgtty.h>
|
| 132 |
+
#include <sys/ioctl.h>
|
| 133 |
+
#define TTY struct sgttyb
|
| 134 |
+
#endif /* MINGW32 */
|
| 135 |
+
#endif /* HAVE_TERMIO_H */
|
| 136 |
+
|
| 137 |
+
#endif /* HAVE_TERMIOS_H */
|
| 138 |
+
|
| 139 |
+
#ifdef TERMIOS
|
| 140 |
+
#define GET_TTY(fd, buf) tcgetattr(fd, buf)
|
| 141 |
+
#define SET_TTY(fd, buf) tcsetattr(fd, TCSADRAIN, buf)
|
| 142 |
+
#elif 0 && (defined(_WIN32) || defined(_WIN64))
|
| 143 |
+
#define GET_TTY(fd, buf) _nc_console_getmode(_nc_console_fd2handle(fd),buf)
|
| 144 |
+
#define SET_TTY(fd, buf) _nc_console_setmode(_nc_console_fd2handle(fd),buf)
|
| 145 |
+
#else
|
| 146 |
+
#define GET_TTY(fd, buf) gtty(fd, buf)
|
| 147 |
+
#define SET_TTY(fd, buf) stty(fd, buf)
|
| 148 |
+
#endif
|
| 149 |
+
|
| 150 |
+
#ifndef GCC_NORETURN
|
| 151 |
+
#define GCC_NORETURN /* nothing */
|
| 152 |
+
#endif
|
| 153 |
+
|
| 154 |
+
#define NAMESIZE 256
|
| 155 |
+
|
| 156 |
+
/* The cast works because TERMTYPE is the first data in TERMINAL */
|
| 157 |
+
#define CUR ((TERMTYPE *)(cur_term))->
|
| 158 |
+
|
| 159 |
+
#define auto_left_margin CUR Booleans[0]
|
| 160 |
+
#define auto_right_margin CUR Booleans[1]
|
| 161 |
+
#define no_esc_ctlc CUR Booleans[2]
|
| 162 |
+
#define ceol_standout_glitch CUR Booleans[3]
|
| 163 |
+
#define eat_newline_glitch CUR Booleans[4]
|
| 164 |
+
#define erase_overstrike CUR Booleans[5]
|
| 165 |
+
#define generic_type CUR Booleans[6]
|
| 166 |
+
#define hard_copy CUR Booleans[7]
|
| 167 |
+
#define has_meta_key CUR Booleans[8]
|
| 168 |
+
#define has_status_line CUR Booleans[9]
|
| 169 |
+
#define insert_null_glitch CUR Booleans[10]
|
| 170 |
+
#define memory_above CUR Booleans[11]
|
| 171 |
+
#define memory_below CUR Booleans[12]
|
| 172 |
+
#define move_insert_mode CUR Booleans[13]
|
| 173 |
+
#define move_standout_mode CUR Booleans[14]
|
| 174 |
+
#define over_strike CUR Booleans[15]
|
| 175 |
+
#define status_line_esc_ok CUR Booleans[16]
|
| 176 |
+
#define dest_tabs_magic_smso CUR Booleans[17]
|
| 177 |
+
#define tilde_glitch CUR Booleans[18]
|
| 178 |
+
#define transparent_underline CUR Booleans[19]
|
| 179 |
+
#define xon_xoff CUR Booleans[20]
|
| 180 |
+
#define needs_xon_xoff CUR Booleans[21]
|
| 181 |
+
#define prtr_silent CUR Booleans[22]
|
| 182 |
+
#define hard_cursor CUR Booleans[23]
|
| 183 |
+
#define non_rev_rmcup CUR Booleans[24]
|
| 184 |
+
#define no_pad_char CUR Booleans[25]
|
| 185 |
+
#define non_dest_scroll_region CUR Booleans[26]
|
| 186 |
+
#define can_change CUR Booleans[27]
|
| 187 |
+
#define back_color_erase CUR Booleans[28]
|
| 188 |
+
#define hue_lightness_saturation CUR Booleans[29]
|
| 189 |
+
#define col_addr_glitch CUR Booleans[30]
|
| 190 |
+
#define cr_cancels_micro_mode CUR Booleans[31]
|
| 191 |
+
#define has_print_wheel CUR Booleans[32]
|
| 192 |
+
#define row_addr_glitch CUR Booleans[33]
|
| 193 |
+
#define semi_auto_right_margin CUR Booleans[34]
|
| 194 |
+
#define cpi_changes_res CUR Booleans[35]
|
| 195 |
+
#define lpi_changes_res CUR Booleans[36]
|
| 196 |
+
#define columns CUR Numbers[0]
|
| 197 |
+
#define init_tabs CUR Numbers[1]
|
| 198 |
+
#define lines CUR Numbers[2]
|
| 199 |
+
#define lines_of_memory CUR Numbers[3]
|
| 200 |
+
#define magic_cookie_glitch CUR Numbers[4]
|
| 201 |
+
#define padding_baud_rate CUR Numbers[5]
|
| 202 |
+
#define virtual_terminal CUR Numbers[6]
|
| 203 |
+
#define width_status_line CUR Numbers[7]
|
| 204 |
+
#define num_labels CUR Numbers[8]
|
| 205 |
+
#define label_height CUR Numbers[9]
|
| 206 |
+
#define label_width CUR Numbers[10]
|
| 207 |
+
#define max_attributes CUR Numbers[11]
|
| 208 |
+
#define maximum_windows CUR Numbers[12]
|
| 209 |
+
#define max_colors CUR Numbers[13]
|
| 210 |
+
#define max_pairs CUR Numbers[14]
|
| 211 |
+
#define no_color_video CUR Numbers[15]
|
| 212 |
+
#define buffer_capacity CUR Numbers[16]
|
| 213 |
+
#define dot_vert_spacing CUR Numbers[17]
|
| 214 |
+
#define dot_horz_spacing CUR Numbers[18]
|
| 215 |
+
#define max_micro_address CUR Numbers[19]
|
| 216 |
+
#define max_micro_jump CUR Numbers[20]
|
| 217 |
+
#define micro_col_size CUR Numbers[21]
|
| 218 |
+
#define micro_line_size CUR Numbers[22]
|
| 219 |
+
#define number_of_pins CUR Numbers[23]
|
| 220 |
+
#define output_res_char CUR Numbers[24]
|
| 221 |
+
#define output_res_line CUR Numbers[25]
|
| 222 |
+
#define output_res_horz_inch CUR Numbers[26]
|
| 223 |
+
#define output_res_vert_inch CUR Numbers[27]
|
| 224 |
+
#define print_rate CUR Numbers[28]
|
| 225 |
+
#define wide_char_size CUR Numbers[29]
|
| 226 |
+
#define buttons CUR Numbers[30]
|
| 227 |
+
#define bit_image_entwining CUR Numbers[31]
|
| 228 |
+
#define bit_image_type CUR Numbers[32]
|
| 229 |
+
#define back_tab CUR Strings[0]
|
| 230 |
+
#define bell CUR Strings[1]
|
| 231 |
+
#define carriage_return CUR Strings[2]
|
| 232 |
+
#define change_scroll_region CUR Strings[3]
|
| 233 |
+
#define clear_all_tabs CUR Strings[4]
|
| 234 |
+
#define clear_screen CUR Strings[5]
|
| 235 |
+
#define clr_eol CUR Strings[6]
|
| 236 |
+
#define clr_eos CUR Strings[7]
|
| 237 |
+
#define column_address CUR Strings[8]
|
| 238 |
+
#define command_character CUR Strings[9]
|
| 239 |
+
#define cursor_address CUR Strings[10]
|
| 240 |
+
#define cursor_down CUR Strings[11]
|
| 241 |
+
#define cursor_home CUR Strings[12]
|
| 242 |
+
#define cursor_invisible CUR Strings[13]
|
| 243 |
+
#define cursor_left CUR Strings[14]
|
| 244 |
+
#define cursor_mem_address CUR Strings[15]
|
| 245 |
+
#define cursor_normal CUR Strings[16]
|
| 246 |
+
#define cursor_right CUR Strings[17]
|
| 247 |
+
#define cursor_to_ll CUR Strings[18]
|
| 248 |
+
#define cursor_up CUR Strings[19]
|
| 249 |
+
#define cursor_visible CUR Strings[20]
|
| 250 |
+
#define delete_character CUR Strings[21]
|
| 251 |
+
#define delete_line CUR Strings[22]
|
| 252 |
+
#define dis_status_line CUR Strings[23]
|
| 253 |
+
#define down_half_line CUR Strings[24]
|
| 254 |
+
#define enter_alt_charset_mode CUR Strings[25]
|
| 255 |
+
#define enter_blink_mode CUR Strings[26]
|
| 256 |
+
#define enter_bold_mode CUR Strings[27]
|
| 257 |
+
#define enter_ca_mode CUR Strings[28]
|
| 258 |
+
#define enter_delete_mode CUR Strings[29]
|
| 259 |
+
#define enter_dim_mode CUR Strings[30]
|
| 260 |
+
#define enter_insert_mode CUR Strings[31]
|
| 261 |
+
#define enter_secure_mode CUR Strings[32]
|
| 262 |
+
#define enter_protected_mode CUR Strings[33]
|
| 263 |
+
#define enter_reverse_mode CUR Strings[34]
|
| 264 |
+
#define enter_standout_mode CUR Strings[35]
|
| 265 |
+
#define enter_underline_mode CUR Strings[36]
|
| 266 |
+
#define erase_chars CUR Strings[37]
|
| 267 |
+
#define exit_alt_charset_mode CUR Strings[38]
|
| 268 |
+
#define exit_attribute_mode CUR Strings[39]
|
| 269 |
+
#define exit_ca_mode CUR Strings[40]
|
| 270 |
+
#define exit_delete_mode CUR Strings[41]
|
| 271 |
+
#define exit_insert_mode CUR Strings[42]
|
| 272 |
+
#define exit_standout_mode CUR Strings[43]
|
| 273 |
+
#define exit_underline_mode CUR Strings[44]
|
| 274 |
+
#define flash_screen CUR Strings[45]
|
| 275 |
+
#define form_feed CUR Strings[46]
|
| 276 |
+
#define from_status_line CUR Strings[47]
|
| 277 |
+
#define init_1string CUR Strings[48]
|
| 278 |
+
#define init_2string CUR Strings[49]
|
| 279 |
+
#define init_3string CUR Strings[50]
|
| 280 |
+
#define init_file CUR Strings[51]
|
| 281 |
+
#define insert_character CUR Strings[52]
|
| 282 |
+
#define insert_line CUR Strings[53]
|
| 283 |
+
#define insert_padding CUR Strings[54]
|
| 284 |
+
#define key_backspace CUR Strings[55]
|
| 285 |
+
#define key_catab CUR Strings[56]
|
| 286 |
+
#define key_clear CUR Strings[57]
|
| 287 |
+
#define key_ctab CUR Strings[58]
|
| 288 |
+
#define key_dc CUR Strings[59]
|
| 289 |
+
#define key_dl CUR Strings[60]
|
| 290 |
+
#define key_down CUR Strings[61]
|
| 291 |
+
#define key_eic CUR Strings[62]
|
| 292 |
+
#define key_eol CUR Strings[63]
|
| 293 |
+
#define key_eos CUR Strings[64]
|
| 294 |
+
#define key_f0 CUR Strings[65]
|
| 295 |
+
#define key_f1 CUR Strings[66]
|
| 296 |
+
#define key_f10 CUR Strings[67]
|
| 297 |
+
#define key_f2 CUR Strings[68]
|
| 298 |
+
#define key_f3 CUR Strings[69]
|
| 299 |
+
#define key_f4 CUR Strings[70]
|
| 300 |
+
#define key_f5 CUR Strings[71]
|
| 301 |
+
#define key_f6 CUR Strings[72]
|
| 302 |
+
#define key_f7 CUR Strings[73]
|
| 303 |
+
#define key_f8 CUR Strings[74]
|
| 304 |
+
#define key_f9 CUR Strings[75]
|
| 305 |
+
#define key_home CUR Strings[76]
|
| 306 |
+
#define key_ic CUR Strings[77]
|
| 307 |
+
#define key_il CUR Strings[78]
|
| 308 |
+
#define key_left CUR Strings[79]
|
| 309 |
+
#define key_ll CUR Strings[80]
|
| 310 |
+
#define key_npage CUR Strings[81]
|
| 311 |
+
#define key_ppage CUR Strings[82]
|
| 312 |
+
#define key_right CUR Strings[83]
|
| 313 |
+
#define key_sf CUR Strings[84]
|
| 314 |
+
#define key_sr CUR Strings[85]
|
| 315 |
+
#define key_stab CUR Strings[86]
|
| 316 |
+
#define key_up CUR Strings[87]
|
| 317 |
+
#define keypad_local CUR Strings[88]
|
| 318 |
+
#define keypad_xmit CUR Strings[89]
|
| 319 |
+
#define lab_f0 CUR Strings[90]
|
| 320 |
+
#define lab_f1 CUR Strings[91]
|
| 321 |
+
#define lab_f10 CUR Strings[92]
|
| 322 |
+
#define lab_f2 CUR Strings[93]
|
| 323 |
+
#define lab_f3 CUR Strings[94]
|
| 324 |
+
#define lab_f4 CUR Strings[95]
|
| 325 |
+
#define lab_f5 CUR Strings[96]
|
| 326 |
+
#define lab_f6 CUR Strings[97]
|
| 327 |
+
#define lab_f7 CUR Strings[98]
|
| 328 |
+
#define lab_f8 CUR Strings[99]
|
| 329 |
+
#define lab_f9 CUR Strings[100]
|
| 330 |
+
#define meta_off CUR Strings[101]
|
| 331 |
+
#define meta_on CUR Strings[102]
|
| 332 |
+
#define newline CUR Strings[103]
|
| 333 |
+
#define pad_char CUR Strings[104]
|
| 334 |
+
#define parm_dch CUR Strings[105]
|
| 335 |
+
#define parm_delete_line CUR Strings[106]
|
| 336 |
+
#define parm_down_cursor CUR Strings[107]
|
| 337 |
+
#define parm_ich CUR Strings[108]
|
| 338 |
+
#define parm_index CUR Strings[109]
|
| 339 |
+
#define parm_insert_line CUR Strings[110]
|
| 340 |
+
#define parm_left_cursor CUR Strings[111]
|
| 341 |
+
#define parm_right_cursor CUR Strings[112]
|
| 342 |
+
#define parm_rindex CUR Strings[113]
|
| 343 |
+
#define parm_up_cursor CUR Strings[114]
|
| 344 |
+
#define pkey_key CUR Strings[115]
|
| 345 |
+
#define pkey_local CUR Strings[116]
|
| 346 |
+
#define pkey_xmit CUR Strings[117]
|
| 347 |
+
#define print_screen CUR Strings[118]
|
| 348 |
+
#define prtr_off CUR Strings[119]
|
| 349 |
+
#define prtr_on CUR Strings[120]
|
| 350 |
+
#define repeat_char CUR Strings[121]
|
| 351 |
+
#define reset_1string CUR Strings[122]
|
| 352 |
+
#define reset_2string CUR Strings[123]
|
| 353 |
+
#define reset_3string CUR Strings[124]
|
| 354 |
+
#define reset_file CUR Strings[125]
|
| 355 |
+
#define restore_cursor CUR Strings[126]
|
| 356 |
+
#define row_address CUR Strings[127]
|
| 357 |
+
#define save_cursor CUR Strings[128]
|
| 358 |
+
#define scroll_forward CUR Strings[129]
|
| 359 |
+
#define scroll_reverse CUR Strings[130]
|
| 360 |
+
#define set_attributes CUR Strings[131]
|
| 361 |
+
#define set_tab CUR Strings[132]
|
| 362 |
+
#define set_window CUR Strings[133]
|
| 363 |
+
#define tab CUR Strings[134]
|
| 364 |
+
#define to_status_line CUR Strings[135]
|
| 365 |
+
#define underline_char CUR Strings[136]
|
| 366 |
+
#define up_half_line CUR Strings[137]
|
| 367 |
+
#define init_prog CUR Strings[138]
|
| 368 |
+
#define key_a1 CUR Strings[139]
|
| 369 |
+
#define key_a3 CUR Strings[140]
|
| 370 |
+
#define key_b2 CUR Strings[141]
|
| 371 |
+
#define key_c1 CUR Strings[142]
|
| 372 |
+
#define key_c3 CUR Strings[143]
|
| 373 |
+
#define prtr_non CUR Strings[144]
|
| 374 |
+
#define char_padding CUR Strings[145]
|
| 375 |
+
#define acs_chars CUR Strings[146]
|
| 376 |
+
#define plab_norm CUR Strings[147]
|
| 377 |
+
#define key_btab CUR Strings[148]
|
| 378 |
+
#define enter_xon_mode CUR Strings[149]
|
| 379 |
+
#define exit_xon_mode CUR Strings[150]
|
| 380 |
+
#define enter_am_mode CUR Strings[151]
|
| 381 |
+
#define exit_am_mode CUR Strings[152]
|
| 382 |
+
#define xon_character CUR Strings[153]
|
| 383 |
+
#define xoff_character CUR Strings[154]
|
| 384 |
+
#define ena_acs CUR Strings[155]
|
| 385 |
+
#define label_on CUR Strings[156]
|
| 386 |
+
#define label_off CUR Strings[157]
|
| 387 |
+
#define key_beg CUR Strings[158]
|
| 388 |
+
#define key_cancel CUR Strings[159]
|
| 389 |
+
#define key_close CUR Strings[160]
|
| 390 |
+
#define key_command CUR Strings[161]
|
| 391 |
+
#define key_copy CUR Strings[162]
|
| 392 |
+
#define key_create CUR Strings[163]
|
| 393 |
+
#define key_end CUR Strings[164]
|
| 394 |
+
#define key_enter CUR Strings[165]
|
| 395 |
+
#define key_exit CUR Strings[166]
|
| 396 |
+
#define key_find CUR Strings[167]
|
| 397 |
+
#define key_help CUR Strings[168]
|
| 398 |
+
#define key_mark CUR Strings[169]
|
| 399 |
+
#define key_message CUR Strings[170]
|
| 400 |
+
#define key_move CUR Strings[171]
|
| 401 |
+
#define key_next CUR Strings[172]
|
| 402 |
+
#define key_open CUR Strings[173]
|
| 403 |
+
#define key_options CUR Strings[174]
|
| 404 |
+
#define key_previous CUR Strings[175]
|
| 405 |
+
#define key_print CUR Strings[176]
|
| 406 |
+
#define key_redo CUR Strings[177]
|
| 407 |
+
#define key_reference CUR Strings[178]
|
| 408 |
+
#define key_refresh CUR Strings[179]
|
| 409 |
+
#define key_replace CUR Strings[180]
|
| 410 |
+
#define key_restart CUR Strings[181]
|
| 411 |
+
#define key_resume CUR Strings[182]
|
| 412 |
+
#define key_save CUR Strings[183]
|
| 413 |
+
#define key_suspend CUR Strings[184]
|
| 414 |
+
#define key_undo CUR Strings[185]
|
| 415 |
+
#define key_sbeg CUR Strings[186]
|
| 416 |
+
#define key_scancel CUR Strings[187]
|
| 417 |
+
#define key_scommand CUR Strings[188]
|
| 418 |
+
#define key_scopy CUR Strings[189]
|
| 419 |
+
#define key_screate CUR Strings[190]
|
| 420 |
+
#define key_sdc CUR Strings[191]
|
| 421 |
+
#define key_sdl CUR Strings[192]
|
| 422 |
+
#define key_select CUR Strings[193]
|
| 423 |
+
#define key_send CUR Strings[194]
|
| 424 |
+
#define key_seol CUR Strings[195]
|
| 425 |
+
#define key_sexit CUR Strings[196]
|
| 426 |
+
#define key_sfind CUR Strings[197]
|
| 427 |
+
#define key_shelp CUR Strings[198]
|
| 428 |
+
#define key_shome CUR Strings[199]
|
| 429 |
+
#define key_sic CUR Strings[200]
|
| 430 |
+
#define key_sleft CUR Strings[201]
|
| 431 |
+
#define key_smessage CUR Strings[202]
|
| 432 |
+
#define key_smove CUR Strings[203]
|
| 433 |
+
#define key_snext CUR Strings[204]
|
| 434 |
+
#define key_soptions CUR Strings[205]
|
| 435 |
+
#define key_sprevious CUR Strings[206]
|
| 436 |
+
#define key_sprint CUR Strings[207]
|
| 437 |
+
#define key_sredo CUR Strings[208]
|
| 438 |
+
#define key_sreplace CUR Strings[209]
|
| 439 |
+
#define key_sright CUR Strings[210]
|
| 440 |
+
#define key_srsume CUR Strings[211]
|
| 441 |
+
#define key_ssave CUR Strings[212]
|
| 442 |
+
#define key_ssuspend CUR Strings[213]
|
| 443 |
+
#define key_sundo CUR Strings[214]
|
| 444 |
+
#define req_for_input CUR Strings[215]
|
| 445 |
+
#define key_f11 CUR Strings[216]
|
| 446 |
+
#define key_f12 CUR Strings[217]
|
| 447 |
+
#define key_f13 CUR Strings[218]
|
| 448 |
+
#define key_f14 CUR Strings[219]
|
| 449 |
+
#define key_f15 CUR Strings[220]
|
| 450 |
+
#define key_f16 CUR Strings[221]
|
| 451 |
+
#define key_f17 CUR Strings[222]
|
| 452 |
+
#define key_f18 CUR Strings[223]
|
| 453 |
+
#define key_f19 CUR Strings[224]
|
| 454 |
+
#define key_f20 CUR Strings[225]
|
| 455 |
+
#define key_f21 CUR Strings[226]
|
| 456 |
+
#define key_f22 CUR Strings[227]
|
| 457 |
+
#define key_f23 CUR Strings[228]
|
| 458 |
+
#define key_f24 CUR Strings[229]
|
| 459 |
+
#define key_f25 CUR Strings[230]
|
| 460 |
+
#define key_f26 CUR Strings[231]
|
| 461 |
+
#define key_f27 CUR Strings[232]
|
| 462 |
+
#define key_f28 CUR Strings[233]
|
| 463 |
+
#define key_f29 CUR Strings[234]
|
| 464 |
+
#define key_f30 CUR Strings[235]
|
| 465 |
+
#define key_f31 CUR Strings[236]
|
| 466 |
+
#define key_f32 CUR Strings[237]
|
| 467 |
+
#define key_f33 CUR Strings[238]
|
| 468 |
+
#define key_f34 CUR Strings[239]
|
| 469 |
+
#define key_f35 CUR Strings[240]
|
| 470 |
+
#define key_f36 CUR Strings[241]
|
| 471 |
+
#define key_f37 CUR Strings[242]
|
| 472 |
+
#define key_f38 CUR Strings[243]
|
| 473 |
+
#define key_f39 CUR Strings[244]
|
| 474 |
+
#define key_f40 CUR Strings[245]
|
| 475 |
+
#define key_f41 CUR Strings[246]
|
| 476 |
+
#define key_f42 CUR Strings[247]
|
| 477 |
+
#define key_f43 CUR Strings[248]
|
| 478 |
+
#define key_f44 CUR Strings[249]
|
| 479 |
+
#define key_f45 CUR Strings[250]
|
| 480 |
+
#define key_f46 CUR Strings[251]
|
| 481 |
+
#define key_f47 CUR Strings[252]
|
| 482 |
+
#define key_f48 CUR Strings[253]
|
| 483 |
+
#define key_f49 CUR Strings[254]
|
| 484 |
+
#define key_f50 CUR Strings[255]
|
| 485 |
+
#define key_f51 CUR Strings[256]
|
| 486 |
+
#define key_f52 CUR Strings[257]
|
| 487 |
+
#define key_f53 CUR Strings[258]
|
| 488 |
+
#define key_f54 CUR Strings[259]
|
| 489 |
+
#define key_f55 CUR Strings[260]
|
| 490 |
+
#define key_f56 CUR Strings[261]
|
| 491 |
+
#define key_f57 CUR Strings[262]
|
| 492 |
+
#define key_f58 CUR Strings[263]
|
| 493 |
+
#define key_f59 CUR Strings[264]
|
| 494 |
+
#define key_f60 CUR Strings[265]
|
| 495 |
+
#define key_f61 CUR Strings[266]
|
| 496 |
+
#define key_f62 CUR Strings[267]
|
| 497 |
+
#define key_f63 CUR Strings[268]
|
| 498 |
+
#define clr_bol CUR Strings[269]
|
| 499 |
+
#define clear_margins CUR Strings[270]
|
| 500 |
+
#define set_left_margin CUR Strings[271]
|
| 501 |
+
#define set_right_margin CUR Strings[272]
|
| 502 |
+
#define label_format CUR Strings[273]
|
| 503 |
+
#define set_clock CUR Strings[274]
|
| 504 |
+
#define display_clock CUR Strings[275]
|
| 505 |
+
#define remove_clock CUR Strings[276]
|
| 506 |
+
#define create_window CUR Strings[277]
|
| 507 |
+
#define goto_window CUR Strings[278]
|
| 508 |
+
#define hangup CUR Strings[279]
|
| 509 |
+
#define dial_phone CUR Strings[280]
|
| 510 |
+
#define quick_dial CUR Strings[281]
|
| 511 |
+
#define tone CUR Strings[282]
|
| 512 |
+
#define pulse CUR Strings[283]
|
| 513 |
+
#define flash_hook CUR Strings[284]
|
| 514 |
+
#define fixed_pause CUR Strings[285]
|
| 515 |
+
#define wait_tone CUR Strings[286]
|
| 516 |
+
#define user0 CUR Strings[287]
|
| 517 |
+
#define user1 CUR Strings[288]
|
| 518 |
+
#define user2 CUR Strings[289]
|
| 519 |
+
#define user3 CUR Strings[290]
|
| 520 |
+
#define user4 CUR Strings[291]
|
| 521 |
+
#define user5 CUR Strings[292]
|
| 522 |
+
#define user6 CUR Strings[293]
|
| 523 |
+
#define user7 CUR Strings[294]
|
| 524 |
+
#define user8 CUR Strings[295]
|
| 525 |
+
#define user9 CUR Strings[296]
|
| 526 |
+
#define orig_pair CUR Strings[297]
|
| 527 |
+
#define orig_colors CUR Strings[298]
|
| 528 |
+
#define initialize_color CUR Strings[299]
|
| 529 |
+
#define initialize_pair CUR Strings[300]
|
| 530 |
+
#define set_color_pair CUR Strings[301]
|
| 531 |
+
#define set_foreground CUR Strings[302]
|
| 532 |
+
#define set_background CUR Strings[303]
|
| 533 |
+
#define change_char_pitch CUR Strings[304]
|
| 534 |
+
#define change_line_pitch CUR Strings[305]
|
| 535 |
+
#define change_res_horz CUR Strings[306]
|
| 536 |
+
#define change_res_vert CUR Strings[307]
|
| 537 |
+
#define define_char CUR Strings[308]
|
| 538 |
+
#define enter_doublewide_mode CUR Strings[309]
|
| 539 |
+
#define enter_draft_quality CUR Strings[310]
|
| 540 |
+
#define enter_italics_mode CUR Strings[311]
|
| 541 |
+
#define enter_leftward_mode CUR Strings[312]
|
| 542 |
+
#define enter_micro_mode CUR Strings[313]
|
| 543 |
+
#define enter_near_letter_quality CUR Strings[314]
|
| 544 |
+
#define enter_normal_quality CUR Strings[315]
|
| 545 |
+
#define enter_shadow_mode CUR Strings[316]
|
| 546 |
+
#define enter_subscript_mode CUR Strings[317]
|
| 547 |
+
#define enter_superscript_mode CUR Strings[318]
|
| 548 |
+
#define enter_upward_mode CUR Strings[319]
|
| 549 |
+
#define exit_doublewide_mode CUR Strings[320]
|
| 550 |
+
#define exit_italics_mode CUR Strings[321]
|
| 551 |
+
#define exit_leftward_mode CUR Strings[322]
|
| 552 |
+
#define exit_micro_mode CUR Strings[323]
|
| 553 |
+
#define exit_shadow_mode CUR Strings[324]
|
| 554 |
+
#define exit_subscript_mode CUR Strings[325]
|
| 555 |
+
#define exit_superscript_mode CUR Strings[326]
|
| 556 |
+
#define exit_upward_mode CUR Strings[327]
|
| 557 |
+
#define micro_column_address CUR Strings[328]
|
| 558 |
+
#define micro_down CUR Strings[329]
|
| 559 |
+
#define micro_left CUR Strings[330]
|
| 560 |
+
#define micro_right CUR Strings[331]
|
| 561 |
+
#define micro_row_address CUR Strings[332]
|
| 562 |
+
#define micro_up CUR Strings[333]
|
| 563 |
+
#define order_of_pins CUR Strings[334]
|
| 564 |
+
#define parm_down_micro CUR Strings[335]
|
| 565 |
+
#define parm_left_micro CUR Strings[336]
|
| 566 |
+
#define parm_right_micro CUR Strings[337]
|
| 567 |
+
#define parm_up_micro CUR Strings[338]
|
| 568 |
+
#define select_char_set CUR Strings[339]
|
| 569 |
+
#define set_bottom_margin CUR Strings[340]
|
| 570 |
+
#define set_bottom_margin_parm CUR Strings[341]
|
| 571 |
+
#define set_left_margin_parm CUR Strings[342]
|
| 572 |
+
#define set_right_margin_parm CUR Strings[343]
|
| 573 |
+
#define set_top_margin CUR Strings[344]
|
| 574 |
+
#define set_top_margin_parm CUR Strings[345]
|
| 575 |
+
#define start_bit_image CUR Strings[346]
|
| 576 |
+
#define start_char_set_def CUR Strings[347]
|
| 577 |
+
#define stop_bit_image CUR Strings[348]
|
| 578 |
+
#define stop_char_set_def CUR Strings[349]
|
| 579 |
+
#define subscript_characters CUR Strings[350]
|
| 580 |
+
#define superscript_characters CUR Strings[351]
|
| 581 |
+
#define these_cause_cr CUR Strings[352]
|
| 582 |
+
#define zero_motion CUR Strings[353]
|
| 583 |
+
#define char_set_names CUR Strings[354]
|
| 584 |
+
#define key_mouse CUR Strings[355]
|
| 585 |
+
#define mouse_info CUR Strings[356]
|
| 586 |
+
#define req_mouse_pos CUR Strings[357]
|
| 587 |
+
#define get_mouse CUR Strings[358]
|
| 588 |
+
#define set_a_foreground CUR Strings[359]
|
| 589 |
+
#define set_a_background CUR Strings[360]
|
| 590 |
+
#define pkey_plab CUR Strings[361]
|
| 591 |
+
#define device_type CUR Strings[362]
|
| 592 |
+
#define code_set_init CUR Strings[363]
|
| 593 |
+
#define set0_des_seq CUR Strings[364]
|
| 594 |
+
#define set1_des_seq CUR Strings[365]
|
| 595 |
+
#define set2_des_seq CUR Strings[366]
|
| 596 |
+
#define set3_des_seq CUR Strings[367]
|
| 597 |
+
#define set_lr_margin CUR Strings[368]
|
| 598 |
+
#define set_tb_margin CUR Strings[369]
|
| 599 |
+
#define bit_image_repeat CUR Strings[370]
|
| 600 |
+
#define bit_image_newline CUR Strings[371]
|
| 601 |
+
#define bit_image_carriage_return CUR Strings[372]
|
| 602 |
+
#define color_names CUR Strings[373]
|
| 603 |
+
#define define_bit_image_region CUR Strings[374]
|
| 604 |
+
#define end_bit_image_region CUR Strings[375]
|
| 605 |
+
#define set_color_band CUR Strings[376]
|
| 606 |
+
#define set_page_length CUR Strings[377]
|
| 607 |
+
#define display_pc_char CUR Strings[378]
|
| 608 |
+
#define enter_pc_charset_mode CUR Strings[379]
|
| 609 |
+
#define exit_pc_charset_mode CUR Strings[380]
|
| 610 |
+
#define enter_scancode_mode CUR Strings[381]
|
| 611 |
+
#define exit_scancode_mode CUR Strings[382]
|
| 612 |
+
#define pc_term_options CUR Strings[383]
|
| 613 |
+
#define scancode_escape CUR Strings[384]
|
| 614 |
+
#define alt_scancode_esc CUR Strings[385]
|
| 615 |
+
#define enter_horizontal_hl_mode CUR Strings[386]
|
| 616 |
+
#define enter_left_hl_mode CUR Strings[387]
|
| 617 |
+
#define enter_low_hl_mode CUR Strings[388]
|
| 618 |
+
#define enter_right_hl_mode CUR Strings[389]
|
| 619 |
+
#define enter_top_hl_mode CUR Strings[390]
|
| 620 |
+
#define enter_vertical_hl_mode CUR Strings[391]
|
| 621 |
+
#define set_a_attributes CUR Strings[392]
|
| 622 |
+
#define set_pglen_inch CUR Strings[393]
|
| 623 |
+
|
| 624 |
+
#define BOOLWRITE 37
|
| 625 |
+
#define NUMWRITE 33
|
| 626 |
+
#define STRWRITE 394
|
| 627 |
+
|
| 628 |
+
/* older synonyms for some capabilities */
|
| 629 |
+
#define beehive_glitch no_esc_ctlc
|
| 630 |
+
#define teleray_glitch dest_tabs_magic_smso
|
| 631 |
+
|
| 632 |
+
/* HPUX-11 uses this name rather than the standard one */
|
| 633 |
+
#ifndef micro_char_size
|
| 634 |
+
#define micro_char_size micro_col_size
|
| 635 |
+
#endif
|
| 636 |
+
|
| 637 |
+
#ifdef __INTERNAL_CAPS_VISIBLE
|
| 638 |
+
#define termcap_init2 CUR Strings[394]
|
| 639 |
+
#define termcap_reset CUR Strings[395]
|
| 640 |
+
#define magic_cookie_glitch_ul CUR Numbers[33]
|
| 641 |
+
#define backspaces_with_bs CUR Booleans[37]
|
| 642 |
+
#define crt_no_scrolling CUR Booleans[38]
|
| 643 |
+
#define no_correctly_working_cr CUR Booleans[39]
|
| 644 |
+
#define carriage_return_delay CUR Numbers[34]
|
| 645 |
+
#define new_line_delay CUR Numbers[35]
|
| 646 |
+
#define linefeed_if_not_lf CUR Strings[396]
|
| 647 |
+
#define backspace_if_not_bs CUR Strings[397]
|
| 648 |
+
#define gnu_has_meta_key CUR Booleans[40]
|
| 649 |
+
#define linefeed_is_newline CUR Booleans[41]
|
| 650 |
+
#define backspace_delay CUR Numbers[36]
|
| 651 |
+
#define horizontal_tab_delay CUR Numbers[37]
|
| 652 |
+
#define number_of_function_keys CUR Numbers[38]
|
| 653 |
+
#define other_non_function_keys CUR Strings[398]
|
| 654 |
+
#define arrow_key_map CUR Strings[399]
|
| 655 |
+
#define has_hardware_tabs CUR Booleans[42]
|
| 656 |
+
#define return_does_clr_eol CUR Booleans[43]
|
| 657 |
+
#define acs_ulcorner CUR Strings[400]
|
| 658 |
+
#define acs_llcorner CUR Strings[401]
|
| 659 |
+
#define acs_urcorner CUR Strings[402]
|
| 660 |
+
#define acs_lrcorner CUR Strings[403]
|
| 661 |
+
#define acs_ltee CUR Strings[404]
|
| 662 |
+
#define acs_rtee CUR Strings[405]
|
| 663 |
+
#define acs_btee CUR Strings[406]
|
| 664 |
+
#define acs_ttee CUR Strings[407]
|
| 665 |
+
#define acs_hline CUR Strings[408]
|
| 666 |
+
#define acs_vline CUR Strings[409]
|
| 667 |
+
#define acs_plus CUR Strings[410]
|
| 668 |
+
#define memory_lock CUR Strings[411]
|
| 669 |
+
#define memory_unlock CUR Strings[412]
|
| 670 |
+
#define box_chars_1 CUR Strings[413]
|
| 671 |
+
#endif /* __INTERNAL_CAPS_VISIBLE */
|
| 672 |
+
|
| 673 |
+
|
| 674 |
+
/*
|
| 675 |
+
* Predefined terminfo array sizes
|
| 676 |
+
*/
|
| 677 |
+
#define BOOLCOUNT 44
|
| 678 |
+
#define NUMCOUNT 39
|
| 679 |
+
#define STRCOUNT 414
|
| 680 |
+
|
| 681 |
+
/* used by code for comparing entries */
|
| 682 |
+
#define acs_chars_index 146
|
| 683 |
+
|
| 684 |
+
typedef struct termtype { /* in-core form of terminfo data */
|
| 685 |
+
char *term_names; /* str_table offset of term names */
|
| 686 |
+
char *str_table; /* pointer to string table */
|
| 687 |
+
NCURSES_SBOOL *Booleans; /* array of boolean values */
|
| 688 |
+
short *Numbers; /* array of integer values */
|
| 689 |
+
char **Strings; /* array of string offsets */
|
| 690 |
+
|
| 691 |
+
#if NCURSES_XNAMES
|
| 692 |
+
char *ext_str_table; /* pointer to extended string table */
|
| 693 |
+
char **ext_Names; /* corresponding names */
|
| 694 |
+
|
| 695 |
+
unsigned short num_Booleans;/* count total Booleans */
|
| 696 |
+
unsigned short num_Numbers; /* count total Numbers */
|
| 697 |
+
unsigned short num_Strings; /* count total Strings */
|
| 698 |
+
|
| 699 |
+
unsigned short ext_Booleans;/* count extensions to Booleans */
|
| 700 |
+
unsigned short ext_Numbers; /* count extensions to Numbers */
|
| 701 |
+
unsigned short ext_Strings; /* count extensions to Strings */
|
| 702 |
+
#endif /* NCURSES_XNAMES */
|
| 703 |
+
|
| 704 |
+
} TERMTYPE;
|
| 705 |
+
|
| 706 |
+
/*
|
| 707 |
+
* The only reason these structures are visible is for read-only use.
|
| 708 |
+
* Programs which modify the data are not, never were, portable across
|
| 709 |
+
* curses implementations.
|
| 710 |
+
*
|
| 711 |
+
* The first field in TERMINAL is used in macros.
|
| 712 |
+
* The remaining fields are private.
|
| 713 |
+
*/
|
| 714 |
+
#ifdef NCURSES_INTERNALS
|
| 715 |
+
|
| 716 |
+
#undef TERMINAL
|
| 717 |
+
#define TERMINAL struct term
|
| 718 |
+
TERMINAL;
|
| 719 |
+
|
| 720 |
+
typedef struct termtype2 { /* in-core form of terminfo data */
|
| 721 |
+
char *term_names; /* str_table offset of term names */
|
| 722 |
+
char *str_table; /* pointer to string table */
|
| 723 |
+
NCURSES_SBOOL *Booleans; /* array of boolean values */
|
| 724 |
+
int *Numbers; /* array of integer values */
|
| 725 |
+
char **Strings; /* array of string offsets */
|
| 726 |
+
|
| 727 |
+
#if NCURSES_XNAMES
|
| 728 |
+
char *ext_str_table; /* pointer to extended string table */
|
| 729 |
+
char **ext_Names; /* corresponding names */
|
| 730 |
+
|
| 731 |
+
unsigned short num_Booleans;/* count total Booleans */
|
| 732 |
+
unsigned short num_Numbers; /* count total Numbers */
|
| 733 |
+
unsigned short num_Strings; /* count total Strings */
|
| 734 |
+
|
| 735 |
+
unsigned short ext_Booleans;/* count extensions to Booleans */
|
| 736 |
+
unsigned short ext_Numbers; /* count extensions to Numbers */
|
| 737 |
+
unsigned short ext_Strings; /* count extensions to Strings */
|
| 738 |
+
#endif /* NCURSES_XNAMES */
|
| 739 |
+
|
| 740 |
+
} TERMTYPE2;
|
| 741 |
+
#else
|
| 742 |
+
|
| 743 |
+
typedef struct term { /* describe an actual terminal */
|
| 744 |
+
TERMTYPE type; /* terminal type description */
|
| 745 |
+
} TERMINAL;
|
| 746 |
+
|
| 747 |
+
#endif /* NCURSES_INTERNALS */
|
| 748 |
+
|
| 749 |
+
|
| 750 |
+
#if 0 && !0
|
| 751 |
+
extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;
|
| 752 |
+
#elif 0
|
| 753 |
+
NCURSES_WRAPPED_VAR(TERMINAL *, cur_term);
|
| 754 |
+
#define cur_term NCURSES_PUBLIC_VAR(cur_term())
|
| 755 |
+
#else
|
| 756 |
+
extern NCURSES_EXPORT_VAR(TERMINAL *) cur_term;
|
| 757 |
+
#endif
|
| 758 |
+
|
| 759 |
+
#if 0 || 0
|
| 760 |
+
NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolnames);
|
| 761 |
+
NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolcodes);
|
| 762 |
+
NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, boolfnames);
|
| 763 |
+
NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numnames);
|
| 764 |
+
NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numcodes);
|
| 765 |
+
NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, numfnames);
|
| 766 |
+
NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strnames);
|
| 767 |
+
NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strcodes);
|
| 768 |
+
NCURSES_WRAPPED_VAR(NCURSES_CONST char * const *, strfnames);
|
| 769 |
+
|
| 770 |
+
#define boolnames NCURSES_PUBLIC_VAR(boolnames())
|
| 771 |
+
#define boolcodes NCURSES_PUBLIC_VAR(boolcodes())
|
| 772 |
+
#define boolfnames NCURSES_PUBLIC_VAR(boolfnames())
|
| 773 |
+
#define numnames NCURSES_PUBLIC_VAR(numnames())
|
| 774 |
+
#define numcodes NCURSES_PUBLIC_VAR(numcodes())
|
| 775 |
+
#define numfnames NCURSES_PUBLIC_VAR(numfnames())
|
| 776 |
+
#define strnames NCURSES_PUBLIC_VAR(strnames())
|
| 777 |
+
#define strcodes NCURSES_PUBLIC_VAR(strcodes())
|
| 778 |
+
#define strfnames NCURSES_PUBLIC_VAR(strfnames())
|
| 779 |
+
|
| 780 |
+
#else
|
| 781 |
+
|
| 782 |
+
extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolnames[];
|
| 783 |
+
extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolcodes[];
|
| 784 |
+
extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) boolfnames[];
|
| 785 |
+
extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numnames[];
|
| 786 |
+
extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numcodes[];
|
| 787 |
+
extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) numfnames[];
|
| 788 |
+
extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strnames[];
|
| 789 |
+
extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strcodes[];
|
| 790 |
+
extern NCURSES_EXPORT_VAR(NCURSES_CONST char * const ) strfnames[];
|
| 791 |
+
|
| 792 |
+
#endif
|
| 793 |
+
|
| 794 |
+
/*
|
| 795 |
+
* These entrypoints are used only by the ncurses utilities such as tic.
|
| 796 |
+
*/
|
| 797 |
+
#ifdef NCURSES_INTERNALS
|
| 798 |
+
|
| 799 |
+
extern NCURSES_EXPORT(int) _nc_set_tty_mode (TTY *buf);
|
| 800 |
+
extern NCURSES_EXPORT(int) _nc_read_entry2 (const char * const, char * const, TERMTYPE2 *const);
|
| 801 |
+
extern NCURSES_EXPORT(int) _nc_read_file_entry (const char *const, TERMTYPE2 *);
|
| 802 |
+
extern NCURSES_EXPORT(int) _nc_read_termtype (TERMTYPE2 *, char *, int);
|
| 803 |
+
extern NCURSES_EXPORT(char *) _nc_first_name (const char *const);
|
| 804 |
+
extern NCURSES_EXPORT(int) _nc_name_match (const char *const, const char *const, const char *const);
|
| 805 |
+
extern NCURSES_EXPORT(char *) _nc_tiparm(int, const char *, ...);
|
| 806 |
+
|
| 807 |
+
#endif /* NCURSES_INTERNALS */
|
| 808 |
+
|
| 809 |
+
|
| 810 |
+
/*
|
| 811 |
+
* These entrypoints are used by tack 1.07.
|
| 812 |
+
*/
|
| 813 |
+
extern NCURSES_EXPORT(const TERMTYPE *) _nc_fallback (const char *);
|
| 814 |
+
extern NCURSES_EXPORT(int) _nc_read_entry (const char * const, char * const, TERMTYPE *const);
|
| 815 |
+
|
| 816 |
+
/*
|
| 817 |
+
* Normal entry points
|
| 818 |
+
*/
|
| 819 |
+
extern NCURSES_EXPORT(TERMINAL *) set_curterm (TERMINAL *);
|
| 820 |
+
extern NCURSES_EXPORT(int) del_curterm (TERMINAL *);
|
| 821 |
+
|
| 822 |
+
/* miscellaneous entry points */
|
| 823 |
+
extern NCURSES_EXPORT(int) restartterm (NCURSES_CONST char *, int, int *);
|
| 824 |
+
extern NCURSES_EXPORT(int) setupterm (const char *,int,int *);
|
| 825 |
+
|
| 826 |
+
/* terminfo entry points, also declared in curses.h */
|
| 827 |
+
#if !defined(__NCURSES_H)
|
| 828 |
+
extern NCURSES_EXPORT(char *) tigetstr (const char *);
|
| 829 |
+
extern NCURSES_EXPORT_VAR(char) ttytype[];
|
| 830 |
+
extern NCURSES_EXPORT(int) putp (const char *);
|
| 831 |
+
extern NCURSES_EXPORT(int) tigetflag (const char *);
|
| 832 |
+
extern NCURSES_EXPORT(int) tigetnum (const char *);
|
| 833 |
+
|
| 834 |
+
#if 1 /* NCURSES_TPARM_VARARGS */
|
| 835 |
+
extern NCURSES_EXPORT(char *) tparm (const char *, ...); /* special */
|
| 836 |
+
#else
|
| 837 |
+
extern NCURSES_EXPORT(char *) tparm (const char *, long,long,long,long,long,long,long,long,long); /* special */
|
| 838 |
+
#endif
|
| 839 |
+
|
| 840 |
+
extern NCURSES_EXPORT(char *) tiparm (const char *, ...); /* special */
|
| 841 |
+
|
| 842 |
+
#endif /* __NCURSES_H */
|
| 843 |
+
|
| 844 |
+
/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */
|
| 845 |
+
#if !defined(NCURSES_TERMCAP_H_incl)
|
| 846 |
+
extern NCURSES_EXPORT(char *) tgetstr (const char *, char **);
|
| 847 |
+
extern NCURSES_EXPORT(char *) tgoto (const char *, int, int);
|
| 848 |
+
extern NCURSES_EXPORT(int) tgetent (char *, const char *);
|
| 849 |
+
extern NCURSES_EXPORT(int) tgetflag (const char *);
|
| 850 |
+
extern NCURSES_EXPORT(int) tgetnum (const char *);
|
| 851 |
+
extern NCURSES_EXPORT(int) tputs (const char *, int, int (*)(int));
|
| 852 |
+
#endif /* NCURSES_TERMCAP_H_incl */
|
| 853 |
+
|
| 854 |
+
/*
|
| 855 |
+
* Include curses.h before term.h to enable these extensions.
|
| 856 |
+
*/
|
| 857 |
+
#if defined(NCURSES_SP_FUNCS) && (NCURSES_SP_FUNCS != 0)
|
| 858 |
+
|
| 859 |
+
extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tigetstr) (SCREEN*, const char *);
|
| 860 |
+
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(putp) (SCREEN*, const char *);
|
| 861 |
+
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tigetflag) (SCREEN*, const char *);
|
| 862 |
+
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tigetnum) (SCREEN*, const char *);
|
| 863 |
+
|
| 864 |
+
#if 1 /* NCURSES_TPARM_VARARGS */
|
| 865 |
+
extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tparm) (SCREEN*, const char *, ...); /* special */
|
| 866 |
+
#else
|
| 867 |
+
extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tparm) (SCREEN*, const char *, long,long,long,long,long,long,long,long,long); /* special */
|
| 868 |
+
#endif
|
| 869 |
+
|
| 870 |
+
/* termcap database emulation (XPG4 uses const only for 2nd param of tgetent) */
|
| 871 |
+
extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tgetstr) (SCREEN*, const char *, char **);
|
| 872 |
+
extern NCURSES_EXPORT(char *) NCURSES_SP_NAME(tgoto) (SCREEN*, const char *, int, int);
|
| 873 |
+
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tgetent) (SCREEN*, char *, const char *);
|
| 874 |
+
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tgetflag) (SCREEN*, const char *);
|
| 875 |
+
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tgetnum) (SCREEN*, const char *);
|
| 876 |
+
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(tputs) (SCREEN*, const char *, int, NCURSES_SP_OUTC);
|
| 877 |
+
|
| 878 |
+
extern NCURSES_EXPORT(TERMINAL *) NCURSES_SP_NAME(set_curterm) (SCREEN*, TERMINAL *);
|
| 879 |
+
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(del_curterm) (SCREEN*, TERMINAL *);
|
| 880 |
+
|
| 881 |
+
extern NCURSES_EXPORT(int) NCURSES_SP_NAME(restartterm) (SCREEN*, NCURSES_CONST char *, int, int *);
|
| 882 |
+
#endif /* NCURSES_SP_FUNCS */
|
| 883 |
+
|
| 884 |
+
/*
|
| 885 |
+
* Debugging features.
|
| 886 |
+
*/
|
| 887 |
+
extern GCC_NORETURN NCURSES_EXPORT(void) exit_terminfo(int);
|
| 888 |
+
|
| 889 |
+
#ifdef __cplusplus
|
| 890 |
+
}
|
| 891 |
+
#endif
|
| 892 |
+
|
| 893 |
+
#endif /* NCURSES_TERM_H_incl */
|
llava_next/include/ncursesw/term_entry.h
ADDED
|
@@ -0,0 +1,239 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/****************************************************************************
|
| 2 |
+
* Copyright 2018-2021,2022 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: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
|
| 32 |
+
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
|
| 33 |
+
* and: Thomas E. Dickey 1998-on *
|
| 34 |
+
****************************************************************************/
|
| 35 |
+
|
| 36 |
+
/* $Id: term_entry.h,v 1.63 2022/09/24 15:04:59 tom Exp $ */
|
| 37 |
+
|
| 38 |
+
/*
|
| 39 |
+
* term_entry.h -- interface to entry-manipulation code
|
| 40 |
+
*/
|
| 41 |
+
|
| 42 |
+
#ifndef NCURSES_TERM_ENTRY_H_incl
|
| 43 |
+
#define NCURSES_TERM_ENTRY_H_incl 1
|
| 44 |
+
/* *INDENT-OFF* */
|
| 45 |
+
|
| 46 |
+
#ifdef __cplusplus
|
| 47 |
+
extern "C" {
|
| 48 |
+
#endif
|
| 49 |
+
|
| 50 |
+
#include <ncursesw/curses.h>
|
| 51 |
+
#include <ncursesw/term.h>
|
| 52 |
+
|
| 53 |
+
/*
|
| 54 |
+
* These macros may be used by programs that know about TERMTYPE:
|
| 55 |
+
*/
|
| 56 |
+
#if NCURSES_XNAMES
|
| 57 |
+
#define NUM_BOOLEANS(tp) (tp)->num_Booleans
|
| 58 |
+
#define NUM_NUMBERS(tp) (tp)->num_Numbers
|
| 59 |
+
#define NUM_STRINGS(tp) (tp)->num_Strings
|
| 60 |
+
#define EXT_NAMES(tp,i,limit,index,table) (i >= limit) ? tp->ext_Names[index] : table[i]
|
| 61 |
+
#else
|
| 62 |
+
#define NUM_BOOLEANS(tp) BOOLCOUNT
|
| 63 |
+
#define NUM_NUMBERS(tp) NUMCOUNT
|
| 64 |
+
#define NUM_STRINGS(tp) STRCOUNT
|
| 65 |
+
#define EXT_NAMES(tp,i,limit,index,table) table[i]
|
| 66 |
+
#endif
|
| 67 |
+
|
| 68 |
+
#define NUM_EXT_NAMES(tp) (unsigned) ((tp)->ext_Booleans + (tp)->ext_Numbers + (tp)->ext_Strings)
|
| 69 |
+
|
| 70 |
+
#define for_each_boolean(n,tp) for(n = 0; n < NUM_BOOLEANS(tp); n++)
|
| 71 |
+
#define for_each_number(n,tp) for(n = 0; n < NUM_NUMBERS(tp); n++)
|
| 72 |
+
#define for_each_string(n,tp) for(n = 0; n < NUM_STRINGS(tp); n++)
|
| 73 |
+
|
| 74 |
+
#if NCURSES_XNAMES
|
| 75 |
+
#define for_each_ext_boolean(n,tp) for(n = BOOLCOUNT; (int) n < (int) NUM_BOOLEANS(tp); n++)
|
| 76 |
+
#define for_each_ext_number(n,tp) for(n = NUMCOUNT; (int) n < (int) NUM_NUMBERS(tp); n++)
|
| 77 |
+
#define for_each_ext_string(n,tp) for(n = STRCOUNT; (int) n < (int) NUM_STRINGS(tp); n++)
|
| 78 |
+
#endif
|
| 79 |
+
|
| 80 |
+
#define ExtBoolname(tp,i,names) EXT_NAMES(tp, i, BOOLCOUNT, (i - (tp->num_Booleans - tp->ext_Booleans)), names)
|
| 81 |
+
#define ExtNumname(tp,i,names) EXT_NAMES(tp, i, NUMCOUNT, (i - (tp->num_Numbers - tp->ext_Numbers)) + tp->ext_Booleans, names)
|
| 82 |
+
#define ExtStrname(tp,i,names) EXT_NAMES(tp, i, STRCOUNT, (i - (tp->num_Strings - tp->ext_Strings)) + (tp->ext_Numbers + tp->ext_Booleans), names)
|
| 83 |
+
|
| 84 |
+
/*
|
| 85 |
+
* The remaining type-definitions and macros are used only internally by the
|
| 86 |
+
* ncurses utilities.
|
| 87 |
+
*/
|
| 88 |
+
#ifdef NCURSES_INTERNALS
|
| 89 |
+
|
| 90 |
+
/*
|
| 91 |
+
* see db_iterator.c - this enumeration lists the places searched for a
|
| 92 |
+
* terminal description and defines the order in which they are searched.
|
| 93 |
+
*/
|
| 94 |
+
typedef enum {
|
| 95 |
+
dbdTIC = 0, /* special, used by tic when writing entry */
|
| 96 |
+
#if NCURSES_USE_DATABASE
|
| 97 |
+
dbdEnvOnce, /* the $TERMINFO environment variable */
|
| 98 |
+
dbdHome, /* $HOME/.terminfo */
|
| 99 |
+
dbdEnvList, /* the $TERMINFO_DIRS environment variable */
|
| 100 |
+
dbdCfgList, /* the compiled-in TERMINFO_DIRS value */
|
| 101 |
+
dbdCfgOnce, /* the compiled-in TERMINFO value */
|
| 102 |
+
#endif
|
| 103 |
+
#if NCURSES_USE_TERMCAP
|
| 104 |
+
dbdEnvOnce2, /* the $TERMCAP environment variable */
|
| 105 |
+
dbdEnvList2, /* the $TERMPATH environment variable */
|
| 106 |
+
dbdCfgList2, /* the compiled-in TERMPATH */
|
| 107 |
+
#endif
|
| 108 |
+
dbdLAST
|
| 109 |
+
} DBDIRS;
|
| 110 |
+
|
| 111 |
+
#define MAX_USES 32
|
| 112 |
+
#define MAX_CROSSLINKS 16
|
| 113 |
+
|
| 114 |
+
typedef struct entry ENTRY;
|
| 115 |
+
|
| 116 |
+
typedef struct {
|
| 117 |
+
char *name;
|
| 118 |
+
ENTRY *link;
|
| 119 |
+
long line;
|
| 120 |
+
} ENTRY_USES;
|
| 121 |
+
|
| 122 |
+
struct entry {
|
| 123 |
+
TERMTYPE2 tterm;
|
| 124 |
+
unsigned nuses;
|
| 125 |
+
ENTRY_USES uses[MAX_USES];
|
| 126 |
+
int ncrosslinks;
|
| 127 |
+
ENTRY *crosslinks[MAX_CROSSLINKS];
|
| 128 |
+
long cstart;
|
| 129 |
+
long cend;
|
| 130 |
+
long startline;
|
| 131 |
+
ENTRY *next;
|
| 132 |
+
ENTRY *last;
|
| 133 |
+
};
|
| 134 |
+
|
| 135 |
+
extern NCURSES_EXPORT_VAR(ENTRY *) _nc_head;
|
| 136 |
+
extern NCURSES_EXPORT_VAR(ENTRY *) _nc_tail;
|
| 137 |
+
#define for_entry_list(qp) for (qp = _nc_head; qp; qp = qp->next)
|
| 138 |
+
#define for_entry_list2(qp,q0) for (qp = q0; qp; qp = qp->next)
|
| 139 |
+
|
| 140 |
+
#define MAX_LINE 132
|
| 141 |
+
|
| 142 |
+
#define NULLHOOK (bool(*)(ENTRY *))0
|
| 143 |
+
|
| 144 |
+
/*
|
| 145 |
+
* Note that WANTED and PRESENT are not simple inverses! If a capability
|
| 146 |
+
* has been explicitly cancelled, it is not considered WANTED.
|
| 147 |
+
*/
|
| 148 |
+
#define WANTED(s) ((s) == ABSENT_STRING)
|
| 149 |
+
#define PRESENT(s) (((s) != ABSENT_STRING) && ((s) != CANCELLED_STRING))
|
| 150 |
+
|
| 151 |
+
#define ANDMISSING(p,q) \
|
| 152 |
+
{ \
|
| 153 |
+
if (PRESENT(p) && !PRESENT(q)) \
|
| 154 |
+
_nc_warning(#p " but no " #q); \
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
#define PAIRED(p,q) \
|
| 158 |
+
{ \
|
| 159 |
+
if (PRESENT(q) && !PRESENT(p)) \
|
| 160 |
+
_nc_warning(#q " but no " #p); \
|
| 161 |
+
if (PRESENT(p) && !PRESENT(q)) \
|
| 162 |
+
_nc_warning(#p " but no " #q); \
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
/*
|
| 166 |
+
* These entrypoints are used only by the ncurses utilities such as tic.
|
| 167 |
+
*/
|
| 168 |
+
|
| 169 |
+
/* alloc_entry.c: elementary allocation code */
|
| 170 |
+
extern NCURSES_EXPORT(ENTRY *) _nc_copy_entry (ENTRY *oldp);
|
| 171 |
+
extern NCURSES_EXPORT(char *) _nc_save_str (const char *const);
|
| 172 |
+
extern NCURSES_EXPORT(void) _nc_init_entry (ENTRY *const);
|
| 173 |
+
extern NCURSES_EXPORT(void) _nc_merge_entry (ENTRY *const, ENTRY *const);
|
| 174 |
+
extern NCURSES_EXPORT(void) _nc_wrap_entry (ENTRY *const, bool);
|
| 175 |
+
|
| 176 |
+
/* alloc_ttype.c: elementary allocation code */
|
| 177 |
+
extern NCURSES_EXPORT(void) _nc_align_termtype (TERMTYPE2 *, TERMTYPE2 *);
|
| 178 |
+
|
| 179 |
+
/* free_ttype.c: elementary allocation code */
|
| 180 |
+
extern NCURSES_EXPORT(void) _nc_free_termtype1 (TERMTYPE *);
|
| 181 |
+
extern NCURSES_EXPORT(void) _nc_free_termtype2 (TERMTYPE2 *);
|
| 182 |
+
|
| 183 |
+
/* lib_termcap.c: trim sgr0 string for termcap users */
|
| 184 |
+
extern NCURSES_EXPORT(char *) _nc_trim_sgr0 (TERMTYPE2 *);
|
| 185 |
+
|
| 186 |
+
/* parse_entry.c: entry-parsing code */
|
| 187 |
+
#if NCURSES_XNAMES
|
| 188 |
+
extern NCURSES_EXPORT_VAR(bool) _nc_user_definable;
|
| 189 |
+
extern NCURSES_EXPORT_VAR(bool) _nc_disable_period;
|
| 190 |
+
#endif
|
| 191 |
+
extern NCURSES_EXPORT(int) _nc_parse_entry (ENTRY *, int, bool);
|
| 192 |
+
extern NCURSES_EXPORT(int) _nc_capcmp (const char *, const char *);
|
| 193 |
+
|
| 194 |
+
/* write_entry.c: writing an entry to the file system */
|
| 195 |
+
extern NCURSES_EXPORT(void) _nc_set_writedir (const char *);
|
| 196 |
+
extern NCURSES_EXPORT(void) _nc_write_entry (TERMTYPE2 *const);
|
| 197 |
+
extern NCURSES_EXPORT(int) _nc_write_object (TERMTYPE2 *, char *, unsigned *, unsigned);
|
| 198 |
+
|
| 199 |
+
/* comp_parse.c: entry list handling */
|
| 200 |
+
extern NCURSES_EXPORT(void) _nc_read_entry_source (FILE*, char*, int, bool, bool (*)(ENTRY*));
|
| 201 |
+
extern NCURSES_EXPORT(bool) _nc_entry_match (char *, char *);
|
| 202 |
+
extern NCURSES_EXPORT(int) _nc_resolve_uses (bool); /* obs 20040705 */
|
| 203 |
+
extern NCURSES_EXPORT(int) _nc_resolve_uses2 (bool, bool);
|
| 204 |
+
extern NCURSES_EXPORT(void) _nc_free_entries (ENTRY *);
|
| 205 |
+
extern NCURSES_IMPEXP void (NCURSES_API *_nc_check_termtype)(TERMTYPE *); /* obs 20040705 */
|
| 206 |
+
extern NCURSES_IMPEXP void (NCURSES_API *_nc_check_termtype2)(TERMTYPE2 *, bool);
|
| 207 |
+
|
| 208 |
+
/* trace_xnames.c */
|
| 209 |
+
extern NCURSES_EXPORT(void) _nc_trace_xnames (TERMTYPE *);
|
| 210 |
+
|
| 211 |
+
#endif /* NCURSES_INTERNALS */
|
| 212 |
+
|
| 213 |
+
/*
|
| 214 |
+
* These entrypoints were used by tack before 1.08.
|
| 215 |
+
*/
|
| 216 |
+
|
| 217 |
+
#undef NCURSES_TACK_1_08
|
| 218 |
+
#ifdef NCURSES_INTERNALS
|
| 219 |
+
#define NCURSES_TACK_1_08 /* nothing */
|
| 220 |
+
#else
|
| 221 |
+
#define NCURSES_TACK_1_08 GCC_DEPRECATED("upgrade to tack 1.08")
|
| 222 |
+
#endif
|
| 223 |
+
|
| 224 |
+
/* alloc_ttype.c: elementary allocation code */
|
| 225 |
+
extern NCURSES_EXPORT(void) _nc_copy_termtype (TERMTYPE *, const TERMTYPE *) NCURSES_TACK_1_08;
|
| 226 |
+
|
| 227 |
+
/* lib_acs.c */
|
| 228 |
+
extern NCURSES_EXPORT(void) _nc_init_acs (void) NCURSES_TACK_1_08; /* corresponds to traditional 'init_acs()' */
|
| 229 |
+
|
| 230 |
+
/* free_ttype.c: elementary allocation code */
|
| 231 |
+
extern NCURSES_EXPORT(void) _nc_free_termtype (TERMTYPE *) NCURSES_TACK_1_08;
|
| 232 |
+
|
| 233 |
+
#ifdef __cplusplus
|
| 234 |
+
}
|
| 235 |
+
#endif
|
| 236 |
+
|
| 237 |
+
/* *INDENT-ON* */
|
| 238 |
+
|
| 239 |
+
#endif /* NCURSES_TERM_ENTRY_H_incl */
|
llava_next/include/ncursesw/unctrl.h
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/****************************************************************************
|
| 2 |
+
* Copyright 2020 Thomas E. Dickey *
|
| 3 |
+
* Copyright 1998-2001,2009 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: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995 *
|
| 32 |
+
* and: Eric S. Raymond <esr@snark.thyrsus.com> *
|
| 33 |
+
****************************************************************************/
|
| 34 |
+
|
| 35 |
+
/*
|
| 36 |
+
* unctrl.h
|
| 37 |
+
*
|
| 38 |
+
* Display a printable version of a control character.
|
| 39 |
+
* Control characters are displayed in caret notation (^x), DELETE is displayed
|
| 40 |
+
* as ^?. Printable characters are displayed as is.
|
| 41 |
+
*/
|
| 42 |
+
|
| 43 |
+
/* $Id: unctrl.h.in,v 1.12 2020/02/02 23:34:34 tom Exp $ */
|
| 44 |
+
|
| 45 |
+
#ifndef NCURSES_UNCTRL_H_incl
|
| 46 |
+
#define NCURSES_UNCTRL_H_incl 1
|
| 47 |
+
|
| 48 |
+
#undef NCURSES_VERSION
|
| 49 |
+
#define NCURSES_VERSION "6.4"
|
| 50 |
+
|
| 51 |
+
#ifdef __cplusplus
|
| 52 |
+
extern "C" {
|
| 53 |
+
#endif
|
| 54 |
+
|
| 55 |
+
#include <ncursesw/curses.h>
|
| 56 |
+
|
| 57 |
+
#undef unctrl
|
| 58 |
+
NCURSES_EXPORT(NCURSES_CONST char *) unctrl (chtype);
|
| 59 |
+
|
| 60 |
+
#if 1
|
| 61 |
+
NCURSES_EXPORT(NCURSES_CONST char *) NCURSES_SP_NAME(unctrl) (SCREEN*, chtype);
|
| 62 |
+
#endif
|
| 63 |
+
|
| 64 |
+
#ifdef __cplusplus
|
| 65 |
+
}
|
| 66 |
+
#endif
|
| 67 |
+
|
| 68 |
+
#endif /* NCURSES_UNCTRL_H_incl */
|
llava_next/include/openssl/asn1err.h
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Generated by util/mkerr.pl DO NOT EDIT
|
| 3 |
+
* Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
|
| 4 |
+
*
|
| 5 |
+
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
| 6 |
+
* this file except in compliance with the License. You can obtain a copy
|
| 7 |
+
* in the file LICENSE in the source distribution or at
|
| 8 |
+
* https://www.openssl.org/source/license.html
|
| 9 |
+
*/
|
| 10 |
+
|
| 11 |
+
#ifndef OPENSSL_ASN1ERR_H
|
| 12 |
+
# define OPENSSL_ASN1ERR_H
|
| 13 |
+
# pragma once
|
| 14 |
+
|
| 15 |
+
# include <openssl/opensslconf.h>
|
| 16 |
+
# include <openssl/symhacks.h>
|
| 17 |
+
# include <openssl/cryptoerr_legacy.h>
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
/*
|
| 22 |
+
* ASN1 reason codes.
|
| 23 |
+
*/
|
| 24 |
+
# define ASN1_R_ADDING_OBJECT 171
|
| 25 |
+
# define ASN1_R_ASN1_PARSE_ERROR 203
|
| 26 |
+
# define ASN1_R_ASN1_SIG_PARSE_ERROR 204
|
| 27 |
+
# define ASN1_R_AUX_ERROR 100
|
| 28 |
+
# define ASN1_R_BAD_OBJECT_HEADER 102
|
| 29 |
+
# define ASN1_R_BAD_TEMPLATE 230
|
| 30 |
+
# define ASN1_R_BMPSTRING_IS_WRONG_LENGTH 214
|
| 31 |
+
# define ASN1_R_BN_LIB 105
|
| 32 |
+
# define ASN1_R_BOOLEAN_IS_WRONG_LENGTH 106
|
| 33 |
+
# define ASN1_R_BUFFER_TOO_SMALL 107
|
| 34 |
+
# define ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 108
|
| 35 |
+
# define ASN1_R_CONTEXT_NOT_INITIALISED 217
|
| 36 |
+
# define ASN1_R_DATA_IS_WRONG 109
|
| 37 |
+
# define ASN1_R_DECODE_ERROR 110
|
| 38 |
+
# define ASN1_R_DEPTH_EXCEEDED 174
|
| 39 |
+
# define ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED 198
|
| 40 |
+
# define ASN1_R_ENCODE_ERROR 112
|
| 41 |
+
# define ASN1_R_ERROR_GETTING_TIME 173
|
| 42 |
+
# define ASN1_R_ERROR_LOADING_SECTION 172
|
| 43 |
+
# define ASN1_R_ERROR_SETTING_CIPHER_PARAMS 114
|
| 44 |
+
# define ASN1_R_EXPECTING_AN_INTEGER 115
|
| 45 |
+
# define ASN1_R_EXPECTING_AN_OBJECT 116
|
| 46 |
+
# define ASN1_R_EXPLICIT_LENGTH_MISMATCH 119
|
| 47 |
+
# define ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED 120
|
| 48 |
+
# define ASN1_R_FIELD_MISSING 121
|
| 49 |
+
# define ASN1_R_FIRST_NUM_TOO_LARGE 122
|
| 50 |
+
# define ASN1_R_HEADER_TOO_LONG 123
|
| 51 |
+
# define ASN1_R_ILLEGAL_BITSTRING_FORMAT 175
|
| 52 |
+
# define ASN1_R_ILLEGAL_BOOLEAN 176
|
| 53 |
+
# define ASN1_R_ILLEGAL_CHARACTERS 124
|
| 54 |
+
# define ASN1_R_ILLEGAL_FORMAT 177
|
| 55 |
+
# define ASN1_R_ILLEGAL_HEX 178
|
| 56 |
+
# define ASN1_R_ILLEGAL_IMPLICIT_TAG 179
|
| 57 |
+
# define ASN1_R_ILLEGAL_INTEGER 180
|
| 58 |
+
# define ASN1_R_ILLEGAL_NEGATIVE_VALUE 226
|
| 59 |
+
# define ASN1_R_ILLEGAL_NESTED_TAGGING 181
|
| 60 |
+
# define ASN1_R_ILLEGAL_NULL 125
|
| 61 |
+
# define ASN1_R_ILLEGAL_NULL_VALUE 182
|
| 62 |
+
# define ASN1_R_ILLEGAL_OBJECT 183
|
| 63 |
+
# define ASN1_R_ILLEGAL_OPTIONAL_ANY 126
|
| 64 |
+
# define ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE 170
|
| 65 |
+
# define ASN1_R_ILLEGAL_PADDING 221
|
| 66 |
+
# define ASN1_R_ILLEGAL_TAGGED_ANY 127
|
| 67 |
+
# define ASN1_R_ILLEGAL_TIME_VALUE 184
|
| 68 |
+
# define ASN1_R_ILLEGAL_ZERO_CONTENT 222
|
| 69 |
+
# define ASN1_R_INTEGER_NOT_ASCII_FORMAT 185
|
| 70 |
+
# define ASN1_R_INTEGER_TOO_LARGE_FOR_LONG 128
|
| 71 |
+
# define ASN1_R_INVALID_BIT_STRING_BITS_LEFT 220
|
| 72 |
+
# define ASN1_R_INVALID_BMPSTRING_LENGTH 129
|
| 73 |
+
# define ASN1_R_INVALID_DIGIT 130
|
| 74 |
+
# define ASN1_R_INVALID_MIME_TYPE 205
|
| 75 |
+
# define ASN1_R_INVALID_MODIFIER 186
|
| 76 |
+
# define ASN1_R_INVALID_NUMBER 187
|
| 77 |
+
# define ASN1_R_INVALID_OBJECT_ENCODING 216
|
| 78 |
+
# define ASN1_R_INVALID_SCRYPT_PARAMETERS 227
|
| 79 |
+
# define ASN1_R_INVALID_SEPARATOR 131
|
| 80 |
+
# define ASN1_R_INVALID_STRING_TABLE_VALUE 218
|
| 81 |
+
# define ASN1_R_INVALID_UNIVERSALSTRING_LENGTH 133
|
| 82 |
+
# define ASN1_R_INVALID_UTF8STRING 134
|
| 83 |
+
# define ASN1_R_INVALID_VALUE 219
|
| 84 |
+
# define ASN1_R_LENGTH_TOO_LONG 231
|
| 85 |
+
# define ASN1_R_LIST_ERROR 188
|
| 86 |
+
# define ASN1_R_MIME_NO_CONTENT_TYPE 206
|
| 87 |
+
# define ASN1_R_MIME_PARSE_ERROR 207
|
| 88 |
+
# define ASN1_R_MIME_SIG_PARSE_ERROR 208
|
| 89 |
+
# define ASN1_R_MISSING_EOC 137
|
| 90 |
+
# define ASN1_R_MISSING_SECOND_NUMBER 138
|
| 91 |
+
# define ASN1_R_MISSING_VALUE 189
|
| 92 |
+
# define ASN1_R_MSTRING_NOT_UNIVERSAL 139
|
| 93 |
+
# define ASN1_R_MSTRING_WRONG_TAG 140
|
| 94 |
+
# define ASN1_R_NESTED_ASN1_STRING 197
|
| 95 |
+
# define ASN1_R_NESTED_TOO_DEEP 201
|
| 96 |
+
# define ASN1_R_NON_HEX_CHARACTERS 141
|
| 97 |
+
# define ASN1_R_NOT_ASCII_FORMAT 190
|
| 98 |
+
# define ASN1_R_NOT_ENOUGH_DATA 142
|
| 99 |
+
# define ASN1_R_NO_CONTENT_TYPE 209
|
| 100 |
+
# define ASN1_R_NO_MATCHING_CHOICE_TYPE 143
|
| 101 |
+
# define ASN1_R_NO_MULTIPART_BODY_FAILURE 210
|
| 102 |
+
# define ASN1_R_NO_MULTIPART_BOUNDARY 211
|
| 103 |
+
# define ASN1_R_NO_SIG_CONTENT_TYPE 212
|
| 104 |
+
# define ASN1_R_NULL_IS_WRONG_LENGTH 144
|
| 105 |
+
# define ASN1_R_OBJECT_NOT_ASCII_FORMAT 191
|
| 106 |
+
# define ASN1_R_ODD_NUMBER_OF_CHARS 145
|
| 107 |
+
# define ASN1_R_SECOND_NUMBER_TOO_LARGE 147
|
| 108 |
+
# define ASN1_R_SEQUENCE_LENGTH_MISMATCH 148
|
| 109 |
+
# define ASN1_R_SEQUENCE_NOT_CONSTRUCTED 149
|
| 110 |
+
# define ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG 192
|
| 111 |
+
# define ASN1_R_SHORT_LINE 150
|
| 112 |
+
# define ASN1_R_SIG_INVALID_MIME_TYPE 213
|
| 113 |
+
# define ASN1_R_STREAMING_NOT_SUPPORTED 202
|
| 114 |
+
# define ASN1_R_STRING_TOO_LONG 151
|
| 115 |
+
# define ASN1_R_STRING_TOO_SHORT 152
|
| 116 |
+
# define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 154
|
| 117 |
+
# define ASN1_R_TIME_NOT_ASCII_FORMAT 193
|
| 118 |
+
# define ASN1_R_TOO_LARGE 223
|
| 119 |
+
# define ASN1_R_TOO_LONG 155
|
| 120 |
+
# define ASN1_R_TOO_SMALL 224
|
| 121 |
+
# define ASN1_R_TYPE_NOT_CONSTRUCTED 156
|
| 122 |
+
# define ASN1_R_TYPE_NOT_PRIMITIVE 195
|
| 123 |
+
# define ASN1_R_UNEXPECTED_EOC 159
|
| 124 |
+
# define ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH 215
|
| 125 |
+
# define ASN1_R_UNKNOWN_DIGEST 229
|
| 126 |
+
# define ASN1_R_UNKNOWN_FORMAT 160
|
| 127 |
+
# define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM 161
|
| 128 |
+
# define ASN1_R_UNKNOWN_OBJECT_TYPE 162
|
| 129 |
+
# define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE 163
|
| 130 |
+
# define ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM 199
|
| 131 |
+
# define ASN1_R_UNKNOWN_TAG 194
|
| 132 |
+
# define ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE 164
|
| 133 |
+
# define ASN1_R_UNSUPPORTED_CIPHER 228
|
| 134 |
+
# define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE 167
|
| 135 |
+
# define ASN1_R_UNSUPPORTED_TYPE 196
|
| 136 |
+
# define ASN1_R_WRONG_INTEGER_TYPE 225
|
| 137 |
+
# define ASN1_R_WRONG_PUBLIC_KEY_TYPE 200
|
| 138 |
+
# define ASN1_R_WRONG_TAG 168
|
| 139 |
+
|
| 140 |
+
#endif
|
llava_next/include/openssl/asn1t.h
ADDED
|
@@ -0,0 +1,946 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* WARNING: do not edit!
|
| 3 |
+
* Generated by Makefile from include/openssl/asn1t.h.in
|
| 4 |
+
*
|
| 5 |
+
* Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
|
| 6 |
+
*
|
| 7 |
+
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
| 8 |
+
* this file except in compliance with the License. You can obtain a copy
|
| 9 |
+
* in the file LICENSE in the source distribution or at
|
| 10 |
+
* https://www.openssl.org/source/license.html
|
| 11 |
+
*/
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
#ifndef OPENSSL_ASN1T_H
|
| 16 |
+
# define OPENSSL_ASN1T_H
|
| 17 |
+
# pragma once
|
| 18 |
+
|
| 19 |
+
# include <openssl/macros.h>
|
| 20 |
+
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
| 21 |
+
# define HEADER_ASN1T_H
|
| 22 |
+
# endif
|
| 23 |
+
|
| 24 |
+
# include <stddef.h>
|
| 25 |
+
# include <openssl/e_os2.h>
|
| 26 |
+
# include <openssl/asn1.h>
|
| 27 |
+
|
| 28 |
+
# ifdef OPENSSL_BUILD_SHLIBCRYPTO
|
| 29 |
+
# undef OPENSSL_EXTERN
|
| 30 |
+
# define OPENSSL_EXTERN OPENSSL_EXPORT
|
| 31 |
+
# endif
|
| 32 |
+
|
| 33 |
+
/* ASN1 template defines, structures and functions */
|
| 34 |
+
|
| 35 |
+
#ifdef __cplusplus
|
| 36 |
+
extern "C" {
|
| 37 |
+
#endif
|
| 38 |
+
|
| 39 |
+
/*-
|
| 40 |
+
* These are the possible values for the itype field of the
|
| 41 |
+
* ASN1_ITEM structure and determine how it is interpreted.
|
| 42 |
+
*
|
| 43 |
+
* For PRIMITIVE types the underlying type
|
| 44 |
+
* determines the behaviour if items is NULL.
|
| 45 |
+
*
|
| 46 |
+
* Otherwise templates must contain a single
|
| 47 |
+
* template and the type is treated in the
|
| 48 |
+
* same way as the type specified in the template.
|
| 49 |
+
*
|
| 50 |
+
* For SEQUENCE types the templates field points
|
| 51 |
+
* to the members, the size field is the
|
| 52 |
+
* structure size.
|
| 53 |
+
*
|
| 54 |
+
* For CHOICE types the templates field points
|
| 55 |
+
* to each possible member (typically a union)
|
| 56 |
+
* and the 'size' field is the offset of the
|
| 57 |
+
* selector.
|
| 58 |
+
*
|
| 59 |
+
* The 'funcs' field is used for application-specific
|
| 60 |
+
* data and functions.
|
| 61 |
+
*
|
| 62 |
+
* The EXTERN type uses a new style d2i/i2d.
|
| 63 |
+
* The new style should be used where possible
|
| 64 |
+
* because it avoids things like the d2i IMPLICIT
|
| 65 |
+
* hack.
|
| 66 |
+
*
|
| 67 |
+
* MSTRING is a multiple string type, it is used
|
| 68 |
+
* for a CHOICE of character strings where the
|
| 69 |
+
* actual strings all occupy an ASN1_STRING
|
| 70 |
+
* structure. In this case the 'utype' field
|
| 71 |
+
* has a special meaning, it is used as a mask
|
| 72 |
+
* of acceptable types using the B_ASN1 constants.
|
| 73 |
+
*
|
| 74 |
+
* NDEF_SEQUENCE is the same as SEQUENCE except
|
| 75 |
+
* that it will use indefinite length constructed
|
| 76 |
+
* encoding if requested.
|
| 77 |
+
*
|
| 78 |
+
*/
|
| 79 |
+
|
| 80 |
+
# define ASN1_ITYPE_PRIMITIVE 0x0
|
| 81 |
+
# define ASN1_ITYPE_SEQUENCE 0x1
|
| 82 |
+
# define ASN1_ITYPE_CHOICE 0x2
|
| 83 |
+
/* unused value 0x3 */
|
| 84 |
+
# define ASN1_ITYPE_EXTERN 0x4
|
| 85 |
+
# define ASN1_ITYPE_MSTRING 0x5
|
| 86 |
+
# define ASN1_ITYPE_NDEF_SEQUENCE 0x6
|
| 87 |
+
|
| 88 |
+
/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */
|
| 89 |
+
# define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)((iptr)()))
|
| 90 |
+
|
| 91 |
+
/* Macros for start and end of ASN1_ITEM definition */
|
| 92 |
+
|
| 93 |
+
# define ASN1_ITEM_start(itname) \
|
| 94 |
+
const ASN1_ITEM * itname##_it(void) \
|
| 95 |
+
{ \
|
| 96 |
+
static const ASN1_ITEM local_it = {
|
| 97 |
+
|
| 98 |
+
# define static_ASN1_ITEM_start(itname) \
|
| 99 |
+
static ASN1_ITEM_start(itname)
|
| 100 |
+
|
| 101 |
+
# define ASN1_ITEM_end(itname) \
|
| 102 |
+
}; \
|
| 103 |
+
return &local_it; \
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
/* Macros to aid ASN1 template writing */
|
| 107 |
+
|
| 108 |
+
# define ASN1_ITEM_TEMPLATE(tname) \
|
| 109 |
+
static const ASN1_TEMPLATE tname##_item_tt
|
| 110 |
+
|
| 111 |
+
# define ASN1_ITEM_TEMPLATE_END(tname) \
|
| 112 |
+
;\
|
| 113 |
+
ASN1_ITEM_start(tname) \
|
| 114 |
+
ASN1_ITYPE_PRIMITIVE,\
|
| 115 |
+
-1,\
|
| 116 |
+
&tname##_item_tt,\
|
| 117 |
+
0,\
|
| 118 |
+
NULL,\
|
| 119 |
+
0,\
|
| 120 |
+
#tname \
|
| 121 |
+
ASN1_ITEM_end(tname)
|
| 122 |
+
# define static_ASN1_ITEM_TEMPLATE_END(tname) \
|
| 123 |
+
;\
|
| 124 |
+
static_ASN1_ITEM_start(tname) \
|
| 125 |
+
ASN1_ITYPE_PRIMITIVE,\
|
| 126 |
+
-1,\
|
| 127 |
+
&tname##_item_tt,\
|
| 128 |
+
0,\
|
| 129 |
+
NULL,\
|
| 130 |
+
0,\
|
| 131 |
+
#tname \
|
| 132 |
+
ASN1_ITEM_end(tname)
|
| 133 |
+
|
| 134 |
+
/* This is a ASN1 type which just embeds a template */
|
| 135 |
+
|
| 136 |
+
/*-
|
| 137 |
+
* This pair helps declare a SEQUENCE. We can do:
|
| 138 |
+
*
|
| 139 |
+
* ASN1_SEQUENCE(stname) = {
|
| 140 |
+
* ... SEQUENCE components ...
|
| 141 |
+
* } ASN1_SEQUENCE_END(stname)
|
| 142 |
+
*
|
| 143 |
+
* This will produce an ASN1_ITEM called stname_it
|
| 144 |
+
* for a structure called stname.
|
| 145 |
+
*
|
| 146 |
+
* If you want the same structure but a different
|
| 147 |
+
* name then use:
|
| 148 |
+
*
|
| 149 |
+
* ASN1_SEQUENCE(itname) = {
|
| 150 |
+
* ... SEQUENCE components ...
|
| 151 |
+
* } ASN1_SEQUENCE_END_name(stname, itname)
|
| 152 |
+
*
|
| 153 |
+
* This will create an item called itname_it using
|
| 154 |
+
* a structure called stname.
|
| 155 |
+
*/
|
| 156 |
+
|
| 157 |
+
# define ASN1_SEQUENCE(tname) \
|
| 158 |
+
static const ASN1_TEMPLATE tname##_seq_tt[]
|
| 159 |
+
|
| 160 |
+
# define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname)
|
| 161 |
+
|
| 162 |
+
# define static_ASN1_SEQUENCE_END(stname) static_ASN1_SEQUENCE_END_name(stname, stname)
|
| 163 |
+
|
| 164 |
+
# define ASN1_SEQUENCE_END_name(stname, tname) \
|
| 165 |
+
;\
|
| 166 |
+
ASN1_ITEM_start(tname) \
|
| 167 |
+
ASN1_ITYPE_SEQUENCE,\
|
| 168 |
+
V_ASN1_SEQUENCE,\
|
| 169 |
+
tname##_seq_tt,\
|
| 170 |
+
sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
|
| 171 |
+
NULL,\
|
| 172 |
+
sizeof(stname),\
|
| 173 |
+
#tname \
|
| 174 |
+
ASN1_ITEM_end(tname)
|
| 175 |
+
|
| 176 |
+
# define static_ASN1_SEQUENCE_END_name(stname, tname) \
|
| 177 |
+
;\
|
| 178 |
+
static_ASN1_ITEM_start(tname) \
|
| 179 |
+
ASN1_ITYPE_SEQUENCE,\
|
| 180 |
+
V_ASN1_SEQUENCE,\
|
| 181 |
+
tname##_seq_tt,\
|
| 182 |
+
sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
|
| 183 |
+
NULL,\
|
| 184 |
+
sizeof(stname),\
|
| 185 |
+
#stname \
|
| 186 |
+
ASN1_ITEM_end(tname)
|
| 187 |
+
|
| 188 |
+
# define ASN1_NDEF_SEQUENCE(tname) \
|
| 189 |
+
ASN1_SEQUENCE(tname)
|
| 190 |
+
|
| 191 |
+
# define ASN1_NDEF_SEQUENCE_cb(tname, cb) \
|
| 192 |
+
ASN1_SEQUENCE_cb(tname, cb)
|
| 193 |
+
|
| 194 |
+
# define ASN1_SEQUENCE_cb(tname, cb) \
|
| 195 |
+
static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0, NULL}; \
|
| 196 |
+
ASN1_SEQUENCE(tname)
|
| 197 |
+
|
| 198 |
+
# define ASN1_SEQUENCE_const_cb(tname, const_cb) \
|
| 199 |
+
static const ASN1_AUX tname##_aux = \
|
| 200 |
+
{NULL, ASN1_AFLG_CONST_CB, 0, 0, NULL, 0, const_cb}; \
|
| 201 |
+
ASN1_SEQUENCE(tname)
|
| 202 |
+
|
| 203 |
+
# define ASN1_SEQUENCE_cb_const_cb(tname, cb, const_cb) \
|
| 204 |
+
static const ASN1_AUX tname##_aux = \
|
| 205 |
+
{NULL, ASN1_AFLG_CONST_CB, 0, 0, cb, 0, const_cb}; \
|
| 206 |
+
ASN1_SEQUENCE(tname)
|
| 207 |
+
|
| 208 |
+
# define ASN1_SEQUENCE_ref(tname, cb) \
|
| 209 |
+
static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_REFCOUNT, offsetof(tname, references), offsetof(tname, lock), cb, 0, NULL}; \
|
| 210 |
+
ASN1_SEQUENCE(tname)
|
| 211 |
+
|
| 212 |
+
# define ASN1_SEQUENCE_enc(tname, enc, cb) \
|
| 213 |
+
static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_ENCODING, 0, 0, cb, offsetof(tname, enc), NULL}; \
|
| 214 |
+
ASN1_SEQUENCE(tname)
|
| 215 |
+
|
| 216 |
+
# define ASN1_NDEF_SEQUENCE_END(tname) \
|
| 217 |
+
;\
|
| 218 |
+
ASN1_ITEM_start(tname) \
|
| 219 |
+
ASN1_ITYPE_NDEF_SEQUENCE,\
|
| 220 |
+
V_ASN1_SEQUENCE,\
|
| 221 |
+
tname##_seq_tt,\
|
| 222 |
+
sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
|
| 223 |
+
NULL,\
|
| 224 |
+
sizeof(tname),\
|
| 225 |
+
#tname \
|
| 226 |
+
ASN1_ITEM_end(tname)
|
| 227 |
+
# define static_ASN1_NDEF_SEQUENCE_END(tname) \
|
| 228 |
+
;\
|
| 229 |
+
static_ASN1_ITEM_start(tname) \
|
| 230 |
+
ASN1_ITYPE_NDEF_SEQUENCE,\
|
| 231 |
+
V_ASN1_SEQUENCE,\
|
| 232 |
+
tname##_seq_tt,\
|
| 233 |
+
sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
|
| 234 |
+
NULL,\
|
| 235 |
+
sizeof(tname),\
|
| 236 |
+
#tname \
|
| 237 |
+
ASN1_ITEM_end(tname)
|
| 238 |
+
|
| 239 |
+
|
| 240 |
+
# define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)
|
| 241 |
+
|
| 242 |
+
# define ASN1_SEQUENCE_END_cb(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname)
|
| 243 |
+
# define static_ASN1_SEQUENCE_END_cb(stname, tname) static_ASN1_SEQUENCE_END_ref(stname, tname)
|
| 244 |
+
|
| 245 |
+
# define ASN1_SEQUENCE_END_ref(stname, tname) \
|
| 246 |
+
;\
|
| 247 |
+
ASN1_ITEM_start(tname) \
|
| 248 |
+
ASN1_ITYPE_SEQUENCE,\
|
| 249 |
+
V_ASN1_SEQUENCE,\
|
| 250 |
+
tname##_seq_tt,\
|
| 251 |
+
sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
|
| 252 |
+
&tname##_aux,\
|
| 253 |
+
sizeof(stname),\
|
| 254 |
+
#tname \
|
| 255 |
+
ASN1_ITEM_end(tname)
|
| 256 |
+
# define static_ASN1_SEQUENCE_END_ref(stname, tname) \
|
| 257 |
+
;\
|
| 258 |
+
static_ASN1_ITEM_start(tname) \
|
| 259 |
+
ASN1_ITYPE_SEQUENCE,\
|
| 260 |
+
V_ASN1_SEQUENCE,\
|
| 261 |
+
tname##_seq_tt,\
|
| 262 |
+
sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
|
| 263 |
+
&tname##_aux,\
|
| 264 |
+
sizeof(stname),\
|
| 265 |
+
#stname \
|
| 266 |
+
ASN1_ITEM_end(tname)
|
| 267 |
+
|
| 268 |
+
# define ASN1_NDEF_SEQUENCE_END_cb(stname, tname) \
|
| 269 |
+
;\
|
| 270 |
+
ASN1_ITEM_start(tname) \
|
| 271 |
+
ASN1_ITYPE_NDEF_SEQUENCE,\
|
| 272 |
+
V_ASN1_SEQUENCE,\
|
| 273 |
+
tname##_seq_tt,\
|
| 274 |
+
sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\
|
| 275 |
+
&tname##_aux,\
|
| 276 |
+
sizeof(stname),\
|
| 277 |
+
#stname \
|
| 278 |
+
ASN1_ITEM_end(tname)
|
| 279 |
+
|
| 280 |
+
/*-
|
| 281 |
+
* This pair helps declare a CHOICE type. We can do:
|
| 282 |
+
*
|
| 283 |
+
* ASN1_CHOICE(chname) = {
|
| 284 |
+
* ... CHOICE options ...
|
| 285 |
+
* ASN1_CHOICE_END(chname)
|
| 286 |
+
*
|
| 287 |
+
* This will produce an ASN1_ITEM called chname_it
|
| 288 |
+
* for a structure called chname. The structure
|
| 289 |
+
* definition must look like this:
|
| 290 |
+
* typedef struct {
|
| 291 |
+
* int type;
|
| 292 |
+
* union {
|
| 293 |
+
* ASN1_SOMETHING *opt1;
|
| 294 |
+
* ASN1_SOMEOTHER *opt2;
|
| 295 |
+
* } value;
|
| 296 |
+
* } chname;
|
| 297 |
+
*
|
| 298 |
+
* the name of the selector must be 'type'.
|
| 299 |
+
* to use an alternative selector name use the
|
| 300 |
+
* ASN1_CHOICE_END_selector() version.
|
| 301 |
+
*/
|
| 302 |
+
|
| 303 |
+
# define ASN1_CHOICE(tname) \
|
| 304 |
+
static const ASN1_TEMPLATE tname##_ch_tt[]
|
| 305 |
+
|
| 306 |
+
# define ASN1_CHOICE_cb(tname, cb) \
|
| 307 |
+
static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0, NULL}; \
|
| 308 |
+
ASN1_CHOICE(tname)
|
| 309 |
+
|
| 310 |
+
# define ASN1_CHOICE_END(stname) ASN1_CHOICE_END_name(stname, stname)
|
| 311 |
+
|
| 312 |
+
# define static_ASN1_CHOICE_END(stname) static_ASN1_CHOICE_END_name(stname, stname)
|
| 313 |
+
|
| 314 |
+
# define ASN1_CHOICE_END_name(stname, tname) ASN1_CHOICE_END_selector(stname, tname, type)
|
| 315 |
+
|
| 316 |
+
# define static_ASN1_CHOICE_END_name(stname, tname) static_ASN1_CHOICE_END_selector(stname, tname, type)
|
| 317 |
+
|
| 318 |
+
# define ASN1_CHOICE_END_selector(stname, tname, selname) \
|
| 319 |
+
;\
|
| 320 |
+
ASN1_ITEM_start(tname) \
|
| 321 |
+
ASN1_ITYPE_CHOICE,\
|
| 322 |
+
offsetof(stname,selname) ,\
|
| 323 |
+
tname##_ch_tt,\
|
| 324 |
+
sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\
|
| 325 |
+
NULL,\
|
| 326 |
+
sizeof(stname),\
|
| 327 |
+
#stname \
|
| 328 |
+
ASN1_ITEM_end(tname)
|
| 329 |
+
|
| 330 |
+
# define static_ASN1_CHOICE_END_selector(stname, tname, selname) \
|
| 331 |
+
;\
|
| 332 |
+
static_ASN1_ITEM_start(tname) \
|
| 333 |
+
ASN1_ITYPE_CHOICE,\
|
| 334 |
+
offsetof(stname,selname) ,\
|
| 335 |
+
tname##_ch_tt,\
|
| 336 |
+
sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\
|
| 337 |
+
NULL,\
|
| 338 |
+
sizeof(stname),\
|
| 339 |
+
#stname \
|
| 340 |
+
ASN1_ITEM_end(tname)
|
| 341 |
+
|
| 342 |
+
# define ASN1_CHOICE_END_cb(stname, tname, selname) \
|
| 343 |
+
;\
|
| 344 |
+
ASN1_ITEM_start(tname) \
|
| 345 |
+
ASN1_ITYPE_CHOICE,\
|
| 346 |
+
offsetof(stname,selname) ,\
|
| 347 |
+
tname##_ch_tt,\
|
| 348 |
+
sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\
|
| 349 |
+
&tname##_aux,\
|
| 350 |
+
sizeof(stname),\
|
| 351 |
+
#stname \
|
| 352 |
+
ASN1_ITEM_end(tname)
|
| 353 |
+
|
| 354 |
+
/* This helps with the template wrapper form of ASN1_ITEM */
|
| 355 |
+
|
| 356 |
+
# define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type) { \
|
| 357 |
+
(flags), (tag), 0,\
|
| 358 |
+
#name, ASN1_ITEM_ref(type) }
|
| 359 |
+
|
| 360 |
+
/* These help with SEQUENCE or CHOICE components */
|
| 361 |
+
|
| 362 |
+
/* used to declare other types */
|
| 363 |
+
|
| 364 |
+
# define ASN1_EX_TYPE(flags, tag, stname, field, type) { \
|
| 365 |
+
(flags), (tag), offsetof(stname, field),\
|
| 366 |
+
#field, ASN1_ITEM_ref(type) }
|
| 367 |
+
|
| 368 |
+
/* implicit and explicit helper macros */
|
| 369 |
+
|
| 370 |
+
# define ASN1_IMP_EX(stname, field, type, tag, ex) \
|
| 371 |
+
ASN1_EX_TYPE(ASN1_TFLG_IMPLICIT | (ex), tag, stname, field, type)
|
| 372 |
+
|
| 373 |
+
# define ASN1_EXP_EX(stname, field, type, tag, ex) \
|
| 374 |
+
ASN1_EX_TYPE(ASN1_TFLG_EXPLICIT | (ex), tag, stname, field, type)
|
| 375 |
+
|
| 376 |
+
/* Any defined by macros: the field used is in the table itself */
|
| 377 |
+
|
| 378 |
+
# define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, tblname##_adb }
|
| 379 |
+
# define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, tblname##_adb }
|
| 380 |
+
|
| 381 |
+
/* Plain simple type */
|
| 382 |
+
# define ASN1_SIMPLE(stname, field, type) ASN1_EX_TYPE(0,0, stname, field, type)
|
| 383 |
+
/* Embedded simple type */
|
| 384 |
+
# define ASN1_EMBED(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_EMBED,0, stname, field, type)
|
| 385 |
+
|
| 386 |
+
/* OPTIONAL simple type */
|
| 387 |
+
# define ASN1_OPT(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL, 0, stname, field, type)
|
| 388 |
+
# define ASN1_OPT_EMBED(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL|ASN1_TFLG_EMBED, 0, stname, field, type)
|
| 389 |
+
|
| 390 |
+
/* IMPLICIT tagged simple type */
|
| 391 |
+
# define ASN1_IMP(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, 0)
|
| 392 |
+
# define ASN1_IMP_EMBED(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_EMBED)
|
| 393 |
+
|
| 394 |
+
/* IMPLICIT tagged OPTIONAL simple type */
|
| 395 |
+
# define ASN1_IMP_OPT(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)
|
| 396 |
+
# define ASN1_IMP_OPT_EMBED(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_EMBED)
|
| 397 |
+
|
| 398 |
+
/* Same as above but EXPLICIT */
|
| 399 |
+
|
| 400 |
+
# define ASN1_EXP(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, 0)
|
| 401 |
+
# define ASN1_EXP_EMBED(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_EMBED)
|
| 402 |
+
# define ASN1_EXP_OPT(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL)
|
| 403 |
+
# define ASN1_EXP_OPT_EMBED(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_EMBED)
|
| 404 |
+
|
| 405 |
+
/* SEQUENCE OF type */
|
| 406 |
+
# define ASN1_SEQUENCE_OF(stname, field, type) \
|
| 407 |
+
ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, stname, field, type)
|
| 408 |
+
|
| 409 |
+
/* OPTIONAL SEQUENCE OF */
|
| 410 |
+
# define ASN1_SEQUENCE_OF_OPT(stname, field, type) \
|
| 411 |
+
ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type)
|
| 412 |
+
|
| 413 |
+
/* Same as above but for SET OF */
|
| 414 |
+
|
| 415 |
+
# define ASN1_SET_OF(stname, field, type) \
|
| 416 |
+
ASN1_EX_TYPE(ASN1_TFLG_SET_OF, 0, stname, field, type)
|
| 417 |
+
|
| 418 |
+
# define ASN1_SET_OF_OPT(stname, field, type) \
|
| 419 |
+
ASN1_EX_TYPE(ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type)
|
| 420 |
+
|
| 421 |
+
/* Finally compound types of SEQUENCE, SET, IMPLICIT, EXPLICIT and OPTIONAL */
|
| 422 |
+
|
| 423 |
+
# define ASN1_IMP_SET_OF(stname, field, type, tag) \
|
| 424 |
+
ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)
|
| 425 |
+
|
| 426 |
+
# define ASN1_EXP_SET_OF(stname, field, type, tag) \
|
| 427 |
+
ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF)
|
| 428 |
+
|
| 429 |
+
# define ASN1_IMP_SET_OF_OPT(stname, field, type, tag) \
|
| 430 |
+
ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL)
|
| 431 |
+
|
| 432 |
+
# define ASN1_EXP_SET_OF_OPT(stname, field, type, tag) \
|
| 433 |
+
ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL)
|
| 434 |
+
|
| 435 |
+
# define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag) \
|
| 436 |
+
ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)
|
| 437 |
+
|
| 438 |
+
# define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag) \
|
| 439 |
+
ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)
|
| 440 |
+
|
| 441 |
+
# define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag) \
|
| 442 |
+
ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF)
|
| 443 |
+
|
| 444 |
+
# define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \
|
| 445 |
+
ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL)
|
| 446 |
+
|
| 447 |
+
/* EXPLICIT using indefinite length constructed form */
|
| 448 |
+
# define ASN1_NDEF_EXP(stname, field, type, tag) \
|
| 449 |
+
ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_NDEF)
|
| 450 |
+
|
| 451 |
+
/* EXPLICIT OPTIONAL using indefinite length constructed form */
|
| 452 |
+
# define ASN1_NDEF_EXP_OPT(stname, field, type, tag) \
|
| 453 |
+
ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_NDEF)
|
| 454 |
+
|
| 455 |
+
/* Macros for the ASN1_ADB structure */
|
| 456 |
+
|
| 457 |
+
# define ASN1_ADB(name) \
|
| 458 |
+
static const ASN1_ADB_TABLE name##_adbtbl[]
|
| 459 |
+
|
| 460 |
+
# define ASN1_ADB_END(name, flags, field, adb_cb, def, none) \
|
| 461 |
+
;\
|
| 462 |
+
static const ASN1_ITEM *name##_adb(void) \
|
| 463 |
+
{ \
|
| 464 |
+
static const ASN1_ADB internal_adb = \
|
| 465 |
+
{\
|
| 466 |
+
flags,\
|
| 467 |
+
offsetof(name, field),\
|
| 468 |
+
adb_cb,\
|
| 469 |
+
name##_adbtbl,\
|
| 470 |
+
sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\
|
| 471 |
+
def,\
|
| 472 |
+
none\
|
| 473 |
+
}; \
|
| 474 |
+
return (const ASN1_ITEM *) &internal_adb; \
|
| 475 |
+
} \
|
| 476 |
+
void dummy_function(void)
|
| 477 |
+
|
| 478 |
+
# define ADB_ENTRY(val, template) {val, template}
|
| 479 |
+
|
| 480 |
+
# define ASN1_ADB_TEMPLATE(name) \
|
| 481 |
+
static const ASN1_TEMPLATE name##_tt
|
| 482 |
+
|
| 483 |
+
/*
|
| 484 |
+
* This is the ASN1 template structure that defines a wrapper round the
|
| 485 |
+
* actual type. It determines the actual position of the field in the value
|
| 486 |
+
* structure, various flags such as OPTIONAL and the field name.
|
| 487 |
+
*/
|
| 488 |
+
|
| 489 |
+
struct ASN1_TEMPLATE_st {
|
| 490 |
+
unsigned long flags; /* Various flags */
|
| 491 |
+
long tag; /* tag, not used if no tagging */
|
| 492 |
+
unsigned long offset; /* Offset of this field in structure */
|
| 493 |
+
const char *field_name; /* Field name */
|
| 494 |
+
ASN1_ITEM_EXP *item; /* Relevant ASN1_ITEM or ASN1_ADB */
|
| 495 |
+
};
|
| 496 |
+
|
| 497 |
+
/* Macro to extract ASN1_ITEM and ASN1_ADB pointer from ASN1_TEMPLATE */
|
| 498 |
+
|
| 499 |
+
# define ASN1_TEMPLATE_item(t) (t->item_ptr)
|
| 500 |
+
# define ASN1_TEMPLATE_adb(t) (t->item_ptr)
|
| 501 |
+
|
| 502 |
+
typedef struct ASN1_ADB_TABLE_st ASN1_ADB_TABLE;
|
| 503 |
+
typedef struct ASN1_ADB_st ASN1_ADB;
|
| 504 |
+
|
| 505 |
+
struct ASN1_ADB_st {
|
| 506 |
+
unsigned long flags; /* Various flags */
|
| 507 |
+
unsigned long offset; /* Offset of selector field */
|
| 508 |
+
int (*adb_cb)(long *psel); /* Application callback */
|
| 509 |
+
const ASN1_ADB_TABLE *tbl; /* Table of possible types */
|
| 510 |
+
long tblcount; /* Number of entries in tbl */
|
| 511 |
+
const ASN1_TEMPLATE *default_tt; /* Type to use if no match */
|
| 512 |
+
const ASN1_TEMPLATE *null_tt; /* Type to use if selector is NULL */
|
| 513 |
+
};
|
| 514 |
+
|
| 515 |
+
struct ASN1_ADB_TABLE_st {
|
| 516 |
+
long value; /* NID for an object or value for an int */
|
| 517 |
+
const ASN1_TEMPLATE tt; /* item for this value */
|
| 518 |
+
};
|
| 519 |
+
|
| 520 |
+
/* template flags */
|
| 521 |
+
|
| 522 |
+
/* Field is optional */
|
| 523 |
+
# define ASN1_TFLG_OPTIONAL (0x1)
|
| 524 |
+
|
| 525 |
+
/* Field is a SET OF */
|
| 526 |
+
# define ASN1_TFLG_SET_OF (0x1 << 1)
|
| 527 |
+
|
| 528 |
+
/* Field is a SEQUENCE OF */
|
| 529 |
+
# define ASN1_TFLG_SEQUENCE_OF (0x2 << 1)
|
| 530 |
+
|
| 531 |
+
/*
|
| 532 |
+
* Special case: this refers to a SET OF that will be sorted into DER order
|
| 533 |
+
* when encoded *and* the corresponding STACK will be modified to match the
|
| 534 |
+
* new order.
|
| 535 |
+
*/
|
| 536 |
+
# define ASN1_TFLG_SET_ORDER (0x3 << 1)
|
| 537 |
+
|
| 538 |
+
/* Mask for SET OF or SEQUENCE OF */
|
| 539 |
+
# define ASN1_TFLG_SK_MASK (0x3 << 1)
|
| 540 |
+
|
| 541 |
+
/*
|
| 542 |
+
* These flags mean the tag should be taken from the tag field. If EXPLICIT
|
| 543 |
+
* then the underlying type is used for the inner tag.
|
| 544 |
+
*/
|
| 545 |
+
|
| 546 |
+
/* IMPLICIT tagging */
|
| 547 |
+
# define ASN1_TFLG_IMPTAG (0x1 << 3)
|
| 548 |
+
|
| 549 |
+
/* EXPLICIT tagging, inner tag from underlying type */
|
| 550 |
+
# define ASN1_TFLG_EXPTAG (0x2 << 3)
|
| 551 |
+
|
| 552 |
+
# define ASN1_TFLG_TAG_MASK (0x3 << 3)
|
| 553 |
+
|
| 554 |
+
/* context specific IMPLICIT */
|
| 555 |
+
# define ASN1_TFLG_IMPLICIT (ASN1_TFLG_IMPTAG|ASN1_TFLG_CONTEXT)
|
| 556 |
+
|
| 557 |
+
/* context specific EXPLICIT */
|
| 558 |
+
# define ASN1_TFLG_EXPLICIT (ASN1_TFLG_EXPTAG|ASN1_TFLG_CONTEXT)
|
| 559 |
+
|
| 560 |
+
/*
|
| 561 |
+
* If tagging is in force these determine the type of tag to use. Otherwise
|
| 562 |
+
* the tag is determined by the underlying type. These values reflect the
|
| 563 |
+
* actual octet format.
|
| 564 |
+
*/
|
| 565 |
+
|
| 566 |
+
/* Universal tag */
|
| 567 |
+
# define ASN1_TFLG_UNIVERSAL (0x0<<6)
|
| 568 |
+
/* Application tag */
|
| 569 |
+
# define ASN1_TFLG_APPLICATION (0x1<<6)
|
| 570 |
+
/* Context specific tag */
|
| 571 |
+
# define ASN1_TFLG_CONTEXT (0x2<<6)
|
| 572 |
+
/* Private tag */
|
| 573 |
+
# define ASN1_TFLG_PRIVATE (0x3<<6)
|
| 574 |
+
|
| 575 |
+
# define ASN1_TFLG_TAG_CLASS (0x3<<6)
|
| 576 |
+
|
| 577 |
+
/*
|
| 578 |
+
* These are for ANY DEFINED BY type. In this case the 'item' field points to
|
| 579 |
+
* an ASN1_ADB structure which contains a table of values to decode the
|
| 580 |
+
* relevant type
|
| 581 |
+
*/
|
| 582 |
+
|
| 583 |
+
# define ASN1_TFLG_ADB_MASK (0x3<<8)
|
| 584 |
+
|
| 585 |
+
# define ASN1_TFLG_ADB_OID (0x1<<8)
|
| 586 |
+
|
| 587 |
+
# define ASN1_TFLG_ADB_INT (0x1<<9)
|
| 588 |
+
|
| 589 |
+
/*
|
| 590 |
+
* This flag when present in a SEQUENCE OF, SET OF or EXPLICIT causes
|
| 591 |
+
* indefinite length constructed encoding to be used if required.
|
| 592 |
+
*/
|
| 593 |
+
|
| 594 |
+
# define ASN1_TFLG_NDEF (0x1<<11)
|
| 595 |
+
|
| 596 |
+
/* Field is embedded and not a pointer */
|
| 597 |
+
# define ASN1_TFLG_EMBED (0x1 << 12)
|
| 598 |
+
|
| 599 |
+
/* This is the actual ASN1 item itself */
|
| 600 |
+
|
| 601 |
+
struct ASN1_ITEM_st {
|
| 602 |
+
char itype; /* The item type, primitive, SEQUENCE, CHOICE
|
| 603 |
+
* or extern */
|
| 604 |
+
long utype; /* underlying type */
|
| 605 |
+
const ASN1_TEMPLATE *templates; /* If SEQUENCE or CHOICE this contains
|
| 606 |
+
* the contents */
|
| 607 |
+
long tcount; /* Number of templates if SEQUENCE or CHOICE */
|
| 608 |
+
const void *funcs; /* further data and type-specific functions */
|
| 609 |
+
/* funcs can be ASN1_PRIMITIVE_FUNCS*, ASN1_EXTERN_FUNCS*, or ASN1_AUX* */
|
| 610 |
+
long size; /* Structure size (usually) */
|
| 611 |
+
const char *sname; /* Structure name */
|
| 612 |
+
};
|
| 613 |
+
|
| 614 |
+
/*
|
| 615 |
+
* Cache for ASN1 tag and length, so we don't keep re-reading it for things
|
| 616 |
+
* like CHOICE
|
| 617 |
+
*/
|
| 618 |
+
|
| 619 |
+
struct ASN1_TLC_st {
|
| 620 |
+
char valid; /* Values below are valid */
|
| 621 |
+
int ret; /* return value */
|
| 622 |
+
long plen; /* length */
|
| 623 |
+
int ptag; /* class value */
|
| 624 |
+
int pclass; /* class value */
|
| 625 |
+
int hdrlen; /* header length */
|
| 626 |
+
};
|
| 627 |
+
|
| 628 |
+
/* Typedefs for ASN1 function pointers */
|
| 629 |
+
typedef int ASN1_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
|
| 630 |
+
const ASN1_ITEM *it, int tag, int aclass, char opt,
|
| 631 |
+
ASN1_TLC *ctx);
|
| 632 |
+
|
| 633 |
+
typedef int ASN1_ex_d2i_ex(ASN1_VALUE **pval, const unsigned char **in, long len,
|
| 634 |
+
const ASN1_ITEM *it, int tag, int aclass, char opt,
|
| 635 |
+
ASN1_TLC *ctx, OSSL_LIB_CTX *libctx,
|
| 636 |
+
const char *propq);
|
| 637 |
+
typedef int ASN1_ex_i2d(const ASN1_VALUE **pval, unsigned char **out,
|
| 638 |
+
const ASN1_ITEM *it, int tag, int aclass);
|
| 639 |
+
typedef int ASN1_ex_new_func(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
| 640 |
+
typedef int ASN1_ex_new_ex_func(ASN1_VALUE **pval, const ASN1_ITEM *it,
|
| 641 |
+
OSSL_LIB_CTX *libctx, const char *propq);
|
| 642 |
+
typedef void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
| 643 |
+
|
| 644 |
+
typedef int ASN1_ex_print_func(BIO *out, const ASN1_VALUE **pval,
|
| 645 |
+
int indent, const char *fname,
|
| 646 |
+
const ASN1_PCTX *pctx);
|
| 647 |
+
|
| 648 |
+
typedef int ASN1_primitive_i2c(const ASN1_VALUE **pval, unsigned char *cont,
|
| 649 |
+
int *putype, const ASN1_ITEM *it);
|
| 650 |
+
typedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont,
|
| 651 |
+
int len, int utype, char *free_cont,
|
| 652 |
+
const ASN1_ITEM *it);
|
| 653 |
+
typedef int ASN1_primitive_print(BIO *out, const ASN1_VALUE **pval,
|
| 654 |
+
const ASN1_ITEM *it, int indent,
|
| 655 |
+
const ASN1_PCTX *pctx);
|
| 656 |
+
|
| 657 |
+
typedef struct ASN1_EXTERN_FUNCS_st {
|
| 658 |
+
void *app_data;
|
| 659 |
+
ASN1_ex_new_func *asn1_ex_new;
|
| 660 |
+
ASN1_ex_free_func *asn1_ex_free;
|
| 661 |
+
ASN1_ex_free_func *asn1_ex_clear;
|
| 662 |
+
ASN1_ex_d2i *asn1_ex_d2i;
|
| 663 |
+
ASN1_ex_i2d *asn1_ex_i2d;
|
| 664 |
+
ASN1_ex_print_func *asn1_ex_print;
|
| 665 |
+
ASN1_ex_new_ex_func *asn1_ex_new_ex;
|
| 666 |
+
ASN1_ex_d2i_ex *asn1_ex_d2i_ex;
|
| 667 |
+
} ASN1_EXTERN_FUNCS;
|
| 668 |
+
|
| 669 |
+
typedef struct ASN1_PRIMITIVE_FUNCS_st {
|
| 670 |
+
void *app_data;
|
| 671 |
+
unsigned long flags;
|
| 672 |
+
ASN1_ex_new_func *prim_new;
|
| 673 |
+
ASN1_ex_free_func *prim_free;
|
| 674 |
+
ASN1_ex_free_func *prim_clear;
|
| 675 |
+
ASN1_primitive_c2i *prim_c2i;
|
| 676 |
+
ASN1_primitive_i2c *prim_i2c;
|
| 677 |
+
ASN1_primitive_print *prim_print;
|
| 678 |
+
} ASN1_PRIMITIVE_FUNCS;
|
| 679 |
+
|
| 680 |
+
/*
|
| 681 |
+
* This is the ASN1_AUX structure: it handles various miscellaneous
|
| 682 |
+
* requirements. For example the use of reference counts and an informational
|
| 683 |
+
* callback. The "informational callback" is called at various points during
|
| 684 |
+
* the ASN1 encoding and decoding. It can be used to provide minor
|
| 685 |
+
* customisation of the structures used. This is most useful where the
|
| 686 |
+
* supplied routines *almost* do the right thing but need some extra help at
|
| 687 |
+
* a few points. If the callback returns zero then it is assumed a fatal
|
| 688 |
+
* error has occurred and the main operation should be abandoned. If major
|
| 689 |
+
* changes in the default behaviour are required then an external type is
|
| 690 |
+
* more appropriate.
|
| 691 |
+
* For the operations ASN1_OP_I2D_PRE, ASN1_OP_I2D_POST, ASN1_OP_PRINT_PRE, and
|
| 692 |
+
* ASN1_OP_PRINT_POST, meanwhile a variant of the callback with const parameter
|
| 693 |
+
* 'in' is provided to make clear statically that its input is not modified. If
|
| 694 |
+
* and only if this variant is in use the flag ASN1_AFLG_CONST_CB must be set.
|
| 695 |
+
*/
|
| 696 |
+
|
| 697 |
+
typedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it,
|
| 698 |
+
void *exarg);
|
| 699 |
+
typedef int ASN1_aux_const_cb(int operation, const ASN1_VALUE **in,
|
| 700 |
+
const ASN1_ITEM *it, void *exarg);
|
| 701 |
+
|
| 702 |
+
typedef struct ASN1_AUX_st {
|
| 703 |
+
void *app_data;
|
| 704 |
+
int flags;
|
| 705 |
+
int ref_offset; /* Offset of reference value */
|
| 706 |
+
int ref_lock; /* Offset of lock value */
|
| 707 |
+
ASN1_aux_cb *asn1_cb;
|
| 708 |
+
int enc_offset; /* Offset of ASN1_ENCODING structure */
|
| 709 |
+
ASN1_aux_const_cb *asn1_const_cb; /* for ASN1_OP_I2D_ and ASN1_OP_PRINT_ */
|
| 710 |
+
} ASN1_AUX;
|
| 711 |
+
|
| 712 |
+
/* For print related callbacks exarg points to this structure */
|
| 713 |
+
typedef struct ASN1_PRINT_ARG_st {
|
| 714 |
+
BIO *out;
|
| 715 |
+
int indent;
|
| 716 |
+
const ASN1_PCTX *pctx;
|
| 717 |
+
} ASN1_PRINT_ARG;
|
| 718 |
+
|
| 719 |
+
/* For streaming related callbacks exarg points to this structure */
|
| 720 |
+
typedef struct ASN1_STREAM_ARG_st {
|
| 721 |
+
/* BIO to stream through */
|
| 722 |
+
BIO *out;
|
| 723 |
+
/* BIO with filters appended */
|
| 724 |
+
BIO *ndef_bio;
|
| 725 |
+
/* Streaming I/O boundary */
|
| 726 |
+
unsigned char **boundary;
|
| 727 |
+
} ASN1_STREAM_ARG;
|
| 728 |
+
|
| 729 |
+
/* Flags in ASN1_AUX */
|
| 730 |
+
|
| 731 |
+
/* Use a reference count */
|
| 732 |
+
# define ASN1_AFLG_REFCOUNT 1
|
| 733 |
+
/* Save the encoding of structure (useful for signatures) */
|
| 734 |
+
# define ASN1_AFLG_ENCODING 2
|
| 735 |
+
/* The Sequence length is invalid */
|
| 736 |
+
# define ASN1_AFLG_BROKEN 4
|
| 737 |
+
/* Use the new asn1_const_cb */
|
| 738 |
+
# define ASN1_AFLG_CONST_CB 8
|
| 739 |
+
|
| 740 |
+
/* operation values for asn1_cb */
|
| 741 |
+
|
| 742 |
+
# define ASN1_OP_NEW_PRE 0
|
| 743 |
+
# define ASN1_OP_NEW_POST 1
|
| 744 |
+
# define ASN1_OP_FREE_PRE 2
|
| 745 |
+
# define ASN1_OP_FREE_POST 3
|
| 746 |
+
# define ASN1_OP_D2I_PRE 4
|
| 747 |
+
# define ASN1_OP_D2I_POST 5
|
| 748 |
+
# define ASN1_OP_I2D_PRE 6
|
| 749 |
+
# define ASN1_OP_I2D_POST 7
|
| 750 |
+
# define ASN1_OP_PRINT_PRE 8
|
| 751 |
+
# define ASN1_OP_PRINT_POST 9
|
| 752 |
+
# define ASN1_OP_STREAM_PRE 10
|
| 753 |
+
# define ASN1_OP_STREAM_POST 11
|
| 754 |
+
# define ASN1_OP_DETACHED_PRE 12
|
| 755 |
+
# define ASN1_OP_DETACHED_POST 13
|
| 756 |
+
# define ASN1_OP_DUP_PRE 14
|
| 757 |
+
# define ASN1_OP_DUP_POST 15
|
| 758 |
+
# define ASN1_OP_GET0_LIBCTX 16
|
| 759 |
+
# define ASN1_OP_GET0_PROPQ 17
|
| 760 |
+
|
| 761 |
+
/* Macro to implement a primitive type */
|
| 762 |
+
# define IMPLEMENT_ASN1_TYPE(stname) IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0)
|
| 763 |
+
# define IMPLEMENT_ASN1_TYPE_ex(itname, vname, ex) \
|
| 764 |
+
ASN1_ITEM_start(itname) \
|
| 765 |
+
ASN1_ITYPE_PRIMITIVE, V_##vname, NULL, 0, NULL, ex, #itname \
|
| 766 |
+
ASN1_ITEM_end(itname)
|
| 767 |
+
|
| 768 |
+
/* Macro to implement a multi string type */
|
| 769 |
+
# define IMPLEMENT_ASN1_MSTRING(itname, mask) \
|
| 770 |
+
ASN1_ITEM_start(itname) \
|
| 771 |
+
ASN1_ITYPE_MSTRING, mask, NULL, 0, NULL, sizeof(ASN1_STRING), #itname \
|
| 772 |
+
ASN1_ITEM_end(itname)
|
| 773 |
+
|
| 774 |
+
# define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \
|
| 775 |
+
ASN1_ITEM_start(sname) \
|
| 776 |
+
ASN1_ITYPE_EXTERN, \
|
| 777 |
+
tag, \
|
| 778 |
+
NULL, \
|
| 779 |
+
0, \
|
| 780 |
+
&fptrs, \
|
| 781 |
+
0, \
|
| 782 |
+
#sname \
|
| 783 |
+
ASN1_ITEM_end(sname)
|
| 784 |
+
|
| 785 |
+
/* Macro to implement standard functions in terms of ASN1_ITEM structures */
|
| 786 |
+
|
| 787 |
+
# define IMPLEMENT_ASN1_FUNCTIONS(stname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, stname, stname)
|
| 788 |
+
|
| 789 |
+
# define IMPLEMENT_ASN1_FUNCTIONS_name(stname, itname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, itname)
|
| 790 |
+
|
| 791 |
+
# define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) \
|
| 792 |
+
IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname)
|
| 793 |
+
|
| 794 |
+
# define IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(stname) \
|
| 795 |
+
IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(static, stname, stname, stname)
|
| 796 |
+
|
| 797 |
+
# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname) \
|
| 798 |
+
IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, stname, stname)
|
| 799 |
+
|
| 800 |
+
# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(pre, stname, itname, fname) \
|
| 801 |
+
pre stname *fname##_new(void) \
|
| 802 |
+
{ \
|
| 803 |
+
return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \
|
| 804 |
+
} \
|
| 805 |
+
pre void fname##_free(stname *a) \
|
| 806 |
+
{ \
|
| 807 |
+
ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \
|
| 808 |
+
}
|
| 809 |
+
|
| 810 |
+
# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) \
|
| 811 |
+
stname *fname##_new(void) \
|
| 812 |
+
{ \
|
| 813 |
+
return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \
|
| 814 |
+
} \
|
| 815 |
+
void fname##_free(stname *a) \
|
| 816 |
+
{ \
|
| 817 |
+
ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \
|
| 818 |
+
}
|
| 819 |
+
|
| 820 |
+
# define IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, fname) \
|
| 821 |
+
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \
|
| 822 |
+
IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname)
|
| 823 |
+
|
| 824 |
+
# define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \
|
| 825 |
+
stname *d2i_##fname(stname **a, const unsigned char **in, long len) \
|
| 826 |
+
{ \
|
| 827 |
+
return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\
|
| 828 |
+
} \
|
| 829 |
+
int i2d_##fname(const stname *a, unsigned char **out) \
|
| 830 |
+
{ \
|
| 831 |
+
return ASN1_item_i2d((const ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\
|
| 832 |
+
}
|
| 833 |
+
|
| 834 |
+
# define IMPLEMENT_ASN1_NDEF_FUNCTION(stname) \
|
| 835 |
+
int i2d_##stname##_NDEF(const stname *a, unsigned char **out) \
|
| 836 |
+
{ \
|
| 837 |
+
return ASN1_item_ndef_i2d((const ASN1_VALUE *)a, out, ASN1_ITEM_rptr(stname));\
|
| 838 |
+
}
|
| 839 |
+
|
| 840 |
+
# define IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(stname) \
|
| 841 |
+
static stname *d2i_##stname(stname **a, \
|
| 842 |
+
const unsigned char **in, long len) \
|
| 843 |
+
{ \
|
| 844 |
+
return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, \
|
| 845 |
+
ASN1_ITEM_rptr(stname)); \
|
| 846 |
+
} \
|
| 847 |
+
static int i2d_##stname(const stname *a, unsigned char **out) \
|
| 848 |
+
{ \
|
| 849 |
+
return ASN1_item_i2d((const ASN1_VALUE *)a, out, \
|
| 850 |
+
ASN1_ITEM_rptr(stname)); \
|
| 851 |
+
}
|
| 852 |
+
|
| 853 |
+
# define IMPLEMENT_ASN1_DUP_FUNCTION(stname) \
|
| 854 |
+
stname * stname##_dup(const stname *x) \
|
| 855 |
+
{ \
|
| 856 |
+
return ASN1_item_dup(ASN1_ITEM_rptr(stname), x); \
|
| 857 |
+
}
|
| 858 |
+
|
| 859 |
+
# define IMPLEMENT_ASN1_PRINT_FUNCTION(stname) \
|
| 860 |
+
IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, stname, stname)
|
| 861 |
+
|
| 862 |
+
# define IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, itname, fname) \
|
| 863 |
+
int fname##_print_ctx(BIO *out, const stname *x, int indent, \
|
| 864 |
+
const ASN1_PCTX *pctx) \
|
| 865 |
+
{ \
|
| 866 |
+
return ASN1_item_print(out, (const ASN1_VALUE *)x, indent, \
|
| 867 |
+
ASN1_ITEM_rptr(itname), pctx); \
|
| 868 |
+
}
|
| 869 |
+
|
| 870 |
+
/* external definitions for primitive types */
|
| 871 |
+
|
| 872 |
+
DECLARE_ASN1_ITEM(ASN1_BOOLEAN)
|
| 873 |
+
DECLARE_ASN1_ITEM(ASN1_TBOOLEAN)
|
| 874 |
+
DECLARE_ASN1_ITEM(ASN1_FBOOLEAN)
|
| 875 |
+
DECLARE_ASN1_ITEM(ASN1_SEQUENCE)
|
| 876 |
+
DECLARE_ASN1_ITEM(CBIGNUM)
|
| 877 |
+
DECLARE_ASN1_ITEM(BIGNUM)
|
| 878 |
+
DECLARE_ASN1_ITEM(INT32)
|
| 879 |
+
DECLARE_ASN1_ITEM(ZINT32)
|
| 880 |
+
DECLARE_ASN1_ITEM(UINT32)
|
| 881 |
+
DECLARE_ASN1_ITEM(ZUINT32)
|
| 882 |
+
DECLARE_ASN1_ITEM(INT64)
|
| 883 |
+
DECLARE_ASN1_ITEM(ZINT64)
|
| 884 |
+
DECLARE_ASN1_ITEM(UINT64)
|
| 885 |
+
DECLARE_ASN1_ITEM(ZUINT64)
|
| 886 |
+
|
| 887 |
+
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
| 888 |
+
/*
|
| 889 |
+
* LONG and ZLONG are strongly discouraged for use as stored data, as the
|
| 890 |
+
* underlying C type (long) differs in size depending on the architecture.
|
| 891 |
+
* They are designed with 32-bit longs in mind.
|
| 892 |
+
*/
|
| 893 |
+
DECLARE_ASN1_ITEM(LONG)
|
| 894 |
+
DECLARE_ASN1_ITEM(ZLONG)
|
| 895 |
+
# endif
|
| 896 |
+
|
| 897 |
+
SKM_DEFINE_STACK_OF_INTERNAL(ASN1_VALUE, ASN1_VALUE, ASN1_VALUE)
|
| 898 |
+
#define sk_ASN1_VALUE_num(sk) OPENSSL_sk_num(ossl_check_const_ASN1_VALUE_sk_type(sk))
|
| 899 |
+
#define sk_ASN1_VALUE_value(sk, idx) ((ASN1_VALUE *)OPENSSL_sk_value(ossl_check_const_ASN1_VALUE_sk_type(sk), (idx)))
|
| 900 |
+
#define sk_ASN1_VALUE_new(cmp) ((STACK_OF(ASN1_VALUE) *)OPENSSL_sk_new(ossl_check_ASN1_VALUE_compfunc_type(cmp)))
|
| 901 |
+
#define sk_ASN1_VALUE_new_null() ((STACK_OF(ASN1_VALUE) *)OPENSSL_sk_new_null())
|
| 902 |
+
#define sk_ASN1_VALUE_new_reserve(cmp, n) ((STACK_OF(ASN1_VALUE) *)OPENSSL_sk_new_reserve(ossl_check_ASN1_VALUE_compfunc_type(cmp), (n)))
|
| 903 |
+
#define sk_ASN1_VALUE_reserve(sk, n) OPENSSL_sk_reserve(ossl_check_ASN1_VALUE_sk_type(sk), (n))
|
| 904 |
+
#define sk_ASN1_VALUE_free(sk) OPENSSL_sk_free(ossl_check_ASN1_VALUE_sk_type(sk))
|
| 905 |
+
#define sk_ASN1_VALUE_zero(sk) OPENSSL_sk_zero(ossl_check_ASN1_VALUE_sk_type(sk))
|
| 906 |
+
#define sk_ASN1_VALUE_delete(sk, i) ((ASN1_VALUE *)OPENSSL_sk_delete(ossl_check_ASN1_VALUE_sk_type(sk), (i)))
|
| 907 |
+
#define sk_ASN1_VALUE_delete_ptr(sk, ptr) ((ASN1_VALUE *)OPENSSL_sk_delete_ptr(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_type(ptr)))
|
| 908 |
+
#define sk_ASN1_VALUE_push(sk, ptr) OPENSSL_sk_push(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_type(ptr))
|
| 909 |
+
#define sk_ASN1_VALUE_unshift(sk, ptr) OPENSSL_sk_unshift(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_type(ptr))
|
| 910 |
+
#define sk_ASN1_VALUE_pop(sk) ((ASN1_VALUE *)OPENSSL_sk_pop(ossl_check_ASN1_VALUE_sk_type(sk)))
|
| 911 |
+
#define sk_ASN1_VALUE_shift(sk) ((ASN1_VALUE *)OPENSSL_sk_shift(ossl_check_ASN1_VALUE_sk_type(sk)))
|
| 912 |
+
#define sk_ASN1_VALUE_pop_free(sk, freefunc) OPENSSL_sk_pop_free(ossl_check_ASN1_VALUE_sk_type(sk),ossl_check_ASN1_VALUE_freefunc_type(freefunc))
|
| 913 |
+
#define sk_ASN1_VALUE_insert(sk, ptr, idx) OPENSSL_sk_insert(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_type(ptr), (idx))
|
| 914 |
+
#define sk_ASN1_VALUE_set(sk, idx, ptr) ((ASN1_VALUE *)OPENSSL_sk_set(ossl_check_ASN1_VALUE_sk_type(sk), (idx), ossl_check_ASN1_VALUE_type(ptr)))
|
| 915 |
+
#define sk_ASN1_VALUE_find(sk, ptr) OPENSSL_sk_find(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_type(ptr))
|
| 916 |
+
#define sk_ASN1_VALUE_find_ex(sk, ptr) OPENSSL_sk_find_ex(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_type(ptr))
|
| 917 |
+
#define sk_ASN1_VALUE_find_all(sk, ptr, pnum) OPENSSL_sk_find_all(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_type(ptr), pnum)
|
| 918 |
+
#define sk_ASN1_VALUE_sort(sk) OPENSSL_sk_sort(ossl_check_ASN1_VALUE_sk_type(sk))
|
| 919 |
+
#define sk_ASN1_VALUE_is_sorted(sk) OPENSSL_sk_is_sorted(ossl_check_const_ASN1_VALUE_sk_type(sk))
|
| 920 |
+
#define sk_ASN1_VALUE_dup(sk) ((STACK_OF(ASN1_VALUE) *)OPENSSL_sk_dup(ossl_check_const_ASN1_VALUE_sk_type(sk)))
|
| 921 |
+
#define sk_ASN1_VALUE_deep_copy(sk, copyfunc, freefunc) ((STACK_OF(ASN1_VALUE) *)OPENSSL_sk_deep_copy(ossl_check_const_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_copyfunc_type(copyfunc), ossl_check_ASN1_VALUE_freefunc_type(freefunc)))
|
| 922 |
+
#define sk_ASN1_VALUE_set_cmp_func(sk, cmp) ((sk_ASN1_VALUE_compfunc)OPENSSL_sk_set_cmp_func(ossl_check_ASN1_VALUE_sk_type(sk), ossl_check_ASN1_VALUE_compfunc_type(cmp)))
|
| 923 |
+
|
| 924 |
+
|
| 925 |
+
|
| 926 |
+
/* Functions used internally by the ASN1 code */
|
| 927 |
+
|
| 928 |
+
int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
| 929 |
+
void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it);
|
| 930 |
+
|
| 931 |
+
int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
|
| 932 |
+
const ASN1_ITEM *it, int tag, int aclass, char opt,
|
| 933 |
+
ASN1_TLC *ctx);
|
| 934 |
+
|
| 935 |
+
int ASN1_item_ex_i2d(const ASN1_VALUE **pval, unsigned char **out,
|
| 936 |
+
const ASN1_ITEM *it, int tag, int aclass);
|
| 937 |
+
|
| 938 |
+
/* Legacy compatibility */
|
| 939 |
+
# define IMPLEMENT_ASN1_FUNCTIONS_const(name) IMPLEMENT_ASN1_FUNCTIONS(name)
|
| 940 |
+
# define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \
|
| 941 |
+
IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname)
|
| 942 |
+
|
| 943 |
+
#ifdef __cplusplus
|
| 944 |
+
}
|
| 945 |
+
#endif
|
| 946 |
+
#endif
|
llava_next/include/openssl/blowfish.h
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
| 5 |
+
* this file except in compliance with the License. You can obtain a copy
|
| 6 |
+
* in the file LICENSE in the source distribution or at
|
| 7 |
+
* https://www.openssl.org/source/license.html
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
#ifndef OPENSSL_BLOWFISH_H
|
| 11 |
+
# define OPENSSL_BLOWFISH_H
|
| 12 |
+
# pragma once
|
| 13 |
+
|
| 14 |
+
# include <openssl/macros.h>
|
| 15 |
+
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
| 16 |
+
# define HEADER_BLOWFISH_H
|
| 17 |
+
# endif
|
| 18 |
+
|
| 19 |
+
# include <openssl/opensslconf.h>
|
| 20 |
+
|
| 21 |
+
# ifndef OPENSSL_NO_BF
|
| 22 |
+
# include <openssl/e_os2.h>
|
| 23 |
+
# ifdef __cplusplus
|
| 24 |
+
extern "C" {
|
| 25 |
+
# endif
|
| 26 |
+
|
| 27 |
+
# define BF_BLOCK 8
|
| 28 |
+
|
| 29 |
+
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
| 30 |
+
|
| 31 |
+
# define BF_ENCRYPT 1
|
| 32 |
+
# define BF_DECRYPT 0
|
| 33 |
+
|
| 34 |
+
/*-
|
| 35 |
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
| 36 |
+
* ! BF_LONG has to be at least 32 bits wide. !
|
| 37 |
+
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
| 38 |
+
*/
|
| 39 |
+
# define BF_LONG unsigned int
|
| 40 |
+
|
| 41 |
+
# define BF_ROUNDS 16
|
| 42 |
+
|
| 43 |
+
typedef struct bf_key_st {
|
| 44 |
+
BF_LONG P[BF_ROUNDS + 2];
|
| 45 |
+
BF_LONG S[4 * 256];
|
| 46 |
+
} BF_KEY;
|
| 47 |
+
|
| 48 |
+
# endif /* OPENSSL_NO_DEPRECATED_3_0 */
|
| 49 |
+
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
| 50 |
+
OSSL_DEPRECATEDIN_3_0 void BF_set_key(BF_KEY *key, int len,
|
| 51 |
+
const unsigned char *data);
|
| 52 |
+
OSSL_DEPRECATEDIN_3_0 void BF_encrypt(BF_LONG *data, const BF_KEY *key);
|
| 53 |
+
OSSL_DEPRECATEDIN_3_0 void BF_decrypt(BF_LONG *data, const BF_KEY *key);
|
| 54 |
+
OSSL_DEPRECATEDIN_3_0 void BF_ecb_encrypt(const unsigned char *in,
|
| 55 |
+
unsigned char *out, const BF_KEY *key,
|
| 56 |
+
int enc);
|
| 57 |
+
OSSL_DEPRECATEDIN_3_0 void BF_cbc_encrypt(const unsigned char *in,
|
| 58 |
+
unsigned char *out, long length,
|
| 59 |
+
const BF_KEY *schedule,
|
| 60 |
+
unsigned char *ivec, int enc);
|
| 61 |
+
OSSL_DEPRECATEDIN_3_0 void BF_cfb64_encrypt(const unsigned char *in,
|
| 62 |
+
unsigned char *out,
|
| 63 |
+
long length, const BF_KEY *schedule,
|
| 64 |
+
unsigned char *ivec, int *num,
|
| 65 |
+
int enc);
|
| 66 |
+
OSSL_DEPRECATEDIN_3_0 void BF_ofb64_encrypt(const unsigned char *in,
|
| 67 |
+
unsigned char *out,
|
| 68 |
+
long length, const BF_KEY *schedule,
|
| 69 |
+
unsigned char *ivec, int *num);
|
| 70 |
+
OSSL_DEPRECATEDIN_3_0 const char *BF_options(void);
|
| 71 |
+
# endif
|
| 72 |
+
|
| 73 |
+
# ifdef __cplusplus
|
| 74 |
+
}
|
| 75 |
+
# endif
|
| 76 |
+
# endif
|
| 77 |
+
|
| 78 |
+
#endif
|
llava_next/include/openssl/bnerr.h
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Generated by util/mkerr.pl DO NOT EDIT
|
| 3 |
+
* Copyright 1995-2022 The OpenSSL Project Authors. All Rights Reserved.
|
| 4 |
+
*
|
| 5 |
+
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
| 6 |
+
* this file except in compliance with the License. You can obtain a copy
|
| 7 |
+
* in the file LICENSE in the source distribution or at
|
| 8 |
+
* https://www.openssl.org/source/license.html
|
| 9 |
+
*/
|
| 10 |
+
|
| 11 |
+
#ifndef OPENSSL_BNERR_H
|
| 12 |
+
# define OPENSSL_BNERR_H
|
| 13 |
+
# pragma once
|
| 14 |
+
|
| 15 |
+
# include <openssl/opensslconf.h>
|
| 16 |
+
# include <openssl/symhacks.h>
|
| 17 |
+
# include <openssl/cryptoerr_legacy.h>
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
/*
|
| 22 |
+
* BN reason codes.
|
| 23 |
+
*/
|
| 24 |
+
# define BN_R_ARG2_LT_ARG3 100
|
| 25 |
+
# define BN_R_BAD_RECIPROCAL 101
|
| 26 |
+
# define BN_R_BIGNUM_TOO_LONG 114
|
| 27 |
+
# define BN_R_BITS_TOO_SMALL 118
|
| 28 |
+
# define BN_R_CALLED_WITH_EVEN_MODULUS 102
|
| 29 |
+
# define BN_R_DIV_BY_ZERO 103
|
| 30 |
+
# define BN_R_ENCODING_ERROR 104
|
| 31 |
+
# define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA 105
|
| 32 |
+
# define BN_R_INPUT_NOT_REDUCED 110
|
| 33 |
+
# define BN_R_INVALID_LENGTH 106
|
| 34 |
+
# define BN_R_INVALID_RANGE 115
|
| 35 |
+
# define BN_R_INVALID_SHIFT 119
|
| 36 |
+
# define BN_R_NOT_A_SQUARE 111
|
| 37 |
+
# define BN_R_NOT_INITIALIZED 107
|
| 38 |
+
# define BN_R_NO_INVERSE 108
|
| 39 |
+
# define BN_R_NO_PRIME_CANDIDATE 121
|
| 40 |
+
# define BN_R_NO_SOLUTION 116
|
| 41 |
+
# define BN_R_NO_SUITABLE_DIGEST 120
|
| 42 |
+
# define BN_R_PRIVATE_KEY_TOO_LARGE 117
|
| 43 |
+
# define BN_R_P_IS_NOT_PRIME 112
|
| 44 |
+
# define BN_R_TOO_MANY_ITERATIONS 113
|
| 45 |
+
# define BN_R_TOO_MANY_TEMPORARY_VARIABLES 109
|
| 46 |
+
|
| 47 |
+
#endif
|
llava_next/include/openssl/camellia.h
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Copyright 2006-2020 The OpenSSL Project Authors. All Rights Reserved.
|
| 3 |
+
*
|
| 4 |
+
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
| 5 |
+
* this file except in compliance with the License. You can obtain a copy
|
| 6 |
+
* in the file LICENSE in the source distribution or at
|
| 7 |
+
* https://www.openssl.org/source/license.html
|
| 8 |
+
*/
|
| 9 |
+
|
| 10 |
+
#ifndef OPENSSL_CAMELLIA_H
|
| 11 |
+
# define OPENSSL_CAMELLIA_H
|
| 12 |
+
# pragma once
|
| 13 |
+
|
| 14 |
+
# include <openssl/macros.h>
|
| 15 |
+
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
| 16 |
+
# define HEADER_CAMELLIA_H
|
| 17 |
+
# endif
|
| 18 |
+
|
| 19 |
+
# include <openssl/opensslconf.h>
|
| 20 |
+
|
| 21 |
+
# ifndef OPENSSL_NO_CAMELLIA
|
| 22 |
+
# include <stddef.h>
|
| 23 |
+
#ifdef __cplusplus
|
| 24 |
+
extern "C" {
|
| 25 |
+
#endif
|
| 26 |
+
|
| 27 |
+
# define CAMELLIA_BLOCK_SIZE 16
|
| 28 |
+
|
| 29 |
+
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
| 30 |
+
|
| 31 |
+
# define CAMELLIA_ENCRYPT 1
|
| 32 |
+
# define CAMELLIA_DECRYPT 0
|
| 33 |
+
|
| 34 |
+
/*
|
| 35 |
+
* Because array size can't be a const in C, the following two are macros.
|
| 36 |
+
* Both sizes are in bytes.
|
| 37 |
+
*/
|
| 38 |
+
|
| 39 |
+
/* This should be a hidden type, but EVP requires that the size be known */
|
| 40 |
+
|
| 41 |
+
# define CAMELLIA_TABLE_BYTE_LEN 272
|
| 42 |
+
# define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / 4)
|
| 43 |
+
|
| 44 |
+
typedef unsigned int KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN]; /* to match
|
| 45 |
+
* with WORD */
|
| 46 |
+
|
| 47 |
+
struct camellia_key_st {
|
| 48 |
+
union {
|
| 49 |
+
double d; /* ensures 64-bit align */
|
| 50 |
+
KEY_TABLE_TYPE rd_key;
|
| 51 |
+
} u;
|
| 52 |
+
int grand_rounds;
|
| 53 |
+
};
|
| 54 |
+
typedef struct camellia_key_st CAMELLIA_KEY;
|
| 55 |
+
|
| 56 |
+
# endif /* OPENSSL_NO_DEPRECATED_3_0 */
|
| 57 |
+
# ifndef OPENSSL_NO_DEPRECATED_3_0
|
| 58 |
+
OSSL_DEPRECATEDIN_3_0 int Camellia_set_key(const unsigned char *userKey,
|
| 59 |
+
const int bits,
|
| 60 |
+
CAMELLIA_KEY *key);
|
| 61 |
+
OSSL_DEPRECATEDIN_3_0 void Camellia_encrypt(const unsigned char *in,
|
| 62 |
+
unsigned char *out,
|
| 63 |
+
const CAMELLIA_KEY *key);
|
| 64 |
+
OSSL_DEPRECATEDIN_3_0 void Camellia_decrypt(const unsigned char *in,
|
| 65 |
+
unsigned char *out,
|
| 66 |
+
const CAMELLIA_KEY *key);
|
| 67 |
+
OSSL_DEPRECATEDIN_3_0 void Camellia_ecb_encrypt(const unsigned char *in,
|
| 68 |
+
unsigned char *out,
|
| 69 |
+
const CAMELLIA_KEY *key,
|
| 70 |
+
const int enc);
|
| 71 |
+
OSSL_DEPRECATEDIN_3_0 void Camellia_cbc_encrypt(const unsigned char *in,
|
| 72 |
+
unsigned char *out,
|
| 73 |
+
size_t length,
|
| 74 |
+
const CAMELLIA_KEY *key,
|
| 75 |
+
unsigned char *ivec,
|
| 76 |
+
const int enc);
|
| 77 |
+
OSSL_DEPRECATEDIN_3_0 void Camellia_cfb128_encrypt(const unsigned char *in,
|
| 78 |
+
unsigned char *out,
|
| 79 |
+
size_t length,
|
| 80 |
+
const CAMELLIA_KEY *key,
|
| 81 |
+
unsigned char *ivec,
|
| 82 |
+
int *num,
|
| 83 |
+
const int enc);
|
| 84 |
+
OSSL_DEPRECATEDIN_3_0 void Camellia_cfb1_encrypt(const unsigned char *in,
|
| 85 |
+
unsigned char *out,
|
| 86 |
+
size_t length,
|
| 87 |
+
const CAMELLIA_KEY *key,
|
| 88 |
+
unsigned char *ivec,
|
| 89 |
+
int *num,
|
| 90 |
+
const int enc);
|
| 91 |
+
OSSL_DEPRECATEDIN_3_0 void Camellia_cfb8_encrypt(const unsigned char *in,
|
| 92 |
+
unsigned char *out,
|
| 93 |
+
size_t length,
|
| 94 |
+
const CAMELLIA_KEY *key,
|
| 95 |
+
unsigned char *ivec,
|
| 96 |
+
int *num,
|
| 97 |
+
const int enc);
|
| 98 |
+
OSSL_DEPRECATEDIN_3_0 void Camellia_ofb128_encrypt(const unsigned char *in,
|
| 99 |
+
unsigned char *out,
|
| 100 |
+
size_t length,
|
| 101 |
+
const CAMELLIA_KEY *key,
|
| 102 |
+
unsigned char *ivec,
|
| 103 |
+
int *num);
|
| 104 |
+
OSSL_DEPRECATEDIN_3_0
|
| 105 |
+
void Camellia_ctr128_encrypt(const unsigned char *in, unsigned char *out,
|
| 106 |
+
size_t length, const CAMELLIA_KEY *key,
|
| 107 |
+
unsigned char ivec[CAMELLIA_BLOCK_SIZE],
|
| 108 |
+
unsigned char ecount_buf[CAMELLIA_BLOCK_SIZE],
|
| 109 |
+
unsigned int *num);
|
| 110 |
+
# endif
|
| 111 |
+
|
| 112 |
+
# ifdef __cplusplus
|
| 113 |
+
}
|
| 114 |
+
# endif
|
| 115 |
+
# endif
|
| 116 |
+
|
| 117 |
+
#endif
|
llava_next/include/openssl/comperr.h
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
/*
|
| 2 |
+
* Generated by util/mkerr.pl DO NOT EDIT
|
| 3 |
+
* Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
|
| 4 |
+
*
|
| 5 |
+
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
| 6 |
+
* this file except in compliance with the License. You can obtain a copy
|
| 7 |
+
* in the file LICENSE in the source distribution or at
|
| 8 |
+
* https://www.openssl.org/source/license.html
|
| 9 |
+
*/
|
| 10 |
+
|
| 11 |
+
#ifndef OPENSSL_COMPERR_H
|
| 12 |
+
# define OPENSSL_COMPERR_H
|
| 13 |
+
# pragma once
|
| 14 |
+
|
| 15 |
+
# include <openssl/opensslconf.h>
|
| 16 |
+
# include <openssl/symhacks.h>
|
| 17 |
+
# include <openssl/cryptoerr_legacy.h>
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
# ifndef OPENSSL_NO_COMP
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
/*
|
| 24 |
+
* COMP reason codes.
|
| 25 |
+
*/
|
| 26 |
+
# define COMP_R_ZLIB_DEFLATE_ERROR 99
|
| 27 |
+
# define COMP_R_ZLIB_INFLATE_ERROR 100
|
| 28 |
+
# define COMP_R_ZLIB_NOT_SUPPORTED 101
|
| 29 |
+
|
| 30 |
+
# endif
|
| 31 |
+
#endif
|