示例#1
0
/*
 * Execute a series of external utility programs.
 * Returns 1 if everything executed OK, 0 if one of the
 * critical commands failed or if the user cancelled.
 */
int
commands_execute(struct i_fn_args *a, struct commands *cmds)
{
	struct dfui_progress *pr;
	struct command *cmd;
	int i;
	int n = 0;
	int result = 0;
	int return_val = 1;

	cmd = cmds->head;
	while (cmd != NULL) {
		n++;
		cmd = cmd->next;
	}

	pr = dfui_progress_new(dfui_info_new(
	    "Executing Commands",
	    "Executing Commands",
	    ""),
	    0);

	if (!dfui_be_progress_begin(a->c, pr))
		abort_backend();

	i = 1;
	for (cmd = cmds->head; cmd != NULL; cmd = cmd->next, i++) {
		result = command_execute(a, pr, cmd);
		if (result == COMMAND_RESULT_CANCELLED) {
			return_val = 0;
			break;
		}
		if (result > 0 && result < 256) {
			return_val = 0;
			if (cmd->failure_mode == COMMAND_FAILURE_ABORT) {
				break;
			}
		}
		dfui_progress_set_amount(pr, (i * 100) / n);
	}

	if (!dfui_be_progress_end(a->c))
		abort_backend();

	dfui_progress_free(pr);

	return(return_val);
}
示例#2
0
struct dfui_progress *
dfui_decode_progress(struct aura_buffer *e)
{
	struct dfui_info *i;
	int amount, streaming;
	char *msg_line;
	struct dfui_progress *pr;

	i = dfui_decode_info(e);
	amount = dfui_decode_int(e);
	streaming = dfui_decode_int(e);
	msg_line = dfui_decode_string(e);

	pr = dfui_progress_new(i, amount);
	dfui_progress_set_streaming(pr, streaming);
	dfui_progress_set_msg_line(pr, msg_line);

	free(msg_line);

	return(pr);
}