Revert "serv_rssclient.c: style update"
[citadel.git] / webcit / scripts / get_ical_data.sh
diff --git a/webcit/scripts/get_ical_data.sh b/webcit/scripts/get_ical_data.sh
new file mode 100755 (executable)
index 0000000..da7cbac
--- /dev/null
@@ -0,0 +1,112 @@
+#!/bin/sh
+
+echo Running $0
+
+# Find our copy of sed , it might be called "gsed" on FreeBSD
+if gsed --version >/dev/null 2>&1 ; then
+       SED=`which gsed`
+elif sed --version >/dev/null 2>&1 ; then
+       SED=`which sed`
+else
+       sed: not found
+       exit 1
+fi
+
+echo sed is ${SED}
+
+
+ICAL=/usr/local/ctdlsupport/include/libical/ical.h
+if test -f /usr/include/libical/ical.h; then 
+    ICAL=/usr/include/libical/ical.h
+elif test -f /usr/local/include/libical/ical.h; then
+       ICAL=/usr/local/include/libical/ical.h
+fi
+
+if test ! -f ${ICAL}; then 
+    echo "failed to locate libical headers - please install the libical development packages or heardes"
+    exit 500
+fi
+
+ICALTYPES="icalproperty_kind"\
+" icalcomponent_kind"\
+" icalrequeststatus"\
+" ical_unknown_token_handling"\
+" icalrecurrencetype_frequency"\
+" icalrecurrencetype_weekday"\
+" icalvalue_kind"\
+" icalproperty_action"\
+" icalproperty_carlevel"\
+" icalproperty_class"\
+" icalproperty_cmd"\
+" icalproperty_method"\
+" icalproperty_querylevel"\
+" icalproperty_status"\
+" icalproperty_transp"\
+" icalproperty_xlicclass"\
+" icalparameter_kind"\
+" icalparameter_action"\
+" icalparameter_cutype"\
+" icalparameter_enable"\
+" icalparameter_encoding"\
+" icalparameter_fbtype"\
+" icalparameter_local"\
+" icalparameter_partstat"\
+" icalparameter_range"\
+" icalparameter_related"\
+" icalparameter_reltype"\
+" icalparameter_role"\
+" icalparameter_rsvp"\
+" icalparameter_value"\
+" icalparameter_xliccomparetype"\
+" icalparameter_xlicerrortype"\
+" icalparser_state"\
+" icalerrorenum"\
+" icalerrorstate"\
+" icalrestriction_kind"
+
+(
+    printf '#include "webcit.h"\n\n\n'
+
+    for icaltype in $ICALTYPES; do 
+       printf "typedef struct _Ical_${icaltype} {\n"\
+"      const char *Name;\n"\
+"      long NameLen;\n"\
+"      ${icaltype} map;\n"\
+"} Ical_${icaltype};\n\n\n"
+
+    done
+
+    for icaltype in $ICALTYPES; do 
+       cat ./scripts/get_ical_data__template.sed | \
+           ${SED} -e "s;__ICALTYPE__;$icaltype;g" > \
+           /tmp/get_ical_data.sed
+    
+       printf "Ical_${icaltype} ${icaltype}_map[] = {\n"
+       cat ${ICAL} |\
+${SED} -e 's;/\*.*\*/;;' -e 's;\t;;g' |\
+${SED} -nf /tmp/get_ical_data.sed |\
+${SED} -e "s;.*typedef *enum *${icaltype} *{\(.*\)} ${icaltype} *\;.*;\1,;" \
+           -e 's;/\*.*\*/;;' \
+           -e 's;/;\n/\n;g' \
+           -e 's;,;,\n;g' \
+           -e 's; *;;g' \
+           -e 's;^t*;;g' \
+           -e 's;\=[0-9]*;;g'|\
+${SED} -e 's;\(.*\),;{HKEY("\1"), \1},;'
+       printf '{"", 0, 0}\n};\n\n\n' 
+       
+    done
+
+
+    printf "void \nInitModule_ICAL_MAPS\n(void)\n{\n\tint i;\n"
+    for icaltype in $ICALTYPES; do 
+       printf "\tfor (i=0; ${icaltype}_map[i].NameLen > 0; i++)\n"\
+"              RegisterTokenParamDefine (\n"\
+"                      ${icaltype}_map[i].Name,\n"\
+"                      ${icaltype}_map[i].NameLen,\n"\
+"                      ${icaltype}_map[i].map);\n"\
+
+    done
+    printf "\n}\n\n"
+
+) > ical_maps.c