Bladeren bron

doxygen update (diglib/portable.c)
use size_t instead of int


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@37266 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 16 jaren geleden
bovenliggende
commit
2f76bd715e
3 gewijzigde bestanden met toevoegingen van 327 en 114 verwijderingen
  1. 17 17
      include/vect/dig_externs.h
  2. 3 2
      lib/vector/diglib/file.c
  3. 307 95
      lib/vector/diglib/portable.c

+ 17 - 17
include/vect/dig_externs.h

@@ -48,22 +48,22 @@ int dig_set_cur_port(struct Port_info *);
 int dig__write_head(struct Map_info *);
 int dig__write_head(struct Map_info *);
 int dig__read_head(struct Map_info *);
 int dig__read_head(struct Map_info *);
 
 
-int dig__fread_port_D(double *, int, GVFILE *);
-int dig__fread_port_F(float *, int, GVFILE *);
-int dig__fread_port_O(off_t *, int, GVFILE *, int);
-int dig__fread_port_L(long *, int, GVFILE *);
-int dig__fread_port_S(short *, int, GVFILE *);
-int dig__fread_port_I(int *, int, GVFILE *);
-int dig__fread_port_P(plus_t *, int, GVFILE *);
-int dig__fread_port_C(char *, int, GVFILE *);
-int dig__fwrite_port_D(const double *, int, GVFILE *);
-int dig__fwrite_port_F(const float *, int, GVFILE *);
-int dig__fwrite_port_O(const off_t *, int, GVFILE *, int);
-int dig__fwrite_port_L(const long *, int, GVFILE *);
-int dig__fwrite_port_S(const short *, int, GVFILE *);
-int dig__fwrite_port_I(const int *, int, GVFILE *);
-int dig__fwrite_port_P(const plus_t *, int, GVFILE *);
-int dig__fwrite_port_C(const char *, int, GVFILE *);
+int dig__fread_port_D(double *, size_t, GVFILE *);
+int dig__fread_port_F(float *, size_t, GVFILE *);
+int dig__fread_port_O(off_t *, size_t, GVFILE *, size_t);
+int dig__fread_port_L(long *, size_t, GVFILE *);
+int dig__fread_port_S(short *, size_t, GVFILE *);
+int dig__fread_port_I(int *, size_t, GVFILE *);
+int dig__fread_port_P(plus_t *, size_t, GVFILE *);
+int dig__fread_port_C(char *, size_t, GVFILE *);
+int dig__fwrite_port_D(const double *, size_t, GVFILE *);
+int dig__fwrite_port_F(const float *, size_t, GVFILE *);
+int dig__fwrite_port_O(const off_t *, size_t, GVFILE *, size_t);
+int dig__fwrite_port_L(const long *, size_t, GVFILE *);
+int dig__fwrite_port_S(const short *, size_t, GVFILE *);
+int dig__fwrite_port_I(const int *, size_t, GVFILE *);
+int dig__fwrite_port_P(const plus_t *, size_t, GVFILE *);
+int dig__fwrite_port_C(const char *, size_t, GVFILE *);
 
 
 
 
 /******************************************************************************/
 /******************************************************************************/
@@ -250,7 +250,7 @@ int dig_fseek(GVFILE * file, off_t offset, int whence);
 void dig_rewind(GVFILE * file);
 void dig_rewind(GVFILE * file);
 int dig_fflush(GVFILE * file);
 int dig_fflush(GVFILE * file);
 size_t dig_fread(void *ptr, size_t size, size_t nmemb, GVFILE * file);
 size_t dig_fread(void *ptr, size_t size, size_t nmemb, GVFILE * file);
-size_t dig_fwrite(void *ptr, size_t size, size_t nmemb, GVFILE * file);
+size_t dig_fwrite(const void *ptr, size_t size, size_t nmemb, GVFILE * file);
 void dig_file_init(GVFILE * file);
 void dig_file_init(GVFILE * file);
 int dig_file_load(GVFILE * file);
 int dig_file_load(GVFILE * file);
 void dig_file_free(GVFILE * file);
 void dig_file_free(GVFILE * file);

+ 3 - 2
lib/vector/diglib/file.c

@@ -14,7 +14,8 @@
    This program is free software under the GNU General Public License
    This program is free software under the GNU General Public License
    (>=v2).  Read the file COPYING that comes with GRASS for details.
    (>=v2).  Read the file COPYING that comes with GRASS for details.
 
 
