From bb2e37f0f383492976030879320b0fbc35e883a9 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Fri, 23 Apr 2004 16:19:06 +0000 Subject: [PATCH] Add native win32 bconsole git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@1273 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/autoconf/configure.in | 5 +++-- bacula/configure | 5 +++-- bacula/src/console/console.c | 13 +++++++++++-- bacula/src/console/console_conf.c | 7 +++++++ bacula/src/lib/message.c | 4 ++++ 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/bacula/autoconf/configure.in b/bacula/autoconf/configure.in index 87c4f3fc1e..37ca9a59d4 100644 --- a/bacula/autoconf/configure.in +++ b/bacula/autoconf/configure.in @@ -1,4 +1,4 @@ -dnl# +lal# dnl# dnl# Process this file with autoconf to produce a configure script. dnl# @@ -1662,8 +1662,9 @@ AC_OUTPUT([autoconf/Make.common \ src/findlib/Makefile \ src/tools/Makefile \ src/win32/winbacula.nsi \ - src/win32/bacula-fd.conf \ + src/win32/baculafd/bacula-fd.conf \ src/win32/Makefile \ + src/win32/console/bconsole.conf.in \ $PFILES ], [(echo "Doing make of dependencies"; make depend;) ] ) diff --git a/bacula/configure b/bacula/configure index 9c953a7951..217ad1b53a 100755 --- a/bacula/configure +++ b/bacula/configure @@ -18186,7 +18186,7 @@ if test "x${subsysdir}" = "x${sbindir}" ; then exit 1 fi - ac_config_files="$ac_config_files autoconf/Make.common Makefile rescue/Makefile rescue/linux/Makefile rescue/freebsd/Makefile rescue/solaris/Makefile scripts/startmysql scripts/stopmysql scripts/btraceback scripts/startit scripts/stopit scripts/bconsole scripts/gconsole scripts/bacula scripts/devel_bacula scripts/fd scripts/Makefile scripts/logrotate scripts/bacula.desktop.gnome1 scripts/bacula.desktop.gnome2 scripts/bacula.desktop.gnome1.consolehelper scripts/bacula.desktop.gnome2.consolehelper scripts/bacula.desktop.gnome1.xsu scripts/bacula.desktop.gnome2.xsu scripts/gnome-console.console_apps scripts/mtx-changer doc/Makefile src/Makefile src/host.h src/console/Makefile src/console/bconsole.conf src/gnome-console/Makefile src/gnome-console/gnome-console.conf src/gnome2-console/Makefile src/gnome2-console/gnome-console.conf src/wx-console/Makefile src/wx-console/wx-console.conf src/dird/Makefile src/dird/bacula-dir.conf src/lib/Makefile src/stored/Makefile src/stored/bacula-sd.conf src/filed/Makefile src/filed/bacula-fd.conf src/filed/win32/Makefile src/cats/Makefile src/cats/make_catalog_backup src/cats/delete_catalog_backup src/cats/create_postgresql_database src/cats/update_postgresql_tables src/cats/make_postgresql_tables src/cats/grant_postgresql_privileges src/cats/drop_postgresql_tables src/cats/drop_postgresql_database src/cats/create_mysql_database src/cats/update_mysql_tables src/cats/make_mysql_tables src/cats/grant_mysql_privileges src/cats/drop_mysql_tables src/cats/drop_mysql_database src/cats/create_sqlite_database src/cats/update_sqlite_tables src/cats/make_sqlite_tables src/cats/grant_sqlite_privileges src/cats/drop_sqlite_tables src/cats/drop_sqlite_database src/cats/sqlite src/cats/mysql src/cats/create_bdb_database src/cats/update_bdb_tables src/cats/make_bdb_tables src/cats/grant_bdb_privileges src/cats/drop_bdb_tables src/cats/drop_bdb_database src/cats/create_bacula_database src/cats/update_bacula_tables src/cats/grant_bacula_privileges src/cats/make_bacula_tables src/cats/drop_bacula_tables src/cats/drop_bacula_database src/findlib/Makefile src/tools/Makefile src/win32/winbacula.nsi src/win32/bacula-fd.conf src/win32/Makefile $PFILES" + ac_config_files="$ac_config_files autoconf/Make.common Makefile rescue/Makefile rescue/linux/Makefile rescue/freebsd/Makefile rescue/solaris/Makefile scripts/startmysql scripts/stopmysql scripts/btraceback scripts/startit scripts/stopit scripts/bconsole scripts/gconsole scripts/bacula scripts/devel_bacula scripts/fd scripts/Makefile scripts/logrotate scripts/bacula.desktop.gnome1 scripts/bacula.desktop.gnome2 scripts/bacula.desktop.gnome1.consolehelper scripts/bacula.desktop.gnome2.consolehelper scripts/bacula.desktop.gnome1.xsu scripts/bacula.desktop.gnome2.xsu scripts/gnome-console.console_apps scripts/mtx-changer doc/Makefile src/Makefile src/host.h src/console/Makefile src/console/bconsole.conf src/gnome-console/Makefile src/gnome-console/gnome-console.conf src/gnome2-console/Makefile src/gnome2-console/gnome-console.conf src/wx-console/Makefile src/wx-console/wx-console.conf src/dird/Makefile src/dird/bacula-dir.conf src/lib/Makefile src/stored/Makefile src/stored/bacula-sd.conf src/filed/Makefile src/filed/bacula-fd.conf src/filed/win32/Makefile src/cats/Makefile src/cats/make_catalog_backup src/cats/delete_catalog_backup src/cats/create_postgresql_database src/cats/update_postgresql_tables src/cats/make_postgresql_tables src/cats/grant_postgresql_privileges src/cats/drop_postgresql_tables src/cats/drop_postgresql_database src/cats/create_mysql_database src/cats/update_mysql_tables src/cats/make_mysql_tables src/cats/grant_mysql_privileges src/cats/drop_mysql_tables src/cats/drop_mysql_database src/cats/create_sqlite_database src/cats/update_sqlite_tables src/cats/make_sqlite_tables src/cats/grant_sqlite_privileges src/cats/drop_sqlite_tables src/cats/drop_sqlite_database src/cats/sqlite src/cats/mysql src/cats/create_bdb_database src/cats/update_bdb_tables src/cats/make_bdb_tables src/cats/grant_bdb_privileges src/cats/drop_bdb_tables src/cats/drop_bdb_database src/cats/create_bacula_database src/cats/update_bacula_tables src/cats/grant_bacula_privileges src/cats/make_bacula_tables src/cats/drop_bacula_tables src/cats/drop_bacula_database src/findlib/Makefile src/tools/Makefile src/win32/winbacula.nsi src/win32/baculafd/bacula-fd.conf src/win32/Makefile src/win32/console/bconsole.conf.in $PFILES" ac_config_commands="$ac_config_commands default" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -18798,8 +18798,9 @@ do "src/findlib/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/findlib/Makefile" ;; "src/tools/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/tools/Makefile" ;; "src/win32/winbacula.nsi" ) CONFIG_FILES="$CONFIG_FILES src/win32/winbacula.nsi" ;; - "src/win32/bacula-fd.conf" ) CONFIG_FILES="$CONFIG_FILES src/win32/bacula-fd.conf" ;; + "src/win32/baculafd/bacula-fd.conf" ) CONFIG_FILES="$CONFIG_FILES src/win32/baculafd/bacula-fd.conf" ;; "src/win32/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/win32/Makefile" ;; + "src/win32/console/bconsole.conf.in" ) CONFIG_FILES="$CONFIG_FILES src/win32/console/bconsole.conf.in" ;; "$PFILES" ) CONFIG_FILES="$CONFIG_FILES $PFILES" ;; "default" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;; "src/config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS src/config.h:autoconf/config.h.in" ;; diff --git a/bacula/src/console/console.c b/bacula/src/console/console.c index 2116aae673..d3f0fcd4e0 100644 --- a/bacula/src/console/console.c +++ b/bacula/src/console/console.c @@ -44,7 +44,7 @@ #ifdef HAVE_WIN32 #include -#define isatty(fd) (fd==1) +#define isatty(fd) (fd==0) DWORD g_platform_id = VER_PLATFORM_WIN32_WINDOWS; #endif @@ -381,6 +381,10 @@ Without that I don't how to speak to the Director :-(\n"), configfile); memset(&jcr, 0, sizeof(jcr)); +#ifdef HAVE_WIN32 + WSA_Init(); /* Initialize Windows sockets */ +#endif + if (ndir > 1) { struct sockaddr_in client_addr; memset(&client_addr, 0, sizeof(client_addr)); @@ -519,6 +523,9 @@ wait_for_data(int fd, int sec) { fd_set fdset; struct timeval tv; +#ifdef HAVE_WIN32 + return 1; /* select doesn't seem to work on Win32 */ +#endif tv.tv_sec = sec; tv.tv_usec = 0; @@ -731,6 +738,8 @@ void sendit(char *buf) if (tee) { fputs(buf, stdout); } - fflush(stdout); + if (output == stdout || tee) { + fflush(stdout); + } #endif } diff --git a/bacula/src/console/console_conf.c b/bacula/src/console/console_conf.c index 48e460b581..1fade95c5f 100644 --- a/bacula/src/console/console_conf.c +++ b/bacula/src/console/console_conf.c @@ -56,8 +56,15 @@ int r_last = R_LAST; * then move it to allocated memory when the resource * scan is complete. */ +#if defined(HAVE_WIN32) && !defined(HAVE_CYGWIN) && !defined(HAVE_MINGW) +extern "C" { // work around visual compiler mangling variables + URES res_all; + int res_all_size = sizeof(res_all); +} +#else URES res_all; int res_all_size = sizeof(res_all); +#endif /* Definition of records permitted within each * resource with the routine to process the record diff --git a/bacula/src/lib/message.c b/bacula/src/lib/message.c index f974268749..697fc59220 100755 --- a/bacula/src/lib/message.c +++ b/bacula/src/lib/message.c @@ -31,9 +31,11 @@ #include "bacula.h" #include "jcr.h" +#if !define(HAVE_CONSOLE) #if defined(HAVE_CYGWIN) || defined(HAVE_WIN32) #include #endif +#endif #define FULL_LOCATION 1 /* set for file:line in Debug messages */ @@ -560,8 +562,10 @@ void dispatch_message(JCR *jcr, int type, int level, char *msg) if (type == M_ABORT || type == M_ERROR_TERM) { fputs(msg, stdout); /* print this here to INSURE that it is printed */ fflush(stdout); +#if !defined(HAVE_CONSOLE) #if defined(HAVE_CYGWIN) || defined(HAVE_WIN32) MessageBox(NULL, msg, "Bacula", MB_OK); +#endif #endif } -- 2.39.5