help-gsasl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Patch for native Win32 Digitalmars C Compiler support


From: Simon Josefsson
Subject: Re: Patch for native Win32 Digitalmars C Compiler support
Date: Wed, 04 Jun 2008 12:50:56 +0200
User-agent: Gnus/5.110011 (No Gnus v0.11) Emacs/22.2 (gnu/linux)

Robert M. Münch <address@hidden> writes:

> Hi, in the attachment I submit a DIFF against current HEAD version
> that will make the code compile with the Digitalmars C compiler on
> Windows.
>
> There are some rough edges done by me to get it work. I'm sure you can
> make changes to the overall project setup in a more convenient
> way. This  rough steps are mostly necessar because of non-autoconf
> tool-chain on  Windows.

Many thanks for providing these!

> Comments:
> 1. I renamed gl/base64.c to gl/gl_base64.c
> Justification: It's not good practice to use the same filename for
> files with different content.

The files are in different directories...  these aren't the only files
that are named the same, every SASL mechanism have a file client.c,
server.c, and mechinfo.c.  I think your makefile should be able to cope
with, by building gl/base64.obj and lib/base64.obj separately.  Possibly
you'll have to move makefile.dmc from lib/src to lib/ to make this work
easily.

> 2. I attached the makefile for the library ONLY containing DIGEST-MD5
> support. Because that's what I need. Important are the DEFINES on the
> commandline to get it to work.
>
> 3. I'm using an empty fake "configure.h" file that's normally
> generated by the autoconf-tool chain but won't exists on native
> Windows. This should  somehow directly be covered in the source.

The config.h file contains some things which should probably stay there,
see comments below.

> I hope this helps the project. With the patches it's possible to build
> GSASL directly on windows without any Cygwin or MingW toolchain.

Thanks again.

> --- a/lib/digest-md5/client.c
> +++ b/lib/digest-md5/client.c
> @@ -43,6 +43,8 @@
>  
>  #define CNONCE_ENTROPY_BYTES 16
>  
> +int asprintf (char **resultp, const char *format, ...);

Doesn't DMC have or declare asprintf?  If not, I suggest this is
something should go into your config.h.

> diff --git a/lib/gl/gc-gnulib.c b/lib/gl/gc-gnulib.c
> index 10e4707..53e5129 100644
> --- a/lib/gl/gc-gnulib.c
> +++ b/lib/gl/gc-gnulib.c
> @@ -30,7 +30,9 @@
>  
>  /* For randomize. */
>  #ifdef GNULIB_GC_RANDOM
> +#ifndef __DMC__
>  # include <unistd.h>
> +#endif

Doesn't DMC have unistd.h?  Or why did you add that?

>  # include <sys/types.h>
>  # include <sys/stat.h>
>  # include <fcntl.h>
> @@ -115,13 +117,18 @@ gc_done (void)
>  
>  /* Randomness. */
>  
> -static Gc_rc
> -randomize (int level, char *data, size_t datalen)
> +#ifdef __DMC__
> +#define rndz gc_randomize
> +#else
> +#define rndz randomize
> +#endif

What error message did you get without doing that?  Does DMC have a
function or symbol called randomize?

> +
> +static Gc_rc rndz (int level, char *data, size_t datalen)
>  {
>  #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
>    if(!g_hProv)
>      return GC_RANDOM_ERROR;
> -  CryptGenRandom(g_hProv, (DWORD)datalen, data);
> +  CryptGenRandom(g_hProv, (DWORD)datalen, (unsigned char*)data);

This should probably be (PBYTE) instead of (unsigned char*).  Does that
work?

> diff --git a/lib/gl/vasnprintf.c b/lib/gl/vasnprintf.c
> index 4583f7d..13f13a9 100644
> --- a/lib/gl/vasnprintf.c
> +++ b/lib/gl/vasnprintf.c
> @@ -54,7 +54,7 @@
>  #ifndef VASNPRINTF
>  # include <config.h>
>  #endif
> -#ifndef IN_LIBINTL
> +#if !defined(IN_LIBINTL) && !defined(__DMC__)
>  # include <alloca.h>

Try removing -DHAVE_ALLOCA from your makefile, it should result in a
more reliable vasnprintf.  Did you get any errors when doing that?

> +#ifdef __DMC__
> +#include <stdint.h>  /* SIZE_MAX */
> +#endif

Try adding -DHAVE_STDINT_H=1 instead, stdint.h should be pulled in from
xsize.h.

> diff --git a/lib/gl/vasprintf.c b/lib/gl/vasprintf.c
> index c74dc76..97be9da 100644
> --- a/lib/gl/vasprintf.c
> +++ b/lib/gl/vasprintf.c
> @@ -30,6 +30,10 @@
>  
>  #include "vasnprintf.h"
>  
> +#ifdef __DMC__
> +#define EOVERFLOW E2BIG
> +#endif

This should go into your config.h.

> diff --git a/lib/src/gsasl.h b/lib/src/gsasl.h
> index 09eda11..e8a0a0f 100644
> --- a/lib/src/gsasl.h
> +++ b/lib/src/gsasl.h
> @@ -25,7 +25,15 @@
>  
>  # include <stdio.h>          /* FILE */
>  # include <stddef.h>         /* size_t */
> +
> +#ifdef __DMC__
> +typedef int          ssize_t;
> +#define PACKAGE "gsasl"
> +#define LOCALEDIR ""
> +#define PACKAGE_VERSION "0.2.26"
> +#else
>  # include <unistd.h>         /* ssize_t */
> +#endif

The PACKAGE, LOCALEDIR and PACKAGE_VERSION belong in config.h.  unistd.h
should pull in ssize_t, but maybe it doesn't exist in DMC... do you have
sys/types.h?  Maybe that contains ssize_t.

If you rewrite the makefile to avoid requiring the base64 renaming, I
can include it.  Please also update the patches, and add a config.h.dmc
with the DMC specific config.h stuff.

Thanks,
Simon




reply via email to

[Prev in Thread] Current Thread [Next in Thread]