]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/webfs/main.c
cwfs: back to previous version
[plan9front.git] / sys / src / cmd / webfs / main.c
1 #include <u.h>
2 #include <libc.h>
3 #include <bio.h>
4 #include <ip.h>
5 #include <plumb.h>
6 #include <thread.h>
7 #include <fcall.h>
8 #include <9p.h>
9 #include "dat.h"
10 #include "fns.h"
11
12 char *cookiefile;
13 char *mtpt = "/mnt/web";
14 char *service;
15
16 Ctl globalctl = 
17 {
18         1,      /* accept cookies */
19         1,      /* send cookies */
20         10,     /* redirect limit */
21         "webfs/2.0 (plan 9)"    /* user agent */
22 };
23
24 void
25 usage(void)
26 {
27         fprint(2, "usage: webfs [-c cookies] [-m mtpt] [-s service]\n");
28         threadexitsall("usage");
29 }
30
31 #include <pool.h>
32 void
33 threadmain(int argc, char **argv)
34 {
35         rfork(RFNOTEG);
36         ARGBEGIN{
37         case 'd':
38                 mainmem->flags |= POOL_PARANOIA|POOL_ANTAGONISM;
39                 break;
40         case 'D':
41                 chatty9p++;
42                 break;
43         case 'c':
44                 cookiefile = EARGF(usage());
45                 break;
46         case 'm':
47                 mtpt = EARGF(usage());
48                 break;
49         case 's':
50                 service = EARGF(usage());
51                 break;
52         default:
53                 usage();
54         }ARGEND
55
56         quotefmtinstall();
57         if(argc != 0)
58                 usage();
59
60         plumbinit();
61         globalctl.useragent = estrdup(globalctl.useragent);
62         initcookies(cookiefile);
63         initurl();
64         initfs();
65         threadpostmountsrv(&fs, service, mtpt, MREPL);
66         threadexits(nil);
67 }