AC_PATH_PROG(CMP, cmp, cmp)
 AC_PATH_PROG(TBL, tbl, tbl)
 AC_PATH_PROG(AR, ar, ar)
-AC_PATH_PROG(RANLIB, ranlib, ranlib)
+dnl AC_PATH_PROG(RANLIB, ranlib, ranlib)
 AC_PATH_PROG(OPENSSL, openssl, none)
 AC_PATH_PROG(MTX, mtx, mtx)
 AC_PATH_PROG(PKGCONFIG, pkg-config, pkg-config)
 
 echo "${ECHO_T}no" >&6
 fi
 
-# Extract the first word of "ranlib", so it can be a program name with args.
-set dummy ranlib; ac_word=$2
-echo "$as_me:$LINENO: checking for $ac_word" >&5
-echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
-if test "${ac_cv_path_RANLIB+set}" = set; then
-  echo $ECHO_N "(cached) $ECHO_C" >&6
-else
-  case $RANLIB in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_RANLIB="$RANLIB" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-  for ac_exec_ext in '' $ac_executable_extensions; do
-  if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_path_RANLIB="$as_dir/$ac_word$ac_exec_ext"
-    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-done
-
-  test -z "$ac_cv_path_RANLIB" && ac_cv_path_RANLIB="ranlib"
-  ;;
-esac
-fi
-RANLIB=$ac_cv_path_RANLIB
-
-if test -n "$RANLIB"; then
-  echo "$as_me:$LINENO: result: $RANLIB" >&5
-echo "${ECHO_T}$RANLIB" >&6
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
-fi
-
 # Extract the first word of "openssl", so it can be a program name with args.
 set dummy openssl; ac_word=$2
 echo "$as_me:$LINENO: checking for $ac_word" >&5
 
 #ifndef _BACULA_H
 #define _BACULA_H 1
 
+#ifdef __cplusplus
+/* Workaround for SGI IRIX 6.5 */
+#define _LANGUAGE_C_PLUS_PLUS 1
+#endif
+
 #ifdef HAVE_WIN32
 #include "winconfig.h"
 #include "winhost.h"
 
 void senditf(const char *fmt, ...);
 void sendit(const char *buf);
 
+extern "C" void got_sigstop(int sig);
+extern "C" void got_sigcontinue(int sig);
+extern "C" void got_sigtout(int sig);
+extern "C" void got_sigtin(int sig);
+
+
 /* Static variables */
 static char *configfile = NULL;
 static BSOCK *UA_sock = NULL;
 "\n"), HOST_OS, DISTNAME, DISTVER);
 }
 
+
+extern "C" 
 void got_sigstop(int sig)
 {
    stop = true;
 }
 
+extern "C" 
 void got_sigcontinue(int sig)
 {
    stop = false;
 }
 
+extern "C" 
 void got_sigtout(int sig) 
 {
 // printf("Got tout\n");
 }
 
+extern "C" 
 void got_sigtin(int sig)
 {   
 // printf("Got tin\n");
 }
 
