1 /* -*- buffer-read-only: t -*- vi: set ro: 2 * 3 * Prototypes for autoopts 4 * Generated Sun Aug 26 10:44:39 PDT 2018 5 */ 6 #ifndef AUTOOPTS_PROTO_H_GUARD 7 #define AUTOOPTS_PROTO_H_GUARD 1 8 9 10 /* 11 * Static declarations from alias.c 12 */ 13 static tSuccess 14 too_many_occurrences(tOptions * opts, tOptDesc * od); 15 16 /* 17 * Static declarations from autoopts.c 18 */ 19 static void * 20 ao_malloc(size_t sz); 21 22 static void * 23 ao_realloc(void *p, size_t sz); 24 25 static char * 26 ao_strdup(char const *str); 27 28 static tSuccess 29 handle_opt(tOptions * opts, tOptState * o_st); 30 31 static tSuccess 32 next_opt(tOptions * opts, tOptState * o_st); 33 34 static tSuccess 35 regular_opts(tOptions * opts); 36 37 /* 38 * Static declarations from check.c 39 */ 40 static bool 41 has_conflict(tOptions * pOpts, tOptDesc * od); 42 43 static bool 44 occurs_enough(tOptions * pOpts, tOptDesc * pOD); 45 46 static bool 47 is_consistent(tOptions * pOpts); 48 49 /* 50 * Static declarations from configfile.c 51 */ 52 static void 53 file_preset(tOptions * opts, char const * fname, int dir); 54 55 static char * 56 handle_comment(char * txt); 57 58 static char * 59 handle_cfg(tOptions * opts, tOptState * ost, char * txt, int dir); 60 61 static char * 62 handle_directive(tOptions * opts, char * txt); 63 64 static char * 65 aoflags_directive(tOptions * opts, char * txt); 66 67 static char * 68 program_directive(tOptions * opts, char * txt); 69 70 static char * 71 handle_section(tOptions * opts, char * txt); 72 73 static int 74 parse_xml_encoding(char ** ppz); 75 76 static char * 77 trim_xml_text(char * intxt, char const * pznm, tOptionLoadMode mode); 78 79 static void 80 cook_xml_text(char * pzData); 81 82 static char * 83 handle_struct(tOptions * opts, tOptState * ost, char * txt, int dir); 84 85 static void 86 intern_file_load(tOptions * opts); 87 88 static char const * 89 parse_attrs(tOptions * opts, char const * txt, tOptionLoadMode * pMode, 90 tOptionValue * pType); 91 92 static char const * 93 parse_keyword(tOptions * opts, char const * txt, tOptionValue * typ); 94 95 static char const * 96 parse_set_mem(tOptions * opts, char const * txt, tOptionValue * typ); 97 98 static char const * 99 parse_value(char const * txt, tOptionValue * typ); 100 101 /* 102 * Static declarations from cook.c 103 */ 104 static char * 105 nl_count(char * start, char * end, int * lnct_p); 106 107 static bool 108 contiguous_quote(char ** pps, char * pq, int * lnct_p); 109 110 /* 111 * Static declarations from enum.c 112 */ 113 static void 114 enum_err(tOptions * pOpts, tOptDesc * pOD, 115 char const * const * paz_names, int name_ct); 116 117 static uintptr_t 118 find_name(char const * name, tOptions * pOpts, tOptDesc * pOD, 119 char const * const * paz_names, unsigned int name_ct); 120 121 static void 122 set_memb_shell(tOptions * pOpts, tOptDesc * pOD, char const * const * paz_names, 123 unsigned int name_ct); 124 125 static void 126 set_memb_names(tOptions * opts, tOptDesc * od, char const * const * nm_list, 127 unsigned int nm_ct); 128 129 static uintptr_t 130 check_membership_start(tOptDesc * od, char const ** argp, bool * invert); 131 132 static uintptr_t 133 find_member_bit(tOptions * opts, tOptDesc * od, char const * pz, int len, 134 char const * const * nm_list, unsigned int nm_ct); 135 136 /* 137 * Static declarations from env.c 138 */ 139 static void 140 doPrognameEnv(tOptions * pOpts, teEnvPresetType type); 141 142 static void 143 do_env_opt(tOptState * os, char * env_name, 144 tOptions * pOpts, teEnvPresetType type); 145 146 static void 147 env_presets(tOptions * pOpts, teEnvPresetType type); 148 149 /* 150 * Static declarations from file.c 151 */ 152 static void 153 check_existence(teOptFileType ftype, tOptions * pOpts, tOptDesc * pOD); 154 155 static void 156 open_file_fd(tOptions * pOpts, tOptDesc * pOD, tuFileMode mode); 157 158 static void 159 fopen_file_fp(tOptions * pOpts, tOptDesc * pOD, tuFileMode mode); 160 161 /* 162 * Static declarations from find.c 163 */ 164 static int 165 parse_opt(char const ** nm_pp, char ** arg_pp, char * buf, size_t bufsz); 166 167 static void 168 opt_ambiguities(tOptions * opts, char const * name, int nm_len); 169 170 static int 171 opt_match_ct(tOptions * opts, char const * name, int nm_len, 172 int * ixp, bool * disable); 173 174 static tSuccess 175 opt_set(tOptions * opts, char * arg, int idx, bool disable, tOptState * st); 176 177 static tSuccess 178 opt_unknown(tOptions * opts, char const * name, char * arg, tOptState * st); 179 180 static tSuccess 181 opt_ambiguous(tOptions * opts, char const * name, int match_ct); 182 183 static tSuccess 184 opt_find_long(tOptions * opts, char const * opt_name, tOptState * state); 185 186 static tSuccess 187 opt_find_short(tOptions * pOpts, uint_t optValue, tOptState * pOptState); 188 189 static tSuccess 190 get_opt_arg_must(tOptions * opts, tOptState * o_st); 191 192 static tSuccess 193 get_opt_arg_may(tOptions * pOpts, tOptState * o_st); 194 195 static tSuccess 196 get_opt_arg_none(tOptions * pOpts, tOptState * o_st); 197 198 static tSuccess 199 get_opt_arg(tOptions * opts, tOptState * o_st); 200 201 static tSuccess 202 find_opt(tOptions * opts, tOptState * o_st); 203 204 /* 205 * Static declarations from init.c 206 */ 207 static tSuccess 208 validate_struct(tOptions * opts, char const * pname); 209 210 static tSuccess 211 immediate_opts(tOptions * opts); 212 213 static tSuccess 214 do_presets(tOptions * opts); 215 216 static bool 217 ao_initialize(tOptions * opts, int a_ct, char ** a_v); 218 219 /* 220 * Static declarations from load.c 221 */ 222 static bool 223 get_realpath(char * buf, size_t b_sz); 224 225 static bool 226 add_prog_path(char * buf, int b_sz, char const * fname, char const * prg_path); 227 228 static bool 229 add_env_val(char * buf, int buf_sz, char const * name); 230 231 static void 232 munge_str(char * txt, tOptionLoadMode mode); 233 234 static char * 235 assemble_arg_val(char * txt, tOptionLoadMode mode); 236 237 static char * 238 trim_quotes(char * arg); 239 240 static bool 241 direction_ok(opt_state_mask_t f, int dir); 242 243 static void 244 load_opt_line(tOptions * opts, tOptState * opt_state, char * line, 245 tDirection direction, tOptionLoadMode load_mode ); 246 247 /* 248 * Static declarations from makeshell.c 249 */ 250 lo_noreturn static void 251 option_exits(int exit_code); 252 253 lo_noreturn static void 254 ao_bug(char const * msg); 255 256 static void 257 fserr_warn(char const * prog, char const * op, char const * fname); 258 259 lo_noreturn static void 260 fserr_exit(char const * prog, char const * op, char const * fname); 261 262 static void 263 emit_var_text(char const * prog, char const * var, int fdin); 264 265 static void 266 text_to_var(tOptions * opts, teTextTo which, tOptDesc * od); 267 268 static void 269 emit_usage(tOptions * opts); 270 271 static void 272 emit_wrapup(tOptions * opts); 273 274 static void 275 emit_setup(tOptions * opts); 276 277 static void 278 emit_action(tOptions * opts, tOptDesc * od); 279 280 static void 281 emit_inaction(tOptions * opts, tOptDesc * od); 282 283 static void 284 emit_flag(tOptions * opts); 285 286 static void 287 emit_match_expr(char const * name, tOptDesc * cod, tOptions * opts); 288 289 static void 290 emit_long(tOptions * opts); 291 292 static char * 293 load_old_output(char const * fname, char const * pname); 294 295 static void 296 open_out(char const * fname, char const * pname); 297 298 /* 299 * Static declarations from nested.c 300 */ 301 static void 302 remove_continuation(char * src); 303 304 static char const * 305 scan_q_str(char const * pzTxt); 306 307 static tOptionValue * 308 add_string(void ** pp, char const * name, size_t nm_len, 309 char const * val, size_t d_len); 310 311 static tOptionValue * 312 add_bool(void ** pp, char const * name, size_t nm_len, 313 char const * val, size_t d_len); 314 315 static tOptionValue * 316 add_number(void ** pp, char const * name, size_t nm_len, 317 char const * val, size_t d_len); 318 319 static tOptionValue * 320 add_nested(void ** pp, char const * name, size_t nm_len, 321 char * val, size_t d_len); 322 323 static char const * 324 scan_name(char const * name, tOptionValue * res); 325 326 static char const * 327 unnamed_xml(char const * txt); 328 329 static char const * 330 scan_xml_name(char const * name, size_t * nm_len, tOptionValue * val); 331 332 static char const * 333 find_end_xml(char const * src, size_t nm_len, char const * val, size_t * len); 334 335 static char const * 336 scan_xml(char const * xml_name, tOptionValue * res_val); 337 338 static void 339 unload_arg_list(tArgList * arg_list); 340 341 static void 342 sort_list(tArgList * arg_list); 343 344 static tOptionValue * 345 optionLoadNested(char const * text, char const * name, size_t nm_len); 346 347 static int 348 get_special_char(char const ** ppz, int * ct); 349 350 static void 351 emit_special_char(FILE * fp, int ch); 352 353 /* 354 * Static declarations from parse-duration.c 355 */ 356 static unsigned long 357 str_const_to_ul (cch_t * str, cch_t ** ppz, int base); 358 359 static long 360 str_const_to_l (cch_t * str, cch_t ** ppz, int base); 361 362 static time_t 363 scale_n_add (time_t base, time_t val, int scale); 364 365 static time_t 366 parse_hr_min_sec (time_t start, cch_t * pz); 367 368 static time_t 369 parse_scaled_value (time_t base, cch_t ** ppz, cch_t * endp, int scale); 370 371 static time_t 372 parse_year_month_day (cch_t * pz, cch_t * ps); 373 374 static time_t 375 parse_yearmonthday (cch_t * in_pz); 376 377 static time_t 378 parse_YMWD (cch_t * pz); 379 380 static time_t 381 parse_hour_minute_second (cch_t * pz, cch_t * ps); 382 383 static time_t 384 parse_hourminutesecond (cch_t * in_pz); 385 386 static time_t 387 parse_HMS (cch_t * pz); 388 389 static time_t 390 parse_time (cch_t * pz); 391 392 static char * 393 trim (char * pz); 394 395 static time_t 396 parse_period (cch_t * in_pz); 397 398 static time_t 399 parse_non_iso8601 (cch_t * pz); 400 401 /* 402 * Static declarations from pgusage.c 403 */ 404 static inline FILE * 405 open_tmp_usage(char ** buf); 406 407 static inline char * 408 mk_pager_cmd(char const * fname); 409 410 /* 411 * Static declarations from putshell.c 412 */ 413 static size_t 414 string_size(char const * scan, size_t nl_len); 415 416 static char const * 417 print_quoted_apostrophes(char const * str); 418 419 static void 420 print_quot_str(char const * str); 421 422 static void 423 print_enumeration(tOptions * pOpts, tOptDesc * pOD); 424 425 static void 426 print_membership(tOptions * pOpts, tOptDesc * pOD); 427 428 static void 429 print_stacked_arg(tOptions * pOpts, tOptDesc * pOD); 430 431 static void 432 print_reordering(tOptions * opts); 433 434 /* 435 * Static declarations from reset.c 436 */ 437 static void 438 optionReset(tOptions * pOpts, tOptDesc * pOD); 439 440 static void 441 optionResetEverything(tOptions * pOpts); 442 443 /* 444 * Static declarations from restore.c 445 */ 446 static void 447 fixupSavedOptionArgs(tOptions * pOpts); 448 449 /* 450 * Static declarations from save.c 451 */ 452 static char const * 453 find_dir_name(tOptions * opts, int * p_free); 454 455 static char const * 456 find_file_name(tOptions * opts, int * p_free_name); 457 458 static void 459 prt_entry(FILE * fp, tOptDesc * od, char const * l_arg, save_flags_mask_t save_fl); 460 461 static void 462 prt_value(FILE * fp, int depth, tOptDesc * od, tOptionValue const * ovp); 463 464 static void 465 prt_string(FILE * fp, char const * name, char const * pz); 466 467 static void 468 prt_val_list(FILE * fp, char const * name, tArgList * al); 469 470 static void 471 prt_nested(FILE * fp, tOptDesc * od, save_flags_mask_t save_fl); 472 473 static void 474 remove_settings(tOptions * opts, char const * fname); 475 476 static FILE * 477 open_sv_file(tOptions * opts, save_flags_mask_t save_fl); 478 479 static void 480 prt_no_arg_opt(FILE * fp, tOptDesc * vod, tOptDesc * pod, save_flags_mask_t save_fl); 481 482 static void 483 prt_str_arg(FILE * fp, tOptDesc * od, save_flags_mask_t save_fl); 484 485 static void 486 prt_enum_arg(FILE * fp, tOptDesc * od, save_flags_mask_t save_fl); 487 488 static void 489 prt_set_arg(FILE * fp, tOptDesc * od, save_flags_mask_t save_fl); 490 491 static void 492 prt_file_arg(FILE * fp, tOptDesc * od, tOptions * opts, save_flags_mask_t save_fl); 493 494 /* 495 * Static declarations from sort.c 496 */ 497 static tSuccess 498 must_arg(tOptions * opts, char * arg_txt, tOptState * pOS, 499 char ** opt_txt, uint32_t * opt_idx); 500 501 static tSuccess 502 maybe_arg(tOptions * opts, char * arg_txt, tOptState * pOS, 503 char ** opt_txt, uint32_t * opt_idx); 504 505 static tSuccess 506 short_opt_ck(tOptions * opts, char * arg_txt, tOptState * pOS, 507 char ** opt_txt, uint32_t * opt_idx); 508 509 static void 510 optionSort(tOptions * opts); 511 512 /* 513 * Static declarations from stack.c 514 */ 515 static void 516 addArgListEntry(void ** ppAL, void * entry); 517 518 /* 519 * Static declarations from text_mmap.c 520 */ 521 static void 522 load_text_file(tmap_info_t * mapinfo, char const * pzFile); 523 524 static void 525 validate_mmap(char const * fname, int prot, int flags, tmap_info_t * mapinfo); 526 527 static void 528 close_mmap_files(tmap_info_t * mi); 529 530 /* 531 * Static declarations from tokenize.c 532 */ 533 static void 534 copy_cooked(ch_t ** ppDest, char const ** ppSrc); 535 536 static void 537 copy_raw(ch_t ** ppDest, char const ** ppSrc); 538 539 static token_list_t * 540 alloc_token_list(char const * str); 541 542 /* 543 * Static declarations from usage.c 544 */ 545 static unsigned int 546 parse_usage_flags(ao_flag_names_t const * fnt, char const * txt); 547 548 static void 549 set_usage_flags(tOptions * opts, char const * flg_txt); 550 551 static inline bool 552 do_gnu_usage(tOptions * pOpts); 553 554 static inline bool 555 skip_misuse_usage(tOptions * pOpts); 556 557 static void 558 print_offer_usage(tOptions * opts); 559 560 static void 561 print_usage_details(tOptions * opts, int exit_code); 562 563 static void 564 print_one_paragraph(char const * text, bool plain, FILE * fp); 565 566 static void 567 prt_conflicts(tOptions * opts, tOptDesc * od); 568 569 static void 570 prt_one_vendor(tOptions * opts, tOptDesc * od, 571 arg_types_t * argtp, char const * usefmt); 572 573 static void 574 prt_vendor_opts(tOptions * opts, char const * title); 575 576 static void 577 prt_extd_usage(tOptions * opts, tOptDesc * od, char const * title); 578 579 static void 580 prt_ini_list(char const * const * papz, char const * ini_file, 581 char const * path_nm); 582 583 static void 584 prt_preamble(tOptions * opts, tOptDesc * od, arg_types_t * at); 585 586 static void 587 prt_one_usage(tOptions * opts, tOptDesc * od, arg_types_t * at); 588 589 static void 590 prt_opt_usage(tOptions * opts, int ex_code, char const * title); 591 592 static void 593 prt_prog_detail(tOptions * opts); 594 595 static int 596 setGnuOptFmts(tOptions * opts, char const ** ptxt); 597 598 static int 599 setStdOptFmts(tOptions * opts, char const ** ptxt); 600 601 /* 602 * Static declarations from version.c 603 */ 604 static void 605 emit_first_line( 606 FILE * fp, char const * alt1, char const * alt2, char const * alt3); 607 608 static void 609 emit_simple_ver(tOptions * o, FILE * fp); 610 611 static void 612 emit_copy_full(tOptions * o, FILE * fp); 613 614 static void 615 emit_copy_note(tOptions * opts, FILE * fp); 616 617 static void 618 print_ver(tOptions * opts, tOptDesc * od, FILE * fp, bool call_exit); 619 620 #endif /* AUTOOPTS_PROTO_H_GUARD */ 621