main.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /****************************************************************************
  2. *
  3. * MODULE: g.findetc
  4. * AUTHOR(S): William Kyngesburye
  5. * PURPOSE: Searches for GRASS support files
  6. * COPYRIGHT: (C) 2007 by the GRASS Development Team
  7. *
  8. * This program is free software under the GNU General Public
  9. * License (>=v2). Read the file COPYING that comes with GRASS
  10. * for details.
  11. *
  12. *****************************************************************************/
  13. #include <string.h>
  14. #include <stdlib.h>
  15. #include <stdio.h>
  16. #include <grass/gis.h>
  17. #include <grass/glocale.h>
  18. int main(int argc, char *argv[])
  19. {
  20. char name[200];
  21. char *fpath;
  22. struct GModule *module;
  23. struct Option *opt1;
  24. module = G_define_module();
  25. G_add_keyword(_("general"));
  26. G_add_keyword(_("map management"));
  27. G_add_keyword(_("scripts"));
  28. module->description = "Searches for GRASS support files.";
  29. G_gisinit(argv[0]);
  30. /* Define the different options */
  31. opt1 = G_define_option();
  32. opt1->key = "file";
  33. opt1->type = TYPE_STRING;
  34. opt1->required = YES;
  35. opt1->description = "Name of an file or directory";
  36. if (G_parser(argc, argv))
  37. exit(EXIT_FAILURE);
  38. strcpy(name, opt1->answer);
  39. fpath = G_find_etc(name);
  40. if (fpath)
  41. fprintf(stdout, "%s\n", fpath);
  42. exit(fpath ? EXIT_SUCCESS : EXIT_FAILURE);
  43. }