X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fmain.c;h=a0d6dccaf8e9971393f211c0dcc38242547aa5d3;hb=6c3403d470cd185d209de32d14f5272e87b4ca38;hp=c1a7aa3ede1f13c971f962c88413c3767a4d8dc0;hpb=e0846ddeb8558dced2e49d501b971d98ce2f9f66;p=routeros-api.git diff --git a/src/main.c b/src/main.c index c1a7aa3..a0d6dcc 100644 --- a/src/main.c +++ b/src/main.c @@ -42,6 +42,11 @@ #include "routeros_api.h" +#if 1 +# define mt_debug(...) fprintf (stdout, __VA_ARGS__) +#else +# define mt_debug(...) /**/ +#endif /* FIXME */ char *strdup (const char *); @@ -300,6 +305,9 @@ static int send_command (mt_connection_t *c, /* {{{ */ size_t i; int status; + /* FIXME: For debugging only */ + memset (buffer, 0, sizeof (buffer)); + buffer_ptr = buffer; buffer_size = sizeof (buffer); @@ -529,6 +537,9 @@ static int create_socket (const char *node, const char *service) /* {{{ */ struct addrinfo *ai_ptr; int status; + mt_debug ("create_socket (node = %s, service = %s);\n", + node, service); + memset (&ai_hint, 0, sizeof (ai_hint)); #ifdef AI_ADDRCONFIG ai_hint.ai_flags |= AI_ADDRCONFIG; @@ -550,11 +561,15 @@ static int create_socket (const char *node, const char *service) /* {{{ */ fd = socket (ai_ptr->ai_family, ai_ptr->ai_socktype, ai_ptr->ai_protocol); if (fd < 0) + { + mt_debug ("create_socket: socket(2) failed.\n"); continue; + } status = connect (fd, ai_ptr->ai_addr, ai_ptr->ai_addrlen); if (status != 0) { + mt_debug ("create_socket: connect(2) failed.\n"); close (fd); continue; } @@ -658,6 +673,13 @@ int mt_reply_num (const mt_reply_t *r) /* {{{ */ return (ret); } /* }}} int mt_reply_num */ +const char *mt_reply_status (const mt_reply_t *r) /* {{{ */ +{ + if (r == NULL) + return (NULL); + return (r->status); +} /* }}} char *mt_reply_status */ + const char *mt_reply_param_key_by_index (const mt_reply_t *r, /* {{{ */ unsigned int index) {