Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
opendht
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
opendht
Commits
15403c0f
Commit
15403c0f
authored
5 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
c wrapper: add dht_runner_put
parent
0eee567c
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
c/opendht.cpp
+15
-2
15 additions, 2 deletions
c/opendht.cpp
c/opendht_c.h
+1
-0
1 addition, 0 deletions
c/opendht_c.h
with
16 additions
and
2 deletions
c/opendht.cpp
+
15
−
2
View file @
15403c0f
...
...
@@ -165,6 +165,7 @@ void dht_runner_get(dht_runner* r, const dht_infohash* h, dht_get_cb cb, dht_don
runner
->
get
(
*
hash
,
[
cb
,
cb_user_data
](
std
::
shared_ptr
<
dht
::
Value
>
value
){
return
cb
(
reinterpret_cast
<
const
dht_value
*>
(
&
value
),
cb_user_data
);
},
[
done_cb
,
cb_user_data
](
bool
ok
){
if
(
done_cb
)
done_cb
(
ok
,
cb_user_data
);
});
}
...
...
@@ -192,10 +193,22 @@ void dht_runner_cancel_listen(dht_runner* r, const dht_infohash* h, dht_op_token
runner
->
cancelListen
(
*
hash
,
std
::
move
(
*
token
));
}
void
dht_runner_put
(
dht_runner
*
r
,
const
dht_infohash
*
h
,
const
dht_value
*
v
,
dht_done_cb
done_cb
,
void
*
cb_user_data
)
{
auto
runner
=
reinterpret_cast
<
dht
::
DhtRunner
*>
(
r
);
auto
hash
=
reinterpret_cast
<
const
dht
::
InfoHash
*>
(
h
);
auto
value
=
reinterpret_cast
<
const
ValueSp
*>
(
v
);
runner
->
put
(
*
hash
,
*
value
,
[
done_cb
,
cb_user_data
](
bool
ok
){
if
(
done_cb
)
done_cb
(
ok
,
cb_user_data
);
});
}
void
dht_runner_shutdown
(
dht_runner
*
r
,
dht_shutdown_cb
done_cb
,
void
*
cb_user_data
)
{
auto
runner
=
reinterpret_cast
<
dht
::
DhtRunner
*>
(
r
);
runner
->
shutdown
([
done_cb
,
cb_user_data
](){
if
(
done_cb
)
done_cb
(
cb_user_data
);
});
}
...
...
This diff is collapsed.
Click to expand it.
c/opendht_c.h
+
1
−
0
View file @
15403c0f
...
...
@@ -89,6 +89,7 @@ OPENDHT_C_PUBLIC void dht_runner_bootstrap(dht_runner* runner, const char* host,
OPENDHT_C_PUBLIC
void
dht_runner_get
(
dht_runner
*
runner
,
const
dht_infohash
*
hash
,
dht_get_cb
cb
,
dht_done_cb
done_cb
,
void
*
cb_user_data
);
OPENDHT_C_PUBLIC
dht_op_token
*
dht_runner_listen
(
dht_runner
*
runner
,
const
dht_infohash
*
hash
,
dht_value_cb
cb
,
void
*
cb_user_data
);
OPENDHT_C_PUBLIC
void
dht_runner_cancel_listen
(
dht_runner
*
runner
,
const
dht_infohash
*
hash
,
dht_op_token
*
token
);
OPENDHT_C_PUBLIC
void
dht_runner_put
(
dht_runner
*
runner
,
const
dht_infohash
*
hash
,
const
dht_value
*
value
,
dht_done_cb
done_cb
,
void
*
cb_user_data
);
OPENDHT_C_PUBLIC
void
dht_runner_shutdown
(
dht_runner
*
runner
,
dht_shutdown_cb
done_cb
,
void
*
cb_user_data
);
#ifdef __cplusplus
...
...
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