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
484878ae
Commit
484878ae
authored
3 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
c: add missing value apis
parent
ace3a94e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
c/opendht.cpp
+10
-0
10 additions, 0 deletions
c/opendht.cpp
c/opendht_c.h
+2
-0
2 additions, 0 deletions
c/opendht_c.h
with
12 additions
and
0 deletions
c/opendht.cpp
+
10
−
0
View file @
484878ae
...
...
@@ -97,10 +97,20 @@ const char* dht_value_get_user_type(const dht_value* data) {
return
vsp
->
user_type
.
c_str
();
}
void
dht_value_set_user_type
(
dht_value
*
data
,
const
char
*
user_type
)
{
(
*
reinterpret_cast
<
ValueSp
*>
(
data
))
->
user_type
=
user_type
;
}
dht_value
*
dht_value_new
(
const
uint8_t
*
data
,
size_t
size
)
{
return
reinterpret_cast
<
dht_value
*>
(
new
ValueSp
(
std
::
make_shared
<
dht
::
Value
>
(
data
,
size
)));
}
dht_value
*
dht_value_new_from_string
(
const
char
*
str
)
{
ValueSp
value
=
std
::
make_shared
<
dht
::
Value
>
((
const
uint8_t
*
)
str
,
strlen
(
str
));
value
->
user_type
=
"text/plain"
;
return
reinterpret_cast
<
dht_value
*>
(
new
ValueSp
(
std
::
move
(
value
)));
}
dht_value
*
dht_value_ref
(
const
dht_value
*
v
)
{
return
reinterpret_cast
<
dht_value
*>
(
new
ValueSp
(
*
reinterpret_cast
<
const
ValueSp
*>
(
v
)));
}
...
...
This diff is collapsed.
Click to expand it.
c/opendht_c.h
+
2
−
0
View file @
484878ae
...
...
@@ -82,6 +82,7 @@ struct OPENDHT_C_PUBLIC dht_value;
typedef
struct
dht_value
dht_value
;
typedef
uint64_t
dht_value_id
;
OPENDHT_C_PUBLIC
dht_value
*
dht_value_new
(
const
uint8_t
*
data
,
size_t
size
);
OPENDHT_C_PUBLIC
dht_value
*
dht_value_new_from_string
(
const
char
*
str
);
OPENDHT_C_PUBLIC
dht_value
*
dht_value_ref
(
const
dht_value
*
);
OPENDHT_C_PUBLIC
void
dht_value_unref
(
dht_value
*
);
OPENDHT_C_PUBLIC
dht_data_view
dht_value_get_data
(
const
dht_value
*
data
);
...
...
@@ -89,6 +90,7 @@ OPENDHT_C_PUBLIC dht_value_id dht_value_get_id(const dht_value* data);
OPENDHT_C_PUBLIC
dht_publickey
*
dht_value_get_owner
(
const
dht_value
*
data
);
OPENDHT_C_PUBLIC
dht_infohash
dht_value_get_recipient
(
const
dht_value
*
data
);
OPENDHT_C_PUBLIC
const
char
*
dht_value_get_user_type
(
const
dht_value
*
data
);
OPENDHT_C_PUBLIC
void
dht_value_set_user_type
(
dht_value
*
data
,
const
char
*
user_type
);
// callbacks
typedef
bool
(
*
dht_get_cb
)(
const
dht_value
*
value
,
void
*
user_data
);
...
...
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