File: put.c

package info (click to toggle)
grass 6.0.2-6
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 40,044 kB
  • ctags: 31,303
  • sloc: ansic: 321,125; tcl: 25,676; sh: 11,176; cpp: 10,098; makefile: 5,025; fortran: 1,846; yacc: 493; lex: 462; perl: 133; sed: 1
file content (45 lines) | stat: -rw-r--r-- 1,259 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <stdio.h>
#include "rowio.h"


/*!
 * \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.
 *
 *  \param r
 *  \param buf
 *  \param n
 *  \return int
 */

int rowio_put ( ROWIO *R, char *buf,int row)
{
    int i;
    int col;
    char *b;

    if (row < 0)
	return 0;

    for (i = 0; i < R->nrows; i++)
	if (row == R->rcb[i].row)
	{
	    b = R->rcb[i].buf;
	    for (col = 0; col < R->len; col++)
		*b++ = *buf++;
	    R->rcb[i].dirty = 1;
	    return 1;
	}
    return ((*R->putrow) (R->fd, buf, row, R->len));
}