]> granicus.if.org Git - mutt/commitdiff
Try to be smart about integer types.
authorThomas Roessler <roessler@does-not-exist.org>
Fri, 21 Jul 2000 07:32:09 +0000 (07:32 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Fri, 21 Jul 2000 07:32:09 +0000 (07:32 +0000)
Makefile.am
checktypes.c [new file with mode: 0644]
imap/md5.h

index 72d9a9d8b195bfefe897da16a6226979340d83e0..8d87bae81a148d9eb3a1475f30c62208ad05067c 100644 (file)
@@ -2,7 +2,7 @@
 ## Use aclocal -I m4; automake --foreign
 
 AUTOMAKE_OPTIONS = foreign
-EXTRA_PROGRAMS = mutt_dotlock pgpring makedoc
+EXTRA_PROGRAMS = mutt_dotlock pgpring makedoc checktypes
 
 if BUILD_IMAP
 IMAP_SUBDIR = imap
@@ -17,7 +17,7 @@ else
 bin_SCRIPTS = muttbug
 endif
 
-BUILT_SOURCES = keymap_defs.h
+BUILT_SOURCES = keymap_defs.h types.h
 
 bin_PROGRAMS = mutt @DOTLOCK_TARGET@ @PGPAUX_TARGET@
 mutt_SOURCES = $(BUILT_SOURCES) \
@@ -39,6 +39,7 @@ mutt_DEPENDENCIES = @MUTT_LIB_OBJECTS@ @LIBOBJS@ $(LIBIMAPDEPS) \
        $(INTLDEPS)
 
 makedoc_SOURCES = makedoc.c
+checktypes_SOURCES = checktypes.c
 
 CPP=@CPP@
 
@@ -69,7 +70,7 @@ EXTRA_DIST = COPYRIGHT GPL OPS OPS.PGP TODO configure acconfig.h account.h \
        sort.h mime.types VERSION prepare _regex.h OPS.MIX      \
        README.SECURITY remailer.c remailer.h browser.h \
        mbyte.h lib.h extlib.c pgpewrap pgplib.h Muttrc.head Muttrc \
-       makedoc.c stamp-doc-rc README.SSL README.UPGRADE
+       makedoc.c stamp-doc-rc README.SSL README.UPGRADE checktypes.c
 
 mutt_dotlock_SOURCES = mutt_dotlock.c
 mutt_dotlock_LDADD = @LIBOBJS@
@@ -97,6 +98,9 @@ muttbug: muttbug.sh
 
 Makefile: $(BUILT_SOURCES)
 
+types.h: checktypes
+       ./checktypes > types.h
+
 keymap_defs.h: $(OPS) $(srcdir)/gen_defs
        $(srcdir)/gen_defs $(OPS) > keymap_defs.h
 
diff --git a/checktypes.c b/checktypes.c
new file mode 100644 (file)
index 0000000..43a197d
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 1999-2000 Thomas Roessler <roessler@guug.de>
+ * 
+ *     This program is free software; you can redistribute it and/or modify
+ *     it under the terms of the GNU General Public License as published by
+ *     the Free Software Foundation; either version 2 of the License, or
+ *     (at your option) any later version.
+ * 
+ *     This program 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 General Public License for more details.
+ * 
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program; if not, write to the Free Software
+ *     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ */ 
+
+/* Check various types for their respective length */
+
+#include <stdio.h>
+
+#define CHECK_TYPE(a,b)                                        \
+       if (!have_UINT##a && (sizeof (b) == a))         \
+       {                                               \
+         have_UINT##a = 1;                             \
+         puts (" #define UINT" #a " " #b);             \
+       }
+
+int main (int argc, char *argv[])
+{
+  short have_UINT2 = 0;
+  short have_UINT4 = 0;
+  
+  puts ("/* This is a generated file.  Don't edit! */");
+  puts ("#ifndef _TYPES_H");
+  puts (" #define _TYPES_H");
+
+  CHECK_TYPE (2, unsigned short int)
+  CHECK_TYPE (2, unsigned int)
+  CHECK_TYPE (4, unsigned short int)
+  CHECK_TYPE (4, unsigned int)
+  CHECK_TYPE (4, unsigned long int)
+  
+  puts ("#endif");
+  
+  if (!have_UINT2 || !have_UINT4)
+  {
+    fputs ("Can't determine integer types.  Please edit " __FILE__ ",\n", stderr);
+    fputs ("and submit a patch to <mutt-dev@mutt.org>\n", stderr);
+    return 1;
+  }
+  
+  return 0;
+}
index a74652119b71ba6671aa4bb41b540dce1d3f3708..e0b70191476643cb20b7eb6be3a938cf725f87ba 100644 (file)
@@ -26,15 +26,22 @@ documentation and/or software.
 #ifndef MD5_H
 #define MD5_H 1
 
+
 /* POINTER defines a generic pointer type */
 typedef unsigned char *POINTER;
 
+#include "types.h"
+
+#if 0
+
 /* UINT2 defines a two byte word */
 typedef unsigned short int UINT2;
 
 /* UINT4 defines a four byte word */
 typedef unsigned long int UINT4;
 
+#endif
+
 /* MD5 context. */
 typedef struct {
   UINT4 state[4];                                   /* state (ABCD) */