1
0

proto.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620
  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. * Static declarations from alias.c
  10. */
  11. static tSuccess
  12. too_many_occurrences(tOptions * opts, tOptDesc * od);
  13. /*
  14. * Static declarations from autoopts.c
  15. */
  16. static void *
  17. ao_malloc(size_t sz);
  18. static void *
  19. ao_realloc(void *p, size_t sz);
  20. static char *
  21. ao_strdup(char const *str);
  22. static tSuccess
  23. handle_opt(tOptions * opts, tOptState * o_st);
  24. static tSuccess
  25. next_opt(tOptions * opts, tOptState * o_st);
  26. static tSuccess
  27. regular_opts(tOptions * opts);
  28. /*
  29. * Static declarations from check.c
  30. */
  31. static bool
  32. has_conflict(tOptions * pOpts, tOptDesc * od);
  33. static bool
  34. occurs_enough(tOptions * pOpts, tOptDesc * pOD);
  35. static bool
  36. is_consistent(tOptions * pOpts);
  37. /*
  38. * Static declarations from configfile.c
  39. */
  40. static void
  41. file_preset(tOptions * opts, char const * fname, int dir);
  42. static char *
  43. handle_comment(char * txt);
  44. static char *
  45. handle_cfg(tOptions * opts, tOptState * ost, char * txt, int dir);
  46. static char *
  47. handle_directive(tOptions * opts, char * txt);
  48. static char *
  49. aoflags_directive(tOptions * opts, char * txt);
  50. static char *
  51. program_directive(tOptions * opts, char * txt);
  52. static char *
  53. handle_section(tOptions * opts, char * txt);
  54. static int
  55. parse_xml_encoding(char ** ppz);
  56. static char *
  57. trim_xml_text(char * intxt, char const * pznm, tOptionLoadMode mode);
  58. static void
  59. cook_xml_text(char * pzData);
  60. static char *
  61. handle_struct(tOptions * opts, tOptState * ost, char * txt, int dir);
  62. static void
  63. intern_file_load(tOptions * opts);
  64. static char const *
  65. parse_attrs(tOptions * opts, char const * txt, tOptionLoadMode * pMode,
  66. tOptionValue * pType);
  67. static char const *
  68. parse_keyword(tOptions * opts, char const * txt, tOptionValue * typ);
  69. static char const *
  70. parse_set_mem(tOptions * opts, char const * txt, tOptionValue * typ);
  71. static char const *
  72. parse_value(char const * txt, tOptionValue * typ);
  73. /*
  74. * Static declarations from cook.c
  75. */
  76. static char *
  77. nl_count(char * start, char * end, int * lnct_p);
  78. static bool
  79. contiguous_quote(char ** pps, char * pq, int * lnct_p);
  80. /*
  81. * Static declarations from enum.c
  82. */
  83. static void
  84. enum_err(tOptions * pOpts, tOptDesc * pOD,
  85. char const * const * paz_names, int name_ct);
  86. static uintptr_t
  87. find_name(char const * name, tOptions * pOpts, tOptDesc * pOD,
  88. char const * const * paz_names, unsigned int name_ct);
  89. static void
  90. set_memb_shell(tOptions * pOpts, tOptDesc * pOD, char const * const * paz_names,
  91. unsigned int name_ct);
  92. static void
  93. set_memb_names(tOptions * opts, tOptDesc * od, char const * const * nm_list,
  94. unsigned int nm_ct);
  95. static uintptr_t
  96. check_membership_start(tOptDesc * od, char const ** argp, bool * invert);
  97. static uintptr_t
  98. find_member_bit(tOptions * opts, tOptDesc * od, char const * pz, int len,
  99. char const * const * nm_list, unsigned int nm_ct);
  100. /*
  101. * Static declarations from env.c
  102. */
  103. static void
  104. doPrognameEnv(tOptions * pOpts, teEnvPresetType type);
  105. static void
  106. do_env_opt(tOptState * os, char * env_name,
  107. tOptions * pOpts, teEnvPresetType type);
  108. static void
  109. env_presets(tOptions * pOpts, teEnvPresetType type);
  110. /*
  111. * Static declarations from file.c
  112. */
  113. static void
  114. check_existence(teOptFileType ftype, tOptions * pOpts, tOptDesc * pOD);
  115. static void
  116. open_file_fd(tOptions * pOpts, tOptDesc * pOD, tuFileMode mode);
  117. static void
  118. fopen_file_fp(tOptions * pOpts, tOptDesc * pOD, tuFileMode mode);
  119. /*
  120. * Static declarations from find.c
  121. */
  122. static int
  123. parse_opt(char const ** nm_pp, char ** arg_pp, char * buf, size_t bufsz);
  124. static void
  125. opt_ambiguities(tOptions * opts, char const * name, int nm_len);
  126. static int
  127. opt_match_ct(tOptions * opts, char const * name, int nm_len,
  128. int * ixp, bool * disable);
  129. static tSuccess
  130. opt_set(tOptions * opts, char * arg, int idx, bool disable, tOptState * st);
  131. static tSuccess
  132. opt_unknown(tOptions * opts, char const * name, char * arg, tOptState * st);
  133. static tSuccess
  134. opt_ambiguous(tOptions * opts, char const * name, int match_ct);
  135. static tSuccess
  136. opt_find_long(tOptions * opts, char const * opt_name, tOptState * state);
  137. static tSuccess
  138. opt_find_short(tOptions * pOpts, uint_t optValue, tOptState * pOptState);
  139. static tSuccess
  140. get_opt_arg_must(tOptions * opts, tOptState * o_st);
  141. static tSuccess
  142. get_opt_arg_may(tOptions * pOpts, tOptState * o_st);
  143. static tSuccess
  144. get_opt_arg_none(tOptions * pOpts, tOptState * o_st);
  145. static tSuccess
  146. get_opt_arg(tOptions * opts, tOptState * o_st);
  147. static tSuccess
  148. find_opt(tOptions * opts, tOptState * o_st);
  149. /*
  150. * Static declarations from init.c
  151. */
  152. static tSuccess
  153. validate_struct(tOptions * opts, char const * pname);
  154. static tSuccess
  155. immediate_opts(tOptions * opts);
  156. static tSuccess
  157. do_presets(tOptions * opts);
  158. static bool
  159. ao_initialize(tOptions * opts, int a_ct, char ** a_v);
  160. /*
  161. * Static declarations from load.c
  162. */
  163. static bool
  164. get_realpath(char * buf, size_t b_sz);
  165. static bool
  166. add_prog_path(char * buf, int b_sz, char const * fname, char const * prg_path);
  167. static bool
  168. add_env_val(char * buf, int buf_sz, char const * name);
  169. static void
  170. munge_str(char * txt, tOptionLoadMode mode);
  171. static char *
  172. assemble_arg_val(char * txt, tOptionLoadMode mode);
  173. static char *
  174. trim_quotes(char * arg);
  175. static bool
  176. direction_ok(opt_state_mask_t f, int dir);
  177. static void
  178. load_opt_line(tOptions * opts, tOptState * opt_state, char * line,
  179. tDirection direction, tOptionLoadMode load_mode );
  180. /*
  181. * Static declarations from makeshell.c
  182. */
  183. noreturn static void
  184. option_exits(int exit_code);
  185. noreturn static void
  186. ao_bug(char const * msg);
  187. static void
  188. fserr_warn(char const * prog, char const * op, char const * fname);
  189. noreturn static void
  190. fserr_exit(char const * prog, char const * op, char const * fname);
  191. static void
  192. emit_var_text(char const * prog, char const * var, int fdin);
  193. static void
  194. text_to_var(tOptions * opts, teTextTo which, tOptDesc * od);
  195. static void
  196. emit_usage(tOptions * opts);
  197. static void
  198. emit_wrapup(tOptions * opts);
  199. static void
  200. emit_setup(tOptions * opts);
  201. static void
  202. emit_action(tOptions * opts, tOptDesc * od);
  203. static void
  204. emit_inaction(tOptions * opts, tOptDesc * od);
  205. static void
  206. emit_flag(tOptions * opts);
  207. static void
  208. emit_match_expr(char const * name, tOptDesc * cod, tOptions * opts);
  209. static void
  210. emit_long(tOptions * opts);
  211. static char *
  212. load_old_output(char const * fname, char const * pname);
  213. static void
  214. open_out(char const * fname, char const * pname);
  215. /*
  216. * Static declarations from nested.c
  217. */
  218. static void
  219. remove_continuation(char * src);
  220. static char const *
  221. scan_q_str(char const * pzTxt);
  222. static tOptionValue *
  223. add_string(void ** pp, char const * name, size_t nm_len,
  224. char const * val, size_t d_len);
  225. static tOptionValue *
  226. add_bool(void ** pp, char const * name, size_t nm_len,
  227. char const * val, size_t d_len);
  228. static tOptionValue *
  229. add_number(void ** pp, char const * name, size_t nm_len,
  230. char const * val, size_t d_len);
  231. static tOptionValue *
  232. add_nested(void ** pp, char const * name, size_t nm_len,
  233. char * val, size_t d_len);
  234. static char const *
  235. scan_name(char const * name, tOptionValue * res);
  236. static char const *
  237. unnamed_xml(char const * txt);
  238. static char const *
  239. scan_xml_name(char const * name, size_t * nm_len, tOptionValue * val);
  240. static char const *
  241. find_end_xml(char const * src, size_t nm_len, char const * val, size_t * len);
  242. static char const *
  243. scan_xml(char const * xml_name, tOptionValue * res_val);
  244. static void
  245. unload_arg_list(tArgList * arg_list);
  246. static void
  247. sort_list(tArgList * arg_list);
  248. static tOptionValue *
  249. optionLoadNested(char const * text, char const * name, size_t nm_len);
  250. static int
  251. get_special_char(char const ** ppz, int * ct);
  252. static void
  253. emit_special_char(FILE * fp, int ch);
  254. /*
  255. * Static declarations from parse-duration.c
  256. */
  257. static unsigned long
  258. str_const_to_ul (cch_t * str, cch_t ** ppz, int base);
  259. static long
  260. str_const_to_l (cch_t * str, cch_t ** ppz, int base);
  261. static time_t
  262. scale_n_add (time_t base, time_t val, int scale);
  263. static time_t
  264. parse_hr_min_sec (time_t start, cch_t * pz);
  265. static time_t
  266. parse_scaled_value (time_t base, cch_t ** ppz, cch_t * endp, int scale);
  267. static time_t
  268. parse_year_month_day (cch_t * pz, cch_t * ps);
  269. static time_t
  270. parse_yearmonthday (cch_t * in_pz);
  271. static time_t
  272. parse_YMWD (cch_t * pz);
  273. static time_t
  274. parse_hour_minute_second (cch_t * pz, cch_t * ps);
  275. static time_t
  276. parse_hourminutesecond (cch_t * in_pz);
  277. static time_t
  278. parse_HMS (cch_t * pz);
  279. static time_t
  280. parse_time (cch_t * pz);
  281. static char *
  282. trim (char * pz);
  283. static time_t
  284. parse_period (cch_t * in_pz);
  285. static time_t
  286. parse_non_iso8601 (cch_t * pz);
  287. /*
  288. * Static declarations from pgusage.c
  289. */
  290. static inline FILE *
  291. open_tmp_usage(char ** buf);
  292. static inline char *
  293. mk_pager_cmd(char const * fname);
  294. /*
  295. * Static declarations from putshell.c
  296. */
  297. static size_t
  298. string_size(char const * scan, size_t nl_len);
  299. static char const *
  300. print_quoted_apostrophes(char const * str);
  301. static void
  302. print_quot_str(char const * str);
  303. static void
  304. print_enumeration(tOptions * pOpts, tOptDesc * pOD);
  305. static void
  306. print_membership(tOptions * pOpts, tOptDesc * pOD);
  307. static void
  308. print_stacked_arg(tOptions * pOpts, tOptDesc * pOD);
  309. static void
  310. print_reordering(tOptions * opts);
  311. /*
  312. * Static declarations from reset.c
  313. */
  314. static void
  315. optionReset(tOptions * pOpts, tOptDesc * pOD);
  316. static void
  317. optionResetEverything(tOptions * pOpts);
  318. /*
  319. * Static declarations from restore.c
  320. */
  321. static void
  322. fixupSavedOptionArgs(tOptions * pOpts);
  323. /*
  324. * Static declarations from save.c
  325. */
  326. static char const *
  327. find_dir_name(tOptions * opts, int * p_free);
  328. static char const *
  329. find_file_name(tOptions * opts, int * p_free_name);
  330. static void
  331. prt_entry(FILE * fp, tOptDesc * od, char const * l_arg, save_flags_mask_t save_fl);
  332. static void
  333. prt_value(FILE * fp, int depth, tOptDesc * od, tOptionValue const * ovp);
  334. static void
  335. prt_string(FILE * fp, char const * name, char const * pz);
  336. static void
  337. prt_val_list(FILE * fp, char const * name, tArgList * al);
  338. static void
  339. prt_nested(FILE * fp, tOptDesc * od, save_flags_mask_t save_fl);
  340. static void
  341. remove_settings(tOptions * opts, char const * fname);
  342. static FILE *
  343. open_sv_file(tOptions * opts, save_flags_mask_t save_fl);
  344. static void
  345. prt_no_arg_opt(FILE * fp, tOptDesc * vod, tOptDesc * pod, save_flags_mask_t save_fl);
  346. static void
  347. prt_str_arg(FILE * fp, tOptDesc * od, save_flags_mask_t save_fl);
  348. static void
  349. prt_enum_arg(FILE * fp, tOptDesc * od, save_flags_mask_t save_fl);
  350. static void
  351. prt_set_arg(FILE * fp, tOptDesc * od, save_flags_mask_t save_fl);
  352. static void
  353. prt_file_arg(FILE * fp, tOptDesc * od, tOptions * opts, save_flags_mask_t save_fl);
  354. /*
  355. * Static declarations from sort.c
  356. */
  357. static tSuccess
  358. must_arg(tOptions * opts, char * arg_txt, tOptState * pOS,
  359. char ** opt_txt, uint32_t * opt_idx);
  360. static tSuccess
  361. maybe_arg(tOptions * opts, char * arg_txt, tOptState * pOS,
  362. char ** opt_txt, uint32_t * opt_idx);
  363. static tSuccess
  364. short_opt_ck(tOptions * opts, char * arg_txt, tOptState * pOS,
  365. char ** opt_txt, uint32_t * opt_idx);
  366. static void
  367. optionSort(tOptions * opts);
  368. /*
  369. * Static declarations from stack.c
  370. */
  371. static void
  372. addArgListEntry(void ** ppAL, void * entry);
  373. /*
  374. * Static declarations from text_mmap.c
  375. */
  376. static void
  377. load_text_file(tmap_info_t * mapinfo, char const * pzFile);
  378. static void
  379. validate_mmap(char const * fname, int prot, int flags, tmap_info_t * mapinfo);
  380. static void
  381. close_mmap_files(tmap_info_t * mi);
  382. /*
  383. * Static declarations from tokenize.c
  384. */
  385. static void
  386. copy_cooked(ch_t ** ppDest, char const ** ppSrc);
  387. static void
  388. copy_raw(ch_t ** ppDest, char const ** ppSrc);
  389. static token_list_t *
  390. alloc_token_list(char const * str);
  391. /*
  392. * Static declarations from usage.c
  393. */
  394. static unsigned int
  395. parse_usage_flags(ao_flag_names_t const * fnt, char const * txt);
  396. static void
  397. set_usage_flags(tOptions * opts, char const * flg_txt);
  398. static inline bool
  399. do_gnu_usage(tOptions * pOpts);
  400. static inline bool
  401. skip_misuse_usage(tOptions * pOpts);
  402. static void
  403. print_offer_usage(tOptions * opts);
  404. static void
  405. print_usage_details(tOptions * opts, int exit_code);
  406. static void
  407. print_one_paragraph(char const * text, bool plain, FILE * fp);
  408. static void
  409. prt_conflicts(tOptions * opts, tOptDesc * od);
  410. static void
  411. prt_one_vendor(tOptions * opts, tOptDesc * od,
  412. arg_types_t * argtp, char const * usefmt);
  413. static void
  414. prt_vendor_opts(tOptions * opts, char const * title);
  415. static void
  416. prt_extd_usage(tOptions * opts, tOptDesc * od, char const * title);
  417. static void
  418. prt_ini_list(char const * const * papz, char const * ini_file,
  419. char const * path_nm);
  420. static void
  421. prt_preamble(tOptions * opts, tOptDesc * od, arg_types_t * at);
  422. static void
  423. prt_one_usage(tOptions * opts, tOptDesc * od, arg_types_t * at);
  424. static void
  425. prt_opt_usage(tOptions * opts, int ex_code, char const * title);
  426. static void
  427. prt_prog_detail(tOptions * opts);
  428. static int
  429. setGnuOptFmts(tOptions * opts, char const ** ptxt);
  430. static int
  431. setStdOptFmts(tOptions * opts, char const ** ptxt);
  432. /*
  433. * Static declarations from version.c
  434. */
  435. static void
  436. emit_first_line(
  437. FILE * fp, char const * alt1, char const * alt2, char const * alt3);
  438. static void
  439. emit_simple_ver(tOptions * o, FILE * fp);
  440. static void
  441. emit_copy_full(tOptions * o, FILE * fp);
  442. static void
  443. emit_copy_note(tOptions * opts, FILE * fp);
  444. static void
  445. print_ver(tOptions * opts, tOptDesc * od, FILE * fp, bool call_exit);
  446. #endif /* AUTOOPTS_PROTO_H_GUARD */