GRASS GIS 8 Programmer's Manual
8.2.2dev(2023)-3d2c704037
|
Go to the source code of this file.
Functions | |
int | Rowio_fileno (const ROWIO *) |
Get file descriptor. More... | |
void | Rowio_forget (ROWIO *, int) |
Release row from memory. More... | |
void * | Rowio_get (ROWIO *, int) |
Read a row. More... | |
void | Rowio_flush (ROWIO *) |
Flush data. More... | |
int | Rowio_put (ROWIO *, const void *, int) |
Write a row. More... | |
void | Rowio_release (ROWIO *) |
int | Rowio_setup (ROWIO *, int, int, int, int(*)(int, void *, int, int), int(*)(int, const void *, int, int)) |
Configure rowio structure. More... | |
int Rowio_fileno | ( | const ROWIO * | R | ) |
void Rowio_flush | ( | ROWIO * | R | ) |
Flush data.
R | pointer to ROWIO strcuture |
Definition at line 89 of file rowio/get.c.
References ROWIO::nrows.
void Rowio_forget | ( | ROWIO * | R, |
int | row | ||
) |
Release row from memory.
R | pointer to ROWIO structure |
row | row number |
Definition at line 22 of file forget.c.
References ROWIO::nrows, ROWIO::rcb, and ROWIO::ROWIO_RCB::row.
void* Rowio_get | ( | ROWIO * | R, |
int | row | ||
) |
Read a row.
Rowio_get() returns a buffer which holds the data for row from the file associated with ROWIO structure R. 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.
R | pointer to ROWIO structure |
row | row number |
Definition at line 41 of file rowio/get.c.
int Rowio_put | ( | ROWIO * | R, |
const void * | buf, | ||
int | row | ||
) |
Write a row.
Writes the buffer buf, which holds the data for row n, into the ROWIO structure r. 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 n 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.
R | pointer to ROWIO structure |
buf | pointer to data buffer |
row | row number |
Definition at line 42 of file rowio/put.c.
References ROWIO::ROWIO_RCB::buf, ROWIO::ROWIO_RCB::dirty, ROWIO::fd, ROWIO::len, ROWIO::nrows, ROWIO::putrow, ROWIO::rcb, and ROWIO::ROWIO_RCB::row.
void Rowio_release | ( | ROWIO * | ) |
Definition at line 5 of file rowio/release.c.
References ROWIO::ROWIO_RCB::buf, free(), ROWIO::nrows, NULL, and ROWIO::rcb.
int Rowio_setup | ( | ROWIO * | R, |
int | fd, | ||
int | nrows, | ||
int | len, | ||
int(*)(int, void *, int, int) | getrow, | ||
int(*)(int, const void *, int, int) | putrow | ||
) |
Configure rowio structure.
Rowio_setup() initializes the ROWIO structure r and allocates the required memory buffers. The file descriptor fd must be open for reading. The number of rows to be held in memory is nrows. The length in bytes of each row is len. 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 fd 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().
R | pointer to ROWIO structure |
fd | file descriptor |
nrows | number of rows |
getrow | get row function |
Definition at line 44 of file rowio/setup.c.
References _, ROWIO::buf, ROWIO::ROWIO_RCB::buf, ROWIO::cur, ROWIO::fd, G_malloc, G_warning(), ROWIO::getrow, ROWIO::len, ROWIO::nrows, NULL, ROWIO::putrow, ROWIO::rcb, and ROWIO::ROWIO_RCB::row.