]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/ua_select.c
Fix: clock diff, Dan's patch, Nic's patch, segfault
[bacula/bacula] / bacula / src / dird / ua_select.c
index b6ec85e84cfae9251d8a71968b62a4055057bf3f..0b1e1ef07e7309ebe95856a139af815ad45267c2 100644 (file)
@@ -74,9 +74,8 @@ int confirm_retention(UAContext *ua, utime_t *ret, char *msg)
  */
 int find_arg_keyword(UAContext *ua, char **list)
 {
-   int i, j;
-   for (i=1; i<ua->argc; i++) {
-      for(j=0; list[j]; j++) {
+   for (int i=1; i<ua->argc; i++) {
+      for(int j=0; list[j]; j++) {
         if (strcasecmp(_(list[j]), ua->argk[i]) == 0) {
            return j;
         }
@@ -86,9 +85,10 @@ int find_arg_keyword(UAContext *ua, char **list)
 }
 
 /* 
- * Given a single keyword, find it in the argument list.
- * Returns: -1 if not found
- *          list index (base 0) on success
+ * Given one keyword, find the first one that
+ *   is in the argument list.
+ * Returns: argk index (always gt 0)
+ *         -1 if not found
  */
 int find_arg(UAContext *ua, char *keyword)
 {
@@ -100,6 +100,12 @@ int find_arg(UAContext *ua, char *keyword)
    return -1;
 }
 
+/* 
+ * Given a single keyword, find it in the argument list, but
+ *   it must have a value
+ * Returns: -1 if not found or no value
+ *          list index (base 0) on success
+ */
 int find_arg_with_value(UAContext *ua, char *keyword)
 {
    for (int i=1; i<ua->argc; i++) {
@@ -114,8 +120,6 @@ int find_arg_with_value(UAContext *ua, char *keyword)
    return -1;
 }
 
-
-
 /* 
  * Given a list of keywords, prompt the user 
  * to choose one.
@@ -274,7 +278,8 @@ CLIENT *get_client_resource(UAContext *ua)
    int i;
    
    for (i=1; i<ua->argc; i++) {
-      if (strcasecmp(ua->argk[i], _("client")) == 0 && ua->argv[i]) {
+      if ((strcasecmp(ua->argk[i], _("client")) == 0 ||
+           strcasecmp(ua->argk[i], _("fd")) == 0) && ua->argv[i]) {
         client = (CLIENT *)GetResWithName(R_CLIENT, ua->argv[i]);
         if (client) {
            return client;
@@ -307,7 +312,8 @@ int get_client_dbr(UAContext *ua, CLIENT_DBR *cr)
       bsendmsg(ua, _("Could not find Client %s: ERR=%s"), cr->Name, db_strerror(ua->db));
    }
    for (i=1; i<ua->argc; i++) {
-      if (strcasecmp(ua->argk[i], _("client")) == 0 && ua->argv[i]) {
+      if ((strcasecmp(ua->argk[i], _("client")) == 0 ||               
+           strcasecmp(ua->argk[i], _("fd")) == 0) && ua->argv[i]) {
         bstrncpy(cr->Name, ua->argv[i], sizeof(cr->Name));
         if (!db_get_client_record(ua->jcr, ua->db, cr)) {
             bsendmsg(ua, _("Could not find Client %s: ERR=%s"), ua->argv[i],
@@ -343,7 +349,7 @@ int select_client_dbr(UAContext *ua, CLIENT_DBR *cr)
       return 0;
    }
    if (num_clients <= 0) {
-      bsendmsg(ua, _("No clients defined. Run a job to create one.\n"));
+      bsendmsg(ua, _("No clients defined. You must run a job before using this command.\n"));
       return 0;
    }
      
@@ -489,7 +495,7 @@ int select_media_dbr(UAContext *ua, MEDIA_DBR *mr)
         return 0;
       }
       mr->PoolId = pr.PoolId;
-      db_list_media_records(ua->jcr, ua->db, mr, prtit, ua, 0);
+      db_list_media_records(ua->jcr, ua->db, mr, prtit, ua, HORZ_LIST);
       if (!get_cmd(ua, _("Enter MediaId or Volume name: "))) {
         return 0;
       }
@@ -554,7 +560,7 @@ POOL *get_pool_resource(UAContext *ua)
  */
 int select_job_dbr(UAContext *ua, JOB_DBR *jr)
 {
-   db_list_job_records(ua->jcr, ua->db, jr, prtit, ua, 0);
+   db_list_job_records(ua->jcr, ua->db, jr, prtit, ua, HORZ_LIST);
    if (!get_pint(ua, _("Enter the JobId to select: "))) {
       return 0;
    }
@@ -747,7 +753,8 @@ STORE *get_storage_resource(UAContext *ua, int use_default)
            break;
         }
       } else {
-         if (strcasecmp(ua->argk[i], _("storage")) == 0) {
+         if (strcasecmp(ua->argk[i], _("storage")) == 0 ||
+             strcasecmp(ua->argk[i], _("sd")) == 0) {
            store_name = ua->argv[i];
            break;