Commit 6914b6bf authored by Ian Goldberg's avatar Ian Goldberg
Browse files

Add the ability to dump *all* contexts

If debugging is enabled, and you type ?OTR!!, all contexts will be
dumped to stderr.
parent 176afffe
...@@ -106,6 +106,17 @@ void otrl_context_siblings_dump(FILE *f, const ConnContext *context) ...@@ -106,6 +106,17 @@ void otrl_context_siblings_dump(FILE *f, const ConnContext *context)
otrl_context_dump(f, citer); otrl_context_dump(f, citer);
} }
} }
/* Dump all contexts. */
void otrl_context_all_dump(FILE *f, OtrlUserState us)
{
const ConnContext *citer;
unsigned int ctxnum = 1;
for (citer = us->context_root; citer; citer = citer->next, ++ctxnum) {
fprintf(f, "%u. ", ctxnum);
otrl_context_dump(f, citer);
}
}
#endif #endif
/* Create a new connection context. */ /* Create a new connection context. */
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
* context and its siblings will be dumped to stderr. */ * context and its siblings will be dumped to stderr. */
const char *OTRL_DEBUGGING_DEBUGSTR = "?OTR!"; const char *OTRL_DEBUGGING_DEBUGSTR = "?OTR!";
void otrl_context_all_dump(FILE *f, OtrlUserState us);
void otrl_context_siblings_dump(FILE *f, const ConnContext *context); void otrl_context_siblings_dump(FILE *f, const ConnContext *context);
#endif #endif
...@@ -253,12 +254,23 @@ gcry_error_t otrl_message_sending(OtrlUserState us, ...@@ -253,12 +254,23 @@ gcry_error_t otrl_message_sending(OtrlUserState us,
#if OTRL_DEBUGGING #if OTRL_DEBUGGING
/* If the user typed the magic debug string, dump this context and /* If the user typed the magic debug string, dump this context and
* its siblings. */ * its siblings. */
if (strstr(original_msg, OTRL_DEBUGGING_DEBUGSTR)) { {
otrl_context_siblings_dump(stderr, context); const char *debugtag = strstr(original_msg, OTRL_DEBUGGING_DEBUGSTR);
if (debugtag) {
const char *debugargs =
debugtag + strlen(OTRL_DEBUGGING_DEBUGSTR);
if (debugargs[0] == '!') { /* typed ?OTR!! */
otrl_context_all_dump(stderr, us);
} else { /* typed ?OTR! without extra command chars */
otrl_context_siblings_dump(stderr, context);
}
*messagep = strdup(""); /* Don't actually send the message */
if (!(*messagep)) { *messagep = strdup("");
err = gcry_error(GPG_ERR_ENOMEM); if (!(*messagep)) {
err = gcry_error(GPG_ERR_ENOMEM);
}
goto fragment; goto fragment;
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment