GRASS Programmer's Manual  6.5.svn(2014)-r66266
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
gis/seek.c
Go to the documentation of this file.
1 
14 #include <stdio.h>
15 #include <sys/types.h>
16 #include <grass/gis.h>
17 #include <grass/glocale.h>
18 
27 off_t G_ftell(FILE *fp)
28 {
29 #ifdef HAVE_FSEEKO
30  return ftello(fp);
31 #else
32  return (off_t) ftell(fp);
33 #endif
34 }
35 
48 void G_fseek(FILE *fp, off_t offset, int whence)
49 {
50 #ifdef HAVE_FSEEKO
51  if (fseeko(fp, offset, whence) != 0)
52  G_fatal_error(_("Unable to seek"));
53 #else
54  long loff = (long) offset;
55  if ((off_t) loff != offset)
56  G_fatal_error(_("Seek offset out of range"));
57  if (fseek(fp, loff, whence) != 0)
58  G_fatal_error(_("Unable to seek"));
59 #endif
60 }
off_t G_ftell(FILE *fp)
Get the current file position of the stream.
Definition: gis/seek.c:27
void G_fseek(FILE *fp, off_t offset, int whence)
Change the file position of the stream.
Definition: gis/seek.c:48
int G_fatal_error(const char *msg,...)
Print a fatal error message to stderr.