ecrypt/src/ecrypt.c

79 lines
1.4 KiB
C

#include <color.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "ecrypt.h"
#include "config.h"
static void
usage(int argc, char *argv[])
{
printf("%s - key generator and checker\n", argv[0]);
printf("usage: %s [-h] [-v] [-s] [-g] [-c]\n", argv[0]);
printf("\n");
printf("%s {-h} Show this message\n", argv[0]);
printf("%s {-v} Show the current version\n", argv[0]);
printf("%s {-s} View compile-time settings\n", argv[0]);
printf("%s {-g} Generate a key\n", argv[0]);
printf("%s {-c} Compare 2 key files\n", argv[0]);
printf("\n");
printf("Ecrypt is free software.\n");
printf("See the GNU GPL version 3 for details.\n");
}
static void
usage_small(int argc, char *argv[])
{
printf("usage: %s [-h] [-v] [-s] [-g] [-c]\n", argv[0]);
}
/* static void
view_compile_time_settings(int argc, char *argv[])
{}
*/
int
main(int argc, char *argv[])
{
if (argc < 2) {
usage_small(argc, argv);
exit(1);
}
int opt;
while ((opt = getopt(argc, argv, ":if:hvsgc")) != -1) {
switch(opt) {
case 'h':
usage(argc, argv);
exit(0);
break;
case 'v':
printf(ECRYPT_VERSION "\n");
exit(0);
break;
case 's':
/* view_compile_time_settings(argc, argv); */
printf("not implemented\n");
exit(0);
break;
case 'g':
genkey(PASSWD_LENGTH);
exit(0);
break;
case 'c':
checkkey(argc, argv);
exit(0);
break;
case '?':
usage_small(argc, argv);
exit(1);
break;
}
}
return 0;
}