summaryrefslogtreecommitdiff
path: root/pim/rc/calendars
blob: e1f191e9e0af488a95b3eb1021fff8d345c78db7 (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
#!/bin/rc
# pim/calendars -- name every mounted calendar, one per line.
#
# rc globs only metacharacters written literally in the source, so a
# pattern held in a variable will not expand.  Every tool that works
# across calendars enumerates them through here instead.
rfork e

mtpt=/mnt/pim
long=()
while(~ $1 -*){
	switch($1){
	case -m
		mtpt=$2; shift
	case -l
		long=1
	case *
		echo 'usage: calendars [-m mtpt] [-l]' >[1=2]
		exit usage
	}
	shift
}
# mntgen leaves the directory behind when a server goes away, so an
# empty name is not a calendar. A live one answers for ctl.
for(c in `{ls -p $mtpt/calendars >[2]/dev/null})
	if(test -f $mtpt/calendars/$c/ctl){
		if(~ $#long 0)
			echo $c
		if(! ~ $#long 0){
			# caps says what the backend can do: a published .ics is
			# read-only, with no iMIP path and nothing to write to
			caps=`{sed -n 's/^caps //p' $mtpt/calendars/$c/ctl}
			if(~ $#caps 0)
				caps=unknown
			echo $c^'	'^$"caps
		}
	}
exit 0