]> git.sur5r.net Git - bacula/bacula/commitdiff
Merge in all the low-risk changes from the Windows branch.
authorRobert Nelson <robertn@the-nelsons.org>
Fri, 30 Jun 2006 04:06:34 +0000 (04:06 +0000)
committerRobert Nelson <robertn@the-nelsons.org>
Fri, 30 Jun 2006 04:06:34 +0000 (04:06 +0000)
Add all the new files from the Windows branch.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3094 91ce42f0-d328-0410-95d8-f526ca767f89

84 files changed:
bacula/src/baconfig.h
bacula/src/bacula.h
bacula/src/bc_types.h
bacula/src/cats/Makefile.in
bacula/src/cats/bdb.c
bacula/src/cats/bdb_create.c
bacula/src/cats/bdb_find.c
bacula/src/cats/bdb_get.c
bacula/src/cats/make_mysql_tables.in
bacula/src/cats/protos.h
bacula/src/cats/sql_create.c
bacula/src/cats/sql_get.c
bacula/src/cats/sql_list.c
bacula/src/cats/sql_update.c
bacula/src/console/console.c
bacula/src/console/console_conf.c
bacula/src/dird/backup.c
bacula/src/dird/bsr.c
bacula/src/dird/catreq.c
bacula/src/dird/dird.c
bacula/src/dird/dird_conf.c
bacula/src/dird/dird_conf.h
bacula/src/dird/expand.c
bacula/src/dird/fd_cmds.c
bacula/src/dird/inc_conf.c
bacula/src/dird/job.c
bacula/src/dird/run_conf.c
bacula/src/dird/scheduler.c
bacula/src/dird/sql_cmds.c
bacula/src/dird/ua_cmds.c
bacula/src/dird/ua_output.c
bacula/src/dird/ua_prune.c
bacula/src/dird/ua_query.c
bacula/src/dird/ua_restore.c
bacula/src/dird/ua_run.c
bacula/src/dird/ua_update.c
bacula/src/filed/estimate.c
bacula/src/filed/filed.c
bacula/src/filed/filed_conf.c
bacula/src/filed/job.c
bacula/src/filed/status.c
bacula/src/findlib/attribs.c
bacula/src/findlib/bfile.c
bacula/src/findlib/bfile.h
bacula/src/findlib/drivetype.c [new file with mode: 0644]
bacula/src/findlib/enable_priv.c
bacula/src/findlib/find.c
bacula/src/findlib/makepath.c
bacula/src/findlib/match.c
bacula/src/lib/base64.c
bacula/src/lib/berrno.c
bacula/src/lib/bnet.c
bacula/src/lib/bpipe.c
bacula/src/lib/bshm.c
bacula/src/lib/bsys.c
bacula/src/lib/btime.c
bacula/src/lib/daemon.c
bacula/src/lib/enh_fnmatch.c [new file with mode: 0644]
bacula/src/lib/enh_fnmatch.h [new file with mode: 0644]
bacula/src/lib/events.c
bacula/src/lib/lex.c
bacula/src/lib/md5.c
bacula/src/lib/message.c
bacula/src/lib/parse_conf.c
bacula/src/lib/protos.h
bacula/src/lib/res.c
bacula/src/lib/runscript.c
bacula/src/lib/sha1.c
bacula/src/stored/bextract.c
bacula/src/stored/bls.c
bacula/src/stored/bscan.c
bacula/src/stored/btape.c
bacula/src/stored/dev.c
bacula/src/stored/dev.h
bacula/src/stored/dircmd.c
bacula/src/stored/fd_cmds.c
bacula/src/stored/spool.c
bacula/src/stored/stored_conf.c
bacula/src/stored/stored_conf.h
bacula/src/tools/bwild.c
bacula/src/tools/drivetype.c [new file with mode: 0644]
bacula/src/tools/fstype.c
bacula/src/tools/testfind.c
bacula/src/tools/testls.c

index 16e9cfe424eb677f6dc2e2329adc3809ca5601b3..f052b13cdead87fc852e32849673cfcfc8584b17 100644 (file)
@@ -65,7 +65,7 @@
 /* Allow printing of NULL pointers */
 #define NPRT(x) (x)?(x):_("*None*")
  
-#ifdef WIN32
+#if defined(HAVE_WIN32)
 #undef ENABLE_NLS
 #endif
 
  * or saved */
 #define FT_DIRBEGIN  18               /* Directory at beginning (not saved) */
 #define FT_INVALIDFS 19               /* File system not allowed for */
+#define FT_INVALIDDT 20               /* Drive type not allowed for */
 
 /* Definitions for upper part of type word (see above). */
 #define AR_DATA_STREAM (1<<16)        /* Data stream id present */
@@ -562,13 +563,9 @@ extern "C" int getdomainname(char *name, int len);
 extern "C" int mknod ( const char *path, int mode, dev_t device );
 #endif
 
-#ifdef HAVE_CYGWIN
-/* They don't really have it */
-#undef HAVE_GETDOMAINNAME
-#endif
 
 /* Define Winsock functions if we aren't on Windows */
-#if (!defined HAVE_WIN32) || (defined HAVE_CYGWIN)
+#if !defined HAVE_WIN32
 #define WSA_Init() 0 /* 0 = success */
 #define WSACleanup() 0 /* 0 = success */
 #endif
index daedd83bd3048d30d1d3c3c633d2d57567b5e46f..f677f2458a5cd44c0002499046633a18872a1878 100644 (file)
@@ -26,8 +26,8 @@
 #define _LANGUAGE_C_PLUS_PLUS 1
 #endif
 
-#ifdef WIN32
-#ifdef HAVE_MINGW
+#if defined(HAVE_WIN32)
+#if defined(HAVE_MINGW)
 #include "mingwconfig.h"
 #include "winhost.h"
 #define _STAT_H       /* don't pull in MinGW stat.h */
index 75950bd32ded714331572a9c6ffc83eb34275855..81595edb9e7a02484dd91bd05cd358f55e403b28 100644 (file)
@@ -173,10 +173,6 @@ typedef float             float32_t;
 /* Unix time (time_t) widened to 64 bits */
 #define utime_t int64_t
 
-#ifdef HAVE_CYGWIN
-#define int_least16_t int32_t
-#endif
-
 #ifndef HAVE_SOCKLEN_T
 #define socklen_t int
 #endif
index 44ec71b3602821ab44f55ae0130b2f277d79409e..0a3495610e09d908ebc7a9207c59a8fe4054a80d 100644 (file)
@@ -81,6 +81,9 @@ realclean: clean
        $(RMF) create_sqlite_database      update_sqlite_tables     make_sqlite_tables
        $(RMF) grant_sqlite_privileges     drop_sqlite_tables       drop_sqlite_database
 
+       $(RMF) create_sqlite3_database     update_sqlite3_tables     make_sqlite3_tables
+       $(RMF) grant_sqlite3_privileges    drop_sqlite3_tables      drop_sqlite3_database
+
        $(RMF) mysql sqlite postgresql
        $(RMF) make_catalog_backup delete_catalog_backup
 
