projects
/
routeros-api.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
87849f1
)
src/main.c: Let ros_connect fail if logging in returns an error.
author
Florian Forster
<octo@leeloo.lan.home.verplant.org>
Wed, 25 Nov 2009 18:53:26 +0000
(19:53 +0100)
committer
Florian Forster
<octo@leeloo.lan.home.verplant.org>
Wed, 25 Nov 2009 18:53:26 +0000
(19:53 +0100)
src/main.c
patch
|
blob
|
history
diff --git
a/src/main.c
b/src/main.c
index
82e8c7f
..
a941750
100644
(file)
--- a/
src/main.c
+++ b/
src/main.c
@@
-638,7
+638,13
@@
static int login2_handler (ros_connection_t *c, const ros_reply_t *r, /* {{{ */
printf ("login2_handler has been called.\n");
reply_dump (r);
printf ("login2_handler has been called.\n");
reply_dump (r);
- if (strcmp (r->status, "done") != 0)
+ if (strcmp (r->status, "trap") == 0)
+ {
+ ros_debug ("login2_handler: Logging in failed: %s.\n",
+ ros_reply_param_val_by_key (r, "message"));
+ return (EACCES);
+ }
+ else if (strcmp (r->status, "done") != 0)
{
ros_debug ("login2_handler: Unexpected status: %s.\n", r->status);
return (EPROTO);
{
ros_debug ("login2_handler: Unexpected status: %s.\n", r->status);
return (EPROTO);
@@
-797,6
+803,13
@@
ros_connection_t *ros_connect (const char *node, const char *service, /* {{{ */
status = ros_query (c, "/login", /* args num = */ 0, /* args = */ NULL,
login_handler, &user_data);
status = ros_query (c, "/login", /* args num = */ 0, /* args = */ NULL,
login_handler, &user_data);
+ if (status != 0)
+ {
+ ros_disconnect (c);
+ errno = status;
+ return (NULL);
+ }
+
return (c);
} /* }}} ros_connection_t *ros_connect */
return (c);
} /* }}} ros_connection_t *ros_connect */