static int do_tar_op(const char *base_directory)
{
- extern struct tar tar_ctx;
+ struct tar *tar_ctx = tar_get_ctx();
int ret = 0;
/* do we already have a connection? */
}
}
- ret = tar_process(&tar_ctx);
+ ret = tar_process(tar_ctx);
out_cli:
cli_shutdown(cli);
int rc = 0;
bool tar_opt = false;
bool service_opt = false;
- extern struct tar tar_ctx;
+ struct tar *tar_ctx = tar_get_ctx();
struct poptOption long_options[] = {
POPT_AUTOHELP
break;
}
i++;
- if (tar_parse_args(&tar_ctx, poptGetOptArg(pc),
+ if (tar_parse_args(tar_ctx, poptGetOptArg(pc),
const_argv + i, argc - i)) {
poptPrintUsage(pc, stderr, 0);
exit(1);
if(new_name_resolve_order)
lp_set_cmdline("name resolve order", new_name_resolve_order);
- if (!tar_to_process(&tar_ctx) && !query_host && !service && !message) {
+ if (!tar_to_process(tar_ctx) && !query_host && !service && !message) {
poptPrintUsage(pc, stderr, 0);
exit(1);
}
max_protocol = lp_client_max_protocol();
- if (tar_to_process(&tar_ctx)) {
+ if (tar_to_process(tar_ctx)) {
if (cmdstr)
process_command_string(cmdstr);
rc = do_tar_op(base_directory);
* the context of the backup process.
*
* The current tar context can be accessed via the global variable
- * `tar_ctx`. It's not static but you should avoid accessing it
- * directly.
+ * `tar_ctx`. It's publicly exported as an opaque handle via
+ * tar_get_ctx().
*
* A tar context is first configured through tar_parse_args() which
* can be called from either the CLI (in client.c) or the interactive
static bool is_subpath(const char *sub, const char *full);
static int set_remote_attr(const char *filename, uint16 new_attr, int mode);
+/**
+ * tar_get_ctx - retrieve global tar context handle
+ */
+struct tar *tar_get_ctx()
+{
+ return &tar_ctx;
+}
/**
* cmd_block - interactive command to change tar blocksize
int tar_parse_args(struct tar* t, const char *flag,
const char **val, int valsize)
{
- TALLOC_CTX *ctx = tar_reset_mem_context(t);
+ TALLOC_CTX *ctx;
bool list = false;
-
/* index of next value to use */
int ival = 0;
+ if (t == NULL) {
+ DBG(0, ("Invalid tar context\n"));
+ return 1;
+ }
+
+ ctx = tar_reset_mem_context(t);
/*
* Reset back some options - could be from interactive version
* all other modes are left as they are
{
int rc = 0;
+ if (t == NULL) {
+ DBG(0, ("Invalid tar context\n"));
+ return 1;
+ }
+
switch(t->mode.operation) {
case TAR_EXTRACT:
rc = tar_extract(t);
*/
bool tar_to_process (struct tar *t)
{
+ if (t == NULL) {
+ DBG(0, ("Invalid tar context\n"));
+ return false;
+ }
return t->to_process;
}
#define NOT_IMPLEMENTED DEBUG(0, ("tar mode not compiled. build with --with-libarchive\n"))
-struct tar
-{
- int dummy;
-};
-
-struct tar tar_ctx;
-
int cmd_block(void)
{
NOT_IMPLEMENTED;
return false;
}
+struct tar *tar_get_ctx()
+{
+ return NULL;
+}
+
#endif
int tar_process(struct tar* tar);
int tar_parse_args(struct tar *tar, const char *flag, const char **val, int valsize);
bool tar_to_process(struct tar *tar);
+struct tar *tar_get_ctx(void);
#endif /* _CLITAR_PROTO_H_ */