A number of small bug fixes, some motivated by compiler warnings.
[u/mdw/catacomb] / cc.h
diff --git a/cc.h b/cc.h
index 24fc205..45e7eff 100644 (file)
--- a/cc.h
+++ b/cc.h
@@ -7,7 +7,7 @@
  * (c) 2004 Straylight/Edgeware
  */
 
-/*----- Licensing notice --------------------------------------------------* 
+/*----- Licensing notice --------------------------------------------------*
  *
  * This file is part of Catacomb.
  *
  * 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,
@@ -82,6 +82,7 @@ typedef struct sig {
   const struct sigops *ops;
   key_packdef *kp;
   void *kd;
+  const gchash *ch;
   ghash *h;
 } sig;
 
@@ -100,7 +101,7 @@ struct sigtab {
   const sigops *verifyops;
   const gchash *ch;
 };
-    
+
 extern const struct sigtab sigtab[];
 
 /* --- Data encoding --- */
@@ -114,7 +115,8 @@ typedef struct encops {
   const char *name;
   const char *rmode, *wmode;
   enc *(*initenc)(FILE */*fp*/, const char */*msg*/);
-  enc *(*initdec)(FILE */*fp*/, const char */*msg*/);
+  enc *(*initdec)(FILE */*fp*/,
+                 int (*/*func*/)(const char *, void *), void */*p*/);
   int (*read)(enc */*e*/, void */*p*/, size_t /*sz*/);
   int (*write)(enc */*e*/, const void */*p*/, size_t /*sz*/);
   int (*encdone)(enc */*e*/);
@@ -201,20 +203,45 @@ extern void freesig(sig */*s*/);
 
 extern const encops *getenc(const char */*enc*/);
 
+/* --- @checkbdry@ --- *
+ *
+ * Arguments:  @const char *b@ = boundary string found
+ *             @void *p@ = boundary string wanted
+ *
+ * Returns:    Nonzero if the boundary string is the one we wanted.
+ *
+ * Use:                Pass as @func@ to @initdec@ if you just want a simple life.
+ */
+
+extern int checkbdry(const char */*b*/, void */*p*/);
+
 /* --- @initenc@ --- *
  *
  * Arguments:  @const encops *eo@ = operations (from @getenc@)
  *             @FILE *fp@ = file handle to attach
  *             @const char *msg@ = banner message
- *             @int wantenc@ = nonzero if we want to encode
  *
  * Returns:    The encoder object.
  *
  * Use:                Initializes an encoder.
  */
 
-extern enc *initenc(const encops */*eo*/, FILE */*fp*/,
-                   const char */*msg*/, int /*wantenc*/);
+extern enc *initenc(const encops */*eo*/, FILE */*fp*/, const char */*msg*/);
+
+/* --- @initdec@ --- *
+ *
+ * Arguments:  @const encops *eo@ = operations (from @getenc@)
+ *             @FILE *fp@ = file handle to attach
+ *             @int (*func)(const char *, void *)@ = banner check function
+ *             @void *p@ = argument for @func@
+ *
+ * Returns:    The encoder object.
+ *
+ * Use:                Initializes an encoder.
+ */
+
+extern enc *initdec(const encops */*eo*/, FILE */*fp*/,
+                   int (*/*func*/)(const char *, void *), void */*p*/);
 
 /* --- @freeenc@ --- *
  *
@@ -227,6 +254,33 @@ extern enc *initenc(const encops */*eo*/, FILE */*fp*/,
 
 extern void freeenc(enc */*e*/);
 
+/* --- @cmd_encode@, @cmd_decode@ --- */
+
+#define CMD_ENCODE {                                                   \
+  "encode", cmd_encode,                                                        \
+    "encode [-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\
+" }
+
+#define CMD_DECODE {                                                   \
+  "decode", cmd_decode,                                                        \
+    "decode [-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\
+" }
+
+extern int cmd_encode(int /*argc*/, char */*argv*/[]);
+extern int cmd_decode(int /*argc*/, char */*argv*/[]);
+
 /* --- @LIST(STRING, FP, END-TEST, NAME-EXPR)@ --- *
  *
  * Produce list of things.  Requires @i@ and @w@ variables in scope.