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

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)
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
/* Create a new connection context. */
......
......@@ -42,6 +42,7 @@
* context and its siblings will be dumped to stderr. */
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);
#endif
......@@ -253,12 +254,23 @@ gcry_error_t otrl_message_sending(OtrlUserState us,
#if OTRL_DEBUGGING
/* If the user typed the magic debug string, dump this context and
* 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("");
if (!(*messagep)) {
err = gcry_error(GPG_ERR_ENOMEM);
/* Don't actually send the message */
*messagep = strdup("");
if (!(*messagep)) {
err = gcry_error(GPG_ERR_ENOMEM);
}
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