parse.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #include <grass/gis.h>
  2. #include <grass/glocale.h>
  3. #include "local_proto.h"
  4. void parse_args(int argc, char** argv,
  5. char** input, char** field,
  6. int* history, int* columns, int* region, int* topo, int* title)
  7. {
  8. struct Option *input_opt, *field_opt;
  9. struct Flag *hist_flag, *col_flag, *region_flag, *topo_flag, *title_flag;
  10. input_opt = G_define_standard_option(G_OPT_V_MAP);
  11. field_opt = G_define_standard_option(G_OPT_V_FIELD);
  12. hist_flag = G_define_flag();
  13. hist_flag->key = 'h';
  14. hist_flag->description = _("Print vector history instead of info");
  15. hist_flag->guisection = _("Print");
  16. col_flag = G_define_flag();
  17. col_flag->key = 'c';
  18. col_flag->description =
  19. _("Print types/names of table columns for specified layer instead of info");
  20. col_flag->guisection = _("Print");
  21. region_flag = G_define_flag();
  22. region_flag->key = 'g';
  23. region_flag->description = _("Print map region only");
  24. region_flag->guisection = _("Print");
  25. title_flag = G_define_flag();
  26. title_flag->key = 'm';
  27. title_flag->description = _("Print map title only");
  28. title_flag->guisection = _("Print");
  29. topo_flag = G_define_flag();
  30. topo_flag->key = 't';
  31. topo_flag->description = _("Print topology information only");
  32. topo_flag->guisection = _("Print");
  33. if (G_parser(argc, argv))
  34. exit(EXIT_FAILURE);
  35. *input = G_store(input_opt->answer);
  36. *field = G_store(field_opt->answer);
  37. *history = hist_flag-> answer ? 1 : 0;
  38. *columns = col_flag-> answer ? 1 : 0;
  39. *region = region_flag-> answer ? 1 : 0;
  40. *title = title_flag-> answer ? 1 : 0;
  41. *topo = topo_flag-> answer ? 1 : 0;
  42. }