Browse Source

Initial commit

Added initial files to the project (main source file and Autotools
boilerplate).
master
Damien Goutte-Gattat 13 years ago
commit
3259fec076
  1. 1
      AUTHORS
  2. 3
      Makefile.am
  3. 31
      configure.ac
  4. 6
      src/Makefile.am
  5. 139
      src/adfgvx.c

1
AUTHORS

@ -0,0 +1 @@
Damien Goutte-Gattat

3
Makefile.am

@ -0,0 +1,3 @@
SUBDIRS = src
dist_doc_DATA = AUTHORS

31
configure.ac

@ -0,0 +1,31 @@
dnl Configure template for the adfgvx package
AC_INIT([adfgvx], [0.1], [damien.goutte-gattat@e.ujf-grenoble.fr])
AC_CONFIG_SRCDIR([configure.ac])
AC_CONFIG_AUX_DIR([config])
AC_CONFIG_HEADERS([config.h]]
AM_INIT_AUTOMAKE([foreign])
dnl Check for development tools (compilers & Co.)
AC_PROG_CC
AC_PROG_INSTALL
dnl Output files
AC_CONFIG_FILES([Makefile src/Makefile])
AC_OUTPUT
dnl Summary
echo "
${PACKAGE_NAME} version ${PACKAGE_VERSION}
Configuration complete
Prefix: '${prefix}'
Compiler: '${CC} ${CFLAGS} ${CPPFLAGS}'
Now type 'make @<:@<target>@:>@'
where the optional <target> is:
all - build all binaries
install - install everything
-------------------------------------------"

6
src/Makefile.am

@ -0,0 +1,6 @@
bin_PROGRAMS = adfgvx
adfgvx_SOURCES = adfgvx.c
localedir = $(datadir)/locale
adfgvx_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\"

139
src/adfgvx.c

@ -0,0 +1,139 @@
/*
* adfgvx
* (C) 2008 Damien Goutte-Gattat <damien.goutte-gattat@e.ujf-grenoble.fr>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#define _GNU_SOURCE
#include <stdio.h>
#include <getopt.h>
#include <locale.h>
#include <errno.h>
/*
* Help and informations about the program
*/
static void
usage(int status)
{
printf(_("\
Usage: %s [options] [FILE]\n\
\n\
"), program_invocation_name);
puts(_("Options:\n\
-h, --help Display this help message.\n\
-v, --version Display the version message.\n\
"));
puts(_("\
-d, --decrypt Decrypt the given file (default action).\n\
-e, --encrypt Encrypt the given file.\n\
-k, --key FILE Use the key in the specified file.\n\
-o, --output FILE Send output to FILE instead of stdout.\n\
"));
exit(status);
}
static void
info(void)
{
printf(_("\
%s - v%s\n\
(C) 2008 Damien Goutte-Gattat <damien.goutte-gattat@e.ujf-grenoble.fr>\n\
\n\
This program is released under the GNU General Public License.\n\
"), program_invocation_name, VERSION);
exit(EXIT_SUCCESS);
}
/*
* Main function
*/
int
main(int argc, char *const argv[])
{
char c;
struct option options[] = {
{ "help", 0, NULL, 'h' },
{ "version", 0, NULL, 'v' },
{ "decrypt", 0, NULL, 'd' },
{ "encrypt", 0, NULL, 'e' },
{ "key", 1, NULL, 'k' },
{ "output", 1, NULL, 'o' },
{ NULL, 0, NULL, 0 }
};
setlocale(LC_ALL, "");
#ifdef ENABLE_NLS
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
#endif
program_invocation_name = argv[0];
while ( (c = getopt_long(argc, argv, "hvdek:o:",
options, NULL)) != -1 ) {
switch ( c ) {
case 'h':
usage(EXIT_SUCCESS);
break;
case '?':
usage(EXIT_FAILURE);
break;
case 'v':
info();
break;
case 'd':
/* decrypt */
break;
case 'e':
/* encrypt */
break;
case 'k':
/* load key */
break;
case 'o':
if ( freopen(optarg, "w", stdout) == NULL ) {
error(_("cannot open file %s: %s\n"), optarg,
strerror(errno));
}
break;
}
}
exit(EXIT_SUCCESS);
return 0;
}
Loading…
Cancel
Save