cmdline.c 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734
  1. /*
  2. File autogenerated by gengetopt version 2.22.6
  3. generated with the following command:
  4. gengetopt
  5. The developers of gengetopt consider the fixed text that goes in all
  6. gengetopt output files to be in the public domain:
  7. we make no copyright claims on it.
  8. */
  9. /* If we use autoconf. */
  10. #ifdef HAVE_CONFIG_H
  11. #include "config.h"
  12. #endif
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <string.h>
  16. #ifndef FIX_UNUSED
  17. #define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */
  18. #endif
  19. #include <getopt.h>
  20. #include "cmdline.h"
  21. const char *gengetopt_args_info_purpose = "";
  22. const char *gengetopt_args_info_usage = "Usage: slop [options]";
  23. const char *gengetopt_args_info_versiontext = "Copyright (C) 2014 Dalton Nell, Slop Contributors\n(https://github.com/naelstrof/slop/graphs/contributors)";
  24. const char *gengetopt_args_info_description = "slop (Select Operation) is an application that queries for a selection from the\nuser and prints the region to stdout.";
  25. const char *gengetopt_args_info_help[] = {
  26. " -h, --help Print help and exit",
  27. " -V, --version Print version and exit",
  28. "Options",
  29. " --xdisplay=hostname:number.screen_number\n Sets the x display. (default=`:0')",
  30. " --nokeyboard Disables the ability to cancel selections with\n the keyboard. (default=off)",
  31. " -b, --bordersize=INT Set the selection rectangle's thickness. Does\n nothing when --highlight is enabled.\n (default=`5')",
  32. " -p, --padding=INT Set the padding size of the selection. Can be\n negative. (default=`0')",
  33. " -t, --tolerance=INT How far in pixels the mouse can move after\n clicking and still be detected as a normal\n click instead of a click and drag. Setting\n this to 0 will disable window selections.\n (default=`2')",
  34. " -g, --gracetime=FLOAT Set the amount of time before slop will check\n for keyboard cancellations in seconds.\n (default=`0.4')",
  35. " -c, --color=FLOAT,FLOAT,FLOAT,FLOAT\n Set the selection rectangle's color. Supports\n RGB or RGBA values.\n (default=`0.5,0.5,0.5,1')",
  36. " -n, --nodecorations Attempt to select child windows in order to\n avoid window decorations. (default=off)",
  37. " --min=INT Set the minimum output of width or height\n values. This is useful to avoid outputting 0.\n Setting min and max to the same value\n disables drag selections. (default=`0')",
  38. " --max=INT Set the maximum output of width or height\n values. Setting min and max to the same value\n disables drag selections. (default=`0')",
  39. " -l, --highlight Instead of outlining selections, slop\n highlights it. This is only useful when\n --color is set to a transparent color.\n (default=off)",
  40. "\nExamples\n $ # Gray, thick, transparent border for maximum visiblity.\n $ slop -b 20 -c 0.5,0.5,0.5,0.8\n\n $ # Remove window decorations.\n $ slop --nodecorations\n\n $ # Disable window selections. Useful for selecting individual pixels.\n $ slop -t 0\n\n $ # Classic Windows XP selection.\n $ slop -l -c 0.3,0.4,0.6,0.4\n",
  41. 0
  42. };
  43. typedef enum {ARG_NO
  44. , ARG_FLAG
  45. , ARG_STRING
  46. , ARG_INT
  47. } cmdline_parser_arg_type;
  48. static
  49. void clear_given (struct gengetopt_args_info *args_info);
  50. static
  51. void clear_args (struct gengetopt_args_info *args_info);
  52. static int
  53. cmdline_parser_internal (int argc, char **argv, struct gengetopt_args_info *args_info,
  54. struct cmdline_parser_params *params, const char *additional_error);
  55. static char *
  56. gengetopt_strdup (const char *s);
  57. static
  58. void clear_given (struct gengetopt_args_info *args_info)
  59. {
  60. args_info->help_given = 0 ;
  61. args_info->version_given = 0 ;
  62. args_info->xdisplay_given = 0 ;
  63. args_info->nokeyboard_given = 0 ;
  64. args_info->bordersize_given = 0 ;
  65. args_info->padding_given = 0 ;
  66. args_info->tolerance_given = 0 ;
  67. args_info->gracetime_given = 0 ;
  68. args_info->color_given = 0 ;
  69. args_info->nodecorations_given = 0 ;
  70. args_info->min_given = 0 ;
  71. args_info->max_given = 0 ;
  72. args_info->highlight_given = 0 ;
  73. }
  74. static
  75. void clear_args (struct gengetopt_args_info *args_info)
  76. {
  77. FIX_UNUSED (args_info);
  78. args_info->xdisplay_arg = gengetopt_strdup (":0");
  79. args_info->xdisplay_orig = NULL;
  80. args_info->nokeyboard_flag = 0;
  81. args_info->bordersize_arg = 5;
  82. args_info->bordersize_orig = NULL;
  83. args_info->padding_arg = 0;
  84. args_info->padding_orig = NULL;
  85. args_info->tolerance_arg = 2;
  86. args_info->tolerance_orig = NULL;
  87. args_info->gracetime_arg = gengetopt_strdup ("0.4");
  88. args_info->gracetime_orig = NULL;
  89. args_info->color_arg = gengetopt_strdup ("0.5,0.5,0.5,1");
  90. args_info->color_orig = NULL;
  91. args_info->nodecorations_flag = 0;
  92. args_info->min_arg = 0;
  93. args_info->min_orig = NULL;
  94. args_info->max_arg = 0;
  95. args_info->max_orig = NULL;
  96. args_info->highlight_flag = 0;
  97. }
  98. static
  99. void init_args_info(struct gengetopt_args_info *args_info)
  100. {
  101. args_info->help_help = gengetopt_args_info_help[0] ;
  102. args_info->version_help = gengetopt_args_info_help[1] ;
  103. args_info->xdisplay_help = gengetopt_args_info_help[3] ;
  104. args_info->nokeyboard_help = gengetopt_args_info_help[4] ;
  105. args_info->bordersize_help = gengetopt_args_info_help[5] ;
  106. args_info->padding_help = gengetopt_args_info_help[6] ;
  107. args_info->tolerance_help = gengetopt_args_info_help[7] ;
  108. args_info->gracetime_help = gengetopt_args_info_help[8] ;
  109. args_info->color_help = gengetopt_args_info_help[9] ;
  110. args_info->nodecorations_help = gengetopt_args_info_help[10] ;
  111. args_info->min_help = gengetopt_args_info_help[11] ;
  112. args_info->max_help = gengetopt_args_info_help[12] ;
  113. args_info->highlight_help = gengetopt_args_info_help[13] ;
  114. }
  115. void
  116. cmdline_parser_print_version (void)
  117. {
  118. printf ("%s %s\n",
  119. (strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE),
  120. CMDLINE_PARSER_VERSION);
  121. if (strlen(gengetopt_args_info_versiontext) > 0)
  122. printf("\n%s\n", gengetopt_args_info_versiontext);
  123. }
  124. static void print_help_common(void) {
  125. cmdline_parser_print_version ();
  126. if (strlen(gengetopt_args_info_purpose) > 0)
  127. printf("\n%s\n", gengetopt_args_info_purpose);
  128. if (strlen(gengetopt_args_info_usage) > 0)
  129. printf("\n%s\n", gengetopt_args_info_usage);
  130. printf("\n");
  131. if (strlen(gengetopt_args_info_description) > 0)
  132. printf("%s\n\n", gengetopt_args_info_description);
  133. }
  134. void
  135. cmdline_parser_print_help (void)
  136. {
  137. int i = 0;
  138. print_help_common();
  139. while (gengetopt_args_info_help[i])
  140. printf("%s\n", gengetopt_args_info_help[i++]);
  141. }
  142. void
  143. cmdline_parser_init (struct gengetopt_args_info *args_info)
  144. {
  145. clear_given (args_info);
  146. clear_args (args_info);
  147. init_args_info (args_info);
  148. }
  149. void
  150. cmdline_parser_params_init(struct cmdline_parser_params *params)
  151. {
  152. if (params)
  153. {
  154. params->override = 0;
  155. params->initialize = 1;
  156. params->check_required = 1;
  157. params->check_ambiguity = 0;
  158. params->print_errors = 1;
  159. }
  160. }
  161. struct cmdline_parser_params *
  162. cmdline_parser_params_create(void)
  163. {
  164. struct cmdline_parser_params *params =
  165. (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params));
  166. cmdline_parser_params_init(params);
  167. return params;
  168. }
  169. static void
  170. free_string_field (char **s)
  171. {
  172. if (*s)
  173. {
  174. free (*s);
  175. *s = 0;
  176. }
  177. }
  178. static void
  179. cmdline_parser_release (struct gengetopt_args_info *args_info)
  180. {
  181. free_string_field (&(args_info->xdisplay_arg));
  182. free_string_field (&(args_info->xdisplay_orig));
  183. free_string_field (&(args_info->bordersize_orig));
  184. free_string_field (&(args_info->padding_orig));
  185. free_string_field (&(args_info->tolerance_orig));
  186. free_string_field (&(args_info->gracetime_arg));
  187. free_string_field (&(args_info->gracetime_orig));
  188. free_string_field (&(args_info->color_arg));
  189. free_string_field (&(args_info->color_orig));
  190. free_string_field (&(args_info->min_orig));
  191. free_string_field (&(args_info->max_orig));
  192. clear_given (args_info);
  193. }
  194. static void
  195. write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[])
  196. {
  197. FIX_UNUSED (values);
  198. if (arg) {
  199. fprintf(outfile, "%s=\"%s\"\n", opt, arg);
  200. } else {
  201. fprintf(outfile, "%s\n", opt);
  202. }
  203. }
  204. int
  205. cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info)
  206. {
  207. int i = 0;
  208. if (!outfile)
  209. {
  210. fprintf (stderr, "%s: cannot dump options to stream\n", CMDLINE_PARSER_PACKAGE);
  211. return EXIT_FAILURE;
  212. }
  213. if (args_info->help_given)
  214. write_into_file(outfile, "help", 0, 0 );
  215. if (args_info->version_given)
  216. write_into_file(outfile, "version", 0, 0 );
  217. if (args_info->xdisplay_given)
  218. write_into_file(outfile, "xdisplay", args_info->xdisplay_orig, 0);
  219. if (args_info->nokeyboard_given)
  220. write_into_file(outfile, "nokeyboard", 0, 0 );
  221. if (args_info->bordersize_given)
  222. write_into_file(outfile, "bordersize", args_info->bordersize_orig, 0);
  223. if (args_info->padding_given)
  224. write_into_file(outfile, "padding", args_info->padding_orig, 0);
  225. if (args_info->tolerance_given)
  226. write_into_file(outfile, "tolerance", args_info->tolerance_orig, 0);
  227. if (args_info->gracetime_given)
  228. write_into_file(outfile, "gracetime", args_info->gracetime_orig, 0);
  229. if (args_info->color_given)
  230. write_into_file(outfile, "color", args_info->color_orig, 0);
  231. if (args_info->nodecorations_given)
  232. write_into_file(outfile, "nodecorations", 0, 0 );
  233. if (args_info->min_given)
  234. write_into_file(outfile, "min", args_info->min_orig, 0);
  235. if (args_info->max_given)
  236. write_into_file(outfile, "max", args_info->max_orig, 0);
  237. if (args_info->highlight_given)
  238. write_into_file(outfile, "highlight", 0, 0 );
  239. i = EXIT_SUCCESS;
  240. return i;
  241. }
  242. int
  243. cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info)
  244. {
  245. FILE *outfile;
  246. int i = 0;
  247. outfile = fopen(filename, "w");
  248. if (!outfile)
  249. {
  250. fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename);
  251. return EXIT_FAILURE;
  252. }
  253. i = cmdline_parser_dump(outfile, args_info);
  254. fclose (outfile);
  255. return i;
  256. }
  257. void
  258. cmdline_parser_free (struct gengetopt_args_info *args_info)
  259. {
  260. cmdline_parser_release (args_info);
  261. }
  262. /** @brief replacement of strdup, which is not standard */
  263. char *
  264. gengetopt_strdup (const char *s)
  265. {
  266. char *result = 0;
  267. if (!s)
  268. return result;
  269. result = (char*)malloc(strlen(s) + 1);
  270. if (result == (char*)0)
  271. return (char*)0;
  272. strcpy(result, s);
  273. return result;
  274. }
  275. int
  276. cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info)
  277. {
  278. return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
  279. }
  280. int
  281. cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info,
  282. struct cmdline_parser_params *params)
  283. {
  284. int result;
  285. result = cmdline_parser_internal (argc, argv, args_info, params, 0);
  286. if (result == EXIT_FAILURE)
  287. {
  288. cmdline_parser_free (args_info);
  289. exit (EXIT_FAILURE);
  290. }
  291. return result;
  292. }
  293. int
  294. cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
  295. {
  296. int result;
  297. struct cmdline_parser_params params;
  298. params.override = override;
  299. params.initialize = initialize;
  300. params.check_required = check_required;
  301. params.check_ambiguity = 0;
  302. params.print_errors = 1;
  303. result = cmdline_parser_internal (argc, argv, args_info, &params, 0);
  304. if (result == EXIT_FAILURE)
  305. {
  306. cmdline_parser_free (args_info);
  307. exit (EXIT_FAILURE);
  308. }
  309. return result;
  310. }
  311. int
  312. cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name)
  313. {
  314. FIX_UNUSED (args_info);
  315. FIX_UNUSED (prog_name);
  316. return EXIT_SUCCESS;
  317. }
  318. static char *package_name = 0;
  319. /**
  320. * @brief updates an option
  321. * @param field the generic pointer to the field to update
  322. * @param orig_field the pointer to the orig field
  323. * @param field_given the pointer to the number of occurrence of this option
  324. * @param prev_given the pointer to the number of occurrence already seen
  325. * @param value the argument for this option (if null no arg was specified)
  326. * @param possible_values the possible values for this option (if specified)
  327. * @param default_value the default value (in case the option only accepts fixed values)
  328. * @param arg_type the type of this option
  329. * @param check_ambiguity @see cmdline_parser_params.check_ambiguity
  330. * @param override @see cmdline_parser_params.override
  331. * @param no_free whether to free a possible previous value
  332. * @param multiple_option whether this is a multiple option
  333. * @param long_opt the corresponding long option
  334. * @param short_opt the corresponding short option (or '-' if none)
  335. * @param additional_error possible further error specification
  336. */
  337. static
  338. int update_arg(void *field, char **orig_field,
  339. unsigned int *field_given, unsigned int *prev_given,
  340. char *value, const char *possible_values[],
  341. const char *default_value,
  342. cmdline_parser_arg_type arg_type,
  343. int check_ambiguity, int override,
  344. int no_free, int multiple_option,
  345. const char *long_opt, char short_opt,
  346. const char *additional_error)
  347. {
  348. char *stop_char = 0;
  349. const char *val = value;
  350. int found;
  351. char **string_field;
  352. FIX_UNUSED (field);
  353. stop_char = 0;
  354. found = 0;
  355. if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given)))
  356. {
  357. if (short_opt != '-')
  358. fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n",
  359. package_name, long_opt, short_opt,
  360. (additional_error ? additional_error : ""));
  361. else
  362. fprintf (stderr, "%s: `--%s' option given more than once%s\n",
  363. package_name, long_opt,
  364. (additional_error ? additional_error : ""));
  365. return 1; /* failure */
  366. }
  367. FIX_UNUSED (default_value);
  368. if (field_given && *field_given && ! override)
  369. return 0;
  370. if (prev_given)
  371. (*prev_given)++;
  372. if (field_given)
  373. (*field_given)++;
  374. if (possible_values)
  375. val = possible_values[found];
  376. switch(arg_type) {
  377. case ARG_FLAG:
  378. *((int *)field) = !*((int *)field);
  379. break;
  380. case ARG_INT:
  381. if (val) *((int *)field) = strtol (val, &stop_char, 0);
  382. break;
  383. case ARG_STRING:
  384. if (val) {
  385. string_field = (char **)field;
  386. if (!no_free && *string_field)
  387. free (*string_field); /* free previous string */
  388. *string_field = gengetopt_strdup (val);
  389. }
  390. break;
  391. default:
  392. break;
  393. };
  394. /* check numeric conversion */
  395. switch(arg_type) {
  396. case ARG_INT:
  397. if (val && !(stop_char && *stop_char == '\0')) {
  398. fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val);
  399. return 1; /* failure */
  400. }
  401. break;
  402. default:
  403. ;
  404. };
  405. /* store the original value */
  406. switch(arg_type) {
  407. case ARG_NO:
  408. case ARG_FLAG:
  409. break;
  410. default:
  411. if (value && orig_field) {
  412. if (no_free) {
  413. *orig_field = value;
  414. } else {
  415. if (*orig_field)
  416. free (*orig_field); /* free previous string */
  417. *orig_field = gengetopt_strdup (value);
  418. }
  419. }
  420. };
  421. return 0; /* OK */
  422. }
  423. int
  424. cmdline_parser_internal (
  425. int argc, char **argv, struct gengetopt_args_info *args_info,
  426. struct cmdline_parser_params *params, const char *additional_error)
  427. {
  428. int c; /* Character of the parsed option. */
  429. int error_occurred = 0;
  430. struct gengetopt_args_info local_args_info;
  431. int override;
  432. int initialize;
  433. int check_required;
  434. int check_ambiguity;
  435. package_name = argv[0];
  436. override = params->override;
  437. initialize = params->initialize;
  438. check_required = params->check_required;
  439. check_ambiguity = params->check_ambiguity;
  440. if (initialize)
  441. cmdline_parser_init (args_info);
  442. cmdline_parser_init (&local_args_info);
  443. optarg = 0;
  444. optind = 0;
  445. opterr = params->print_errors;
  446. optopt = '?';
  447. while (1)
  448. {
  449. int option_index = 0;
  450. static struct option long_options[] = {
  451. { "help", 0, NULL, 'h' },
  452. { "version", 0, NULL, 'V' },
  453. { "xdisplay", 1, NULL, 0 },
  454. { "nokeyboard", 0, NULL, 0 },
  455. { "bordersize", 1, NULL, 'b' },
  456. { "padding", 1, NULL, 'p' },
  457. { "tolerance", 1, NULL, 't' },
  458. { "gracetime", 1, NULL, 'g' },
  459. { "color", 1, NULL, 'c' },
  460. { "nodecorations", 0, NULL, 'n' },
  461. { "min", 1, NULL, 0 },
  462. { "max", 1, NULL, 0 },
  463. { "highlight", 0, NULL, 'l' },
  464. { 0, 0, 0, 0 }
  465. };
  466. c = getopt_long (argc, argv, "hVb:p:t:g:c:nl", long_options, &option_index);
  467. if (c == -1) break; /* Exit from `while (1)' loop. */
  468. switch (c)
  469. {
  470. case 'h': /* Print help and exit. */
  471. cmdline_parser_print_help ();
  472. cmdline_parser_free (&local_args_info);
  473. exit (EXIT_SUCCESS);
  474. case 'V': /* Print version and exit. */
  475. cmdline_parser_print_version ();
  476. cmdline_parser_free (&local_args_info);
  477. exit (EXIT_SUCCESS);
  478. case 'b': /* Set the selection rectangle's thickness. Does nothing when --highlight is enabled.. */
  479. if (update_arg( (void *)&(args_info->bordersize_arg),
  480. &(args_info->bordersize_orig), &(args_info->bordersize_given),
  481. &(local_args_info.bordersize_given), optarg, 0, "5", ARG_INT,
  482. check_ambiguity, override, 0, 0,
  483. "bordersize", 'b',
  484. additional_error))
  485. goto failure;
  486. break;
  487. case 'p': /* Set the padding size of the selection. Can be negative.. */
  488. if (update_arg( (void *)&(args_info->padding_arg),
  489. &(args_info->padding_orig), &(args_info->padding_given),
  490. &(local_args_info.padding_given), optarg, 0, "0", ARG_INT,
  491. check_ambiguity, override, 0, 0,
  492. "padding", 'p',
  493. additional_error))
  494. goto failure;
  495. break;
  496. case 't': /* How far in pixels the mouse can move after clicking and still be detected as a normal click instead of a click and drag. Setting this to 0 will disable window selections.. */
  497. if (update_arg( (void *)&(args_info->tolerance_arg),
  498. &(args_info->tolerance_orig), &(args_info->tolerance_given),
  499. &(local_args_info.tolerance_given), optarg, 0, "2", ARG_INT,
  500. check_ambiguity, override, 0, 0,
  501. "tolerance", 't',
  502. additional_error))
  503. goto failure;
  504. break;
  505. case 'g': /* Set the amount of time before slop will check for keyboard cancellations in seconds.. */
  506. if (update_arg( (void *)&(args_info->gracetime_arg),
  507. &(args_info->gracetime_orig), &(args_info->gracetime_given),
  508. &(local_args_info.gracetime_given), optarg, 0, "0.4", ARG_STRING,
  509. check_ambiguity, override, 0, 0,
  510. "gracetime", 'g',
  511. additional_error))
  512. goto failure;
  513. break;
  514. case 'c': /* Set the selection rectangle's color. Supports RGB or RGBA values.. */
  515. if (update_arg( (void *)&(args_info->color_arg),
  516. &(args_info->color_orig), &(args_info->color_given),
  517. &(local_args_info.color_given), optarg, 0, "0.5,0.5,0.5,1", ARG_STRING,
  518. check_ambiguity, override, 0, 0,
  519. "color", 'c',
  520. additional_error))
  521. goto failure;
  522. break;
  523. case 'n': /* Attempt to select child windows in order to avoid window decorations.. */
  524. if (update_arg((void *)&(args_info->nodecorations_flag), 0, &(args_info->nodecorations_given),
  525. &(local_args_info.nodecorations_given), optarg, 0, 0, ARG_FLAG,
  526. check_ambiguity, override, 1, 0, "nodecorations", 'n',
  527. additional_error))
  528. goto failure;
  529. break;
  530. case 'l': /* Instead of outlining selections, slop highlights it. This is only useful when --color is set to a transparent color.. */
  531. if (update_arg((void *)&(args_info->highlight_flag), 0, &(args_info->highlight_given),
  532. &(local_args_info.highlight_given), optarg, 0, 0, ARG_FLAG,
  533. check_ambiguity, override, 1, 0, "highlight", 'l',
  534. additional_error))
  535. goto failure;
  536. break;
  537. case 0: /* Long option with no short option */
  538. /* Sets the x display.. */
  539. if (strcmp (long_options[option_index].name, "xdisplay") == 0)
  540. {
  541. if (update_arg( (void *)&(args_info->xdisplay_arg),
  542. &(args_info->xdisplay_orig), &(args_info->xdisplay_given),
  543. &(local_args_info.xdisplay_given), optarg, 0, ":0", ARG_STRING,
  544. check_ambiguity, override, 0, 0,
  545. "xdisplay", '-',
  546. additional_error))
  547. goto failure;
  548. }
  549. /* Disables the ability to cancel selections with the keyboard.. */
  550. else if (strcmp (long_options[option_index].name, "nokeyboard") == 0)
  551. {
  552. if (update_arg((void *)&(args_info->nokeyboard_flag), 0, &(args_info->nokeyboard_given),
  553. &(local_args_info.nokeyboard_given), optarg, 0, 0, ARG_FLAG,
  554. check_ambiguity, override, 1, 0, "nokeyboard", '-',
  555. additional_error))
  556. goto failure;
  557. }
  558. /* Set the minimum output of width or height values. This is useful to avoid outputting 0. Setting min and max to the same value disables drag selections.. */
  559. else if (strcmp (long_options[option_index].name, "min") == 0)
  560. {
  561. if (update_arg( (void *)&(args_info->min_arg),
  562. &(args_info->min_orig), &(args_info->min_given),
  563. &(local_args_info.min_given), optarg, 0, "0", ARG_INT,
  564. check_ambiguity, override, 0, 0,
  565. "min", '-',
  566. additional_error))
  567. goto failure;
  568. }
  569. /* Set the maximum output of width or height values. Setting min and max to the same value disables drag selections.. */
  570. else if (strcmp (long_options[option_index].name, "max") == 0)
  571. {
  572. if (update_arg( (void *)&(args_info->max_arg),
  573. &(args_info->max_orig), &(args_info->max_given),
  574. &(local_args_info.max_given), optarg, 0, "0", ARG_INT,
  575. check_ambiguity, override, 0, 0,
  576. "max", '-',
  577. additional_error))
  578. goto failure;
  579. }
  580. break;
  581. case '?': /* Invalid option. */
  582. /* `getopt_long' already printed an error message. */
  583. goto failure;
  584. default: /* bug: option not considered. */
  585. fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : ""));
  586. abort ();
  587. } /* switch */
  588. } /* while */
  589. cmdline_parser_release (&local_args_info);
  590. if ( error_occurred )
  591. return (EXIT_FAILURE);
  592. return 0;
  593. failure:
  594. cmdline_parser_release (&local_args_info);
  595. return (EXIT_FAILURE);
  596. }