sigfile.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*!
  2. \file lib/imagery/sigfile.c
  3. \brief Imagery Library - Signature file functions (statistics for i.maxlik).
  4. (C) 2001-2008, 2013, 2021 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. Returns a pointer to FILE for writing signature file.
  14. Use fclose on the pointer to close after use.
  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 *name)
  20. {
  21. char dir[GNAME_MAX];
  22. FILE *fd;
  23. /* create sig directory */
  24. I_make_signatures_dir(I_SIGFILE_TYPE_SIG);
  25. I_get_signatures_dir(dir, I_SIGFILE_TYPE_SIG);
  26. fd = G_fopen_new_misc(dir, "sig", name);
  27. return fd;
  28. }
  29. /*!
  30. \brief Open existing signature file
  31. Use fully qualified names for signatures from other mapsets.
  32. Returns a pointer to FILE with signature. Use fclose on the pointer
  33. after use.
  34. \param name signature filename
  35. \return pointer to FILE
  36. \return NULL on error
  37. */
  38. FILE *I_fopen_signature_file_old(const char *name)
  39. {
  40. char sig_name[GNAME_MAX], sig_mapset[GMAPSET_MAX];
  41. char dir[GNAME_MAX];
  42. FILE *fd;
  43. if (G_unqualified_name(name, NULL, sig_name, sig_mapset) == 0)
  44. strcpy(sig_mapset, G_mapset());
  45. I_get_signatures_dir(dir, I_SIGFILE_TYPE_SIG);
  46. fd = G_fopen_old_misc(dir, "sig", sig_name, sig_mapset);
  47. return fd;
  48. }