GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-b4e4cb0fe9
sigsetfile.c
Go to the documentation of this file.
1 /*!
2  \file lib/imagery/sigsetfile.c
3 
4  \brief Imagery Library - Signature file functions (statistics for i.smap)
5 
6  (C) 2001-2011, 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 
16 #include <grass/gis.h>
17 #include <grass/imagery.h>
18 #include <grass/glocale.h>
19 
20 /*!
21  \brief Create new sigset file
22 
23  \param name name of sigset file
24 
25  \return pointer to FILE
26  \return NULL on error
27  */
28 FILE *I_fopen_sigset_file_new(const char *name)
29 {
30  char dir[GNAME_MAX];
31  FILE *fd;
32 
33  /* create sig directory */
35 
37  fd = G_fopen_new_misc(dir, "sig", name);
38 
39  return fd;
40 }
41 
42 /*!
43  \brief Open existing sigset signature file
44 
45  \param name name of signature file (may be fully qualified)
46 
47  \return pointer to FILE*
48  \return NULL on error
49  */
50 FILE *I_fopen_sigset_file_old(const char *name)
51 {
52  char sig_name[GNAME_MAX], sig_mapset[GMAPSET_MAX];
53  char dir[GNAME_MAX];
54  FILE *fd;
55 
56  if (G_unqualified_name(name, NULL, sig_name, sig_mapset) == 0)
57  strcpy(sig_mapset, G_mapset());
58 
60  fd = G_fopen_old_misc(dir, "sig", sig_name, sig_mapset);
61 
62  return fd;
63 }
#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:205
int G_unqualified_name(const char *, const char *, char *, char *)
Returns unqualified map name (without @ mapset)
Definition: nme_in_mps.c:134
FILE * G_fopen_new_misc(const char *, const char *, const char *)
open a new database misc file
Definition: open_misc.c:178
const char * G_mapset(void)
Get current mapset name.
Definition: gis/mapset.c:33
void I_make_signatures_dir(I_SIGFILE_TYPE)
Make signature dir.
void I_get_signatures_dir(char *, I_SIGFILE_TYPE)
Get signature directory.
#define GMAPSET_MAX
Definition: gis.h:192
#define GNAME_MAX
Definition: gis.h:191
@ I_SIGFILE_TYPE_SIGSET
Definition: imagery.h:195
const char * name
Definition: named_colr.c:6
#define strcpy
Definition: parson.c:62
FILE * I_fopen_sigset_file_old(const char *name)
Open existing sigset signature file.
Definition: sigsetfile.c:50
FILE * I_fopen_sigset_file_new(const char *name)
Create new sigset file.
Definition: sigsetfile.c:28