aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/upas/fs/tester.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2005-10-29 16:26:44 +0000
committerrsc <devnull@localhost>2005-10-29 16:26:44 +0000
commit5cdb17983ae6e6367ad7a940cb219eab247a9304 (patch)
tree8ca1ef49af2a96e7daebe624d91fdf679814a057 /src/cmd/upas/fs/tester.c
parentcd3745196389579fb78b9b01ef1daefb5a57aa71 (diff)
downloadplan9port-5cdb17983ae6e6367ad7a940cb219eab247a9304.tar.gz
plan9port-5cdb17983ae6e6367ad7a940cb219eab247a9304.tar.bz2
plan9port-5cdb17983ae6e6367ad7a940cb219eab247a9304.zip
Thanks to John Cummings.
Diffstat (limited to 'src/cmd/upas/fs/tester.c')
-rw-r--r--src/cmd/upas/fs/tester.c81
1 files changed, 81 insertions, 0 deletions
diff --git a/src/cmd/upas/fs/tester.c b/src/cmd/upas/fs/tester.c
new file mode 100644
index 00000000..3d24012e
--- /dev/null
+++ b/src/cmd/upas/fs/tester.c
@@ -0,0 +1,81 @@
+#include <u.h>
+#include <libc.h>
+#include <ctype.h>
+#include <String.h>
+#include "message.h"
+
+Message *root;
+
+void
+prindent(int i)
+{
+ for(; i > 0; i--)
+ print(" ");
+}
+
+void
+prstring(int indent, char *tag, String *s)
+{
+ if(s == nil)
+ return;
+ prindent(indent+1);
+ print("%s %s\n", tag, s_to_c(s));
+}
+
+void
+info(int indent, int mno, Message *m)
+{
+ int i;
+ Message *nm;
+
+ prindent(indent);
+ print("%d%c %d ", mno, m->allocated?'*':' ', m->end - m->start);
+ if(m->unixfrom != nil)
+ print("uf %s ", s_to_c(m->unixfrom));
+ if(m->unixdate != nil)
+ print("ud %s ", s_to_c(m->unixdate));
+ print("\n");
+ prstring(indent, "from:", m->from822);
+ prstring(indent, "sender:", m->sender822);
+ prstring(indent, "to:", m->to822);
+ prstring(indent, "cc:", m->cc822);
+ prstring(indent, "reply-to:", m->replyto822);
+ prstring(indent, "subject:", m->subject822);
+ prstring(indent, "date:", m->date822);
+ prstring(indent, "filename:", m->filename);
+ prstring(indent, "type:", m->type);
+ prstring(indent, "charset:", m->charset);
+
+ i = 1;
+ for(nm = m->part; nm != nil; nm = nm->next){
+ info(indent+1, i++, nm);
+ }
+}
+
+
+void
+main(int argc, char **argv)
+{
+ char *err;
+ char *mboxfile;
+
+ ARGBEGIN{
+ }ARGEND;
+
+ if(argc > 0)
+ mboxfile = argv[0];
+ else
+ mboxfile = "./mbox";
+
+ root = newmessage(nil);
+
+ err = readmbox(mboxfile, &root->part);
+ if(err != nil){
+ fprint(2, "boom: %s\n", err);
+ exits(0);
+ }
+
+ info(0, 1, root);
+
+ exits(0);
+}