[GRASS-SVN] r38358 - in grass/trunk: include lib/rowio
raster/r.mfilter raster/r.thin
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Jul 10 17:05:14 EDT 2009
Author: martinl
Date: 2009-07-10 17:05:13 -0400 (Fri, 10 Jul 2009)
New Revision: 38358
Modified:
grass/trunk/include/rowio.h
grass/trunk/lib/rowio/fileno.c
grass/trunk/lib/rowio/forget.c
grass/trunk/lib/rowio/get.c
grass/trunk/lib/rowio/put.c
grass/trunk/lib/rowio/release.c
grass/trunk/lib/rowio/setup.c
grass/trunk/raster/r.mfilter/execute.c
grass/trunk/raster/r.mfilter/perform.c
grass/trunk/raster/r.thin/io.c
Log:
rowiolib: fns rename to follow naming convetions (rowio_ -> Rowio_)
some doxygen documentation
Modified: grass/trunk/include/rowio.h
===================================================================
--- grass/trunk/include/rowio.h 2009-07-10 19:13:22 UTC (rev 38357)
+++ grass/trunk/include/rowio.h 2009-07-10 21:05:13 UTC (rev 38358)
@@ -20,13 +20,13 @@
} *rcb;
} ROWIO;
-int rowio_fileno(const ROWIO *);
-void rowio_forget(ROWIO *, int);
-void *rowio_get(ROWIO *, int);
-void rowio_flush(ROWIO *);
-int rowio_put(ROWIO *, const void *, int);
-void rowio_release(ROWIO *);
-int rowio_setup(ROWIO *, int, int, int, int (*)(int, void *, int, int),
+int Rowio_fileno(const ROWIO *);
+void Rowio_forget(ROWIO *, int);
+void *Rowio_get(ROWIO *, int);
+void Rowio_flush(ROWIO *);
+int Rowio_put(ROWIO *, const void *, int);
+void Rowio_release(ROWIO *);
+int Rowio_setup(ROWIO *, int, int, int, int (*)(int, void *, int, int),
int (*)(int, const void *, int, int));
#endif
Modified: grass/trunk/lib/rowio/fileno.c
===================================================================
--- grass/trunk/lib/rowio/fileno.c 2009-07-10 19:13:22 UTC (rev 38357)
+++ grass/trunk/lib/rowio/fileno.c 2009-07-10 21:05:13 UTC (rev 38358)
@@ -1,16 +1,28 @@
+/*!
+ \file rowio/fileno.c
+
+ \brief RowIO library - file descriptor
+
+ (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
+*/
+
#include <grass/rowio.h>
/*!
- * \brief get file descriptor
+ * \brief Get file descriptor
*
- * Rowio_fileno()
- * returns the file descriptor associated with the ROWIO structure.
+ * Returns the file descriptor associated with the ROWIO structure.
*
- * \param r
- * \return int
+ * \param r pointer to ROWIO structure
+ *
+ * \return file descriptor
*/
-
-int rowio_fileno(const ROWIO * R)
+int Rowio_fileno(const ROWIO * R)
{
return R->fd;
}
Modified: grass/trunk/lib/rowio/forget.c
===================================================================
--- grass/trunk/lib/rowio/forget.c 2009-07-10 19:13:22 UTC (rev 38357)
+++ grass/trunk/lib/rowio/forget.c 2009-07-10 21:05:13 UTC (rev 38358)
@@ -1,6 +1,25 @@
+/*!
+ \file rowio/forget.c
+
+ \brief RowIO library - Release a row
+
+ (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
+*/
+
#include <grass/rowio.h>
-void rowio_forget(ROWIO * R, int row)
+/*!
+ \brief Release row from memory
+
+ \param R pointer to ROWIO structure
+ \param row row number
+*/
+void Rowio_forget(ROWIO * R, int row)
{
int i;
Modified: grass/trunk/lib/rowio/get.c
===================================================================
--- grass/trunk/lib/rowio/get.c 2009-07-10 19:13:22 UTC (rev 38357)
+++ grass/trunk/lib/rowio/get.c 2009-07-10 21:05:13 UTC (rev 38358)
@@ -1,3 +1,16 @@
+/*!
+ \file rowio/get.c
+
+ \brief RowIO library - Get a row
+
+ (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
+*/
+
#include <stdio.h>
#include <grass/rowio.h>
@@ -6,29 +19,26 @@
/*!
- * \brief read a row
+ * \brief Read a row
*
- * Rowio_get() returns a
- * buffer which holds the data for row <b>n</b> from the file associated with
- * ROWIO structure <b>r.</b> If the row requested is not in memory, the
- * <b>getrow()</b> routine specified in <i>rowio_setup</i> is called to
- * read row <b>n</b> into memory and a pointer to the memory buffer containing
- * the row is returned. If the data currently in the buffer had been changed by
- * <i>rowio_put</i>, the <b>putrow()</b> routine specified in
- * <i>rowio_setup</i> is called first to write the changed row to disk. If row
- * <b>n</b> is already in memory, no disk read is done. The pointer to the data
- * is simply returned.
- * Return codes:
- * NULL <b>n</b> is negative, or
- * <b>getrow()</b> returned 0 (indicating an error condition).
- * !NULL pointer to buffer containing row <b>n.</b>
+ * Rowio_get() returns a buffer which holds the data for row from the
+ * file associated with ROWIO structure <i>R</i>. If the row requested
+ * is not in memory, the getrow() routine specified in
+ * Rowio_setup() is called to read row into memory and a
+ * pointer to the memory buffer containing the row is returned. If the
+ * data currently in the buffer had been changed by Rowio_put(),
+ * the putrow() routine specified in Rowio_setup() is
+ * called first to write the changed row to disk. If row is
+ * already in memory, no disk read is done. The pointer to the data is
+ * simply returned.
*
- * \param r
- * \param n
- * \return char *
+ * \param R pointer to ROWIO structure
+ * \param row row number
+ *
+ * \return NULL on error
+ * \return pointer to the buffer containing row
*/
-
-void *rowio_get(ROWIO * R, int row)
+void *Rowio_get(ROWIO * R, int row)
{
int i;
int age;
@@ -71,7 +81,12 @@
return my_select(R, cur);
}
-void rowio_flush(ROWIO * R)
+/*!
+ \brief Flush data
+
+ \param R pointer to ROWIO strcuture
+*/
+void Rowio_flush(ROWIO * R)
{
int i;
Modified: grass/trunk/lib/rowio/put.c
===================================================================
--- grass/trunk/lib/rowio/put.c 2009-07-10 19:13:22 UTC (rev 38357)
+++ grass/trunk/lib/rowio/put.c 2009-07-10 21:05:13 UTC (rev 38358)
@@ -1,3 +1,16 @@
+/*!
+ \file rowio/put.c
+
+ \brief RowIO library - Write a row
+
+ (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
+*/
+
#include <stdio.h>
#include <string.h>
#include <grass/rowio.h>
@@ -4,27 +17,29 @@
/*!
- * \brief write a row
+ * \brief Write a row
*
- * Rowio_put()
- * writes the buffer <b>buf</b>, which holds the data for row <b>n</b>, into
- * the ROWIO structure <b>r.</b> If the row requested is currently in memory,
- * the buffer is simply copied into the structure and marked as having been
- * changed. It will be written out later. Otherwise it is written immediately.
- * Note that when the row is finally written to disk, the <b>putrow()</b>
- * routine specified in <i>rowio_setup</i> is called to write row <b>n</b>
- * to the file. <b>rowio_flush</b> ( r) force pending updates to disk ROWIO *r;
- * Rowio_flush() forces all rows modified by <i>rowio_put</i> to be written
- * to the file. This routine must be called before closing the file or releasing
- * the rowio structure if rowio_put() has been called.
+ * Writes the buffer <i>buf</i>, which holds the data for row
+ * <i>n</i>, into the ROWIO structure <i>r</i>. If the row requested
+ * is currently in memory, the buffer is simply copied into the
+ * structure and marked as having been changed. It will be written out
+ * later. Otherwise it is written immediately. Note that when the row
+ * is finally written to disk, the putrow() routine specified in
+ * Rowio_setup() is called to write row <i>n</i> to the
+ * file. Rowio_flush() force pending updates to disk ROWIO *r;
+ * Rowio_flush() forces all rows modified by Rowio_put() to be
+ * written to the file. This routine must be called before closing the
+ * file or releasing the rowio structure if Rowio_put() has been
+ * called.
*
- * \param r
- * \param buf
- * \param n
- * \return int
+ * \param R pointer to ROWIO structure
+ * \param buf pointer to data buffer
+ * \param row row number
+ *
+ * \return
*/
-int rowio_put(ROWIO * R, const void *buf, int row)
+int Rowio_put(ROWIO * R, const void *buf, int row)
{
int i;
Modified: grass/trunk/lib/rowio/release.c
===================================================================
--- grass/trunk/lib/rowio/release.c 2009-07-10 19:13:22 UTC (rev 38357)
+++ grass/trunk/lib/rowio/release.c 2009-07-10 21:05:13 UTC (rev 38358)
@@ -2,7 +2,7 @@
#include <stdlib.h>
#include <grass/rowio.h>
-void rowio_release(ROWIO * R)
+void Rowio_release(ROWIO * R)
{
int i;
Modified: grass/trunk/lib/rowio/setup.c
===================================================================
--- grass/trunk/lib/rowio/setup.c 2009-07-10 19:13:22 UTC (rev 38357)
+++ grass/trunk/lib/rowio/setup.c 2009-07-10 21:05:13 UTC (rev 38358)
@@ -1,31 +1,47 @@
+/*!
+ \file rowio/setup.c
+
+ \brief RowIO library - Setup
+
+ (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
+*/
+
#include <stdio.h>
#include <stdlib.h>
+#include <grass/gis.h>
+#include <grass/glocale.h>
#include <grass/rowio.h>
-
/*!
- * \brief configure rowio structure
+ * \brief Configure rowio structure
*
- * Rowio_setup()
- * initializes the ROWIO structure <b>r</b> and allocates the required memory
- * buffers. The file descriptor <b>fd</b> must be open for reading. The number
- * of rows to be held in memory is <b>nrows.</b> The length in bytes of each
- * row is <b>len.</b> The routine which will be called to read data from the
- * file is <b>getrow()</b> and must be provided by the programmer. If the
- * application requires that the rows be written back into the file if changed,
- * the file descriptor <b>fd</b> must be open for write as well, and the
- * programmer must provide a <b>putrow()</b> routine to write the data into
- * the file. If no writing of the file is to occur, specify NULL for
- * <b>putrow().</b>
- * Return codes:
- * 1 ok
- * -1 there is not enough memory for buffer allocation
+ * Rowio_setup() initializes the ROWIO structure <i>r</i> and
+ * allocates the required memory buffers. The file descriptor
+ * <i>fd</i> must be open for reading. The number of rows to be held
+ * in memory is <i>nrows</i>. The length in bytes of each row is
+ * <i>len</i>. The routine which will be called to read data from the
+ * file is getrow() and must be provided by the programmer. If the
+ * application requires that the rows be written back into the file if
+ * changed, the file descriptor <i>fd</i> must be open for write as
+ * well, and the programmer must provide a putrow() routine to write
+ * the data into the file. If no writing of the file is to occur,
+ * specify NULL for putrow().
*
- * \param
- * \return int
+ * \param R pointer to ROWIO structure
+ * \param fd file descriptor
+ * \param nrows number of rows
+ * \param getrow get row function
+ *
+ * \return 1 on success
+ * \return -1 no memory
*/
-int rowio_setup(ROWIO * R,
+int Rowio_setup(ROWIO * R,
int fd, int nrows, int len,
int (*getrow) (int, void *, int, int),
int (*putrow) (int, const void *, int, int))
@@ -40,15 +56,15 @@
R->buf = NULL;
R->fd = fd;
- R->rcb = (struct ROWIO_RCB *)malloc(nrows * sizeof(struct ROWIO_RCB));
+ R->rcb = (struct ROWIO_RCB *) G_malloc(nrows * sizeof(struct ROWIO_RCB));
if (R->rcb == NULL) {
- fprintf(stderr, "rowio_setup: out of memory\n");
+ G_warning(_("Out of memory"));
return -1;
}
for (i = 0; i < nrows; i++) {
- R->rcb[i].buf = malloc(len);
+ R->rcb[i].buf = G_malloc(len);
if (R->rcb[i].buf == NULL) {
- fprintf(stderr, "rowio_setup: out of memory\n");
+ G_warning(_("Out of memory"));
return -1;
}
R->rcb[i].row = -1; /* mark not used */
Modified: grass/trunk/raster/r.mfilter/execute.c
===================================================================
--- grass/trunk/raster/r.mfilter/execute.c 2009-07-10 19:13:22 UTC (rev 38357)
+++ grass/trunk/raster/r.mfilter/execute.c 2009-07-10 21:05:13 UTC (rev 38358)
@@ -61,7 +61,7 @@
/* copy border rows to output */
row = starty;
for (i = 0; i < mid; i++) {
- cp = (DCELL *) rowio_get(r, row);
+ cp = (DCELL *) Rowio_get(r, row);
write(out, cp, buflen);
row += dy;
}
@@ -73,7 +73,7 @@
starty += dy;
/* get "size" rows */
for (i = 0; i < size; i++) {
- bufs[i] = (DCELL *) rowio_get(r, row);
+ bufs[i] = (DCELL *) Rowio_get(r, row);
box[i] = bufs[i] + startx;
row += dy;
}
@@ -112,7 +112,7 @@
/* copy border rows to output */
row = starty + mid * dy;
for (i = 0; i < mid; i++) {
- cp = (DCELL *) rowio_get(r, row);
+ cp = (DCELL *) Rowio_get(r, row);
write(out, cp, buflen);
row += dy;
}
Modified: grass/trunk/raster/r.mfilter/perform.c
===================================================================
--- grass/trunk/raster/r.mfilter/perform.c 2009-07-10 19:13:22 UTC (rev 38357)
+++ grass/trunk/raster/r.mfilter/perform.c 2009-07-10 21:05:13 UTC (rev 38358)
@@ -63,12 +63,12 @@
out = fd;
}
- rowio_setup(&r, in, filter[n].size, buflen,
+ Rowio_setup(&r, in, filter[n].size, buflen,
count ? getrow : getmaprow, NULL);
execute_filter(&r, out, &filter[n], cell);
- rowio_release(&r);
+ Rowio_release(&r);
}
}
Modified: grass/trunk/raster/r.thin/io.c
===================================================================
--- grass/trunk/raster/r.thin/io.c 2009-07-10 19:13:22 UTC (rev 38357)
+++ grass/trunk/raster/r.thin/io.c 2009-07-10 21:05:13 UTC (rev 38358)
@@ -58,13 +58,13 @@
{
if (row < 0 || row >= n_rows)
return (NULL);
- return ((CELL *) rowio_get(&row_io, row));
+ return ((CELL *) Rowio_get(&row_io, row));
}
int put_a_row(int row, CELL * buf)
{
/* rowio.h defines this withe 2nd argument as char * */
- rowio_put(&row_io, (char *)buf, row);
+ Rowio_put(&row_io, (char *)buf, row);
return 0;
}
@@ -147,7 +147,7 @@
n_rows += (PAD << 1);
G_free(buf);
Rast_close(cell_file);
- rowio_setup(&row_io, work_file, MAX_ROW, n_cols * sizeof(CELL), read_row,
+ Rowio_setup(&row_io, work_file, MAX_ROW, n_cols * sizeof(CELL), read_row,
write_row);
return 0;
@@ -179,9 +179,9 @@
Rast_put_row(cell_file, buf + PAD, CELL_TYPE);
}
Rast_close(cell_file);
- rowio_flush(&row_io);
- close(rowio_fileno(&row_io));
- rowio_release(&row_io);
+ Rowio_flush(&row_io);
+ close(Rowio_fileno(&row_io));
+ Rowio_release(&row_io);
unlink(work_file_name);
return 0;
More information about the grass-commit
mailing list