GRASS GIS 8 Programmer's Manual  8.4.0dev(2024)-535c39c9fc
defs/rowio.h File Reference
This graph shows which files directly or indirectly include this file:

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...
 

Function Documentation

◆ Rowio_fileno()

int Rowio_fileno ( const ROWIO R)

Get file descriptor.

Returns the file descriptor associated with the ROWIO structure.

Parameters
Rpointer to ROWIO structure
Returns
file descriptor

Definition at line 25 of file fileno.c.

References ROWIO::fd.

◆ Rowio_flush()

void Rowio_flush ( ROWIO R)

Flush data.

Parameters
Rpointer to ROWIO structure

Definition at line 88 of file rowio/get.c.

References ROWIO::nrows.

◆ Rowio_forget()

void Rowio_forget ( ROWIO R,
int  row 
)

Release row from memory.

Parameters
Rpointer to ROWIO structure
rowrow number

Definition at line 22 of file forget.c.

References ROWIO::nrows, ROWIO::rcb, and ROWIO::ROWIO_RCB::row.

◆ Rowio_get()

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.

Parameters
Rpointer to ROWIO structure
rowrow number
Returns
NULL on error
pointer to the buffer containing row

Definition at line 40 of file rowio/get.c.

◆ Rowio_put()

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.

Parameters
Rpointer to ROWIO structure
bufpointer to data buffer
rowrow number
Returns

Definition at line 41 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.

◆ Rowio_release()

void Rowio_release ( ROWIO R)

Definition at line 5 of file rowio/release.c.

References ROWIO::ROWIO_RCB::buf, free(), ROWIO::nrows, NULL, and ROWIO::rcb.

◆ Rowio_setup()

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().

Parameters
Rpointer to ROWIO structure
fdfile descriptor
nrowsnumber of rows
getrowget row function
Returns
1 on success
-1 no memory

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.