X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/fa54fe1eda6977fc8aef0c154f8483e351e20bdd..cd6eca4375f46a35b93e2fea4b0428a23b451aa3:/cc.h diff --git a/cc.h b/cc.h index 5574e9e..6f92978 100644 --- a/cc.h +++ b/cc.h @@ -7,7 +7,7 @@ * (c) 2004 Straylight/Edgeware */ -/*----- Licensing notice --------------------------------------------------* +/*----- Licensing notice --------------------------------------------------* * * 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. - * + * * 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, @@ -36,8 +36,13 @@ /*----- Header files ------------------------------------------------------*/ +#if _FILE_OFFSET_BITS != 64 +# error "Must set _FILE_OFFSET_BITS to 64." +#endif + #include #include +#include #include @@ -48,6 +53,15 @@ /*----- Data structures ---------------------------------------------------*/ +/* --- Progress indicators --- */ + +typedef struct fprogress { + const char *bp; + off_t o, sz, olast; + time_t start, last; + char name[24]; +} fprogress; + /* --- Key encapsulation --- */ typedef struct kem { @@ -82,6 +96,7 @@ typedef struct sig { const struct sigops *ops; key_packdef *kp; void *kd; + const gchash *ch; ghash *h; } sig; @@ -100,7 +115,7 @@ struct sigtab { const sigops *verifyops; const gchash *ch; }; - + extern const struct sigtab sigtab[]; /* --- Data encoding --- */ @@ -113,6 +128,7 @@ typedef struct enc { typedef struct encops { const char *name; const char *rmode, *wmode; + int nraw, ncook; enc *(*initenc)(FILE */*fp*/, const char */*msg*/); enc *(*initdec)(FILE */*fp*/, int (*/*func*/)(const char *, void *), void */*p*/); @@ -257,24 +273,26 @@ extern void freeenc(enc */*e*/); #define CMD_ENCODE { \ "encode", cmd_encode, \ - "encode [-f FORMAT] [-b LABEL] [-o OUTPUT] [FILE]", \ + "encode [-p] [-f FORMAT] [-b LABEL] [-o OUTPUT] [FILE]", \ "\ Options:\n\ \n\ -f, --format=FORMAT Encode to FORMAT.\n\ -b, --boundary=LABEL PEM boundary is LABEL.\n\ -o, --output=FILE Write output to FILE.\n\ +-p, --progress Show progress on large files.\n\ " } #define CMD_DECODE { \ "decode", cmd_decode, \ - "decode [-f FORMAT] [-b LABEL] [-o OUTPUT] [FILE]", \ + "decode [-p] [-f FORMAT] [-b LABEL] [-o OUTPUT] [FILE]", \ "\ Options:\n\ \n\ -f, --format=FORMAT Decode from FORMAT.\n\ -b, --boundary=LABEL PEM boundary is LABEL.\n\ -o, --output=FILE Write output to FILE.\n\ +-p, --progress Show progress on large files.\n\ " } extern int cmd_encode(int /*argc*/, char */*argv*/[]); @@ -386,6 +404,58 @@ const cmd *findcmd(const cmd */*cmds*/, const char */*name*/); extern void sc_help(const cmd */*cmds*/, FILE */*fp*/, char *const */*argv*/); +/*----- Progress indicators -----------------------------------------------*/ + +/* --- @fprogress_init@ --- * + * + * Arguments: @fprogress *f@ = progress context to be initialized + * @const char *name@ = file name string to show + * @FILE *fp@ = file we're reading from + * + * Returns: Zero on success, nonzero if the file's state is now broken. + * + * Use: Initializes a progress context. Nothing is actually + * displayed yet. + */ + +extern int fprogress_init(fprogress */*f*/, + const char */*name*/, FILE */*fp*/); + +/* --- @fprogress_update@ --- * + * + * Arguments: @fprogress *f@ = progress context + * @size_t n@ = how much progress has been made + * + * Returns: --- + * + * Use: Maybe updates the display to show that some progress has been + * made. + */ + +extern void fprogress_update(fprogress */*f*/, size_t /*n*/); + +/* --- @fprogress_clear@ --- * + * + * Arguments: @fprogress *f@ = progress context + * + * Returns: --- + * + * Use: Clears the progress display from the screen. + */ + +extern void fprogress_clear(fprogress */*f*/); + +/* --- @fprogress_done@ --- * + * + * Arguments: @fprogress *f@ = progress context + * + * Returns: --- + * + * Use: Clear up the progress context and removes any display. + */ + +extern void fprogress_done(fprogress */*f*/); + /*----- That's all, folks -------------------------------------------------*/ #ifdef __cplusplus