mirror of
https://github.com/cathugger/mkp224o.git
synced 2025-01-24 17:57:51 -03:00
change usage formatting, print version
This commit is contained in:
parent
f374555fd4
commit
0eee09364d
3 changed files with 89 additions and 29 deletions
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
CC= @CC@
|
CC= @CC@
|
||||||
CSTD= @CSTD@
|
CSTD= @CSTD@
|
||||||
CFLAGS= $(CSTD) @CFLAGS@ @CPPFLAGS@ -DED25519_@ED25519IMPL@ @PIE@ @MYDEFS@
|
CFLAGS= $(CSTD) @CFLAGS@ @CPPFLAGS@ -DED25519_@ED25519IMPL@ @PIE@ @MYDEFS@ -DVERSION='"@VERSION@"'
|
||||||
ASFLAGS= @PIE@
|
ASFLAGS= @PIE@
|
||||||
LDFLAGS= @LDFLAGS@
|
LDFLAGS= @LDFLAGS@
|
||||||
MV= mv
|
MV= mv
|
||||||
|
|
33
configure.ac
33
configure.ac
|
@ -5,6 +5,38 @@ AC_CONFIG_SRCDIR([main.c])
|
||||||
oldcflags="$CFLAGS"
|
oldcflags="$CFLAGS"
|
||||||
AC_PROG_CC
|
AC_PROG_CC
|
||||||
|
|
||||||
|
# determine version
|
||||||
|
ver=""
|
||||||
|
if test -r "$srcdir/version.txt"
|
||||||
|
then
|
||||||
|
ver=`cat "$srcdir/version.txt"`
|
||||||
|
elif test -d "$srcdir/.git"
|
||||||
|
then
|
||||||
|
if git --version >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
# try matching exact tag
|
||||||
|
ver=`git -C "$srcdir" describe --tags --exact-match 2>/dev/null`
|
||||||
|
if test -z "$ver"
|
||||||
|
then
|
||||||
|
# otherwise obtain full commit ID
|
||||||
|
ver=git-`git -C "$srcdir" rev-parse HEAD 2>/dev/null`
|
||||||
|
fi
|
||||||
|
if test -n "$ver"
|
||||||
|
then
|
||||||
|
if ! git -C "$srcdir" diff --exit-code >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
# add at the end to mark modified version
|
||||||
|
ver="$ver"'*'
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test -z "$ver"
|
||||||
|
then
|
||||||
|
ver=unknown
|
||||||
|
fi
|
||||||
|
|
||||||
# NOTE: this script intentionally doesn't check for small details like posix functions and hard dependencies (libsodium) so you may get errors at compilation
|
# NOTE: this script intentionally doesn't check for small details like posix functions and hard dependencies (libsodium) so you may get errors at compilation
|
||||||
|
|
||||||
if test "x$oldcflags" != "x$CFLAGS"
|
if test "x$oldcflags" != "x$CFLAGS"
|
||||||
|
@ -346,5 +378,6 @@ AC_SUBST(MYDEFS,["$MYDEFS"])
|
||||||
AC_SUBST(MAINLIB,["$MAINLIB"])
|
AC_SUBST(MAINLIB,["$MAINLIB"])
|
||||||
AC_SUBST(PIE,["$pie"])
|
AC_SUBST(PIE,["$pie"])
|
||||||
AC_SUBST(SRCDIR,["$srcdir"])
|
AC_SUBST(SRCDIR,["$srcdir"])
|
||||||
|
AC_SUBST(VERSION,["$ver"])
|
||||||
AC_CONFIG_FILES([GNUmakefile])
|
AC_CONFIG_FILES([GNUmakefile])
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
|
83
main.c
83
main.c
|
@ -89,42 +89,61 @@ VEC_STRUCT(tstatsvec,struct tstatstruct);
|
||||||
|
|
||||||
static void printhelp(FILE *out,const char *progname)
|
static void printhelp(FILE *out,const char *progname)
|
||||||
{
|
{
|
||||||
|
// 0 1 2 3 4 5 6 7
|
||||||
|
// 01234567890123456789012345678901234567890123456789012345678901234567890123456789
|
||||||
fprintf(out,
|
fprintf(out,
|
||||||
"Usage: %s filter [filter...] [options]\n"
|
"Usage: %s FILTER [FILTER...] [OPTION]\n"
|
||||||
" %s -f filterfile [options]\n"
|
" %s -f FILTERFILE [OPTION]\n"
|
||||||
"Options:\n"
|
"Options:\n"
|
||||||
"\t-h - print help to stdout and quit\n"
|
" -f FILTERFILE specify filter file which contains filters separated\n"
|
||||||
"\t-f - specify filter file which contains filters separated by newlines\n"
|
" by newlines\n"
|
||||||
"\t-D - deduplicate filters\n"
|
" -D deduplicate filters\n"
|
||||||
"\t-q - do not print diagnostic output to stderr\n"
|
" -q do not print diagnostic output to stderr\n"
|
||||||
"\t-x - do not print onion names\n"
|
" -x do not print onion names\n"
|
||||||
"\t-v - print more diagnostic data\n"
|
" -v print more diagnostic data\n"
|
||||||
"\t-o filename - output onion names to specified file (append)\n"
|
" -o FILENAME output onion names to specified file (append)\n"
|
||||||
"\t-O filename - output onion names to specified file (overwrite)\n"
|
" -O FILENAME output onion names to specified file (overwrite)\n"
|
||||||
"\t-F - include directory names in onion names output\n"
|
" -F include directory names in onion names output\n"
|
||||||
"\t-d dirname - output directory\n"
|
" -d DIRNAME output directory\n"
|
||||||
"\t-t numthreads - specify number of threads to utilise (default - CPU core count or 1)\n"
|
" -t NUMTHREADS specify number of threads to utilise\n"
|
||||||
"\t-j numthreads - same as -t\n"
|
" (default - try detecting CPU core count)\n"
|
||||||
"\t-n numkeys - specify number of keys (default - 0 - unlimited)\n"
|
" -j NUMTHREADS same as -t\n"
|
||||||
"\t-N numwords - specify number of words per key (default - 1)\n"
|
" -n NUMKEYS specify number of keys (default - 0 - unlimited)\n"
|
||||||
"\t-Z - use \"slower\" key generation method (initial default)\n"
|
" -N NUMWORDS specify number of words per key (default - 1)\n"
|
||||||
"\t-z - use \"faster\" key generation method (later default)\n"
|
" -Z use \"slower\" key generation method (initial default)\n"
|
||||||
"\t-B - use batching key generation method (>10x faster than -z, current default)\n"
|
" -z use \"faster\" key generation method (later default)\n"
|
||||||
"\t-s - print statistics each 10 seconds\n"
|
" -B use batching key generation method\n"
|
||||||
"\t-S t - print statistics every specified ammount of seconds\n"
|
" (>10x faster than -z, current default)\n"
|
||||||
"\t-T - do not reset statistics counters when printing\n"
|
" -s print statistics each 10 seconds\n"
|
||||||
"\t-y - output generated keys in YAML format instead of dumping them to filesystem\n"
|
" -S SECONDS print statistics every specified amount of seconds\n"
|
||||||
"\t-Y [filename [host.onion]] - parse YAML encoded input and extract key(s) to filesystem\n"
|
" -T do not reset statistics counters when printing\n"
|
||||||
"\t--rawyaml - raw (unprefixed) public/secret keys for -y/-Y (may be useful for tor controller API)\n"
|
" -y output generated keys in YAML format instead of\n"
|
||||||
|
" dumping them to filesystem\n"
|
||||||
|
" -Y [FILENAME [host.onion]]\n"
|
||||||
|
" parse YAML encoded input and extract key(s) to\n"
|
||||||
|
" filesystem\n"
|
||||||
#ifdef PASSPHRASE
|
#ifdef PASSPHRASE
|
||||||
"\t-p passphrase - use passphrase to initialize the random seed with\n"
|
" -p PASSPHRASE use passphrase to initialize the random seed with\n"
|
||||||
"\t-P - same as -p, but takes passphrase from PASSPHRASE environment variable\n"
|
" -P same as -p, but takes passphrase from PASSPHRASE\n"
|
||||||
"\t--checkpoint filename - load/save checkpoint of progress to specified file (requires passphrase)\n"
|
" environment variable\n"
|
||||||
|
" --checkpoint filename\n"
|
||||||
|
" load/save checkpoint of progress to specified file\n"
|
||||||
|
" (requires passphrase)\n"
|
||||||
#endif
|
#endif
|
||||||
|
" --rawyaml raw (unprefixed) public/secret keys for -y/-Y\n"
|
||||||
|
" (may be useful for tor controller API)\n"
|
||||||
|
" -h, --help, --usage print help to stdout and quit\n"
|
||||||
|
" -V, --version print version information to stdout and exit\n"
|
||||||
,progname,progname);
|
,progname,progname);
|
||||||
fflush(out);
|
fflush(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void printversion(void)
|
||||||
|
{
|
||||||
|
fprintf(stdout,"mkp224o " VERSION "\n");
|
||||||
|
fflush(stdout);
|
||||||
|
}
|
||||||
|
|
||||||
static void e_additional(void)
|
static void e_additional(void)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"additional argument required\n");
|
fprintf(stderr,"additional argument required\n");
|
||||||
|
@ -303,6 +322,10 @@ int main(int argc,char **argv)
|
||||||
printhelp(stdout,progname);
|
printhelp(stdout,progname);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
else if (!strcmp(arg,"version")) {
|
||||||
|
printversion();
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
else if (!strcmp(arg,"rawyaml"))
|
else if (!strcmp(arg,"rawyaml"))
|
||||||
yamlraw = 1;
|
yamlraw = 1;
|
||||||
#ifdef PASSPHRASE
|
#ifdef PASSPHRASE
|
||||||
|
@ -328,6 +351,10 @@ int main(int argc,char **argv)
|
||||||
printhelp(stdout,progname);
|
printhelp(stdout,progname);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
else if (*arg == 'V') {
|
||||||
|
printversion();
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
else if (*arg == 'f') {
|
else if (*arg == 'f') {
|
||||||
if (argc--) {
|
if (argc--) {
|
||||||
if (!loadfilterfile(*argv++))
|
if (!loadfilterfile(*argv++))
|
||||||
|
|
Loading…
Add table
Reference in a new issue