Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 1 | /**************************************************************************** |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 2 | * Copyright 2018-2022,2023 Thomas E. Dickey * |
| 3 | * Copyright 1998-2013,2017 Free Software Foundation, Inc. * |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 4 | * * |
| 5 | * Permission is hereby granted, free of charge, to any person obtaining a * |
| 6 | * copy of this software and associated documentation files (the * |
| 7 | * "Software"), to deal in the Software without restriction, including * |
| 8 | * without limitation the rights to use, copy, modify, merge, publish, * |
| 9 | * distribute, distribute with modifications, sublicense, and/or sell * |
| 10 | * copies of the Software, and to permit persons to whom the Software is * |
| 11 | * furnished to do so, subject to the following conditions: * |
| 12 | * * |
| 13 | * The above copyright notice and this permission notice shall be included * |
| 14 | * in all copies or substantial portions of the Software. * |
| 15 | * * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * |
| 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * |
| 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * |
| 19 | * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * |
| 20 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * |
| 21 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * |
| 22 | * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * |
| 23 | * * |
| 24 | * Except as contained in this notice, the name(s) of the above copyright * |
| 25 | * holders shall not be used in advertising or otherwise to promote the * |
| 26 | * sale, use or other dealings in this Software without prior written * |
| 27 | * authorization. * |
| 28 | ****************************************************************************/ |
| 29 | |
| 30 | /**************************************************************************** |
| 31 | * Author: 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 | * toe.c --- table of entries report generator |
| 38 | */ |
| 39 | |
| 40 | #include <progs.priv.h> |
| 41 | |
| 42 | #include <sys/stat.h> |
| 43 | |
| 44 | #if USE_HASHED_DB |
| 45 | #include <hashed_db.h> |
| 46 | #endif |
| 47 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 48 | MODULE_ID("$Id: toe.c,v 1.89 2023/07/01 17:04:46 tom Exp $") |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 49 | |
| 50 | #define isDotname(name) (!strcmp(name, ".") || !strcmp(name, "..")) |
| 51 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 52 | typedef struct { |
| 53 | int db_index; |
| 54 | unsigned long checksum; |
| 55 | char *term_name; |
| 56 | char *description; |
| 57 | } TERMDATA; |
| 58 | |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 59 | const char *_nc_progname; |
| 60 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 61 | static TERMDATA *ptr_termdata; /* array of terminal data */ |
| 62 | static size_t use_termdata; /* actual usage in ptr_termdata[] */ |
| 63 | static size_t len_termdata; /* allocated size of ptr_termdata[] */ |
| 64 | |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 65 | #if NO_LEAKS |
| 66 | #undef ExitProgram |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 67 | static GCC_NORETURN void ExitProgram(int code); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 68 | static void |
| 69 | ExitProgram(int code) |
| 70 | { |
| 71 | _nc_free_entries(_nc_head); |
| 72 | _nc_free_tic(code); |
| 73 | } |
| 74 | #endif |
| 75 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 76 | static GCC_NORETURN void failed(const char *); |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 77 | |
| 78 | static void |
| 79 | failed(const char *msg) |
| 80 | { |
| 81 | perror(msg); |
| 82 | ExitProgram(EXIT_FAILURE); |
| 83 | } |
| 84 | |
| 85 | static char * |
| 86 | strmalloc(const char *value) |
| 87 | { |
| 88 | char *result = strdup(value); |
| 89 | if (result == 0) { |
| 90 | failed("strmalloc"); |
| 91 | } |
| 92 | return result; |
| 93 | } |
| 94 | |
| 95 | static TERMDATA * |
| 96 | new_termdata(void) |
| 97 | { |
| 98 | size_t want = use_termdata + 1; |
| 99 | |
| 100 | if (want >= len_termdata) { |
| 101 | len_termdata = (2 * want) + 10; |
| 102 | ptr_termdata = typeRealloc(TERMDATA, len_termdata, ptr_termdata); |
| 103 | if (ptr_termdata == 0) |
| 104 | failed("ptr_termdata"); |
| 105 | } |
| 106 | |
| 107 | return ptr_termdata + use_termdata++; |
| 108 | } |
| 109 | |
| 110 | static int |
| 111 | compare_termdata(const void *a, const void *b) |
| 112 | { |
| 113 | const TERMDATA *p = (const TERMDATA *) a; |
| 114 | const TERMDATA *q = (const TERMDATA *) b; |
| 115 | int result = strcmp(p->term_name, q->term_name); |
| 116 | |
| 117 | if (result == 0) { |
| 118 | result = (p->db_index - q->db_index); |
| 119 | } |
| 120 | return result; |
| 121 | } |
| 122 | |
| 123 | /* |
| 124 | * Sort the array of TERMDATA and print it. If more than one database is being |
| 125 | * reported, add a column to show which database has a given entry. |
| 126 | */ |
| 127 | static void |
| 128 | show_termdata(int eargc, char **eargv) |
| 129 | { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 130 | if (use_termdata) { |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 131 | size_t n; |
| 132 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 133 | if (eargc > 1) { |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 134 | int j; |
| 135 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 136 | for (j = 0; j < eargc; ++j) { |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 137 | int k; |
| 138 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 139 | for (k = 0; k <= j; ++k) { |
| 140 | printf("--"); |
| 141 | } |
| 142 | printf("> "); |
| 143 | printf("%s\n", eargv[j]); |
| 144 | } |
| 145 | } |
| 146 | if (use_termdata > 1) |
| 147 | qsort(ptr_termdata, use_termdata, sizeof(TERMDATA), compare_termdata); |
| 148 | for (n = 0; n < use_termdata; ++n) { |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 149 | int nk = -1; |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 150 | |
| 151 | /* |
| 152 | * If there is more than one database, show how they differ. |
| 153 | */ |
| 154 | if (eargc > 1) { |
| 155 | unsigned long check = 0; |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 156 | int k = 0; |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 157 | for (;;) { |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 158 | char mark = ((check == 0 |
| 159 | || (check != ptr_termdata[n].checksum)) |
| 160 | ? '*' |
| 161 | : '+'); |
| 162 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 163 | for (; k < ptr_termdata[n].db_index; ++k) { |
| 164 | printf("--"); |
| 165 | } |
| 166 | |
| 167 | /* |
| 168 | * If this is the first entry, or its checksum differs |
| 169 | * from the first entry's checksum, print "*". Otherwise |
| 170 | * it looks enough like a duplicate to print "+". |
| 171 | */ |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 172 | printf("%c-", mark); |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 173 | check = ptr_termdata[n].checksum; |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 174 | if (mark == '*' && nk < 0) |
| 175 | nk = (int) n; |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 176 | |
| 177 | ++k; |
| 178 | if ((n + 1) >= use_termdata |
| 179 | || strcmp(ptr_termdata[n].term_name, |
| 180 | ptr_termdata[n + 1].term_name)) { |
| 181 | break; |
| 182 | } |
| 183 | ++n; |
| 184 | } |
| 185 | for (; k < eargc; ++k) { |
| 186 | printf("--"); |
| 187 | } |
| 188 | printf(":\t"); |
| 189 | } |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 190 | if (nk < 0) |
| 191 | nk = (int) n; |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 192 | |
| 193 | (void) printf("%-10s\t%s\n", |
| 194 | ptr_termdata[n].term_name, |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 195 | ptr_termdata[nk].description); |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 196 | } |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | static void |
| 201 | free_termdata(void) |
| 202 | { |
| 203 | if (ptr_termdata != 0) { |
| 204 | while (use_termdata != 0) { |
| 205 | --use_termdata; |
| 206 | free(ptr_termdata[use_termdata].term_name); |
| 207 | free(ptr_termdata[use_termdata].description); |
| 208 | } |
| 209 | free(ptr_termdata); |
| 210 | ptr_termdata = 0; |
| 211 | } |
| 212 | use_termdata = 0; |
| 213 | len_termdata = 0; |
| 214 | } |
| 215 | |
| 216 | static char ** |
| 217 | allocArgv(size_t count) |
| 218 | { |
| 219 | char **result = typeCalloc(char *, count + 1); |
| 220 | if (result == 0) |
| 221 | failed("realloc eargv"); |
| 222 | |
| 223 | assert(result != 0); |
| 224 | return result; |
| 225 | } |
| 226 | |
| 227 | static void |
| 228 | freeArgv(char **argv) |
| 229 | { |
| 230 | if (argv) { |
| 231 | int count = 0; |
| 232 | while (argv[count]) { |
| 233 | free(argv[count++]); |
| 234 | } |
| 235 | free(argv); |
| 236 | } |
| 237 | } |
| 238 | |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 239 | #if USE_HASHED_DB |
| 240 | static bool |
| 241 | make_db_name(char *dst, const char *src, unsigned limit) |
| 242 | { |
| 243 | static const char suffix[] = DBM_SUFFIX; |
| 244 | |
| 245 | bool result = FALSE; |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 246 | size_t lens = sizeof(suffix) - 1; |
| 247 | size_t size = strlen(src); |
| 248 | size_t need = lens + size; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 249 | |
| 250 | if (need <= limit) { |
| 251 | if (size >= lens |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 252 | && !strcmp(src + size - lens, suffix)) { |
| 253 | _nc_STRCPY(dst, src, PATH_MAX); |
| 254 | } else { |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 255 | _nc_SPRINTF(dst, _nc_SLIMIT(PATH_MAX) "%.*s%s", |
| 256 | (int) (PATH_MAX - sizeof(suffix)), |
| 257 | src, suffix); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 258 | } |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 259 | result = TRUE; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 260 | } |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 261 | return result; |
| 262 | } |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 263 | #endif |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 264 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 265 | typedef void (DescHook) (int /* db_index */ , |
| 266 | int /* db_limit */ , |
| 267 | const char * /* term_name */ , |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 268 | TERMTYPE2 * /* term */ ); |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 269 | |
| 270 | static const char * |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 271 | term_description(TERMTYPE2 *tp) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 272 | { |
| 273 | const char *desc; |
| 274 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 275 | if (tp->term_names == 0 |
| 276 | || (desc = strrchr(tp->term_names, '|')) == 0 |
| 277 | || (*++desc == '\0')) { |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 278 | desc = "(No description)"; |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 279 | } |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 280 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 281 | return desc; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 282 | } |
| 283 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 284 | /* display a description for the type */ |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 285 | static void |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 286 | deschook(int db_index, int db_limit, const char *term_name, TERMTYPE2 *tp) |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 287 | { |
| 288 | (void) db_index; |
| 289 | (void) db_limit; |
| 290 | (void) printf("%-10s\t%s\n", term_name, term_description(tp)); |
| 291 | } |
| 292 | |
| 293 | static unsigned long |
| 294 | string_sum(const char *value) |
| 295 | { |
| 296 | unsigned long result = 0; |
| 297 | |
| 298 | if ((intptr_t) value == (intptr_t) (-1)) { |
| 299 | result = ~result; |
| 300 | } else if (value) { |
| 301 | while (*value) { |
| 302 | result += UChar(*value); |
| 303 | ++value; |
| 304 | } |
| 305 | } |
| 306 | return result; |
| 307 | } |
| 308 | |
| 309 | static unsigned long |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 310 | checksum_of(TERMTYPE2 *tp) |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 311 | { |
| 312 | unsigned long result = string_sum(tp->term_names); |
| 313 | unsigned i; |
| 314 | |
| 315 | for (i = 0; i < NUM_BOOLEANS(tp); i++) { |
| 316 | result += (unsigned long) (tp->Booleans[i]); |
| 317 | } |
| 318 | for (i = 0; i < NUM_NUMBERS(tp); i++) { |
| 319 | result += (unsigned long) (tp->Numbers[i]); |
| 320 | } |
| 321 | for (i = 0; i < NUM_STRINGS(tp); i++) { |
| 322 | result += string_sum(tp->Strings[i]); |
| 323 | } |
| 324 | return result; |
| 325 | } |
| 326 | |
| 327 | /* collect data, to sort before display */ |
| 328 | static void |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 329 | sorthook(int db_index, int db_limit, const char *term_name, TERMTYPE2 *tp) |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 330 | { |
| 331 | TERMDATA *data = new_termdata(); |
| 332 | |
| 333 | data->db_index = db_index; |
| 334 | data->checksum = ((db_limit > 1) ? checksum_of(tp) : 0); |
| 335 | data->term_name = strmalloc(term_name); |
| 336 | data->description = strmalloc(term_description(tp)); |
| 337 | } |
| 338 | |
| 339 | #if NCURSES_USE_TERMCAP |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 340 | /* |
| 341 | * Check if the buffer contents are printable ASCII, ensuring that we do not |
| 342 | * accidentally pick up incompatible binary content from a hashed database. |
| 343 | */ |
| 344 | static bool |
| 345 | is_termcap(char *buffer) |
| 346 | { |
| 347 | bool result = TRUE; |
| 348 | while (*buffer != '\0') { |
| 349 | int ch = UChar(*buffer++); |
| 350 | if (ch == '\t') |
| 351 | continue; |
| 352 | if (ch < ' ' || ch > '~') { |
| 353 | result = FALSE; |
| 354 | break; |
| 355 | } |
| 356 | } |
| 357 | return result; |
| 358 | } |
| 359 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 360 | static void |
| 361 | show_termcap(int db_index, int db_limit, char *buffer, DescHook hook) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 362 | { |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 363 | TERMTYPE2 data; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 364 | char *next = strchr(buffer, ':'); |
| 365 | char *last; |
| 366 | char *list = buffer; |
| 367 | |
| 368 | if (next) |
| 369 | *next = '\0'; |
| 370 | |
| 371 | last = strrchr(buffer, '|'); |
| 372 | if (last) |
| 373 | ++last; |
| 374 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 375 | memset(&data, 0, sizeof(data)); |
| 376 | data.term_names = strmalloc(buffer); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 377 | while ((next = strtok(list, "|")) != 0) { |
| 378 | if (next != last) |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 379 | hook(db_index, db_limit, next, &data); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 380 | list = 0; |
| 381 | } |
| 382 | free(data.term_names); |
| 383 | } |
| 384 | #endif |
| 385 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 386 | #if NCURSES_USE_DATABASE |
| 387 | static char * |
| 388 | copy_entryname(DIRENT * src) |
| 389 | { |
| 390 | size_t len = NAMLEN(src); |
| 391 | char *result = malloc(len + 1); |
| 392 | if (result == 0) |
| 393 | failed("copy entryname"); |
| 394 | memcpy(result, src->d_name, len); |
| 395 | result[len] = '\0'; |
| 396 | |
| 397 | return result; |
| 398 | } |
| 399 | #endif |
| 400 | |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 401 | static int |
| 402 | typelist(int eargc, char *eargv[], |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 403 | int verbosity, |
| 404 | DescHook hook) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 405 | /* apply a function to each entry in given terminfo directories */ |
| 406 | { |
| 407 | int i; |
| 408 | |
| 409 | for (i = 0; i < eargc; i++) { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 410 | #if NCURSES_USE_DATABASE |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 411 | if (_nc_is_dir_path(eargv[i])) { |
| 412 | char *cwd_buf = 0; |
| 413 | DIR *termdir; |
| 414 | DIRENT *subdir; |
| 415 | |
| 416 | if ((termdir = opendir(eargv[i])) == 0) { |
| 417 | (void) fflush(stdout); |
| 418 | (void) fprintf(stderr, |
| 419 | "%s: can't open terminfo directory %s\n", |
| 420 | _nc_progname, eargv[i]); |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 421 | continue; |
| 422 | } |
| 423 | |
| 424 | if (verbosity) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 425 | (void) printf("#\n#%s:\n#\n", eargv[i]); |
| 426 | |
| 427 | while ((subdir = readdir(termdir)) != 0) { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 428 | size_t cwd_len; |
| 429 | char *name_1; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 430 | DIR *entrydir; |
| 431 | DIRENT *entry; |
| 432 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 433 | name_1 = copy_entryname(subdir); |
| 434 | if (isDotname(name_1)) { |
| 435 | free(name_1); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 436 | continue; |
| 437 | } |
| 438 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 439 | cwd_len = NAMLEN(subdir) + strlen(eargv[i]) + 3; |
| 440 | cwd_buf = typeRealloc(char, cwd_len, cwd_buf); |
| 441 | if (cwd_buf == 0) |
| 442 | failed("realloc cwd_buf"); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 443 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 444 | assert(cwd_buf != 0); |
| 445 | |
| 446 | _nc_SPRINTF(cwd_buf, _nc_SLIMIT(cwd_len) |
| 447 | "%s/%s/", eargv[i], name_1); |
| 448 | free(name_1); |
| 449 | |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 450 | if (chdir(cwd_buf) != 0) |
| 451 | continue; |
| 452 | |
| 453 | entrydir = opendir("."); |
| 454 | if (entrydir == 0) { |
| 455 | perror(cwd_buf); |
| 456 | continue; |
| 457 | } |
| 458 | while ((entry = readdir(entrydir)) != 0) { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 459 | char *name_2; |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 460 | TERMTYPE2 lterm; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 461 | char *cn; |
| 462 | int status; |
| 463 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 464 | name_2 = copy_entryname(entry); |
| 465 | if (isDotname(name_2) || !_nc_is_file_path(name_2)) { |
| 466 | free(name_2); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 467 | continue; |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 468 | } |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 469 | |
| 470 | status = _nc_read_file_entry(name_2, <erm); |
| 471 | if (status <= 0) { |
| 472 | (void) fflush(stdout); |
| 473 | (void) fprintf(stderr, |
| 474 | "%s: couldn't open terminfo file %s.\n", |
| 475 | _nc_progname, name_2); |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 476 | free(name_2); |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 477 | continue; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 478 | } |
| 479 | |
| 480 | /* only visit things once, by primary name */ |
| 481 | cn = _nc_first_name(lterm.term_names); |
| 482 | if (!strcmp(cn, name_2)) { |
| 483 | /* apply the selected hook function */ |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 484 | hook(i, eargc, cn, <erm); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 485 | } |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 486 | _nc_free_termtype2(<erm); |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 487 | free(name_2); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 488 | } |
| 489 | closedir(entrydir); |
| 490 | } |
| 491 | closedir(termdir); |
| 492 | if (cwd_buf != 0) |
| 493 | free(cwd_buf); |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 494 | continue; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 495 | } |
| 496 | #if USE_HASHED_DB |
| 497 | else { |
| 498 | DB *capdbp; |
| 499 | char filename[PATH_MAX]; |
| 500 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 501 | if (verbosity) |
| 502 | (void) printf("#\n#%s:\n#\n", eargv[i]); |
| 503 | |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 504 | if (make_db_name(filename, eargv[i], sizeof(filename))) { |
| 505 | if ((capdbp = _nc_db_open(filename, FALSE)) != 0) { |
| 506 | DBT key, data; |
| 507 | int code; |
| 508 | |
| 509 | code = _nc_db_first(capdbp, &key, &data); |
| 510 | while (code == 0) { |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 511 | TERMTYPE2 lterm; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 512 | int used; |
| 513 | char *have; |
| 514 | char *cn; |
| 515 | |
| 516 | if (_nc_db_have_data(&key, &data, &have, &used)) { |
| 517 | if (_nc_read_termtype(<erm, have, used) > 0) { |
| 518 | /* only visit things once, by primary name */ |
| 519 | cn = _nc_first_name(lterm.term_names); |
| 520 | /* apply the selected hook function */ |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 521 | hook(i, eargc, cn, <erm); |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 522 | _nc_free_termtype2(<erm); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 523 | } |
| 524 | } |
| 525 | code = _nc_db_next(capdbp, &key, &data); |
| 526 | } |
| 527 | |
| 528 | _nc_db_close(capdbp); |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 529 | continue; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 530 | } |
| 531 | } |
| 532 | } |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 533 | #endif /* USE_HASHED_DB */ |
| 534 | #endif /* NCURSES_USE_DATABASE */ |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 535 | #if NCURSES_USE_TERMCAP |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 536 | #if HAVE_BSD_CGETENT |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 537 | { |
| 538 | CGETENT_CONST char *db_array[2]; |
| 539 | char *buffer = 0; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 540 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 541 | if (verbosity) |
| 542 | (void) printf("#\n#%s:\n#\n", eargv[i]); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 543 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 544 | db_array[0] = eargv[i]; |
| 545 | db_array[1] = 0; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 546 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 547 | if (cgetfirst(&buffer, db_array) > 0) { |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 548 | if (is_termcap(buffer)) { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 549 | show_termcap(i, eargc, buffer, hook); |
| 550 | free(buffer); |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 551 | while (cgetnext(&buffer, db_array) > 0) { |
| 552 | show_termcap(i, eargc, buffer, hook); |
| 553 | free(buffer); |
| 554 | } |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 555 | } |
| 556 | cgetclose(); |
| 557 | continue; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 558 | } |
| 559 | } |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 560 | #else |
| 561 | /* scan termcap text-file only */ |
| 562 | if (_nc_is_file_path(eargv[i])) { |
| 563 | char buffer[2048]; |
| 564 | FILE *fp; |
| 565 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 566 | if (verbosity) |
| 567 | (void) printf("#\n#%s:\n#\n", eargv[i]); |
| 568 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 569 | if ((fp = safe_fopen(eargv[i], "r")) != 0) { |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 570 | while (fgets(buffer, sizeof(buffer), fp) != 0) { |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 571 | if (!is_termcap(buffer)) |
| 572 | break; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 573 | if (*buffer == '#') |
| 574 | continue; |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 575 | if (isspace(UChar(*buffer))) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 576 | continue; |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 577 | show_termcap(i, eargc, buffer, hook); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 578 | } |
| 579 | fclose(fp); |
| 580 | } |
| 581 | } |
| 582 | #endif |
| 583 | #endif |
| 584 | } |
| 585 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 586 | if (hook == sorthook) { |
| 587 | show_termdata(eargc, eargv); |
| 588 | free_termdata(); |
| 589 | } |
| 590 | |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 591 | return (EXIT_SUCCESS); |
| 592 | } |
| 593 | |
| 594 | static void |
| 595 | usage(void) |
| 596 | { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 597 | (void) fprintf(stderr, "usage: %s [-ahsuUV] [-v n] [file...]\n", _nc_progname); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 598 | ExitProgram(EXIT_FAILURE); |
| 599 | } |
| 600 | |
| 601 | int |
| 602 | main(int argc, char *argv[]) |
| 603 | { |
| 604 | bool all_dirs = FALSE; |
| 605 | bool direct_dependencies = FALSE; |
| 606 | bool invert_dependencies = FALSE; |
| 607 | bool header = FALSE; |
| 608 | char *report_file = 0; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 609 | int code; |
| 610 | int this_opt, last_opt = '?'; |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 611 | unsigned v_opt = 0; |
| 612 | DescHook *hook = deschook; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 613 | |
| 614 | _nc_progname = _nc_rootname(argv[0]); |
| 615 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 616 | while ((this_opt = getopt(argc, argv, "0123456789ahsu:vU:V")) != -1) { |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 617 | /* handle optional parameter */ |
| 618 | if (isdigit(this_opt)) { |
| 619 | switch (last_opt) { |
| 620 | case 'v': |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 621 | v_opt = (unsigned) (this_opt - '0'); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 622 | break; |
| 623 | default: |
| 624 | if (isdigit(last_opt)) |
| 625 | v_opt *= 10; |
| 626 | else |
| 627 | v_opt = 0; |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 628 | v_opt += (unsigned) (this_opt - '0'); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 629 | last_opt = this_opt; |
| 630 | } |
| 631 | continue; |
| 632 | } |
| 633 | switch (this_opt) { |
| 634 | case 'a': |
| 635 | all_dirs = TRUE; |
| 636 | break; |
| 637 | case 'h': |
| 638 | header = TRUE; |
| 639 | break; |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 640 | case 's': |
| 641 | hook = sorthook; |
| 642 | break; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 643 | case 'u': |
| 644 | direct_dependencies = TRUE; |
| 645 | report_file = optarg; |
| 646 | break; |
| 647 | case 'v': |
| 648 | v_opt = 1; |
| 649 | break; |
| 650 | case 'U': |
| 651 | invert_dependencies = TRUE; |
| 652 | report_file = optarg; |
| 653 | break; |
| 654 | case 'V': |
| 655 | puts(curses_version()); |
| 656 | ExitProgram(EXIT_SUCCESS); |
| 657 | default: |
| 658 | usage(); |
| 659 | } |
| 660 | } |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 661 | use_verbosity(v_opt); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 662 | |
| 663 | if (report_file != 0) { |
| 664 | if (freopen(report_file, "r", stdin) == 0) { |
| 665 | (void) fflush(stdout); |
| 666 | fprintf(stderr, "%s: can't open %s\n", _nc_progname, report_file); |
| 667 | ExitProgram(EXIT_FAILURE); |
| 668 | } |
| 669 | |
| 670 | /* parse entries out of the source file */ |
| 671 | _nc_set_source(report_file); |
| 672 | _nc_read_entry_source(stdin, 0, FALSE, FALSE, NULLHOOK); |
| 673 | } |
| 674 | |
| 675 | /* maybe we want a direct-dependency listing? */ |
| 676 | if (direct_dependencies) { |
| 677 | ENTRY *qp; |
| 678 | |
| 679 | for_entry_list(qp) { |
| 680 | if (qp->nuses) { |
| 681 | unsigned j; |
| 682 | |
| 683 | (void) printf("%s:", _nc_first_name(qp->tterm.term_names)); |
| 684 | for (j = 0; j < qp->nuses; j++) |
| 685 | (void) printf(" %s", qp->uses[j].name); |
| 686 | putchar('\n'); |
| 687 | } |
| 688 | } |
| 689 | |
| 690 | ExitProgram(EXIT_SUCCESS); |
| 691 | } |
| 692 | |
| 693 | /* maybe we want a reverse-dependency listing? */ |
| 694 | if (invert_dependencies) { |
| 695 | ENTRY *qp, *rp; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 696 | |
| 697 | for_entry_list(qp) { |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 698 | int matchcount = 0; |
| 699 | |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 700 | for_entry_list(rp) { |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 701 | unsigned i; |
| 702 | |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 703 | if (rp->nuses == 0) |
| 704 | continue; |
| 705 | |
| 706 | for (i = 0; i < rp->nuses; i++) |
| 707 | if (_nc_name_match(qp->tterm.term_names, |
| 708 | rp->uses[i].name, "|")) { |
| 709 | if (matchcount++ == 0) |
| 710 | (void) printf("%s:", |
| 711 | _nc_first_name(qp->tterm.term_names)); |
| 712 | (void) printf(" %s", |
| 713 | _nc_first_name(rp->tterm.term_names)); |
| 714 | } |
| 715 | } |
| 716 | if (matchcount) |
| 717 | putchar('\n'); |
| 718 | } |
| 719 | |
| 720 | ExitProgram(EXIT_SUCCESS); |
| 721 | } |
| 722 | |
| 723 | /* |
| 724 | * If we get this far, user wants a simple terminal type listing. |
| 725 | */ |
| 726 | if (optind < argc) { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 727 | code = typelist(argc - optind, argv + optind, header, hook); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 728 | } else if (all_dirs) { |
| 729 | DBDIRS state; |
| 730 | int offset; |
| 731 | int pass; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 732 | char **eargv = 0; |
| 733 | |
| 734 | code = EXIT_FAILURE; |
| 735 | for (pass = 0; pass < 2; ++pass) { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 736 | size_t count = 0; |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 737 | const char *path; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 738 | |
| 739 | _nc_first_db(&state, &offset); |
| 740 | while ((path = _nc_next_db(&state, &offset)) != 0) { |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 741 | if (quick_prefix(path)) |
| 742 | continue; |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 743 | if (pass) { |
| 744 | eargv[count] = strmalloc(path); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 745 | } |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 746 | ++count; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 747 | } |
| 748 | if (!pass) { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 749 | eargv = allocArgv(count); |
| 750 | if (eargv == 0) |
| 751 | failed("eargv"); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 752 | } else { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 753 | code = typelist((int) count, eargv, header, hook); |
| 754 | freeArgv(eargv); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 755 | } |
| 756 | } |
| 757 | } else { |
| 758 | DBDIRS state; |
| 759 | int offset; |
| 760 | const char *path; |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 761 | char **eargv = allocArgv((size_t) 2); |
| 762 | size_t count = 0; |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 763 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 764 | if (eargv == 0) |
| 765 | failed("eargv"); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 766 | _nc_first_db(&state, &offset); |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 767 | if ((path = _nc_next_db(&state, &offset)) != 0) { |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 768 | if (!quick_prefix(path)) |
| 769 | eargv[count++] = strmalloc(path); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 770 | } |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 771 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 772 | code = typelist((int) count, eargv, header, hook); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 773 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 774 | freeArgv(eargv); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 775 | } |
| 776 | _nc_last_db(); |
| 777 | |
| 778 | ExitProgram(code); |
| 779 | } |