GRASS 8 Programmer's Manual
8.6.0dev(2026)-56a9afeb9f
Loading...
Searching...
No Matches
segment/get.c
Go to the documentation of this file.
1
/**
2
* \file lib/segment/get.c
3
*
4
* \brief Get segment routines.
5
*
6
* This program is free software under the GNU General Public License
7
* (>=v2). Read the file COPYING that comes with GRASS for details.
8
*
9
* \author GRASS Development Team
10
*
11
* \date 2005-2018
12
*/
13
14
#include <
string.h
>
15
#include "local_proto.h"
16
17
/*bugfix: buf: char* vs int* -> wrong pointer arithmetics!!!. Pierre de Mouveaux
18
* - 09 april 2000 */
19
/* int Segment_get (SEGMENT *SEG, register int *buf,int row,int col) */
20
21
/**
22
* \brief Get value from segment file.
23
*
24
* Provides random read access to the segmented data. It gets
25
* <i>len</i> bytes of data into <b>buf</b> from the segment file
26
* <b>seg</b> for the corresponding <b>row</b> and <b>col</b> in the
27
* original data matrix.
28
*
29
* \param[in] SEG segment
30
* \param[in,out] buf value return buffer
31
* \param[in] row
32
* \param[in] col
33
* \return 1 of successful
34
* \return -1 if unable to seek or read segment file
35
*/
36
int
Segment_get
(
SEGMENT
*
SEG
,
void
*buf,
off_t
row,
off_t
col
)
37
{
38
int
index, n, i;
39
40
if
(
SEG
->cache) {
41
memcpy
(buf,
SEG
->cache + ((
size_t
)row *
SEG
->ncols +
col
) *
SEG
->len,
42
SEG
->len);
43
44
return
1;
45
}
46
47
SEG
->address(
SEG
, row,
col
, &n, &index);
48
if
((i =
seg_pagein
(
SEG
, n)) < 0)
49
return
-1;
50
51
memcpy
(buf, &
SEG
->scb[i].
buf
[index],
SEG
->len);
52
53
return
1;
54
}
AMI_STREAM
Definition
ami_stream.h:153
UntypedStream::buf
char * buf
Definition
ami_stream.h:141
seg_pagein
int seg_pagein(SEGMENT *SEG, int n)
Internal use only.
Definition
pagein.c:37
Segment_get
int Segment_get(SEGMENT *SEG, void *buf, off_t row, off_t col)
Get value from segment file.
Definition
segment/get.c:36
string.h
SEGMENT
Definition
segment.h:19
lib
segment
get.c
Generated on Sat Apr 4 2026 17:44:27 for GRASS 8 Programmer's Manual by
1.9.8