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
d09a5e06
Commit
d09a5e06
authored
7 years ago
by
Ionuț-Alex Oprea
Browse files
Options
Downloads
Patches
Plain Diff
some suggestions
parent
414061fa
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
Makefile
+2
-2
2 additions, 2 deletions
Makefile
libmobile.c
+12
-7
12 additions, 7 deletions
libmobile.c
with
14 additions
and
9 deletions
Makefile
+
2
−
2
View file @
d09a5e06
...
@@ -2,7 +2,7 @@ CC = gcc
...
@@ -2,7 +2,7 @@ CC = gcc
CFLAGS
=
-g
-Wall
CFLAGS
=
-g
-Wall
LIBS
=
-ljson-c
-lubox
-lubus
-luci
-lcurl
-lmobile
LIBS
=
-ljson-c
-lubox
-lubus
-luci
-lcurl
-lmobile
all
:
libmobile1 libmobile2
#
common dongle_apn dongle_pin dongle_network
all
:
libmobile1 libmobile2 common dongle_apn dongle_pin dongle_network
#gcc -shared -o libhello.so -fPIC hello.c
#gcc -shared -o libhello.so -fPIC hello.c
...
@@ -34,7 +34,7 @@ libmobile2: ${MOBJS}
...
@@ -34,7 +34,7 @@ libmobile2: ${MOBJS}
#DPOBJS = dongle_pin.o
#DPOBJS = dongle_pin.o
#DPSRCS = dongle_pin.c
#DPSRCS = dongle_pin.c
#dongle_pin: ${DPOBJS}
#dongle_pin: ${DPOBJS}
# ${CC} ${CFLAGS} ${DPOBJS} ${COBJS} -o dongle_pin ${LIBS}
# ${CC} ${CFLAGS} ${DPOBJS} ${COBJS} -o dongle_pin
-L .
${LIBS}
#
#
#DNOBJS = dongle_network.o
#DNOBJS = dongle_network.o
#DNSRCS = dongle_network.c
#DNSRCS = dongle_network.c
...
...
This diff is collapsed.
Click to expand it.
libmobile.c
+
12
−
7
View file @
d09a5e06
...
@@ -18,6 +18,7 @@ static int apn_profile_idx(struct json_object *apn_profiles, char *name);
...
@@ -18,6 +18,7 @@ static int apn_profile_idx(struct json_object *apn_profiles, char *name);
static
int
get_apn_profiles_len
(
void
);
static
int
get_apn_profiles_len
(
void
);
static
char
*
lexer
(
char
**
input
,
char
*
delimiter
);
static
char
*
lexer
(
char
**
input
,
char
*
delimiter
);
static
char
*
get_query_wrapper
(
char
*
vars
);
static
char
*
get_query_wrapper
(
char
*
vars
);
static
char
*
mobile_post_request
(
char
*
query
);
/**
/**
* Function: curl_cleaner
* Function: curl_cleaner
...
@@ -50,18 +51,21 @@ static void curl_cleaner(CURLcode *curl)
...
@@ -50,18 +51,21 @@ static void curl_cleaner(CURLcode *curl)
static
size_t
write_func
(
void
*
buffer
,
size_t
size
,
size_t
nmemb
,
void
*
userp
)
static
size_t
write_func
(
void
*
buffer
,
size_t
size
,
size_t
nmemb
,
void
*
userp
)
{
{
struct
string
*
str
=
(
struct
string
*
)
userp
;
struct
string
*
str
=
(
struct
string
*
)
userp
;
size_t
new_len
=
str
->
len
+
(
size
*
nmemb
);
size_t
len
=
size
*
nmemb
;
size_t
new_len
=
str
->
len
+
len
;
str
->
ptr
=
realloc
(
str
->
ptr
,
new_len
+
1
);
ptr
=
realloc
(
str
->
ptr
,
new_len
+
1
);
if
(
str
->
ptr
==
NULL
)
{
if
(
ptr
==
NULL
)
{
free
(
str
->
ptr
);
printf
(
"not enough ptr (realloc returned NULL)
\n
"
);
printf
(
"not enough ptr (realloc returned NULL)
\n
"
);
return
0
;
return
0
;
}
}
else
//realloc succeeded
memcpy
(
str
->
ptr
+
str
->
len
,
buffer
,
size
*
nmemb
);
str
->
ptr
=
ptr
;
memcpy
(
str
->
ptr
+
str
->
len
,
buffer
,
len
);
str
->
ptr
[
new_len
]
=
'\0'
;
str
->
ptr
[
new_len
]
=
'\0'
;
str
->
len
=
new_len
;
str
->
len
=
new_len
;
return
size
*
nmemb
;
return
len
;
}
}
/**
/**
...
@@ -438,7 +442,7 @@ char *mobile_disable_pin(char *pin)
...
@@ -438,7 +442,7 @@ char *mobile_disable_pin(char *pin)
return
mobile_post_request
(
query
);
return
mobile_post_request
(
query
);
}
}
char
*
mobile_post_request
(
char
*
query
)
static
char
*
mobile_post_request
(
char
*
query
)
{
{
CURL
*
curl
;
CURL
*
curl
;
CURLcode
res
;
CURLcode
res
;
...
@@ -478,6 +482,7 @@ char *mobile_get_request(char *vars)
...
@@ -478,6 +482,7 @@ char *mobile_get_request(char *vars)
if
(
!
query
)
if
(
!
query
)
goto
fail
;
goto
fail
;
// flow, calloc return code, gotos and frees
str
.
ptr
=
calloc
(
1
,
1
);
str
.
ptr
=
calloc
(
1
,
1
);
str
.
len
=
0
;
str
.
len
=
0
;
curl
=
curl_easy_init
();
curl
=
curl_easy_init
();
...
...
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