56 #include <grass/gis.h>
57 #include <grass/glocale.h>
79 G_zero(hist,
sizeof(
struct History));
85 if (!
G_getl(hist->mapid,
sizeof(hist->mapid), fd))
89 if (!
G_getl(hist->title,
sizeof(hist->title), fd))
93 if (!
G_getl(hist->mapset,
sizeof(hist->mapset), fd))
97 if (!
G_getl(hist->creator,
sizeof(hist->creator), fd))
101 if (!
G_getl(hist->maptype,
sizeof(hist->maptype), fd))
105 if (!
G_getl(hist->datsrc_1,
sizeof(hist->datsrc_1), fd))
109 if (!
G_getl(hist->datsrc_2,
sizeof(hist->datsrc_2), fd))
113 if (!
G_getl(hist->keywrd,
sizeof(hist->keywrd), fd))
118 while ((hist->edlinecnt < MAXEDLINES) &&
120 (hist->edhist[hist->edlinecnt],
sizeof(hist->edhist[0]), fd))) {
132 G_warning(_(
"can't get history information for [%s] in mapset [%s]"),
162 fprintf(fd,
"%s\n", hist->mapid);
163 fprintf(fd,
"%s\n", hist->title);
164 fprintf(fd,
"%s\n", hist->mapset);
165 fprintf(fd,
"%s\n", hist->creator);
166 fprintf(fd,
"%s\n", hist->maptype);
167 fprintf(fd,
"%s\n", hist->datsrc_1);
168 fprintf(fd,
"%s\n", hist->datsrc_2);
169 fprintf(fd,
"%s\n", hist->keywrd);
171 for (i = 0; i < hist->edlinecnt; i++)
172 fprintf(fd,
"%s\n", hist->edhist[i]);
180 G_warning(_(
"can't write history information for [%s]"), name);
204 strncpy(hist->mapid,
G_date(), RECORD_LEN);
205 strncpy(hist->title, name, RECORD_LEN);
206 strncpy(hist->mapset,
G_mapset(), RECORD_LEN);
207 strncpy(hist->creator,
G_whoami(), RECORD_LEN);
208 strncpy(hist->maptype, type, RECORD_LEN);
211 strcpy(hist->datsrc_1,
"");
212 strcpy(hist->datsrc_2,
"");
260 cmdlen = strlen(cmdlin);
262 if (hist->edlinecnt > MAXEDLINES - 2) {
263 G_warning(_(
"Not enough room in history file to record command line."));
267 if (hist->edlinecnt > 0) {
268 strcpy(hist->edhist[hist->edlinecnt],
"");
278 while ((cmdlen - j) > 70) {
279 strncpy(hist->edhist[hist->edlinecnt], &cmdlin[j], 68);
280 hist->edhist[hist->edlinecnt][68] =
'\0';
281 strcat(hist->edhist[hist->edlinecnt],
"\\");
284 if (hist->edlinecnt > MAXEDLINES - 2) {
285 G_warning(_(
"Not enough room in history file for command line (truncated)."));
289 if ((cmdlen - j) > 0) {
290 strcpy(hist->edhist[hist->edlinecnt], &cmdlin[j]);
char * G_mapset(void)
current mapset name
sprintf(buf2,"%s", G3D_CATS_ELEMENT)
int G_short_history(const char *name, const char *type, struct History *hist)
initialize history structure
int G_ascii_check(char *string)
Removes non-ascii characters from buffer.
char * G_recreate_command(void)
Creates command to run non-interactive.
int G_write_history(const char *name, struct History *hist)
write raster history file
int G_zero(void *buf, int i)
Zero out a buffer, buf, of length i.
int G_command_history(struct History *hist)
Save command line to raster history structure.
const char * G_program_name(void)
return module name
char * G_whoami(void)
Gets user's name.
int G_getl(char *buf, int n, FILE *fd)
gets a line of text from a file
FILE * G_fopen_new(const char *element, const char *name)
Open a new database file.
G_warning("category support for [%s] in mapset [%s] %s", name, mapset, type)
int G_read_history(const char *name, const char *mapset, struct History *hist)
read raster history file
char * G_date(void)
Current date and time.
FILE * G_fopen_old(const char *element, const char *name, const char *mapset)
Open a database file for reading.