96 #include <grass/gis.h>
97 #include <grass/glocale.h>
111 const DateTime * dt1,
const DateTime * dt2)
123 while (fgets(buf,
sizeof(buf), fd)) {
124 if (sscanf(buf,
"%1s", comment) != 1 || *comment ==
'#')
151 fprintf(fd,
"%s\n", buf);
173 char temp1[128], temp2[128];
186 else if (ts->count == 2)
187 sprintf(buf,
"%s / %s", temp1, temp2);
214 for (slash = buf; *slash; slash++)
253 DateTime * dt1, DateTime * dt2,
int *
count)
274 static int write_timestamp(
const char *
maptype,
const char *dir,
275 const char *
name,
const struct TimeStamp *ts)
282 G_warning(_(
"Can't create timestamp file for %s map %s in mapset %s"),
291 G_warning(_(
"Invalid timestamp specified for %s map %s in mapset %s"),
302 static int read_timestamp(
const char *maptype,
const char *dir,
303 const char *name,
const char *mapset,
304 struct TimeStamp *ts)
313 G_warning(_(
"Can't open timestamp file for %s map %s in mapset %s"),
314 maptype, name, mapset);
322 G_warning(_(
"Invalid timestamp file for %s map %s in mapset %s"),
323 maptype, name, mapset);
327 #define RAST_MISC "cell_misc"
328 #define VECT_MISC "dig_misc"
329 #define GRID3 "grid3"
345 struct TimeStamp *ts)
347 return read_timestamp(
"raster",
RAST_MISC, name, mapset, ts);
383 struct TimeStamp *ts)
385 return read_timestamp(
"vector",
VECT_MISC, name, mapset, ts);
422 struct TimeStamp *ts)
424 return read_timestamp(
"grid3",
GRID3, name, mapset, ts);
461 return write_timestamp(
"raster",
RAST_MISC, name, ts);
480 return write_timestamp(
"vector",
VECT_MISC, name, ts);
498 return write_timestamp(
"grid3",
GRID3, name, ts);
char * G_mapset(void)
current mapset name
sprintf(buf2,"%s", G3D_CATS_ELEMENT)
int G_read_raster_timestamp(const char *name, const char *mapset, struct TimeStamp *ts)
Read timestamp from raster map.
int G__write_timestamp(FILE *fd, const struct TimeStamp *ts)
output TimeStamp structure to a file as a formatted string
void G_set_timestamp(struct TimeStamp *ts, const DateTime *dt)
char * G_find_file2_misc(const char *dir, const char *element, const char *name, const char *mapset)
int G_scan_timestamp(struct TimeStamp *ts, const char *buf)
Fill a TimeStamp structure from a datetime string.
FILE * G_fopen_old_misc(const char *dir, const char *element, const char *name, const char *mapset)
open a database file for reading
int G_write_vector_timestamp(const char *name, const struct TimeStamp *ts)
Returns: 1 on success. -1 error - can't create timestamp file -2 error - invalid datetime in ts...
int G_write_raster_timestamp(const char *name, const struct TimeStamp *ts)
Returns: 1 on success. -1 error - can't create timestamp file -2 error - invalid datetime in ts...
int G__read_timestamp(FILE *fd, struct TimeStamp *ts)
int G_read_grid3_timestamp(const char *name, const char *mapset, struct TimeStamp *ts)
read grid3 timestamp
int G_remove_vector_timestamp(const char *name)
Is this used anymore with the new GRASS 6 vector engine???
void datetime_copy(DateTime *dst, const DateTime *src)
Copies the DateTime [into/from ???] src.
int G_write_grid3_timestamp(const char *name, const struct TimeStamp *ts)
write grid3 timestamp
int G_remove_grid3_timestamp(const char *name)
remove grid3 timestamp
int G_get_timestamps(const struct TimeStamp *ts, DateTime *dt1, DateTime *dt2, int *count)
copy TimeStamp into [two] Datetimes structs
char buf[GNAME_MAX+sizeof(G3D_DIRECTORY)+2]
G_warning("category support for [%s] in mapset [%s] %s", name, mapset, type)
void G_set_timestamp_range(struct TimeStamp *ts, const DateTime *dt1, const DateTime *dt2)
FILE * G_fopen_new_misc(const char *dir, const char *element, const char *name)
open a new database file
int G_remove_misc(const char *dir, const char *element, const char *name)
Remove a database misc file.
int G_remove_raster_timestamp(const char *name)
Only timestamp files in current mapset can be removed Returns: 0 if no file 1 if successful -1 on fai...
int datetime_scan(DateTime *dt, const char *buf)
Convert the ascii string into a DateTime. This determines the mode/from/to based on the string...
int G_format_timestamp(const struct TimeStamp *ts, char *buf)
Create text string from TimeStamp structure.
int G_read_vector_timestamp(const char *name, const char *mapset, struct TimeStamp *ts)
Read vector timestamp.
void G_init_timestamp(struct TimeStamp *ts)