Browse Source

Added default key file option

Added configure-time option "--enable-default-keyfile" and corresponding
support in src/adfgvx.c.
master
Damien Goutte-Gattat 13 years ago
parent
commit
d99d4dad7b
  1. 16
      configure.ac
  2. 17
      src/adfgvx.c

16
configure.ac

@ -10,6 +10,21 @@ dnl Check for development tools (compilers & Co.)
AC_PROG_CC
AC_PROG_INSTALL
dnl Options
AC_ARG_ENABLE([default-keyfile],
[AS_HELP_STRING([--enable-default-keyfile],
[Enable use of a default keyfile @<:@default=yes@:>@])],
[],
[enable_default_keyfile=yes])
if test "x$enable_default_keyfile" = xyes ; then
enable_default_keyfile=.adfgvx.key
fi
if test "x$enable_default_keyfile" != xno ; then
AC_DEFINE_UNQUOTED([DEFAULT_KEYFILE], ["$enable_default_keyfile"],
[Default key filename.])
fi
dnl Output files
AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT
@ -22,6 +37,7 @@ Configuration complete
Prefix: '${prefix}'
Compiler: '${CC} ${CFLAGS} ${CPPFLAGS}'
Default keyfile: '${enable_default_keyfile}'
Now type 'make @<:@<target>@:>@'
where the optional <target> is:

17
src/adfgvx.c

@ -110,6 +110,19 @@ load_key(const char *filename)
return key;
}
#ifdef DEFAULT_KEYFILE
static cipher_key_t *
get_default_key(void)
{
char keyfile[255], *home;
home = getenv("HOME");
sprintf(keyfile, "%s/%s", home, DEFAULT_KEYFILE);
return load_key(keyfile);
}
#endif /* DEFAULT_KEYFILE */
/*
* Operations on files
@ -257,7 +270,11 @@ main(int argc, char *const argv[])
}
if ( key == NULL )
#ifndef DEFAULT_KEYFILE
error(_("no keyfile specified (-k)\n"));
#else
key = get_default_key();
#endif
if ( argc - optind >= 1 &&
(argv[optind][0] != '-' || argv[optind][1] != '\0') ) {

Loading…
Cancel
Save