Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Guile DNS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hugo Hörnquist
Guile DNS
Commits
cb394486
Commit
cb394486
authored
3 years ago
by
Hugo Hörnquist
Browse files
Options
Downloads
Patches
Plain Diff
Add "stateful" setters.
parent
1dacbdf7
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
dns/internal/bv.scm
+52
-1
52 additions, 1 deletion
dns/internal/bv.scm
with
52 additions
and
1 deletion
dns/internal/bv.scm
+
52
−
1
View file @
cb394486
...
@@ -11,7 +11,10 @@
...
@@ -11,7 +11,10 @@
:use-module
(
dns
internal
state-monad
)
:use-module
(
dns
internal
state-monad
)
:use-module
(
rnrs
bytevectors
)
:use-module
(
rnrs
bytevectors
)
:use-module
(
srfi
srfi-88
)
:use-module
(
srfi
srfi-88
)
:export
(
u8
u16
u32
bv-get
uint-get
)
:export
(
bv-copy!
u8!
u16!
u32!
u8
u16
u32
bv-get
uint-get
)
)
)
...
@@ -48,3 +51,51 @@
...
@@ -48,3 +51,51 @@
(
define
(
uint-get
bv
len
)
(
define
(
uint-get
bv
len
)
(
do
vec
<-
(
bv-get
bv
len
)
(
do
vec
<-
(
bv-get
bv
len
)
(
return
(
bytevector-uint-ref
vec
0
(
endianness
big
)
len
))))
(
return
(
bytevector-uint-ref
vec
0
(
endianness
big
)
len
))))
(
define
(
double-bv
bv
)
(
define
new-bv
(
make-bytevector
(
*
2
(
max
1
(
bytevector-length
bv
)))))
(
bytevector-copy!
bv
0
new-bv
0
(
bytevector-length
bv
))
new-bv
)
(
define
(
with-resizing-bv
bv
proc
)
(
catch
'out-of-range
(
lambda
()
(
proc
bv
)
bv
)
(
lambda
(
err
err-proc
msg
arg
data
)
;; Call ourselves recursivly, if index is way out of bounds
(
with-resizing-bv
(
double-bv
bv
)
proc
))))
(
define
(
bytevector-u8-set-safe!
bv
ptr
item
)
(
with-resizing-bv
bv
(
lambda
(
bv
)
(
bytevector-u8-set!
bv
ptr
item
))))
(
define*
(
bytevector-u16-set-safe!
bv
ptr
item
optional:
(
e
(
endianness
big
)))
(
with-resizing-bv
bv
(
lambda
(
bv
)
(
bytevector-u16-set!
bv
ptr
item
e
))))
(
define*
(
bytevector-u32-set-safe!
bv
ptr
item
optional:
(
e
(
endianness
big
)))
(
with-resizing-bv
bv
(
lambda
(
bv
)
(
bytevector-u32-set!
bv
ptr
item
e
))))
(
define
(
bytevector-copy-safe!
source
source-start
target
target-start
len
)
(
with-resizing-bv
target
(
lambda
(
target
)
(
bytevector-copy!
source
source-start
target
target-start
len
))))
(
define
((
u8!
item
)
bv
ptr
)
(
values
#f
(
bytevector-u8-set-safe!
bv
ptr
item
)
(
+
ptr
1
)))
(
define*
((
u16!
item
optional:
(
e
(
endianness
big
)))
bv
ptr
)
(
values
#f
(
bytevector-u16-set-safe!
bv
ptr
item
e
)
(
+
ptr
2
)))
(
define*
((
u32!
item
optional:
(
e
(
endianness
big
)))
bv
ptr
)
(
values
#f
(
bytevector-u32-set-safe!
bv
ptr
item
e
)
(
+
ptr
4
)))
(
define*
((
bv-copy!
source
optional:
(
start
0
)
(
length
(
-
(
bytevector-length
source
)
start
)))
bv
ptr
)
(
values
#f
(
bytevector-copy-safe!
source
start
bv
ptr
length
)
(
+
ptr
length
)))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment