diff --git a/ChangeLog b/ChangeLog index 61ae8be..b744112 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,8 +8,8 @@ ChangeLog for davfs2 Replace xxfsent functions by xxmntent functions. Don't compare commandline and fstab for options 'user' and 'users', only check fstab for presence. - * mount_davfs.c, log_dbg_cmdline: - Replace argz. + * mount_davfs.h, mount_davfs.c: + Replace log_dbg_cmdline. 2010-08-07 Werner Baumann (werner.baumann@onlinehome.de) * webdav.c: diff --git a/src/mount_davfs.c b/src/mount_davfs.c index 3d6b36a..b767656 100644 --- a/src/mount_davfs.c +++ b/src/mount_davfs.c @@ -190,9 +190,6 @@ ignore_home(const char *name, const char *ignore_list); static dav_args * new_args(void); -static void -log_dbg_cmdline(int argc, char *argv[]); - static void log_dbg_config(char *argv[], dav_args *args); @@ -935,9 +932,23 @@ is_mounted(void) static dav_args * parse_commandline(int argc, char *argv[]) { - log_dbg_cmdline(argc, argv); dav_args *args = new_args(); + size_t len = argc; + int i; + for (i = 0; i < argc; i++) + len += strlen(argv[i]); + args->cmdline = malloc(len); + if (!args->cmdline) abort(); + char *p = args->cmdline; + for (i = 0; i < argc - 1; i++) { + strcpy(p, argv[i]); + p += strlen(argv[i]); + *p = ' '; + p++; + } + strcpy(p, argv[argc - 1]); + char *short_options = "vwVho:"; static const struct option options[] = { {"version", no_argument, NULL, 'V'}, @@ -973,7 +984,7 @@ parse_commandline(int argc, char *argv[]) o = getopt_long(argc, argv, short_options, options, NULL); } - int i = optind; + i = optind; switch (argc - i) { case 0: case 1: @@ -1418,6 +1429,8 @@ decode_octal(const char *s) static void delete_args(dav_args *args) { + if (args->cmdline) + free(args->cmdline); if (args->dav_user) free(args->dav_user); if (args->dav_group) @@ -1734,6 +1747,7 @@ new_args(void) dav_args *args = ne_malloc(sizeof(*args)); + args->cmdline = NULL; args->dav_user = ne_strdup(DAV_USER); args->dav_group = ne_strdup(DAV_GROUP); args->ignore_home = NULL; @@ -1825,33 +1839,11 @@ new_args(void) } -static void -log_dbg_cmdline(int argc, char *argv[]) -{ - size_t len = argc; - int i; - for (i = 0; i < argc; i++) - len += strlen(argv[i]); - char *cmdline = malloc(len); - if (!cmdline) abort(); - - char *p = cmdline; - for (i = 0; i < argc - 1; i++) { - strcpy(p, argv[i]); - p += strlen(argv[i]); - *p = ' '; - p++; - } - strcpy(p, argv[argc - 1]); - - syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), cmdline); - free(cmdline); -} - - static void log_dbg_config(char *argv[], dav_args *args) { + syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), + "%s", args->cmdline); syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), "Configuration:"); syslog(LOG_MAKEPRI(LOG_DAEMON, LOG_DEBUG), diff --git a/src/mount_davfs.h b/src/mount_davfs.h index a016072..df6368b 100644 --- a/src/mount_davfs.h +++ b/src/mount_davfs.h @@ -31,6 +31,7 @@ Some data will be copied into global or local variables to be available in daemon mode. The rest will be freed when forking into daemon mode. */ typedef struct { + char *cmdline; char *dav_user; /* System config file */ char *dav_group; /* System config file */ char *ignore_home; /* System config file */