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
c826b2ab
Commit
c826b2ab
authored
7 years ago
by
Jakob Olsson
Browse files
Options
Downloads
Patches
Plain Diff
refactor print_list to stupid code
parent
c1956bf5
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dongle.c
+25
-19
25 additions, 19 deletions
dongle.c
dongle.h
+1
-1
1 addition, 1 deletion
dongle.h
with
26 additions
and
20 deletions
dongle.c
+
25
−
19
View file @
c826b2ab
...
@@ -454,61 +454,56 @@ fail:
...
@@ -454,61 +454,56 @@ fail:
return
ipv4_addr
;
return
ipv4_addr
;
}
}
int
list_to_blob
(
void
)
int
list_to_blob
(
struct
blob_buf
*
bb
)
{
{
struct
device
*
net_dev
;
struct
device
*
net_dev
;
struct
blob_buf
bb
;
void
*
arr
,
*
table
;
void
*
arr
,
*
table
;
int
rv
;
int
rv
;
memset
(
&
bb
,
0
,
sizeof
(
bb
));
memset
(
bb
,
0
,
sizeof
(
*
bb
));
rv
=
blob_buf_init
(
&
bb
,
0
);
rv
=
blob_buf_init
(
bb
,
0
);
if
(
rv
!=
0
)
if
(
rv
!=
0
)
goto
fail
;
goto
fail
;
arr
=
blobmsg_open_array
(
&
bb
,
"network_devices"
);
arr
=
blobmsg_open_array
(
bb
,
"network_devices"
);
if
(
!
arr
)
if
(
!
arr
)
goto
fail_arr
;
goto
fail_arr
;
list_for_each_entry
(
net_dev
,
&
devices
,
list
)
list_for_each_entry
(
net_dev
,
&
devices
,
list
)
{
{
table
=
blobmsg_open_table
(
bb
,
""
);
table
=
blobmsg_open_table
(
&
bb
,
""
);
if
(
!
table
)
if
(
!
table
)
goto
fail_table
;
goto
fail_table
;
rv
=
blobmsg_add_string
(
&
bb
,
"product"
,
net_dev
->
usb
.
product
);
rv
=
blobmsg_add_string
(
bb
,
"product"
,
net_dev
->
usb
.
product
);
if
(
rv
<
0
)
if
(
rv
<
0
)
goto
fail_string
;
goto
fail_string
;
rv
=
blobmsg_add_string
(
&
bb
,
"interface_name"
,
net_dev
->
usb
.
if_name
);
rv
=
blobmsg_add_string
(
bb
,
"interface_name"
,
net_dev
->
usb
.
if_name
);
if
(
rv
<
0
)
if
(
rv
<
0
)
goto
fail_string
;
goto
fail_string
;
rv
=
blobmsg_add_string
(
&
bb
,
"idproduct"
,
net_dev
->
usb
.
product_id
);
rv
=
blobmsg_add_string
(
bb
,
"idproduct"
,
net_dev
->
usb
.
product_id
);
if
(
rv
<
0
)
if
(
rv
<
0
)
goto
fail_string
;
goto
fail_string
;
rv
=
blobmsg_add_string
(
&
bb
,
"idvendor"
,
net_dev
->
usb
.
vendor_id
);
rv
=
blobmsg_add_string
(
bb
,
"idvendor"
,
net_dev
->
usb
.
vendor_id
);
if
(
rv
<
0
)
if
(
rv
<
0
)
goto
fail_string
;
goto
fail_string
;
if
(
net_dev
->
ip
)
if
(
net_dev
->
ip
)
{
{
rv
=
blobmsg_add_string
(
&
bb
,
"ip"
,
net_dev
->
ip
);
rv
=
blobmsg_add_string
(
bb
,
"ip"
,
net_dev
->
ip
);
if
(
rv
<
0
)
if
(
rv
<
0
)
goto
fail_string
;
goto
fail_string
;
}
}
blobmsg_close_table
(
&
bb
,
table
);
blobmsg_close_table
(
bb
,
table
);
}
}
blobmsg_close_array
(
&
bb
,
arr
);
blobmsg_close_array
(
bb
,
arr
);
ubus_send_reply
(
ctx
,
req
,
bb
.
head
);
blob_buf_free
(
&
bb
);
return
0
;
return
0
;
fail_string:
fail_string:
fail_table:
fail_table:
fail_arr:
fail_arr:
blob_buf_free
(
&
bb
);
fail:
fail:
return
UBUS_STATUS_UNKNOWN_ERROR
;
return
UBUS_STATUS_UNKNOWN_ERROR
;
}
}
...
@@ -517,7 +512,18 @@ int print_list(struct ubus_context *ctx, struct ubus_object *obj,
...
@@ -517,7 +512,18 @@ int print_list(struct ubus_context *ctx, struct ubus_object *obj,
struct
ubus_request_data
*
req
,
const
char
*
method
,
struct
ubus_request_data
*
req
,
const
char
*
method
,
struct
blob_attr
*
msg
)
struct
blob_attr
*
msg
)
{
{
return
list_to_blob
();
struct
blob_buf
bb
;
int
rv
;
rv
=
list_to_blob
(
&
bb
);
if
(
rv
==
0
)
goto
fail
;
ubus_send_reply
(
ctx
,
req
,
bb
.
head
);
fail:
blob_buf_free
(
&
bb
);
return
rv
;
}
}
int
clear
(
struct
ubus_context
*
ctx
,
struct
ubus_object
*
obj
,
int
clear
(
struct
ubus_context
*
ctx
,
struct
ubus_object
*
obj
,
...
...
This diff is collapsed.
Click to expand it.
dongle.h
+
1
−
1
View file @
c826b2ab
...
@@ -34,7 +34,7 @@ void remove_newline(char *input);
...
@@ -34,7 +34,7 @@ void remove_newline(char *input);
char
*
get_usb_stat
(
char
*
path
,
char
*
dir
,
char
*
stat
);
char
*
get_usb_stat
(
char
*
path
,
char
*
dir
,
char
*
stat
);
char
*
get_device_name
(
char
*
dir_name
);
char
*
get_device_name
(
char
*
dir_name
);
char
*
get_device_ip
(
char
*
device_name
);
char
*
get_device_ip
(
char
*
device_name
);
int
list_to_blob
(
void
);
int
list_to_blob
(
struct
blob_buf
*
bb
);
int
print_list
(
struct
ubus_context
*
ctx
,
struct
ubus_object
*
obj
,
int
print_list
(
struct
ubus_context
*
ctx
,
struct
ubus_object
*
obj
,
struct
ubus_request_data
*
req
,
const
char
*
method
,
struct
ubus_request_data
*
req
,
const
char
*
method
,
struct
blob_attr
*
msg
);
struct
blob_attr
*
msg
);
...
...
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