Gather up another utility.
[u/mdw/catacomb] / des-mktab.c
index ed03fbc..e41e372 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: des-mktab.c,v 1.2 1999/12/22 16:02:30 mdw Exp $
+ * $Id: des-mktab.c,v 1.5 2004/04/08 01:36:15 mdw Exp $
  *
  * Build combined S-P tables for DES
  *
  * MA 02111-1307, USA.
  */
 
-/*----- Revision history --------------------------------------------------* 
- *
- * $Log: des-mktab.c,v $
- * Revision 1.2  1999/12/22 16:02:30  mdw
- * Output the table with the correct new header guard names.
- *
- * Revision 1.1  1999/09/03 08:41:11  mdw
- * Initial import.
- *
- */
-
 /*----- Header files ------------------------------------------------------*/
 
 #include <stdarg.h>
@@ -51,7 +40,7 @@
 
 /* --- S boxes --- */
 
-static char s[8][4][16] = {
+static const char s[8][4][16] = {
 
   /* --- S1 --- */
 
@@ -133,7 +122,7 @@ static char p[32] = {
  *             unique.
  */
 
-static int unique(char *t, int base, int sz, const char *name, ...)
+static int unique(const char *t, int base, int sz, const char *name, ...)
 {
   char u[32];
   char nbuf[128];
@@ -256,11 +245,11 @@ int main(void)
   fputs("\
 /* -*-c-*-\n\
  *\n\
- * DES SP table [generated]\n\
+ * DES tables [generated]\n\
  */\n\
 \n\
-#ifndef CATACOMB_DES_SP_H\n\
-#define CATACOMB_DES_SP_H\n\
+#ifndef CATACOMB_DES_TAB_H\n\
+#define CATACOMB_DES_TAB_H\n\
 \n\
 #define DES_SP {                                                       \\\n\
 ", stdout);
@@ -286,6 +275,12 @@ int main(void)
 \n\
 #endif\n\
 ", stdout);
+
+  if (fclose(stdout)) {
+    fprintf(stderr, "error writing data\n");
+    exit(EXIT_FAILURE);
+  }
+
   return (0);
 }