From: Florian Forster Date: Thu, 19 Nov 2009 11:29:55 +0000 (+0100) Subject: Implemented the "reply_dump" function. X-Git-Tag: librouteros-0.1.0~19 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=5a9c21cc2cbff2eb640008a88bb857ea3a888aee;p=routeros-api.git Implemented the "reply_dump" function. Todo: Remove when not debugging. --- diff --git a/src/main.c b/src/main.c index 3273091..1130394 100644 --- a/src/main.c +++ b/src/main.c @@ -165,6 +165,30 @@ static int reply_add_keyval (mt_reply_t *r, const char *key, /* {{{ */ return (0); } /* }}} int reply_add_keyval */ +static void reply_dump (const mt_reply_t *r) /* {{{ */ +{ + if (r == NULL) + return; + + printf ("=== BEGIN REPLY ===\n" + "Address: %p\n" + "Status: %s\n", + (void *) r, r->status); + if (r->params_num > 0) + { + unsigned int i; + + printf ("Arguments:\n"); + for (i = 0; i < r->params_num; i++) + printf (" %3u: %s = %s\n", i, r->keys[i], r->values[i]); + } + if (r->next != NULL) + printf ("Next: %p\n", (void *) r->next); + printf ("=== END REPLY ===\n"); + + reply_dump (r->next); +} /* }}} void reply_dump */ + static void reply_free (mt_reply_t *r) /* {{{ */ { mt_reply_t *next; @@ -598,6 +622,7 @@ static int login2_handler (mt_connection_t *c, const mt_reply_t *r, /* {{{ */ return (EINVAL); printf ("login2_handler has been called.\n"); + reply_dump (r); return (0); } /* }}} int login2_handler */ @@ -671,6 +696,7 @@ static int login_handler (mt_connection_t *c, const mt_reply_t *r, /* {{{ */ return (EINVAL); printf ("login_handler has been called.\n"); + reply_dump (r); login_data = user_data; if (login_data == NULL)