blob: 353ca4fadc498bc8a37d774deb71ab17d9241d64 (
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
86
87
|
#!/bin/rc
# pim/who -- who you met with, over a range of days.
#
# pim/who the last seven days
# pim/who -n 30 the last thirty
# pim/who -a only those who accepted
# pim/who -x calvinm leave yourself out
rfork e
mtpt=/mnt/pim
days=7
only=()
me=()
acc=()
while(~ $1 -*){
switch($1){
case -m
mtpt=$2; shift
case -n
days=$2; shift
case -x
me=$2; shift
case -a
acc=1
case -c
only=($only $2); shift
case *
echo 'usage: who [-m mtpt] [-n days] [-x me] [-a]' >[1=2]
exit usage
}
shift
}
now=`{date -n}
from=`{date -i `{echo $now - $days '*' 86400 | bc}}
to=`{date -i `{echo $now + 86400 | bc}}
cals=$only
if(~ $#cals 0)
cals=`{pim/calendars -m $mtpt}
# Who counts as you comes from the calendar's me= in the config, which
# the server reports in ctl. -x adds to it.
ex=/tmp/who.ex.$pid
fn sigexit { rm -f $ex $tmp }
>$ex
if(! ~ $#me 0)
echo $me >>$ex
for(c in $cals)
sed -n 's/^cal .* me //p' $mtpt/calendars/$c/ctl >[2]/dev/null |
tr , ' ' | tr ' ' '
' >>$ex
grep -v '^$' $ex >$ex^.t; mv $ex^.t $ex
hits=()
for(c in $cals){
echo 'from='^$"from^' to='^$"to >$mtpt/calendars/$c/query
for(r in `{cat $mtpt/calendars/$c/query})
hits=($hits $mtpt/calendars/$c/$r)
}
if(~ $#hits 0){
echo 'nobody, in the last '^$"days^' days'
exit 0
}
fn people {
for(h in $hits){
d=`{basename -d $h}
ev=`{sed -n 's/^event: //p' $h}
if(! ~ $#ev 0){
f=$d/$"ev/attendees
if(test -f $f){
if(~ $#acc 0)
awk -F'\t' 'NF>2{print $3}' $f
if(! ~ $#acc 0)
awk -F'\t' 'NF>2 && $1 ~ /ACCEPTED/{print $3}' $f
}
}
}
}
if(test -s $ex)
people | grep -v -f $ex | sort | uniq -c | sort -nr
if(! test -s $ex)
people | sort | uniq -c | sort -nr
exit 0
|