-   \author Dave Gerdes, Radim Blazek
+   \author Original author CERL, probably Dave Gerdes
+   \author Update to GRASS 5.7 Radim Blazek
  */
  */
 
 
 #include <grass/config.h>
 #include <grass/config.h>
@@ -154,7 +155,7 @@ size_t dig_fread(void *ptr, size_t size, size_t nmemb, GVFILE *file)
 
 
   \return number of items written
   \return number of items written
  */
  */
-size_t dig_fwrite(void *ptr, size_t size, size_t nmemb, GVFILE *file)
+size_t dig_fwrite(const void *ptr, size_t size, size_t nmemb, GVFILE *file)
 {
 {
     if (file->loaded) {	/* using memory */
     if (file->loaded) {	/* using memory */
 	G_fatal_error(_("Writing to file loaded to memory not supported"));
 	G_fatal_error(_("Writing to file loaded to memory not supported"));

+ 307 - 95
lib/vector/diglib/portable.c

@@ -1,32 +1,32 @@
-/*
- ****************************************************************************
- *
- * MODULE:       Vector library 
- *              
- * AUTHOR(S):    Original author CERL, probably Dave Gerdes.
- *               Update to GRASS 5.7 Radim Blazek.
- *
- * PURPOSE:      Lower level functions for reading/writing/manipulating vectors.
- *
- * COPYRIGHT:    (C) 2001 by the GRASS Development Team
- *
- *               This program is free software under the GNU General Public
- *              License (>=v2). Read the file COPYING that comes with GRASS
- *              for details.
- *
- *****************************************************************************/
+/*!
+   \file diglib/file.c
+
+   \brief Vector library (diglib) - portability
+
+   Lower level functions for reading/writing/manipulating vectors.
+   
+   (C) 2001-2009 by the GRASS Development Team
+
+   This program is free software under the GNU General Public License
+   (>=v2).  Read the file COPYING that comes with GRASS for details.
+
+   \author Original author CERL, probably Dave Gerdes
+   \author Update to GRASS 5.7 Radim Blazek
+*/
+
 #include <grass/config.h>
 #include <grass/config.h>
 #include <sys/types.h>
 #include <sys/types.h>
 #include <string.h>
 #include <string.h>
 #include <grass/gis.h>
 #include <grass/gis.h>
 #include <grass/Vect.h>
 #include <grass/Vect.h>
+#include <grass/glocale.h>
 
 
 extern void port_init(void);
 extern void port_init(void);
 
 
 extern int nat_dbl;
 extern int nat_dbl;
 extern int nat_flt;
 extern int nat_flt;
 extern int nat_lng;
 extern int nat_lng;
-extern int nat_off_t;
+extern size_t nat_off_t;
 extern int nat_int;
 extern int nat_int;
 extern int nat_shrt;
 extern int nat_shrt;
 
 
@@ -65,33 +65,35 @@ static int buf_alloc(int needed)
     return (0);
     return (0);
 }
 }
 
 
-/***************************** READ ************************************/
-/*  These are the routines to read from the Portable Vector Format.
+/*!
+  \brief Read doubles from the Portable Vector Format
+
    These routines must handle any type size conversions between the
    These routines must handle any type size conversions between the
    portable format and the native machine.
    portable format and the native machine.
 
 
-   Return:  0 error
-   1 OK
+   \param[out] buf data buffer
+   \param cnt number of members
+   \param fp pointer to GVFILE
 
 
- */
-
-
-/* read doubles from the PVF file */
-int dig__fread_port_D(double *buf, int cnt, GVFILE * fp)
+   \return 0 error
+   \return 1 OK
+*/
+int dig__fread_port_D(double *buf, size_t cnt, GVFILE * fp)
 {
 {
-    int i, j, ret;
+    unsigned int i, j;
+    int ret;
     unsigned char *c1, *c2;
     unsigned char *c1, *c2;
 
 
     if (Cur_Head->dbl_quick) {
     if (Cur_Head->dbl_quick) {
 	ret = dig_fread(buf, PORT_DOUBLE, cnt, fp);
 	ret = dig_fread(buf, PORT_DOUBLE, cnt, fp);
-	if (ret != cnt)
+	if (ret != (int) cnt)
 	    return 0;
 	    return 0;
     }
     }
     else {
     else {
 	/* read into buffer */
 	/* read into buffer */
 	buf_alloc(cnt * PORT_DOUBLE);
 	buf_alloc(cnt * PORT_DOUBLE);
 	ret = dig_fread(buffer, PORT_DOUBLE, cnt, fp);
 	ret = dig_fread(buffer, PORT_DOUBLE, cnt, fp);
-	if (ret != cnt)
+	if (ret != (int) cnt)
 	    return 0;
 	    return 0;
 	/* read from buffer in changed order */
 	/* read from buffer in changed order */
 	c1 = (unsigned char *)buffer;
 	c1 = (unsigned char *)buffer;
@@ -107,22 +109,35 @@ int dig__fread_port_D(double *buf, int cnt, GVFILE * fp)
     return 1;
     return 1;
 }
 }
 
 
-/* read floats from the PVF file */
-int dig__fread_port_F(float *buf, int cnt, GVFILE * fp)
+/*!
+  \brief Read floats from the Portable Vector Format
+
+   These routines must handle any type size conversions between the
+   portable format and the native machine.
+
+   \param[out] buf data buffer
+   \param cnt number of members
+   \param fp pointer to GVFILE
+
+   \return 0 error
+   \return 1 OK
+*/
+int dig__fread_port_F(float *buf, size_t cnt, GVFILE * fp)
 {
 {
-    int i, j, ret;
+    unsigned int i, j;
+    int ret;
     unsigned char *c1, *c2;
     unsigned char *c1, *c2;
 
 
     if (Cur_Head->flt_quick) {
     if (Cur_Head->flt_quick) {
 	ret = dig_fread(buf, PORT_FLOAT, cnt, fp);
 	ret = dig_fread(buf, PORT_FLOAT, cnt, fp);
-	if (ret != cnt)
+	if (ret != (int) cnt)
 	    return 0;
 	    return 0;
     }
     }
     else {
     else {
 	/* read into buffer */
 	/* read into buffer */
 	buf_alloc(cnt * PORT_FLOAT);
 	buf_alloc(cnt * PORT_FLOAT);
 	ret = dig_fread(buffer, PORT_FLOAT, cnt, fp);
 	ret = dig_fread(buffer, PORT_FLOAT, cnt, fp);
-	if (ret != cnt)
+	if (ret != (int) cnt)
 	    return 0;
 	    return 0;
 	/* read from buffer in changed order */
 	/* read from buffer in changed order */
 	c1 = (unsigned char *)buffer;
 	c1 = (unsigned char *)buffer;
@@ -138,23 +153,36 @@ int dig__fread_port_F(float *buf, int cnt, GVFILE * fp)
     return 1;
     return 1;
 }
 }
 
 
-/* read off_ts from the PVF file */
-int dig__fread_port_O(off_t *buf, int cnt, GVFILE * fp, int port_off_t_size)
+/*!
+  \brief Read off_ts from the Portable Vector Format
+
+   These routines must handle any type size conversions between the
+   portable format and the native machine.
+
+   \param[out] buf data buffer
+   \param cnt number of members
+   \param fp pointer to GVFILE
+   \param port_off_t_size offset
+   \return 0 error
+   \return 1 OK
+*/
+int dig__fread_port_O(off_t *buf, size_t cnt, GVFILE * fp, size_t port_off_t_size)
 {
 {
-    int i, j, ret;
+    unsigned int i, j;
+    int ret;
     unsigned char *c1, *c2;
     unsigned char *c1, *c2;
 
 
     if (Cur_Head->off_t_quick) {
     if (Cur_Head->off_t_quick) {
 	if (nat_off_t == port_off_t_size) {
 	if (nat_off_t == port_off_t_size) {
 	    ret = dig_fread(buf, port_off_t_size, cnt, fp);
 	    ret = dig_fread(buf, port_off_t_size, cnt, fp);
-	    if (ret != cnt)
+	    if (ret != (int) cnt)
 		return 0;
 		return 0;
 	}
 	}
 	else if (nat_off_t > port_off_t_size) {
 	else if (nat_off_t > port_off_t_size) {
 	    /* read into buffer */
 	    /* read into buffer */
 	    buf_alloc(cnt * port_off_t_size);
 	    buf_alloc(cnt * port_off_t_size);
 	    ret = dig_fread(buffer, port_off_t_size, cnt, fp);
 	    ret = dig_fread(buffer, port_off_t_size, cnt, fp);
-	    if (ret != cnt)
+	    if (ret != (int) cnt)
 		return 0;
 		return 0;
 	    /* set buffer to zero (positive numbers) */
 	    /* set buffer to zero (positive numbers) */
 	    memset(buf, 0, cnt * sizeof(off_t));
 	    memset(buf, 0, cnt * sizeof(off_t));
@@ -181,7 +209,7 @@ int dig__fread_port_O(off_t *buf, int cnt, GVFILE * fp, int port_off_t_size)
 	}
 	}
 	else if (nat_off_t < port_off_t_size) {
 	else if (nat_off_t < port_off_t_size) {
 	    /* should never happen */
 	    /* should never happen */
-	    G_fatal_error("Vector exceeds supported file size limit");
+	    G_fatal_error(_("Vector exceeds supported file size limit"));
 	}
 	}
     }
     }
     else {
     else {
@@ -189,7 +217,7 @@ int dig__fread_port_O(off_t *buf, int cnt, GVFILE * fp, int port_off_t_size)
 	    /* read into buffer */
 	    /* read into buffer */
 	    buf_alloc(cnt * port_off_t_size);
 	    buf_alloc(cnt * port_off_t_size);
 	    ret = dig_fread(buffer, port_off_t_size, cnt, fp);
 	    ret = dig_fread(buffer, port_off_t_size, cnt, fp);
-	    if (ret != cnt)
+	    if (ret != (int) cnt)
 		return 0;
 		return 0;
 	    /* set buffer to zero (positive numbers) */
 	    /* set buffer to zero (positive numbers) */
 	    memset(buf, 0, cnt * sizeof(off_t));
 	    memset(buf, 0, cnt * sizeof(off_t));
@@ -214,29 +242,42 @@ int dig__fread_port_O(off_t *buf, int cnt, GVFILE * fp, int port_off_t_size)
 	}
 	}
 	else if (nat_off_t < port_off_t_size) {
 	else if (nat_off_t < port_off_t_size) {
 	    /* should never happen */
 	    /* should never happen */
-	    G_fatal_error("Vector exceeds supported file size limit");
+	    G_fatal_error(_("Vector exceeds supported file size limit"));
 	}
 	}
     }
     }
     return 1;
     return 1;
 }
 }
 
 
-/* read longs from the PVF file */
-int dig__fread_port_L(long *buf, int cnt, GVFILE * fp)
+/*!
+  \brief Read longs from the Portable Vector Format
+
+   These routines must handle any type size conversions between the
+   portable format and the native machine.
+
+   \param[out] buf data buffer
+   \param cnt number of members
+   \param fp pointer to GVFILE
+
+   \return 0 error
+   \return 1 OK
+*/
+int dig__fread_port_L(long *buf, size_t cnt, GVFILE * fp)
 {
 {
-    int i, j, ret;
+    unsigned int i, j;
+    int ret;
     unsigned char *c1, *c2;
     unsigned char *c1, *c2;
 
 
     if (Cur_Head->lng_quick) {
     if (Cur_Head->lng_quick) {
 	if (nat_lng == PORT_LONG) {
 	if (nat_lng == PORT_LONG) {
 	    ret = dig_fread(buf, PORT_LONG, cnt, fp);
 	    ret = dig_fread(buf, PORT_LONG, cnt, fp);
-	    if (ret != cnt)
+	    if (ret != (int) cnt)
 		return 0;
 		return 0;
 	}
 	}
 	else {
 	else {
 	    /* read into buffer */
 	    /* read into buffer */
 	    buf_alloc(cnt * PORT_LONG);
 	    buf_alloc(cnt * PORT_LONG);
 	    ret = dig_fread(buffer, PORT_LONG, cnt, fp);
 	    ret = dig_fread(buffer, PORT_LONG, cnt, fp);
-	    if (ret != cnt)
+	    if (ret != (int) cnt)
 		return 0;
 		return 0;
 	    /* set buffer to zero (positive numbers) */
 	    /* set buffer to zero (positive numbers) */
 	    memset(buf, 0, cnt * sizeof(long));
 	    memset(buf, 0, cnt * sizeof(long));
@@ -266,7 +307,7 @@ int dig__fread_port_L(long *buf, int cnt, GVFILE * fp)
 	/* read into buffer */
 	/* read into buffer */
 	buf_alloc(cnt * PORT_LONG);
 	buf_alloc(cnt * PORT_LONG);
 	ret = dig_fread(buffer, PORT_LONG, cnt, fp);
 	ret = dig_fread(buffer, PORT_LONG, cnt, fp);
-	if (ret != cnt)
+	if (ret != (int) cnt)
 	    return 0;
 	    return 0;
 	/* set buffer to zero (positive numbers) */
 	/* set buffer to zero (positive numbers) */
 	memset(buf, 0, cnt * sizeof(long));
 	memset(buf, 0, cnt * sizeof(long));
@@ -292,23 +333,36 @@ int dig__fread_port_L(long *buf, int cnt, GVFILE * fp)
     return 1;
     return 1;
 }
 }
 
 
-/* read ints from the PVF file */
-int dig__fread_port_I(int *buf, int cnt, GVFILE * fp)
+/*!
+  \brief Read integers from the Portable Vector Format
+
+   These routines must handle any type size conversions between the
+   portable format and the native machine.
+
+   \param[out] buf data buffer
+   \param cnt number of members
+   \param fp pointer to GVFILE
+
+   \return 0 error
+   \return 1 OK
+*/
+int dig__fread_port_I(int *buf, size_t cnt, GVFILE * fp)
 {
 {
-    int i, j, ret;
+    unsigned int i, j;
+    int ret;
     unsigned char *c1, *c2;
     unsigned char *c1, *c2;
 
 
     if (Cur_Head->int_quick) {
     if (Cur_Head->int_quick) {
 	if (nat_int == PORT_INT) {
 	if (nat_int == PORT_INT) {
 	    ret = dig_fread(buf, PORT_INT, cnt, fp);
 	    ret = dig_fread(buf, PORT_INT, cnt, fp);
-	    if (ret != cnt)
+	    if (ret != (int) cnt)
 		return 0;
 		return 0;
 	}
 	}
 	else {
 	else {
 	    /* read into buffer */
 	    /* read into buffer */
 	    buf_alloc(cnt * PORT_INT);
 	    buf_alloc(cnt * PORT_INT);
 	    ret = dig_fread(buffer, PORT_INT, cnt, fp);
 	    ret = dig_fread(buffer, PORT_INT, cnt, fp);
-	    if (ret != cnt)
+	    if (ret != (int) cnt)
 		return 0;
 		return 0;
 	    /* set buffer to zero (positive numbers) */
 	    /* set buffer to zero (positive numbers) */
 	    memset(buf, 0, cnt * sizeof(int));
 	    memset(buf, 0, cnt * sizeof(int));
@@ -338,7 +392,7 @@ int dig__fread_port_I(int *buf, int cnt, GVFILE * fp)
 	/* read into buffer */
 	/* read into buffer */
 	buf_alloc(cnt * PORT_INT);
 	buf_alloc(cnt * PORT_INT);
 	ret = dig_fread(buffer, PORT_INT, cnt, fp);
 	ret = dig_fread(buffer, PORT_INT, cnt, fp);
-	if (ret != cnt)
+	if (ret != (int) cnt)
 	    return 0;
 	    return 0;
 	/* set buffer to zero (positive numbers) */
 	/* set buffer to zero (positive numbers) */
 	memset(buf, 0, cnt * sizeof(int));
 	memset(buf, 0, cnt * sizeof(int));
@@ -364,23 +418,36 @@ int dig__fread_port_I(int *buf, int cnt, GVFILE * fp)
     return 1;
     return 1;
 }
 }
 
 
-/* read shorts from the PVF file */
-int dig__fread_port_S(short *buf, int cnt, GVFILE * fp)
+/*!
+  \brief Read shorts from the Portable Vector Format
+
+   These routines must handle any type size conversions between the
+   portable format and the native machine.
+
+   \param[out] buf data buffer
+   \param cnt number of members
+   \param fp pointer to GVFILE
+
+   \return 0 error
+   \return 1 OK
+*/
+int dig__fread_port_S(short *buf, size_t cnt, GVFILE * fp)
 {
 {
-    int i, j, ret;
+    unsigned int i, j;
+    int ret;
     unsigned char *c1, *c2;
     unsigned char *c1, *c2;
 
 
     if (Cur_Head->shrt_quick) {
     if (Cur_Head->shrt_quick) {
 	if (nat_shrt == PORT_SHORT) {
 	if (nat_shrt == PORT_SHORT) {
 	    ret = dig_fread(buf, PORT_SHORT, cnt, fp);
 	    ret = dig_fread(buf, PORT_SHORT, cnt, fp);
-	    if (ret != cnt)
+	    if (ret != (int) cnt)
 		return 0;
 		return 0;
 	}
 	}
 	else {
 	else {
 	    /* read into buffer */
 	    /* read into buffer */
 	    buf_alloc(cnt * PORT_SHORT);
 	    buf_alloc(cnt * PORT_SHORT);
 	    if (0 >= (ret = dig_fread(buffer, PORT_SHORT, cnt, fp)))
 	    if (0 >= (ret = dig_fread(buffer, PORT_SHORT, cnt, fp)))
-		if (ret != cnt)
+		if (ret != (int) cnt)
 		    return 0;
 		    return 0;
 	    /* set buffer to zero (positive numbers) */
 	    /* set buffer to zero (positive numbers) */
 	    memset(buf, 0, cnt * sizeof(short));
 	    memset(buf, 0, cnt * sizeof(short));
@@ -410,7 +477,7 @@ int dig__fread_port_S(short *buf, int cnt, GVFILE * fp)
 	/* read into buffer */
 	/* read into buffer */
 	buf_alloc(cnt * PORT_SHORT);
 	buf_alloc(cnt * PORT_SHORT);
 	ret = dig_fread(buffer, PORT_SHORT, cnt, fp);
 	ret = dig_fread(buffer, PORT_SHORT, cnt, fp);
-	if (ret != cnt)
+	if (ret != (int) cnt)
 	    return 0;
 	    return 0;
 	/* set buffer to zero (positive numbers) */
 	/* set buffer to zero (positive numbers) */
 	memset(buf, 0, cnt * sizeof(short));
 	memset(buf, 0, cnt * sizeof(short));
@@ -436,20 +503,46 @@ int dig__fread_port_S(short *buf, int cnt, GVFILE * fp)
     return 1;
     return 1;
 }
 }
 
 
-/* read chars from the PVF file */
-int dig__fread_port_C(char *buf, int cnt, GVFILE * fp)
+/*!
+  \brief Read chars from the Portable Vector Format
+
+   These routines must handle any type size conversions between the
+   portable format and the native machine.
+
+   \param[out] buf data buffer
+   \param cnt number of members
+   \param fp pointer to GVFILE
+
+   \return 0 error
+   \return 1 OK
+*/
+int dig__fread_port_C(char *buf, size_t cnt, GVFILE * fp)
 {
 {
     int ret;
     int ret;
 
 
     ret = dig_fread(buf, PORT_CHAR, cnt, fp);
     ret = dig_fread(buf, PORT_CHAR, cnt, fp);
-    if (ret != cnt)
+    if (ret != (int) cnt)
 	return 0;
 	return 0;
     return 1;
     return 1;
 }
 }
 
 
-/* read plus_t from the PVF file */
-/* plus_t is defined as int so we only retype pointer and use int function */
-int dig__fread_port_P(plus_t * buf, int cnt, GVFILE * fp)
+/*!
+  \brief Read plus_t from the Portable Vector Format
+
+   These routines must handle any type size conversions between the
+   portable format and the native machine.
+   
+   plus_t is defined as int so we only retype pointer and use int
+   function.
+
+   \param[out] buf data buffer
+   \param cnt number of members
+   \param fp pointer to GVFILE
+
+   \return 0 error
+   \return 1 OK
+*/
+int dig__fread_port_P(plus_t * buf, size_t cnt, GVFILE * fp)
 {
 {
     int *ibuf;
     int *ibuf;
 
 
@@ -458,12 +551,23 @@ int dig__fread_port_P(plus_t * buf, int cnt, GVFILE * fp)
     return (dig__fread_port_I(ibuf, cnt, fp));
     return (dig__fread_port_I(ibuf, cnt, fp));
 }
 }
 
 
-/***************************** WRITE ************************************/
+/*!
+  \brief Write doubles to the Portable Vector Format
+
+   These routines must handle any type size conversions between the
+   portable format and the native machine.
+
+   \param buf data buffer
+   \param cnt number of members
+   \param[in,out] fp pointer to GVFILE
 
 
-int dig__fwrite_port_D(const double *buf,	/* DOUBLE */
-		       int cnt, GVFILE * fp)
+   \return 0 error
+   \return 1 OK
+*/
+int dig__fwrite_port_D(const double *buf,
+		       size_t cnt, GVFILE * fp)
 {
 {
-    int i, j;
+    unsigned int i, j;
     unsigned char *c1, *c2;
     unsigned char *c1, *c2;
 
 
     if (Cur_Head->dbl_quick) {
     if (Cur_Head->dbl_quick) {
@@ -486,10 +590,23 @@ int dig__fwrite_port_D(const double *buf,	/* DOUBLE */
     return 0;
     return 0;
 }
 }
 
 
-int dig__fwrite_port_F(const float *buf,	/* FLOAT */
-		       int cnt, GVFILE * fp)
+/*!
+  \brief Write floats to the Portable Vector Format
+
+   These routines must handle any type size conversions between the
+   portable format and the native machine.
+
+   \param buf data buffer
+   \param cnt number of members
+   \param[in,out] fp pointer to GVFILE
+
+   \return 0 error
+   \return 1 OK
+*/
+int dig__fwrite_port_F(const float *buf,
+		       size_t cnt, GVFILE * fp)
 {
 {
-    int i, j;
+    unsigned int i, j;
     unsigned char *c1, *c2;
     unsigned char *c1, *c2;
 
 
     if (Cur_Head->flt_quick) {
     if (Cur_Head->flt_quick) {
@@ -512,10 +629,23 @@ int dig__fwrite_port_F(const float *buf,	/* FLOAT */
     return 0;
     return 0;
 }
 }
 
 
-int dig__fwrite_port_O(const off_t *buf,	/* OFF_T */
-		       int cnt, GVFILE * fp, int port_off_t_size)
+/*!
+  \brief Write off_ts to the Portable Vector Format
+
+   These routines must handle any type size conversions between the
+   portable format and the native machine.
+
+   \param buf data buffer
+   \param cnt number of members
+   \param[in,out] fp pointer to GVFILE
+
+   \return 0 error
+   \return 1 OK
+*/
+int dig__fwrite_port_O(const off_t *buf,
+		       size_t cnt, GVFILE * fp, size_t port_off_t_size)
 {
 {
-    int i, j;
+    unsigned int i, j;
     unsigned char *c1, *c2;
     unsigned char *c1, *c2;
 
 
     if (Cur_Head->off_t_quick) {
     if (Cur_Head->off_t_quick) {
@@ -559,16 +689,29 @@ int dig__fwrite_port_O(const off_t *buf,	/* OFF_T */
 	}
 	}
 	else if (nat_off_t < port_off_t_size) {
 	else if (nat_off_t < port_off_t_size) {
 	    /* should never happen */
 	    /* should never happen */
-	    G_fatal_error("Vector exceeds supported file size limit");
+	    G_fatal_error(_("Vector exceeds supported file size limit"));
 	}
 	}
     }
     }
     return 0;
     return 0;
 }
 }
 
 
-int dig__fwrite_port_L(const long *buf,	/* LONG */
-		       int cnt, GVFILE * fp)
+/*!
+  \brief Write longs to the Portable Vector Format
+
+   These routines must handle any type size conversions between the
+   portable format and the native machine.
+
+   \param buf data buffer
+   \param cnt number of members
+   \param[in,out] fp pointer to GVFILE
+
+   \return 0 error
+   \return 1 OK
+*/
+int dig__fwrite_port_L(const long *buf,
+		       size_t cnt, GVFILE * fp)
 {
 {
-    int i, j;
+    unsigned int i, j;
     unsigned char *c1, *c2;
     unsigned char *c1, *c2;
 
 
     if (Cur_Head->lng_quick) {
     if (Cur_Head->lng_quick) {
@@ -608,10 +751,23 @@ int dig__fwrite_port_L(const long *buf,	/* LONG */
     return 0;
     return 0;
 }
 }
 
 
-int dig__fwrite_port_I(const int *buf,	/* INT */
-		       int cnt, GVFILE * fp)
+/*!
+  \brief Write integers to the Portable Vector Format
+
+   These routines must handle any type size conversions between the
+   portable format and the native machine.
+
+   \param buf data buffer
+   \param cnt number of members
+   \param[in,out] fp pointer to GVFILE
+
+   \return 0 error
+   \return 1 OK
+*/
+int dig__fwrite_port_I(const int *buf,
+		       size_t cnt, GVFILE * fp)
 {
 {
-    int i, j;
+    unsigned int i, j;
     unsigned char *c1, *c2;
     unsigned char *c1, *c2;
 
 
     if (Cur_Head->int_quick) {
     if (Cur_Head->int_quick) {
@@ -651,10 +807,23 @@ int dig__fwrite_port_I(const int *buf,	/* INT */
     return 0;
     return 0;
 }
 }
 
 
-int dig__fwrite_port_S(const short *buf,	/* SHORT */
-		       int cnt, GVFILE * fp)
+/*!
+  \brief Write shorts to the Portable Vector Format
+
+   These routines must handle any type size conversions between the
+   portable format and the native machine.
+
+   \param buf data buffer
+   \param cnt number of members
+   \param[in,out] fp pointer to GVFILE
+
+   \return 0 error
+   \return 1 OK
+*/
+int dig__fwrite_port_S(const short *buf,
+		       size_t cnt, GVFILE * fp)
 {
 {
-    int i, j;
+    unsigned int i, j;
     unsigned char *c1, *c2;
     unsigned char *c1, *c2;
 
 
     if (Cur_Head->shrt_quick) {
     if (Cur_Head->shrt_quick) {
@@ -694,15 +863,41 @@ int dig__fwrite_port_S(const short *buf,	/* SHORT */
     return 0;
     return 0;
 }
 }
 
 
-/* plus_t is defined as int so we only retype pointer and use int function */
-int dig__fwrite_port_P(const plus_t * buf,	/* PLUS_T->INT */
-		       int cnt, GVFILE * fp)
+
+/*!
+  \brief Write plus_t to the Portable Vector Format
+
+   These routines must handle any type size conversions between the
+   portable format and the native machine.
+
+   \param buf data buffer
+   \param cnt number of members
+   \param[in,out] fp pointer to GVFILE
+
+   \return 0 error
+   \return 1 OK
+*/
+int dig__fwrite_port_P(const plus_t * buf,
+		       size_t cnt, GVFILE * fp)
 {
 {
     return (dig__fwrite_port_I((int *)buf, cnt, fp));
     return (dig__fwrite_port_I((int *)buf, cnt, fp));
 }
 }
 
 
-int dig__fwrite_port_C(const char *buf,	/* CHAR */
-		       int cnt, GVFILE * fp)
+/*!
+  \brief Write chars to the Portable Vector Format
+
+   These routines must handle any type size conversions between the
+   portable format and the native machine.
+
+   \param buf data buffer
+   \param cnt number of members
+   \param[in,out] fp pointer to GVFILE
+
+   \return 0 error
+   \return 1 OK
+*/
+int dig__fwrite_port_C(const char *buf,
+		       size_t cnt, GVFILE * fp)
 {
 {
     if (dig_fwrite(buf, PORT_CHAR, cnt, fp) == cnt)
     if (dig_fwrite(buf, PORT_CHAR, cnt, fp) == cnt)
 	return 1;
 	return 1;
@@ -710,10 +905,15 @@ int dig__fwrite_port_C(const char *buf,	/* CHAR */
     return 0;
     return 0;
 }
 }
 
 
-/* set portable info structure to byte order of file */
+/*!
+  \brief Set portable info structure to byte order of file
+
+  \param port pointer to Port_info
+  \param byte_order ENDIAN_BIG or ENDIAN_LITTLE
+*/
 void dig_init_portable(struct Port_info *port, int byte_order)
 void dig_init_portable(struct Port_info *port, int byte_order)
 {
 {
-    int i;
+    unsigned int i;
 
 
     port_init();
     port_init();
 
 
@@ -800,13 +1000,25 @@ void dig_init_portable(struct Port_info *port, int byte_order)
     return;
     return;
 }
 }
 
 
-/* set current portable info */
+/*!
+  \brief set current portable info
+
+  \param port pointer to Port_info
+
+  \return 0
+*/
 int dig_set_cur_port(struct Port_info *port)
 int dig_set_cur_port(struct Port_info *port)
 {
 {
     Cur_Head = port;
     Cur_Head = port;
     return 0;
     return 0;
 }
 }
 
 
+/*!
+  \brief Get byte order
+
+  \return ENDIAN_LITTLE
+  \return ENDIAN_BIG
+*/
 int dig__byte_order_out()
 int dig__byte_order_out()
 {
 {
     if (dbl_order == ENDIAN_LITTLE)
     if (dbl_order == ENDIAN_LITTLE)