From 53cdfdd29c4c3d50c84e5c88b5adf8c2f63e00d5 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Tue, 15 Jun 2004 17:22:20 +0000 Subject: [PATCH] Add extern C to callback functions git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1423 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/autoconf/configure.in | 2 +- bacula/configure | 40 --------------------------- bacula/src/bacula.h | 5 ++++ bacula/src/console/console.c | 14 +++++++++- bacula/src/dird/dird.c | 4 ++- bacula/src/dird/jobq.c | 11 +++++--- bacula/src/dird/msgchan.c | 7 +++-- bacula/src/dird/ua_cmds.c | 2 +- bacula/src/dird/ua_server.c | 6 ++-- bacula/src/filed/heartbeat.c | 9 ++++-- bacula/src/filed/job.c | 4 +-- bacula/src/findlib/match.c | 22 +++++++++------ bacula/src/gnome2-console/callbacks.c | 6 +++- bacula/src/gnome2-console/console.c | 9 ++++-- bacula/src/gnome2-console/console.h | 5 ++-- bacula/src/lib/bnet.c | 6 ++-- bacula/src/lib/jcr.c | 9 +++--- bacula/src/lib/signal.c | 4 +++ bacula/src/lib/watchdog.c | 5 ++-- bacula/src/lib/workq.c | 5 ++-- bacula/src/stored/stored.c | 6 ++-- bacula/src/version.h | 4 +-- 22 files changed, 99 insertions(+), 86 deletions(-) diff --git a/bacula/autoconf/configure.in b/bacula/autoconf/configure.in index 4be8e345a7..eccacfec29 100644 --- a/bacula/autoconf/configure.in +++ b/bacula/autoconf/configure.in @@ -59,7 +59,7 @@ AC_PATH_PROG(ECHO, echo, echo) 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) diff --git a/bacula/configure b/bacula/configure index 06bdc02c80..ab0d125729 100755 --- a/bacula/configure +++ b/bacula/configure @@ -3571,46 +3571,6 @@ else 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 diff --git a/bacula/src/bacula.h b/bacula/src/bacula.h index 54c355f42e..726c7ac880 100644 --- a/bacula/src/bacula.h +++ b/bacula/src/bacula.h @@ -27,6 +27,11 @@ #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" diff --git a/bacula/src/console/console.c b/bacula/src/console/console.c index a59dc3eefc..0c221bce15 100644 --- a/bacula/src/console/console.c +++ b/bacula/src/console/console.c @@ -68,6 +68,12 @@ static int do_outputcmd(FILE *input, BSOCK *UA_sock); 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; @@ -106,26 +112,32 @@ static void usage() "\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(); @@ -531,7 +543,7 @@ wait_for_data(int fd, int sec) 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; diff --git a/bacula/src/dird/dird.c b/bacula/src/dird/dird.c index 326999d84d..109b582d57 100644 --- a/bacula/src/dird/dird.c +++ b/bacula/src/dird/dird.c @@ -34,7 +34,8 @@ static void terminate_dird(int sig); static int check_resources(); /* Exported subroutines */ -void reload_config(int sig); + +extern "C" void reload_config(int sig); /* Imported subroutines */ @@ -341,6 +342,7 @@ static int find_free_table() * 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; diff --git a/bacula/src/dird/jobq.c b/bacula/src/dird/jobq.c index 112584fcd4..8040ed77e0 100755 --- a/bacula/src/dird/jobq.c +++ b/bacula/src/dird/jobq.c @@ -42,7 +42,9 @@ /* 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); /* @@ -152,7 +154,8 @@ struct wait_pkt { * 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; @@ -186,7 +189,6 @@ static void *sched_wait(void *arg) return NULL; } - /* * Add a job to the queue * jq is a queue that was created with jobq_init @@ -352,7 +354,8 @@ static int start_server(jobq_t *jq) * 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; diff --git a/bacula/src/dird/msgchan.c b/bacula/src/dird/msgchan.c index 1afe148ba6..62ea608768 100644 --- a/bacula/src/dird/msgchan.c +++ b/bacula/src/dird/msgchan.c @@ -54,7 +54,7 @@ static char Job_end[] = 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 @@ -188,7 +188,7 @@ int start_storage_daemon_message_thread(JCR *jcr) 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"); @@ -206,7 +206,8 @@ static void msg_thread_cleanup(void *arg) * 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; diff --git a/bacula/src/dird/ua_cmds.c b/bacula/src/dird/ua_cmds.c index 73858a8490..35b9212f3c 100644 --- a/bacula/src/dird/ua_cmds.c +++ b/bacula/src/dird/ua_cmds.c @@ -1526,7 +1526,7 @@ static int time_cmd(UAContext *ua, const char *cmd) /* * 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) { diff --git a/bacula/src/dird/ua_server.c b/bacula/src/dird/ua_server.c index 4dd97dbab0..415a60e1a6 100644 --- a/bacula/src/dird/ua_server.c +++ b/bacula/src/dird/ua_server.c @@ -48,7 +48,8 @@ int quit_cmd_thread = 0; /* Forward referenced functions */ -static void *connect_thread(void *arg); +extern "C" void *connect_thread(void *arg); + static void *handle_UA_client_request(void *arg); @@ -80,7 +81,8 @@ void start_UA_server(char *UA_addr, int UA_port) return; } -static void *connect_thread(void *arg) +extern "C" +void *connect_thread(void *arg) { struct s_addr_port *UA = (struct s_addr_port *)arg; diff --git a/bacula/src/filed/heartbeat.c b/bacula/src/filed/heartbeat.c index 8e1c033d22..3a1ae9406c 100644 --- a/bacula/src/filed/heartbeat.c +++ b/bacula/src/filed/heartbeat.c @@ -41,12 +41,16 @@ #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; @@ -121,7 +125,7 @@ void stop_heartbeat_monitor(JCR *jcr) * 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; @@ -149,6 +153,7 @@ static void *dir_heartbeat_thread(void *arg) jcr->hb_bsock = NULL; return NULL; } + /* * Same as above but we don't listen to the SD */ diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index 4706531d60..ed8833fba9 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -1032,7 +1032,7 @@ static int level_cmd(JCR *jcr) 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); @@ -1094,7 +1094,7 @@ static int storage_cmd(JCR *jcr) 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) { diff --git a/bacula/src/findlib/match.c b/bacula/src/findlib/match.c index 377ce45393..62d3da7329 100644 --- a/bacula/src/findlib/match.c +++ b/bacula/src/findlib/match.c @@ -148,7 +148,7 @@ void add_fname_to_include_list(FF_PKT *ff, int prefixed, const char *fname) 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); @@ -215,17 +215,13 @@ void add_fname_to_exclude_list(FF_PKT *ff, const char *fname) 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; @@ -237,6 +233,14 @@ void add_fname_to_exclude_list(FF_PKT *ff, const char *fname) 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; } diff --git a/bacula/src/gnome2-console/callbacks.c b/bacula/src/gnome2-console/callbacks.c index 9bf6075341..0de9987a6e 100644 --- a/bacula/src/gnome2-console/callbacks.c +++ b/bacula/src/gnome2-console/callbacks.c @@ -21,11 +21,14 @@ 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 @@ -224,7 +227,8 @@ on_select_director_cancel_clicked(GtkButton *button, gpointer user_data) /* * 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); } diff --git a/bacula/src/gnome2-console/console.c b/bacula/src/gnome2-console/console.c index 136c2417d4..963b96b58e 100644 --- a/bacula/src/gnome2-console/console.c +++ b/bacula/src/gnome2-console/console.c @@ -62,8 +62,12 @@ GList *type_list, *level_list; /* 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 */ @@ -463,6 +467,7 @@ void write_director(const gchar *msg) } } +extern "C" void read_director(gpointer data, gint fd, GdkInputCondition condition) { int stat; diff --git a/bacula/src/gnome2-console/console.h b/bacula/src/gnome2-console/console.h index 98dedfae0b..ce3a117732 100644 --- a/bacula/src/gnome2-console/console.h +++ b/bacula/src/gnome2-console/console.h @@ -24,7 +24,7 @@ extern GtkWidget *entry1; /* entry box */ 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 */ @@ -56,8 +56,9 @@ int disconnect_from_director(gpointer data); 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 diff --git a/bacula/src/lib/bnet.c b/bacula/src/lib/bnet.c index 3f64090f3c..df0680a1cf 100644 --- a/bacula/src/lib/bnet.c +++ b/bacula/src/lib/bnet.c @@ -117,7 +117,7 @@ static int32_t write_nbytes(BSOCK *bsock, char *ptr, int32_t nbytes) 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); @@ -439,7 +439,7 @@ bnet_wait_data(BSOCK *bsock, int sec) 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 ( ;; ) { @@ -470,7 +470,7 @@ bnet_wait_data_intr(BSOCK *bsock, int sec) 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 ( ;; ) { diff --git a/bacula/src/lib/jcr.c b/bacula/src/lib/jcr.c index 3f1c7d89f3..4d18839ab3 100755 --- a/bacula/src/lib/jcr.c +++ b/bacula/src/lib/jcr.c @@ -35,7 +35,8 @@ 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; @@ -79,7 +80,7 @@ void read_last_jobs_list(int fd, uint64_t addr) 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)) { @@ -116,7 +117,7 @@ uint64_t write_last_jobs_list(int fd, uint64_t addr) 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) { @@ -638,7 +639,7 @@ static void jcr_timeout_check(watchdog_t *self) /* * Timeout signal comes here */ -static void timeout_handler(int sig) +extern "C" void timeout_handler(int sig) { return; /* thus interrupting the function */ } diff --git a/bacula/src/lib/signal.c b/bacula/src/lib/signal.c index 4e32d44401..c9216ac926 100644 --- a/bacula/src/lib/signal.c +++ b/bacula/src/lib/signal.c @@ -58,6 +58,10 @@ static pid_t main_pid = 0; /* * Handle signals here */ +extern "C" { + static void signal_handler(int sig); +} + static void signal_handler(int sig) { static int already_dead = 0; diff --git a/bacula/src/lib/watchdog.c b/bacula/src/lib/watchdog.c index 13d3375847..28ac35f0bd 100755 --- a/bacula/src/lib/watchdog.c +++ b/bacula/src/lib/watchdog.c @@ -36,7 +36,8 @@ time_t watchdog_time = 0; /* this has granularity of SLEEP_TIME */ #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(); @@ -214,7 +215,7 @@ bool unregister_watchdog(watchdog_t *wd) return ret; } -static void *watchdog_thread(void *arg) +extern "C" void *watchdog_thread(void *arg) { Dmsg0(400, "NicB-reworked watchdog thread entered\n"); diff --git a/bacula/src/lib/workq.c b/bacula/src/lib/workq.c index 318a20eb35..01c9307cb1 100755 --- a/bacula/src/lib/workq.c +++ b/bacula/src/lib/workq.c @@ -50,7 +50,7 @@ #include "bacula.h" /* Forward referenced functions */ -static void *workq_server(void *arg); +extern "C" void *workq_server(void *arg); /* * Initialize a work queue @@ -282,7 +282,8 @@ int workq_remove(workq_t *wq, workq_ele_t *work_item) * 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; diff --git a/bacula/src/stored/stored.c b/bacula/src/stored/stored.c index f910f85e2f..fe12febbea 100644 --- a/bacula/src/stored/stored.c +++ b/bacula/src/stored/stored.c @@ -38,7 +38,8 @@ /* 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 */ @@ -295,7 +296,8 @@ static void check_config() * 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; diff --git a/bacula/src/version.h b/bacula/src/version.h index 7ae7e586d1..ea7ebab74f 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -2,8 +2,8 @@ #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 -- 2.39.5