[Pkg-privacy-commits] [libotr] 105/225: Add the ability to dump *all* contexts

Ximin Luo infinity0 at moszumanska.debian.org
Sat Aug 22 12:45:05 UTC 2015


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch master
in repository libotr.

commit 6914b6bfc3b89bb6515db200c03f8a3df96a7227
Author: Ian Goldberg <iang at cs.uwaterloo.ca>
Date:   Fri Aug 24 15:52:58 2012 -0400

    Add the ability to dump *all* contexts
    
    If debugging is enabled, and you type ?OTR!!, all contexts will be
    dumped to stderr.
---
 src/context.c | 11 +++++++++++
 src/message.c | 22 +++++++++++++++++-----
 2 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/src/context.c b/src/context.c
index 3d4eae4..6b415a6 100644
--- a/src/context.c
+++ b/src/context.c
@@ -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. */
diff --git a/src/message.c b/src/message.c
index b9a743d..a28b98c 100644
--- a/src/message.c
+++ b/src/message.c
@@ -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;
 	}
     }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/libotr.git



More information about the Pkg-privacy-commits mailing list