From 6693d31057e69d8aed2edd0c4fc460959cd8c929 Mon Sep 17 00:00:00 2001 From: Thomas Roessler Date: Fri, 21 Jul 2000 07:32:09 +0000 Subject: [PATCH] Try to be smart about integer types. --- Makefile.am | 10 +++++++--- checktypes.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++ imap/md5.h | 7 +++++++ 3 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 checktypes.c diff --git a/Makefile.am b/Makefile.am index 72d9a9d8..8d87bae8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 index 00000000..43a197d7 --- /dev/null +++ b/checktypes.c @@ -0,0 +1,55 @@ +/* + * Copyright (C) 1999-2000 Thomas Roessler + * + * 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 + +#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 \n", stderr); + return 1; + } + + return 0; +} diff --git a/imap/md5.h b/imap/md5.h index a7465211..e0b70191 100644 --- a/imap/md5.h +++ b/imap/md5.h @@ -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) */ -- 2.40.0