GRASS GIS 8 Programmer's Manual
8.5.0dev(2024)-bea8435a9e
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
* \brief Write a row
20
*
21
* Writes the buffer <i>buf</i>, which holds the data for row
22
* <i>n</i>, into the ROWIO structure <i>r</i>. If the row requested
23
* is currently in memory, the buffer is simply copied into the
24
* structure and marked as having been changed. It will be written out
25
* later. Otherwise it is written immediately. Note that when the row
26
* is finally written to disk, the putrow() routine specified in
27
* Rowio_setup() is called to write row <i>n</i> to the
28
* file. Rowio_flush() force pending updates to disk ROWIO *r;
29
* Rowio_flush() forces all rows modified by Rowio_put() to be
30
* written to the file. This routine must be called before closing the
31
* file or releasing the rowio structure if Rowio_put() has been
32
* called.
33
*
34
* \param R pointer to ROWIO structure
35
* \param buf pointer to data buffer
36
* \param row row number
37
*
38
* \return
39
*/
40
41
int
Rowio_put
(
ROWIO
*R,
const
void
*buf,
int
row)
42
{
43
int
i;
44
45
if
(row < 0)
46
return
0;
47
48
for
(i = 0; i < R->
nrows
; i++)
49
if
(row == R->
rcb
[i].
row
) {
50
memcpy(R->
rcb
[i].
buf
, buf, R->
len
);
51
R->
rcb
[i].
dirty
= 1;
52
return
1;
53
}
54
return
((*R->
putrow
)(R->
fd
, buf, row, R->
len
));
55
}
Rowio_put
int Rowio_put(ROWIO *R, const void *buf, int row)
Write a row.
Definition:
rowio/put.c:41
rowio.h
ROWIO::ROWIO_RCB::buf
void * buf
Definition:
rowio.h:15
ROWIO::ROWIO_RCB::row
int row
Definition:
rowio.h:17
ROWIO::ROWIO_RCB::dirty
int dirty
Definition:
rowio.h:18
ROWIO
Definition:
rowio.h:4
ROWIO::len
int len
Definition:
rowio.h:7
ROWIO::rcb
struct ROWIO::ROWIO_RCB * rcb
ROWIO::fd
int fd
Definition:
rowio.h:5
ROWIO::putrow
int(* putrow)(int, const void *, int, int)
Definition:
rowio.h:11
ROWIO::nrows
int nrows
Definition:
rowio.h:6
lib
rowio
put.c
Generated on Sun Nov 24 2024 07:03:40 for GRASS GIS 8 Programmer's Manual by
1.9.1