+ * Select a Client record from the catalog
+ * Returns 1 on success
+ * 0 on failure
+ */
+bool select_client_dbr(UAContext *ua, CLIENT_DBR *cr)
+{
+ CLIENT_DBR ocr;
+ char name[MAX_NAME_LENGTH];
+ int num_clients, i;
+ uint32_t *ids;
+
+
+ cr->ClientId = 0;
+ if (!db_get_client_ids(ua->jcr, ua->db, &num_clients, &ids)) {
+ ua->error_msg(_("Error obtaining client ids. ERR=%s\n"), db_strerror(ua->db));
+ return 0;
+ }
+ if (num_clients <= 0) {
+ ua->error_msg(_("No clients defined. You must run a job before using this command.\n"));
+ return 0;
+ }
+
+ start_prompt(ua, _("Defined Clients:\n"));
+ for (i=0; i < num_clients; i++) {
+ ocr.ClientId = ids[i];
+ if (!db_get_client_record(ua->jcr, ua->db, &ocr) ||
+ !acl_access_ok(ua, Client_ACL, ocr.Name)) {
+ continue;
+ }
+ add_prompt(ua, ocr.Name);
+ }
+ free(ids);
+ if (do_prompt(ua, _("Client"), _("Select the Client"), name, sizeof(name)) < 0) {
+ return 0;
+ }
+ memset(&ocr, 0, sizeof(ocr));
+ bstrncpy(ocr.Name, name, sizeof(ocr.Name));
+
+ if (!db_get_client_record(ua->jcr, ua->db, &ocr)) {
+ ua->error_msg(_("Could not find Client \"%s\": ERR=%s"), name, db_strerror(ua->db));
+ return 0;
+ }
+ memcpy(cr, &ocr, sizeof(ocr));
+ return 1;
+}
+
+/* Scan what the user has entered looking for:
+ *
+ * argk=<pool-name>
+ *
+ * where argk can be : pool, recyclepool, scratchpool, nextpool etc..
+ *
+ * if error or not found, put up a list of pool DBRs
+ * to choose from.
+ *
+ * returns: false on error
+ * true on success and fills in POOL_DBR