/* Get a new context so we don't destroy restore command args */
UAContext *ua = new_ua_context(tree->ua->jcr);
ua->UA_sock = tree->ua->UA_sock; /* patch in UA socket */
+ ua->api = tree->ua->api; /* keep API flag too */
+ BSOCK *user = ua->UA_sock;
- bsendmsg(tree->ua, _(
+ ua->send_msg(_(
"\nYou are now entering file selection mode where you add (mark) and\n"
"remove (unmark) files to be restored. No files are initially added, unless\n"
"you used the \"all\" keyword on the command line.\n"
*/
tree->node = (TREE_NODE *)tree->root;
tree_getpath(tree->node, cwd, sizeof(cwd));
- bsendmsg(tree->ua, _("cwd is: %s\n"), cwd);
+ ua->send_msg(_("cwd is: %s\n"), cwd);
for ( ;; ) {
int found, len, i;
if (!get_cmd(ua, "$ ")) {
break;
}
+ if (ua->api) user->signal(BNET_CMD_BEGIN);
parse_args_only(ua->cmd, &ua->args, &ua->argc, ua->argk, ua->argv, MAX_CMD_ARGS);
if (ua->argc == 0) {
- bsendmsg(tree->ua, _("Invalid command. Enter \"done\" to exit.\n"));
+ ua->warning_msg(_("Invalid command. Enter \"done\" to exit.\n"));
+ if (ua->api) user->signal(BNET_CMD_FAILED);
continue;
}
break;
}
if (!found) {
- bsendmsg(tree->ua, _("Invalid command. Enter \"done\" to exit.\n"));
+ ua->warning_msg(_("Invalid command. Enter \"done\" to exit.\n"));
+ if (ua->api) user->signal(BNET_CMD_FAILED);
continue;
}
+ if (ua->api) user->signal(BNET_CMD_OK);
if (!stat) {
break;
}
if (node->inserted) {
tree->FileCount++;
if (tree->DeltaCount > 0 && (tree->FileCount-tree->LastCount) > tree->DeltaCount) {
- bsendmsg(tree->ua, "+");
+ tree->ua->send_msg("+");
tree->LastCount = tree->FileCount;
}
}
char ec1[50];
if (ua->argc < 2 || !tree_node_has_child(tree->node)) {
- bsendmsg(ua, _("No files marked.\n"));
+ ua->send_msg(_("No files marked.\n"));
return 1;
}
for (int i=1; i < ua->argc; i++) {
}
}
if (count == 0) {
- bsendmsg(ua, _("No files marked.\n"));
+ ua->send_msg(_("No files marked.\n"));
} else if (count == 1) {
- bsendmsg(ua, _("1 file marked.\n"));
+ ua->send_msg(_("1 file marked.\n"));
} else {
- bsendmsg(ua, _("%s files marked.\n"),
+ ua->send_msg(_("%s files marked.\n"),
edit_uint64_with_commas(count, ec1));
}
return 1;
char ec1[50];
if (ua->argc < 2 || !tree_node_has_child(tree->node)) {
- bsendmsg(ua, _("No files marked.\n"));
+ ua->send_msg(_("No files marked.\n"));
return 1;
}
for (int i=1; i < ua->argc; i++) {
}
}
if (count == 0) {
- bsendmsg(ua, _("No directories marked.\n"));
+ ua->send_msg(_("No directories marked.\n"));
} else if (count == 1) {
- bsendmsg(ua, _("1 directory marked.\n"));
+ ua->send_msg(_("1 directory marked.\n"));
} else {
- bsendmsg(ua, _("%s directories marked.\n"),
+ ua->send_msg(_("%s directories marked.\n"),
edit_uint64_with_commas(count, ec1));
}
return 1;
}
}
}
- bsendmsg(ua, _("%s total files/dirs. %s marked to be restored.\n"),
+ ua->send_msg(_("%s total files/dirs. %s marked to be restored.\n"),
edit_uint64_with_commas(total, ec1),
edit_uint64_with_commas(num_extract, ec2));
return 1;
char cwd[2000];
if (ua->argc == 1) {
- bsendmsg(ua, _("No file specification given.\n"));
+ ua->send_msg(_("No file specification given.\n"));
return 1; /* make it non-fatal */
}
} else {
tag = "";
}
- bsendmsg(ua, "%s%s\n", tag, cwd);
+ ua->send_msg("%s%s\n", tag, cwd);
}
}
}
} else {
tag = "";
}
- bsendmsg(ua, "%s%s%s\n", tag, node->fname, tree_node_has_child(node)?"/":"");
+ ua->send_msg("%s%s%s\n", tag, node->fname, tree_node_has_child(node)?"/":"");
}
}
return 1;
} else {
tag = "";
}
- bsendmsg(ua, "%s%s%s\n", tag, node->fname, tree_node_has_child(node)?"/":"");
+ ua->send_msg("%s%s%s\n", tag, node->fname, tree_node_has_child(node)?"/":"");
if (tree_node_has_child(node)) {
rlsmark(ua, node);
}
char cwd[1100], *pcwd;
if (!tree_node_has_child(tree->node)) {
- bsendmsg(ua, _("Node %s has no children.\n"), tree->node->fname);
+ ua->send_msg(_("Node %s has no children.\n"), tree->node->fname);
return 1;
}
memset(&statp, 0, sizeof(statp));
}
ls_output(buf, cwd, tag, &statp, dot_cmd);
- bsendmsg(ua, "%s\n", buf);
+ ua->send_msg("%s\n", buf);
}
}
return 1;
}
}
}
- bsendmsg(ua, _("%d total files; %d marked to be restored; %s bytes.\n"),
+ ua->send_msg(_("%d total files; %d marked to be restored; %s bytes.\n"),
total, num_extract, edit_uint64_with_commas(total_bytes, ec1));
return 1;
}
{
unsigned int i;
- bsendmsg(ua, _(" Command Description\n ======= ===========\n"));
+ ua->send_msg(_(" Command Description\n ======= ===========\n"));
for (i=0; i<comsize; i++) {
/* List only non-dot commands */
if (commands[i].key[0] != '.') {
- bsendmsg(ua, " %-10s %s\n", _(commands[i].key), _(commands[i].help));
+ ua->send_msg(" %-10s %s\n", _(commands[i].key), _(commands[i].help));
}
}
- bsendmsg(ua, "\n");
+ ua->send_msg("\n");
return 1;
}
if (ua->argc != 2) {
- bsendmsg(ua, _("Too few or too many arguments. Try using double quotes.\n"));
+ ua->error_msg(_("Too few or too many arguments. Try using double quotes.\n"));
return 1;
}
node = tree_cwd(ua->argk[1], tree->root, tree->node);
node = tree_cwd(cwd, tree->root, tree->node);
}
if (!node) {
- bsendmsg(ua, _("Invalid path given.\n"));
+ ua->warning_msg(_("Invalid path given.\n"));
} else {
tree->node = node;
}
} else {
tree->node = node;
}
- tree_getpath(tree->node, cwd, sizeof(cwd));
- if (ua->api) {
- bsendmsg(ua, "%s", cwd);
- } else {
- bsendmsg(ua, _("cwd is: %s\n"), cwd);
- }
- return 1;
+ return pwdcmd(ua, tree);
}
static int pwdcmd(UAContext *ua, TREE_CTX *tree)
{
char cwd[2000];
tree_getpath(tree->node, cwd, sizeof(cwd));
- bsendmsg(ua, _("cwd is: %s\n"), cwd);
+ if (ua->api) {
+ ua->send_msg("%s", cwd);
+ } else {
+ ua->send_msg(_("cwd is: %s\n"), cwd);
+ }
return 1;
}
{
char cwd[2000];
tree_getpath(tree->node, cwd, sizeof(cwd));
- bsendmsg(ua, _("%s"), cwd);
+ ua->send_msg("%s", cwd);
return 1;
}
int count = 0;
if (ua->argc < 2 || !tree_node_has_child(tree->node)) {
- bsendmsg(ua, _("No files unmarked.\n"));
+ ua->send_msg(_("No files unmarked.\n"));
return 1;
}
for (int i=1; i < ua->argc; i++) {
}
}
if (count == 0) {
- bsendmsg(ua, _("No files unmarked.\n"));
+ ua->send_msg(_("No files unmarked.\n"));
} else if (count == 1) {
- bsendmsg(ua, _("1 file unmarked.\n"));
+ ua->send_msg(_("1 file unmarked.\n"));
} else {
char ed1[50];
- bsendmsg(ua, _("%s files unmarked.\n"), edit_uint64_with_commas(count, ed1));
+ ua->send_msg(_("%s files unmarked.\n"), edit_uint64_with_commas(count, ed1));
}
return 1;
}
int count = 0;
if (ua->argc < 2 || !tree_node_has_child(tree->node)) {
- bsendmsg(ua, _("No directories unmarked.\n"));
+ ua->send_msg(_("No directories unmarked.\n"));
return 1;
}
}
if (count == 0) {
- bsendmsg(ua, _("No directories unmarked.\n"));
+ ua->send_msg(_("No directories unmarked.\n"));
} else if (count == 1) {
- bsendmsg(ua, _("1 directory unmarked.\n"));
+ ua->send_msg(_("1 directory unmarked.\n"));
} else {
- bsendmsg(ua, _("%d directories unmarked.\n"), count);
+ ua->send_msg(_("%d directories unmarked.\n"), count);
}
return 1;
}