]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/cats/bdb_find.c
Implement restore files
[bacula/bacula] / bacula / src / cats / bdb_find.c
index 71363d33bd21398b27ad2a83b2c8032558c431f7..852694647433da4b411bd2f684892caacceab741 100644 (file)
  *  system.
  *   
  *    Kern Sibbald, January MMI 
+ *
+ *    Version $Id$
  */
 
 /*
-   Copyright (C) 2001, 2002 Kern Sibbald and John Walker
+   Copyright (C) 2001-2003 Kern Sibbald and John Walker
 
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License as
@@ -47,7 +49,6 @@
 #ifdef HAVE_BACULA_DB
 
 /* Forward referenced functions */
-int db_find_job_start_time(B_DB *mdb, JOB_DBR *jr, char *stime);
 
 /* -----------------------------------------------------------------------
  *
@@ -64,7 +65,7 @@ int db_find_job_start_time(B_DB *mdb, JOB_DBR *jr, char *stime);
  * Returns: 0 on failure
  *         1 on success, jr unchanged, but stime set
  */
-int db_find_job_start_time(B_DB *mdb, JOB_DBR *jr, char *stime)
+int db_find_job_start_time(JCR *jcr, B_DB *mdb, JOB_DBR *jr, POOLMEM **stime)
 {
    char cmd[MAXSTRING], Name[MAX_NAME_LENGTH], StartTime[MAXSTRING];
    int Type, Level;
@@ -74,10 +75,10 @@ int db_find_job_start_time(B_DB *mdb, JOB_DBR *jr, char *stime)
    int found;
    long addr;
 
-   strcpy(stime, "0000-00-00 00:00:00");   /* default */
-   P(mdb->mutex);
+   db_lock(mdb);
+   pm_strcpy(stime, "0000-00-00 00:00:00");   /* default */
    if (!bdb_open_jobs_file(mdb)) {
-      V(mdb->mutex);
+      db_unlock(mdb);
       return 0;
    }
    fseek(mdb->jobfd, 0L, SEEK_SET);   /* rewind file */
@@ -122,7 +123,7 @@ StartTime=%100s", &JobId, Name, cType, cLevel, StartTime) == 5) {
            /* Reset for next read */
            fseek(mdb->jobfd, addr, SEEK_SET);
            if (found) {
-              strcpy(stime, StartTime);
+              pm_strcpy(stime, StartTime);
               stat = 1;              /* Got a candidate */
                Dmsg5(200, "Got candidate JobId=%d Type=%c Level=%c Name=%s StartTime=%s\n",
                  JobId, Type, Level, Name, StartTime);
@@ -130,7 +131,7 @@ StartTime=%100s", &JobId, Name, cType, cLevel, StartTime) == 5) {
         }
       }
    }
-   V(mdb->mutex);
+   db_unlock(mdb);
    return stat;
 }
 
@@ -143,16 +144,16 @@ StartTime=%100s", &JobId, Name, cType, cLevel, StartTime) == 5) {
  * Returns: 0 on failure
  *         numrows on success
  */
-int db_find_next_volume(B_DB *mdb, int item, MEDIA_DBR *mr)
+int db_find_next_volume(JCR *jcr, B_DB *mdb, int item, MEDIA_DBR *mr)
 {
    MEDIA_DBR omr;
    int stat = 0;
    int index = 0;
    int len;
 
-   P(mdb->mutex);
+   db_lock(mdb);
    if (!bdb_open_media_file(mdb)) {
-      V(mdb->mutex);
+      db_unlock(mdb);
       return 0;
    }
    fseek(mdb->mediafd, 0L, SEEK_SET);  /* rewind file */
@@ -171,11 +172,11 @@ int db_find_next_volume(B_DB *mdb, int item, MEDIA_DBR *mr)
         break;                       /* found it */
       }
    }
-   V(mdb->mutex);
+   db_unlock(mdb);
    return stat;                
 }
 
-int db_find_last_full_verify(B_DB *mdb, JOB_DBR *jr) { return 0; }
+int db_find_last_jobid(JCR *jcr, B_DB *mdb, JOB_DBR *jr) { return 0; }
 
 
 #endif /* HAVE_BACULA_DB */