Add compatibility for building with DJGPP under DOS. (Christophe

Grenier, slightly modified by me)

(Logical change 1.247)
edge.strict_endians
cantab.net!aia21 2004-01-06 11:04:29 +00:00
parent 388a10109f
commit 1226d98038
8 changed files with 63 additions and 14 deletions

View File

@ -11,6 +11,7 @@ Anton Altaparmakov <aia21@cantab.net>
Albert D. Cahalan <acahalan@cs.uml.edu>
Russ Christensen <rchriste@cs.utah.edu>
Matthew J. Fanto <fanto1mj@cmich.edu>
Christophe Grenier <grenier@cgsecurity.org>
Ian Jackson <ian@davenant.greenend.org.uk>
Jan Kratochvil <project-captive@jankratochvil.net>
Lode Leroy <lode.leroy@barco.com>

View File

@ -3,6 +3,8 @@
- Add new API function runlist.[hc]:ntfs_rl_pread().
- Fix bug in run list encoding functions that hit sparse and compressed
files with holes. (Szabolcs Szakacsits)
- Add compatibility for building with DJGPP under DOS. (Christophe
Grenier, slightly modified by me)
19/11/2003 - 1.8.0 - Final fixes and tidy ups.
- Cleanup build system wrt CFLAGS handling placing it all in one place

View File

@ -1,17 +1,20 @@
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the <asm/byteorder.h> header file. */
#undef HAVE_ASM_BYTEORDER_H
/* Define to 1 if you have the `atexit' function. */
#undef HAVE_ATEXIT
/* Define to 1 if you have the <byteswap.h> header file. */
#undef HAVE_BYTESWAP_H
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
#undef HAVE_DOPRNT
/* Define to 1 if you have the <endian.h> header file. */
#undef HAVE_ENDIAN_H
/* Define to 1 if you have the <errno.h> header file. */
#undef HAVE_ERRNO_H
@ -59,6 +62,9 @@
/* Define to 1 if mbrtowc and mbstate_t are properly declared. */
#undef HAVE_MBRTOWC
/* Define to 1 if you have the `mbsinit' function. */
#undef HAVE_MBSINIT
/* Define to 1 if you have the `memmove' function. */
#undef HAVE_MEMMOVE

8
configure vendored
View File

@ -8460,12 +8460,13 @@ fi
for ac_header in fcntl.h libintl.h limits.h locale.h mntent.h stddef.h \
stdint.h stdlib.h stdio.h stdarg.h string.h strings.h errno.h time.h \
sys/ioctl.h sys/mount.h unistd.h utime.h wchar.h getopt.h sys/stat.h \
sys/types.h asm/byteorder.h linux/major.h linux/fd.h
endian.h byteswap.h sys/ioctl.h sys/mount.h unistd.h utime.h wchar.h \
getopt.h sys/stat.h sys/types.h linux/major.h linux/fd.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if eval "test \"\${$as_ac_Header+set}\" = set"; then
@ -10671,8 +10672,9 @@ done
for ac_func in atexit fdatasync hasmntopt memmove memset regcomp setlocale \
strcasecmp strchr strdup strerror strtol strtoul utime
strcasecmp strchr strdup strerror strtol strtoul utime mbsinit
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5

View File

