Add the possibility to load an additional exclude file.

This commit is contained in:
Andreas Schneider 2008-05-20 15:50:02 +02:00
parent 891827a48a
commit dddb81c5cd
3 changed files with 40 additions and 6 deletions

View file

@ -29,6 +29,11 @@
#include "csync_auth.h"
enum {
KEY_DUMMY = 129,
KEY_EXCLUDE_FILE
};
const char *argp_program_version = "csync commandline client 0.42";
const char *argp_program_bug_address = "<csync-devel@csync.org>";
@ -61,7 +66,15 @@ static struct argp_option options[] = {
.key = 'j',
.arg = NULL,
.flags = 0,
.doc = "Testing only",
.doc = "Run update detection and write the journal (TESTING ONLY!)",
.group = 0
},
{
.name = "exclude-file",
.key = KEY_EXCLUDE_FILE,
.arg = "<file>",
.flags = 0,
.doc = "Add an additional exclude file",
.group = 0
},
{NULL, 0, 0, 0, NULL, 0}
@ -70,6 +83,7 @@ static struct argp_option options[] = {
/* Used by main to communicate with parse_opt. */
struct argument_s {
char *args[2]; /* SOURCE and DESTINATION */
char *exclude_file;
int journal;
int update;
int reconcile;
@ -102,6 +116,9 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) {
arguments->reconcile = 1;
arguments->propagate = 0;
break;
case KEY_EXCLUDE_FILE:
arguments->exclude_file = strdup(arg);
break;
case ARGP_KEY_ARG:
if (state->arg_num >= 2) {
/* Too many arguments. */
@ -156,8 +173,15 @@ int main(int argc, char **argv) {
csync_set_module_auth_callback(csync, csync_auth_fn);
fprintf(stdout,"\n");
csync_init(csync);
printf("Version: %s\n", csync_version());
if (csync_init(csync) < 0) {
goto err;
}
if (arguments.exclude_file != NULL) {
if (csync_add_exclude_list(csync, arguments.exclude_file) < 0) {
goto err;
}
}
if (arguments.update) {
if (csync_update(csync) < 0) {

View file

@ -514,14 +514,22 @@ const char *csync_version(void) {
return CSYNC_VERSION_STRING;
}
int csync_add_exclude_list(CSYNC *ctx, const char *path) {
return csync_exclude_load(ctx, path);
}
void csync_set_module_auth_callback(CSYNC *ctx, csync_module_auth_callback cb) {
if (ctx->status & CSYNC_INIT) {
fprintf(stderr, "This function must be called before initialization");
fprintf(stderr, "This function must be called before initialization.");
exit(1);
}
ctx->auth_callback = cb;
}
csync_module_auth_callback csync_get_module_auth_callback(CSYNC *ctx) {
return ctx->auth_callback;
}
void csync_set_status(CSYNC *ctx, int status) {
ctx->status = status;
}

View file

@ -127,9 +127,11 @@ int csync_destroy(CSYNC *ctx);
*/
const char *csync_version(void);
int csync_add_exclude_list(CSYNC *ctx, const char *path);
csync_module_auth_callback csync_get_module_auth_callback(CSYNC *ctx);
void csync_set_module_auth_callback(CSYNC *ctx, csync_module_auth_callback cb);
void csync_set_status(CSYNC *ctx, int status);
int csync_get_status(CSYNC *ctx);
void csync_set_status(CSYNC *ctx, int status);
#ifdef __cplusplus
}