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
e255c5af
Commit
e255c5af
authored
7 years ago
by
Jakob Olsson
Browse files
Options
Downloads
Patches
Plain Diff
combine common files, solve merge conflicts
parent
f7018b25
No related branches found
No related tags found
No related merge requests found
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
Makefile
+5
-5
5 additions, 5 deletions
Makefile
common.c
+74
-21
74 additions, 21 deletions
common.c
common.h
+10
-2
10 additions, 2 deletions
common.h
common_hilink.h
+0
-20
0 additions, 20 deletions
common_hilink.h
common_zte.c
+0
-53
0 additions, 53 deletions
common_zte.c
dongle.c
+1
-1
1 addition, 1 deletion
dongle.c
with
90 additions
and
102 deletions
Makefile
+
5
−
5
View file @
e255c5af
...
...
@@ -21,10 +21,10 @@ libmobile1_hilink: ${HLOBJS}
libmobile2_hilink
:
${HLOBJS}
${
CC
}
${
HLOBJS
}
-shared
-o
libmobile_hilink.so
H
OBJS
=
common
_hilink
.o
H
SRCS
=
common
_hilink
.c
common
_hilink
:
${
H
OBJS}
${
CC
}
-c
${
CFLAGS
}
${
H
SRCS
}
-o
${
H
OBJS
}
C
OBJS
=
common.o
C
SRCS
=
common.c
common
:
${
C
OBJS}
${
CC
}
-c
${
CFLAGS
}
${
C
SRCS
}
-o
${
C
OBJS
}
STOBJS
=
stack_operations.o
STSRCS
=
stack_operations.c
...
...
@@ -34,7 +34,7 @@ stack_operations: ${STOBJS}
DIOBJS
=
dongle_infrastructure.o
DISRCS
=
dongle_infrastructure.c
dongle_infrastructure
:
${DIOBJS}
${
CC
}
-c
${
CWFLAGS
}
${
DISRCS
}
${
ZC
OBJS
}
${
ST
OBJS
}
-o
${
DIOBJS
}
-L
.
${
LIBS
}
${
CC
}
-c
${
CWFLAGS
}
${
DISRCS
}
${
ST
OBJS
}
${
C
OBJS
}
-o
${
DIOBJS
}
-L
.
${
LIBS
}
dongle
:
dongle.o
${
CC
}
${
CWFLAGS
}
dongle.o
${
ZCOBJS
}
${
DIOBJS
}
${
STOBJS
}
-o
dongle
-L
.
${
LIBS
}
...
...
This diff is collapsed.
Click to expand it.
common
_hilink
.c
→
common.c
+
74
−
21
View file @
e255c5af
#include
"common_hilink.h"
#include
"common.h"
int
print_to_ubus
(
struct
json_object
*
parsed_response
,
struct
ubus_context
*
ctx
,
struct
ubus_request_data
*
req
)
{
struct
blob_buf
bb
;
memset
(
&
bb
,
0
,
sizeof
(
bb
));
blob_buf_init
(
&
bb
,
0
);
bb
=
json_to_blob
(
parsed_response
,
bb
);
ubus_send_reply
(
ctx
,
req
,
bb
.
head
);
blob_buf_free
(
&
bb
);
json_object_put
(
parsed_response
);
return
0
;
}
struct
blob_buf
json_to_blob
(
struct
json_object
*
response
,
struct
blob_buf
bb
)
{
void
*
arr
,
*
obj
;
int
i
;
json_object_object_foreach
(
response
,
key
,
val
)
{
int
val_type
=
json_object_get_type
(
val
);
switch
(
val_type
)
{
case
json_type_int
:
blobmsg_add_u32
(
&
bb
,
key
,
json_object_get_int
(
val
));
break
;
case
json_type_double
:
blobmsg_add_double
(
&
bb
,
key
,
json_object_get_double
(
val
));
break
;
case
json_type_string
:
blobmsg_add_string
(
&
bb
,
key
,
json_object_get_string
(
val
));
break
;
case
json_type_array
:
arr
=
blobmsg_open_array
(
&
bb
,
key
);
for
(
i
=
0
;
i
<
json_object_array_length
(
val
);
i
++
)
{
// add open table
bb
=
json_to_blob
(
json_object_array_get_idx
(
val
,
i
),
bb
);
// add close table
}
blobmsg_close_array
(
&
bb
,
arr
);
break
;
case
json_type_object
:
obj
=
blobmsg_open_table
(
&
bb
,
key
);
bb
=
json_to_blob
(
val
,
bb
);
blobmsg_close_table
(
&
bb
,
obj
);
break
;
}
}
return
bb
;
}
//need to free tag content..
char
*
xml_parser
(
struct
write_result
*
result
,
char
*
tag
)
...
...
@@ -17,23 +69,25 @@ char *xml_parser(struct write_result *result, char *tag)
xpathctx_ptr
=
doc_ptr
?
xmlXPathNewContext
(
doc_ptr
)
:
NULL
;
xpathobj_ptr
=
xpathctx_ptr
?
xmlXPathEvalExpression
((
xmlChar
*
)
tag
,
xpathctx_ptr
)
:
NULL
;
if
(
xpathobj_ptr
)
{
if
(
xpathobj_ptr
)
{
int
n
;
xmlNodeSetPtr
nodeset_ptr
=
xpathobj_ptr
->
nodesetval
;
for
(
n
=
0
;
nodeset_ptr
&&
n
<
xmlXPathNodeSetGetLength
(
nodeset_ptr
);
n
++
)
{
for
(
n
=
0
;
nodeset_ptr
&&
n
<
xmlXPathNodeSetGetLength
(
nodeset_ptr
);
n
++
)
{
//if (DEBUG)
//printf("n value: %d\n", n);
xmlNodePtr
node_ptr
=
nodeset_ptr
->
nodeTab
[
n
];
if
(
node_ptr
->
type
!=
XML_ATTRIBUTE_NODE
&&
node_ptr
->
type
!=
XML_ELEMENT_NODE
&&
node_ptr
->
type
!=
XML_CDATA_SECTION_NODE
)
continue
;
if
(
node_ptr
->
children
)
{
if
(
node_ptr
->
children
)
{
//tag_content = (char*) node_ptr->children->content;
strcpy
(
tag_content
,
(
char
*
)
node_ptr
->
children
->
content
);
if
(
DEBUG
)
printf
(
"tag content: %s
\n
"
,
tag_content
);
break
;
}
}
}
...
...
@@ -48,7 +102,6 @@ char *xml_parser(struct write_result *result, char *tag)
leave:
return
NULL
;
}
void
xml_to_json
(
xmlNode
*
anode
,
json_object
*
jobj
)
...
...
@@ -56,19 +109,24 @@ void xml_to_json(xmlNode *anode, json_object *jobj)
xmlNodePtr
cur_node
=
NULL
;
json_object
*
cur_jstr
=
NULL
;
for
(
cur_node
=
anode
;
cur_node
;
cur_node
=
cur_node
->
next
)
{
if
(
DEBUG_COMMON
)
{
for
(
cur_node
=
anode
;
cur_node
;
cur_node
=
cur_node
->
next
)
{
if
(
DEBUG_COMMON
)
{
printf
(
"child address: %p
\n
"
,
cur_node
);
printf
(
"next addres: %p
\n
"
,
cur_node
->
next
);
printf
(
"root child content: %s
\n
"
,
(
uint8_t
*
)
xmlNodeGetContent
(
cur_node
));
}
if
(
cur_node
->
type
==
XML_ELEMENT_NODE
)
{
if
(
xmlChildElementCount
(
cur_node
)
==
0
)
{
if
(
cur_node
->
type
==
XML_ELEMENT_NODE
)
{
if
(
xmlChildElementCount
(
cur_node
)
==
0
)
{
cur_jstr
=
json_object_new_string
((
char
*
)
xmlNodeGetContent
(
cur_node
));
if
(
DEBUG_COMMON
)
{
printf
(
"xmlNodeGet name: %sn"
,
(
char
*
)
cur_node
->
name
);
printf
(
"xmlNodeGetContent: %sn"
,
(
char
*
)
xmlNodeGetContent
(
cur_node
));
if
(
DEBUG_COMMON
)
{
printf
(
"xmlNodeGet name: %sn"
,
(
char
*
)
cur_node
->
name
);
printf
(
"xmlNodeGetContent: %sn"
,
(
char
*
)
xmlNodeGetContent
(
cur_node
));
}
json_object_object_add
(
jobj
,
(
char
*
)
cur_node
->
name
,
cur_jstr
);
...
...
@@ -79,8 +137,6 @@ void xml_to_json(xmlNode *anode, json_object *jobj)
}
}
void
xml_to_json_converter
(
struct
write_result
*
result
)
{
json_object
*
jobj
;
...
...
@@ -94,11 +150,8 @@ void xml_to_json_converter(struct write_result *result)
jobj
=
json_object_new_object
();
xml_to_json
(
origin_node
,
jobj
);
if
(
DEBUG_COMMON
)
{
printf
(
"The json object created: %s
\n
"
,
json_object_to_json_string
(
jobj
));
if
(
DEBUG_COMMON
)
{
printf
(
"The json object created: %s
\n
"
,
json_object_to_json_string
(
jobj
));
}
}
This diff is collapsed.
Click to expand it.
common
_zte
.h
→
common.h
+
10
−
2
View file @
e255c5af
...
...
@@ -14,15 +14,20 @@
#include
<libubox/list.h>
#include
<libubox/uloop.h>
#include
<ctype.h>
#include
"libmobile_zte.h"
#include
<json-c/json.h>
#include
<string.h>
#include
<libubox/blobmsg.h>
#include
<libubox/blobmsg_json.h>
#include
<libubus.h>
#include
<libxml2/libxml/parser.h>
#include
<libxml/xpath.h>
#include
<libxml/xpathInternals.h>
#include
"libmobile_hilink.h"
#include
"libmobile_zte.h"
extern
int
debug
;
extern
char
*
ip_addr
;
extern
struct
ubus_context
*
global_ctx
;
#define debug_print(...) \
...
...
@@ -61,4 +66,7 @@ int print_to_ubus(struct json_object *parsed_response, struct ubus_context *ctx,
* Blob buffer containing the replicated json_object.
*/
struct
blob_buf
json_to_blob
(
struct
json_object
*
response
,
struct
blob_buf
bb
);
char
*
xml_parser
(
struct
write_result
*
result
,
char
*
tag
);
void
xml_to_json_converter
(
struct
write_result
*
result
);
#endif
This diff is collapsed.
Click to expand it.
common_hilink.h
deleted
100644 → 0
+
0
−
20
View file @
f7018b25
#ifndef COMMON_HILINK_H
#define COMMON_HILINK_H
#include
"libmobile_hilink.h"
#include
<libxml2/libxml/parser.h>
#include
<libxml/xpath.h>
#include
<libxml/xpathInternals.h>
#include
<json-c/json.h>
#define DEBUG_COMMON 0
char
*
xml_parser
(
struct
write_result
*
result
,
char
*
tag
);
void
xml_to_json_converter
(
struct
write_result
*
result
);
#endif
This diff is collapsed.
Click to expand it.
common_zte.c
deleted
100644 → 0
+
0
−
53
View file @
f7018b25
#include
"common_zte.h"
int
print_to_ubus
(
struct
json_object
*
parsed_response
,
struct
ubus_context
*
ctx
,
struct
ubus_request_data
*
req
)
{
struct
blob_buf
bb
;
memset
(
&
bb
,
0
,
sizeof
(
bb
));
blob_buf_init
(
&
bb
,
0
);
bb
=
json_to_blob
(
parsed_response
,
bb
);
ubus_send_reply
(
ctx
,
req
,
bb
.
head
);
blob_buf_free
(
&
bb
);
json_object_put
(
parsed_response
);
return
0
;
}
struct
blob_buf
json_to_blob
(
struct
json_object
*
response
,
struct
blob_buf
bb
)
{
void
*
arr
,
*
obj
;
int
i
;
json_object_object_foreach
(
response
,
key
,
val
)
{
int
val_type
=
json_object_get_type
(
val
);
switch
(
val_type
)
{
case
json_type_int
:
blobmsg_add_u32
(
&
bb
,
key
,
json_object_get_int
(
val
));
break
;
case
json_type_double
:
blobmsg_add_double
(
&
bb
,
key
,
json_object_get_double
(
val
));
break
;
case
json_type_string
:
blobmsg_add_string
(
&
bb
,
key
,
json_object_get_string
(
val
));
break
;
case
json_type_array
:
arr
=
blobmsg_open_array
(
&
bb
,
key
);
for
(
i
=
0
;
i
<
json_object_array_length
(
val
);
i
++
)
{
// add open table
bb
=
json_to_blob
(
json_object_array_get_idx
(
val
,
i
),
bb
);
// add close table
}
blobmsg_close_array
(
&
bb
,
arr
);
break
;
case
json_type_object
:
obj
=
blobmsg_open_table
(
&
bb
,
key
);
bb
=
json_to_blob
(
val
,
bb
);
blobmsg_close_table
(
&
bb
,
obj
);
break
;
}
}
return
bb
;
}
This diff is collapsed.
Click to expand it.
dongle.c
+
1
−
1
View file @
e255c5af
#include
<getopt.h>
#include
"common
_zte
.h"
#include
"common.h"
#include
"dongle_infrastructure.h"
...
...
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