GRASS GIS 8 Programmer's Manual  8.2.1dev(2022)-5aae26b9b
sigfile.c
Go to the documentation of this file.
1 /*!
2  \file lib/imagery/sigfile.c
3 
4  \brief Imagery Library - Signature file functions (statistics for i.maxlik).
5 
6  (C) 2001-2008, 2013, 2021 by the GRASS Development Team
7 
8  This program is free software under the GNU General Public License
9  (>=v2). Read the file COPYING that comes with GRASS for details.
10 
11  \author USA CERL
12  */
13 
14 #include <string.h>
15 #include <grass/imagery.h>
16 
17 /*!
18  \brief Create signature file
19 
20  Returns a pointer to FILE for writing signature file.
21  Use fclose on the pointer to close after use.
22 
23  \param name signature filename
24 
25  \return pointer to FILE
26  \return NULL on error
27  */
28 FILE *I_fopen_signature_file_new(const char *name)
29 {
30  char dir[GNAME_MAX];
31  FILE *fd;
32 
33  /* create sig directory */
36  fd = G_fopen_new_misc(dir, "sig", name);
37 
38  return fd;
39 }
40 
41 /*!
42  \brief Open existing signature file
43 
44  Use fully qualified names for signatures from other mapsets.
45 
46  Returns a pointer to FILE with signature. Use fclose on the pointer
47  after use.
48 
49  \param name signature filename
50 
51  \return pointer to FILE
52  \return NULL on error
53  */
54 FILE *I_fopen_signature_file_old(const char *name)
55 {
56  char sig_name[GNAME_MAX], sig_mapset[GMAPSET_MAX];
57  char dir[GNAME_MAX];
58  FILE *fd;
59 
60  if (G_unqualified_name(name, NULL, sig_name, sig_mapset) == 0)
61  strcpy(sig_mapset, G_mapset());
62 
64  fd = G_fopen_old_misc(dir, "sig", sig_name, sig_mapset);
65 
66  return fd;
67 }
#define GMAPSET_MAX
Definition: gis.h:178
int G_unqualified_name(const char *, const char *, char *, char *)
Returns unqualified map name (without @ mapset)
Definition: nme_in_mps.c:134
#define NULL
Definition: ccmath.h:32
FILE * G_fopen_old_misc(const char *, const char *, const char *, const char *)
open a database misc file for reading
Definition: open_misc.c:210
FILE * I_fopen_signature_file_new(const char *name)
Create signature file.
Definition: sigfile.c:28
FILE * I_fopen_signature_file_old(const char *name)
Open existing signature file.
Definition: sigfile.c:54
FILE * G_fopen_new_misc(const char *, const char *, const char *)
open a new database misc file
Definition: open_misc.c:182
const char * G_mapset(void)
Get current mapset name.
Definition: gis/mapset.c:33
#define GNAME_MAX
Definition: gis.h:177
void I_make_signatures_dir(I_SIGFILE_TYPE)
Make signature dir.
void I_get_signatures_dir(char *, I_SIGFILE_TYPE)
Get signature directory.
const char * name
Definition: named_colr.c:7