Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
celllframe-node
Manage
Activity
Members
Labels
Plan
Issues
5
Issue boards
Milestones
Code
Merge requests
15
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cellframe
celllframe-node
Commits
43ab6e8c
Commit
43ab6e8c
authored
5 years ago
by
alexander.lysikov
Browse files
Options
Downloads
Patches
Plain Diff
added receiving the return code from command and function exit(ret_code)
parent
39eaec16
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
sources/main_node_cli.c
+1
-1
1 addition, 1 deletion
sources/main_node_cli.c
sources/main_node_cli_net.c
+32
-18
32 additions, 18 deletions
sources/main_node_cli_net.c
with
33 additions
and
19 deletions
sources/main_node_cli.c
+
1
−
1
View file @
43ab6e8c
...
...
@@ -183,7 +183,7 @@ int main(int argc, const char * argv[])
if
(
!
cparam
)
{
printf
(
"Can't connected to kelvin-node
\n
"
);
exit
(
0
);
exit
(
-
1
);
}
/*{
printf("start node_cli_post_command()\n");
...
...
This diff is collapsed.
Click to expand it.
sources/main_node_cli_net.c
+
32
−
18
View file @
43ab6e8c
/*
* Authors:
* Dmitriy A. Gearasimov <kahovski@gmail.com>
* Alexander Lysikov <alexander.lysikov@demlabs.net>
* DeM Labs Inc. https://demlabs.net
* DeM Labs Open source community https://github.com/demlabsinc
* Copyright (c) 2017-2019
...
...
@@ -30,6 +31,7 @@
#include
<assert.h>
#include
<sys/socket.h>
#include
"dap_common.h"
#include
"dap_strfuncs.h"
#include
"dap_chain_node_cli.h"
// for UNIX_SOCKET_FILE
#include
"main_node_cli_net.h"
...
...
@@ -156,24 +158,35 @@ int node_cli_post_command(connect_param *conn, cmd_state *cmd)
}
}
}
add_mem_data
((
uint8_t
**
)
&
post_data
,
&
post_data_len
,
"
\r\n\r\n
"
,
4
);
if
(
post_data
)
ret
=
curl_easy_setopt
(
curl
,
CURLOPT_POSTFIELDS
,
post_data
);
// data for POST request
if
(
post_data_len
>=
0
)
ret
=
curl_easy_setopt
(
curl
,
CURLOPT_POSTFIELDSIZE
,
(
long
)
post_data_len
);
// if need a lot to send: CURLOPT_POSTFIELDSIZE_LARGE
// sending request and receiving the http page (filling cmd)
//printf("cmd='%s'\n", cmd->cmd_name);
ret
=
curl_easy_perform
(
curl
);
// curl_easy_send
//printf("res=%s(err_code=%d) ret='%s'\n", (!ret) ? "OK" : "Err", ret, (cmd->cmd_res) ? cmd->cmd_res : "-");
if
(
ret
!=
CURLE_OK
)
printf
(
"Error (err_code=%d)
\n
"
,
ret
);
printf
(
"%s
\n
"
,
(
cmd
->
cmd_res
)
?
cmd
->
cmd_res
:
"no response"
);
DAP_DELETE
(
post_data
);
return
ret
;
//}
//else
// printf("%s\n", "no parameters");
return
-
1
;
add_mem_data
((
uint8_t
**
)
&
post_data
,
&
post_data_len
,
"
\r\n\r\n
"
,
4
);
if
(
post_data
)
ret
=
curl_easy_setopt
(
curl
,
CURLOPT_POSTFIELDS
,
post_data
);
// data for POST request
if
(
post_data_len
>=
0
)
ret
=
curl_easy_setopt
(
curl
,
CURLOPT_POSTFIELDSIZE
,
(
long
)
post_data_len
);
// if need a lot to send: CURLOPT_POSTFIELDSIZE_LARGE
// sending request and receiving the http page (filling cmd)
//printf("cmd='%s'\n", cmd->cmd_name);
ret
=
curl_easy_perform
(
curl
);
// curl_easy_send
if
(
ret
!=
CURLE_OK
)
{
printf
(
"Error (err_code=%d)
\n
"
,
ret
);
exit
(
-
1
);
}
int
l_err_code
=
-
1
;
if
(
cmd
->
cmd_res
)
{
char
**
l_str
=
dap_strsplit
(
cmd
->
cmd_res
,
"
\r\n
"
,
1
);
int
l_cnt
=
dap_str_countv
(
l_str
);
char
*
l_str_reply
=
NULL
;
if
(
l_cnt
==
2
)
{
l_err_code
=
strtol
(
l_str
[
0
],
NULL
,
10
);
l_str_reply
=
l_str
[
1
];
}
printf
(
"%s
\n
"
,
(
l_str_reply
)
?
l_str_reply
:
"no response"
);
dap_strfreev
(
l_str
);
}
DAP_DELETE
(
post_data
);
exit
(
l_err_code
);
return
0
;
}
int
node_cli_desconnect
(
connect_param
*
param
)
...
...
@@ -185,4 +198,5 @@ int node_cli_desconnect(connect_param *param)
}
curl_global_cleanup
();
return
0
;
}
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