projects
/
u
/
mdw
/
catacomb
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Catcrypt tools: Roll out progress indicator stuff from hashsum.
[u/mdw/catacomb]
/
dsig.c
diff --git
a/dsig.c
b/dsig.c
index
bcfe51d
..
d09b675
100644
(file)
--- a/
dsig.c
+++ b/
dsig.c
@@
-7,7
+7,7
@@
* (c) 2000 Straylight/Edgeware
*/
* (c) 2000 Straylight/Edgeware
*/
-/*----- Licensing notice --------------------------------------------------*
+/*----- Licensing notice --------------------------------------------------*
*
* This file is part of Catacomb.
*
*
* This file is part of Catacomb.
*
@@
-15,12
+15,12
@@
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
- *
+ *
* Catacomb 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 Library General Public License for more details.
* Catacomb 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 Library General Public License for more details.
- *
+ *
* You should have received a copy of the GNU Library General Public
* License along with Catacomb; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* You should have received a copy of the GNU Library General Public
* License along with Catacomb; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
@@
-29,6
+29,8
@@
/*----- Header files ------------------------------------------------------*/
/*----- Header files ------------------------------------------------------*/
+#define _FILE_OFFSET_BITS 64
+
#include "config.h"
#include <ctype.h>
#include "config.h"
#include <ctype.h>
@@
-585,7
+587,7
@@
static void bemit(block *b, FILE *fp, ghash *h, unsigned bin)
if (fp && !bin)
bwrite(b, fp);
}
if (fp && !bin)
bwrite(b, fp);
}
-
+
/*----- Static variables --------------------------------------------------*/
static const char *keyring = "keyring";
/*----- Static variables --------------------------------------------------*/
static const char *keyring = "keyring";
@@
-595,6
+597,7
@@
static const char *keyring = "keyring";
/* --- @fhash@ --- *
*
* Arguments: @const gchash *c@ = pointer to hash class
/* --- @fhash@ --- *
*
* Arguments: @const gchash *c@ = pointer to hash class
+ * @unsigned f@ = flags
* @const char *file@ = file to hash
* @void *b@ = pointer to output buffer
*
* @const char *file@ = file to hash
* @void *b@ = pointer to output buffer
*
@@
-603,9
+606,12
@@
static const char *keyring = "keyring";
* Use: Hashes a file.
*/
* Use: Hashes a file.
*/
-static int fhash(const gchash *c, const char *file, void *b)
+#define FHF_PROGRESS 256u
+
+static int fhash(const gchash *c, unsigned f, const char *file, void *b)
{
FILE *fp = fopen(file, "rb");
{
FILE *fp = fopen(file, "rb");
+ fprogress ff;
ghash *h = GH_INIT(c);
char buf[4096];
size_t sz;
ghash *h = GH_INIT(c);
char buf[4096];
size_t sz;
@@
-613,10
+619,16
@@
static int fhash(const gchash *c, const char *file, void *b)
if (!fp)
return (-1);
if (!fp)
return (-1);
- while ((sz = fread(buf, 1, sizeof(buf), fp)) > 0)
+ if (f & FHF_PROGRESS) {
+ if (fprogress_init(&ff, file, fp)) return (-1);
+ }
+ while ((sz = fread(buf, 1, sizeof(buf), fp)) > 0) {
GH_HASH(h, buf, sz);
GH_HASH(h, buf, sz);
+ if (f & FHF_PROGRESS) fprogress_update(&ff, sz);
+ }
if (ferror(fp))
rc = -1;
if (ferror(fp))
rc = -1;
+ if (f & FHF_PROGRESS) fprogress_done(&ff);
GH_DONE(h, b);
GH_DESTROY(h);
fclose(fp);
GH_DONE(h, b);
GH_DESTROY(h);
fclose(fp);
@@
-645,7
+657,7
@@
static void fhex(FILE *fp, const void *p, size_t sz)
if (!sz)
break;
}
if (!sz)
break;
}
-}
+}
/*----- Signature generation ----------------------------------------------*/
/*----- Signature generation ----------------------------------------------*/
@@
-677,6
+689,7
@@
static int sign(int argc, char *argv[])
{ "null", 0, 0, '0' },
{ "binary", 0, 0, 'b' },
{ "verbose", 0, 0, 'v' },
{ "null", 0, 0, '0' },
{ "binary", 0, 0, 'b' },
{ "verbose", 0, 0, 'v' },
+ { "progress", 0, 0, 'p' },
{ "quiet", 0, 0, 'q' },
{ "comment", OPTF_ARGREQ, 0, 'c' },
{ "file", OPTF_ARGREQ, 0, 'f' },
{ "quiet", 0, 0, 'q' },
{ "comment", OPTF_ARGREQ, 0, 'c' },
{ "file", OPTF_ARGREQ, 0, 'f' },
@@
-686,7
+699,7
@@
static int sign(int argc, char *argv[])
{ "nocheck", OPTF_ARGREQ, 0, 'C' },
{ 0, 0, 0, 0 }
};
{ "nocheck", OPTF_ARGREQ, 0, 'C' },
{ 0, 0, 0, 0 }
};
- int i = mdwopt(argc, argv, "+0vqbC" "c:" "f:o:" "k:e:", opts, 0, 0, 0);
+ int i = mdwopt(argc, argv, "+0v
p
qbC" "c:" "f:o:" "k:e:", opts, 0, 0, 0);
if (i < 0)
break;
switch (i) {
if (i < 0)
break;
switch (i) {
@@
-699,6
+712,9
@@
static int sign(int argc, char *argv[])
case 'v':
verb++;
break;
case 'v':
verb++;
break;
+ case 'p':
+ f |= FHF_PROGRESS;
+ break;
case 'q':
if (verb > 0)
verb--;
case 'q':
if (verb > 0)
verb--;
@@
-771,7
+787,7
@@
static int sign(int argc, char *argv[])
binit(&b); b.tag = T_IDENT;
dstr_putf(&b.d, "%s, Catacomb version " VERSION, QUIS);
bemit(&b, ofp, 0, f & f_bin);
binit(&b); b.tag = T_IDENT;
dstr_putf(&b.d, "%s, Catacomb version " VERSION, QUIS);
bemit(&b, ofp, 0, f & f_bin);
-
+
breset(&b); b.tag = T_KEYID; b.k = k->id;
bemit(&b, ofp, 0, f & f_bin);
breset(&b); b.tag = T_KEYID; b.k = k->id;
bemit(&b, ofp, 0, f & f_bin);
@@
-811,7
+827,7
@@
static int sign(int argc, char *argv[])
break;
b.tag = T_FILE;
DENSURE(&b.b, GH_CLASS(s->h)->hashsz);
break;
b.tag = T_FILE;
DENSURE(&b.b, GH_CLASS(s->h)->hashsz);
- if (fhash(GH_CLASS(s->h), b.d.buf, b.b.buf)) {
+ if (fhash(GH_CLASS(s->h),
f,
b.d.buf, b.b.buf)) {
moan("Error reading `%s': %s", b.d.buf, strerror(errno));
f |= f_bogus;
} else {
moan("Error reading `%s': %s", b.d.buf, strerror(errno));
f |= f_bogus;
} else {
@@
-897,17
+913,21
@@
static int verify(int argc, char *argv[])
for (;;) {
static struct option opts[] = {
{ "verbose", 0, 0, 'v' },
for (;;) {
static struct option opts[] = {
{ "verbose", 0, 0, 'v' },
+ { "progress", 0, 0, 'p' },
{ "quiet", 0, 0, 'q' },
{ "nocheck", 0, 0, 'C' },
{ 0, 0, 0, 0 }
};
{ "quiet", 0, 0, 'q' },
{ "nocheck", 0, 0, 'C' },
{ 0, 0, 0, 0 }
};
- int i = mdwopt(argc, argv, "+vqC", opts, 0, 0, 0);
+ int i = mdwopt(argc, argv, "+v
p
qC", opts, 0, 0, 0);
if (i < 0)
break;
switch (i) {
case 'v':
verb++;
break;
if (i < 0)
break;
switch (i) {
case 'v':
verb++;
break;
+ case 'p':
+ f |= FHF_PROGRESS;
+ break;
case 'q':
if (verb)
verb--;
case 'q':
if (verb)
verb--;
@@
-1025,7
+1045,7
@@
static int verify(int argc, char *argv[])
case T_FILE:
DRESET(&d);
DENSURE(&d, GH_CLASS(s->h)->hashsz);
case T_FILE:
DRESET(&d);
DENSURE(&d, GH_CLASS(s->h)->hashsz);
- if (fhash(GH_CLASS(s->h), b.d.buf, d.buf)) {
+ if (fhash(GH_CLASS(s->h),
f,
b.d.buf, d.buf)) {
if (verb > 1) {
printf("BAD error reading file `%s': %s\n",
b.d.buf, strerror(errno));
if (verb > 1) {
printf("BAD error reading file `%s': %s\n",
b.d.buf, strerror(errno));
@@
-1109,7
+1129,7
@@
static cmd cmdtab[] = {
{ "help", cmd_help, "help [COMMAND...]" },
{ "show", cmd_show, "show [ITEM...]" },
{ "sign", sign,
{ "help", cmd_help, "help [COMMAND...]" },
{ "show", cmd_show, "show [ITEM...]" },
{ "sign", sign,
- "sign [-0bqvC] [-c COMMENT] [-k TAG] [-e EXPIRE]\n\t\
+ "sign [-0b
p
qvC] [-c COMMENT] [-k TAG] [-e EXPIRE]\n\t\
[-f FILE] [-o OUTPUT]",
"\
Options:\n\
[-f FILE] [-o OUTPUT]",
"\
Options:\n\
@@
-1118,6
+1138,7
@@
Options:\n\
-b, --binary Produce a binary output file.\n\
-q, --quiet Produce fewer messages while working.\n\
-v, --verbose Produce more messages while working.\n\
-b, --binary Produce a binary output file.\n\
-q, --quiet Produce fewer messages while working.\n\
-v, --verbose Produce more messages while working.\n\
+-p, --progress Show progress on large files.\n\
-C, --nocheck Don't check the private key.\n\
-c, --comment=COMMENT Include COMMENT in the output file.\n\
-f, --file=FILE Read filenames to hash from FILE.\n\
-C, --nocheck Don't check the private key.\n\
-c, --comment=COMMENT Include COMMENT in the output file.\n\
-f, --file=FILE Read filenames to hash from FILE.\n\
@@
-1126,11
+1147,12
@@
Options:\n\
-e, --expire=TIME The signature should expire after TIME.\n\
" },
{ "verify", verify,
-e, --expire=TIME The signature should expire after TIME.\n\
" },
{ "verify", verify,
- "verify [-qvC] [FILE]", "\
+ "verify [-
p
qvC] [FILE]", "\
Options:\n\
\n\
-q, --quiet Produce fewer messages while working.\n\
-v, --verbose Produce more messages while working.\n\
Options:\n\
\n\
-q, --quiet Produce fewer messages while working.\n\
-v, --verbose Produce more messages while working.\n\
+-p, --progress Show progress on large files.\n\
-C, --nocheck Don't check the public key.\n\
" },
{ 0, 0, 0 }
-C, --nocheck Don't check the public key.\n\
" },
{ 0, 0, 0 }