continue;
}
if (strcasecmp(ua->cmd, _("yes")) == 0) {
- break;
+ return 1;
+ }
+ if (strcasecmp(ua->cmd, _("no")) == 0) {
+ return 0;
}
}
return 1;
*/
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;
}
}
/*
- * 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)
{
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++) {
return -1;
}
-
-
/*
* Given a list of keywords, prompt the user
* to choose one.
for (i=0; list[i]; i++) {
add_prompt(ua, list[i]);
}
- return do_prompt(ua, msg, NULL, 0);
+ return do_prompt(ua, "", msg, NULL, 0);
}
add_prompt(ua, store->hdr.name);
}
UnlockRes();
- do_prompt(ua, _("Select Storage resource"), name, sizeof(name));
+ do_prompt(ua, _("Storage"), _("Select Storage resource"), name, sizeof(name));
store = (STORE *)GetResWithName(R_STORAGE, name);
return store;
}
add_prompt(ua, fs->hdr.name);
}
UnlockRes();
- do_prompt(ua, _("Select FileSet resource"), name, sizeof(name));
+ do_prompt(ua, _("FileSet"), _("Select FileSet resource"), name, sizeof(name));
fs = (FILESET *)GetResWithName(R_FILESET, name);
return fs;
}
add_prompt(ua, catalog->hdr.name);
}
UnlockRes();
- do_prompt(ua, _("Select Catalog resource"), name, sizeof(name));
+ do_prompt(ua, _("Catalog"), _("Select Catalog resource"), name, sizeof(name));
catalog = (CAT *)GetResWithName(R_CATALOG, name);
}
return catalog;
add_prompt(ua, job->hdr.name);
}
UnlockRes();
- do_prompt(ua, _("Select Job resource"), name, sizeof(name));
+ do_prompt(ua, _("Job"), _("Select Job resource"), name, sizeof(name));
job = (JOB *)GetResWithName(R_JOB, name);
return job;
}
}
}
UnlockRes();
- do_prompt(ua, _("Select Restore Job"), name, sizeof(name));
+ do_prompt(ua, _("Job"), _("Select Restore Job"), name, sizeof(name));
job = (JOB *)GetResWithName(R_JOB, name);
return job;
}
add_prompt(ua, client->hdr.name);
}
UnlockRes();
- do_prompt(ua, _("Select Client (File daemon) resource"), name, sizeof(name));
+ do_prompt(ua, _("Client"), _("Select Client (File daemon) resource"), name, sizeof(name));
client = (CLIENT *)GetResWithName(R_CLIENT, name);
return client;
}
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;
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],
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;
}
add_prompt(ua, ocr.Name);
}
free(ids);
- if (do_prompt(ua, _("Select the Client"), name, sizeof(name)) < 0) {
+ if (do_prompt(ua, _("Client"), _("Select the Client"), name, sizeof(name)) < 0) {
return 0;
}
memset(&ocr, 0, sizeof(ocr));
add_prompt(ua, opr.Name);
}
free(ids);
- if (do_prompt(ua, _("Select the Pool"), name, sizeof(name)) < 0) {
+ if (do_prompt(ua, _("Pool"), _("Select the Pool"), name, sizeof(name)) < 0) {
return 0;
}
memset(&opr, 0, sizeof(opr));
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;
}
add_prompt(ua, pool->hdr.name);
}
UnlockRes();
- do_prompt(ua, _("Select Pool resource"), name, sizeof(name));
+ do_prompt(ua, _("Pool"), _("Select Pool resource"), name, sizeof(name));
pool = (POOL *)GetResWithName(R_POOL, name);
return pool;
}
*/
int select_job_dbr(UAContext *ua, JOB_DBR *jr)
{
- db_list_job_records(ua->jcr, ua->db, jr, prtit, ua, 0);
- if (!get_cmd(ua, _("Enter the JobId to select: "))) {
+ db_list_job_records(ua->jcr, ua->db, jr, prtit, ua, HORZ_LIST);
+ if (!get_pint(ua, _("Enter the JobId to select: "))) {
return 0;
}
- jr->JobId = atoi(ua->cmd);
+ jr->JobId = ua->pint32_val;
if (!db_get_job_record(ua->jcr, ua->db, jr)) {
bsendmsg(ua, "%s", db_strerror(ua->db));
return 0;
* index base 0 on success, and choice
* is copied to prompt if not NULL
*/
-int do_prompt(UAContext *ua, char *msg, char *prompt, int max_prompt)
+int do_prompt(UAContext *ua, char *automsg, char *msg, char *prompt, int max_prompt)
{
int i, item;
char pmsg[MAXSTRING];
+ if (ua->num_prompts == 2) {
+ item = 1;
+ if (prompt) {
+ bstrncpy(prompt, ua->prompt[1], max_prompt);
+ }
+ bsendmsg(ua, _("Automatically selected %s: %s\n"), automsg, ua->prompt[1]);
+ goto done;
+ }
bsendmsg(ua, ua->prompt[0]);
for (i=1; i < ua->num_prompts; i++) {
bsendmsg(ua, "%6d: %s\n", i, ua->prompt[i]);
sprintf(pmsg, "%s (1-%d): ", msg, ua->num_prompts-1);
}
/* Either a . or an @ will get you out of the loop */
- if (!get_cmd(ua, pmsg) || *ua->cmd == '@') {
+ if (!get_pint(ua, pmsg)) {
item = -1; /* error */
bsendmsg(ua, _("Selection aborted, nothing done.\n"));
break;
}
- item = atoi(ua->cmd);
+ item = ua->pint32_val;
if (item < 1 || item >= ua->num_prompts) {
bsendmsg(ua, _("Please enter a number between 1 and %d\n"), ua->num_prompts-1);
continue;
break;
}
+done:
for (i=0; i < ua->num_prompts; i++) {
free(ua->prompt[i]);
}
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;
add_prompt(ua, store->media_type);
}
UnlockRes();
- return (do_prompt(ua, _("Select the Media Type"), MediaType, max_media) < 0) ? 0 : 1;
+ return (do_prompt(ua, _("Media Type"), _("Select the Media Type"), MediaType, max_media) < 0) ? 0 : 1;
}