File: scan.c

package info (click to toggle)
tra 20020816-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, sarge
  • size: 1,696 kB
  • ctags: 2,623
  • sloc: ansic: 22,519; makefile: 406; asm: 269
file content (62 lines) | stat: -rw-r--r-- 893 bytes parent folder | download
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
#include "tra.h"

Replica *repl;

static Path*
strtopath(char *s)
{
	char *f[20];
	int i, nf;
	Path *p;

	nf = getfields(s, f, nelem(f), 1, "/");
	p = nil;
	for(i=0; i<nf; i++)
		p = mkpath(p, f[i]);
	return p;
}

void
usage(void)
{
	fprint(2, "usage: scan replica [path...]\n");
	exits("usage");
}

void
threadmain(int argc, char **argv)
{
	int i;

	fmtinstall('H', encodefmt);
	fmtinstall('P', pathfmt);
	fmtinstall('$', statfmt);
	fmtinstall('V', vtimefmt);

	ARGBEGIN{
	default:
		usage();
	}ARGEND

	if(argc < 1)
		usage();

	startclient();
	repl = dialreplica(argv[0]);
	threadcreate(replthread, repl);
	
	argc--;
	argv++;
	if(argc == 0){
		if(rpcstat(repl, nil) == nil)
			sysfatal("rpcstat: %s", rpcerror());
	}else{
		for(i=0; i<argc; i++)
			if(rpcstat(repl, strtopath(argv[i])) == nil)
				sysfatal("rpcstat: %s", rpcerror());
	}
	rpchangup(repl);
	replclose(repl);
	exits(nil);
}