@ -167,8 +167,8 @@ AC_SUBST(AUTODIRS)
AC_HEADER_STDC
AC_CHECK_HEADERS([fcntl.h libintl.h limits.h locale.h mntent.h stddef.h \
stdint.h stdlib.h stdio.h stdarg.h string.h strings.h errno.h time.h \
sys/ioctl.h sys/mount.h unistd.h utime.h wchar.h getopt.h sys/stat.h \
sys/types.h asm/byteorder.h linux/major.h linux/fd.h])
endian.h byteswap.h sys/ioctl.h sys/mount.h unistd.h utime.h wchar.h \
getopt.h sys/stat.h sys/types.h linux/major.h linux/fd.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
@ -192,7 +192,7 @@ AC_FUNC_STRFTIME
AC_FUNC_UTIME_NULL
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([atexit fdatasync hasmntopt memmove memset regcomp setlocale \
strcasecmp strchr strdup strerror strtol strtoul utime])
strcasecmp strchr strdup strerror strtol strtoul utime mbsinit])
# Makefiles to be created by configure.
AC_CONFIG_FILES([

View File

@ -33,8 +33,12 @@
* architectures requiring aligned memory accesses...
*/
#include <endian.h>
#include <byteswap.h>
#ifdef HAVE_ENDIAN_H
# include <endian.h>
#endif
#ifdef HAVE_BYTESWAP_H
# include <byteswap.h>
#endif
#if (__BYTE_ORDER == __LITTLE_ENDIAN)

View File

@ -25,13 +25,15 @@
#include "config.h"
#include <stdio.h>
#include <sys/mount.h>
#ifdef HAVE_SYS_MOUNT_H
# include <sys/mount.h>
#endif
#ifdef HAVE_MNTENT_H
# include <mntent.h>
#endif
/* Cygwin doesn't seem to have MS_RDONLY, so we define it here. */
#if defined(__CYGWIN32__) && !defined(MS_RDONLY)
/* Both under Cygwin and DJGPP we do not have MS_RDONLY, so we define it. */
#if !defined(MS_RDONLY)
typedef enum {
MS_RDONLY = 1,
} MS_MOUNT;

View File

@ -321,7 +321,9 @@ int ntfs_ucstombs(const uchar_t *ins, const int ins_len, char **outs,
wchar_t wc;
int i, o, mbs_len;
int cnt = 0;
#ifdef HAVE_MBSINIT
mbstate_t mbstate;
#endif
if (!ins || !outs) {
errno = EINVAL;
@ -339,7 +341,11 @@ int ntfs_ucstombs(const uchar_t *ins, const int ins_len, char **outs,
if (!mbs)
return -1;
}
#ifdef HAVE_MBSINIT
memset(&mbstate, 0, sizeof(mbstate));
#else
wctomb(NULL, 0);
#endif
for (i = o = 0; i < ins_len; i++) {
/* Reallocate memory if necessary or abort. */
if ((int)(o + MB_CUR_MAX) > mbs_len) {
@ -361,7 +367,11 @@ int ntfs_ucstombs(const uchar_t *ins, const int ins_len, char **outs,
if (!wc)
break;
/* Convert the CPU endian wide character to multibyte. */
#ifdef HAVE_MBSINIT
cnt = wcrtomb(mbs + o, wc, &mbstate);
#else
cnt = wctomb(mbs + o, wc);
#endif
if (cnt == -1)
goto err_out;
if (cnt <= 0) {
@ -371,12 +381,14 @@ int ntfs_ucstombs(const uchar_t *ins, const int ins_len, char **outs,
}
o += cnt;
}
#ifdef HAVE_MBSINIT
/* Make sure we are back in the initial state. */
if (!mbsinit(&mbstate)) {
Dputs("Eeek. mbstate not in initial state!");
errno = EILSEQ;
goto err_out;
}
#endif
/* Now write the NULL character. */
mbs[o] = '\0';
if (*outs != mbs)
@ -421,7 +433,9 @@ int ntfs_mbstoucs(char *ins, uchar_t **outs, int outs_len)
char *s;
wchar_t wc;
int i, o, cnt, ins_len, ucs_len;
#ifdef HAVE_MBSINIT
mbstate_t mbstate;
#endif
if (!ins || !outs) {
errno = EINVAL;
@ -435,11 +449,19 @@ int ntfs_mbstoucs(char *ins, uchar_t **outs, int outs_len)
}
/* Determine the length of the multi-byte string. */
s = ins;
#ifdef HAVE_MBSINIT
memset(&mbstate, 0, sizeof(mbstate));
ins_len = mbsrtowcs(NULL, (const char **)&s, 0, &mbstate);
#else
ins_len = mbstowcs(NULL, s, 0);
#endif
if (ins_len == -1)
return ins_len;
#ifdef HAVE_MBSINIT
if ((s != ins) || !mbsinit(&mbstate)) {
#else
if (s != ins) {
#endif
errno = EILSEQ;
return -1;
}
@ -451,7 +473,11 @@ int ntfs_mbstoucs(char *ins, uchar_t **outs, int outs_len)
if (!ucs)
return -1;
}
#ifdef HAVE_MBSINIT
memset(&mbstate, 0, sizeof(mbstate));
#else
mbtowc(NULL, NULL, 0);
#endif
for (i = o = cnt = 0; o < ins_len; i += cnt, o++) {
/* Reallocate memory if necessary or abort. */
if (o >= ucs_len) {
@ -472,7 +498,11 @@ int ntfs_mbstoucs(char *ins, uchar_t **outs, int outs_len)
ucs_len /= sizeof(uchar_t);
}
/* Convert the multibyte character to a wide character. */
#ifdef HAVE_MBSINIT
cnt = mbrtowc(&wc, ins + i, ins_len - i, &mbstate);
#else
cnt = mbtowc(&wc, ins + i, ins_len - i);
#endif
if (!cnt)
break;
if (cnt == -1)
@ -491,6 +521,7 @@ int ntfs_mbstoucs(char *ins, uchar_t **outs, int outs_len)
/* Convert the CPU wide character to a LE Unicode character. */
ucs[o] = cpu_to_le16(wc);
}
#ifdef HAVE_MBSINIT
/* Make sure we are back in the initial state. */
if (!mbsinit(&mbstate)) {
Dprintf("%s(): Eeek. mbstate not in initial state!\n",
@ -498,6 +529,7 @@ int ntfs_mbstoucs(char *ins, uchar_t **outs, int outs_len)
errno = EILSEQ;
goto err_out;
}
#endif
/* Now write the NULL character. */
ucs[o] = cpu_to_le16(L'\0');
if (*outs != ucs)