aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/upas/nfs/main.c
blob: 121d97461fdbdc4372473f36e4768a089b5d1840 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
TO DO

can get disposition info out of imap extended structure if needed
sizes in stat/ls ?
translate character sets in =? subjects

fetch headers, bodies on demand

cache headers, bodies on disk

cache message information on disk across runs

body.jpg

*/

#include "a.h"

Imap *imap;

void
usage(void)
{
	fprint(2, "usage: mailfs [-DVtx] [-s srvname] [-r root] server\n");
	threadexitsall("usage");
}

void
threadmain(int argc, char **argv)
{
	char *server, *srvname, *root;
	int mode;

	srvname = "mail";
	root = "";
	mode = Unencrypted;
	ARGBEGIN{
	default:
		usage();
	case 'D':
		chatty9p++;
		break;
	case 'V':
		chattyimap++;
		break;
	case 's':
		srvname = EARGF(usage());
		break;
	case 't':
		mode = Tls;
		break;
	case 'x':
		mode = Cmd;
		break;
	case 'r':
		root = EARGF(usage());
		break;
	}ARGEND

	quotefmtinstall();	
	fmtinstall('$', sxfmt);

	if(argc != 1)
		usage();
	server = argv[0];
	
	mailthreadinit();
	boxinit();
	fsinit0();

	if((imap = imapconnect(server, mode, root)) == nil)
		sysfatal("imapconnect: %r");
	threadpostmountsrv(&fs, srvname, nil, 0);
}