GRASS GIS 7 Programmer's Manual
7.9.dev(2021)-e5379bbd7
rowio/put.c
Go to the documentation of this file.
1
/*!
2
\file rowio/put.c
3
4
\brief RowIO library - Write a row
5
6
(C) 2001-2009 by the GRASS Development Team
7
8
This program is free software under the GNU General Public License
9
(>=v2). Read the file COPYING that comes with GRASS for details.
10
11
\author Original author CERL
12
*/
13
14
#include <stdio.h>
15
#include <string.h>
16
#include <
grass/rowio.h
>
17
18
19
/*!
20
* \brief Write a row
21
*
22
* Writes the buffer <i>buf</i>, which holds the data for row
23
* <i>n</i>, into the ROWIO structure <i>r</i>. If the row requested
24
* is currently in memory, the buffer is simply copied into the
25
* structure and marked as having been changed. It will be written out
26
* later. Otherwise it is written immediately. Note that when the row
27
* is finally written to disk, the putrow() routine specified in
28
* Rowio_setup() is called to write row <i>n</i> to the
29
* file. Rowio_flush() force pending updates to disk ROWIO *r;
30
* Rowio_flush() forces all rows modified by Rowio_put() to be
31
* written to the file. This routine must be called before closing the
32
* file or releasing the rowio structure if Rowio_put() has been
33
* called.
34
*
35
* \param R pointer to ROWIO structure
36
* \param buf pointer to data buffer
37
* \param row row number
38
*
39
* \return
40
*/
41
42
int
Rowio_put
(
ROWIO
* R,
const
void
*buf,
int
row)
43
{
44
int
i;
45
46
if
(row < 0)
47
return
0;
48
49
for
(i = 0; i < R->
nrows
; i++)
50
if
(row == R->
rcb
[i].
row
) {
51
memcpy(R->
rcb
[i].
buf
, buf, R->
len
);
52
R->
rcb
[i].
dirty
= 1;
53
return
1;
54
}
55
return
((*R->
putrow
) (R->
fd
, buf, row, R->
len
));
56
}
ROWIO::ROWIO_RCB::buf
void * buf
Definition:
rowio.h:16
Rowio_put
int Rowio_put(ROWIO *R, const void *buf, int row)
Write a row.
Definition:
rowio/put.c:42
ROWIO::ROWIO_RCB::row
int row
Definition:
rowio.h:18
ROWIO::putrow
int(* putrow)(int, const void *, int, int)
Definition:
rowio.h:12
ROWIO::len
int len
Definition:
rowio.h:8
ROWIO::rcb
struct ROWIO::ROWIO_RCB * rcb
ROWIO
Definition:
rowio.h:4
ROWIO::fd
int fd
Definition:
rowio.h:6
ROWIO::nrows
int nrows
Definition:
rowio.h:7
ROWIO::ROWIO_RCB::dirty
int dirty
Definition:
rowio.h:19
rowio.h
lib
rowio
put.c
Generated on Mon May 31 2021 05:21:31 for GRASS GIS 7 Programmer's Manual by
1.8.13