summaryrefslogtreecommitdiff
path: root/pim/rc/calendars
diff options
context:
space:
mode:
Diffstat (limited to 'pim/rc/calendars')
-rw-r--r--pim/rc/calendars38
1 files changed, 38 insertions, 0 deletions
diff --git a/pim/rc/calendars b/pim/rc/calendars
new file mode 100644
index 0000000..e1f191e
--- /dev/null
+++ b/pim/rc/calendars
@@ -0,0 +1,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