]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/ua_run.c
Add heap stats to Dir and SD -- eliminate #ifdefs
[bacula/bacula] / bacula / src / dird / ua_run.c
index e95e050b06867492cb826fadbf2fc426cd1784f9..6fdd3478474202b50e6bc3c868f1e028481f0f85 100644 (file)
@@ -8,7 +8,7 @@
  */
 
 /*
-   Copyright (C) 2001-2003 Kern Sibbald and John Walker
+   Copyright (C) 2001-2004 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
@@ -33,7 +33,6 @@
 /* Imported subroutines */
 
 /* Imported variables */
-extern struct s_jl joblevels[];
 extern struct s_kw ReplaceOptions[];
 
 /*
@@ -44,14 +43,15 @@ extern struct s_kw ReplaceOptions[];
  *     run <job-name> jobid=nn
  *
  */
-int run_cmd(UAContext *ua, char *cmd)
+int run_cmd(UAContext *ua, const char *cmd)
 {
    JCR *jcr;
    char *job_name, *level_name, *jid, *store_name, *pool_name;
-   char *where, *fileset_name, *client_name, *bootstrap, *replace;
+   char *where, *fileset_name, *client_name, *bootstrap;
+   const char *replace;
    char *when, *verify_job_name;
    int Priority = 0;
-   int i, j, opt;
+   int i, j, opt, files = 0;
    bool kw_ok;
    JOB *job = NULL;
    JOB *verify_job = NULL;
@@ -59,7 +59,7 @@ int run_cmd(UAContext *ua, char *cmd)
    CLIENT *client = NULL;
    FILESET *fileset = NULL;
    POOL *pool = NULL;
-   static char *kw[] = {             /* command line arguments */
+   static const char *kw[] = {       /* command line arguments */
       N_("job"),                      /*  Used in a switch() */
       N_("jobid"),                    /* 1 */
       N_("client"),                   /* 2 */
@@ -224,7 +224,8 @@ int run_cmd(UAContext *ua, char *cmd)
               verify_job_name = ua->argv[i];
               kw_ok = true;
               break;
-           case 16: /* files  -- ignore for now */
+           case 16: /* files */
+              files = atoi(ua->argv[i]);
               kw_ok = true;
               break;
 
@@ -258,7 +259,9 @@ int run_cmd(UAContext *ua, char *cmd)
       /* Find Job */
       job = (JOB *)GetResWithName(R_JOB, job_name);
       if (!job) {
-         bsendmsg(ua, _("Job \"%s\" not found\n"), job_name);
+        if (*job_name != 0) {
+            bsendmsg(ua, _("Job \"%s\" not found\n"), job_name);
+        }
         job = select_job_resource(ua);
       } else {
          Dmsg1(200, "Found job=%s\n", job_name);
@@ -274,7 +277,9 @@ int run_cmd(UAContext *ua, char *cmd)
    if (store_name) {
       store = (STORE *)GetResWithName(R_STORAGE, store_name);
       if (!store) {
-         bsendmsg(ua, _("Storage \"%s\" not found.\n"), store_name);
+        if (*store_name != 0) {
+            bsendmsg(ua, _("Storage \"%s\" not found.\n"), store_name);
+        }
         store = select_storage_resource(ua);
       }
    } else {
@@ -288,17 +293,24 @@ int run_cmd(UAContext *ua, char *cmd)
    if (pool_name) {
       pool = (POOL *)GetResWithName(R_POOL, pool_name);
       if (!pool) {
-         bsendmsg(ua, _("Pool \"%s\" not found.\n"), pool_name);
-        pool = get_pool_resource(ua);
+        if (*pool_name != 0) {
+            bsendmsg(ua, _("Pool \"%s\" not found.\n"), pool_name);
+        }
+        pool = select_pool_resource(ua);
       }
    } else {
       pool = job->pool;            /* use default */
    }
+   if (!pool) {
+      return 1;
+   }
 
    if (client_name) {
       client = (CLIENT *)GetResWithName(R_CLIENT, client_name);
       if (!client) {
-         bsendmsg(ua, _("Client \"%s\" not found.\n"), client_name);
+        if (*client_name != 0) {
+            bsendmsg(ua, _("Client \"%s\" not found.\n"), client_name);
+        }
         client = select_client_resource(ua);
       }
    } else {
@@ -342,6 +354,7 @@ int run_cmd(UAContext *ua, char *cmd)
    jcr->client = client;
    jcr->fileset = fileset;
    jcr->pool = pool;
+   jcr->ExpectedFiles = files;
    if (where) {
       if (jcr->where) {
         free(jcr->where);
@@ -393,21 +406,11 @@ try_again:
       }
    }
    if (level_name) {
-      /* Look up level name and pull code */
-      bool found = false;
-      for (i=0; joblevels[i].level_name; i++) {
-        if (strcasecmp(level_name, _(joblevels[i].level_name)) == 0) {
-           jcr->JobLevel = joblevels[i].level;
-           found = true;
-           break;
-        }
-      }
-      if (!found) { 
+      if (!get_level_from_name(jcr, level_name)) {
          bsendmsg(ua, _("Level %s not valid.\n"), level_name);
         goto bail_out;
       }
    }
-   level_name = NULL;
    if (jid) {
       jcr->RestoreJobId = atoi(jid);
    }
@@ -468,7 +471,7 @@ Priority: %d\n"),
                 bstrutime(dt, sizeof(dt), jcr->sched_time),
                 jcr->JobPriority);
       } else { /* JT_VERIFY */
-        char *Name;
+        const char *Name;
         if (jcr->job->verify_job) {
            Name = jcr->job->verify_job->hdr.name;
         } else {