+
 static int zed_keyscmd(FILE *input, BSOCK *UA_sock)
 {
    con_set_zed_keys();
    tv.tv_usec = 0;
    for ( ;; ) {
       FD_ZERO(&fdset);
-      FD_SET(fd, &fdset);
+      FD_SET((unsigned)fd, &fdset);
       switch(select(fd + 1, &fdset, NULL, NULL, &tv)) {
       case 0:                        /* timeout */
         return 0;
 
 static int check_resources();
 
 /* Exported subroutines */
-void reload_config(int sig);
+
+extern "C" void reload_config(int sig);
 
 
 /* Imported subroutines */
  * If we get here, we have received a SIGHUP, which means to
  *    reread our configuration file. 
  */
+extern "C"
 void reload_config(int sig)
 {
    static bool already_here = false;
 
 
 
 /* Forward referenced functions */
-static void *jobq_server(void *arg);
+extern "C" void *jobq_server(void *arg);
+extern "C" void *sched_wait(void *arg);
+
 static int   start_server(jobq_t *jq);
 
 /*   
  *  most jobs are put into the job queue only when their
  *  scheduled time arives.
  */
-static void *sched_wait(void *arg)
+extern "C"  
+void *sched_wait(void *arg)
 {
    JCR *jcr = ((wait_pkt *)arg)->jcr;
    jobq_t *jq = ((wait_pkt *)arg)->jq;
    return NULL;
 }
 
-
 /*
  *  Add a job to the queue
  *    jq is a queue that was created with jobq_init
  * When all the resources are acquired for the job, 
  *  it will call the user's engine.
  */
-static void *jobq_server(void *arg)
+extern "C"  
+void *jobq_server(void *arg)
 {
    struct timespec timeout;
    jobq_t *jq = (jobq_t *)arg;
 
 static char Job_status[] = "3012 Job %127s jobstatus %d\n";
 
 /* Forward referenced functions */
-static void *msg_thread(void *arg);
+extern "C" void *msg_thread(void *arg);
 
 /*
  * Establish a message channel connection with the Storage daemon
    return 1;
 }
 
-static void msg_thread_cleanup(void *arg)
+extern "C" void msg_thread_cleanup(void *arg)
 {
    JCR *jcr = (JCR *)arg;
    Dmsg0(200, "End msg_thread\n");
  *  Storage daemon).
  * Note, we are running in a separate thread.
  */
-static void *msg_thread(void *arg)
+extern "C"
+void *msg_thread(void *arg)
 {
    JCR *jcr = (JCR *)arg;
    BSOCK *sd;
 
 /*
  * reload the conf file
  */
-extern void reload_config(int sig);
+extern "C" void reload_config(int sig);
 
 static int reload_cmd(UAContext *ua, const char *cmd)
 {
 
 
 /* Forward referenced functions */
 
-static void *connect_thread(void *arg);
+extern "C" void *connect_thread(void *arg);
+
 static void *handle_UA_client_request(void *arg);
 
 
    return;
 }
 
-static void *connect_thread(void *arg)
+extern "C" 
+void *connect_thread(void *arg)
 {
    struct s_addr_port *UA = (struct s_addr_port *)arg;
 
 
 #define WAIT_INTERVAL 60
 #endif
 
+extern "C" void *sd_heartbeat_thread(void *arg);
+extern "C" void *dir_heartbeat_thread(void *arg);
+
+
 /* 
  * Listen on the SD socket for heartbeat signals.
  * Send heartbeats to the Director every HB_TIME
  *   seconds.
  */
-static void *sd_heartbeat_thread(void *arg)
+extern "C" void *sd_heartbeat_thread(void *arg)
 {
    int32_t n;
    JCR *jcr = (JCR *)arg;
  *   is no SD monitoring needed -- e.g. restore and verify Vol
  *   both do their own read() on the SD socket.
  */
-static void *dir_heartbeat_thread(void *arg)
+extern "C" void *dir_heartbeat_thread(void *arg)
 {
    JCR *jcr = (JCR *)arg;
    BSOCK *dir;
    jcr->hb_bsock = NULL;
    return NULL;
 }
+
 /*
  * Same as above but we don't listen to the SD
  */
 
 
       Dmsg2(100, "adj = %d since_time=%d\n", (int)adj, (int)since_time);
       jcr->incremental = 1;          /* set incremental or decremental backup */
-      jcr->mtime = since_time;       /* set since time */
+      jcr->mtime = (time_t)since_time; /* set since time */
    } else {
       Jmsg1(jcr, M_FATAL, 0, "Unknown backup level: %s\n", level);
       free_memory(level);
    Dmsg3(110, "Open storage: %s:%d ssl=%d\n", jcr->stored_addr, stored_port, enable_ssl);
    /* Open command communications with Storage daemon */
    /* Try to connect for 1 hour at 10 second intervals */
-   sd = bnet_connect(jcr, 10, me->SDConnectTimeout, _("Storage daemon"), 
+   sd = bnet_connect(jcr, 10, (int)me->SDConnectTimeout, _("Storage daemon"), 
                     jcr->stored_addr, NULL, stored_port, 1);
    Dmsg0(110, "Connection OK to SD.\n");
    if (sd == NULL) {
 
          case 'A':
            inc->options |= FO_ACL;
            break;
-        case 'Z':                 /* gzip compression */
+         case 'Z':                 /* gzip compression */
            inc->options |= FO_GZIP;
             inc->level = *++rp - '0';
             Dmsg1(200, "Compression level=%d\n", inc->level);
    int len;
    struct s_excluded_file *exc, **list;
 
-#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
-   /* Convert any \'s into /'s */
-   for (char *p=fname; *p; p++) {
-      if (*p == '\\') {
-         *p = '/';
-      }
-   }
-#endif
    Dmsg1(20, "Add name to exclude: %s\n", fname);
 
+#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
+   if (strchr(fname, '/') || strchr(fname, '\\')) {
+#else
    if (strchr(fname, '/')) {
+#endif
       list = &ff->excluded_paths_list;
    } else {
       list = &ff->excluded_files_list;
    exc->next = *list;
    exc->len = len;
    strcpy(exc->fname, fname);                
+#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
+   /* Convert any \'s into /'s */
+   for (char *p=exc->fname; *p; p++) {
+      if (*p == '\\') {
+         *p = '/';
+      }
+   }
+#endif
    *list = exc;
 }
 
 
 
 void terminate_console(int sig);
 
+extern "C" gint compare_func(const void *data1, const void *data2);
+
 gboolean
 on_console_delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_data)
 {
    gtk_main_quit();
    terminate_console(0);     
+   return TRUE;
 }
 
 void
 /*
  * Compare list string items
  */
-static gint compare_func(const void *data1, const void *data2)
+extern "C"
+gint compare_func(const void *data1, const void *data2)
 {
    return strcmp((const char *)data1, (const char *)data2);
 }
 
 
 /* Forward referenced functions */
 void terminate_console(int sig);
-static gint message_handler(gpointer data);
-static int initial_connect_to_director(gpointer data);
+
+extern "C" {
+    static gint message_handler(gpointer data);
+    static int initial_connect_to_director(gpointer data);
+}
+
 static void set_scroll_bar_to_end(void);
 
 /* Static variables */
    }
 }
 
+extern "C"
 void read_director(gpointer data, gint fd, GdkInputCondition condition)
 {
    int stat;
 
 extern GtkWidget *combo1;     /* Directory combo */
 extern GtkWidget *dir_dialog; 
 extern GtkWidget *dir_select;
-extern GtkWidget *run_dialog;      /* run dialog */
+extern GtkWidget *run_dialog;       /* run dialog */
 extern GtkWidget *label_dialog;     
 extern GtkWidget *restore_dialog;   /* restore dialog */
 extern GtkWidget *restore_file_selection;   /* restore files dialog */
 void start_director_reader(gpointer data);
 void stop_director_reader(gpointer data);
 void write_director(const gchar *msg);
-void read_director(gpointer data, gint fd, GdkInputCondition condition);
 void set_restore_dialog_defaults();
 void select_restore_files();
 
+extern "C" void read_director(gpointer data, gint fd, GdkInputCondition condition);
+
 #endif
 
         struct timeval tv;
 
         FD_ZERO(&fdset);
-        FD_SET(bsock->fd, &fdset);
+        FD_SET((unsigned)bsock->fd, &fdset);
         tv.tv_sec = 10;
         tv.tv_usec = 0;
         select(bsock->fd + 1, NULL, &fdset, NULL, &tv);
    struct timeval tv;
 
    FD_ZERO(&fdset);
-   FD_SET(bsock->fd, &fdset);
+   FD_SET((unsigned)bsock->fd, &fdset);
    tv.tv_sec = sec;
    tv.tv_usec = 0;
    for ( ;; ) {
    struct timeval tv;
 
    FD_ZERO(&fdset);
-   FD_SET(bsock->fd, &fdset);
+   FD_SET((unsigned)bsock->fd, &fdset);
    tv.tv_sec = sec;
    tv.tv_usec = 0;
    for ( ;; ) {
 
 extern time_t watchdog_time;
 
 /* Forward referenced functions */
-static void timeout_handler(int sig);
+extern "C" void timeout_handler(int sig);
+
 static void jcr_timeout_check(watchdog_t *self);
 
 int num_jobs_run;
    uint32_t num;
 
    Dmsg1(100, "read_last_jobs seek to %d\n", (int)addr);
-   if (addr == 0 || lseek(fd, addr, SEEK_SET) < 0) {
+   if (addr == 0 || lseek(fd, (off_t)addr, SEEK_SET) < 0) {
       return;
    }
    if (read(fd, &num, sizeof(num)) != sizeof(num)) {
    uint32_t num;
 
    Dmsg1(100, "write_last_jobs seek to %d\n", (int)addr);
-   if (lseek(fd, addr, SEEK_SET) < 0) {
+   if (lseek(fd, (off_t)addr, SEEK_SET) < 0) {
       return 0;
    }
    if (last_jobs) {
 /*
  * Timeout signal comes here
  */
-static void timeout_handler(int sig)
+extern "C" void timeout_handler(int sig)
 {
    return;                           /* thus interrupting the function */
 }
 
 /* 
  * Handle signals here
  */
+extern "C" {
+    static void signal_handler(int sig);
+}
+
 static void signal_handler(int sig)
 {
    static int already_dead = 0;
 
 #define SLEEP_TIME 1                 /* examine things every second */
 
 /* Forward referenced functions */
-static void *watchdog_thread(void *arg);
+extern "C" void *watchdog_thread(void *arg);
+
 static void wd_lock();
 static void wd_unlock();
 
    return ret;
 }
 
-static void *watchdog_thread(void *arg)
+extern "C" void *watchdog_thread(void *arg)
 {
    Dmsg0(400, "NicB-reworked watchdog thread entered\n");
 
 
 #include "bacula.h"
 
 /* Forward referenced functions */
-static void *workq_server(void *arg);
+extern "C" void *workq_server(void *arg);
 
 /*   
  * Initialize a work queue
  * This is the worker thread that serves the work queue.
  * In due course, it will call the user's engine.
  */
-static void *workq_server(void *arg)
+extern "C"
+void *workq_server(void *arg)
 {
    struct timespec timeout;
    workq_t *wq = (workq_t *)arg;
 
 /* Forward referenced functions */
 void terminate_stored(int sig);
 static void check_config();
-static void *device_allocation(void *arg);
+
+extern "C" void *device_allocation(void *arg);
 
 #define CONFIG_FILE "bacula-sd.conf"  /* Default config file */
 
  * We are started as a separate thread.  The
  *  resources are alread locked.
  */
-static void *device_allocation(void *arg)
+extern "C"
+void *device_allocation(void *arg)
 {
    DEVRES *device;
 
 
 #undef  VERSION
 #define VERSION "1.35.0"
 #define VSTRING "1"
-#define BDATE   "14 June 2004"
-#define LSMDATE "14Jun04"
+#define BDATE   "15 June 2004"
+#define LSMDATE "15Jun04"
 
 /* Debug flags */
 #undef  DEBUG