validate_recipients() now strips out duplicate recipients ... probably some 15 years...
[citadel] / webcit / scripts / get_ical_data.sh
1 #!/bin/sh
2
3 echo Running $0
4
5
6 ICAL=/usr/local/ctdlsupport/include/libical/ical.h
7 if test -f /usr/include/libical/ical.h; then 
8     ICAL=/usr/include/libical/ical.h
9 fi
10
11 if test ! -f ${ICAL}; then 
12     echo "failed to locate libical headers - please install the libical development packages or heardes"
13     exit 500
14 fi
15
16 ICALTYPES="icalproperty_kind"\
17 " icalcomponent_kind"\
18 " icalrequeststatus"\
19 " ical_unknown_token_handling"\
20 " icalrecurrencetype_frequency"\
21 " icalrecurrencetype_weekday"\
22 " icalvalue_kind"\
23 " icalproperty_action"\
24 " icalproperty_carlevel"\
25 " icalproperty_class"\
26 " icalproperty_cmd"\
27 " icalproperty_method"\
28 " icalproperty_querylevel"\
29 " icalproperty_status"\
30 " icalproperty_transp"\
31 " icalproperty_xlicclass"\
32 " icalparameter_kind"\
33 " icalparameter_action"\
34 " icalparameter_cutype"\
35 " icalparameter_enable"\
36 " icalparameter_encoding"\
37 " icalparameter_fbtype"\
38 " icalparameter_local"\
39 " icalparameter_partstat"\
40 " icalparameter_range"\
41 " icalparameter_related"\
42 " icalparameter_reltype"\
43 " icalparameter_role"\
44 " icalparameter_rsvp"\
45 " icalparameter_value"\
46 " icalparameter_xliccomparetype"\
47 " icalparameter_xlicerrortype"\
48 " icalparser_state"\
49 " icalerrorenum"\
50 " icalerrorstate"\
51 " icalrestriction_kind"
52
53 (
54     printf '#include "webcit.h"\n\n\n'
55
56     for icaltype in $ICALTYPES; do 
57         printf "typedef struct _Ical_${icaltype} {\n"\
58 "       const char *Name;\n"\
59 "       long NameLen;\n"\
60 "       ${icaltype} map;\n"\
61 "} Ical_${icaltype};\n\n\n"
62
63     done
64
65     for icaltype in $ICALTYPES; do 
66         cat ./scripts/get_ical_data__template.sed | \
67             sed -e "s;__ICALTYPE__;$icaltype;g" > \
68             /tmp/get_ical_data.sed
69     
70         printf "Ical_${icaltype} ${icaltype}_map[] = {\n"
71         cat ${ICAL} |\
72 sed -e 's;/\*.*\*/;;' -e 's;\t;;g' |\
73 sed -nf /tmp/get_ical_data.sed |\
74 sed -e "s;.*typedef *enum *${icaltype} *{\(.*\)} ${icaltype} *\;.*;\1,;" \
75             -e 's;/\*.*\*/;;' \
76             -e 's;/;\n/\n;g' \
77             -e 's;,;,\n;g' \
78             -e 's; *;;g' \
79             -e 's;^t*;;g' \
80             -e 's;\=[0-9]*;;g'|\
81 sed -e 's;\(.*\),;{HKEY("\1"), \1},;'
82         printf '{"", 0, 0}\n};\n\n\n' 
83         
84     done
85
86
87     printf "void \nInitModule_ICAL_MAPS\n(void)\n{\n\tint i;\n"
88     for icaltype in $ICALTYPES; do 
89         printf "\tfor (i=0; ${icaltype}_map[i].NameLen > 0; i++)\n"\
90 "               RegisterTokenParamDefine (\n"\
91 "                       ${icaltype}_map[i].Name,\n"\
92 "                       ${icaltype}_map[i].NameLen,\n"\
93 "                       ${icaltype}_map[i].map);\n"\
94
95     done
96     printf "\n}\n\n"
97
98 ) > ical_maps.c