GRASS GIS 8 Programmer's Manual  8.5.0dev(2024)-36359e2344
manage_signatures.c File Reference
#include <unistd.h>
#include <string.h>
#include <grass/gis.h>
#include <grass/imagery.h>
#include <grass/glocale.h>
Include dependency graph for manage_signatures.c:

Go to the source code of this file.

Functions

void I_get_signatures_dir (char *dir, I_SIGFILE_TYPE type)
 Get signature directory. More...
 
void I_make_signatures_dir (I_SIGFILE_TYPE type)
 Make signature dir. More...
 
int I_signatures_remove (I_SIGFILE_TYPE type, const char *name)
 Remove a signature file. More...
 
int I_signatures_copy (I_SIGFILE_TYPE type, const char *old_name, const char *old_mapset, const char *new_name)
 Copy a signature file. More...
 
int I_signatures_rename (I_SIGFILE_TYPE type, const char *old_name, const char *new_name)
 Rename a signature file. More...
 
int I_signatures_list_by_type (I_SIGFILE_TYPE type, const char *mapset, char ***out_list)
 Get list of existing signatures by type. More...
 
void I_free_signatures_list (int count, char ***list)
 Free memory allocated by I_signatures_list_by_type. More...
 

Function Documentation

◆ I_free_signatures_list()

void I_free_signatures_list ( int  count,
char ***  list 
)

Free memory allocated by I_signatures_list_by_type.

Calls G_free for all list items returned by I_signatures_list_by_type() Sets pointer to NULL to prevent accidental use after free.

Parameters
intReturn value of I_signatures_list_by_type()
pointerto array filled by I_signatures_list_by_type()

Definition at line 264 of file manage_signatures.c.

References count, G_free(), and NULL.

◆ I_get_signatures_dir()

void I_get_signatures_dir ( char *  dir,
I_SIGFILE_TYPE  type 
)

Get signature directory.

The directory will be in a form "signatures/<type>".

Parameters
dir[GNAME_MAX] allocated string buffer
typeI_SIGFILE_TYPE

Definition at line 29 of file manage_signatures.c.

Referenced by I_fopen_signature_file_new(), I_fopen_signature_file_old(), I_fopen_sigset_file_new(), and I_fopen_sigset_file_old().

◆ I_make_signatures_dir()

void I_make_signatures_dir ( I_SIGFILE_TYPE  type)

Make signature dir.

Creates directories for storage of signature files of specified type. E.g. "<location>/<mapset>/signatures/<type>/"

Parameters
typeI_SIGFILE_TYPE

Definition at line 53 of file manage_signatures.c.

Referenced by I_fopen_signature_file_new(), and I_fopen_sigset_file_new().

◆ I_signatures_copy()

int I_signatures_copy ( I_SIGFILE_TYPE  type,
const char *  old_name,
const char *  old_mapset,
const char *  new_name 
)

Copy a signature file.

If copy fails, prints warning messages and returns 1. It is safe to pass fully qualified names.

Parameters
typeI_SIGFILE_TYPE signature type
nameof old signature
mapsetof old signature
nameof new signature
Returns
0 on success
1 on failure

Definition at line 114 of file manage_signatures.c.

◆ I_signatures_list_by_type()

int I_signatures_list_by_type ( I_SIGFILE_TYPE  type,
const char *  mapset,
char ***  out_list 
)

Get list of existing signatures by type.

Fills passed list with fully qualified names of existing signatures.

If no mapset is passed, all mapsets in the search path are used. If no signatures are found, returns 0 and list is set to NULL.

The function will assign memory for the list. It is up to callee to free the memory of each list item and the list itself.

Parameters
typeI_SIGFILE_TYPE signature type
mapsetoptional mapset to search in or NULL
pointerto array of found signature strings or NULL if none found
Returns
count of signature strings in the array

Definition at line 237 of file manage_signatures.c.

◆ I_signatures_remove()

int I_signatures_remove ( I_SIGFILE_TYPE  type,
const char *  name 
)

Remove a signature file.

If removal fails, prints a warning and returns 1. It is safe to pass fully qualified names.

Parameters
typeI_SIGFILE_TYPE signature type
nameof signature to remove
Returns
0 on success
1 on failure

Definition at line 75 of file manage_signatures.c.

◆ I_signatures_rename()

int I_signatures_rename ( I_SIGFILE_TYPE  type,
const char *  old_name,
const char *  new_name 
)

Rename a signature file.

If rename fails, prints warning messages and returns 1. It is safe to pass fully qualified names.

Parameters
typeI_SIGFILE_TYPE signature type
nameof old signature
nameof new signature
Returns
0 on success
1 on failure

Definition at line 172 of file manage_signatures.c.