summaryrefslogtreecommitdiff
path: root/sys/src/cmd/wikifs/testwrite.c
diff options
context:
space:
mode:
authorTaru Karttunen <taruti@taruti.net>2011-03-30 15:46:40 +0300
committerTaru Karttunen <taruti@taruti.net>2011-03-30 15:46:40 +0300
commite5888a1ffdae813d7575f5fb02275c6bb07e5199 (patch)
treed8d51eac403f07814b9e936eed0c9a79195e2450 /sys/src/cmd/wikifs/testwrite.c
Import sources from 2011-03-30 iso image
Diffstat (limited to 'sys/src/cmd/wikifs/testwrite.c')
-rwxr-xr-xsys/src/cmd/wikifs/testwrite.c52
1 files changed, 52 insertions, 0 deletions
diff --git a/sys/src/cmd/wikifs/testwrite.c b/sys/src/cmd/wikifs/testwrite.c
new file mode 100755
index 000000000..86e418abb
--- /dev/null
+++ b/sys/src/cmd/wikifs/testwrite.c
@@ -0,0 +1,52 @@
+#include <u.h>
+#include <libc.h>
+#include <bio.h>
+#include <String.h>
+#include <thread.h>
+#include "wiki.h"
+
+char *wikidir = ".";
+
+void
+usage(void)
+{
+ fprint(2, "usage: testwrite [-d dir] wikifile n\n");
+ exits("usage");
+}
+
+void
+main(int argc, char **argv)
+{
+ ulong t;
+ int i;
+ Biobuf *b;
+ String *h;
+ Whist *doc;
+ char tmp[20];
+
+ t = 0;
+ ARGBEGIN{
+ case 't':
+ t = strtoul(EARGF(usage()), 0, 0);
+ break;
+ default:
+ usage();
+ }ARGEND
+
+ if(argc != 2)
+ usage();
+
+ if((b = Bopen(argv[0], OREAD)) == nil)
+ sysfatal("Bopen: %r");
+
+ if((doc = Brdwhist(b)) == nil)
+ sysfatal("Brdwtxt: %r");
+
+ sprint(tmp, "D%lud\n", time(0));
+ if((h = pagetext(s_copy(tmp), (doc->doc+doc->ndoc-1)->wtxt, 1))==nil)
+ sysfatal("wiki2text: %r");
+
+ if(writepage(atoi(argv[1]), t, h, doc->title) <0)
+ sysfatal("writepage: %r");
+ exits(0);
+}