GFXprim
2D bitmap graphics library with emphasis on speed and correctness
Toggle main menu visibility
Main Page
Topics
Data Structures
Data Structures
Data Structure Index
Data Fields
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
Variables
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
Files
File List
Globals
All
g
j
Functions
g
Variables
Typedefs
g
Enumerations
g
j
Enumerator
g
Macros
g
•
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Modules
Pages
Loading...
Searching...
No Matches
include
utils
gp_seek.h
Go to the documentation of this file.
1
// SPDX-License-Identifier: LGPL-2.1-or-later
2
/*
3
4
Copyright (C) 2020-2024 Cyril Hrubis <metan@ucw.cz>
5
6
*/
7
13
#ifndef GP_SEEK_H
14
#define GP_SEEK_H
15
16
#include <sys/types.h>
17
#include <stddef.h>
18
24
enum
gp_seek_whence
{
25
GP_SEEK_SET = 0,
26
GP_SEEK_CUR = 1,
27
GP_SEEK_END = 2,
28
};
24
enum
gp_seek_whence
{
…
};
29
41
static
inline
int
gp_seek_off
(ssize_t off,
enum
gp_seek_whence
whence,
size_t
*cur_pos,
size_t
max_pos)
42
{
43
switch
(whence) {
44
case
GP_SEEK_SET:
45
if
(off < 0)
46
return
-1;
47
48
if
((
size_t
)off > max_pos)
49
return
1;
50
51
*cur_pos = off;
52
53
return
0;
54
break
;
55
case
GP_SEEK_CUR:
56
if
(off < 0) {
57
if
(*cur_pos < (
size_t
)-off)
58
return
-1;
59
}
else
{
60
if
(*cur_pos + (
size_t
)off > max_pos)
61
return
1;
62
}
63
64
*cur_pos += off;
65
66
return
0;
67
break
;
68
case
GP_SEEK_END:
69
if
(off > 0)
70
return
1;
71
72
if
((
size_t
)-off > max_pos)
73
return
-1;
74
75
*cur_pos = max_pos + off;
76
77
return
0;
78
break
;
79
}
80
81
return
-1;
82
}
41
static
inline
int
gp_seek_off
(ssize_t off,
enum
gp_seek_whence
whence,
size_t
*cur_pos,
size_t
max_pos) {
…
}
83
84
#endif
/* GP_SEEK_H */
gp_seek_whence
gp_seek_whence
Seek constants.
Definition
gp_seek.h:24
gp_seek_off
static int gp_seek_off(ssize_t off, enum gp_seek_whence whence, size_t *cur_pos, size_t max_pos)
Computes position for a seek like parameters.
Definition
gp_seek.h:41
Generated by
1.9.8