summaryrefslogtreecommitdiff
path: root/sys/src/cmd/webfs/main.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/webfs/main.c
Import sources from 2011-03-30 iso image
Diffstat (limited to 'sys/src/cmd/webfs/main.c')
-rwxr-xr-xsys/src/cmd/webfs/main.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/sys/src/cmd/webfs/main.c b/sys/src/cmd/webfs/main.c
new file mode 100755
index 000000000..0792dbf13
--- /dev/null
+++ b/sys/src/cmd/webfs/main.c
@@ -0,0 +1,67 @@
+#include <u.h>
+#include <libc.h>
+#include <bio.h>
+#include <ip.h>
+#include <plumb.h>
+#include <thread.h>
+#include <fcall.h>
+#include <9p.h>
+#include "dat.h"
+#include "fns.h"
+
+char *cookiefile;
+char *mtpt = "/mnt/web";
+char *service;
+
+Ctl globalctl =
+{
+ 1, /* accept cookies */
+ 1, /* send cookies */
+ 10, /* redirect limit */
+ "webfs/2.0 (plan 9)" /* user agent */
+};
+
+void
+usage(void)
+{
+ fprint(2, "usage: webfs [-c cookies] [-m mtpt] [-s service]\n");
+ threadexitsall("usage");
+}
+
+#include <pool.h>
+void
+threadmain(int argc, char **argv)
+{
+ rfork(RFNOTEG);
+ ARGBEGIN{
+ case 'd':
+ mainmem->flags |= POOL_PARANOIA|POOL_ANTAGONISM;
+ break;
+ case 'D':
+ chatty9p++;
+ break;
+ case 'c':
+ cookiefile = EARGF(usage());
+ break;
+ case 'm':
+ mtpt = EARGF(usage());
+ break;
+ case 's':
+ service = EARGF(usage());
+ break;
+ default:
+ usage();
+ }ARGEND
+
+ quotefmtinstall();
+ if(argc != 0)
+ usage();
+
+ plumbinit();
+ globalctl.useragent = estrdup(globalctl.useragent);
+ initcookies(cookiefile);
+ initurl();
+ initfs();
+ threadpostmountsrv(&fs, service, mtpt, MREPL);
+ threadexits(nil);
+}