Add compatibility for building with DJGPP under DOS. (Christophe
Grenier, slightly modified by me) (Logical change 1.247)edge.strict_endians
parent
388a10109f
commit
1226d98038
1
CREDITS
1
CREDITS
|
|
@ -11,6 +11,7 @@ Anton Altaparmakov <aia21@cantab.net>
|
||||||
Albert D. Cahalan <acahalan@cs.uml.edu>
|
Albert D. Cahalan <acahalan@cs.uml.edu>
|
||||||
Russ Christensen <rchriste@cs.utah.edu>
|
Russ Christensen <rchriste@cs.utah.edu>
|
||||||
Matthew J. Fanto <fanto1mj@cmich.edu>
|
Matthew J. Fanto <fanto1mj@cmich.edu>
|
||||||
|
Christophe Grenier <grenier@cgsecurity.org>
|
||||||
Ian Jackson <ian@davenant.greenend.org.uk>
|
Ian Jackson <ian@davenant.greenend.org.uk>
|
||||||
Jan Kratochvil <project-captive@jankratochvil.net>
|
Jan Kratochvil <project-captive@jankratochvil.net>
|
||||||
Lode Leroy <lode.leroy@barco.com>
|
Lode Leroy <lode.leroy@barco.com>
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@
|
||||||
- Add new API function runlist.[hc]:ntfs_rl_pread().
|
- Add new API function runlist.[hc]:ntfs_rl_pread().
|
||||||
- Fix bug in run list encoding functions that hit sparse and compressed
|
- Fix bug in run list encoding functions that hit sparse and compressed
|
||||||
files with holes. (Szabolcs Szakacsits)
|
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.
|
19/11/2003 - 1.8.0 - Final fixes and tidy ups.
|
||||||
- Cleanup build system wrt CFLAGS handling placing it all in one place
|
- Cleanup build system wrt CFLAGS handling placing it all in one place
|
||||||
|
|
|
||||||
12
config.h.in
12
config.h.in
|
|
@ -1,17 +1,20 @@
|
||||||
/* config.h.in. Generated from configure.ac by autoheader. */
|
/* 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. */
|
/* Define to 1 if you have the `atexit' function. */
|
||||||
#undef HAVE_ATEXIT
|
#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. */
|
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||||
#undef HAVE_DLFCN_H
|
#undef HAVE_DLFCN_H
|
||||||
|
|
||||||
/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
|
/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
|
||||||
#undef 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. */
|
/* Define to 1 if you have the <errno.h> header file. */
|
||||||
#undef HAVE_ERRNO_H
|
#undef HAVE_ERRNO_H
|
||||||
|
|
||||||
|
|
@ -59,6 +62,9 @@
|
||||||
/* Define to 1 if mbrtowc and mbstate_t are properly declared. */
|
/* Define to 1 if mbrtowc and mbstate_t are properly declared. */
|
||||||
#undef HAVE_MBRTOWC
|
#undef HAVE_MBRTOWC
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `mbsinit' function. */
|
||||||
|
#undef HAVE_MBSINIT
|
||||||
|
|
||||||
/* Define to 1 if you have the `memmove' function. */
|
/* Define to 1 if you have the `memmove' function. */
|
||||||
#undef HAVE_MEMMOVE
|
#undef HAVE_MEMMOVE
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8460,12 +8460,13 @@ fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for ac_header in fcntl.h libintl.h limits.h locale.h mntent.h stddef.h \
|
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 \
|
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 \
|
endian.h byteswap.h sys/ioctl.h sys/mount.h unistd.h utime.h wchar.h \
|
||||||
sys/types.h asm/byteorder.h linux/major.h linux/fd.h
|
getopt.h sys/stat.h sys/types.h linux/major.h linux/fd.h
|
||||||
do
|
do
|
||||||
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
|
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
|
||||||
if eval "test \"\${$as_ac_Header+set}\" = set"; then
|
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 \
|
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
|
do
|
||||||
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
||||||
echo "$as_me:$LINENO: checking for $ac_func" >&5
|
echo "$as_me:$LINENO: checking for $ac_func" >&5
|
||||||
|
|
|
||||||
|
|
@ -167,8 +167,8 @@ AC_SUBST(AUTODIRS)
|
||||||
AC_HEADER_STDC
|
AC_HEADER_STDC
|
||||||
AC_CHECK_HEADERS([fcntl.h libintl.h limits.h locale.h mntent.h stddef.h \
|
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 \
|
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 \
|
endian.h byteswap.h sys/ioctl.h sys/mount.h unistd.h utime.h wchar.h \
|
||||||
sys/types.h asm/byteorder.h linux/major.h linux/fd.h])
|
getopt.h sys/stat.h sys/types.h linux/major.h linux/fd.h])
|
||||||
|
|
||||||
# Checks for typedefs, structures, and compiler characteristics.
|
# Checks for typedefs, structures, and compiler characteristics.
|
||||||
AC_HEADER_STDBOOL
|
AC_HEADER_STDBOOL
|
||||||
|
|
@ -192,7 +192,7 @@ AC_FUNC_STRFTIME
|
||||||
AC_FUNC_UTIME_NULL
|
AC_FUNC_UTIME_NULL
|
||||||
AC_FUNC_VPRINTF
|
AC_FUNC_VPRINTF
|
||||||
AC_CHECK_FUNCS([atexit fdatasync hasmntopt memmove memset regcomp setlocale \
|
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.
|
# Makefiles to be created by configure.
|
||||||
AC_CONFIG_FILES([
|
AC_CONFIG_FILES([
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,12 @@
|
||||||
* architectures requiring aligned memory accesses...
|
* architectures requiring aligned memory accesses...
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <endian.h>
|
#ifdef HAVE_ENDIAN_H
|
||||||
#include <byteswap.h>
|
# include <endian.h>
|
||||||
|
#endif
|
||||||
|
#ifdef HAVE_BYTESWAP_H
|
||||||
|
# include <byteswap.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#if (__BYTE_ORDER == __LITTLE_ENDIAN)
|
#if (__BYTE_ORDER == __LITTLE_ENDIAN)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,13 +25,15 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/mount.h>
|
#ifdef HAVE_SYS_MOUNT_H
|
||||||
|
# include <sys/mount.h>
|
||||||
|
#endif
|
||||||
#ifdef HAVE_MNTENT_H
|
#ifdef HAVE_MNTENT_H
|
||||||
# include <mntent.h>
|
# include <mntent.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Cygwin doesn't seem to have MS_RDONLY, so we define it here. */
|
/* Both under Cygwin and DJGPP we do not have MS_RDONLY, so we define it. */
|
||||||
#if defined(__CYGWIN32__) && !defined(MS_RDONLY)
|
#if !defined(MS_RDONLY)
|
||||||
typedef enum {
|
typedef enum {
|
||||||
MS_RDONLY = 1,
|
MS_RDONLY = 1,
|
||||||
} MS_MOUNT;
|
} MS_MOUNT;
|
||||||
|
|
|
||||||
|
|
@ -321,7 +321,9 @@ int ntfs_ucstombs(const uchar_t *ins, const int ins_len, char **outs,
|
||||||
wchar_t wc;
|
wchar_t wc;
|
||||||
int i, o, mbs_len;
|
int i, o, mbs_len;
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
|
#ifdef HAVE_MBSINIT
|
||||||
mbstate_t mbstate;
|
mbstate_t mbstate;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!ins || !outs) {
|
if (!ins || !outs) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
|
|
@ -339,7 +341,11 @@ int ntfs_ucstombs(const uchar_t *ins, const int ins_len, char **outs,
|
||||||
if (!mbs)
|
if (!mbs)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_MBSINIT
|
||||||
memset(&mbstate, 0, sizeof(mbstate));
|
memset(&mbstate, 0, sizeof(mbstate));
|
||||||
|
#else
|
||||||
|
wctomb(NULL, 0);
|
||||||
|
#endif
|
||||||
for (i = o = 0; i < ins_len; i++) {
|
for (i = o = 0; i < ins_len; i++) {
|
||||||
/* Reallocate memory if necessary or abort. */
|
/* Reallocate memory if necessary or abort. */
|
||||||
if ((int)(o + MB_CUR_MAX) > mbs_len) {
|
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)
|
if (!wc)
|
||||||
break;
|
break;
|
||||||
/* Convert the CPU endian wide character to multibyte. */
|
/* Convert the CPU endian wide character to multibyte. */
|
||||||
|
#ifdef HAVE_MBSINIT
|
||||||
cnt = wcrtomb(mbs + o, wc, &mbstate);
|
cnt = wcrtomb(mbs + o, wc, &mbstate);
|
||||||
|
#else
|
||||||
|
cnt = wctomb(mbs + o, wc);
|
||||||
|
#endif
|
||||||
if (cnt == -1)
|
if (cnt == -1)
|
||||||
goto err_out;
|
goto err_out;
|
||||||
if (cnt <= 0) {
|
if (cnt <= 0) {
|
||||||
|
|
@ -371,12 +381,14 @@ int ntfs_ucstombs(const uchar_t *ins, const int ins_len, char **outs,
|
||||||
}
|
}
|
||||||
o += cnt;
|
o += cnt;
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_MBSINIT
|
||||||
/* Make sure we are back in the initial state. */
|
/* Make sure we are back in the initial state. */
|
||||||
if (!mbsinit(&mbstate)) {
|
if (!mbsinit(&mbstate)) {
|
||||||
Dputs("Eeek. mbstate not in initial state!");
|
Dputs("Eeek. mbstate not in initial state!");
|
||||||
errno = EILSEQ;
|
errno = EILSEQ;
|
||||||
goto err_out;
|
goto err_out;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
/* Now write the NULL character. */
|
/* Now write the NULL character. */
|
||||||
mbs[o] = '\0';
|
mbs[o] = '\0';
|
||||||
if (*outs != mbs)
|
if (*outs != mbs)
|
||||||
|
|
@ -421,7 +433,9 @@ int ntfs_mbstoucs(char *ins, uchar_t **outs, int outs_len)
|
||||||
char *s;
|
char *s;
|
||||||
wchar_t wc;
|
wchar_t wc;
|
||||||
int i, o, cnt, ins_len, ucs_len;
|
int i, o, cnt, ins_len, ucs_len;
|
||||||
|
#ifdef HAVE_MBSINIT
|
||||||
mbstate_t mbstate;
|
mbstate_t mbstate;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!ins || !outs) {
|
if (!ins || !outs) {
|
||||||
errno = EINVAL;
|
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. */
|
/* Determine the length of the multi-byte string. */
|
||||||
s = ins;
|
s = ins;
|
||||||
|
#ifdef HAVE_MBSINIT
|
||||||
memset(&mbstate, 0, sizeof(mbstate));
|
memset(&mbstate, 0, sizeof(mbstate));
|
||||||
ins_len = mbsrtowcs(NULL, (const char **)&s, 0, &mbstate);
|
ins_len = mbsrtowcs(NULL, (const char **)&s, 0, &mbstate);
|
||||||
|
#else
|
||||||
|
ins_len = mbstowcs(NULL, s, 0);
|
||||||
|
#endif
|
||||||
if (ins_len == -1)
|
if (ins_len == -1)
|
||||||
return ins_len;
|
return ins_len;
|
||||||
|
#ifdef HAVE_MBSINIT
|
||||||
if ((s != ins) || !mbsinit(&mbstate)) {
|
if ((s != ins) || !mbsinit(&mbstate)) {
|
||||||
|
#else
|
||||||
|
if (s != ins) {
|
||||||
|
#endif
|
||||||
errno = EILSEQ;
|
errno = EILSEQ;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
@ -451,7 +473,11 @@ int ntfs_mbstoucs(char *ins, uchar_t **outs, int outs_len)
|
||||||
if (!ucs)
|
if (!ucs)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_MBSINIT
|
||||||
memset(&mbstate, 0, sizeof(mbstate));
|
memset(&mbstate, 0, sizeof(mbstate));
|
||||||
|
#else
|
||||||
|
mbtowc(NULL, NULL, 0);
|
||||||
|
#endif
|
||||||
for (i = o = cnt = 0; o < ins_len; i += cnt, o++) {
|
for (i = o = cnt = 0; o < ins_len; i += cnt, o++) {
|
||||||
/* Reallocate memory if necessary or abort. */
|
/* Reallocate memory if necessary or abort. */
|
||||||
if (o >= ucs_len) {
|
if (o >= ucs_len) {
|
||||||
|
|
@ -472,7 +498,11 @@ int ntfs_mbstoucs(char *ins, uchar_t **outs, int outs_len)
|
||||||
ucs_len /= sizeof(uchar_t);
|
ucs_len /= sizeof(uchar_t);
|
||||||
}
|
}
|
||||||
/* Convert the multibyte character to a wide character. */
|
/* Convert the multibyte character to a wide character. */
|
||||||
|
#ifdef HAVE_MBSINIT
|
||||||
cnt = mbrtowc(&wc, ins + i, ins_len - i, &mbstate);
|
cnt = mbrtowc(&wc, ins + i, ins_len - i, &mbstate);
|
||||||
|
#else
|
||||||
|
cnt = mbtowc(&wc, ins + i, ins_len - i);
|
||||||
|
#endif
|
||||||
if (!cnt)
|
if (!cnt)
|
||||||
break;
|
break;
|
||||||
if (cnt == -1)
|
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. */
|
/* Convert the CPU wide character to a LE Unicode character. */
|
||||||
ucs[o] = cpu_to_le16(wc);
|
ucs[o] = cpu_to_le16(wc);
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_MBSINIT
|
||||||
/* Make sure we are back in the initial state. */
|
/* Make sure we are back in the initial state. */
|
||||||
if (!mbsinit(&mbstate)) {
|
if (!mbsinit(&mbstate)) {
|
||||||
Dprintf("%s(): Eeek. mbstate not in initial state!\n",
|
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;
|
errno = EILSEQ;
|
||||||
goto err_out;
|
goto err_out;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
/* Now write the NULL character. */
|
/* Now write the NULL character. */
|
||||||
ucs[o] = cpu_to_le16(L'\0');
|
ucs[o] = cpu_to_le16(L'\0');
|
||||||
if (*outs != ucs)
|
if (*outs != ucs)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue