/*
- * Includes specific to the Director User Agent Server
- *
- * Kern Sibbald, August MMI
- *
- * Version $Id$
- */
-/*
- Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
+ Bacula® - The Network Backup Solution
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
+ Copyright (C) 2001-2007 Free Software Foundation Europe e.V.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
+ The main author of Bacula is Kern Sibbald, with contributions from
+ many others, a complete list can be found in the file AUTHORS.
+ This program is Free Software; you can redistribute it and/or
+ modify it under the terms of version two of the GNU General Public
+ License as published by the Free Software Foundation plus additions
+ that are listed in the file LICENSE.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
- You should have received a copy of the GNU General Public
- License along with this program; if not, write to the Free
- Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
- MA 02111-1307, USA.
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+ Bacula® is a registered trademark of John Walker.
+ The licensor of Bacula is the Free Software Foundation Europe
+ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
+ Switzerland, email:ftf@fsfeurope.org.
+*/
+/*
+ * Includes specific to the Director User Agent Server
+ *
+ * Kern Sibbald, August MMI
+ *
+ * Version $Id$
*/
-#define MAX_ARGS 30
+#ifndef __UA_H_
+#define __UA_H_ 1
-typedef struct s_ua_context {
+class UAContext {
+public:
BSOCK *UA_sock;
BSOCK *sd;
JCR *jcr;
B_DB *db;
CAT *catalog;
+ CONRES *cons; /* console resource */
POOLMEM *cmd; /* return command/name buffer */
POOLMEM *args; /* command line arguments */
- char *argk[MAX_ARGS]; /* argument keywords */
- char *argv[MAX_ARGS]; /* argument values */
+ char *argk[MAX_CMD_ARGS]; /* argument keywords */
+ char *argv[MAX_CMD_ARGS]; /* argument values */
int argc; /* number of arguments */
char **prompt; /* list of prompts */
int max_prompts; /* max size of list */
int num_prompts; /* current number in list */
- int auto_display_messages; /* if set, display messages */
- int user_notified_msg_pending; /* set when user notified */
- int automount; /* if set, mount after label */
- int quit; /* if set, quit */
- int verbose; /* set for normal UA verbosity */
-} UAContext;
+ int api; /* For programs want an API */
+ bool auto_display_messages; /* if set, display messages */
+ bool user_notified_msg_pending; /* set when user notified */
+ bool automount; /* if set, mount after label */
+ bool quit; /* if set, quit */
+ bool verbose; /* set for normal UA verbosity */
+ bool batch; /* set for non-interactive mode */
+ bool gui; /* set if talking to GUI program */
+ uint32_t pint32_val; /* positive integer */
+ int32_t int32_val; /* positive/negative */
+ int64_t int64_val; /* big int */
-/* ua_cmds.c */
-int do_a_command(UAContext *ua, char *cmd);
-int do_a_dot_command(UAContext *ua, char *cmd);
-int qmessagescmd(UAContext *ua, char *cmd);
-int open_db(UAContext *ua);
-void close_db(UAContext *ua);
+ void signal(int sig) { UA_sock->signal(sig); };
-/* ua_input.c */
-char *next_arg(char **s);
-int get_cmd(UAContext *ua, char *prompt);
-void parse_command_args(UAContext *ua);
+ /* The below are in ua_output.c */
+ void send_msg(const char *fmt, ...);
+ void error_msg(const char *fmt, ...);
+ void warning_msg(const char *fmt, ...);
+ void info_msg(const char *fmt, ...);
+};
-/* ua_output.c */
-void prtit(void *ctx, char *msg);
+/* Context for insert_tree_handler() */
+struct TREE_CTX {
+ TREE_ROOT *root; /* root */
+ TREE_NODE *node; /* current node */
+ TREE_NODE *avail_node; /* unused node last insert */
+ int cnt; /* count for user feedback */
+ bool all; /* if set mark all as default */
+ UAContext *ua;
+ uint32_t FileEstimate; /* estimate of number of files */
+ uint32_t FileCount; /* current count of files */
+ uint32_t LastCount; /* last count of files */
+ uint32_t DeltaCount; /* trigger for printing */
+};
-/* ua_server.c */
-void bsendmsg(void *sock, char *fmt, ...);
+struct NAME_LIST {
+ char **name; /* list of names */
+ int num_ids; /* ids stored */
+ int max_ids; /* size of array */
+ int num_del; /* number deleted */
+ int tot_ids; /* total to process */
+};
-/* ua_select.c */
-STORE *select_storage_resource(UAContext *ua);
-JOB *select_job_resource(UAContext *ua);
-int select_pool_dbr(UAContext *ua, POOL_DBR *pr);
-CLIENT *select_client_resource(UAContext *ua);
-FILESET *select_fs_resource(UAContext *ua);
-int select_pool_and_media_dbr(UAContext *ua, POOL_DBR *pr, MEDIA_DBR *mr);
-void start_prompt(UAContext *ua, char *msg);
-void add_prompt(UAContext *ua, char *prompt);
-int do_prompt(UAContext *ua, char *msg, char *prompt);
-CAT *get_catalog_resource(UAContext *ua);
-STORE *get_storage_resource(UAContext *ua, char *cmd);
-int get_media_type(UAContext *ua, char *MediaType);
-int get_pool_dbr(UAContext *ua, POOL_DBR *pr);
-POOL *get_pool_resource(UAContext *ua);
-CLIENT *get_client_resource(UAContext *ua);
-int get_job_dbr(UAContext *ua, JOB_DBR *jr);
+/* Main structure for obtaining JobIds or Files to be restored */
+struct RESTORE_CTX {
+ utime_t JobTDate;
+ uint32_t TotalFiles;
+ JobId_t JobId;
+ char ClientName[MAX_NAME_LENGTH];
+ char last_jobid[20];
+ POOLMEM *JobIds; /* User entered string of JobIds */
+ STORE *store;
+ JOB *restore_job;
+ POOL *pool;
+ int restore_jobs;
+ uint32_t selected_files;
+ char *where;
+ char *RegexWhere;
+ RBSR *bsr;
+ POOLMEM *fname; /* filename only */
+ POOLMEM *path; /* path only */
+ POOLMEM *query;
+ int fnl; /* filename length */
+ int pnl; /* path length */
+ bool found;
+ bool all; /* mark all as default */
+ NAME_LIST name_list;
+};
-int find_arg_keyword(UAContext *ua, char **list);
-int do_keyword_prompt(UAContext *ua, char *msg, char **list);
-int confirm_retention(UAContext *ua, btime_t *ret, char *msg);
+#define MAX_ID_LIST_LEN 2000000
-/* ua_prune.c */
-int prune_files(UAContext *ua, CLIENT *client);
-int prune_jobs(UAContext *ua, CLIENT *client);
-int prune_volume(UAContext *ua, POOL_DBR *pr, MEDIA_DBR *mr);
+#endif