aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/upas/nfs/main.c
blob: ebcf701cab1116697b005a439a55f9319405d3f4 (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
77
78
79
80
81
82
83
84
85
/*
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] [-m mtpt] [-s srvname] [-r root] [-u user] server\n");
	threadexitsall("usage");
}

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

	srvname = "mail";
	root = "";
	mode = Unencrypted;
	mtpt = nil;
	user = nil;
	ARGBEGIN{
	default:
		usage();
	case 'D':
		chatty9p++;
		break;
	case 'V':
		chattyimap++;
		break;
	case 'm':
		mtpt = EARGF(usage());
		break;
	case 's':
		srvname = EARGF(usage());
		break;
	case 't':
		mode = Tls;
		break;
	case 'u':
		user = EARGF(usage());
		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, user)) == nil)
		sysfatal("imapconnect: %r");
	threadpostmountsrv(&fs, srvname, mtpt, 0);
}