GRASS 8 Programmer's Manual 8.6.0dev(2026)-4bb960b182
Loading...
Searching...
No Matches
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 SPDX-FileCopyrightText: 2001-2009 GRASS Development Team
7 SPDX-License-Identifier: GPL-2.0-or-later
8
9 \author Original author CERL
10 */
11
12#include <stdio.h>
13#include <string.h>
14#include <grass/rowio.h>
15
16/*!
17 * \brief Write a row
18 *
19 * Writes the buffer <i>buf</i>, which holds the data for row
20 * <i>n</i>, into the ROWIO structure <i>r</i>. If the row requested
21 * is currently in memory, the buffer is simply copied into the
22 * structure and marked as having been changed. It will be written out
23 * later. Otherwise it is written immediately. Note that when the row
24 * is finally written to disk, the putrow() routine specified in
25 * Rowio_setup() is called to write row <i>n</i> to the
26 * file. Rowio_flush() force pending updates to disk ROWIO *r;
27 * Rowio_flush() forces all rows modified by Rowio_put() to be
28 * written to the file. This routine must be called before closing the
29 * file or releasing the rowio structure if Rowio_put() has been
30 * called.
31 *
32 * \param R pointer to ROWIO structure
33 * \param buf pointer to data buffer
34 * \param row row number
35 *
36 * \return
37 */
38int Rowio_put(ROWIO *R, const void *buf, int row)
39{
40 int i;
41
42 if (row < 0)
43 return 0;
44
45 for (i = 0; i < R->nrows; i++)
46 if (row == R->rcb[i].row) {
47 memcpy(R->rcb[i].buf, buf, R->len);
48 R->rcb[i].dirty = 1;
49 return 1;
50 }
51 return ((*R->putrow)(R->fd, buf, row, R->len));
52}
int Rowio_put(ROWIO *R, const void *buf, int row)
Write a row.
Definition rowio/put.c:38
Definition rowio.h:4
int len
Definition rowio.h:7
struct ROWIO::ROWIO_RCB * rcb
int fd
Definition rowio.h:5
int(* putrow)(int, const void *, int, int)
Definition rowio.h:11
int nrows
Definition rowio.h:6