index a0836efc9f7c35b1f9017d83864a338642653c55..43cc175e2bc81d4c8ac44c05ad5fd15e04471538 100644 (file)
@@ -296,7 +296,7 @@ int bdb_open_jobs_file(B_DB *mdb)
 
    if (!mdb->jobfd) {
       dbf = make_filename(mdb, DB_JOBS_FILENAME);
-      mdb->jobfd = fopen(dbf, "r+");
+      mdb->jobfd = fopen(dbf, "r+b");
       if (!mdb->jobfd) {
          Mmsg2(&mdb->errmsg, "Error opening DB Jobs file %s: ERR=%s\n",
             dbf, strerror(errno));
@@ -318,7 +318,7 @@ int bdb_open_jobmedia_file(B_DB *mdb)
 
    if (!mdb->jobmediafd) {
       dbf = make_filename(mdb, DB_JOBMEDIA_FILENAME);
-      mdb->jobmediafd = fopen(dbf, "r+");
+      mdb->jobmediafd = fopen(dbf, "r+b");
       if (!mdb->jobmediafd) {
          Mmsg2(&mdb->errmsg, "Error opening DB JobMedia file %s: ERR=%s\n",
             dbf, strerror(errno));
@@ -341,7 +341,7 @@ int bdb_open_pools_file(B_DB *mdb)
 
    if (!mdb->poolfd) {
       dbf = make_filename(mdb, DB_POOLS_FILENAME);
-      mdb->poolfd = fopen(dbf, "r+");
+      mdb->poolfd = fopen(dbf, "r+b");
       if (!mdb->poolfd) {
          Mmsg2(&mdb->errmsg, "Error opening DB Pools file %s: ERR=%s\n",
             dbf, strerror(errno));
@@ -364,7 +364,7 @@ int bdb_open_client_file(B_DB *mdb)
 
    if (!mdb->clientfd) {
       dbf = make_filename(mdb, DB_CLIENT_FILENAME);
-      mdb->clientfd = fopen(dbf, "r+");
+      mdb->clientfd = fopen(dbf, "r+b");
       if (!mdb->clientfd) {
          Mmsg2(&mdb->errmsg, "Error opening DB Clients file %s: ERR=%s\n",
             dbf, strerror(errno));
@@ -386,7 +386,7 @@ int bdb_open_fileset_file(B_DB *mdb)
 
    if (!mdb->filesetfd) {
       dbf = make_filename(mdb, DB_CLIENT_FILENAME);
-      mdb->filesetfd = fopen(dbf, "r+");
+      mdb->filesetfd = fopen(dbf, "r+b");
       if (!mdb->filesetfd) {
          Mmsg2(&mdb->errmsg, "Error opening DB FileSet file %s: ERR=%s\n",
             dbf, strerror(errno));
@@ -410,7 +410,7 @@ int bdb_open_media_file(B_DB *mdb)
 
    if (!mdb->mediafd) {
       dbf = make_filename(mdb, DB_MEDIA_FILENAME);
-      mdb->mediafd = fopen(dbf, "r+");
+      mdb->mediafd = fopen(dbf, "r+b");
       if (!mdb->mediafd) {
          Mmsg2(&mdb->errmsg, "Error opening DB Media file %s: ERR=%s\n",
             dbf, strerror(errno));
index 3228d42e08e11e0d487ec2d87370ceeea1a5af8f..07d7b9a711d609d81cf799d5b66727c218f77618 100644 (file)
@@ -23,8 +23,8 @@
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
-   the file LICENSE for additional details.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+   file LICENSE for additional details.
 
  */
 
@@ -71,7 +71,7 @@ int db_create_file_item(JCR *jcr, B_DB *mdb, ATTR_DBR *ar)
  * Returns: 0 on failure
  *          1 on success
  */
-int db_create_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
+bool db_create_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
 {
    int len;
 
index 6c5bd3b11740c812634b5c42e3389dbcda53a19c..f63a5354dc04f96f154b77ea1b8826b737ada460 100644 (file)
@@ -16,6 +16,7 @@
  *
  *    Version $Id$
  */
+
 /*
    Copyright (C) 2001-2006 Kern Sibbald
 
@@ -171,7 +172,7 @@ db_find_next_volume(JCR *jcr, B_DB *mdb, int item, bool InChanger, MEDIA_DBR *mr
    return stat;
 }
 
-int
+bool
 db_find_last_jobid(JCR *jcr, B_DB *mdb, const char *Name, JOB_DBR *jr)
 { return 0; }
 
index 8fd20b0fa3898753ac50a06b9d6b43a0abfbcb60..3a1e7d8174a7ab58ec691e33438493b975e990bc 100644 (file)
@@ -15,6 +15,7 @@
  *
  *    Version $Id$
  */
+
 /*
    Copyright (C) 2001-2006 Kern Sibbald
 
@@ -26,7 +27,7 @@
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
-   the file LICENSE for additional details.
+   file LICENSE for additional details.
 
  */
 
@@ -59,7 +60,7 @@
  *          1 on success
  */
 
-int db_get_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
+bool db_get_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
 {
    JOB_DBR ojr;
    faddr_t rec_addr;
index 541e2d8863116e52c5eb0b66ce3e95a6142b0363..d0f7f3108d52d3502852c35a3bf4dc11542ca92f 100644 (file)
@@ -92,21 +92,21 @@ CREATE TABLE Job (
    Name TINYBLOB NOT NULL,
    Type BINARY(1) NOT NULL,
    Level BINARY(1) NOT NULL,
-   ClientId INTEGER NOT NULL REFERENCES Client,
+   ClientId INTEGER NOT NULL DEFAULT 0 REFERENCES Client,
    JobStatus BINARY(1) NOT NULL,
    SchedTime DATETIME NOT NULL,
-   StartTime DATETIME NOT NULL,
-   EndTime DATETIME NOT NULL,
-   RealEndTime DATETIME NOT NULL,
+   StartTime DATETIME NOT NULL DEFAULT 0,
+   EndTime DATETIME NOT NULL DEFAULT 0,
+   RealEndTime DATETIME NOT NULL DEFAULT 0,
    JobTDate BIGINT UNSIGNED NOT NULL,
    VolSessionId INTEGER UNSIGNED NOT NULL DEFAULT 0,
    VolSessionTime INTEGER UNSIGNED NOT NULL DEFAULT 0,
    JobFiles INTEGER UNSIGNED NOT NULL DEFAULT 0,
-   JobBytes BIGINT UNSIGNED NOT NULL,
+   JobBytes BIGINT UNSIGNED NOT NULL DEFAULT 0,
    JobErrors INTEGER UNSIGNED NOT NULL DEFAULT 0,
    JobMissingFiles INTEGER UNSIGNED NOT NULL DEFAULT 0,
-   PoolId INTEGER UNSIGNED NOT NULL REFERENCES Pool,
-   FileSetId INTEGER UNSIGNED NOT NULL REFERENCES FileSet,
+   PoolId INTEGER UNSIGNED NOT NULL DEFAULT 0 REFERENCES Pool,
+   FileSetId INTEGER UNSIGNED NOT NULL DEFAULT 0 REFERENCES FileSet,
    PriorJobId INTEGER UNSIGNED DEFAULT 0 REFERENCES Job,
    PurgedFiles TINYINT NOT NULL DEFAULT 0,
    HasBase TINYINT NOT NULL DEFAULT 0,
@@ -157,9 +157,9 @@ CREATE TABLE Media (
    MediaType TINYBLOB NOT NULL,
    MediaTypeId INTEGER UNSIGNED NOT NULL REFERENCES MediaType,
    LabelType TINYINT NOT NULL DEFAULT 0,
-   FirstWritten DATETIME NOT NULL,
-   LastWritten DATETIME NOT NULL,
-   LabelDate DATETIME NOT NULL,
+   FirstWritten DATETIME NOT NULL DEFAULT 0,
+   LastWritten DATETIME NOT NULL DEFAULT 0,
+   LabelDate DATETIME NOT NULL DEFAULT 0,
    VolJobs INTEGER UNSIGNED NOT NULL DEFAULT 0,
    VolFiles INTEGER UNSIGNED NOT NULL DEFAULT 0,
    VolBlocks INTEGER UNSIGNED NOT NULL DEFAULT 0,
@@ -188,7 +188,7 @@ CREATE TABLE Media (
    EndBlock INTEGER UNSIGNED NOT NULL DEFAULT 0,
    LocationId INTEGER UNSIGNED DEFAULT 0 REFERENCES Location,
    RecycleCount INTEGER UNSIGNED DEFAULT 0,
-   InitialWrite DATETIME NOT NULL,
+   InitialWrite DATETIME NOT NULL DEFAULT 0,
    ScratchPoolId INTEGER UNSIGNED DEFAULT 0 REFERENCES Pool,
    RecyclePoolId INTEGER UNSIGNED DEFAULT 0 REFERENCES Pool,
    PRIMARY KEY(MediaId),
index fd3aa6d8183c8fc837d9a76f5e115778a28765f9..dcc84f7cb8fdbff493db16091a346193a18091c4 100644 (file)
@@ -93,7 +93,7 @@ void db_list_job_totals(JCR *jcr, B_DB *db, JOB_DBR *jr, DB_LIST_HANDLER sendit,
 void db_list_files_for_job(JCR *jcr, B_DB *db, uint32_t jobid, DB_LIST_HANDLER sendit, void *ctx);
 void db_list_media_records(JCR *jcr, B_DB *mdb, MEDIA_DBR *mdbr, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type);
 void db_list_jobmedia_records(JCR *jcr, B_DB *mdb, JobId_t JobId, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type);
-int  db_list_sql_query(JCR *jcr, B_DB *mdb, char *query, DB_LIST_HANDLER *sendit, void *ctx, int verbose, e_list_type type);
+int  db_list_sql_query(JCR *jcr, B_DB *mdb, const char *query, DB_LIST_HANDLER *sendit, void *ctx, int verbose, e_list_type type);
 void db_list_client_records(JCR *jcr, B_DB *mdb, DB_LIST_HANDLER *sendit, void *ctx, e_list_type type);
 
 /* update.c */
index f42f2cd3d31fc99c09badf422cd8800af053787c..7b1cc909d7852e0a8407165890cdb04f5543adb4 100644 (file)
@@ -71,8 +71,8 @@ db_create_job_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
    stime = jr->SchedTime;
    ASSERT(stime != 0);
 
-   localtime_r(&stime, &tm);
-   strftime(dt, sizeof(dt), "%Y-%m-%d %T", &tm);
+   (void)localtime_r(&stime, &tm);
+   strftime(dt, sizeof(dt), "%Y-%m-%d %H:%M:%S", &tm);
    JobTDate = (utime_t)stime;
 
    /* Must create it */
@@ -443,8 +443,8 @@ db_create_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
          if (mr->LabelDate == 0) {
             mr->LabelDate = time(NULL);
          }
-         localtime_r(&mr->LabelDate, &tm);
-         strftime(dt, sizeof(dt), "%Y-%m-%d %T", &tm);
+         (void)localtime_r(&mr->LabelDate, &tm);
+         strftime(dt, sizeof(dt), "%Y-%m-%d %H:%M:%S", &tm);
          Mmsg(mdb->cmd, "UPDATE Media SET LabelDate='%s' "
               "WHERE MediaId=%d", dt, mr->MediaId);
          stat = UPDATE_DB(jcr, mdb, mdb->cmd);
@@ -615,8 +615,8 @@ bool db_create_fileset_record(JCR *jcr, B_DB *mdb, FILESET_DBR *fsr)
    if (fsr->CreateTime == 0 && fsr->cCreateTime[0] == 0) {
       fsr->CreateTime = time(NULL);
    }
-   localtime_r(&fsr->CreateTime, &tm);
-   strftime(fsr->cCreateTime, sizeof(fsr->cCreateTime), "%Y-%m-%d %T", &tm);
+   (void)localtime_r(&fsr->CreateTime, &tm);
+   strftime(fsr->cCreateTime, sizeof(fsr->cCreateTime), "%Y-%m-%d %H:%M:%S", &tm);
 
    /* Must create it */
       Mmsg(mdb->cmd, "INSERT INTO FileSet (FileSet,MD5,CreateTime) "
index 4068dfbaec4d3447e64de421878812562b9c8aba..0fcc2dabd52d59a51d10612f1d59d0bdb6b6d335 100644 (file)
@@ -407,6 +407,8 @@ int db_get_job_volume_parameters(JCR *jcr, B_DB *mdb, JobId_t JobId, VOL_PARAMS
          if (stat > 0) {
             *VolParams = Vols = (VOL_PARAMS *)malloc(stat * sizeof(VOL_PARAMS));
             SId = (DBId_t *)malloc(stat * sizeof(DBId_t));
+         } else {
+            SId = NULL;
          }
          for (i=0; i < stat; i++) {
             if ((row = sql_fetch_row(mdb)) == NULL) {
index ff71728cc332a181b4e5518197f91141a3b87966..cbc94137386012ea20ea91f52e793fb436f43d76 100644 (file)
@@ -45,7 +45,7 @@ extern int QueryDB(const char *file, int line, JCR *jcr, B_DB *db, char *select_
 /*
  * Submit general SQL query
  */
-int db_list_sql_query(JCR *jcr, B_DB *mdb, char *query, DB_LIST_HANDLER *sendit,
+int db_list_sql_query(JCR *jcr, B_DB *mdb, const char *query, DB_LIST_HANDLER *sendit,
                       void *ctx, int verbose, e_list_type type)
 {
    db_lock(mdb);
index 736d94fb31ef44277bf438fe74ef1e8143cdeeba..b276c671bded9b29efa0a94b8eecf128f3af48a8 100644 (file)
@@ -96,7 +96,7 @@ db_update_job_start_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
    char ed1[50], ed2[50], ed3[50], ed4[50];
 
    stime = jr->StartTime;
-   localtime_r(&stime, &tm);
+   (void)localtime_r(&stime, &tm);
    strftime(dt, sizeof(dt), "%Y-%m-%d %H:%M:%S", &tm);
    JobTDate = (btime_t)stime;
 
@@ -157,14 +157,14 @@ db_update_job_end_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
    }
 
    ttime = jr->EndTime;
-   localtime_r(&ttime, &tm);
+   (void)localtime_r(&ttime, &tm);
    strftime(dt, sizeof(dt), "%Y-%m-%d %H:%M:%S", &tm);
 
    if (jr->RealEndTime == 0) {
       jr->RealEndTime = jr->EndTime;
    }
    ttime = jr->RealEndTime;
-   localtime_r(&ttime, &tm);
+   (void)localtime_r(&ttime, &tm);
    strftime(rdt, sizeof(rdt), "%Y-%m-%d %H:%M:%S", &tm);
 
    JobTDate = ttime;
@@ -178,7 +178,7 @@ db_update_job_end_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr)
       (char)(jr->JobStatus), dt, ClientId, edit_uint64(jr->JobBytes, ed1),
       jr->JobFiles, jr->JobErrors, jr->VolSessionId, jr->VolSessionTime,
       PoolId, FileSetId, edit_uint64(JobTDate, ed2), 
-      rdt, 
+      rdt,
       PriorJobId,
       edit_int64(jr->JobId, ed3));
 
@@ -312,7 +312,7 @@ db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
    if (mr->set_first_written) {
       Dmsg1(400, "Set FirstWritten Vol=%s\n", mr->VolumeName);
       ttime = mr->FirstWritten;
-      localtime_r(&ttime, &tm);
+      (void)localtime_r(&ttime, &tm);
       strftime(dt, sizeof(dt), "%Y-%m-%d %H:%M:%S", &tm);
       Mmsg(mdb->cmd, "UPDATE Media SET FirstWritten='%s'"
            " WHERE VolumeName='%s'", dt, mr->VolumeName);
@@ -326,7 +326,7 @@ db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
       if (ttime == 0) {
          ttime = time(NULL);
       }
-      localtime_r(&ttime, &tm);
+      (void)localtime_r(&ttime, &tm);
       strftime(dt, sizeof(dt), "%Y-%m-%d %H:%M:%S", &tm);
       Mmsg(mdb->cmd, "UPDATE Media SET LabelDate='%s' "
            "WHERE VolumeName='%s'", dt, mr->VolumeName);
@@ -335,7 +335,7 @@ db_update_media_record(JCR *jcr, B_DB *mdb, MEDIA_DBR *mr)
 
    if (mr->LastWritten != 0) {
       ttime = mr->LastWritten;
-      localtime_r(&ttime, &tm);
+      (void)localtime_r(&ttime, &tm);
       strftime(dt, sizeof(dt), "%Y-%m-%d %H:%M:%S", &tm);
       Mmsg(mdb->cmd, "UPDATE Media Set LastWritten='%s' "
            "WHERE VolumeName='%s'", dt, mr->VolumeName);
index 38a12f89ca08fe287160f4abe3d334c56761e4e6..b4392f2b06748d9e843bf4c5feec80e2739a632b 100644 (file)
 
 /* Exported variables */
 
-#ifdef HAVE_CYGWIN
-int rl_catch_signals;
-#else
 extern int rl_catch_signals;
-#endif
 #ifdef HAVE_MINGW
 /* Remove when we have real lib in src/lib */
 int enable_vss;
@@ -383,9 +379,9 @@ int main(int argc, char *argv[])
       init_signals(terminate_console);
    }
 
+
 #if !defined(HAVE_WIN32)
    /* Override Bacula default signals */
-// signal(SIGCHLD, SIG_IGN);
    signal(SIGQUIT, SIG_IGN);
    signal(SIGTSTP, got_sigstop);
    signal(SIGCONT, got_sigcontinue);
@@ -533,7 +529,7 @@ try_again:
       FILE *fd;
       pm_strcpy(&UA_sock->msg, env);
       pm_strcat(&UA_sock->msg, "/.bconsolerc");
-      fd = fopen(UA_sock->msg, "r");
+      fd = fopen(UA_sock->msg, "rb");
       if (fd) {
          read_and_process_input(fd, UA_sock);
          fclose(fd);
@@ -780,7 +776,7 @@ static int inputcmd(FILE *input, BSOCK *UA_sock)
       sendit(_("First argument to input command must be a filename.\n"));
       return 1;
    }
-   fd = fopen(argk[1], "r");
+   fd = fopen(argk[1], "rb");
    if (!fd) {
       senditf(_("Cannot open file %s for input. ERR=%s\n"),
          argk[1], strerror(errno));
@@ -809,7 +805,7 @@ static int outputcmd(FILE *input, BSOCK *UA_sock)
 static int do_outputcmd(FILE *input, BSOCK *UA_sock)
 {
    FILE *fd;
-   const char *mode = "a+";
+   const char *mode = "a+b";
 
    if (argc > 3) {
       sendit(_("Too many arguments on output/tee command.\n"));
@@ -855,7 +851,7 @@ static int timecmd(FILE *input, BSOCK *UA_sock)
    char sdt[50];
    time_t ttime = time(NULL);
    struct tm tm;
-   localtime_r(&ttime, &tm);
+   (void)localtime_r(&ttime, &tm);
    strftime(sdt, sizeof(sdt), "%d-%b-%Y %H:%M:%S", &tm);
    sendit("\n");
    return 1;
index 8112adfac3c082293ec11a1c6882adad735a12d3..0336a957cbcee88210594fbb74969bffbcc365b2 100644 (file)
@@ -54,15 +54,14 @@ RES **res_head = sres_head;
  * then move it to allocated memory when the resource
  * scan is complete.
  */
-#if defined(HAVE_WIN32) && !defined(HAVE_CYGWIN)  && !defined(HAVE_MINGW)
+#if defined(_MSC_VER)
 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
+int  res_all_size = sizeof(res_all);
 
 /* Definition of records permitted within each
  * resource with the routine to process the record
index fe7cbc292c15b8364b1c8d55c5e9eb80b4bf452d..ef845c72336edcf1a0705471d09a80d29062f9f0 100644 (file)
@@ -499,7 +499,7 @@ void update_bootstrap_file(JCR *jcr)
          fd = bpipe ? bpipe->wfd : NULL;
       } else {
          /* ***FIXME*** handle BASE */
-         fd = fopen(fname, jcr->JobLevel==L_FULL?"w+":"a+");
+         fd = fopen(fname, jcr->JobLevel==L_FULL?"w+b":"a+b");
       }
       if (fd) {
          VolCount = db_get_job_volume_parameters(jcr, jcr->db, jcr->JobId,
index 2b2e77526e362bdc9e5be97118da1d7ab64b9203..ae4317c452fac02771976d7dc3cad667c2796f41 100644 (file)
@@ -227,7 +227,7 @@ uint32_t write_bsr_file(UAContext *ua, RESTORE_CTX &rx)
    JobId_t JobId;
 
    make_unique_restore_filename(ua, &fname);
-   fd = fopen(fname, "w+");
+   fd = fopen(fname, "w+b");
    if (!fd) {
       berrno be;
       bsendmsg(ua, _("Unable to create bootstrap file %s. ERR=%s\n"),
index 02514e8d498e435eca1f8e31edb7ee05410aa41e..f40b39a41a150e7afc95f045ef3986b97a1fe67b 100644 (file)
@@ -415,7 +415,7 @@ void catalog_update(JCR *jcr, BSOCK *bs)
          Jmsg(jcr, M_WARNING, 0, _("Got %s but not same File as attributes\n"), stream_to_ascii(Stream));
       } else {
          /* Update digest in catalog */
-         char digestbuf[CRYPTO_DIGEST_MAX_SIZE];
+         char digestbuf[BASE64_SIZE(CRYPTO_DIGEST_MAX_SIZE)];
          int len = 0;
          int type = CRYPTO_DIGEST_NONE;
 
index a5f65266e83498457140763b06a95d71b2f48aaf..26af749a6afb015e6e6de8d30a3a6eb6e89fb6dc 100644 (file)
@@ -60,8 +60,14 @@ extern int r_first, r_last;           /* first and last resources */
 extern RES_TABLE resources[];
 extern RES **res_head;
 extern RES_ITEM job_items[];
-extern URES res_all;
 
+#if defined(_MSC_VER)
+extern "C" { // work around visual compiler mangling variables
+    extern URES res_all;
+}
+#else
+extern URES res_all;
+#endif
 
 #define CONFIG_FILE "./bacula-dir.conf" /* default configuration file */
 
@@ -250,6 +256,8 @@ int main (int argc, char *argv[])
    }
 
    terminate_dird(0);
+
+   return 0;
 }
 
 /* Cleanup and then exit */
index 9eedba0e6f9113abf8437228dfb1b221d5ab2bd8..e7ba378dd404625dec84e46d943eb374e1d70bb1 100644 (file)
@@ -72,7 +72,13 @@ static void store_short_runscript(LEX *lc, RES_ITEM *item, int index, int pass);
  * then move it to allocated memory when the resource
  * scan is complete.
  */
+#if defined(_MSC_VER)
+extern "C" { // work around visual compiler mangling variables
+    URES res_all;
+}
+#else
 URES res_all;
+#endif
 int  res_all_size = sizeof(res_all);
 
 
index f6a80fea9739d8a0fc68147d94d19b381ac949a8..56efa2fb2dcc605acdf998a5d0527b1963ed4840 100644 (file)
@@ -77,13 +77,13 @@ struct s_jt {
 
 /* Definition of the contents of each Resource */
 /* Needed for forward references */
-struct SCHED;
-struct CLIENT;
-struct FILESET;
-struct POOL;
-struct RUN;
-struct DEVICE;
-struct RUNSCRIPT;
+class SCHED;
+class CLIENT;
+class FILESET;
+class POOL;
+class RUN;
+class DEVICE;
+class RUNSCRIPT;
 
 /*
  *   Director Resource
index f7d9167b7bd5cf94c207739e6be7fa30dd75f26f..3a414342150bec5b044d69aeaa125023705f45c3 100644 (file)
@@ -37,7 +37,7 @@ static int date_item(JCR *jcr, int code,
 {
    struct tm tm;
    time_t now = time(NULL);
-   localtime_r(&now, &tm);
+   (void)localtime_r(&now, &tm);
    int val = 0;
    char buf[10];
 
index febd1873d82c44b4dfb6ccd09ae672327e9046f5..3d884f4663b81140e4628e5a65915eb7dcd27f0e 100644 (file)
@@ -341,7 +341,7 @@ static bool send_fileset(JCR *jcr)
                break;
             case '<':
                p++;                      /* skip over < */
-               if ((ffd = fopen(p, "r")) == NULL) {
+               if ((ffd = fopen(p, "rb")) == NULL) {
                   berrno be;
                   Jmsg(jcr, M_FATAL, 0, _("Cannot open included file: %s. ERR=%s\n"),
                      p, be.strerror());
@@ -435,7 +435,7 @@ bool send_bootstrap_file(JCR *jcr, BSOCK *sock)
    if (!jcr->RestoreBootstrap) {
       return true;
    }
-   bs = fopen(jcr->RestoreBootstrap, "r");
+   bs = fopen(jcr->RestoreBootstrap, "rb");
    if (!bs) {
       berrno be;
       Jmsg(jcr, M_FATAL, 0, _("Could not open bootstrap file %s: ERR=%s\n"),
index dff8eae194fd225dfb09cbc4795fcf649fac98a7..3b5e0d8d52d6dda23eb358734b78e47c75a3c381 100644 (file)
@@ -51,7 +51,13 @@ static void setup_current_opts(void);
  * then move it to allocated memory when the resource
  * scan is complete.
  */
+#if defined(_MSC_VER)
+extern "C" { // work around visual compiler mangling variables
+    extern URES res_all;
+}
+#else
 extern URES res_all;
+#endif
 extern int  res_all_size;
 
 /* We build the current new Include and Exclude items here */
@@ -246,7 +252,7 @@ static void scan_include_options(LEX *lc, int keyword, char *opts, int optlen)
     */
    } else {
       for (i=0; FS_options[i].name; i++) {
-         if (strcasecmp(lc->str, FS_options[i].name) == 0 && FS_options[i].keyword == keyword) {
+         if (FS_options[i].keyword == keyword && strcasecmp(lc->str, FS_options[i].name) == 0) {
             /* NOTE! maximum 2 letters here or increase option[3] */
             option[0] = FS_options[i].option[0];
             option[1] = FS_options[i].option[1];
index 09499daa3e011840862c36110b1d2dd264af1cbb..984f932041df1e7dda2ff5a823e36afc2d0c9a8b 100644 (file)
@@ -771,7 +771,7 @@ void create_unique_job_name(JCR *jcr, const char *base_name)
    V(mutex);                          /* allow creation of jobs */
    jcr->start_time = now;
    /* Form Unique JobName */
-   localtime_r(&now, &tm);
+   (void)localtime_r(&now, &tm);
    /* Use only characters that are permitted in Windows filenames */
    strftime(dt, sizeof(dt), "%Y-%m-%d_%H.%M.%S", &tm);
    bstrncpy(name, base_name, sizeof(name));
index 44337d50fb5777815ceec3c2fca9fe234ce148c5..b7eb4896d06ce16be75bf567f0c31d71ae612806 100644 (file)
 #include "bacula.h"
 #include "dird.h"
 
+#if defined(_MSC_VER)
+extern "C" { // work around visual compiler mangling variables
+   extern URES res_all;
+}
+#else
 extern URES res_all;
+#endif
 extern struct s_jl joblevels[];
 
 /* Forward referenced subroutines */
index 498bef71f7f20c817ccbfd2b897a972b557aadc7..ada34c437ab1410386f8100c14bb5c534f4c3d1f 100644 (file)
@@ -259,7 +259,7 @@ static void find_runs()
 
    /* compute values for time now */
    now = time(NULL);
-   localtime_r(&now, &tm);
+   (void)localtime_r(&now, &tm);
    hour = tm.tm_hour;
    minute = tm.tm_min;
    mday = tm.tm_mday - 1;
@@ -274,7 +274,7 @@ static void find_runs()
     * sleeping.
     */
    next_hour = now + 3600;
-   localtime_r(&next_hour, &tm);
+   (void)localtime_r(&next_hour, &tm);
    nh_hour = tm.tm_hour;
    nh_mday = tm.tm_mday - 1;
    nh_wday = tm.tm_wday;
@@ -336,7 +336,7 @@ static void find_runs()
          Dmsg3(dbglvl, "run@%p: run_now=%d run_nh=%d\n", run, run_now, run_nh);
 
          /* find time (time_t) job is to be run */
-         localtime_r(&now, &tm);      /* reset tm structure */
+         (void)localtime_r(&now, &tm);      /* reset tm structure */
          tm.tm_min = run->minute;     /* set run minute */
          tm.tm_sec = 0;               /* zero secs */
          if (run_now) {
index a5291a751c5b09e8c9bd523f70ea59b735182ac6..de34bead738c92cba0346982a3376731f1368b2d 100644 (file)
@@ -69,14 +69,13 @@ const char *drop_deltabs[] = {
 /* List of SQL commands to create temp table and indicies  */
 const char *create_deltabs[] = {
    "CREATE TEMPORARY TABLE DelCandidates ("
-#ifdef HAVE_MYSQL
+#if defined(HAVE_MYSQL)
       "JobId INTEGER UNSIGNED NOT NULL, "
       "PurgedFiles TINYINT, "
       "FileSetId INTEGER UNSIGNED, "
       "JobFiles INTEGER UNSIGNED, "
       "JobStatus BINARY(1))",
-#else
-#ifdef HAVE_POSTGRESQL
+#elif defined(HAVE_POSTGRESQL)
       "JobId INTEGER NOT NULL, "
       "PurgedFiles SMALLINT, "
       "FileSetId INTEGER, "
@@ -88,7 +87,6 @@ const char *create_deltabs[] = {
       "FileSetId INTEGER UNSIGNED, "
       "JobFiles INTEGER UNSIGNED, "
       "JobStatus CHAR)",
-#endif
 #endif
    "CREATE INDEX DelInx1 ON DelCandidates (JobId)",
    NULL};
@@ -194,7 +192,7 @@ const char *uar_file =
    "AND Job.JobId=File.JobId "
    "AND Path.PathId=File.PathId AND Filename.FilenameId=File.FilenameId "
    "AND Filename.Name='%s' ORDER BY StartTime DESC LIMIT 20";
- #endif
+#endif
 
 
 /*
index 9b19f765c7aa17fbf0cecf6b1c16999dddc87f3f..7e71408bb4f3ccf0d4cdb6f91c601033d8d60b7a 100644 (file)
@@ -1084,7 +1084,7 @@ static int time_cmd(UAContext *ua, const char *cmd)
    char sdt[50];
    time_t ttime = time(NULL);
    struct tm tm;
-   localtime_r(&ttime, &tm);
+   (void)localtime_r(&ttime, &tm);
    strftime(sdt, sizeof(sdt), "%d-%b-%Y %H:%M:%S", &tm);
    bsendmsg(ua, "%s\n", sdt);
    return 1;
index d53d41ad1103cc30984b121180f39b73002e7428..a738dfe326aab085c81c65efc16304ee70ef9d28 100644 (file)
@@ -537,7 +537,7 @@ RUN *find_next_run(RUN *run, JOB *job, time_t &runtime, int ndays)
          future = now + (day * 60 * 60 * 24);
 
          /* Break down the time into components */
-         localtime_r(&future, &tm);
+         (void)localtime_r(&future, &tm);
          mday = tm.tm_mday - 1;
          wday = tm.tm_wday;
          month = tm.tm_mon;
@@ -571,7 +571,7 @@ RUN *find_next_run(RUN *run, JOB *job, time_t &runtime, int ndays)
             Dmsg1(000, "%s", buf);
 #endif
             /* find time (time_t) job is to be run */
-            localtime_r(&future, &runtm);
+            (void)localtime_r(&future, &runtm);
             for (i= 0; i < 24; i++) {
                if (bit_is_set(i, run->hour)) {
                   runtm.tm_hour = i;
index e6d65dd51225cc011e7216ae57787e5e5dd5d00b..bfbaf8f748dfeb52b2bc82d59628a69769733b02 100644 (file)
 #define MAX_DEL_LIST_LEN 2000000
 
 /* Imported variables */
-extern char *select_job;
-extern char *drop_deltabs[];
-extern char *create_deltabs[];
-extern char *insert_delcand;
-extern char *select_backup_del;
-extern char *select_verify_del;
-extern char *select_restore_del;
-extern char *select_admin_del;
-extern char *cnt_File;
-extern char *del_File;
-extern char *upd_Purged;
-extern char *cnt_DelCand;
-extern char *del_Job;
-extern char *del_MAC;
-extern char *del_JobMedia;
-extern char *cnt_JobMedia;
-extern char *sel_JobMedia;
+extern const char *select_job;
+extern const char *drop_deltabs[];
+extern const char *create_deltabs[];
+extern const char *insert_delcand;
+extern const char *select_backup_del;
+extern const char *select_verify_del;
+extern const char *select_restore_del;
+extern const char *select_admin_del;
+extern const char *cnt_File;
+extern const char *del_File;
+extern const char *upd_Purged;
+extern const char *cnt_DelCand;
+extern const char *del_Job;
+extern const char *del_MAC;
+extern const char *del_JobMedia;
+extern const char *cnt_JobMedia;
+extern const char *sel_JobMedia;
 
 
 /* In memory list of JobIds */
index ba8cd815343298edf1fa2cf161791c2825931d96..6e1a3c2b845a6ad51123bb4a422a444525d1ac7a 100644 (file)
@@ -55,7 +55,7 @@ int querycmd(UAContext *ua, const char *cmd)
    if (!open_db(ua)) {
       goto bail_out;
    }
-   if ((fd=fopen(query_file, "r")) == NULL) {
+   if ((fd=fopen(query_file, "rb")) == NULL) {
       bsendmsg(ua, _("Could not open %s: ERR=%s\n"), query_file,
          strerror(errno));
       goto bail_out;
index a625da14c9d40e076111b73fff87e5afe53958a7..78889be8ff40952ff00380dd3b4ce9a558c379a3 100644 (file)
 extern void print_bsr(UAContext *ua, RBSR *bsr);
 
 /* Imported variables */
-extern char *uar_list_jobs,      *uar_file,        *uar_sel_files;
-extern char *uar_del_temp,       *uar_del_temp1,   *uar_create_temp;
-extern char *uar_create_temp1,   *uar_last_full,   *uar_full;
-extern char *uar_inc,            *uar_list_temp,   *uar_sel_jobid_temp;
-extern char *uar_sel_all_temp1,  *uar_sel_fileset, *uar_mediatype;
-extern char *uar_jobid_fileindex, *uar_dif,        *uar_sel_all_temp;
-extern char *uar_count_files,     *uar_jobids_fileindex;
-extern char *uar_jobid_fileindex_from_dir;
-extern char *uar_jobid_fileindex_from_table;
+extern const char *uar_list_jobs,      *uar_file,        *uar_sel_files;
+extern const char *uar_del_temp,       *uar_del_temp1,   *uar_create_temp;
+extern const char *uar_create_temp1,   *uar_last_full,   *uar_full;
+extern const char *uar_inc,            *uar_list_temp,   *uar_sel_jobid_temp;
+extern const char *uar_sel_all_temp1,  *uar_sel_fileset, *uar_mediatype;
+extern const char *uar_jobid_fileindex, *uar_dif,        *uar_sel_all_temp;
+extern const char *uar_count_files,     *uar_jobids_fileindex;
+extern const char *uar_jobid_fileindex_from_dir;
+extern const char *uar_jobid_fileindex_from_table;
 
 
 
@@ -276,7 +276,7 @@ static int user_select_jobids_or_files(UAContext *ua, RESTORE_CTX *rx)
    char date[MAX_TIME_LENGTH];
    bool have_date = false;
    JobId_t JobId;
-   JOB_DBR jr;
+   JOB_DBR jr = { (JobId_t)-1 };
    bool done = false;
    int i, j;
    const char *list[] = {
@@ -678,7 +678,7 @@ static void insert_one_file_or_dir(UAContext *ua, RESTORE_CTX *rx, char *date, b
    switch (*p) {
    case '<':
       p++;
-      if ((ffd = fopen(p, "r")) == NULL) {
+      if ((ffd = fopen(p, "rb")) == NULL) {
          berrno be;
          bsendmsg(ua, _("Cannot open file %s: ERR=%s\n"),
             p, be.strerror());
index 52315f69762ffa505d858c3c85fe6c5b8b3da9c5..5aa292d101d5291b914b6982b457188d666cee37 100644 (file)
@@ -866,7 +866,7 @@ try_again:
          }
          if (ua->cmd[0] != 0) {
             jcr->RestoreBootstrap = bstrdup(ua->cmd);
-            fd = fopen(jcr->RestoreBootstrap, "r");
+            fd = fopen(jcr->RestoreBootstrap, "rb");
             if (!fd) {
                bsendmsg(ua, _("Warning cannot open %s: ERR=%s\n"),
                   jcr->RestoreBootstrap, strerror(errno));
index ccf7db8916af20a9364df3dcd63fee241eb50c03..75a1a3489d59c3ed52930c9eb6626ac689431f81 100644 (file)
@@ -26,7 +26,7 @@
 #include "dird.h"
 
 /* External variables */
-extern char *list_pool;               /* in sql_cmds.c */
+extern const char *list_pool;               /* in sql_cmds.c */
 
 /* Imported functions */
 void update_slots(UAContext *ua);
index 1651f2d457669f934e030344205219d596a117b0..ccf2e660f37a856a010e2d7a094a52a603f38d6a 100644 (file)
@@ -67,6 +67,7 @@ static int tally_file(FF_PKT *ff_pkt, void *ijcr, bool top_level)
    case FT_NORECURSE:
    case FT_NOFSCHG:
    case FT_INVALIDFS:
+   case FT_INVALIDDT:
    case FT_DIREND:
    case FT_SPEC:
    case FT_RAW:
index ae021bbf2c456c147e877db962fcec564c22e97d..5145735a1cab7b41c4428a31f52d59b018b55302 100644 (file)
@@ -74,7 +74,7 @@ static void usage()
  *  Main Bacula Unix Client Program
  *
  */
-#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
+#if defined(HAVE_WIN32)
 #define main BaculaMain
 #endif
 
index e20709827dd6c89f7f4aa22c5a4b1721775641d1..f06d921efff60ca9917f8a56736f44ed86195998 100644 (file)
@@ -57,15 +57,14 @@ RES **res_head = sres_head;
  * then move it to allocated memory when the resource
  * scan is complete.
  */
-#if defined(HAVE_WIN32) && !defined(HAVE_CYGWIN)
+#if defined(_MSC_VER)
 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
+int  res_all_size = sizeof(res_all);
 
 /* Definition of records permitted within each
  * resource with the routine to process the record
index 1e6835c780f8a1733f3f7695e5287be53c418da8..96365bff361bd1841a0ce3cf2fa0c96494c59f51 100644 (file)
@@ -338,9 +338,7 @@ static int cancel_cmd(JCR *jcr)
          if (cjcr->store_bsock) {
             cjcr->store_bsock->timed_out = 1;
             cjcr->store_bsock->terminated = 1;
-#if !defined(HAVE_CYGWIN)
             pthread_kill(cjcr->my_thread_id, TIMEOUT_SIGNAL);
-#endif
          }
          set_jcr_job_status(cjcr, JS_Canceled);
          free_jcr(cjcr);
@@ -400,7 +398,7 @@ static int job_cmd(JCR *jcr)
 {
    BSOCK *dir = jcr->dir_bsock;
    POOLMEM *sd_auth_key;
-   
+
    sd_auth_key = get_memory(dir->msglen);
    if (sscanf(dir->msg, jobcmd,  &jcr->JobId, jcr->Job,
               &jcr->VolSessionId, &jcr->VolSessionTime,
@@ -604,7 +602,7 @@ static void add_file_to_fileset(JCR *jcr, const char *fname, findFILESET *filese
    case '<':
       Dmsg0(100, "Doing < include on client.\n");
       p++;                      /* skip over < */
-      if ((ffd = fopen(p, "r")) == NULL) {
+      if ((ffd = fopen(p, "rb")) == NULL) {
          berrno be;
          Jmsg(jcr, M_FATAL, 0, _("Cannot open FileSet input file: %s. ERR=%s\n"),
             p, be.strerror());
@@ -1011,7 +1009,7 @@ static int bootstrap_cmd(JCR *jcr)
       jcr->Job);
    Dmsg1(400, "bootstrap=%s\n", fname);
    jcr->RestoreBootstrap = fname;
-   bs = fopen(fname, "a+");           /* create file */
+   bs = fopen(fname, "a+b");           /* create file */
    if (!bs) {
       berrno be;
       Jmsg(jcr, M_FATAL, 0, _("Could not create bootstrap file %s: ERR=%s\n"),
@@ -1695,7 +1693,7 @@ static int send_bootstrap_file(JCR *jcr)
    if (!jcr->RestoreBootstrap) {
       return 1;
    }
-   bs = fopen(jcr->RestoreBootstrap, "r");
+   bs = fopen(jcr->RestoreBootstrap, "rb");
    if (!bs) {
       berrno be;
       Jmsg(jcr, M_FATAL, 0, _("Could not open bootstrap file %s: ERR=%s\n"),
index e96060aead2221e86c8fd980e5ddb566c815811b..2c90d7a0a9d1d810891d77ee204e9bbdc185e9f1 100755 (executable)
@@ -40,7 +40,7 @@ static char qstatus[] = ".status %s\n";
 static char OKqstatus[]   = "2000 OK .status\n";
 static char DotStatusJob[] = "JobId=%d JobStatus=%c JobErrors=%d\n";
 
-#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
+#if defined(HAVE_WIN32)
 static int privs = 0;
 #endif
 #ifdef WIN32_VSS
@@ -71,7 +71,7 @@ static void do_status(void sendit(const char *msg, int len, void *sarg), void *a
    len = Mmsg(msg, _("Daemon started %s, %d Job%s run since started.\n"),
         dt, num_jobs_run, num_jobs_run == 1 ? "" : "s");
    sendit(msg, len, arg);
-#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
+#if defined(HAVE_WIN32)
    if (debug_level > 0) {
       if (!privs) {
          privs = enable_backup_privileges(NULL, 1);
@@ -402,7 +402,7 @@ static const char *level_to_str(int level)
 }
 
 
-#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
+#if defined(HAVE_WIN32)
 #include <windows.h>
 
 int bacstat = 0;
@@ -493,4 +493,4 @@ done:
    return buf;
 }
 
-#endif /* HAVE_CYGWIN */
+#endif /* HAVE_WIN32 */
index 3988eae7aa79418b545fab231ace632290e99f0c..fdf0c67322c1bc3bd3a47524e6e2e4d7ccf2ec0e 100755 (executable)
@@ -26,7 +26,7 @@
 #include "bacula.h"
 #include "find.h"
 
-#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
+#if defined(HAVE_WIN32)
 
 #include "../lib/winapi.h"
 
@@ -36,7 +36,7 @@ static bool set_win32_attributes(JCR *jcr, ATTR *attr, BFILE *ofd);
 void unix_name_to_win32(POOLMEM **win32_name, char *name);
 void win_error(JCR *jcr, char *prefix, POOLMEM *ofile);
 HANDLE bget_handle(BFILE *bfd);
-#endif
+#endif /* HAVE_WIN32 */
 
 /* For old systems that don't have lchown() use chown() */
 #ifndef HAVE_LCHOWN
@@ -219,6 +219,7 @@ void encode_stat(char *buf, FF_PKT *ff_pkt, int data_stream)
   #endif
 #endif
 
+
 /* Decode a stat packet from base64 characters */
 int decode_stat(char *buf, struct stat *statp, int32_t *LinkFI)
 {
@@ -362,7 +363,7 @@ bool set_attributes(JCR *jcr, ATTR *attr, BFILE *ofd)
    bool ok = true;
    off_t fsize;
 
-#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
+#if defined(HAVE_WIN32)
    if (attr->stream == STREAM_UNIX_ATTRIBUTES_EX &&
        set_win32_attributes(jcr, attr, ofd)) {
        if (is_bopen(ofd)) {
@@ -467,7 +468,7 @@ bool set_attributes(JCR *jcr, ATTR *attr, BFILE *ofd)
 /*                                                             */
 /*=============================================================*/
 
-#if !defined(HAVE_CYGWIN) && !defined(HAVE_WIN32)
+#if !defined(HAVE_WIN32)
 
 /*
  * It is possible to piggyback additional data e.g. ACLs on
@@ -507,7 +508,7 @@ int encode_attribsEx(JCR *jcr, char *attribsEx, FF_PKT *ff_pkt)
 /*                                                             */
 /*=============================================================*/
 
-#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
+#if defined(HAVE_WIN32)
 
 int encode_attribsEx(JCR *jcr, char *attribsEx, FF_PKT *ff_pkt)
 {
@@ -726,4 +727,4 @@ void unix_name_to_win32(POOLMEM **win32_name, char *name)
    conv_unix_to_win32_path(name, *win32_name, dwSize);
 }
 
-#endif  /* HAVE_CYGWIN */
+#endif  /* HAVE_WIN32 */
index 21ea1705bd6bf02329c1c217590e162f4bd65347..8f930ed5d2c9f187aa4e46d78f9c160edd3794b5 100644 (file)
@@ -253,7 +253,7 @@ bool processWin32BackupAPIBlock (BFILE *bfd, void *pBuffer, ssize_t dwSize)
  * ===============================================================
  */
 
-#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
+#if defined(HAVE_WIN32)
 
 void unix_name_to_win32(POOLMEM **win32_name, char *name);
 extern "C" HANDLE get_osfhandle(int fd);
index 46b58cc1c7b444d75edd1ab74c9d380c75ba3eb5..69cce6fb68540aa8a50149d5d3647d681d27677a 100644 (file)
@@ -64,7 +64,7 @@ typedef struct _PROCESS_WIN32_BACKUPAPIBLOCK_CONTEXT {
  *
  *  =======================================================
  */
-#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
+#if defined(HAVE_WIN32)
 
 #include <windows.h>
 #include "../lib/winapi.h"
@@ -79,7 +79,7 @@ enum {
 
 /* Basic Win32 low level I/O file packet */
 struct BFILE {
-   int use_backup_api;                /* set if using BackupRead/Write */
+   bool use_backup_api;               /* set if using BackupRead/Write */
    int mode;                          /* set if file is open */
    HANDLE fh;                         /* Win32 file handle */
    int fid;                           /* fd if doing Unix style */
diff --git a/bacula/src/findlib/drivetype.c b/bacula/src/findlib/drivetype.c
new file mode 100644 (file)
index 0000000..a12fef3
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ *  Implement routines to determine drive type (Windows specific).
+ *
+ *   Written by Robert Nelson, June 2006
+ *
+ *   Version $Id$
+ */
+
+/*
+   Copyright (C) 2006 Kern Sibbald
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   version 2 as amended with additional clauses defined in the
+   file LICENSE in the main source directory.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+   the file LICENSE for additional details.
+
+ */
+
+#ifndef TEST_PROGRAM
+
+#include "bacula.h"
+#include "find.h"
+
+#else /* Set up for testing a stand alone program */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#define SUPPORTEDOSES \
+   "HAVE_WIN32\n"
+#define false              0
+#define true               1
+#define bstrncpy           strncpy
+#define Dmsg0(n,s)         fprintf(stderr, s)
+#define Dmsg1(n,s,a1)      fprintf(stderr, s, a1)
+#define Dmsg2(n,s,a1,a2)   fprintf(stderr, s, a1, a2)
+#endif
+
+/*
+ * These functions should be implemented for each OS
+ *
+ *       bool drivetype(const char *fname, char *dt, int dtlen);
+ */
+
+#if defined (HAVE_WIN32)
+/* Windows */
+
+bool drivetype(const char *fname, char *dt, int dtlen)
+{
+   CHAR rootpath[4];
+   UINT type;
+
+   /* Copy Drive Letter, colon, and backslash to rootpath */
+   bstrncpy(rootpath, fname, 3);
+   rootpath[3] = '\0';
+
+   type = GetDriveType(rootpath);
+
+   switch (type) {
+   case DRIVE_REMOVABLE:   bstrncpy(dt, "removable", dtlen);   return true;
+   case DRIVE_FIXED:       bstrncpy(dt, "fixed", dtlen);       return true;
+   case DRIVE_REMOTE:      bstrncpy(dt, "remote", dtlen);      return true;
+   case DRIVE_CDROM:       bstrncpy(dt, "cdrom", dtlen);       return true;
+   case DRIVE_RAMDISK:     bstrncpy(dt, "ramdisk", dtlen);     return true;
+   case DRIVE_UNKNOWN:
+   case DRIVE_NO_ROOT_DIR:
+   default:
+      return false;
+   }
+}
+/* Windows */
+
+#else    /* No recognised OS */
+
+bool drivetype(const char *fname, char *dt, int dtlen)
+{
+   Dmsg0(10, "!!! drivetype() not implemented for this OS. !!!\n");
+#ifdef TEST_PROGRAM
+   Dmsg1(10, "Please define one of the following when compiling:\n\n%s\n",
+         SUPPORTEDOSES);
+   exit(EXIT_FAILURE);
+#endif
+
+   return false;
+}
+#endif
+
+#ifdef TEST_PROGRAM
+int main(int argc, char **argv)
+{
+   char *p;
+   char dt[1000];
+   int status = 0;
+
+   if (argc < 2) {
+      p = (argc < 1) ? "drivetype" : argv[0];
+      printf("usage:\t%s path ...\n"
+            "\t%s prints the drive type and pathname of the paths.\n",
+            p, p);
+      return EXIT_FAILURE;
+   }
+   while (*++argv) {
+      if (!drivetype(*argv, dt, sizeof(dt))) {
+         status = EXIT_FAILURE;
+      } else {
+         printf("%s\t%s\n", dt, *argv);
+      }
+   }
+   return status;
+}
+#endif
index 8fd78fbd9c7eeaad307e60e594cb3c3c150e2b5b..34539eb8ebd57312c72fc525b4f830abc27ea3bf 100755 (executable)
@@ -37,7 +37,7 @@
 /*                                                             */
 /*=============================================================*/
 
-#if !defined(HAVE_CYGWIN) && !defined(HAVE_WIN32)
+#if !defined(HAVE_WIN32)
 
 int enable_backup_privileges(JCR *jcr, int ignore_errors)
  { return 0; }
@@ -53,7 +53,7 @@ int enable_backup_privileges(JCR *jcr, int ignore_errors)
 /*                                                             */
 /*=============================================================*/
 
-#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
+#if defined(HAVE_WIN32)
 
 void win_error(JCR *jcr, char *prefix, DWORD lerror);
 
@@ -155,4 +155,4 @@ int enable_backup_privileges(JCR *jcr, int ignore_errors)
     return stat;
 }
 
-#endif  /* HAVE_CYGWIN */
+#endif  /* HAVE_WIN32 */
index 1565234489e523ad37da81eaf9dc8d83ef5ca535..8fde075a359c32585844774bcac12319d3a9628f 100644 (file)
@@ -97,7 +97,7 @@ get_win32_driveletters(FF_PKT *ff, char* szDrives)
 {
    /* szDrives must be at least 27 bytes long */
 
-#ifndef WIN32
+#if !defined(HAVE_WIN32)
    return 0;
 #endif
 
@@ -209,9 +209,9 @@ static bool accept_file(FF_PKT *ff)
                if (ff->flags & FO_EXCLUDE) {
                   Dmsg2(100, "Exclude wilddir: %s file=%s\n", (char *)fo->wilddir.get(k),
                      ff->fname);
-                  return false;       /* reject file */
+                  return false;       /* reject dir */
                }
-               return true;           /* accept file */
+               return true;           /* accept dir */
             }
          }
       } else {
@@ -325,6 +325,7 @@ static int our_callback(FF_PKT *ff, void *hpkt, bool top_level)
    case FT_NORECURSE:
    case FT_NOFSCHG:
    case FT_INVALIDFS:
+   case FT_INVALIDDT:
    case FT_NOOPEN:
 //    return ff->callback(ff, hpkt, top_level);
 
index 11eb9f804e1689105db6b1a4b85e1348c2cc71df..70e7feaf4c75d78c4ade637c41c60254b21a2e2a 100644 (file)
@@ -136,7 +136,7 @@ make_dir(JCR *jcr, const char *dir, const char *dirpath, mode_t mode, int *creat
 int
 isAbsolute(const char *path)
 {
-#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
+#if defined(HAVE_WIN32)
     return path[1] == ':' || *path == '/' || *path == '\\';     /* drivespec:/blah is absolute */
 #else
     return *path == '/';
@@ -213,12 +213,6 @@ make_path(
         re_protect = 0;
       }
 
-#if defined(HAVE_CYGWIN)
-      /* Because of silly Win32 security, we allow everything */
-      tmp_mode = S_IRWXUGO;
-      re_protect = 0;
-
-#endif
 #if defined(HAVE_WIN32)
       // chdir can fail if permissions are sufficiently restricted since I don't think
       // backup/restore security rights affect ChangeWorkingDirectory
index a5d9d8f7136b1890652a0871d0a164e22d564a70..4c239840a953d1ad2b36e79f6496a62ff6a5f36f 100644 (file)
@@ -39,7 +39,7 @@
 #endif
 
 /* Fold case in fnmatch() on Win32 */
-#ifdef WIN32
+#ifdef HAVE_WIN32
 static const int fnmode = FNM_CASEFOLD;
 #else
 static const int fnmode = 0;
@@ -213,7 +213,7 @@ void add_fname_to_include_list(FF_PKT *ff, int prefixed, const char *fname)
          break;
       }
    }
-#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
+#if defined(HAVE_WIN32)
    /* Convert any \'s into /'s */
    for (p=inc->fname; *p; p++) {
       if (*p == '\\') {
@@ -247,7 +247,7 @@ void add_fname_to_exclude_list(FF_PKT *ff, const char *fname)
 
    Dmsg1(20, "Add name to exclude: %s\n", fname);
 
-#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
+#if defined(HAVE_WIN32)
    if (strchr(fname, '/') || strchr(fname, '\\')) {
 #else
    if (strchr(fname, '/')) {
@@ -263,7 +263,7 @@ 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)
+#if defined(HAVE_WIN32)
    /* Convert any \'s into /'s */
    for (char *p=exc->fname; *p; p++) {
       if (*p == '\\') {
index d81b00cd187a4c498f6a494078767bde565fa670..19e83ce49d7820517cc72b0c0290f316d5e7ba06 100644 (file)
@@ -157,7 +157,7 @@ bin_to_base64(char *buf, char *bin, int len)
       }
       save = reg;
       reg >>= (rem - 6);
-      buf[j++] = base64_digits[reg & (uint32_t)0x3F];
+      buf[j++] = base64_digits[reg & 0x3F];
       reg = save;
       rem -= 6;
    }
index 03b4eb381afcd111a63612e427bbe9222153526b..76641fd49b7ba645f3e30cde43e974e0353edc90 100644 (file)
@@ -36,12 +36,13 @@ extern int execvp_errors[];
 
 const char *berrno::strerror()
 {
-   int stat = 0;
 #ifdef HAVE_WIN32
    if (berrno_ & b_errno_win32) {
       return (const char *)buf_;
    }
 #else
+   int stat = 0;
+
    if (berrno_ & b_errno_exit) {
       stat = (berrno_ & ~b_errno_exit);       /* remove bit */
       if (stat == 0) {
index eb58d956b418d48ec679437c2b60e6971d1ead23..7ebaecd9403796c43ac6e53cde276685ab4d56d1 100644 (file)
@@ -1003,7 +1003,7 @@ bool bnet_set_buffer_size(BSOCK * bs, uint32_t size, int rw)
  * Returns previous socket flag
  */
 int bnet_set_nonblocking (BSOCK *bsock) {
-#ifndef WIN32
+#ifndef HAVE_WIN32
    int oflags;
 
    /* Get current flags */
@@ -1038,7 +1038,7 @@ int bnet_set_nonblocking (BSOCK *bsock) {
  */
 int bnet_set_blocking (BSOCK *bsock) 
 {
-#ifndef WIN32
+#ifndef HAVE_WIN32
    int oflags;
    /* Get current flags */
    if ((oflags = fcntl(bsock->fd, F_GETFL, 0)) < 0) {
@@ -1071,7 +1071,7 @@ int bnet_set_blocking (BSOCK *bsock)
  */
 void bnet_restore_blocking (BSOCK *bsock, int flags) 
 {
-#ifndef WIN32
+#ifndef HAVE_WIN32
    if ((fcntl(bsock->fd, F_SETFL, flags)) < 0) {
       berrno be;
       Jmsg1(bsock->jcr, M_ABORT, 0, _("fcntl F_SETFL error. ERR=%s\n"), be.strerror());
index a28f3650b395b43aa1058c91d913e5694d369cda..12a5d8b925397c591c0a329e84314ff79d0165ee 100644 (file)
@@ -32,7 +32,7 @@ int execvp_errors[] = {
         E2BIG,
         ENAMETOOLONG,
         ENOMEM,
-#ifndef WIN32
+#ifndef HAVE_WIN32
         ETXTBSY,
 #endif
         ENOENT
@@ -232,7 +232,7 @@ int close_bpipe(BPIPE *bpipe)
          }
          Dmsg1(800, "child status=%d\n", stat & ~b_errno_exit);
       } else if (WIFSIGNALED(chldstatus)) {  /* process died */
-#ifndef WIN32
+#ifndef HAVE_WIN32
          stat = WTERMSIG(chldstatus);
 #else
 #warning "WTERMSIG undefined in Win32 !!!"
index 41f62cf4d8373b0b886e9e61c004e82dd11aa36b..7849266e3994f11744c53a45a3adce6dd9f8de57 100644 (file)
@@ -38,7 +38,7 @@
 
 #include "bacula.h"
 
-#if !defined(HAVE_CYGWIN) && !defined(HAVE_WIN32)
+#if !defined(HAVE_WIN32)
 
 #ifdef NEED_SHARED_MEMORY
 #define SHM_KEY 0x0BACB01            /* key for shared memory */
@@ -145,6 +145,6 @@ void shm_destroy(BSHM *shm)
 #endif
 }
 
-#endif /* ! HAVE_CYGWIN */
+#endif /* ! HAVE_WIN32 */
 
 #endif
index 7ccfa0f9b3544838f99978b5120e04fb9b01222a..26a9b72cae212edfec376179203d659d79ff9db9 100644 (file)
@@ -417,7 +417,7 @@ void b_memset(const char *file, int line, void *mem, int val, size_t num)
 }
 #endif
 
-#if !defined(HAVE_CYGWIN) && !defined(HAVE_WIN32)
+#if !defined(HAVE_WIN32)
 static int del_pid_file_ok = FALSE;
 #endif
 
@@ -426,7 +426,7 @@ static int del_pid_file_ok = FALSE;
  */
 void create_pid_file(char *dir, const char *progname, int port)
 {
-#if !defined(HAVE_CYGWIN) && !defined(HAVE_WIN32)
+#if !defined(HAVE_WIN32)
    int pidfd, len;
    int oldpid;
    char  pidbuf[20];
@@ -469,7 +469,7 @@ void create_pid_file(char *dir, const char *progname, int port)
  */
 int delete_pid_file(char *dir, const char *progname, int port)
 {
-#if !defined(HAVE_CYGWIN)  && !defined(HAVE_WIN32)
+#if !defined(HAVE_WIN32)
    POOLMEM *fname = get_pool_memory(PM_FNAME);
 
    if (!del_pid_file_ok) {
index 943a8860883b67356e7c00545a855fa840af7c73..79fc7578f96af9ccc57b86e865a97ffab1fb1aab 100644 (file)
@@ -48,7 +48,7 @@ char *bstrftime(char *dt, int maxlen, utime_t tim)
    struct tm tm;
 
    /* ***FIXME**** the format and localtime_r() should be user configurable */
-   localtime_r(&ttime, &tm);
+   (void)localtime_r(&ttime, &tm);
    strftime(dt, maxlen, "%d-%b-%Y %H:%M", &tm);
    return dt;
 }
@@ -60,7 +60,7 @@ char *bstrftimes(char *dt, int maxlen, utime_t tim)
    struct tm tm;
 
    /* ***FIXME**** the format and localtime_r() should be user configurable */
-   localtime_r(&ttime, &tm);
+   (void)localtime_r(&ttime, &tm);
    strftime(dt, maxlen, "%d-%b-%Y %H:%M:%S", &tm);
    return dt;
 }
@@ -73,7 +73,7 @@ char *bstrftime_ny(char *dt, int maxlen, utime_t tim)
    struct tm tm;
 
    /* ***FIXME**** the format and localtime_r() should be user configurable */
-   localtime_r(&ttime, &tm);
+   (void)localtime_r(&ttime, &tm);
    strftime(dt, maxlen, "%d-%b %H:%M", &tm);
    return dt;
 }
@@ -86,7 +86,7 @@ char *bstrftime_nc(char *dt, int maxlen, utime_t tim)
    struct tm tm;
 
    /* ***FIXME**** the format and localtime_r() should be user configurable */
-   localtime_r(&ttime, &tm);
+   (void)localtime_r(&ttime, &tm);
    /* NOTE! since the compiler complains about %y, I use %y and cut the century */
    strftime(dt, maxlen, "%d-%b-%Y %H:%M", &tm);
    strcpy(dt+7, dt+9);
@@ -99,7 +99,7 @@ char *bstrutime(char *dt, int maxlen, utime_t tim)
 {
    time_t ttime = (time_t)tim;
    struct tm tm;
-   localtime_r(&ttime, &tm);
+   (void)localtime_r(&ttime, &tm);
    strftime(dt, maxlen, "%Y-%m-%d %H:%M:%S", &tm);
    return dt;
 }
@@ -197,12 +197,12 @@ int tm_woy(time_t stime)
    time_t time4;
    struct tm tm;
    memset(&tm, 0, sizeof(struct tm));
-   localtime_r(&stime, &tm);
+   (void)localtime_r(&stime, &tm);
    tm_yday = tm.tm_yday;
    tm.tm_mon = 0;
    tm.tm_mday = 4;
    time4 = mktime(&tm);
-   localtime_r(&time4, &tm);
+   (void)localtime_r(&time4, &tm);
    fty = 1 - tm.tm_wday;
    if (fty <= 0) {
       fty += 7;
@@ -221,7 +221,7 @@ void get_current_time(struct date_time *dt)
    time_t now;
 
    now = time(NULL);
-   gmtime_r(&now, &tm);
+   (void)gmtime_r(&now, &tm);
    Dmsg6(200, "m=%d d=%d y=%d h=%d m=%d s=%d\n", tm.tm_mon+1, tm.tm_mday, tm.tm_year+1900,
       tm.tm_hour, tm.tm_min, tm.tm_sec);
    tm_encode(dt, &tm);
index 871a25e169c1ec4dd6d3adc7227c3795e3ea6031..540c5f711e9cb99fbb4b8d64bd522598ea786e54 100644 (file)
@@ -34,7 +34,7 @@ extern int debug_level;
 void
 daemon_start()
 {
-#if !defined(HAVE_CYGWIN) && !defined(HAVE_WIN32)
+#if !defined(HAVE_WIN32)
    int i;
    pid_t cpid;
    mode_t oldmask;
@@ -101,6 +101,6 @@ daemon_start()
       }
    }
 
-#endif /* HAVE_CYGWIN */
+#endif /* HAVE_WIN32 */
    Dmsg0(900, "Exit daemon_start\n");
 }
diff --git a/bacula/src/lib/enh_fnmatch.c b/bacula/src/lib/enh_fnmatch.c
new file mode 100644 (file)
index 0000000..090f68e
--- /dev/null
@@ -0,0 +1,285 @@
+/* Copyright (C) 1991, 1992, 1993, 1996, 1997 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software Foundation,
+  Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+/* Modified version of fnmatch.c - Robert Nelson */
+
+#include "bacula.h"
+#include "enh_fnmatch.h"
+
+# ifndef errno
+extern int errno;
+# endif
+
+int
+enh_fnmatch_sub(const char *pattern, const char *string, int patternlen, int flags)
+{
+  register const char *p = pattern, *n = string;
+  register char c;
+
+/* Note that this evaluates C many times.  */
+# define FOLD(c) ((flags & FNM_CASEFOLD) && B_ISUPPER (c) ? tolower (c) : (c))
+
+  while ((p - pattern) < patternlen)
+    {
+      c = *p++;
+      c = FOLD (c);
+
+      switch (c)
+        {
+        case '?':
+          if (*n == '\0')
+            return 0;
+          else if ((flags & FNM_FILE_NAME) && *n == '/')
+            return 0;
+          else if ((flags & FNM_PERIOD) && *n == '.' &&
+                   (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
+            return 0;
+          break;
+
+        case '\\':
+          if (!(flags & FNM_NOESCAPE))
+            {
+              if ((p - pattern) >= patternlen)
+                /* Trailing \ loses.  */
+                return 0;
+
+              c = *p++;
+              c = FOLD(c);
+            }
+          if (FOLD (*n) != c)
+            return 0;
+          break;
+
+        case '*':
+          if ((flags & FNM_PERIOD) && *n == '.' &&
+              (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
+            return FNM_NOMATCH;
+
+          if ((p - pattern) >= patternlen)
+              return patternlen;
+
+          for (c = *p++; ((p - pattern) <= patternlen) && (c == '?' || c == '*'); c = *p++)
+            {
+              if ((flags & FNM_FILE_NAME) && *n == '/')
+                /* A slash does not match a wildcard under FNM_FILE_NAME.  */
+                return 0;
+              else if (c == '?')
+                {
+                  /* A ? needs to match one character.  */
+                  if (*n == '\0')
+                    /* There isn't another character; no match.  */
+                    return 0;
+                  else
+                    /* One character of the string is consumed in matching
+                       this ? wildcard, so *??? won't match if there are
+                       less than three characters.  */
+                    ++n;
+                }
+            }
+
+          if ((p - pattern) >= patternlen)
+              return patternlen;
+
+          {
+            char c1 = (!(flags & FNM_NOESCAPE) && c == '\\') ? *p : c;
+            c1 = FOLD (c1);
+            for (--p; *n != '\0'; ++n)
+              {
+                if (c == '[' || c == '{' || FOLD((unsigned char)*n) == c1)
+                  {
+                    int len;
+
+                    len = enh_fnmatch_sub(p, n, (int)(patternlen - (p - pattern)), flags & ~FNM_PERIOD);
+
+                    if (len > 0 && n[len] == '\0')
+                      return (int)(n - string + len);
+                  }
+                else
+                  {
+                    if ((flags & FNM_FILE_NAME) && *n == '/')
+                      return 0;    /* A slash does not match a wildcard under FNM_FILE_NAME.  */
+                  }
+
+              }
+            return 0;
+          }
+
+        case '{':
+          {
+            const char *pstart = p;
+
+            while ((p - pattern) < patternlen)
+              {
+                c = *p++;
+
+                if (!(flags & FNM_NOESCAPE) && c == '\\')
+                  {
+                    if ((p - pattern) >= patternlen)
+                      return 0;
+
+                    ++p;
+                    continue;
+                  }
+              
+                if (c == ',' || c == '}')
+                  {
+                    int matchlen;
+                  
+                    matchlen = enh_fnmatch_sub(pstart, n, (int)(p - pstart - 1), flags & ~FNM_PERIOD);
+
+                    if (matchlen > 0)
+                      {
+                        n += matchlen - 1;
+                        while (c != '}')
+                          {
+                            if (!(flags & FNM_NOESCAPE) && c == '\\')
+                              {
+                                if ((p - pattern) >= patternlen)
+                                  return 0;
+
+                                ++p;
+                              }
+
+                            if ((p - pattern) >= patternlen)
+                              return 0;
+
+                            c = *p++;
+                          }
+                        break;
+                      }
+
+                    if (c == '}')
+                      return 0;
+
+                    pstart = p;
+                  }
+              }
+            break;
+          }
+
+        case '[':
+          {
+            /* Nonzero if the sense of the character class is inverted.  */
+            register int nnot;
+
+            if (*n == '\0')
+              return 0;
+
+            if ((flags & FNM_PERIOD) && *n == '.' &&
+                (n == string || ((flags & FNM_FILE_NAME) && n[-1] == '/')))
+              return 0;
+
+            nnot = (*p == '!' || *p == '^');
+            if (nnot)
+              ++p;
+
+            if ((p - pattern) >= patternlen)
+              /* [ (unterminated) loses.  */
+              return 0;
+
+            c = *p++;
+
+            for (;;)
+              {
+                register char cstart, cend;
+
+                cstart = cend = FOLD (c);
+
+                if ((p - pattern) >= patternlen)
+                  /* [ (unterminated) loses.  */
+                  return 0;
+
+                c = *p++;
+                c = FOLD (c);
+
+                if ((flags & FNM_FILE_NAME) && c == '/')
+                  /* [/] can never match.  */
+                  return 0;
+
+                if (c == '-' && *p != ']')
+                  {
+                    if ((p - pattern) >= patternlen)
+                      return 0;
+
+                    cend = *p++;
+
+                    cend = FOLD (cend);
+
+                    if ((p - pattern) >= patternlen)
+                      return 0;
+
+                    c = *p++;
+                  }
+
+                if (FOLD (*n) >= cstart && FOLD (*n) <= cend)
+                  goto matched;
+
+                if (c == ']')
+                  break;
+              }
+            if (!nnot)
+              return 0;
+            break;
+
+          matched:;
+            /* Skip the rest of the [...] that already matched.  */
+            while (c != ']')
+              {
+                if ((p - pattern) >= patternlen)
+                  return 0;
+
+                c = *p++;
+              }
+            if (nnot)
+              return 0;
+          }
+          break;
+
+        default:
+          if (c != FOLD (*n))
+            return 0;
+          break;
+        }
+
+      ++n;
+    }
+
+    return (int)(n - string);
+
+# undef FOLD
+}
+
+/* Match STRING against the filename pattern PATTERN, returning number of characters
+   in STRING that were matched if all of PATTERN matches, nonzero if not.  */
+int
+enh_fnmatch(const char *pattern, const char *string, int flags)
+{
+  int matchlen;
+
+  matchlen = enh_fnmatch_sub(pattern, string, (int)strlen(pattern), flags);
+
+  if (matchlen == 0)
+    return FNM_NOMATCH;
+
+  if (string[matchlen] == '\0')
+    return 0;
+
+  if ((flags & FNM_LEADING_DIR) && string[matchlen] == '/')
+    /* The FNM_LEADING_DIR flag says that "foo*" matches "foobar/frobozz".  */
+    return 0;
+
+  return FNM_NOMATCH;
+}
diff --git a/bacula/src/lib/enh_fnmatch.h b/bacula/src/lib/enh_fnmatch.h
new file mode 100644 (file)
index 0000000..0a53016
--- /dev/null
@@ -0,0 +1,51 @@
+/* Copyright (C) 1991, 1992, 1993 Free Software Foundation, Inc.
+
+NOTE: The canonical source of this file is maintained with the GNU C Library.
+Bugs can be reported to bug-glibc@prep.ai.mit.edu.
+
+This program is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software Foundation,
+Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* Modified version of fnmatch.h - Robert Nelson */
+
+#ifndef _ENH_FNMATCH_H
+
+#define _ENH_FNMATCH_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined (__cplusplus) || (defined (__STDC__) && __STDC__)
+#undef __P
+#define __P(protos)    protos
+#else /* Not C++ or ANSI C.  */
+#undef __P
+#define __P(protos)    ()
+/* We can get away without defining `const' here only because in this file
+   it is used only inside the prototype for `fnmatch', which is elided in
+   non-ANSI C where `const' is problematical.  */
+#endif /* C++ or ANSI C.  */
+
+
+/* Match STRING against the filename pattern PATTERN,
+   returning zero if it matches, FNM_NOMATCH if not.  */
+extern int enh_fnmatch __P ((const char *__pattern, const char *__string,
+                        int __flags));
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* fnmatch.h */
index 861c8c8b785d61814460d39a2cb063ec8166ecf6..782778e12ad8809240ecefa350e5cb485c007aed 100644 (file)
@@ -138,7 +138,7 @@ bailout:
 
 #endif /* IMPLEMENTED */
 
-#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
+#if defined(HAVE_WIN32)
 
 #include <windows.h>
 
@@ -172,4 +172,4 @@ void FillEventsBox(HWND hwnd, int idlist)
     return;
 }
 
-#endif /* HAVE_CYGWIN */
+#endif /* HAVE_WIN32 */
index 11b9af015639f7bda9f64e1c82df3dda8feb6baa..13b2cb9ab2a4ab1c0da93132631bf0a204797d7f 100644 (file)
@@ -155,7 +155,7 @@ LEX *lex_open_file(LEX *lf, const char *filename, LEX_ERROR_HANDLER *scan_error)
    char *fname = bstrdup(filename);
 
 
-   if ((fd = fopen(fname, "r")) == NULL) {
+   if ((fd = fopen(fname, "rb")) == NULL) {
       return NULL;
    }
    Dmsg1(400, "Open config file: %s\n", fname);
index 0725dc5eaa8b37483d7213857f00eaaadd57e026..d5b5bf7e4ef06d9a0b39842e49ceb1b24d8f1575 100644 (file)
@@ -298,7 +298,7 @@ int main(int argc, char *argv[])
       exit(1);
    }
 
-   fd = fopen(argv[0], "r");
+   fd = fopen(argv[0], "rb");
    if (!fd) {
       printf("Could not open %s: ERR=%s\n", argv[0], strerror(errno));
       exit(1);
index a394f0dac5bf92629488144553af50abb9057a12..1c4b685d9a96b3530cabec342bf24c366960ea7c 100755 (executable)
 #include "bacula.h"
 #include "jcr.h"
 
-#if !defined(HAVE_CONSOLE)
-#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
+#if !defined(HAVE_CONSOLE) && defined(HAVE_WIN32)
 #include <windows.h>
 #endif
-#endif
 
 #define FULL_LOCATION 1               /* set for file:line in Debug messages */
 
@@ -52,19 +50,15 @@ FILE *con_fd = NULL;                  /* Console file descriptor */
 brwlock_t con_lock;                   /* Console lock structure */
 
 
-#ifdef HAVE_POSTGRESQL
+#if defined(HAVE_POSTGRESQL)
 char catalog_db[] = "PostgreSQL";
-#else
-#ifdef HAVE_MYSQL
+#elif defined(HAVE_MYSQL)
 char catalog_db[] = "MySQL";
-#else
-#ifdef HAVE_SQLITE
+#elif defined(HAVE_SQLITE)
 char catalog_db[] = "SQLite";
 #else
 char catalog_db[] = "Internal";
 #endif
-#endif
-#endif
 
 const char *host_os = HOST_OS;
 const char *distname = DISTNAME;
@@ -117,7 +111,7 @@ void my_name_is(int argc, char *argv[], const char *name)
          l++;
       } else {
          l = argv[0];
-#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
+#if defined(HAVE_WIN32)
          /* On Windows allow c: junk */
          if (l[1] == ':') {
             l += 2;
@@ -162,7 +156,9 @@ void
 init_msg(JCR *jcr, MSGS *msg)
 {
    DEST *d, *dnew, *temp_chain = NULL;
+#ifndef HAVE_WIN32
    int i;
+#endif
 
    if (jcr == NULL && msg == NULL) {
       init_last_jobs_list();
@@ -193,7 +189,7 @@ init_msg(JCR *jcr, MSGS *msg)
    if (msg == NULL) {
       daemon_msgs = (MSGS *)malloc(sizeof(MSGS));
       memset(daemon_msgs, 0, sizeof(MSGS));
-#ifndef WIN32
+#ifndef HAVE_WIN32
       for (i=1; i<=M_MAX; i++) {
          add_msg_dest(daemon_msgs, MD_STDOUT, i, NULL, NULL);
       }
@@ -258,7 +254,7 @@ void init_console_msg(const char *wd)
       console_msg_pending = 1;
    }
    close(fd);
-   con_fd = fopen(con_fname, "a+");
+   con_fd = fopen(con_fname, "a+b");
    if (!con_fd) {
       berrno be;
       Emsg2(M_ERROR, 0, _("Could not open console message file %s: ERR=%s\n"),
@@ -606,7 +602,7 @@ void dispatch_message(JCR *jcr, int type, time_t mtime, char *msg)
              case MD_CONSOLE:
                 Dmsg1(850, "CONSOLE for following msg: %s", msg);
                 if (!con_fd) {
-                   con_fd = fopen(con_fname, "a+");
+                   con_fd = fopen(con_fname, "a+b");
                    Dmsg0(850, "Console file not open.\n");
                 }
                 if (con_fd) {
@@ -630,7 +626,7 @@ void dispatch_message(JCR *jcr, int type, time_t mtime, char *msg)
                 }
                 break;
              case MD_SYSLOG:
-                Dmsg1(850, "SYSLOG for collowing msg: %s\n", msg);
+                Dmsg1(850, "SYSLOG for following msg: %s\n", msg);
                 /*
                  * We really should do an openlog() here.
                  */
@@ -661,7 +657,7 @@ void dispatch_message(JCR *jcr, int type, time_t mtime, char *msg)
                 if (!d->fd) {
                    POOLMEM *name = get_pool_memory(PM_MESSAGE);
                    make_unique_mail_filename(jcr, name, d);
-                   d->fd = fopen(name, "w+");
+                   d->fd = fopen(name, "w+b");
                    if (!d->fd) {
                       berrno be;
                       d->fd = stdout;
@@ -683,7 +679,7 @@ void dispatch_message(JCR *jcr, int type, time_t mtime, char *msg)
              case MD_FILE:
                 Dmsg1(850, "FILE for following msg: %s", msg);
                 if (!d->fd) {
-                   d->fd = fopen(d->where, "w+");
+                   d->fd = fopen(d->where, "w+b");
                    if (!d->fd) {
                       berrno be;
                       d->fd = stdout;
@@ -699,7 +695,7 @@ void dispatch_message(JCR *jcr, int type, time_t mtime, char *msg)
              case MD_APPEND:
                 Dmsg1(850, "APPEND for following msg: %s", msg);
                 if (!d->fd) {
-                   d->fd = fopen(d->where, "a");
+                   d->fd = fopen(d->where, "ab");
                    if (!d->fd) {
                       berrno be;
                       d->fd = stdout;
@@ -789,7 +785,7 @@ d_msg(const char *file, int line, int level, const char *fmt,...)
           if (!trace_fd) {
              char fn[200];
              bsnprintf(fn, sizeof(fn), "%s/bacula.trace", working_directory ? working_directory : ".");
-             trace_fd = fopen(fn, "a+");
+             trace_fd = fopen(fn, "a+b");
           }
           if (trace_fd) {
              fputs(buf, trace_fd);
@@ -885,7 +881,7 @@ t_msg(const char *file, int line, int level, const char *fmt,...)
     if (level <= debug_level) {
        if (!trace_fd) {
           bsnprintf(buf, sizeof(buf), "%s/bacula.trace", working_directory);
-          trace_fd = fopen(buf, "a+");
+          trace_fd = fopen(buf, "a+b");
        }
 
 #ifdef FULL_LOCATION
index 8e53477325662afbb9055fbbd7320c3f33b3973a..f95b60948510ce01f15eebad25186c7de04a7a89 100755 (executable)
@@ -61,15 +61,14 @@ extern int r_last;
 extern RES_TABLE resources[];
 extern RES **res_head;
 
-#ifdef HAVE_WIN32
+#if defined(_MSC_VER)
 // work around visual studio name manling preventing external linkage since res_all
 // is declared as a different type when instantiated.
 extern "C" CURES res_all;
-extern "C" int res_all_size;
 #else
 extern  CURES res_all;
-extern int res_all_size;
 #endif
+extern int res_all_size;
 
 extern brwlock_t res_lock;            /* resource lock */
 
index 118989c0dec60418f5ee391e827030fc1cb72a4f..9198e74b97563aee36745f6cacd80fdc97eb6783 100644 (file)
@@ -76,7 +76,7 @@ BSOCK *    bnet_connect          (JCR *jcr, int retry_interval,
 void       bnet_close            (BSOCK *bsock);
 BSOCK *    init_bsock            (JCR *jcr, int sockfd, const char *who, const char *ip,
                                   int port, struct sockaddr *client_addr);
-#ifdef WIN32
+#ifdef HAVE_WIN32
 #ifndef socklen_t
 #define socklen_t int
 #endif
index 9c6e360100e924e4c047eb1af7addc49aec28edc..c35fb68ee5c7d4dd8ecbb59c44060f22354bba68 100644 (file)
@@ -34,17 +34,6 @@ extern int r_last;
 extern RES_TABLE resources[];
 extern RES **res_head;
 
-#ifdef HAVE_WIN32
-// work around visual studio name manling preventing external linkage since res_all
-// is declared as a different type when instantiated.
-extern "C" CURES res_all;
-extern "C" int res_all_size;
-#else
-extern  CURES res_all;
-extern int res_all_size;
-#endif
-
-
 brwlock_t res_lock;                   /* resource lock */
 static int res_locked = 0;            /* set when resource chains locked -- for debug */
 
index 8b9b92c6ae18b7695511bc45974b7e66727cde2e..c73cc1012c47d04351d88171b28752ba8718ecc5 100644 (file)
@@ -25,8 +25,6 @@
 #include "bacula.h"
 #include "jcr.h"
 
-#define USE_RUNSCRIPT
-
 #include "runscript.h"
 
 RUNSCRIPT *new_runscript()
index 136d8a7f17b429568398b63b125abbf4b0b772fe..063fad0e9436f5c18fc843dbc28668ed11045595 100644 (file)
@@ -490,7 +490,7 @@ int main(int argc, char *argv[])
       printf("Must have filename\n");
       exit(1);
    }
-   fd = fopen(argv[1], "r");
+   fd = fopen(argv[1], "rb");
    if (!fd) {
       printf("Could not open %s: ERR=%s\n", argv[1], strerror(errno));
       exit(1);
index 4d1cf2051d1c2fb84264cb29ae5ab6621346de63..1856539ac306cfe3cc4c55f8cdc4645e7e9b62f0 100644 (file)
@@ -26,7 +26,7 @@
 #include "stored.h"
 #include "findlib/find.h"
 
-#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
+#if defined(HAVE_WIN32)
 int win32_client = 1;
 #else
 int win32_client = 0;
@@ -122,7 +122,7 @@ int main (int argc, char *argv[])
          break;
 
       case 'e':                    /* exclude list */
-         if ((fd = fopen(optarg, "r")) == NULL) {
+         if ((fd = fopen(optarg, "rb")) == NULL) {
             berrno be;
             Pmsg2(0, _("Could not open exclude file: %s, ERR=%s\n"),
                optarg, be.strerror());
@@ -137,7 +137,7 @@ int main (int argc, char *argv[])
          break;
 
       case 'i':                    /* include list */
-         if ((fd = fopen(optarg, "r")) == NULL) {
+         if ((fd = fopen(optarg, "rb")) == NULL) {
             berrno be;
             Pmsg2(0, _("Could not open include file: %s, ERR=%s\n"),
                optarg, be.strerror());
index 933af258c2772320d437c252cc1924beff89bd2f..40d348ccaebf74a79b03a8ceb5fe1b7a6c1fc01b 100644 (file)
@@ -124,7 +124,7 @@ int main (int argc, char *argv[])
          break;
 
       case 'e':                    /* exclude list */
-         if ((fd = fopen(optarg, "r")) == NULL) {
+         if ((fd = fopen(optarg, "rb")) == NULL) {
             Pmsg2(0, _("Could not open exclude file: %s, ERR=%s\n"),
                optarg, strerror(errno));
             exit(1);
@@ -138,7 +138,7 @@ int main (int argc, char *argv[])
          break;
 
       case 'i':                    /* include list */
-         if ((fd = fopen(optarg, "r")) == NULL) {
+         if ((fd = fopen(optarg, "rb")) == NULL) {
             Pmsg2(0, _("Could not open include file: %s, ERR=%s\n"),
                optarg, strerror(errno));
             exit(1);
index d88a10991a5f37662e2bfa0c7ad3d7f004144caa..6d979c96f5ee62805b991f8cb4c9fe981db55ebf 100644 (file)
@@ -52,7 +52,7 @@ static int update_digest_record(B_DB *db, char *digest, DEV_RECORD *rec, int typ
 
 
 /* Global variables */
-#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
+#if defined(HAVE_WIN32)
 int win32_client = 1;
 #else
 int win32_client = 0;
index fd9338b9ad2f2a03f896855c48675f1b8acae367..4575531848e001703c9ce6c8337b846e0bb8581c 100644 (file)
@@ -1881,8 +1881,8 @@ static void fillcmd()
     */
    jcr->dcr->VolFirstIndex = 0;
    time(&jcr->run_time);              /* start counting time for rates */
-   localtime_r(&jcr->run_time, &tm);
-   strftime(buf1, sizeof(buf1), "%T", &tm);
+   (void)localtime_r(&jcr->run_time, &tm);
+   strftime(buf1, sizeof(buf1), "%H:%M:%S", &tm);
    if (simple) {
       Pmsg1(-1, _("%s Begin writing Bacula records to tape ...\n"), buf1);
    } else {
@@ -1935,8 +1935,8 @@ static void fillcmd()
           */
          if ((block->BlockNumber % 32000) == 0) {
             now = time(NULL);
-            localtime_r(&now, &tm);
-            strftime(buf1, sizeof(buf1), "%T", &tm);
+            (void)localtime_r(&now, &tm);
+            strftime(buf1, sizeof(buf1), "%H:%M:%S", &tm);
             Pmsg1(-1, _("%s Flush block, write EOF\n"), buf1);
             flush_block(block, 0);
             dev->weof(1);
@@ -2012,8 +2012,8 @@ static void fillcmd()
    }
 
    now = time(NULL);
-   localtime_r(&now, &tm);
-   strftime(buf1, sizeof(buf1), "%T", &tm);
+   (void)localtime_r(&now, &tm);
+   strftime(buf1, sizeof(buf1), "%H:%M:%S", &tm);
    if (simple) {
       Pmsg3(-1, _("\n\n%s Done filling tape at %d:%d. Now beginning re-read of tape ...\n"),
          buf1, jcr->dcr->dev->file, jcr->dcr->dev->block_num);
index 99be022c9117b809724326953e4bff6005ec02ad..6373a8e39fe6d1f1eee84dce4916cc2bf04aeecc 100644 (file)
@@ -12,7 +12,7 @@
  *        to carry out operations without worrying about who
  *        set what lock (i.e. race conditions).
  *
- *     Note, this is the device dependent code, and my have
+ *     Note, this is the device dependent code, and may have
  *           to be modified for each system, but is meant to
  *           be as "generic" as possible.
  *
@@ -103,7 +103,7 @@ init_dev(JCR *jcr, DEVRES *device)
    DCR *dcr = NULL;
    DEVICE *dev;
 
-   
+
    /* If no device type specified, try to guess */
    if (!device->dev_type) {
       /* Check that device is available */
index 4ca8fb6da7d3f797298538bf6c97084d5b0130dd..e52f19e0c0b1c1448330636097b65862c5b537c8 100644 (file)
@@ -181,7 +181,7 @@ typedef struct s_steal_lock {
    int        dev_prev_blocked;       /* previous blocked state */
 } bsteal_lock_t;
 
-struct DEVRES;                        /* Device resource defined in stored_conf.h */
+class DEVRES;                        /* Device resource defined in stored_conf.h */
 
 class DCR; /* forward reference */
 /*
index b00f425233924a7698e49553996d4fbb3ed1f09a..c2a429378e441711a949fcb1e329a6cde61cee35 100644 (file)
@@ -873,7 +873,7 @@ static bool changer_cmd(JCR *jcr)
       if (dcr) {
          dev = dcr->dev;
          P(dev->mutex);               /* Use P to avoid indefinite block */
-         if (!dev->device->changer_res) {     
+         if (!dev->device->changer_res) {
             bnet_fsend(dir, _("3995 Device %s is not an autochanger.\n"), 
                dev->print_name());
          /* Under certain "safe" conditions, we can steal the lock */
index 41df7eae30ba53f1c4d59041ab228dbe606c18e6..af5198173187293e8067d0beafffecddfd5fd366 100644 (file)
@@ -324,7 +324,7 @@ bool get_bootstrap_file(JCR *jcr, BSOCK *sock)
       jcr->Job);
    Dmsg1(400, "bootstrap=%s\n", fname);
    jcr->RestoreBootstrap = fname;
-   bs = fopen(fname, "a+");           /* create file */
+   bs = fopen(fname, "a+b");           /* create file */
    if (!bs) {
       Jmsg(jcr, M_FATAL, 0, _("Could not create bootstrap file %s: ERR=%s\n"),
          jcr->RestoreBootstrap, strerror(errno));
index 9cf930447b916eabdd81a7e5cd91efec16eb8e53..e57326ccc119848ba77ad4432a2ed6d97970e9e6 100644 (file)
@@ -579,7 +579,7 @@ bool open_attr_spool_file(JCR *jcr, BSOCK *bs)
    POOLMEM *name  = get_pool_memory(PM_MESSAGE);
 
    make_unique_spool_filename(jcr, &name, bs->fd);
-   bs->spool_fd = fopen(name, "w+");
+   bs->spool_fd = fopen(name, "w+b");
    if (!bs->spool_fd) {
       berrno be;
       Jmsg(jcr, M_FATAL, 0, _("fopen attr spool file %s failed: ERR=%s\n"), name,
index 51b7dd76b7e9fe57a3862a707921f5547ebfa187..cb9766cd6f443f930f4fff6a944849f265d1a567 100644 (file)
@@ -39,7 +39,13 @@ static void store_devtype(LEX *lc, RES_ITEM *item, int index, int pass);
 
 /* We build the current resource here statically,
  * then move it to dynamic memory */
+#if defined(_MSC_VER)
+extern "C" { // work around visual compiler mangling variables
+    URES res_all;
+}
+#else
 URES res_all;
+#endif
 int res_all_size = sizeof(res_all);
 
 /* Definition of records permitted within each
index e1db10d0bc37a05e97f14f85f9e19f0a460cda82..77a759eb06caa48b82c5dc57c9067e01a5a6d548 100644 (file)
@@ -85,7 +85,7 @@ public:
 
    TLS_CONTEXT *tls_ctx;              /* Shared TLS Context */
 };
-typedef struct s_res_store STORES;
+typedef class s_res_store STORES;
 
 class AUTOCHANGER {
 public:
index 65b6a2d647198508a6af3105bb77262ef9e36f37..a7b09770463be16199cc949b57dd125a4a8aec38 100644 (file)
@@ -19,7 +19,6 @@
 #include "bacula.h"
 #include "lib/fnmatch.h"
 
-
 static void usage()
 {
    fprintf(stderr,
diff --git a/bacula/src/tools/drivetype.c b/bacula/src/tools/drivetype.c
new file mode 100644 (file)
index 0000000..b778ade
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * Program for determining drive type
+ *
+ *   Written by Robert Nelson, June 2006
+ *
+ *   Version $Id$
+ *
+ */
+/*
+   Copyright (C) 2006 Kern Sibbald
+
+   This program is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   version 2 as amended with additional clauses defined in the
+   file LICENSE in the main source directory.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+   file LICENSE for additional details.
+
+ */
+
+#include "bacula.h"
+#include "findlib/find.h"
+
+/* Dummy functions */
+int generate_daemon_event(JCR *jcr, const char *event) 
+   { return 1; }
+
+static void usage()
+{
+   fprintf(stderr, _(
+"\n"
+"Usage: drivetype [-v] path ...\n"
+"\n"
+"       Print the drive type a given file/directory is on.\n"
+"       The following options are supported:\n"
+"\n"
+"       -v     print both path and file system type.\n"
+"       -?     print this message.\n"
+"\n"));
+
+   exit(1);
+}
+
+
+int
+main (int argc, char *const *argv)
+{
+   char dt[100];
+   int verbose = 0;
+   int status = 0;
+   int ch, i;
+
+   setlocale(LC_ALL, "");
+   bindtextdomain("bacula", LOCALEDIR);
+   textdomain("bacula");
+
+   while ((ch = getopt(argc, argv, "v?")) != -1) {
+      switch (ch) {
+         case 'v':
+            verbose = 1;
+            break;
+         case '?':
+         default:
+            usage();
+
+      }
+   }
+   argc -= optind;
+   argv += optind;
+
+   if (argc < 1) {
+      usage();
+   }
+
+   OSDependentInit();
+   for (i = 0; i < argc; --argc, ++argv) {
+      if (drivetype(*argv, dt, sizeof(dt))) {
+         if (verbose) {
+            printf("%s: %s\n", *argv, dt);
+         } else {
+            puts(dt);
+         }
+      } else {
+         fprintf(stderr, _("%s: unknown\n"), *argv);
+         status = 1;
+      }
+   }
+
+   exit(status);
+}
index e671257908a0ac1efdfc7e3973bbcd5ca855333c..796588d9a6f590d78bd191623fb1e1b33933acb4 100644 (file)
@@ -32,7 +32,7 @@ static void usage()
 {
    fprintf(stderr, _(
 "\n"
-"Usage: fstype [-d debug_level] path ...\n"
+"Usage: fstype [-v] path ...\n"
 "\n"
 "       Print the file system type a given file/directory is on.\n"
 "       The following options are supported:\n"
index 851c3a879463c1e2f2591c64ca0cab16b11ffbca..fe4c21a2e626489d31bfa17bad4c3d326c3f607d 100644 (file)
@@ -20,7 +20,7 @@
 #include "findlib/find.h"
 
 
-#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
+#if defined(HAVE_WIN32)
 int win32_client = 1;
 #else
 int win32_client = 0;
index e48df2e6ccfc321d289b50975d540300a374ab89..78ff15d3ecdef49109f7d8cd12117b48e86108c8 100755 (executable)
@@ -19,7 +19,7 @@
 #include "bacula.h"
 #include "findlib/find.h"
 
-#if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
+#if defined(HAVE_WIN32)
 int win32_client = 1;
 #else
 int win32_client = 0;
@@ -125,7 +125,7 @@ main (int argc, char *const *argv)
       }
    }
    if (inc) {
-      fd = fopen(inc, "r");
+      fd = fopen(inc, "rb");
       if (!fd) {
          printf(_("Could not open include file: %s\n"), inc);
          exit(1);
@@ -138,7 +138,7 @@ main (int argc, char *const *argv)
    }
 
    if (exc) {
-      fd = fopen(exc, "r");
+      fd = fopen(exc, "rb");
       if (!fd) {
          printf(_("Could not open exclude file: %s\n"), exc);
          exit(1);