[GRASS-SVN] r35818 - in grass/trunk: include lib/gis

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Feb 9 05:53:26 EST 2009


Author: glynn
Date: 2009-02-09 05:53:26 -0500 (Mon, 09 Feb 2009)
New Revision: 35818

Added:
   grass/trunk/lib/gis/seek.c
Modified:
   grass/trunk/include/gisdefs.h
Log:
Add G_fseek(), G_ftell()


Modified: grass/trunk/include/gisdefs.h
===================================================================
--- grass/trunk/include/gisdefs.h	2009-02-09 01:20:12 UTC (rev 35817)
+++ grass/trunk/include/gisdefs.h	2009-02-09 10:53:26 UTC (rev 35818)
@@ -44,6 +44,8 @@
 # define G__freea(p) G_free(p)
 #endif
 
+#include <sys/types.h>
+
 /* adj_cellhd.c */
 const char *G_adjust_Cell_head(struct Cell_head *, int, int);
 const char *G_adjust_Cell_head3(struct Cell_head *, int, int, int);
@@ -1050,6 +1052,10 @@
     int, const struct Cell_head *, struct Categories *, double, double, int,
     INTERP_TYPE);
 
+/* seek.c */
+off_t G_ftell(FILE *);
+void G_fseek(FILE *, off_t, int);
+
 /* set_window.c */
 void G_get_set_window(struct Cell_head *);
 int G_set_window(struct Cell_head *);

Added: grass/trunk/lib/gis/seek.c
===================================================================
--- grass/trunk/lib/gis/seek.c	                        (rev 0)
+++ grass/trunk/lib/gis/seek.c	2009-02-09 10:53:26 UTC (rev 35818)
@@ -0,0 +1,30 @@
+
+#include <grass/config.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <grass/gis.h>
+#include <grass/glocale.h>
+
+off_t G_ftell(FILE *fp)
+{
+#ifdef HAVE_LARGEFILES
+    return ftello(fp);
+#else
+    return (off_t) ftell(fp);
+#endif     
+}
+
+void G_fseek(FILE *fp, off_t offset, int whence)
+{
+#ifdef HAVE_LARGEFILES
+    if (fseeko(fp, offset, whence) != 0)
+	G_fatal_error(_("unable to seek"));
+#else
+    long loff = (long) offset;
+    if ((off_t) loff != offset)
+	G_fatal_error(_("seek offset out of range"));
+    if (fseek(fp, loff, whence) != 0)
+	G_fatal_error(_("unable to seek"));
+#endif     
+}
+



More information about the grass-commit mailing list