history.c File Reference

#include <string.h>
#include <grass/gis.h>
#include <grass/glocale.h>

Include dependency graph for history.c:

Go to the source code of this file.

Functions

int G_read_history (char *name, char *mapset, struct History *hist)
 read raster history file
int G_write_history (char *name, struct History *hist)
 write raster history file
int G_short_history (char *name, char *type, struct History *hist)
 initialize history structure
int G_command_history (struct History *hist)
 Save command line to raster history structure.


Function Documentation

int G_command_history ( struct History *  hist  ) 

Save command line to raster history structure.

This routine takes an existing (run G_short_history first) history structure and adds the command line to the end of the comments array, as cleaned & expanded by the parser.

History file is limited to [80]x[50], as defined in include/gis.h

* First version had for loops of [i][j] character assignments and ending nulls, but using the string libraries is cleaner and less bug prone. * Second version had white space detection, intelligent wrapping, and indentation of continued lines, but this proved a pain in the neck for things like r.patch which can have long strings without any parser-acceptable breaks. * This is MK-III, simplified, but that's good: it's cut & paste-able.

NOTE: use G_write_history() to write the structure.

Sample Usage:

struct History history; G_short_history(rasterfile, "raster", &history); G_command_history(&history); G_write_history(rasterfile, &history);

Returns: 0 success 1 failure (history file full, no change) 2 failure (history file full, added as much as we could)

Parameters:
history 
Returns:
int

Definition at line 261 of file history.c.

References G_recreate_command(), and G_warning().

int G_read_history ( char *  name,
char *  mapset,
struct History *  hist 
)

read raster history file

This routine reads the history file for the raster file name in mapset into the history structure. A diagnostic message is printed and -1 is returned if there is an error reading the history file. Otherwise, 0 is returned.

Parameters:
name 
mapset 
history 
Returns:
int

Definition at line 74 of file history.c.

References G_ascii_check(), G_fopen_old(), G_getl(), G_warning(), G_zero(), and NULL.

int G_short_history ( char *  name,
char *  type,
struct History *  hist 
)

initialize history structure

This routine initializes the history structure, recording the date, user, module name and the raster file name structure. The type is an anachronism from earlier versions of GRASS and should be specified as "raster". Note. This routine only initializes the data structure. It does not write the history file.

Parameters:
name 
type 
history 
Returns:
int

Definition at line 206 of file history.c.

References G_date(), G_mapset(), G_program_name(), and G_whoami().

int G_write_history ( char *  name,
struct History *  hist 
)

write raster history file

This routine writes the history file for the raster file name in the current mapset from the history 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 history structure should first be initialized using G_short_history.

Parameters:
name 
history 
Returns:
int

Definition at line 155 of file history.c.

References G_fopen_new(), and G_warning().


Generated on Sun Apr 6 17:32:20 2008 for GRASS by  doxygen 1.5.5