$OpenBSD: patch-src_tz_zoneinfo_read_c,v 1.1 2011/01/19 17:19:20 landry Exp $
cherrypick commit for orage 4.8.0.1
fixes from http://bugzilla.xfce.org/show_bug.cgi?id=7141
--- src/tz_zoneinfo_read.c.orig	Thu Jan 13 14:09:46 2011
+++ src/tz_zoneinfo_read.c	Wed Jan 19 14:15:33 2011
@@ -23,7 +23,6 @@
 #include <config.h>
 #endif
 
-#include <error.h>
 #include <errno.h>
     /* errno */
 
@@ -56,6 +55,11 @@
 #define __USE_GNU 1
 #include <ftw.h>
     /* nftw */
+#ifndef FTW_ACTIONRETVAL
+/* BSD systems lack FTW_ACTIONRETVAL, so we need to define needed
+ * things like FTW_CONTINUE locally */
+#define FTW_CONTINUE 0
+#endif
 
 #define DEFAULT_OS_ZONEINFO_DIRECTORY  "/usr/share/zoneinfo"
 #define ZONETAB_FILE        "zone.tab"
@@ -568,6 +572,7 @@ static int file_call(const char *file_name, const stru
     else if (flags == FTW_D) { /* this is directory */
         if (debug > 0)
             printf("\tfile_call: processing directory=(%s)\n", file_name);
+#ifdef FTW_ACTIONRETVAL
         /* need to check if we have excluded directory */
         for (i = 0; (i <= excl_dir_cnt) && excl_dir[i]; i++) {
             if (strcmp(excl_dir[i],  file_name+f->base) == 0) {
@@ -577,6 +582,12 @@ static int file_call(const char *file_name, const stru
                 return(FTW_SKIP_SUBTREE);
             }
         }
+#else
+        /* not easy to do that in BSD, where we do not have FTW_ACTIONRETVAL
+           features. It can be done by checking differently */
+    if (debug > 0)
+        printf("FIXME: this directory should be skipped\n");
+#endif
     }
     else if (flags == FTW_SL) {
         if (debug > 0) {
@@ -791,7 +802,7 @@ static void read_countries(void)
     tz_dir = malloc(in_file_base_offset + zoneinfo_len + 1); /* '\0' */
     strncpy(tz_dir, in_file, in_file_base_offset);
     tz_dir[in_file_base_offset] = '\0'; 
-    strcat(tz_dir, "zoneinfo/"); /* now we have the base directory */
+    strcat(tz_dir, "misc/"); /* now we have the base directory */
 
     country_file_name = malloc(strlen(tz_dir) + strlen(COUNTRY_FILE) + 1);
     strcpy(country_file_name, tz_dir);
@@ -868,7 +879,7 @@ static void read_ical_timezones(void)
 
 orage_timezone_array get_orage_timezones(int show_details, int ical)
 {
-    int tz_array_size = 1000; /* FIXME: this needs to be counted */
+    int tz_array_size = 2000; /* FIXME: this needs to be counted */
     /*
      icalarray *tz_array;
      icaltimezone *l_tz;
@@ -903,8 +914,13 @@ orage_timezone_array get_orage_timezones(int show_deta
         }
     /* nftw goes through the whole file structure and calls "file_call"
      * with each file. It returns 0 when everything has been done and -1
-     * if it run into an error. */
+     * if it run into an error. 
+     * BSD lacks FTW_ACTIONRETVAL, so we only use it when available. */
+#ifdef FTW_ACTIONRETVAL
         if (nftw(in_file, file_call, 10, FTW_PHYS | FTW_ACTIONRETVAL) == -1) {
+#else
+        if (nftw(in_file, file_call, 10, FTW_PHYS) == -1) {
+#endif
             perror("nftw error in file handling");
             exit(EXIT_FAILURE);
         }
