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
56b52ce9
Commit
56b52ce9
authored
7 years ago
by
Jakob Olsson
Browse files
Options
Downloads
Patches
Plain Diff
common: change to json_to_blob arguments, and its use accordingly
parent
405509c3
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
common.c
+13
-15
13 additions, 15 deletions
common.c
common.h
+2
-4
2 additions, 4 deletions
common.h
with
15 additions
and
19 deletions
common.c
+
13
−
15
View file @
56b52ce9
...
@@ -6,7 +6,7 @@ int print_to_ubus(struct json_object *parsed_response, struct ubus_context *ctx,
...
@@ -6,7 +6,7 @@ int print_to_ubus(struct json_object *parsed_response, struct ubus_context *ctx,
memset
(
&
bb
,
0
,
sizeof
(
bb
));
memset
(
&
bb
,
0
,
sizeof
(
bb
));
blob_buf_init
(
&
bb
,
0
);
blob_buf_init
(
&
bb
,
0
);
bb
=
json_to_blob
(
parsed_response
,
bb
);
json_to_blob
(
parsed_response
,
&
bb
);
ubus_send_reply
(
ctx
,
req
,
bb
.
head
);
ubus_send_reply
(
ctx
,
req
,
bb
.
head
);
blob_buf_free
(
&
bb
);
blob_buf_free
(
&
bb
);
...
@@ -14,7 +14,7 @@ int print_to_ubus(struct json_object *parsed_response, struct ubus_context *ctx,
...
@@ -14,7 +14,7 @@ int print_to_ubus(struct json_object *parsed_response, struct ubus_context *ctx,
return
0
;
return
0
;
}
}
struct
blob_buf
json_to_blob
(
struct
json_object
*
response
,
struct
blob_buf
bb
)
void
json_to_blob
(
struct
json_object
*
response
,
struct
blob_buf
*
bb
)
{
{
void
*
arr
,
*
obj
;
void
*
arr
,
*
obj
;
int
i
;
int
i
;
...
@@ -24,32 +24,30 @@ struct blob_buf json_to_blob(struct json_object *response, struct blob_buf bb)
...
@@ -24,32 +24,30 @@ struct blob_buf json_to_blob(struct json_object *response, struct blob_buf bb)
switch
(
val_type
)
{
switch
(
val_type
)
{
case
json_type_int
:
case
json_type_int
:
blobmsg_add_u32
(
&
bb
,
key
,
json_object_get_int
(
val
));
blobmsg_add_u32
(
bb
,
key
,
json_object_get_int
(
val
));
break
;
break
;
case
json_type_double
:
case
json_type_double
:
blobmsg_add_double
(
&
bb
,
key
,
json_object_get_double
(
val
));
blobmsg_add_double
(
bb
,
key
,
json_object_get_double
(
val
));
break
;
break
;
case
json_type_string
:
case
json_type_string
:
blobmsg_add_string
(
&
bb
,
key
,
json_object_get_string
(
val
));
blobmsg_add_string
(
bb
,
key
,
json_object_get_string
(
val
));
break
;
break
;
case
json_type_array
:
case
json_type_array
:
arr
=
blobmsg_open_array
(
&
bb
,
key
);
arr
=
blobmsg_open_array
(
bb
,
key
);
for
(
i
=
0
;
i
<
json_object_array_length
(
val
);
i
++
)
{
for
(
i
=
0
;
i
<
json_object_array_length
(
val
);
i
++
)
{
// add open table
// add open table
?
bb
=
json_to_blob
(
json_object_array_get_idx
(
val
,
i
),
bb
);
json_to_blob
(
json_object_array_get_idx
(
val
,
i
),
bb
);
// add close table
// add close table
?
}
}
blobmsg_close_array
(
&
bb
,
arr
);
blobmsg_close_array
(
bb
,
arr
);
break
;
break
;
case
json_type_object
:
case
json_type_object
:
obj
=
blobmsg_open_table
(
&
bb
,
key
);
obj
=
blobmsg_open_table
(
bb
,
key
);
bb
=
json_to_blob
(
val
,
bb
);
json_to_blob
(
val
,
bb
);
blobmsg_close_table
(
&
bb
,
obj
);
blobmsg_close_table
(
bb
,
obj
);
break
;
break
;
}
}
}
}
return
bb
;
}
}
struct
json_object
*
get_json_string_object_by_key
(
json_object
*
json_obj
,
char
*
string
)
struct
json_object
*
get_json_string_object_by_key
(
json_object
*
json_obj
,
char
*
string
)
...
...
This diff is collapsed.
Click to expand it.
common.h
+
2
−
4
View file @
56b52ce9
...
@@ -68,12 +68,10 @@ int print_to_ubus(struct json_object *parsed_response, struct ubus_context *ctx,
...
@@ -68,12 +68,10 @@ int print_to_ubus(struct json_object *parsed_response, struct ubus_context *ctx,
*
*
* Parameters:
* Parameters:
* response - json_object pointer to be replicated in a blob buffer.
* response - json_object pointer to be replicated in a blob buffer.
* bb - The blob buffer to hold the results.
* bb - The blob buffer
pointer
to hold the results.
*
*
* Returns:
* Blob buffer containing the replicated json_object.
*/
*/
struct
blob_buf
json_to_blob
(
struct
json_object
*
response
,
struct
blob_buf
bb
);
void
json_to_blob
(
struct
json_object
*
response
,
struct
blob_buf
*
bb
);
char
*
xml_parser
(
struct
write_result
*
result
,
char
*
tag
);
char
*
xml_parser
(
struct
write_result
*
result
,
char
*
tag
);
struct
json_object
*
xml_to_json_converter
(
struct
write_result
*
result
);
struct
json_object
*
xml_to_json_converter
(
struct
write_result
*
result
);
...
...
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