2 * Copyright (c)2004 The DragonFly Project. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
8 * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
11 * Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in
13 * the documentation and/or other materials provided with the
16 * Neither the name of the DragonFly Project nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
25 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
31 * OF THE POSSIBILITY OF SUCH DAMAGE.
36 * $Id: commands.h,v 1.14 2005/02/06 21:05:18 cpressey Exp $
41 #include "libdfui/dfui.h"
50 #include "functions.h"
55 #ifdef NEEDS_COMMANDS_STRUCTURE_DEFINITIONS
65 char *cmdline
; /* command line to execute */
66 char *desc
; /* description displayed in progress bar */
67 int log_mode
; /* use a COMMAND_LOG_* constant here */
68 int failure_mode
; /* use a COMMAND_FAILURE_* constant here */
69 char *tag
; /* tag which is recorded on failure */
70 int result
; /* result code from executing command */
71 char *output
; /* output of command */
76 #define COMMAND_LOG_SILENT 0
77 #define COMMAND_LOG_QUIET 1
78 #define COMMAND_LOG_VERBOSE 2
80 #define COMMAND_FAILURE_IGNORE 0
81 #define COMMAND_FAILURE_WARN 1
82 #define COMMAND_FAILURE_ABORT 2
84 #define COMMAND_RESULT_NEVER_EXECUTED -1
85 #define COMMAND_RESULT_POPEN_ERR 256
86 #define COMMAND_RESULT_SELECT_ERR 257
87 #define COMMAND_RESULT_CANCELLED 512
88 #define COMMAND_RESULT_SKIPPED 513
92 struct commands
*commands_new(void);
93 struct command
*command_add(struct commands
*, const char *, ...);
95 void command_set_log_mode(struct command
*, int);
96 void command_set_failure_mode(struct command
*, int);
97 void command_set_desc(struct command
*, const char *, ...);
98 void command_set_tag(struct command
*, const char *, ...);
100 struct command
*command_get_first(const struct commands
*);
101 struct command
*command_get_next(const struct command
*);
103 char *command_get_cmdline(const struct command
*);
104 char *command_get_tag(const struct command
*);
105 int command_get_result(const struct command
*);
107 void commands_preview(struct dfui_connection
*, const struct commands
*);
108 int commands_execute(struct i_fn_args
*, struct commands
*);
110 void commands_free(struct commands
*);
112 void view_command_log(struct i_fn_args
*);
114 /* Command Generators */
116 void unmount_all_under(struct i_fn_args
*, struct commands
*,
119 #endif /* !__COMMANDS_H_ */