GRASS GIS 8 Programmer's Manual
8.5.0dev(2024)-3973a58369
|
Raster Library - History management. More...
#include <stdarg.h>
#include <string.h>
#include <grass/gis.h>
#include <grass/raster.h>
#include <grass/glocale.h>
Go to the source code of this file.
Functions | |
void | Rast_append_history (struct History *hist, const char *str) |
Append a string to a History structure. More... | |
void | Rast_append_format_history (struct History *hist, const char *fmt,...) |
Append a formatted string to a History structure. More... | |
int | Rast__read_history (struct History *hist, FILE *fp) |
int | Rast_read_history (const char *name, const char *mapset, struct History *hist) |
Read raster history file. More... | |
void | Rast__write_history (struct History *hist, FILE *fp) |
void | Rast_write_history (const char *name, struct History *hist) |
Write raster history file. More... | |
const char * | Rast_get_history (struct History *hist, int field) |
Set the string of a specific history field. More... | |
void | Rast_set_history (struct History *hist, int field, const char *str) |
Set the string of a specific history field. More... | |
void | Rast_format_history (struct History *hist, int field, const char *fmt,...) |
void | Rast_short_history (const char *name, const char *type, struct History *hist) |
Initialize history structure. More... | |
int | Rast_command_history (struct History *hist) |
Save command line to raster history structure. More... | |
void | Rast_clear_history (struct History *hist) |
void | Rast_free_history (struct History *hist) |
int | Rast_history_length (struct History *hist) |
const char * | Rast_history_line (struct History *hist, int line) |
Raster Library - History management.
(C) 2001-2009 GRASS Development Team
This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.
Definition in file raster/history.c.
int Rast__read_history | ( | struct History * | hist, |
FILE * | fp | ||
) |
Definition at line 59 of file raster/history.c.
References History::fields, G_ascii_check(), G_getl(), G_store(), HIST_NUM_FIELDS, History::nlines, and Rast_append_history().
Referenced by Rast3d_read_history(), and Rast_read_history().
void Rast__write_history | ( | struct History * | hist, |
FILE * | fp | ||
) |
Definition at line 128 of file raster/history.c.
References History::fields, HIST_NUM_FIELDS, History::lines, and History::nlines.
Referenced by Rast3d_write_history(), and Rast_write_history().
void Rast_append_format_history | ( | struct History * | hist, |
const char * | fmt, | ||
... | |||
) |
Append a formatted string to a History structure.
hist | pointer to History structure which holds history info |
fmt | a string of format characters |
... | the arguments associated with the format characters |
Definition at line 45 of file raster/history.c.
References G_realloc, G_vasprintf(), History::lines, and History::nlines.
void Rast_append_history | ( | struct History * | hist, |
const char * | str | ||
) |
Append a string to a History structure.
hist | pointer to History structure which holds history info |
str | string to append |
Definition at line 29 of file raster/history.c.
References G_realloc, G_store(), History::lines, and History::nlines.
Referenced by Rast__read_history(), and Rast_command_history().
void Rast_clear_history | ( | struct History * | hist | ) |
Definition at line 307 of file raster/history.c.
References G_free(), History::lines, History::nlines, and NULL.
Referenced by Rast_free_history().
int Rast_command_history | ( | struct History * | hist | ) |
Save command line to raster history structure.
This routine takes an existing (run Rast_short_history first() history structure and adds the command line to the end of the comments array, as cleaned & expanded by the parser.
Note: use Rast_write_history() to write the structure.
Sample Usage:
hist | pointer to History structure which holds history info |
Definition at line 274 of file raster/history.c.
References G_free(), G_recreate_command(), History::nlines, and Rast_append_history().
void Rast_format_history | ( | struct History * | hist, |
int | field, | ||
const char * | fmt, | ||
... | |||
) |
Definition at line 200 of file raster/history.c.
References History::fields, G_free(), and G_vasprintf().
void Rast_free_history | ( | struct History * | hist | ) |
Definition at line 321 of file raster/history.c.
References History::fields, G_free(), HIST_NUM_FIELDS, NULL, and Rast_clear_history().
const char* Rast_get_history | ( | struct History * | hist, |
int | field | ||
) |
Set the string of a specific history field.
hist | pointer to History structure which holds history info |
field | number of a specific history field, should be accessed with macros (HIST_MAPID, ...) |
Definition at line 178 of file raster/history.c.
References History::fields.
int Rast_history_length | ( | struct History * | hist | ) |
Definition at line 334 of file raster/history.c.
References History::nlines.
const char* Rast_history_line | ( | struct History * | hist, |
int | line | ||
) |
Definition at line 339 of file raster/history.c.
int Rast_read_history | ( | const char * | name, |
const char * | mapset, | ||
struct History * | hist | ||
) |
Read raster history file.
This routine reads the history file for the raster map name in mapset into the hist structure.
A diagnostic message is printed and -1 is returned if there is an error reading the history file. Otherwise, 0 is returned.
name | map name |
mapset | mapset name |
hist | pointer to History structure which holds history info |
Definition at line 107 of file raster/history.c.
References _, G_fopen_old(), G_warning(), G_zero(), name, and Rast__read_history().
void Rast_set_history | ( | struct History * | hist, |
int | field, | ||
const char * | str | ||
) |
Set the string of a specific history field.
hist | pointer to History structure which holds history info |
field | number of a specific history field, should be accessed with macros (HIST_MAPID, ...) |
str | string of the history field |
Definition at line 193 of file raster/history.c.
References History::fields, G_free(), G_store(), and NULL.
void Rast_short_history | ( | const char * | name, |
const char * | type, | ||
struct History * | hist | ||
) |
Initialize history structure.
This routine initializes the hist structure, recording the date, user, module name and the raster map name structure. The type can be "raster", "reclass", "GDAL-link", or "virtual".
Note: This routine only initializes the data structure. It does not write the history file.
name | map name |
type | map type |
hist | pointer to History structure which holds history info |
Definition at line 227 of file raster/history.c.
void Rast_write_history | ( | const char * | name, |
struct History * | hist | ||
) |
Write raster history file.
This routine writes the history file for the raster map name in the current mapset from the hist structure.
A diagnostic message is printed and -1 is returned if there is an error writing the history file. Otherwise, 0 is returned.
Note: The hist structure should first be initialized using Rast_short_history().
name | map name | |
[out] | hist | pointer to History structure which holds history info |
Definition at line 158 of file raster/history.c.
References _, G_fatal_error(), G_fopen_new(), name, and Rast__write_history().