--- a/mailnews/base/src/nsMsgUtils.h
+++ b/mailnews/base/src/nsMsgUtils.h
@@ -438,9 +438,118 @@ void MsgLogToConsole4(const nsAString& a
} while (0)
/**
* Perform C-style string escaping. E.g. "foo\r\n" => "foo\\r\\n"
* This is primarily intended for debuggin purposes.
*/
nsCString CEscapeString(nsACString const& s);
+/*
+ *
+ * PSTREAM(p) value: p=0x%08x in func at line of filename
+ * PSTREAM2(p,msg) value: p=0x%08x 'msg' at in func at line of filename
+ * ASSIGNSTREAM(p, q) assigning: p=0x%08x <- q=%08x in function at line of
+ * filename
+ * ASSIGNSREAM2(p, q, msg) assign: p=0x%08x <- q=%08x 'msg' in function
+ * at line of filename
+ * CLOSESTREAM(p) closing: p (0x%08x)->Close() in
+ * function at line of filename
+ * CLOSESTREAM2(p, msg) closing: p * (0x%08x)->Close()
+ * 'msg' in function at line of filename
+ */
+
+#ifdef DEBUG
+# define PSTREAM(p) \
+ do { \
+ fflush(stdout); \
+ fprintf(stderr, "{streamdebug} value: %s = %p in %s at line %d of %s\n", \
+ #p, (void *)p, __func__, __LINE__, __FILE__); \
+ } while (0)
+
+# define PSTREAM2(p, msg) \
+ do { \
+ fflush(stdout); \
+ fprintf(stderr, \
+ "{streamdebug} value: %s = %p '%s' in %s at line %d of %s\n", \
+ #p, (void *)p, msg, __func__, __LINE__, __FILE__); \
+ } while (0)
+
+# define ASSIGNSTREAM(p, q) \
+ do { \
+ fflush(stdout); \
+ fprintf(stderr, \
+ "{streamdebug} assigning: %s (= %p ) <- %s (= %p ) in %s at " \
+ "line %d " \
+ "of %s\n", \
+ #p, (void *)p, #q, (void *)q, __func__, __LINE__, __FILE__); \
+ } while (0)
+
+# define ASSIGNSTREAM2(p, q, msg) \
+ do { \
+ fflush(stdout); \
+ fprintf( \
+ stderr, \
+ "{streamdebug} assigning: %s (= %p ) <- %s (= %p ) '%s' in %s at " \
+ "line %d of %s\n", \
+ #p, (void *)p, #q, (void *)q, msg, __func__, __LINE__, __FILE__); \
+ } while (0)
+
+# define CLOSESTREAM(p) \
+ do { \
+ fflush(stdout); \
+ fprintf(stderr, \
+ "{streamdebug} closing: %s (= %p )->Close() in %s at line %d " \
+ "of %s\n", \
+ #p, (void *)p, __func__, __LINE__, __FILE__); \
+ } while (0)
+
+# define CLOSESTREAM2(p, msg) \
+ do { \
+ fflush(stdout); \
+ fprintf( \
+ stderr, \
+ "{streamdebug} closing: %s (= %p )->Close() '%s' in %s at line %d " \
+ "of %s\n", \
+ #p, (void *)p, msg, __func__, __LINE__, __FILE__); \
+ } while (0)
+#else
+# define PSTREAM(p)
+# define PSTREAM2(p, msg)
+# define ASSIGNSTREAM(p, q)
+# define ASSIGNSTREAM2(p, q, msg)
+# define CLOSESTREAM(p)
+# define CLOSESTREAM2(p, msg)
#endif
+
+#ifdef DEBUG
+# ifdef DEBUG_TEST_PSTREAM
+# include <stdio.h>
+# include <unistd.h>
+struct A {
+ int a;
+ int b;
+ char c;
+} sa;
+
+struct B {
+ int a;
+ int b;
+ char c;
+} sb;
+
+int main(int argc, char *argv[]) {
+ struct A *p, *q;
+ p = &sa;
+ q = NULL;
+ PSTREAM(p);
+ PSTREAM2(p, "with message");
+ ASSIGNSTREAM(p, q);
+ ASSIGNSTREAM2(p, NULL, "with message");
+ CLOSESTREAM(p);
+ CLOSESTREAM2(p, "with message");
+ exit(0);
+}
+# endif
+#endif
+
+#endif
+