Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mdmngr
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
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
IOPSYS
mdmngr
Commits
14b5edb1
Commit
14b5edb1
authored
7 years ago
by
Jakob Olsson
Browse files
Options
Downloads
Patches
Plain Diff
lib_commons.*: some fixes to get_object_by_keys
parent
80ba4060
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib_commons.c
+6
-3
6 additions, 3 deletions
lib_commons.c
lib_commons.h
+4
-1
4 additions, 1 deletion
lib_commons.h
with
10 additions
and
4 deletions
lib_commons.c
+
6
−
3
View file @
14b5edb1
...
@@ -25,7 +25,7 @@ size_t write_func(void *buffer, size_t size, size_t nmemb, void *data)
...
@@ -25,7 +25,7 @@ size_t write_func(void *buffer, size_t size, size_t nmemb, void *data)
struct
json_object
*
get_object_by_keys
(
struct
json_object
*
input_obj
,
char
*
input_key
,
char
*
output_key
)
struct
json_object
*
get_object_by_keys
(
struct
json_object
*
input_obj
,
char
*
input_key
,
char
*
output_key
)
{
{
struct
json_object
*
obj
=
NULL
;
struct
json_object
*
obj
=
NULL
;
struct
json_object
*
jstring
=
NULL
;
struct
json_object
*
jstring
;
enum
json_type
type
;
enum
json_type
type
;
type
=
json_object_get_type
(
input_obj
);
type
=
json_object_get_type
(
input_obj
);
...
@@ -34,10 +34,13 @@ struct json_object *get_object_by_keys(struct json_object *input_obj, char *inpu
...
@@ -34,10 +34,13 @@ struct json_object *get_object_by_keys(struct json_object *input_obj, char *inpu
json_object_object_foreach
(
input_obj
,
key
,
val
)
{
json_object_object_foreach
(
input_obj
,
key
,
val
)
{
if
(
strcmp
(
input_key
,
key
)
!=
0
)
if
(
strcmp
(
input_key
,
key
)
!=
0
)
goto
fail
;
continue
;
obj
=
json_object_new_object
();
obj
=
json_object_new_object
();
json_object_object_add
(
obj
,
output_key
,
val
);
jstring
=
json_object_new_string
((
char
*
)
json_object_get_string
(
val
));
json_object_object_add
(
obj
,
output_key
,
jstring
);
//json_object_object_add(obj, output_key, val);
break
;
break
;
}
}
...
...
This diff is collapsed.
Click to expand it.
lib_commons.h
+
4
−
1
View file @
14b5edb1
...
@@ -4,6 +4,9 @@
...
@@ -4,6 +4,9 @@
#include
<stdlib.h>
#include
<stdlib.h>
#include
<string.h>
#include
<string.h>
#include
<json-c/json.h>
#include
<json-c/json.h>
#define PIN_STATUS_H "PinOptState"
#define PIN_STATUS_Z "pin_status"
#define PIN_STATUS "pin_status"
/**
/**
* Struct used for parsing the curl response from the dongle.
* Struct used for parsing the curl response from the dongle.
...
@@ -25,5 +28,5 @@ struct string {
...
@@ -25,5 +28,5 @@ struct string {
*/
*/
size_t
write_func
(
void
*
buffer
,
size_t
size
,
size_t
nmemb
,
void
*
data
);
size_t
write_func
(
void
*
buffer
,
size_t
size
,
size_t
nmemb
,
void
*
data
);
struct
json_object
*
get_object_by_key
(
json_object
*
json_obj
,
char
*
string
,
char
*
output_key
);
struct
json_object
*
get_object_by_key
s
(
json_object
*
json_obj
,
char
*
string
,
char
*
output_key
);
#endif
#endif
\ No newline at end of file
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