mdigest.c (schily-2021-08-14.tar.bz2) | : | mdigest.c (schily-2021-09-18.tar.bz2) | ||
---|---|---|---|---|
/* @(#)mdigest.c 1.6 16/11/01 Copyright 2009-2016 J. Schilling */ | /* @(#)mdigest.c 1.9 21/08/22 Copyright 2009-2021 J. Schilling */ | |||
#include <schily/mconfig.h> | #include <schily/mconfig.h> | |||
#ifndef lint | #ifndef lint | |||
static UConst char sccsid[] = | static UConst char sccsid[] = | |||
/*static const char sccsid[] =*/ | /*static const char sccsid[] =*/ | |||
"@(#)mdigest.c 1.6 16/11/01 Copyright 2009-2016 J. Schilling"; | "@(#)mdigest.c 1.9 21/08/22 Copyright 2009-2021 J. Schilling"; | |||
#endif | #endif | |||
/* | /* | |||
* Compute the message digest for files | * Compute the message digest for files | |||
* | * | |||
* Copyright (c) 2009-2016 J. Schilling | * Copyright (c) 2009-2021 J. Schilling | |||
*/ | */ | |||
/* | /* | |||
* The contents of this file are subject to the terms of the | * The contents of this file are subject to the terms of the | |||
* Common Development and Distribution License, Version 1.0 only | * Common Development and Distribution License, Version 1.0 only | |||
* (the "License"). You may not use this file except in compliance | * (the "License"). You may not use this file except in compliance | |||
* with the License. | * with the License. | |||
* | * | |||
* See the file CDDL.Schily.txt in this distribution for details. | * See the file CDDL.Schily.txt in this distribution for details. | |||
* A copy of the CDDL is also available via the Internet at | * A copy of the CDDL is also available via the Internet at | |||
* http://www.opensource.org/licenses/cddl1.txt | * http://www.opensource.org/licenses/cddl1.txt | |||
skipping to change at line 35 | skipping to change at line 35 | |||
*/ | */ | |||
#include <schily/stdio.h> | #include <schily/stdio.h> | |||
#include <schily/standard.h> | #include <schily/standard.h> | |||
#include <schily/stdlib.h> | #include <schily/stdlib.h> | |||
#include <schily/unistd.h> | #include <schily/unistd.h> | |||
#include <schily/utypes.h> | #include <schily/utypes.h> | |||
#include <schily/fcntl.h> | #include <schily/fcntl.h> | |||
#include <schily/string.h> | #include <schily/string.h> | |||
#include <signal.h> | #include <signal.h> | |||
#define GT_COMERR /* #define comerr gtcomerr */ | ||||
#define GT_ERROR /* #define error gterror */ | ||||
#include <schily/schily.h> | #include <schily/schily.h> | |||
#include <schily/errno.h> | #include <schily/errno.h> | |||
#include <schily/md4.h> | #include <schily/md4.h> | |||
#include <schily/md5.h> | #include <schily/md5.h> | |||
#include <schily/rmd160.h> | #include <schily/rmd160.h> | |||
#include <schily/sha1.h> | #include <schily/sha1.h> | |||
#include <schily/sha2.h> | #include <schily/sha2.h> | |||
#include <schily/sha3.h> | #include <schily/sha3.h> | |||
#include <schily/nlsdefs.h> | ||||
typedef union uctx { | typedef union uctx { | |||
MD4_CTX ctx_md4; | MD4_CTX ctx_md4; | |||
MD5_CTX ctx_md6; | MD5_CTX ctx_md6; | |||
RMD160_CTX ctx_rmd160; | RMD160_CTX ctx_rmd160; | |||
SHA1_CTX ctx_sha1; | SHA1_CTX ctx_sha1; | |||
SHA2_CTX ctx_sha2; | SHA2_CTX ctx_sha2; | |||
#ifdef sha3_224_hash_size | #ifdef sha3_224_hash_size | |||
SHA3_CTX ctx_sha3; | SHA3_CTX ctx_sha3; | |||
#endif | #endif | |||
skipping to change at line 121 | skipping to change at line 124 | |||
LOCAL void | LOCAL void | |||
usage(exitcode) | usage(exitcode) | |||
int exitcode; | int exitcode; | |||
{ | { | |||
error("Usage: mdigest [options] [file1...filen]\n"); | error("Usage: mdigest [options] [file1...filen]\n"); | |||
error("Options:\n"); | error("Options:\n"); | |||
error("\t-help\t\tprint this online help\n"); | error("\t-help\t\tprint this online help\n"); | |||
error("\t-version\tprint version number\n"); | error("\t-version\tprint version number\n"); | |||
error("\t-verbose,-v\tprint more verbose output\n"); | error("\t-verbose,-v\tprint more verbose output\n"); | |||
error("\t-a alrorithm\tspecify digest algorithm\n"); | error("\t-a algorithm\tspecify digest algorithm\n"); | |||
error("\t-l\t\tprint a list of supported algorithms\n"); | error("\t-l\t\tprint a list of supported algorithms\n"); | |||
exit(exitcode); | exit(exitcode); | |||
} | } | |||
EXPORT int | EXPORT int | |||
main(ac, av) | main(ac, av) | |||
int ac; | int ac; | |||
char *av[]; | char *av[]; | |||
{ | { | |||
int cac; | int cac; | |||
char *const *cav; | char *const *cav; | |||
BOOL help = FALSE; | BOOL help = FALSE; | |||
BOOL prvers = FALSE; | BOOL prvers = FALSE; | |||
BOOL list = FALSE; | BOOL list = FALSE; | |||
char *alg = NULL; | char *alg = NULL; | |||
char *buf; | char *buf; | |||
FILE *f; | FILE *f; | |||
struct adigest *dp = dlist; | struct adigest *dp = dlist; | |||
save_args(ac, av); | save_args(ac, av); | |||
(void) setlocale(LC_ALL, ""); | ||||
#ifdef USE_NLS | ||||
#if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */ | ||||
#define TEXT_DOMAIN "mdigest" /* Use this only if it weren't */ | ||||
#endif | ||||
{ char *dir; | ||||
dir = searchfileinpath("share/locale", F_OK, | ||||
SIP_ANY_FILE|SIP_NO_PATH, NULL); | ||||
if (dir) | ||||
(void) bindtextdomain(TEXT_DOMAIN, dir); | ||||
else | ||||
#if defined(PROTOTYPES) && defined(INS_BASE) | ||||
(void) bindtextdomain(TEXT_DOMAIN, INS_BASE "/share/locale"); | ||||
#else | ||||
(void) bindtextdomain(TEXT_DOMAIN, "/usr/share/locale"); | ||||
#endif | ||||
(void) textdomain(TEXT_DOMAIN); | ||||
} | ||||
#endif /* USE_NLS */ | ||||
cac = --ac; | cac = --ac; | |||
cav = ++av; | cav = ++av; | |||
if (getallargs(&cac, &cav, options, &help, &prvers, | if (getallargs(&cac, &cav, options, &help, &prvers, | |||
&verbose, &verbose, | &verbose, &verbose, | |||
&list, &alg) < 0) { | &list, &alg) < 0) { | |||
errmsgno(EX_BAD, "Bad flag: %s.\n", cav[0]); | errmsgno(EX_BAD, "Bad flag: %s.\n", cav[0]); | |||
usage(EX_BAD); | usage(EX_BAD); | |||
} | } | |||
if (help) usage(0); | if (help) usage(0); | |||
if (prvers) { | if (prvers) { | |||
printf("mdigest %s (%s-%s-%s)\n\n", "1.6", HOST_CPU, HOST_VENDOR, | gtprintf("mdigest %s (%s-%s-%s)\n\n", "1.9", HOST_CPU, HOST_VENDO | |||
HOST_OS); | R, HOST_OS); | |||
printf("Copyright (C) 2009-2016 Jörg Schilling\n"); | gtprintf("Copyright (C) 2009-2021 %s\n", _("Jörg Schilling")); | |||
printf("This is free software; see the source for copying conditi | gtprintf("This is free software; see the source for copying condi | |||
ons. There is NO\n"); | tions. There is NO\n"); | |||
printf("warranty; not even for MERCHANTABILITY or FITNESS FOR A P | gtprintf("warranty; not even for MERCHANTABILITY or FITNESS FOR A | |||
ARTICULAR PURPOSE.\n"); | PARTICULAR PURPOSE.\n"); | |||
exit(0); | exit(0); | |||
} | } | |||
if (list) { | if (list) { | |||
for (; dp->name; dp++) { | for (; dp->name; dp++) { | |||
printf("%s\n", dp->name); | printf("%s\n", dp->name); | |||
} | } | |||
exit(0); | exit(0); | |||
} | } | |||
if (alg == NULL) | if (alg == NULL) | |||
usage(EX_BAD); | usage(EX_BAD); | |||
End of changes. 8 change blocks. | ||||
11 lines changed or deleted | 36 lines changed or added |