]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/dird/ua.h
Big backport from Enterprise
[bacula/bacula] / bacula / src / dird / ua.h
1 /*
2    Bacula(R) - The Network Backup Solution
3
4    Copyright (C) 2000-2017 Kern Sibbald
5
6    The original author of Bacula is Kern Sibbald, with contributions
7    from many others, a complete list can be found in the file AUTHORS.
8
9    You may use this file and others of this release according to the
10    license defined in the LICENSE file, which includes the Affero General
11    Public License, v3.0 ("AGPLv3") and some additional permissions and
12    terms pursuant to its AGPLv3 Section 7.
13
14    This notice must be preserved when any source code is
15    conveyed and/or propagated.
16
17    Bacula(R) is a registered trademark of Kern Sibbald.
18 */
19 /*
20  * Includes specific to the Director User Agent Server
21  *
22  *     Kern Sibbald, August MMI
23  */
24
25 #ifndef __UA_H_
26 #define __UA_H_ 1
27
28 class UAContext {
29 public:
30    BSOCK *UA_sock;
31    BSOCK *sd;
32    JCR *jcr;
33    BDB *db;                          /* Pointing to shared or private db */
34    BDB *shared_db;                   /* Main Bacula DB access */
35    BDB *private_db;                  /* Private DB access */
36    CAT *catalog;
37    CONRES *cons;                      /* console resource */
38    POOLMEM *cmd;                      /* return command/name buffer */
39    POOLMEM *args;                     /* command line arguments */
40    POOLMEM *errmsg;                   /* store error message */
41    char *argk[MAX_CMD_ARGS];          /* argument keywords */
42    char *argv[MAX_CMD_ARGS];          /* argument values */
43    int argc;                          /* number of arguments */
44    char **prompt;                     /* list of prompts */
45    char **unique;                     /* extra unique field */
46    int max_prompts;                   /* max size of list */
47    int num_prompts;                   /* current number in list */
48    char api_opts[MAX_NAME_LENGTH];    /* Api options */
49    int api;                           /* For programs want an API */
50    int cmd_index;                     /* Index in command table */
51    bool force_mult_db_connections;    /* overwrite cat.mult_db_connections */
52    bool auto_display_messages;        /* if set, display messages */
53    bool user_notified_msg_pending;    /* set when user notified */
54    bool automount;                    /* if set, mount after label */
55    bool quit;                         /* if set, quit */
56    bool verbose;                      /* set for normal UA verbosity */
57    bool batch;                        /* set for non-interactive mode */
58    bool gui;                          /* set if talking to GUI program */
59    bool runscript;                    /* set if we are in runscript */
60    uint32_t pint32_val;               /* positive integer */
61    int32_t  int32_val;                /* positive/negative */
62    int64_t  int64_val;                /* big int */
63
64    void *bvfs;                        /* used in some bvfs queries */
65
66    void signal(int sig) { UA_sock->signal(sig); };
67
68    /* The below are in ua_output.c */
69    void send_msg(const char *fmt, ...);
70    void error_msg(const char *fmt, ...);
71    void warning_msg(const char *fmt, ...);
72    void info_msg(const char *fmt, ...);
73 };
74
75 /* Context for insert_tree_handler() */
76 struct TREE_CTX {
77    TREE_ROOT *root;                   /* root */
78    TREE_NODE *node;                   /* current node */
79    TREE_NODE *avail_node;             /* unused node last insert */
80    int cnt;                           /* count for user feedback */
81    bool all;                          /* if set mark all as default */
82    bool hardlinks_in_mem;             /* Set to optimize for speed */
83    UAContext *ua;
84    uint32_t FileEstimate;             /* estimate of number of files */
85    uint32_t FileCount;                /* current count of files */
86    uint32_t LastCount;                /* last count of files */
87    uint32_t DeltaCount;               /* trigger for printing */
88    alist *uid_acl;                    /* UID allowed in the tree */
89    alist *gid_acl;                    /* GID allowed in the tree */
90    alist *dir_acl;                    /* Directories that can be displayed */
91    char  *last_dir_acl;               /* Last directory from the DirectoryACL list */
92 };
93
94 struct NAME_LIST {
95    char **name;                       /* list of names */
96    int num_ids;                       /* ids stored */
97    int max_ids;                       /* size of array */
98    int num_del;                       /* number deleted */
99    int tot_ids;                       /* total to process */
100 };
101
102
103 /* Main structure for obtaining JobIds or Files to be restored */
104 struct RESTORE_CTX {
105    utime_t JobTDate;
106    uint32_t TotalFiles;
107    JobId_t JobId;
108    char ClientName[MAX_NAME_LENGTH];  /* backup client */
109    char RestoreClientName[MAX_NAME_LENGTH];  /* restore client */
110    char RestoreMediaType[MAX_NAME_LENGTH];   /* restore Media type when storage override */
111    char last_jobid[20];
112    POOLMEM *JobIds;                   /* User entered string of JobIds */
113    POOLMEM *BaseJobIds;               /* Base jobids */
114    STORE  *store;
115    JOB *restore_job;
116    POOL *pool;
117    int restore_jobs;
118    uint32_t selected_files;
119    char *comment;
120    char *where;
121    char *RegexWhere;
122    char *replace;
123    char *fileregex;
124
125    char *when;
126    rblist *bsr_list;
127    POOLMEM *fname;                    /* filename only */
128    POOLMEM *path;                     /* path only */
129    POOLMEM *query;
130    int fnl;                           /* filename length */
131    int pnl;                           /* path length */
132    bool found;
133    bool all;                          /* mark all as default */
134    bool hardlinks_in_mem;             /* keep hard links in memory */
135    bool fdcalled;                     /* True if we should reuse the FD socket */
136    NAME_LIST name_list;
137    POOLMEM *component_fname;
138    FILE *component_fd;
139 };
140
141 #define MAX_ID_LIST_LEN 2000000
142
143 #endif