sigfile.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*!
  2. \file lib/imagery/sigfile.c
  3. \brief Imagery Library - Signature file functions (statistics for i.maxlik).
  4. (C) 2001-2008, 2013 by the GRASS Development Team
  5. This program is free software under the GNU General Public License
  6. (>=v2). Read the file COPYING that comes with GRASS for details.
  7. \author USA CERL
  8. */
  9. #include <string.h>
  10. #include <grass/imagery.h>
  11. /*!
  12. \brief Create signature file
  13. \param group group name
  14. \param subgroup subgroup name in given group
  15. \param name signature filename
  16. \return pointer to FILE*
  17. \return NULL on error
  18. */
  19. FILE *I_fopen_signature_file_new(const char *group,
  20. const char *subgroup, const char *name)
  21. {
  22. char element[GPATH_MAX];
  23. char group_name[GNAME_MAX], group_mapset[GMAPSET_MAX];
  24. FILE *fd;
  25. if (!G_name_is_fully_qualified(group, group_name, group_mapset)) {
  26. strcpy(group_name, group);
  27. }
  28. /* create sigset directory */
  29. sprintf(element, "%s/subgroup/%s/sig", group_name, subgroup);
  30. G__make_mapset_element_misc("group", element);
  31. sprintf(element, "subgroup/%s/sig/%s", subgroup, name);
  32. fd = G_fopen_new_misc("group", element, group_name);
  33. return fd;
  34. }
  35. /*!
  36. \brief Open existing signature file
  37. \param group group name (may be fully qualified)
  38. \param subgroup subgroup name in given group
  39. \param name signature filename
  40. \return pointer to FILE*
  41. \return NULL on error
  42. */
  43. FILE *I_fopen_signature_file_old(const char *group,
  44. const char *subgroup, const char *name)
  45. {
  46. char element[GPATH_MAX];
  47. char group_name[GNAME_MAX], group_mapset[GMAPSET_MAX];
  48. FILE *fd;
  49. G_unqualified_name(group, NULL, group_name, group_mapset);
  50. sprintf(element, "subgroup/%s/sig/%s", subgroup, name);
  51. fd = G_fopen_old_misc("group", element, group_name, group_mapset);
  52. return fd;
  53. }