[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r714 - in Extractor: . src/include src/main
From: |
durner |
Subject: |
[GNUnet-SVN] r714 - in Extractor: . src/include src/main |
Date: |
Sun, 1 May 2005 06:29:09 -0700 (PDT) |
Author: durner
Date: 2005-05-01 06:28:48 -0700 (Sun, 01 May 2005)
New Revision: 714
Added:
Extractor/mkinstalldirs
Extractor/src/include/plibc.h
Modified:
Extractor/configure.ac
Extractor/src/include/platform.h
Extractor/src/include/winproc.h
Extractor/src/main/extractor.c
Extractor/src/main/winproc.c
Log:
Use PlibC for POSIX emulation under Windows
Modified: Extractor/configure.ac
===================================================================
--- Extractor/configure.ac 2005-05-01 13:28:40 UTC (rev 713)
+++ Extractor/configure.ac 2005-05-01 13:28:48 UTC (rev 714)
@@ -58,7 +58,7 @@
AC_DEFINE_UNQUOTED(MINGW,1,[This is a MinGW system])
AC_DEFINE_UNQUOTED(WINDOWS,1,[This is a Windows system])
AC_CHECK_LIB(intl, gettext)
- LDFLAGS="$LDFLAGS -no-undefined -Wl,--export-all-symbols -lws2_32"
+ LDFLAGS="$LDFLAGS -no-undefined -Wl,--export-all-symbols -lws2_32 -lplibc"
;;
*)
AC_MSG_RESULT(Unrecognised OS $host_os)
Added: Extractor/mkinstalldirs
===================================================================
--- Extractor/mkinstalldirs 2005-05-01 13:28:40 UTC (rev 713)
+++ Extractor/mkinstalldirs 2005-05-01 13:28:48 UTC (rev 714)
@@ -0,0 +1,143 @@
+#! /bin/sh
+# mkinstalldirs --- make directory hierarchy
+
+scriptversion=2003-11-08.23
+
+# Original author: Noah Friedman <address@hidden>
+# Created: 1993-05-16
+# Public domain.
+#
+# This file is maintained in Automake, please report
+# bugs to <address@hidden> or send patches to
+# <address@hidden>.
+
+errstatus=0
+dirmode=""
+
+usage="\
+Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
+
+Create each directory DIR (with mode MODE, if specified), including all
+leading file name components.
+
+Report bugs to <address@hidden>."
+
+# process command line arguments
+while test $# -gt 0 ; do
+ case $1 in
+ -h | --help | --h*) # -h for help
+ echo "$usage"
+ exit 0
+ ;;
+ -m) # -m PERM arg
+ shift
+ test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
+ dirmode=$1
+ shift
+ ;;
+ --version)
+ echo "$0 $scriptversion"
+ exit 0
+ ;;
+ --) # stop option processing
+ shift
+ break
+ ;;
+ -*) # unknown option
+ echo "$usage" 1>&2
+ exit 1
+ ;;
+ *) # first non-opt arg
+ break
+ ;;
+ esac
+done
+
+for file
+do
+ if test -d "$file"; then
+ shift
+ else
+ break
+ fi
+done
+
+case $# in
+ 0) exit 0 ;;
+esac
+
+case $dirmode in
+ '')
+ if mkdir -p -- . 2>/dev/null; then
+ echo "mkdir -p -- $*"
+ exec mkdir -p -- "$@"
+ else
+ # On NextStep and OpenStep, the `mkdir' command does not
+ # recognize any option. It will interpret all options as
+ # directories to create, and then abort because `.' already
+ # exists.
+ test -d ./-p && rmdir ./-p
+ test -d ./-- && rmdir ./--
+ fi
+ ;;
+ *)
+ if mkdir -m "$dirmode" -p -- . 2>/dev/null; then
+ echo "mkdir -m $dirmode -p -- $*"
+ exec mkdir -m "$dirmode" -p -- "$@"
+ else
+ # Clean up after NextStep and OpenStep mkdir.
+ for d in ./-m ./-p ./-- "./$dirmode";
+ do
+ test -d $d && rmdir $d
+ done
+ fi
+ ;;
+esac
+
+for file
+do
+ set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
+ shift
+
+ pathcomp=
+ for d
+ do
+ pathcomp="$pathcomp$d"
+ case $pathcomp in
+ -*) pathcomp=./$pathcomp ;;
+ esac
+
+ if test ! -d "$pathcomp"; then
+ echo "mkdir $pathcomp"
+
+ mkdir "$pathcomp" || lasterr=$?
+
+ if test ! -d "$pathcomp"; then
+ errstatus=$lasterr
+ else
+ if test ! -z "$dirmode"; then
+ echo "chmod $dirmode $pathcomp"
+ lasterr=""
+ chmod "$dirmode" "$pathcomp" || lasterr=$?
+
+ if test ! -z "$lasterr"; then
+ errstatus=$lasterr
+ fi
+ fi
+ fi
+ fi
+
+ pathcomp="$pathcomp/"
+ done
+done
+
+exit $errstatus
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
Modified: Extractor/src/include/platform.h
===================================================================
--- Extractor/src/include/platform.h 2005-05-01 13:28:40 UTC (rev 713)
+++ Extractor/src/include/platform.h 2005-05-01 13:28:48 UTC (rev 714)
@@ -32,6 +32,8 @@
#include "gettext.h"
#define _(a) dgettext(PACKAGE, a)
+#include "plibc.h"
+
#include <string.h>
#include <unistd.h>
#include <ctype.h>
@@ -51,210 +53,14 @@
#include <sys/mman.h>
#include <netinet/in.h>
#include <arpa/inet.h>
-
#else
#include <winsock2.h>
- #include <pthread.h>
#endif
#include <locale.h>
#include <iconv.h>
-
-#ifndef MINGW
- #define DIR_SEPARATOR '/'
-
- #define CREAT(p, m) creat(p, m)
- #undef FOPEN
- #define FOPEN(f, m) fopen(f, m)
- #define OPENDIR(d) opendir(d)
- #define CHDIR(d) chdir(d)
- #define RMDIR(f) rmdir(f)
- #define ACCESS(p, m) access(p, m)
- #define CHMOD(f, p) chmod(f, p)
- #define FSTAT(h, b) fstat(h, b)
- #define PIPE(h) pipe(h)
- #define REMOVE(p) remove(p)
- #define RENAME(o, n) rename(o, n)
- #define STAT(p, b) stat(p, b)
- #define UNLINK(f) unlink(f)
- #define WRITE(f, b, n) write(f, b, n)
- #define READ(f, b, n) read(f, b, n)
- #define GN_FREAD(b, s, c, f) fread(b, s, c, f)
- #define GN_FWRITE(b, s, c, f) fwrite(b, s, c, f)
- #define MMAP(s, l, p, f, d, o) mmap(s, l, p, f, d, o)
- #define MUNMAP(s, l) munmap(s, l)
- #define STRERROR(i) strerror(i)
-#else
-
- #include "winproc.h"
-
-
- #define DIR_SEPARATOR '\\'
-
- #define int64_t long long
- #define int32_t long
-
- #define CREAT(p, m) _win_creat(p, m)
- #define FOPEN(f, m) _win_fopen(f, m)
- #define OPENDIR(d) _win_opendir(d)
- #define CHDIR(d) _win_chdir(d)
- #define FSTAT(h, b) _win_fstat(h, b)
- #define RMDIR(f) _win_rmdir(f)
- #define ACCESS(p, m) _win_access(p, m)
- #define CHMOD(f, p) _win_chmod(f, p)
- #define PIPE(h) _win_pipe(h)
- #define REMOVE(p) _win_remove(p)
- #define RENAME(o, n) _win_rename(o, n)
- #define STAT(p, b) _win_stat(p, b)
- #define UNLINK(f) _win_unlink(f)
- #define WRITE(f, b, n) _win_write(f, b, n)
- #define READ(f, b, n) _win_read(f, b, n)
- #define GN_FREAD(b, s, c, f) _win_fread(b, s, c, f)
- #define GN_FWRITE(b, s, c, f) _win_fwrite(b, s, c, f)
- #define MMAP(s, l, p, f, d, o) _win_mmap(s, l, p, f, d, o)
- #define MUNMAP(s, l) _win_munmap(s, l)
- #define STRERROR(i) _win_strerror(i)
-#endif
-
#ifdef OSX
#define socklen_t unsigned int
#endif
-#ifndef HAVE_LANGINFO_H
-/* Modified version of glibc's langinfo.h */
-
-/* Enumeration of locale items that can be queried with `nl_langinfo'. */
-enum
-{
- /* LC_TIME category: date and time formatting. */
-
- /* Abbreviated days of the week. */
- ABDAY_1, /* Sun */
-#define ABDAY_1 ABDAY_1
- ABDAY_2,
-#define ABDAY_2 ABDAY_2
- ABDAY_3,
-#define ABDAY_3 ABDAY_3
- ABDAY_4,
-#define ABDAY_4 ABDAY_4
- ABDAY_5,
-#define ABDAY_5 ABDAY_5
- ABDAY_6,
-#define ABDAY_6 ABDAY_6
- ABDAY_7,
-#define ABDAY_7 ABDAY_7
-
- /* Long-named days of the week. */
- DAY_1, /* Sunday */
-#define DAY_1 DAY_1
- DAY_2, /* Monday */
-#define DAY_2 DAY_2
- DAY_3, /* Tuesday */
-#define DAY_3 DAY_3
- DAY_4, /* Wednesday */
-#define DAY_4 DAY_4
- DAY_5, /* Thursday */
-#define DAY_5 DAY_5
- DAY_6, /* Friday */
-#define DAY_6 DAY_6
- DAY_7, /* Saturday */
-#define DAY_7 DAY_7
-
- /* Abbreviated month names. */
- ABMON_1, /* Jan */
-#define ABMON_1 ABMON_1
- ABMON_2,
-#define ABMON_2 ABMON_2
- ABMON_3,
-#define ABMON_3 ABMON_3
- ABMON_4,
-#define ABMON_4 ABMON_4
- ABMON_5,
-#define ABMON_5 ABMON_5
- ABMON_6,
-#define ABMON_6 ABMON_6
- ABMON_7,
-#define ABMON_7 ABMON_7
- ABMON_8,
-#define ABMON_8 ABMON_8
- ABMON_9,
-#define ABMON_9 ABMON_9
- ABMON_10,
-#define ABMON_10 ABMON_10
- ABMON_11,
-#define ABMON_11 ABMON_11
- ABMON_12,
-#define ABMON_12 ABMON_12
-
- /* Long month names. */
- MON_1, /* January */
-#define MON_1 MON_1
- MON_2,
-#define MON_2 MON_2
- MON_3,
-#define MON_3 MON_3
- MON_4,
-#define MON_4 MON_4
- MON_5,
-#define MON_5 MON_5
- MON_6,
-#define MON_6 MON_6
- MON_7,
-#define MON_7 MON_7
- MON_8,
-#define MON_8 MON_8
- MON_9,
-#define MON_9 MON_9
- MON_10,
-#define MON_10 MON_10
- MON_11,
-#define MON_11 MON_11
- MON_12,
-#define MON_12 MON_12
-
- AM_STR, /* Ante meridian string. */
-#define AM_STR AM_STR
- PM_STR, /* Post meridian string. */
-#define PM_STR PM_STR
-
- D_T_FMT, /* Date and time format for strftime. */
-#define D_T_FMT D_T_FMT
- D_FMT, /* Date format for strftime. */
-#define D_FMT D_FMT
- T_FMT, /* Time format for strftime. */
-#define T_FMT T_FMT
- T_FMT_AMPM, /* 12-hour time format for strftime. */
-#define T_FMT_AMPM T_FMT_AMPM
-
- ERA, /* Alternate era. */
-#define ERA ERA
- ERA_D_FMT, /* Date in alternate era format. */
-#define ERA_D_FMT ERA_D_FMT
- ALT_DIGITS, /* Alternate symbols for digits. */
-#define ALT_DIGITS ALT_DIGITS
- ERA_D_T_FMT, /* Date and time in alternate era format. */
-#define ERA_D_T_FMT ERA_D_T_FMT
- ERA_T_FMT, /* Time in alternate era format. */
-#define ERA_T_FMT ERA_T_FMT
- _DATE_FMT, /* strftime format for date. */
-#define _DATE_FMT _DATE_FMT
- CODESET,
-#define CODESET CODESET
- CRNCYSTR,
-#define CRNCYSTR CRNCYSTR
- RADIXCHAR,
-#define RADIXCHAR RADIXCHAR
- THOUSEP,
-#define THOUSEP THOUSEP
- YESEXPR,
-#define YESEXPR YESEXPR
- NOEXPR, /* Regex matching ``no'' input. */
-#define NOEXPR NOEXPR
- /* This marks the highest value used. */
- _NL_NUM
-};
-#else
- #include <langinfo.h>
-#endif /* #ifndef HAVE_LANGINFO_H */
-
#endif
Added: Extractor/src/include/plibc.h
===================================================================
--- Extractor/src/include/plibc.h 2005-05-01 13:28:40 UTC (rev 713)
+++ Extractor/src/include/plibc.h 2005-05-01 13:28:48 UTC (rev 714)
@@ -0,0 +1,550 @@
+/*
+ This file is part of PlibC.
+ (C) 2005 Nils Durner (and other contributing authors)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
+*/
+
+/**
+ * @file include/plibc.h
+ * @brief PlibC header
+ * @attention This file is usually not installed under Unix,
+ * so ship it with your application
+ * @version $Revision: 1.12 $
+ */
+
+#ifndef _PLIBC_H_
+#define _PLIBC_H_
+
+#ifndef SIGALRM
+ #define SIGALRM 14
+#endif
+
+#if ENABLE_NLS
+ #include "langinfo.h"
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef WINDOWS
+
+#include <windows.h>
+#include <time.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <dirent.h>
+
+#define __BYTE_ORDER BYTE_ORDER
+#define __BIG_ENDIAN BIG_ENDIAN
+
+/* Conflicts with our definitions */
+#define __G_WIN32_H__
+
+/* Convert LARGE_INTEGER to double */
+#define Li2Double(x) ((double)((x).HighPart) * 4.294967296E9 + \
+ (double)((x).LowPart))
+
+#define socklen_t int
+#define ssize_t int
+#define ftruncate chsize
+#define off_t int
+#define int64_t long long
+#define int32_t long
+
+/* Thanks to the Cygwin project */
+#define EPERM 1 /* Not super-user */
+#define ENOENT 2 /* No such file or directory */
+#define ESRCH 3 /* No such process */
+#define EINTR 4 /* Interrupted system call */
+#define EIO 5 /* I/O error */
+#define ENXIO 6 /* No such device or address */
+#define E2BIG 7 /* Arg list too long */
+#define ENOEXEC 8 /* Exec format error */
+#define EBADF 9 /* Bad file number */
+#define ECHILD 10 /* No children */
+#define EAGAIN 11 /* Resource unavailable or operation would block, try
again */
+#define ENOMEM 12 /* Not enough memory */
+#define EACCES 13 /* Permission denied */
+#define EFAULT 14 /* Bad address */
+#define ENOTBLK 15 /* Block device required */
+#define EBUSY 16 /* Mount device busy */
+#define EEXIST 17 /* File exists */
+#define EXDEV 18 /* Cross-device link */
+#define ENODEV 19 /* No such device */
+#define ENOTDIR 20 /* Not a directory */
+#define EISDIR 21 /* Is a directory */
+#define EINVAL 22 /* Invalid argument */
+#define ENFILE 23 /* Too many open files in system */
+#define EMFILE 24 /* Too many open files */
+#define ENOTTY 25 /* Not a typewriter */
+#define ETXTBSY 26 /* Text file busy */
+#define EFBIG 27 /* File too large */
+#define ENOSPC 28 /* No space left on device */
+#define ESPIPE 29 /* Illegal seek */
+#define EROFS 30 /* Read only file system */
+#define EMLINK 31 /* Too many links */
+#define EPIPE 32 /* Broken pipe */
+#define EDOM 33 /* Math arg out of domain of func */
+#define ERANGE 34 /* Math result not representable */
+#define ENOMSG 35 /* No message of desired type */
+#define EIDRM 36 /* Identifier removed */
+#define ECHRNG 37 /* Channel number out of range */
+#define EL2NSYNC 38 /* Level 2 not synchronized */
+#define L3HLT 39 /* Level 3 halted */
+#define EL3RST 40 /* Level 3 reset */
+#define ELNRNG 41 /* Link number out of range */
+#define EUNATCH 42 /* Protocol driver not attached */
+#define ENOCSI 43 /* No CSI structure available */
+#define EL2HLT 44 /* Level 2 halted */
+#undef EDEADLK
+#define EDEADLK 45 /* Deadlock condition */
+#undef ENOLCK
+#define ENOLCK 46 /* No record locks available */
+#define EBADE 50 /* Invalid exchange */
+#define EBADR 51 /* Invalid request descriptor */
+#define EXFULL 52 /* Exchange full */
+#define ENOANO 53 /* No anode */
+#define EBADRQC 54 /* Invalid request code */
+#define EBADSLT 55 /* Invalid slot */
+#undef EDEADLOCK
+#define EDEADLOCK 56 /* File locking deadlock error */
+#define EBFONT 57 /* Bad font file fmt */
+#define ENOSTR 60 /* Device not a stream */
+#define ENODATA 61 /* No data (for no delay io) */
+#define ETIME 62 /* Timer expired */
+#define ENOSR 63 /* Out of streams resources */
+#define ENONET 64 /* Machine is not on the network */
+#define ENOPKG 65 /* Package not installed */
+#define EREMOTE 66 /* The object is remote */
+#define ENOLINK 67 /* The link has been severed */
+#define EADV 68 /* Advertise error */
+#define ESRMNT 69 /* Srmount error */
+#define ECOMM 70 /* Communication error on send */
+#define EPROTO 71 /* Protocol error */
+#define EMULTIHOP 74 /* Multihop attempted */
+#define ELBIN 75 /* Inode is remote (not really error) */
+#define EDOTDOT 76 /* Cross mount point (not really error) */
+#define EBADMSG 77 /* Trying to read unreadable message */
+#define ENOTUNIQ 80 /* Given log. name not unique */
+#define EBADFD 81 /* f.d. invalid for this operation */
+#define EREMCHG 82 /* Remote address changed */
+#define ELIBACC 83 /* Can't access a needed shared lib */
+#define ELIBBAD 84 /* Accessing a corrupted shared lib */
+#define ELIBSCN 85 /* .lib section in a.out corrupted */
+#define ELIBMAX 86 /* Attempting to link in too many libs */
+#define ELIBEXEC 87 /* Attempting to exec a shared library */
+#undef ENOSYS
+#define ENOSYS 88 /* Function not implemented */
+#define ENMFILE 89 /* No more files */
+#undef ENOTEMPTY
+#define ENOTEMPTY 90 /* Directory not empty */
+#undef ENAMETOOLONG
+#define ENAMETOOLONG 91 /* File or path name too long */
+#define ELOOP 92 /* Too many symbolic links */
+#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
+#define EPFNOSUPPORT 96 /* Protocol family not supported */
+#define ECONNRESET 104 /* Connection reset by peer */
+#define ENOBUFS 105 /* No buffer space available */
+#define EAFNOSUPPORT 106 /* Address family not supported by protocol family */
+#define EPROTOTYPE 107 /* Protocol wrong type for socket */
+#define ENOTSOCK 108 /* Socket operation on non-socket */
+#define ENOPROTOOPT 109 /* Protocol not available */
+#define ESHUTDOWN 110 /* Can't send after socket shutdown */
+#define ECONNREFUSED 111 /* Connection refused */
+#define EADDRINUSE 112 /* Address already in use */
+#define ECONNABORTED 113 /* Connection aborted */
+#define ENETUNREACH 114 /* Network is unreachable */
+#define ENETDOWN 115 /* Network interface is not configured */
+#undef ETIMEDOUT
+#define ETIMEDOUT 116 /* Connection timed out */
+#define EHOSTDOWN 117 /* Host is down */
+#define EHOSTUNREACH 118 /* Host is unreachable */
+#define EINPROGRESS 119 /* Connection already in progress */
+#define EALREADY 120 /* Socket already connected */
+#define EDESTADDRREQ 121 /* Destination address required */
+#define EMSGSIZE 122 /* Message too long */
+#define EPROTONOSUPPORT 123 /* Unknown protocol */
+#define ESOCKTNOSUPPORT 124 /* Socket type not supported */
+#define EADDRNOTAVAIL 125 /* Address not available */
+#define ENETRESET 126 /* Connection aborted by network */
+#define EISCONN 127 /* Socket is already connected */
+#define ENOTCONN 128 /* Socket is not connected */
+#define ETOOMANYREFS 129 /* Too many references: cannot splice */
+#define EPROCLIM 130 /* Too many processes */
+#define EUSERS 131 /* Too many users */
+#define EDQUOT 132 /* Disk quota exceeded */
+#define ESTALE 133 /* Unknown error */
+#undef ENOTSUP
+#define ENOTSUP 134 /* Not supported */
+#define ENOMEDIUM 135 /* No medium (in tape drive) */
+#define ENOSHARE 136 /* No such host or network path */
+#define ECASECLASH 137 /* Filename exists with different case */
+#define EWOULDBLOCK EAGAIN /* Operation would block */
+
+#undef HOST_NOT_FOUND
+#define HOST_NOT_FOUND 1
+#undef TRY_AGAIN
+#define TRY_AGAIN 2
+#undef NO_RECOVERY
+#define NO_RECOVERY 3
+#undef NO_ADDRESS
+#define NO_ADDRESS 4
+
+#define PROT_READ 0x1
+#define PROT_WRITE 0x2
+#define MAP_SHARED 0x1
+#define MAP_PRIVATE 0x2 /* unsupported */
+#define MAP_FIXED 0x10
+
+struct statfs
+{
+ long f_type; /* type of filesystem (see below) */
+ long f_bsize; /* optimal transfer block size */
+ long f_blocks; /* total data blocks in file system */
+ long f_bfree; /* free blocks in fs */
+ long f_bavail; /* free blocks avail to non-superuser */
+ long f_files; /* total file nodes in file system */
+ long f_ffree; /* free file nodes in fs */
+ long f_fsid; /* file system id */
+ long f_namelen; /* maximum length of filenames */
+ long f_spare[6]; /* spare for later */
+};
+
+/* Taken from the Wine project <http://www.winehq.org>
+ /wine/include/winternl.h */
+enum SYSTEM_INFORMATION_CLASS
+{
+ SystemBasicInformation = 0,
+ Unknown1,
+ SystemPerformanceInformation = 2,
+ SystemTimeOfDayInformation = 3, /* was SystemTimeInformation */
+ Unknown4,
+ SystemProcessInformation = 5,
+ Unknown6,
+ Unknown7,
+ SystemProcessorPerformanceInformation = 8,
+ Unknown9,
+ Unknown10,
+ SystemDriverInformation,
+ Unknown12,
+ Unknown13,
+ Unknown14,
+ Unknown15,
+ SystemHandleList,
+ Unknown17,
+ Unknown18,
+ Unknown19,
+ Unknown20,
+ SystemCacheInformation,
+ Unknown22,
+ SystemInterruptInformation = 23,
+ SystemExceptionInformation = 33,
+ SystemRegistryQuotaInformation = 37,
+ SystemLookasideInformation = 45
+};
+
+typedef struct
+{
+ LARGE_INTEGER IdleTime;
+ LARGE_INTEGER KernelTime;
+ LARGE_INTEGER UserTime;
+ LARGE_INTEGER Reserved1[2];
+ ULONG Reserved2;
+} SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION;
+
+#define sleep(secs) (Sleep(secs * 1000))
+
+/*********************** statfs *****************************/
+/* fake block size */
+#define FAKED_BLOCK_SIZE 512
+
+/* linux-compatible values for fs type */
+#define MSDOS_SUPER_MAGIC 0x4d44
+#define NTFS_SUPER_MAGIC 0x5346544E
+
+/*********************** End of statfs ***********************/
+
+#define SHUT_RDWR SD_BOTH
+
+/* Operations for flock() */
+#define LOCK_SH 1 /* shared lock */
+#define LOCK_EX 2 /* exclusive lock */
+#define LOCK_NB 4 /* or'd with one of the above to prevent
+ blocking */
+#define LOCK_UN 8 /* remove lock */
+
+/* Not supported under MinGW */
+#define S_IRGRP 0
+#define S_IWGRP 0
+#define S_IROTH 0
+#define S_IXGRP 0
+#define S_IWOTH 0
+#define S_IXOTH 0
+#define S_ISUID 0
+#define S_ISGID 0
+#define S_ISVTX 0
+#define S_IRWXG 0
+#define S_IRWXO 0
+
+#define SetErrnoFromWinError(e) _SetErrnoFromWinError(e, __FILE__, __LINE__)
+
+BOOL _plibc_CreateShortcut(const char *pszSrc, const char *pszDest);
+BOOL _plibc_DereferenceShortcut(char *pszShortcut);
+long QueryRegistry(HKEY hMainKey, char *pszKey, char *pszSubKey,
+ char *pszBuffer, long *pdLength);
+
+BOOL __win_IsHandleMarkedAsBlocking(SOCKET hHandle);
+void __win_SetHandleBlockingMode(SOCKET s, BOOL bBlocking);
+void __win_DiscardHandleBlockingMode(SOCKET s);
+int _win_isSocketValid(int s);
+int plibc_conv_to_win_path(const char *pszUnix, char *pszWindows);
+
+typedef void (*TPanicProc) (int, char *);
+void plibc_set_panic_proc(TPanicProc proc);
+
+int flock(int fd, int operation);
+int fsync(int fildes);
+int inet_pton(int af, const char *src, void *dst);
+int inet_pton4(const char *src, u_char *dst, int pton);
+#if USE_IPV6
+int inet_pton6(const char *src, u_char *dst);
+#endif
+int truncate(const char *fname, int distance);
+int statfs(const char *path, struct statfs *buf);
+const char *hstrerror(int err);
+void gettimeofday(struct timeval *tp, void *tzp);
+int mkstemp(char *tmplate);
+char *strptime (const char *buf, const char *format, struct tm *tm);
+char *ctime(const time_t *clock);
+char *ctime_r(const time_t *clock, char *buf);
+int plibc_init(char *pszOrg, char *pszApp);
+void plibc_shutdown();
+int plibc_conv_to_win_path_ex(const char *pszUnix, char *pszWindows, int
derefLinks);
+void _SetErrnoFromWinError(long lWinError, char *pszCaller, int iLine);
+void SetErrnoFromWinsockError(long lWinError);
+void SetHErrnoFromWinError(long lWinError);
+void SetErrnoFromHRESULT(HRESULT hRes);
+FILE *_win_fopen(const char *filename, const char *mode);
+DIR *_win_opendir(const char *dirname);
+int _win_open(const char *filename, int oflag, ...);
+int _win_chdir(const char *path);
+int _win_close(int fd);
+int _win_fstat(int handle, struct stat *buffer);
+int _win_pipe(int *phandles);
+int _win_rmdir(const char *path);
+int _win_access( const char *path, int mode );
+int _win_chmod(const char *filename, int pmode);
+char *realpath(const char *file_name, char *resolved_name);
+int _win_remove(const char *path);
+int _win_rename(const char *oldname, const char *newname);
+int _win_stat(const char *path, struct stat *buffer);
+int _win_unlink(const char *filename);
+int _win_write(int fildes, const void *buf, size_t nbyte);
+int _win_read(int fildes, void *buf, size_t nbyte);
+size_t _win_fwrite(const void *buffer, size_t size, size_t count, FILE
*stream);
+size_t _win_fread( void *buffer, size_t size, size_t count, FILE *stream );
+int _win_symlink(const char *path1, const char *path2);
+void *_win_mmap(void *start, size_t len, int access, int flags, int fd,
+ unsigned long long offset);
+int _win_munmap(void *start, size_t length);
+int _win_lstat(const char *path, struct stat *buf);
+int _win_readlink(const char *path, char *buf, size_t bufsize);
+int _win_accept(SOCKET s, struct sockaddr *addr, int *addrlen);
+int _win_printf(const char *format,...);
+int _win_fprintf(FILE *f,const char *format,...);
+int _win_vprintf(const char *format, va_list ap);
+int _win_vfprintf(FILE *stream, const char *format, va_list arg_ptr);
+int _win_vsprintf(char *dest,const char *format, va_list arg_ptr);
+int _win_vsnprintf(char* str, size_t size, const char *format, va_list
arg_ptr);
+int _win_snprintf(char *str,size_t size,const char *format,...);
+int _win_sprintf(char *dest,const char *format,...);
+int _win_vsscanf(const char* str, const char* format, va_list arg_ptr);
+int _win_sscanf(const char *str, const char *format, ...);
+int _win_vfscanf(FILE *stream, const char *format, va_list arg_ptr);
+int _win_vscanf(const char *format, va_list arg_ptr);
+int _win_scanf(const char *format, ...);
+int _win_fscanf(FILE *stream, const char *format, ...);
+int _win_bind(SOCKET s, const struct sockaddr *name, int namelen);
+int _win_connect(SOCKET s,const struct sockaddr *name, int namelen);
+int _win_getpeername(SOCKET s, struct sockaddr *name,
+ int *namelen);
+int _win_getsockname(SOCKET s, struct sockaddr *name,
+ int *namelen);
+int _win_getsockopt(SOCKET s, int level, int optname, char *optval,
+ int *optlen);
+int _win_listen(SOCKET s, int backlog);
+int _win_recv(SOCKET s, char *buf, int len, int flags);
+int _win_recvfrom(SOCKET s, void *buf, int len, int flags,
+ struct sockaddr *from, int *fromlen);
+int _win_select(int max_fd, fd_set * rfds, fd_set * wfds, fd_set * efds,
+ const struct timeval *tv);
+int _win_send(SOCKET s, const char *buf, int len, int flags);
+int _win_sendto(SOCKET s, const char *buf, int len, int flags,
+ const struct sockaddr *to, int tolen);
+int _win_setsockopt(SOCKET s, int level, int optname, const void *optval,
+ int optlen);
+int _win_shutdown(SOCKET s, int how);
+SOCKET _win_socket(int af, int type, int protocol);
+struct hostent *_win_gethostbyaddr(const char *addr, int len, int type);
+struct hostent *_win_gethostbyname(const char *name);
+char *_win_strerror(int errnum);
+int IsWinNT();
+
+#if !HAVE_STRNDUP
+char *strndup (const char *s, size_t n);
+#endif
+#if !HAVE_STRNLEN
+size_t strnlen (const char *str, size_t maxlen);
+#endif
+
+#endif /* WINDOWS */
+
+#ifndef WINDOWS
+ #define DIR_SEPARATOR '/'
+ #define DIR_SEPARATOR_STR "/"
+ #define NEWLINE "\n"
+
+ #define CREAT(p, m) creat(p, m)
+ #undef FOPEN
+ #define FOPEN(f, m) fopen(f, m)
+ #define OPENDIR(d) opendir(d)
+ #define OPEN(f) open(f)
+ #define CHDIR(d) chdir(d)
+ #define CLOSE(f) close(f)
+ #define RMDIR(f) rmdir(f)
+ #define ACCESS(p, m) access(p, m)
+ #define CHMOD(f, p) chmod(f, p)
+ #define FSTAT(h, b) fstat(h, b)
+ #define PIPE(h) pipe(h)
+ #define REMOVE(p) remove(p)
+ #define RENAME(o, n) rename(o, n)
+ #define STAT(p, b) stat(p, b)
+ #define UNLINK(f) unlink(f)
+ #define WRITE(f, b, n) write(f, b, n)
+ #define READ(f, b, n) read(f, b, n)
+ #define GN_FREAD(b, s, c, f) fread(b, s, c, f)
+ #define GN_FWRITE(b, s, c, f) fwrite(b, s, c, f)
+ #define SYMLINK(a, b) symlink(a, b)
+ #define MMAP(s, l, p, f, d, o) mmap(s, l, p, f, d, o)
+ #define MUNMAP(s, l) munmap(s, l);
+ #define STRERROR(i) strerror(i)
+ #define READLINK(p, b, s) readlink(p, b, s)
+ #define LSTAT(p, b) lstat(p, b)
+ #define PRINTF(f, ...) printf(f , __VA_ARGS__)
+ #define FPRINTF(fil, fmt, ...) fprintf(fil, fmt, __VA_ARGS__)
+ #define VPRINTF(f, a) vprintf(f, a)
+ #define VFPRINTF(s, f, a) vfprintf(s, f, a)
+ #define VSPRINTF(d, f, a) vsprintf(d, f, a)
+ #define VSNPRINTF(str, size, fmt, a) vsnprintf(str, size, fmt, a)
+ #define _REAL_SNPRINTF(str, size, fmt, ...) snprintf(str, size, fmt,
__VA_ARGS__)
+ #define SPRINTF(d, f, ...) sprintf(d, f, __VA_ARGS__)
+ #define VSSCANF(s, f, a) vsscanf(s, f, a)
+ #define SSCANF(s, f, ...) sscanf(s, f, __VA_ARGS__)
+ #define VFSCANF(s, f, a) vfscanf(s, f, a)
+ #define VSCANF(f, a) vscanf(f, a)
+ #define SCANF(f, ...) scanf(f, __VA_ARGS__)
+ #define FSCANF(s, f, ...) fscanf(s, f, __VA_ARGS__)
+ #define ACCEPT(s, a, l) accept(s, a, l)
+ #define BIND(s, n, l) bind(s, n, l)
+ #define CONNECT(s, n, l) connect(s, n, l)
+ #define GETPEERNAME(s, n, l) getpeername(s, n, l)
+ #define GETSOCKNAME(s, n, l) getsockname(s, n, l)
+ #define GETSOCKOPT(s, l, o, v, p) getsockopt(s, l, o, v, p)
+ #define LISTEN(s, b) listen(s, b)
+ #define RECV(s, b, l, f) recv(s, b, l, f)
+ #define RECVFROM(s, b, l, f, r, o) recvfrom(s, b, l, f, r, o)
+ #define SELECT(n, r, w, e, t) select(n, r, w, e, t)
+ #define SEND(s, b, l, f) send(s, b, l, f)
+ #define SENDTO(s, b, l, f, o, n) sendto(s, b, l, f, o, n)
+ #define SETSOCKOPT(s, l, o, v, n) setsockopt(s, l, o, v, n)
+ #define SHUTDOWN(s, h) shutdown(s, h)
+ #define SOCKET(a, t, p) socket(a, t, p)
+ #define GETHOSTBYADDR(a, l, t) gethostbyname(a, l, t)
+ #define GETHOSTBYNAME(n) gethostbyname(n)
+#else
+ #define DIR_SEPARATOR '\\'
+ #define DIR_SEPARATOR_STR "\\"
+ #define NEWLINE "\r\n"
+
+ #define CREAT(p, m) _win_creat(p, m)
+ #define FOPEN(f, m) _win_fopen(f, m)
+ #define OPENDIR(d) _win_opendir(d)
+ #define OPEN(f) _win_open(f)
+ #define CHDIR(d) _win_chdir(d)
+ #define CLOSE(f) _win_close(f)
+ #define FSTAT(h, b) _win_fstat(h, b)
+ #define RMDIR(f) _win_rmdir(f)
+ #define ACCESS(p, m) _win_access(p, m)
+ #define CHMOD(f, p) _win_chmod(f, p)
+ #define PIPE(h) _win_pipe(h)
+ #define REMOVE(p) _win_remove(p)
+ #define RENAME(o, n) _win_rename(o, n)
+ #define STAT(p, b) _win_stat(p, b)
+ #define UNLINK(f) _win_unlink(f)
+ #define WRITE(f, b, n) _win_write(f, b, n)
+ #define READ(f, b, n) _win_read(f, b, n)
+ #define GN_FREAD(b, s, c, f) _win_fread(b, s, c, f)
+ #define GN_FWRITE(b, s, c, f) _win_fwrite(b, s, c, f)
+ #define SYMLINK(a, b) _win_symlink(a, b)
+ #define MMAP(s, l, p, f, d, o) _win_mmap(s, l, p, f, d, o)
+ #define MUNMAP(s, l) _win_munmap(s, l)
+ #define STRERROR(i) _win_strerror(i)
+ #define READLINK(p, b, s) _win_readlink(p, b, s)
+ #define LSTAT(p, b) _win_lstat(p, b)
+ #define PRINTF(f, ...) _win_printf(f , __VA_ARGS__)
+ #define FPRINTF(fil, fmt, ...) _win_fprintf(fil, fmt, __VA_ARGS__)
+ #define VPRINTF(f, a) _win_vprintf(f, a)
+ #define VFPRINTF(s, f, a) _win_vfprintf(s, f, a)
+ #define VSPRINTF(d, f, a) _win_vsprintf(d, f, a)
+ #define VSNPRINTF(str, size, fmt, a) _win_vsnprintf(str, size, fmt, a)
+ #define _REAL_SNPRINTF(str, size, fmt, ...) _win_snprintf(str, size, fmt,
__VA_ARGS__)
+ #define SPRINTF(d, f, ...) _win_sprintf(d, f, __VA_ARGS__)
+ #define VSSCANF(s, f, a) _win_vsscanf(s, f, a)
+ #define SSCANF(s, f, ...) _win_sscanf(s, f, __VA_ARGS__)
+ #define VFSCANF(s, f, a) _win_vfscanf(s, f, a)
+ #define VSCANF(f, a) _win_vscanf(f, a)
+ #define SCANF(f, ...) _win_scanf(f, __VA_ARGS__)
+ #define FSCANF(s, f, ...) _win_fscanf(s, f, __VA_ARGS__)
+ #define ACCEPT(s, a, l) _win_accept(s, a, l)
+ #define BIND(s, n, l) _win_bind(s, n, l)
+ #define CONNECT(s, n, l) _win_connect(s, n, l)
+ #define GETPEERNAME(s, n, l) _win_getpeername(s, n, l)
+ #define GETSOCKNAME(s, n, l) _win_getsockname(s, n, l)
+ #define GETSOCKOPT(s, l, o, v, p) _win_getsockopt(s, l, o, v, p)
+ #define LISTEN(s, b) _win_listen(s, b)
+ #define RECV(s, b, l, f) _win_recv(s, b, l, f)
+ #define RECVFROM(s, b, l, f, r, o) _win_recvfrom(s, b, l, f, r, o)
+ #define SELECT(n, r, w, e, t) _win_select(n, r, w, e, t)
+ #define SEND(s, b, l, f) _win_send(s, b, l, f)
+ #define SENDTO(s, b, l, f, o, n) _win_sendto(s, b, l, f, o, n)
+ #define SETSOCKOPT(s, l, o, v, n) _win_setsockopt(s, l, o, v, n)
+ #define SHUTDOWN(s, h) _win_shutdown(s, h)
+ #define SOCKET(a, t, p) _win_socket(a, t, p)
+ #define GETHOSTBYADDR(a, l, t) _win_gethostbyname(a, l, t)
+ #define GETHOSTBYNAME(n) _win_gethostbyname(n)
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif //_PLIBC_H_
+
+/* end of plibc.h */
Modified: Extractor/src/include/winproc.h
===================================================================
--- Extractor/src/include/winproc.h 2005-05-01 13:28:40 UTC (rev 713)
+++ Extractor/src/include/winproc.h 2005-05-01 13:28:48 UTC (rev 714)
@@ -1,6 +1,6 @@
/*
This file is part of libextractor.
- (C) 2001 - 2005 Christian Grothoff (and other contributing authors)
+ (C) 2001, 2002, 2003, 2003, 2005 Christian Grothoff (and other
contributing authors)
libextractor is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -19,340 +19,26 @@
*/
/**
- * @file util/winproc.h
+ * @file include/winproc.h
* @brief Definitions for MS Windows
* @author Nils Durner
+ * @note This file differs from GNUnet's winproc.h
*/
-/*** Note: this file differs from GNUnet's winproc.h **/
-
#ifndef WINPROC_H
#define WINPROC_H
-#include <io.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/timeb.h>
-#include <time.h>
-#include <dirent.h>
-#include <windows.h>
-#include <winsock.h>
-#include <winerror.h>
-#include <iphlpapi.h>
#include "platform.h"
#ifdef __cplusplus
extern "C" {
#endif
-/* Conflicts with our definitions */
-#define __G_WIN32_H__
-
-/* Convert LARGE_INTEGER to double */
-#define Li2Double(x) ((double)((x).HighPart) * 4.294967296E9 + \
- (double)((x).LowPart))
-
-#define socklen_t int
-#define ssize_t int
-#define ftruncate chsize
-#define off_t int
-
-/* Thanks to the Cygwin project */
-#define EPERM 1 /* Not super-user */
-#define ENOENT 2 /* No such file or directory */
-#define ESRCH 3 /* No such process */
-#define EINTR 4 /* Interrupted system call */
-#define EIO 5 /* I/O error */
-#define ENXIO 6 /* No such device or address */
-#define E2BIG 7 /* Arg list too long */
-#define ENOEXEC 8 /* Exec format error */
-#define EBADF 9 /* Bad file number */
-#define ECHILD 10 /* No children */
-#define EAGAIN 11 /* Resource unavailable or operation would block, try
again */
-#define ENOMEM 12 /* Not enough memory */
-#define EACCES 13 /* Permission denied */
-#define EFAULT 14 /* Bad address */
-#define ENOTBLK 15 /* Block device required */
-#define EBUSY 16 /* Mount device busy */
-#define EEXIST 17 /* File exists */
-#define EXDEV 18 /* Cross-device link */
-#define ENODEV 19 /* No such device */
-#define ENOTDIR 20 /* Not a directory */
-#define EISDIR 21 /* Is a directory */
-#define EINVAL 22 /* Invalid argument */
-#define ENFILE 23 /* Too many open files in system */
-#define EMFILE 24 /* Too many open files */
-#define ENOTTY 25 /* Not a typewriter */
-#define ETXTBSY 26 /* Text file busy */
-#define EFBIG 27 /* File too large */
-#define ENOSPC 28 /* No space left on device */
-#define ESPIPE 29 /* Illegal seek */
-#define EROFS 30 /* Read only file system */
-#define EMLINK 31 /* Too many links */
-#define EPIPE 32 /* Broken pipe */
-#define EDOM 33 /* Math arg out of domain of func */
-#define ERANGE 34 /* Math result not representable */
-#define ENOMSG 35 /* No message of desired type */
-#define EIDRM 36 /* Identifier removed */
-#define ECHRNG 37 /* Channel number out of range */
-#define EL2NSYNC 38 /* Level 2 not synchronized */
-#define L3HLT 39 /* Level 3 halted */
-#define EL3RST 40 /* Level 3 reset */
-#define ELNRNG 41 /* Link number out of range */
-#define EUNATCH 42 /* Protocol driver not attached */
-#define ENOCSI 43 /* No CSI structure available */
-#define EL2HLT 44 /* Level 2 halted */
-#undef EDEADLK
-#define EDEADLK 45 /* Deadlock condition */
-#undef ENOLCK
-#define ENOLCK 46 /* No record locks available */
-#define EBADE 50 /* Invalid exchange */
-#define EBADR 51 /* Invalid request descriptor */
-#define EXFULL 52 /* Exchange full */
-#define ENOANO 53 /* No anode */
-#define EBADRQC 54 /* Invalid request code */
-#define EBADSLT 55 /* Invalid slot */
-#undef EDEADLOCK
-#define EDEADLOCK 56 /* File locking deadlock error */
-#define EBFONT 57 /* Bad font file fmt */
-#define ENOSTR 60 /* Device not a stream */
-#define ENODATA 61 /* No data (for no delay io) */
-#define ETIME 62 /* Timer expired */
-#define ENOSR 63 /* Out of streams resources */
-#define ENONET 64 /* Machine is not on the network */
-#define ENOPKG 65 /* Package not installed */
-#define EREMOTE 66 /* The object is remote */
-#define ENOLINK 67 /* The link has been severed */
-#define EADV 68 /* Advertise error */
-#define ESRMNT 69 /* Srmount error */
-#define ECOMM 70 /* Communication error on send */
-#define EPROTO 71 /* Protocol error */
-#define EMULTIHOP 74 /* Multihop attempted */
-#define ELBIN 75 /* Inode is remote (not really error) */
-#define EDOTDOT 76 /* Cross mount point (not really error) */
-#define EBADMSG 77 /* Trying to read unreadable message */
-#define ENOTUNIQ 80 /* Given log. name not unique */
-#define EBADFD 81 /* f.d. invalid for this operation */
-#define EREMCHG 82 /* Remote address changed */
-#define ELIBACC 83 /* Can't access a needed shared lib */
-#define ELIBBAD 84 /* Accessing a corrupted shared lib */
-#define ELIBSCN 85 /* .lib section in a.out corrupted */
-#define ELIBMAX 86 /* Attempting to link in too many libs */
-#define ELIBEXEC 87 /* Attempting to exec a shared library */
-#undef ENOSYS
-#define ENOSYS 88 /* Function not implemented */
-#define ENMFILE 89 /* No more files */
-#undef ENOTEMPTY
-#define ENOTEMPTY 90 /* Directory not empty */
-#undef ENAMETOOLONG
-#define ENAMETOOLONG 91 /* File or path name too long */
-#define ELOOP 92 /* Too many symbolic links */
-#define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */
-#define EPFNOSUPPORT 96 /* Protocol family not supported */
-#define ECONNRESET 104 /* Connection reset by peer */
-#define ENOBUFS 105 /* No buffer space available */
-#define EAFNOSUPPORT 106 /* Address family not supported by protocol family */
-#define EPROTOTYPE 107 /* Protocol wrong type for socket */
-#define ENOTSOCK 108 /* Socket operation on non-socket */
-#define ENOPROTOOPT 109 /* Protocol not available */
-#define ESHUTDOWN 110 /* Can't send after socket shutdown */
-#define ECONNREFUSED 111 /* Connection refused */
-#define EADDRINUSE 112 /* Address already in use */
-#define ECONNABORTED 113 /* Connection aborted */
-#define ENETUNREACH 114 /* Network is unreachable */
-#define ENETDOWN 115 /* Network interface is not configured */
-#undef ETIMEDOUT
-#define ETIMEDOUT 116 /* Connection timed out */
-#define EHOSTDOWN 117 /* Host is down */
-#define EHOSTUNREACH 118 /* Host is unreachable */
-#define EINPROGRESS 119 /* Connection already in progress */
-#define EALREADY 120 /* Socket already connected */
-#define EDESTADDRREQ 121 /* Destination address required */
-#define EMSGSIZE 122 /* Message too long */
-#define EPROTONOSUPPORT 123 /* Unknown protocol */
-#define ESOCKTNOSUPPORT 124 /* Socket type not supported */
-#define EADDRNOTAVAIL 125 /* Address not available */
-#define ENETRESET 126 /* Connection aborted by network */
-#define EISCONN 127 /* Socket is already connected */
-#define ENOTCONN 128 /* Socket is not connected */
-#define ETOOMANYREFS 129 /* Too many references: cannot splice */
-#define EPROCLIM 130 /* Too many processes */
-#define EUSERS 131 /* Too many users */
-#define EDQUOT 132 /* Disk quota exceeded */
-#define ESTALE 133 /* Unknown error */
-#undef ENOTSUP
-#define ENOTSUP 134 /* Not supported */
-#define ENOMEDIUM 135 /* No medium (in tape drive) */
-#define ENOSHARE 136 /* No such host or network path */
-#define ECASECLASH 137 /* Filename exists with different case */
-#define EWOULDBLOCK EAGAIN /* Operation would block */
-
-#undef HOST_NOT_FOUND
-#define HOST_NOT_FOUND 1
-#undef TRY_AGAIN
-#define TRY_AGAIN 2
-#undef NO_RECOVERY
-#define NO_RECOVERY 3
-#undef NO_ADDRESS
-#define NO_ADDRESS 4
-
-#define PROT_READ 0x1
-#define PROT_WRITE 0x2
-#define MAP_SHARED 0x1
-#define MAP_PRIVATE 0x2
-#define MAP_FIXED 0x10
-
-struct statfs
-{
- long f_type; /* type of filesystem (see below) */
- long f_bsize; /* optimal transfer block size */
- long f_blocks; /* total data blocks in file system */
- long f_bfree; /* free blocks in fs */
- long f_bavail; /* free blocks avail to non-superuser */
- long f_files; /* total file nodes in file system */
- long f_ffree; /* free file nodes in fs */
- long f_fsid; /* file system id */
- long f_namelen; /* maximum length of filenames */
- long f_spare[6]; /* spare for later */
-};
-
-/* Taken from the Wine project <http://www.winehq.org>
- /wine/include/winternl.h */
-enum SYSTEM_INFORMATION_CLASS
-{
- SystemBasicInformation = 0,
- Unknown1,
- SystemPerformanceInformation = 2,
- SystemTimeOfDayInformation = 3, /* was SystemTimeInformation */
- Unknown4,
- SystemProcessInformation = 5,
- Unknown6,
- Unknown7,
- SystemProcessorPerformanceInformation = 8,
- Unknown9,
- Unknown10,
- SystemDriverInformation,
- Unknown12,
- Unknown13,
- Unknown14,
- Unknown15,
- SystemHandleList,
- Unknown17,
- Unknown18,
- Unknown19,
- Unknown20,
- SystemCacheInformation,
- Unknown22,
- SystemInterruptInformation = 23,
- SystemExceptionInformation = 33,
- SystemRegistryQuotaInformation = 37,
- SystemLookasideInformation = 45
-};
-
-typedef struct
-{
- LARGE_INTEGER IdleTime;
- LARGE_INTEGER KernelTime;
- LARGE_INTEGER UserTime;
- LARGE_INTEGER Reserved1[2];
- ULONG Reserved2;
-} SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION;
-
-#define sleep(secs) (Sleep(secs * 1000))
-
-/*********************** statfs ****************************/
-/* fake block size */
-#define FAKED_BLOCK_SIZE 512
-
-/* linux-compatible values for fs type */
-#define MSDOS_SUPER_MAGIC 0x4d44
-#define NTFS_SUPER_MAGIC 0x5346544E
-
-/*********************** End of statfs **********************/
-
-typedef struct
-{
- SOCKET s;
- BOOL bBlocking;
-} Winsock;
-extern Winsock *pSocks;
-extern unsigned int uiSockCount;
-
-#define SHUT_RDWR SD_BOTH
-
-/* Operations for flock() */
-#define LOCK_SH 1 /* shared lock */
-#define LOCK_EX 2 /* exclusive lock */
-#define LOCK_NB 4 /* or'd with one of the above to prevent
- blocking */
-#define LOCK_UN 8 /* remove lock */
-
-/* Not supported under MinGW */
-#define S_IRGRP 0
-#define S_IWGRP 0
-
-typedef DWORD WINAPI (*TNtQuerySystemInformation) (int, PVOID, ULONG, PULONG);
-typedef DWORD WINAPI (*TGetIfEntry) (PMIB_IFROW pIfRow);
-typedef DWORD WINAPI (*TGetIpAddrTable) (PMIB_IPADDRTABLE pIpAddrTable,
- PULONG pdwSize, BOOL bOrder);
-typedef DWORD WINAPI (*TGetIfTable) (PMIB_IFTABLE pIfTable, PULONG pdwSize,
- BOOL bOrder);
-
-#define SetErrnoFromWinError(e) _SetErrnoFromWinError(e, __FILE__, __LINE__)
-
-extern TNtQuerySystemInformation GNNtQuerySystemInformation;
-extern TGetIfEntry GNGetIfEntry;
-extern TGetIpAddrTable GNGetIpAddrTable;
-extern TGetIfTable GNGetIfTable;
-
-int flock(int fd, int operation);
-int fsync(int fildes);
-int truncate(const char *fname, int distance);
-int statfs(const char *path, struct statfs *buf);
-const char *hstrerror(int err);
-void gettimeofday(struct timeval *tp, void *tzp);
-int mkstemp(char *tmplate);
void InitWinEnv();
void ShutdownWinEnv();
-int conv_to_win_path(const char *pszUnix, char *pszWindows);
-void _SetErrnoFromWinError(long lWinError, char *pszCaller, int iLine);
-void SetErrnoFromWinsockError(long lWinError);
-void SetHErrnoFromWinError(long lWinError);
-FILE *_win_fopen(const char *filename, const char *mode);
-DIR *_win_opendir(const char *dirname);
-int _win_chdir(const char *path);
-int _win_fstat(int handle, struct stat *buffer);
-int _win_pipe(int *phandles);
-int _win_rmdir(const char *path);
-int _win_access( const char *path, int mode );
-int _win_chmod(const char *filename, int pmode);
-char *realpath(const char *file_name, char *resolved_name);
-int _win_remove(const char *path);
-int _win_rename(const char *oldname, const char *newname);
-int _win_stat(const char *path, struct stat *buffer);
-int _win_unlink(const char *filename);
-int _win_write(int fildes, const void *buf, size_t nbyte);
-int _win_read(int fildes, void *buf, size_t nbyte);
-size_t _win_fwrite(const void *buffer, size_t size, size_t count, FILE
*stream);
-size_t _win_fread( void *buffer, size_t size, size_t count, FILE *stream );
-void *_win_mmap(void *start, size_t len, int access, int flags, int fd,
- unsigned long long offset);
-int _win_munmap(void *start, size_t length);
-char *_win_strerror(int errnum);
-#ifndef HAVE_LANGINFO_H
-char *nl_langinfo(int item);
-#endif
-#if !HAVE_STRNDUP
-char *strndup (const char *s, size_t n);
#endif
-#if !HAVE_STRNLEN
-size_t strnlen (const char *str, size_t maxlen);
-#endif
-#endif
-
#ifdef __cplusplus
} /* extern "C" */
#endif
Modified: Extractor/src/main/extractor.c
===================================================================
--- Extractor/src/main/extractor.c 2005-05-01 13:28:40 UTC (rev 713)
+++ Extractor/src/main/extractor.c 2005-05-01 13:28:48 UTC (rev 714)
@@ -227,8 +227,8 @@
/**
* Open a file
*/
-static int OPEN(const char *filename,
- int oflag, ...) {
+int fileopen(const char *filename, int oflag, ...)
+{
int mode;
char *fn;
@@ -236,7 +236,7 @@
char szFile[_MAX_PATH + 1];
long lRet;
- if ((lRet = conv_to_win_path(filename, szFile)) != ERROR_SUCCESS)
+ if ((lRet = plibc_conv_to_win_path(filename, szFile)) != ERROR_SUCCESS)
{
errno = ENOENT;
SetLastError(lRet);
@@ -552,9 +552,9 @@
size_t size;
#ifdef O_LARGEFILE
- file = OPEN(filename, O_RDONLY | O_LARGEFILE);
+ file = fileopen(filename, O_RDONLY | O_LARGEFILE);
#else
- file = OPEN(filename, O_RDONLY);
+ file = fileopen(filename, O_RDONLY);
#endif
if (-1 == file)
return NULL;
Modified: Extractor/src/main/winproc.c
===================================================================
--- Extractor/src/main/winproc.c 2005-05-01 13:28:40 UTC (rev 713)
+++ Extractor/src/main/winproc.c 2005-05-01 13:28:48 UTC (rev 714)
@@ -1,486 +1,41 @@
/*
- This file is part of libextractor.
- (C) 2004, 2005 Christian Grothoff (and other contributing authors)
+ This file is part of GNUnet.
+ (C) 2001, 2002, 2003, 2004, 2005 Christian Grothoff (and other
contributing authors)
- libextractor is free software; you can redistribute it and/or modify
+ GNUnet 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, or (at your
option) any later version.
- libextractor is distributed in the hope that it will be useful, but
+ GNUnet 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 libextractor; see the file COPYING. If not, write to the
+ along with GNUnet; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/**
- * @file util/winproc.c
+ * @file util/win/winproc.c
* @brief Functions for MS Windows
* @author Nils Durner
+ * @note This file differs from GNUnet's winproc.c
*/
-/*** Note: this file differs from GNUnet's winproc.c ***/
-
#include "platform.h"
-#ifdef __cplusplus
-extern "C" {
-#endif
+#ifdef MINGW
-const char *errlist[] = {
- gettext_noop("No error"),
- gettext_noop("Unknown host"), /* 1 HOST_NOT_FOUND */
- gettext_noop("Host name lookup failure"), /* 2 TRY_AGAIN */
- gettext_noop("Unknown server error"), /* 3 NO_RECOVERY */
- gettext_noop("No address associated with name"), /* 4 NO_ADDRESS */
- gettext_noop("Internal resolver error"), /* errno < 0 */
- gettext_noop("Unknown resolver error") /* errno > 4 */
-};
-
-typedef struct {
- char *pStart;
- HANDLE hMapping;
-} TMapping;
-
-static char szRootDir[_MAX_PATH + 1];
-static long lRootDirLen;
-static char szHomeDir[_MAX_PATH + 2];
-static long lHomeDirLen;
-static char szUser[261];
-static OSVERSIONINFO theWinVersion;
-unsigned int uiSockCount = 0;
-Winsock *pSocks;
-static char __langinfo[251];
-static unsigned int uiMappingsCount = 0;
-static TMapping *pMappings;
-HANDLE hMappingsLock;
-
-static HINSTANCE hNTDLL, hIphlpapi;
-TNtQuerySystemInformation GNNtQuerySystemInformation;
-TGetIfEntry GNGetIfEntry;
-TGetIpAddrTable GNGetIpAddrTable;
-TGetIfTable GNGetIfTable;
-
/**
- * @author Prof. A Olowofoyeku (The African Chief)
- * @author Frank Heckenbach
- * source: http://gd.tuwien.ac.at/gnu/mingw/os-hacks.h
- */
-
-int truncate(const char *fname, int distance)
-{
- int i;
- HANDLE hFile;
-
- i = -1;
- hFile = CreateFile(fname, GENERIC_READ | GENERIC_WRITE,
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL, OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, NULL);
- if(hFile != INVALID_HANDLE_VALUE)
- {
- if(SetFilePointer(hFile, distance, NULL, FILE_BEGIN) != 0xFFFFFFFF)
- {
- if(SetEndOfFile(hFile))
- i = 0;
- }
- CloseHandle(hFile);
- }
- return i;
-}
-
-/*********************** statfs ****************************/
-
-/**
- * @author Prof. A Olowofoyeku (The African Chief)
- * @author Frank Heckenbach
- * source: http://gd.tuwien.ac.at/gnu/mingw/os-hacks.h
- */
-
-int statfs(const char *path, struct statfs *buf)
-{
- HINSTANCE h;
- FARPROC f;
- char tmp[MAX_PATH], resolved_path[MAX_PATH];
- int retval = 0;
-
- realpath(path, resolved_path);
- if(!resolved_path)
- retval = -1;
- else
- {
- /* check whether GetDiskFreeSpaceExA is supported */
- h = LoadLibraryA("kernel32.dll");
- if(h)
- f = GetProcAddress(h, "GetDiskFreeSpaceExA");
- else
- f = NULL;
- if(f)
- {
- ULARGE_INTEGER bytes_free, bytes_total, bytes_free2;
- if(!f(resolved_path, &bytes_free2, &bytes_total, &bytes_free))
- {
- errno = ENOENT;
- retval = -1;
- }
- else
- {
- buf->f_bsize = FAKED_BLOCK_SIZE;
- buf->f_bfree = (bytes_free.QuadPart) / FAKED_BLOCK_SIZE;
- buf->f_files = buf->f_blocks =
- (bytes_total.QuadPart) / FAKED_BLOCK_SIZE;
- buf->f_ffree = buf->f_bavail =
- (bytes_free2.QuadPart) / FAKED_BLOCK_SIZE;
- }
- }
- else
- {
- DWORD sectors_per_cluster, bytes_per_sector;
- if(h)
- FreeLibrary(h);
- if(!GetDiskFreeSpaceA(resolved_path, §ors_per_cluster,
- &bytes_per_sector, &buf->f_bavail,
- &buf->f_blocks))
- {
- errno = ENOENT;
- retval = -1;
- }
- else
- {
- buf->f_bsize = sectors_per_cluster * bytes_per_sector;
- buf->f_files = buf->f_blocks;
- buf->f_ffree = buf->f_bavail;
- buf->f_bfree = buf->f_bavail;
- }
- }
- if(h)
- FreeLibrary(h);
- }
-
- /* get the FS volume information */
- if(strspn(":", resolved_path) > 0)
- resolved_path[3] = '\0'; /* we want only the root */
- if(GetVolumeInformation
- (resolved_path, NULL, 0, &buf->f_fsid, &buf->f_namelen, NULL, tmp,
- MAX_PATH))
- {
- if(strcasecmp("NTFS", tmp) == 0)
- {
- buf->f_type = NTFS_SUPER_MAGIC;
- }
- else
- {
- buf->f_type = MSDOS_SUPER_MAGIC;
- }
- }
- else
- {
- errno = ENOENT;
- retval = -1;
- }
- return retval;
-}
-
-/*********************** End of statfs **********************/
-
-const char *hstrerror(int err)
-{
- if(err < 0)
- err = 5;
- else if(err > 4)
- err = 6;
-
- return _(errlist[err]);
-}
-
-void gettimeofday(struct timeval *tp, void *tzp)
-{
- struct _timeb theTime;
-
- _ftime(&theTime);
- tp->tv_sec = theTime.time;
- tp->tv_usec = theTime.millitm * 1000;
-}
-
-int mkstemp(char *tmplate)
-{
- static const char letters[]
- = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
- int iLen, iRnd;
- char *pChr;
- char szDest[_MAX_PATH + 1];
-
- iLen = strlen(tmplate);
- if(iLen >= 6)
- {
- pChr = tmplate + iLen - 6;
- srand((unsigned int) time(NULL));
-
- if(strncmp(pChr, "XXXXXX", 6) == 0)
- {
- int iChr;
- for(iChr = 0; iChr < 6; iChr++)
- {
- /* 528.5 = RAND_MAX / letters */
- iRnd = rand() / 528.5;
- *(pChr++) = letters[iRnd > 0 ? iRnd - 1 : 0];
- }
- }
- else
- {
- errno = EINVAL;
- return -1;
- }
- }
- else
- {
- errno = EINVAL;
- return -1;
- }
-
- conv_to_win_path(tmplate, szDest);
-
- return _open(szDest, _O_CREAT | _O_EXCL, _S_IREAD | _S_IWRITE);
-}
-
-/*********************** posix path -> win path ****************************/
-
-/**
- * Get information from the Windows registry
- * @param hMainKey handle to (main-)key to query (HKEY_LOCAL_MACHINE etc.)
- * @param pszKey name of key to query
- * @param pszSubKey name of subkey to query
- * @param pszBuffer buffer for returned string
- * @param pdLength receives size of returned string
+ * Initialize PlibC and set up Windows environment
* @return Error code from winerror.h, ERROR_SUCCESS on success
- */
-long QueryRegistry(HKEY hMainKey, char *pszKey, char *pszSubKey,
- char *pszBuffer, long *pdLength)
-{
- HKEY hKey;
- long lRet;
-
- if((lRet = RegOpenKeyEx(hMainKey, pszKey, 0, KEY_EXECUTE, &hKey)) ==
- ERROR_SUCCESS)
- {
- lRet = RegQueryValueEx(hKey, pszSubKey, 0, NULL, pszBuffer, pdLength);
-
- RegCloseKey(hKey);
- }
-
- return lRet;
-}
-
-/**
- * Determine the Windows path of our / directory
- * @return Error code from winerror.h, ERROR_SUCCESS on success
- */
-long DetermineRootDir()
-{
- char szModule[_MAX_PATH], szDrv[_MAX_DRIVE], szDir[_MAX_DIR];
- long lDirLen;
-
- /* Get the path of the calling module.
- It should be located in one of the "bin" directories */
- GetModuleFileName(NULL, szModule, MAX_PATH);
- _splitpath(szModule, szDrv, szDir, NULL, NULL);
-
- lDirLen = strlen(szDir);
-
- if(stricmp(szDir + lDirLen - 15, "\\usr\\local\\bin\\") == 0)
- szDir[lDirLen -= 14] = 0;
- /* "\\local\\bin" is right, "/usr" points to "/" under MinGW */
- else if(stricmp(szDir + lDirLen - 11, "\\local\\bin\\") == 0)
- szDir[lDirLen -= 10] = 0;
- else if(stricmp(szDir + lDirLen - 9, "\\usr\\bin\\") == 0)
- szDir[lDirLen -= 8] = 0;
- else if(stricmp(szDir + lDirLen - 5, "\\bin\\") == 0)
- szDir[lDirLen -= 4] = 0;
- else
- {
- /* Get the installation path from the registry */
- lDirLen = _MAX_PATH - 1;
-
- if(QueryRegistry
- (HKEY_CURRENT_USER, "Software\\GNU\\libextractor", "InstallDir",
- szRootDir, &lDirLen) != ERROR_SUCCESS)
- {
- lDirLen = _MAX_PATH - 1;
-
- if(QueryRegistry
- (HKEY_LOCAL_MACHINE, "Software\\GNU\\libextractor", "InstallDir",
- szRootDir, &lDirLen) != ERROR_SUCCESS)
- {
- return ERROR_BAD_ENVIRONMENT;
- }
- }
- strcat(szRootDir, "\\");
- lRootDirLen = lDirLen;
- szDrv[0] = 0;
- }
-
- if(szDrv[0])
- {
- strcpy(szRootDir, szDrv);
- lRootDirLen = 3 + lDirLen - 1; /* 3 = strlen(szDir) */
- if(lRootDirLen > _MAX_PATH)
- return ERROR_BUFFER_OVERFLOW;
-
- strcat(szRootDir, szDir);
- }
-
- return ERROR_SUCCESS;
-}
-
-/**
- * Determine the user's home directory
- * @return Error code from winerror.h, ERROR_SUCCESS on success
*/
-long DetermineHomeDir()
-{
- char *lpszProfile = getenv("USERPROFILE");
- if(lpszProfile != NULL && lpszProfile[0] != 0) /* Windows NT */
- {
- lHomeDirLen = strlen(lpszProfile);
- if(lHomeDirLen + 1 > _MAX_PATH)
- return ERROR_BUFFER_OVERFLOW;
-
- strcpy(szHomeDir, lpszProfile);
- if(szHomeDir[lHomeDirLen - 1] != '\\')
- {
- szHomeDir[lHomeDirLen] = '\\';
- szHomeDir[++lHomeDirLen] = 0;
- }
- }
- else
- {
- /* C:\My Documents */
- long lRet;
-
- lHomeDirLen = _MAX_PATH;
- lRet = QueryRegistry(HKEY_CURRENT_USER,
- "Software\\Microsoft\\Windows\\CurrentVersion\\"
- "Explorer\\Shell Folders",
- "Personal", szHomeDir, &lHomeDirLen);
-
- if(lRet == ERROR_BUFFER_OVERFLOW)
- return ERROR_BUFFER_OVERFLOW;
- else if(lRet == ERROR_SUCCESS)
- lHomeDirLen--;
- else
- {
- /* C:\Program Files\GNUnet\home\... */
- /* 5 = strlen("home\\") */
- lHomeDirLen = strlen(szRootDir) + strlen(szUser) + 5 + 1;
-
- if(_MAX_PATH < lHomeDirLen)
- return ERROR_BUFFER_OVERFLOW;
-
- strcpy(szHomeDir, szRootDir);
- strcat(szHomeDir, szUser);
- strcat(szHomeDir, "\\");
- }
- }
-
- return ERROR_SUCCESS;
-}
-
-/**
- * Initialize POSIX emulation and set up Windows environment
- * @return Error code from winerror.h, ERROR_SUCCESS on success
-*/
void InitWinEnv()
{
- long lRet;
- enum {ROOT, USER, HOME} eAction = ROOT;
-
- /* Init path translation */
- if((lRet = DetermineRootDir()) == ERROR_SUCCESS)
- {
- DWORD dwSize = 261;
-
- GetUserName(szUser, &dwSize);
-
- eAction = HOME;
- lRet = DetermineHomeDir();
- }
-
- if(lRet != ERROR_SUCCESS)
- {
- char *pszMsg, *pszMsg2;
-
- lRet =
- FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS, NULL, lRet, 0,
- (LPTSTR) & pszMsg, 0, NULL);
-
- pszMsg2 = (char *) malloc(lRet + 1);
- strcpy(pszMsg2, pszMsg);
- if(pszMsg2[lRet - 2] == '\r')
- pszMsg2[lRet - 2] = 0;
-
- fprintf(stderr,
- eAction == ROOT
- ? _("Cannot determine root directory (%s)\n")
- : _("Cannot determine home directory (%s)\n"),
- pszMsg2);
- LocalFree(pszMsg);
- free(pszMsg2);
-
- exit(1);
- }
-
- /* To keep track of mapped files */
- pMappings = (TMapping *) malloc(sizeof(TMapping));
- pMappings[0].pStart = NULL;
- hMappingsLock = CreateMutex(NULL, FALSE, NULL);
-
- /* Open files in binary mode */
- _fmode = _O_BINARY;
-
- /* Get Windows version */
- theWinVersion.dwOSVersionInfoSize = sizeof(theWinVersion);
- GetVersionEx(&theWinVersion);
-
- hNTDLL = LoadLibrary("ntdll.dll");
-
- /* Function to get CPU usage under Win NT */
- if (hNTDLL)
- {
- GNNtQuerySystemInformation = (TNtQuerySystemInformation)
- GetProcAddress(hNTDLL, "NtQuerySystemInformation");
- }
- else
- {
- GNNtQuerySystemInformation = NULL;
- }
-
- /* Functions to get information about a network adapter */
- hIphlpapi = LoadLibrary("iphlpapi.dll");
- if (hIphlpapi)
- {
- GNGetIfEntry = (TGetIfEntry) GetProcAddress(hIphlpapi, "GetIfEntry");
- GNGetIpAddrTable = (TGetIpAddrTable) GetProcAddress(hIphlpapi,
- "GetIpAddrTable");
- GNGetIfTable = (TGetIfTable) GetProcAddress(hIphlpapi, "GetIfTable");
- }
- else
- {
- GNGetIfEntry = NULL;
- GNGetIpAddrTable = NULL;
- GNGetIfTable = NULL;
- }
-
- /* Use ANSI codepage for console IO */
- SetConsoleCP(CP_ACP);
- SetConsoleOutputCP(CP_ACP);
- setlocale( LC_ALL, ".OCP" );
+ plibc_init("GNU", PACKAGE);
}
/**
@@ -488,1917 +43,9 @@
*/
void ShutdownWinEnv()
{
- free(pMappings);
- CloseHandle(hMappingsLock);
-
- FreeLibrary(hNTDLL);
- FreeLibrary(hIphlpapi);
+ plibc_shutdown();
}
-/**
- * Convert a POSIX-sytle path to a Windows-style path
- * @param pszUnix POSIX path
- * @param pszWindows Windows path
- * @return Error code from winerror.h, ERROR_SUCCESS on success
-*/
-int conv_to_win_path(const char *pszUnix, char *pszWindows)
-{
- char *pSrc, *pDest;
- long iSpaceUsed;
+#endif /* MINGW */
- /* Check if we already have a windows path */
- if((strchr(pszUnix, '\\') != NULL) || (strchr(pszUnix, ':') != NULL))
- {
- if(strlen(pszUnix) > MAX_PATH)
- return ERROR_BUFFER_OVERFLOW;
- strcpy(pszWindows, pszUnix);
- }
-
- /* Is the unix path a full path? */
- if(pszUnix[0] == '/')
- {
- strcpy(pszWindows, szRootDir);
- iSpaceUsed = lRootDirLen;
- pDest = pszWindows + lRootDirLen;
- pSrc = (char *) pszUnix + 1;
- }
- /* Temp. dir? */
- else if(strncmp(pszUnix, "/tmp/", 5) == 0)
- {
- iSpaceUsed = GetTempPath(_MAX_PATH, pszWindows);
- if (iSpaceUsed > _MAX_PATH)
- return ERROR_BUFFER_OVERFLOW;
- pDest = pszWindows + iSpaceUsed;
- pSrc = (char *) pszUnix + 5;
- }
- /* Home dir? */
- else if(strncmp(pszUnix, "~/", 2) == 0)
- {
- strcpy(pszWindows, szHomeDir);
- iSpaceUsed = lHomeDirLen;
- pDest = pszWindows + lHomeDirLen;
- pSrc = (char *) pszUnix + 2;
- }
- /* Bit bucket? */
- else if (strncmp(pszUnix, "/dev/null", 9) == 0)
- {
- strcpy(pszWindows, "nul");
- iSpaceUsed = 3;
- pDest = pszWindows + lHomeDirLen;
- pSrc = (char *) pszUnix + 9;
- }
- else
- {
- pDest = pszWindows;
- iSpaceUsed = 0;
- pSrc = (char *) pszUnix;
- }
-
- if(iSpaceUsed + strlen(pSrc) + 1 > _MAX_PATH)
- return ERROR_BUFFER_OVERFLOW;
-
- /* substitute all slashes */
- while(*pSrc)
- {
- if(*pSrc == '/')
- *pDest = '\\';
- else
- *pDest = *pSrc;
-
- pDest++;
- pSrc++;
- }
- *pDest = 0;
-
- return ERROR_SUCCESS;
-}
-
-/*********************** posix path -> win path ****************************/
-
-/**
- * Set errno according to a Windows error
- * @param lWinError Error code defined in winerror.h
- */
-void _SetErrnoFromWinError(long lWinError, char *pszCaller, int iLine)
-{
- switch(lWinError)
- {
- case ERROR_SUCCESS:
- errno = 0;
- break;
-
- case ERROR_INVALID_FUNCTION:
- errno = EBADRQC;
- break;
-
- case ERROR_FILE_NOT_FOUND:
- errno = ENOENT;
- break;
-
- case ERROR_PATH_NOT_FOUND:
- errno = ENOENT;
- break;
-
- case ERROR_TOO_MANY_OPEN_FILES:
- errno = EMFILE;
- break;
-
- case ERROR_ACCESS_DENIED:
- errno = EACCES;
- break;
-
- case ERROR_INVALID_HANDLE:
- errno = EBADF;
- break;
-
- case ERROR_NOT_ENOUGH_MEMORY:
- errno = ENOMEM;
- break;
-
- case ERROR_INVALID_DATA:
- errno = EINVAL;
- break;
-
- case ERROR_OUTOFMEMORY:
- errno = ENOMEM;
- break;
-
- case ERROR_INVALID_DRIVE:
- errno = ENODEV;
- break;
-
- case ERROR_NOT_SAME_DEVICE:
- errno = EXDEV;
- break;
-
- case ERROR_NO_MORE_FILES:
- errno = ENMFILE;
- break;
-
- case ERROR_WRITE_PROTECT:
- errno = EROFS;
- break;
-
- case ERROR_BAD_UNIT:
- errno = ENODEV;
- break;
-
- case ERROR_SHARING_VIOLATION:
- errno = EACCES;
- break;
-
- case ERROR_LOCK_VIOLATION:
- errno = EACCES;
- break;
-
- case ERROR_SHARING_BUFFER_EXCEEDED:
- errno = ENOLCK;
- break;
-
- case ERROR_HANDLE_EOF:
- errno = ENODATA;
- break;
-
- case ERROR_HANDLE_DISK_FULL:
- errno = ENOSPC;
- break;
-
- case ERROR_NOT_SUPPORTED:
- errno = ENOSYS;
- break;
-
- case ERROR_REM_NOT_LIST:
- errno = ENONET;
- break;
-
- case ERROR_DUP_NAME:
- errno = ENOTUNIQ;
- break;
-
- case ERROR_BAD_NETPATH:
- errno = ENOSHARE;
- break;
-
- case ERROR_BAD_NET_NAME:
- errno = ENOSHARE;
- break;
-
- case ERROR_FILE_EXISTS:
- errno = EEXIST;
- break;
-
- case ERROR_CANNOT_MAKE:
- errno = EPERM;
- break;
-
- case ERROR_INVALID_PARAMETER:
- errno = EINVAL;
- break;
-
- case ERROR_NO_PROC_SLOTS:
- errno = EAGAIN;
- break;
-
- case ERROR_BROKEN_PIPE:
- errno = EPIPE;
- break;
-
- case ERROR_OPEN_FAILED:
- errno = EIO;
- break;
-
- case ERROR_NO_MORE_SEARCH_HANDLES:
- errno = ENFILE;
- break;
-
- case ERROR_CALL_NOT_IMPLEMENTED:
- errno = ENOSYS;
- break;
-
- case ERROR_INVALID_NAME:
- errno = ENOENT;
- break;
-
- case ERROR_WAIT_NO_CHILDREN:
- errno = ECHILD;
- break;
-
- case ERROR_CHILD_NOT_COMPLETE:
- errno = EBUSY;
- break;
-
- case ERROR_DIR_NOT_EMPTY:
- errno = ENOTEMPTY;
- break;
-
- case ERROR_SIGNAL_REFUSED:
- errno = EIO;
- break;
-
- case ERROR_BAD_PATHNAME:
- errno = ENOENT;
- break;
-
- case ERROR_SIGNAL_PENDING:
- errno = EBUSY;
- break;
-
- case ERROR_MAX_THRDS_REACHED:
- errno = EAGAIN;
- break;
-
- case ERROR_BUSY:
- errno = EBUSY;
- break;
-
- case ERROR_ALREADY_EXISTS:
- errno = EEXIST;
- break;
-
- case ERROR_NO_SIGNAL_SENT:
- errno = EIO;
- break;
-
- case ERROR_FILENAME_EXCED_RANGE:
- errno = EINVAL;
- break;
-
- case ERROR_META_EXPANSION_TOO_LONG:
- errno = EINVAL;
- break;
-
- case ERROR_INVALID_SIGNAL_NUMBER:
- errno = EINVAL;
- break;
-
- case ERROR_THREAD_1_INACTIVE:
- errno = EINVAL;
- break;
-
- case ERROR_BAD_PIPE:
- errno = EINVAL;
- break;
-
- case ERROR_PIPE_BUSY:
- errno = EBUSY;
- break;
-
- case ERROR_NO_DATA:
- errno = EPIPE;
- break;
-
- case ERROR_PIPE_NOT_CONNECTED:
- errno = ECOMM;
- break;
-
- case ERROR_MORE_DATA:
- errno = EAGAIN;
- break;
-
- case ERROR_DIRECTORY:
- errno = ENOTDIR;
- break;
-
- case ERROR_PIPE_CONNECTED:
- errno = EBUSY;
- break;
-
- case ERROR_PIPE_LISTENING:
- errno = ECOMM;
- break;
-
- case ERROR_NO_TOKEN:
- errno = EINVAL;
- break;
-
- case ERROR_PROCESS_ABORTED:
- errno = EFAULT;
- break;
-
- case ERROR_BAD_DEVICE:
- errno = ENODEV;
- break;
-
- case ERROR_BAD_USERNAME:
- errno = EINVAL;
- break;
-
- case ERROR_NOT_CONNECTED:
- errno = ENOLINK;
- break;
-
- case ERROR_OPEN_FILES:
- errno = EAGAIN;
- break;
-
- case ERROR_ACTIVE_CONNECTIONS:
- errno = EAGAIN;
- break;
-
- case ERROR_DEVICE_IN_USE:
- errno = EAGAIN;
- break;
-
- case ERROR_INVALID_AT_INTERRUPT_TIME:
- errno = EINTR;
- break;
-
- case ERROR_IO_DEVICE:
- errno = EIO;
- break;
-
- case ERROR_NOT_OWNER:
- errno = EPERM;
- break;
-
- case ERROR_END_OF_MEDIA:
- errno = ENOSPC;
- break;
-
- case ERROR_EOM_OVERFLOW:
- errno = ENOSPC;
- break;
-
- case ERROR_BEGINNING_OF_MEDIA:
- errno = ESPIPE;
- break;
-
- case ERROR_SETMARK_DETECTED:
- errno = ESPIPE;
- break;
-
- case ERROR_NO_DATA_DETECTED:
- errno = ENOSPC;
- break;
-
- case ERROR_POSSIBLE_DEADLOCK:
- errno = EDEADLOCK;
- break;
-
- case ERROR_CRC:
- errno = EIO;
- break;
-
- case ERROR_NEGATIVE_SEEK:
- errno = EINVAL;
- break;
-
- case ERROR_NOT_READY:
- errno = ENOMEDIUM;
- break;
-
- case ERROR_DISK_FULL:
- errno = ENOSPC;
- break;
-
- case ERROR_NOACCESS:
- errno = EFAULT;
- break;
-
- case ERROR_FILE_INVALID:
- errno = ENXIO;
- break;
-
- case ERROR_INVALID_ADDRESS:
- errno = EFAULT;
- break;
-
- case ERROR_BUFFER_OVERFLOW:
- errno = ENOMEM;
- break;
-
- default:
- errno = ESTALE;
- fprintf(stderr, "ERROR: Unknown error %i in SetErrnoFromWinError(). " \
- "Source: %s:%i\n", lWinError, pszCaller, iLine);
- break;
- }
-}
-
-/**
- * Apply or remove an advisory lock on an open file
- */
-int flock(int fd, int operation)
-{
- DWORD dwFlags;
- HANDLE hFile;
- OVERLAPPED theOvInfo;
- BOOL bRet;
-
- hFile = (HANDLE) _get_osfhandle(fd);
- memset(&theOvInfo, 0, sizeof(OVERLAPPED));
-
- /* Don't deadlock ourselves */
- if (theWinVersion.dwPlatformId == VER_PLATFORM_WIN32_NT)
- bRet = UnlockFileEx(hFile, 0, 1, 0, &theOvInfo);
- else
- bRet = UnlockFile(hFile, 0, 0, 1, 0);
-
- if (operation & LOCK_UN)
- {
- if (!bRet && ((dwFlags = GetLastError()) != ERROR_NOT_LOCKED))
- {
- SetErrnoFromWinError(dwFlags);
- return -1;
- }
- else
- return 0;
- }
-
- if (operation & LOCK_EX)
- {
- dwFlags = LOCKFILE_EXCLUSIVE_LOCK;
- }
- else if (operation & LOCK_SH)
- {
- dwFlags = 0;
- }
- else
- {
- errno = EINVAL;
- return -1;
- }
-
- if (operation & LOCK_NB)
- dwFlags |= LOCKFILE_FAIL_IMMEDIATELY;
-
- if (theWinVersion.dwPlatformId == VER_PLATFORM_WIN32_NT)
- bRet = LockFileEx(hFile, dwFlags, 0, 1, 0, &theOvInfo);
- else
- bRet = LockFile(hFile, 0, 0, 1, 0);
-
- if (! bRet)
- {
- SetErrnoFromWinError(GetLastError());
- return -1;
- }
- else
- return 0;
-}
-
-/**
- * Synchronize changes to a file
- */
-int fsync(int fildes)
-{
- if (!FlushFileBuffers((HANDLE) _get_osfhandle(fildes)))
- {
- SetErrnoFromWinError(GetLastError());
- return -1;
- }
- else
- return 0;
-}
-
-/**
- * Open a file
- */
-FILE *_win_fopen(const char *filename, const char *mode)
-{
- char szFile[_MAX_PATH + 1];
- if (conv_to_win_path(filename, szFile) != ERROR_SUCCESS)
- {
- return NULL;
- }
-
- return fopen(szFile, mode);
-}
-
-/**
- * Open a directory
- */
-DIR *_win_opendir(const char *dirname)
-{
- char szDir[_MAX_PATH + 1];
- long lRet;
-
- if ((lRet = conv_to_win_path(dirname, szDir)) != ERROR_SUCCESS)
- {
- SetErrnoFromWinError(lRet);
- return NULL;
- }
-
- return opendir(szDir);
-}
-
-/**
- * Change directory
- */
-int _win_chdir(const char *path)
-{
- char szDir[_MAX_PATH + 1];
- long lRet;
-
- if ((lRet = conv_to_win_path(path, szDir)) != ERROR_SUCCESS)
- {
- SetErrnoFromWinError(lRet);
- return -1;
- }
-
- return chdir(szDir);
-}
-
-/**
- * Get information about an open file.
- */
-int _win_fstat(int handle, struct stat *buffer)
-{
- /* File */
- if (fstat(handle, buffer) == -1)
- {
- /* We just check for a valid handle here */
-
- /* Handle */
- memset(buffer, sizeof(struct stat), 0);
- GetFileType(handle);
- if (GetLastError() != NO_ERROR)
- {
- /* Invalid handle */
- return -1;
- }
- }
-
- return 0;
-}
-
-/**
- * Remove directory
- */
-int _win_rmdir(const char *path)
-{
- char szDir[_MAX_PATH + 1];
- long lRet;
-
- if ((lRet = conv_to_win_path(path, szDir)) != ERROR_SUCCESS)
- {
- SetErrnoFromWinError(lRet);
- return -1;
- }
-
- return rmdir(szDir);
-}
-
-/**
- * Create a pipe for reading and writing
- */
-int _win_pipe(int *phandles)
-{
- if (!CreatePipe((HANDLE *) &phandles[0],(HANDLE *) &phandles[1], NULL, 0))
- {
- SetErrnoFromWinError(GetLastError());
-
- return -1;
- }
- else
- {
- return 0;
- }
-}
-
-/**
- * map files into memory
- * @author Cygwin team
- * @author Nils Durner
- */
-void *_win_mmap(void *start, size_t len, int access, int flags, int fd,
- unsigned long long off) {
- DWORD protect, high, low, access_param;
- HANDLE h, hFile;
- SECURITY_ATTRIBUTES sec_none;
- void *base;
- BOOL bFound = FALSE;
- unsigned int uiIndex;
-
- errno = 0;
-
- switch(access)
- {
- case PROT_WRITE:
- protect = PAGE_READWRITE;
- access_param = FILE_MAP_WRITE;
- break;
- case PROT_READ:
- protect = PAGE_READONLY;
- access_param = FILE_MAP_READ;
- break;
- default:
- protect = PAGE_WRITECOPY;
- access_param = FILE_MAP_COPY;
- break;
- }
-
- sec_none.nLength = sizeof(SECURITY_ATTRIBUTES);
- sec_none.bInheritHandle = TRUE;
- sec_none.lpSecurityDescriptor = NULL;
-
- hFile = (HANDLE) _get_osfhandle(fd);
-
- h = CreateFileMapping(hFile, &sec_none, protect, 0, 0, NULL);
-
- if (! h)
- {
- SetErrnoFromWinError(GetLastError());
- return (void *) -1;
- }
-
- high = off >> 32;
- low = off & ULONG_MAX;
- base = NULL;
-
- /* If a non-zero start is given, try mapping using the given address first.
- If it fails and flags is not MAP_FIXED, try again with NULL address. */
- if (start)
- base = MapViewOfFileEx(h, access_param, high, low, len, start);
- if (!base && !(flags & MAP_FIXED))
- base = MapViewOfFileEx(h, access_param, high, low, len, NULL);
-
- if (!base || ((flags & MAP_FIXED) && base != start))
- {
- if (!base)
- SetErrnoFromWinError(GetLastError());
- else
- errno = EINVAL;
-
- CloseHandle(h);
- return (void *) -1;
- }
-
- /* Save mapping handle */
- WaitForSingleObject(hMappingsLock, INFINITE);
-
- for(uiIndex = 0; uiIndex <= uiMappingsCount; uiIndex++)
- {
- if (pMappings[uiIndex].pStart == base)
- {
- bFound = 1;
- break;
- }
- }
-
- if (! bFound)
- {
- uiIndex = 0;
-
- while(TRUE)
- {
- if (pMappings[uiIndex].pStart == NULL)
- {
- pMappings[uiIndex].pStart = base;
- pMappings[uiIndex].hMapping = h;
- }
- if (uiIndex == uiMappingsCount)
- {
- uiMappingsCount++;
- pMappings = (TMapping *) realloc(pMappings, (uiMappingsCount + 1) *
sizeof(TMapping));
- pMappings[uiMappingsCount].pStart = NULL;
-
- break;
- }
- uiIndex++;
- }
- }
- ReleaseMutex(hMappingsLock);
-
- return base;
-}
-
-/**
- * Unmap files from memory
- * @author Cygwin team
- * @author Nils Durner
- */
-int _win_munmap(void *start, size_t length)
-{
- unsigned uiIndex;
- BOOL success = UnmapViewOfFile(start);
- SetErrnoFromWinError(GetLastError());
-
- if (success)
- {
- /* Release mapping handle */
- WaitForSingleObject(hMappingsLock, INFINITE);
-
- for(uiIndex = 0; uiIndex <= uiMappingsCount; uiIndex++)
- {
- if (pMappings[uiIndex].pStart == start)
- {
- success = CloseHandle(pMappings[uiIndex].hMapping);
- SetErrnoFromWinError(GetLastError());
- pMappings[uiIndex].pStart = NULL;
- pMappings[uiIndex].hMapping = NULL;
-
- break;
- }
- }
-
- ReleaseMutex(hMappingsLock);
- }
-
- return success ? 0 : -1;
-}
-
-/**
- * Determine file-access permission.
- */
-int _win_access( const char *path, int mode )
-{
- char szFile[_MAX_PATH + 1];
- long lRet;
-
- if ((lRet = conv_to_win_path(path, szFile)) != ERROR_SUCCESS)
- {
- SetErrnoFromWinError(lRet);
- return -1;
- }
-
- return access(szFile, mode);
-}
-
-/**
- * Change the file-permission settings.
- */
-int _win_chmod(const char *filename, int pmode)
-{
- char szFile[_MAX_PATH + 1];
- long lRet;
-
- if ((lRet = conv_to_win_path(filename, szFile)) != ERROR_SUCCESS)
- {
- SetErrnoFromWinError(lRet);
- return -1;
- }
-
- return access(szFile, pmode);
-}
-
-
-char *realpath(const char *file_name, char *resolved_name)
-{
- char szFile[_MAX_PATH + 1];
- long lRet;
-
- if ((lRet = conv_to_win_path(file_name, szFile)) != ERROR_SUCCESS)
- {
- SetErrnoFromWinError(lRet);
- return NULL;
- }
-
- return _fullpath(szFile, resolved_name, MAX_PATH);
-}
-
-/**
- * Delete a file
- */
-int _win_remove(const char *path)
-{
- char szFile[_MAX_PATH + 1];
- long lRet;
-
- if ((lRet = conv_to_win_path(path, szFile)) != ERROR_SUCCESS)
- {
- SetErrnoFromWinError(lRet);
- return -1;
- }
-
- return remove(szFile);
-}
-
-/**
- * Rename a file
- */
-int _win_rename(const char *oldname, const char *newname)
-{
- char szOldName[_MAX_PATH + 1];
- char szNewName[_MAX_PATH + 1];
- long lRet;
-
- if ((lRet = conv_to_win_path(oldname, szOldName)) != ERROR_SUCCESS)
- {
- SetErrnoFromWinError(lRet);
- return -1;
- }
-
- if ((lRet = conv_to_win_path(newname, szNewName)) != ERROR_SUCCESS)
- {
- SetErrnoFromWinError(lRet);
- return -1;
- }
-
- return rename(szOldName, szNewName);
-}
-
-/**
- * Get status information on a file
- */
-int _win_stat(const char *path, struct stat *buffer)
-{
- char szFile[_MAX_PATH + 1];
- long lRet;
-
- if ((lRet = conv_to_win_path(path, szFile)) != ERROR_SUCCESS)
- {
- SetErrnoFromWinError(lRet);
- return -1;
- }
-
- /* Remove trailing slash */
- lRet = strlen(szFile) - 1;
- if (szFile[lRet] == '\\')
- {
- szFile[lRet] = 0;
- }
-
- return stat(szFile, buffer);
-}
-
-/**
- * Delete a file
- */
-int _win_unlink(const char *filename)
-{
- char szFile[_MAX_PATH + 1];
- long lRet;
-
- if ((lRet = conv_to_win_path(filename, szFile)) != ERROR_SUCCESS)
- {
- SetErrnoFromWinError(lRet);
- return -1;
- }
-
- return unlink(szFile);
-}
-
-/**
- * Write on a file
- */
-int _win_write(int fildes, const void *buf, size_t nbyte)
-{
- int iRet;
- if ((iRet = write(fildes, buf, nbyte)) == -1)
- {
- DWORD dwWritten;
- if (!WriteFile((HANDLE) fildes, buf, nbyte, &dwWritten, NULL))
- {
- SetErrnoFromWinError(GetLastError());
- return -1;
- }
- else
- return dwWritten;
- }
- else
- return iRet;
-}
-
-/**
- * Reads data from a file.
- */
-int _win_read(int fildes, void *buf, size_t nbyte)
-{
- int iRet;
- if ((iRet = read(fildes, buf, nbyte)) == -1)
- {
- DWORD dwRead;
- if (!ReadFile((HANDLE) fildes, buf, nbyte, &dwRead, NULL))
- {
- SetErrnoFromWinError(GetLastError());
- return -1;
- }
- else
- return dwRead;
- }
- else
- return iRet;
-}
-
-/**
- * Writes data to a stream
- */
-size_t _win_fwrite(const void *buffer, size_t size, size_t count, FILE *stream)
-{
- DWORD dwWritten;
- int iError;
-
- WriteFile((HANDLE) _get_osfhandle(fileno(stream)), buffer, size, &dwWritten,
- NULL);
- if ((iError = GetLastError()) != ERROR_SUCCESS)
- {
- SetErrnoFromWinError(iError);
- }
-
- return dwWritten;
-}
-
-/**
- * Reads data from a stream
- */
-size_t _win_fread( void *buffer, size_t size, size_t count, FILE *stream )
-{
- DWORD dwRead;
- int iItemsRead, iError;
- void *pDest = buffer;
-
- for(iItemsRead = 0; iItemsRead < count; iItemsRead++)
- {
- if (!ReadFile((HANDLE) _get_osfhandle(fileno(stream)), pDest, size,
- &dwRead, NULL))
- break;
- pDest += size;
- }
-
- if ((iError = GetLastError()) != ERROR_SUCCESS)
- {
- SetErrnoFromWinError(iError);
- }
-
- return iItemsRead;
-}
-
-/**
- * Get a system error message
- */
-char *_win_strerror(int errnum)
-{
- char *error;
-
- switch (errnum)
- {
-#ifdef EPERM
- case EPERM:
- error = _("Not super-user");
- break;
-#endif
-#ifdef ENOENT
- case ENOENT:
- error = _("No such file or directory");
- break;
-#endif
-#ifdef ESRCH
- case ESRCH:
- error = _("No such process");
- break;
-#endif
-#ifdef EINTR
- case EINTR:
- error = _("Interrupted system call");
- break;
-#endif
-#ifdef EIO
- case EIO:
- error = _("I/O error");
- break;
-#endif
-#ifdef ENXIO
- case ENXIO:
- error = _("No such device or address");
- break;
-#endif
-#ifdef E2BIG
- case E2BIG:
- error = _("Arg list too long");
- break;
-#endif
-#ifdef ENOEXEC
- case ENOEXEC:
- error = _("Exec format error");
- break;
-#endif
-#ifdef EBADF
- case EBADF:
- error = _("Bad file number");
- break;
-#endif
-#ifdef ECHILD
- case ECHILD:
- error = _("No children");
- break;
-#endif
-#ifdef EAGAIN
- case EAGAIN:
- error = _("Resource unavailable or operation would block, try again");
- break;
-#endif
-#ifdef ENOMEM
- case ENOMEM:
- error = _("Not enough memory");
- break;
-#endif
-#ifdef EACCES
- case EACCES:
- error = _("Permission denied");
- break;
-#endif
-#ifdef EFAULT
- case EFAULT:
- error = _("Bad address");
- break;
-#endif
-#ifdef ENOTBLK
- case ENOTBLK:
- error = _("Block device required");
- break;
-#endif
-#ifdef EBUSY
- case EBUSY:
- error = _("Mount device busy");
- break;
-#endif
-#ifdef EEXIST
- case EEXIST:
- error = _("File exists");
- break;
-#endif
-#ifdef EXDEV
- case EXDEV:
- error = _("Cross-device link");
- break;
-#endif
-#ifdef ENODEV
- case ENODEV:
- error = _("No such device");
- break;
-#endif
-#ifdef ENOTDIR
- case ENOTDIR:
- error = _("Not a directory");
- break;
-#endif
-#ifdef EISDIR
- case EISDIR:
- error = _("Is a directory");
- break;
-#endif
-#ifdef EINVAL
- case EINVAL:
- error = _("Invalid argument");
- break;
-#endif
-#ifdef ENFILE
- case ENFILE:
- error = _("Too many open files in system");
- break;
-#endif
-#ifdef EMFILE
- case EMFILE:
- error = _("Too many open files");
- break;
-#endif
-#ifdef ENOTTY
- case ENOTTY:
- error = _("Not a typewriter");
- break;
-#endif
-#ifdef ETXTBSY
- case ETXTBSY:
- error = _("Text file busy");
- break;
-#endif
-#ifdef EFBIG
- case EFBIG:
- error = _("File too large");
- break;
-#endif
-#ifdef ENOSPC
- case ENOSPC:
- error = _("No space left on device");
- break;
-#endif
-#ifdef ESPIPE
- case ESPIPE:
- error = _("Illegal seek");
- break;
-#endif
-#ifdef EROFS
- case EROFS:
- error = _("Read only file system");
- break;
-#endif
-#ifdef EMLINK
- case EMLINK:
- error = _("Too many links");
- break;
-#endif
-#ifdef EPIPE
- case EPIPE:
- error = _("Broken pipe");
- break;
-#endif
-#ifdef EDOM
- case EDOM:
- error = _("Math arg out of domain of func");
- break;
-#endif
-#ifdef ERANGE
- case ERANGE:
- error = _("Math result not representable");
- break;
-#endif
-#ifdef ENOMSG
- case ENOMSG:
- error = _("No message of desired type");
- break;
-#endif
-#ifdef EIDRM
- case EIDRM:
- error = _("Identifier removed");
- break;
-#endif
-#ifdef ECHRNG
- case ECHRNG:
- error = _("Channel number out of range");
- break;
-#endif
-#ifdef EL2NSYNC
- case EL2NSYNC:
- error = _("Level 2 not synchronized");
- break;
-#endif
-#ifdef L3HLT
- case L3HLT:
- error = _("Level 3 halted");
- break;
-#endif
-#ifdef EL3RST
- case EL3RST:
- error = _("Level 3 reset");
- break;
-#endif
-#ifdef ELNRNG
- case ELNRNG:
- error = _("Link number out of range");
- break;
-#endif
-#ifdef EUNATCH
- case EUNATCH:
- error = _("Protocol driver not attached");
- break;
-#endif
-#ifdef ENOCSI
- case ENOCSI:
- error = _("No CSI structure available");
- break;
-#endif
-#ifdef EL2HLT
- case EL2HLT:
- error = _("Level 2 halted");
- break;
-#endif
-#ifdef EDEADLK
- case EDEADLK:
- error = _("Deadlock condition");
- break;
-#endif
-#ifdef ENOLCK
- case ENOLCK:
- error = _("No record locks available");
- break;
-#endif
-#ifdef EBADE
- case EBADE:
- error = _("Invalid exchange");
- break;
-#endif
-#ifdef EBADR
- case EBADR:
- error = _("Invalid request descriptor");
- break;
-#endif
-#ifdef EXFULL
- case EXFULL:
- error = _("Exchange full");
- break;
-#endif
-#ifdef ENOANO
- case ENOANO:
- error = _("No anode");
- break;
-#endif
-#ifdef EBADRQC
- case EBADRQC:
- error = _("Invalid request code");
- break;
-#endif
-#ifdef EBADSLT
- case EBADSLT:
- error = _("Invalid slot");
- break;
-#endif
-#ifdef EDEADLOCK
- case EDEADLOCK:
- error = _("File locking deadlock error");
- break;
-#endif
-#ifdef EBFONT
- case EBFONT:
- error = _("Bad font file fmt");
- break;
-#endif
-#ifdef ENOSTR
- case ENOSTR:
- error = _("Device not a stream");
- break;
-#endif
-#ifdef ENODATA
- case ENODATA:
- error = _("No data (for no delay io)");
- break;
-#endif
-#ifdef ETIME
- case ETIME:
- error = _("Timer expired");
- break;
-#endif
-#ifdef ENOSR
- case ENOSR:
- error = _("Out of streams resources");
- break;
-#endif
-#ifdef ENONET
- case ENONET:
- error = _("Machine is not on the network");
- break;
-#endif
-#ifdef ENOPKG
- case ENOPKG:
- error = _("Package not installed");
- break;
-#endif
-#ifdef EREMOTE
- case EREMOTE:
- error = _("The object is remote");
- break;
-#endif
-#ifdef ENOLINK
- case ENOLINK:
- error = _("The link has been severed");
- break;
-#endif
-#ifdef EADV
- case EADV:
- error = _("Advertise error");
- break;
-#endif
-#ifdef ESRMNT
- case ESRMNT:
- error = _("Srmount error");
- break;
-#endif
-#ifdef ECOMM
- case ECOMM:
- error = _("Communication error on send");
- break;
-#endif
-#ifdef EPROTO
- case EPROTO:
- error = _("Protocol error");
- break;
-#endif
-#ifdef EMULTIHOP
- case EMULTIHOP:
- error = _("Multihop attempted");
- break;
-#endif
-#ifdef ELBIN
- case ELBIN:
- error = _("Inode is remote (not really error)");
- break;
-#endif
-#ifdef EDOTDOT
- case EDOTDOT:
- error = _("Cross mount point (not really error)");
- break;
-#endif
-#ifdef EBADMSG
- case EBADMSG:
- error = _("Trying to read unreadable message");
- break;
-#endif
-#ifdef ENOTUNIQ
- case ENOTUNIQ:
- error = _("Given log. name not unique");
- break;
-#endif
-#ifdef EBADFD
- case EBADFD:
- error = _("f.d. invalid for this operation");
- break;
-#endif
-#ifdef EREMCHG
- case EREMCHG:
- error = _("Remote address changed");
- break;
-#endif
-#ifdef ELIBACC
- case ELIBACC:
- error = _("Can't access a needed shared lib");
- break;
-#endif
-#ifdef ELIBBAD
- case ELIBBAD:
- error = _("Accessing a corrupted shared lib");
- break;
-#endif
-#ifdef ELIBSCN
- case ELIBSCN:
- error = _(".lib section in a.out corrupted");
- break;
-#endif
-#ifdef ELIBMAX
- case ELIBMAX:
- error = _("Attempting to link in too many libs");
- break;
-#endif
-#ifdef ELIBEXEC
- case ELIBEXEC:
- error = _("Attempting to exec a shared library");
- break;
-#endif
-#ifdef ENOSYS
- case ENOSYS:
- error = _("Function not implemented");
- break;
-#endif
-#ifdef ENMFILE
- case ENMFILE:
- error = _("No more files");
- break;
-#endif
-#ifdef ENOTEMPTY
- case ENOTEMPTY:
- error = _("Directory not empty");
- break;
-#endif
-#ifdef ENAMETOOLONG
- case ENAMETOOLONG:
- error = _("File or path name too long");
- break;
-#endif
-#ifdef ELOOP
- case ELOOP:
- error = _("Too many symbolic links");
- break;
-#endif
-#ifdef EOPNOTSUPP
- case EOPNOTSUPP:
- error = _("Operation not supported on transport endpoint");
- break;
-#endif
-#ifdef EPFNOSUPPORT
- case EPFNOSUPPORT:
- error = _("Protocol family not supported");
- break;
-#endif
-#ifdef ECONNRESET
- case ECONNRESET:
- error = _("Connection reset by peer");
- break;
-#endif
-#ifdef ENOBUFS
- case ENOBUFS:
- error = _("No buffer space available");
- break;
-#endif
-#ifdef EAFNOSUPPORT
- case EAFNOSUPPORT:
- error = _("Address family not supported by protocol family");
- break;
-#endif
-#ifdef EPROTOTYPE
- case EPROTOTYPE:
- error = _("Protocol wrong type for socket");
- break;
-#endif
-#ifdef ENOTSOCK
- case ENOTSOCK:
- error = _("Socket operation on non-socket");
- break;
-#endif
-#ifdef ENOPROTOOPT
- case ENOPROTOOPT:
- error = _("Protocol not available");
- break;
-#endif
-#ifdef ESHUTDOWN
- case ESHUTDOWN:
- error = _("Can't send after socket shutdown");
- break;
-#endif
-#ifdef ECONNREFUSED
- case ECONNREFUSED:
- error = _("Connection refused");
- break;
-#endif
-#ifdef EADDRINUSE
- case EADDRINUSE:
- error = _("Address already in use");
- break;
-#endif
-#ifdef ECONNABORTED
- case ECONNABORTED:
- error = _("Connection aborted");
- break;
-#endif
-#ifdef ENETUNREACH
- case ENETUNREACH:
- error = _("Network is unreachable");
- break;
-#endif
-#ifdef ENETDOWN
- case ENETDOWN:
- error = _("Network interface is not configured");
- break;
-#endif
-#ifdef ETIMEDOUT
- case ETIMEDOUT:
- error = _("Connection timed out");
- break;
-#endif
-#ifdef EHOSTDOWN
- case EHOSTDOWN:
- error = _("Host is down");
- break;
-#endif
-#ifdef EHOSTUNREACH
- case EHOSTUNREACH:
- error = _("Host is unreachable");
- break;
-#endif
-#ifdef EINPROGRESS
- case EINPROGRESS:
- error = _("Connection already in progress");
- break;
-#endif
-#ifdef EALREADY
- case EALREADY:
- error = _("Socket already connected");
- break;
-#endif
-#ifdef EDESTADDRREQ
- case EDESTADDRREQ:
- error = _("Destination address required");
- break;
-#endif
-#ifdef EMSGSIZE
- case EMSGSIZE:
- error = _("Message too long");
- break;
-#endif
-#ifdef EPROTONOSUPPORT
- case EPROTONOSUPPORT:
- error = _("Unknown protocol");
- break;
-#endif
-#ifdef ESOCKTNOSUPPORT
- case ESOCKTNOSUPPORT:
- error = _("Socket type not supported");
- break;
-#endif
-#ifdef EADDRNOTAVAIL
- case EADDRNOTAVAIL:
- error = _("Address not available");
- break;
-#endif
-#ifdef ENETRESET
- case ENETRESET:
- error = _("Connection aborted by network");
- break;
-#endif
-#ifdef EISCONN
- case EISCONN:
- error = _("Socket is already connected");
- break;
-#endif
-#ifdef ENOTCONN
- case ENOTCONN:
- error = _("Socket is not connected");
- break;
-#endif
-#ifdef ETOOMANYREFS
- case ETOOMANYREFS:
- error = _("Too many references: cannot splice");
- break;
-#endif
-#ifdef EPROCLIM
- case EPROCLIM:
- error = _("Too many processes");
- break;
-#endif
-#ifdef EUSERS
- case EUSERS:
- error = _("Too many users");
- break;
-#endif
-#ifdef EDQUOT
- case EDQUOT:
- error = _("Disk quota exceeded");
- break;
-#endif
-#ifdef ESTALE
- case ESTALE:
- error = _("Unknown error");
- break;
-#endif
-#ifdef ENOTSUP
- case ENOTSUP:
- error = _("Not supported");
- break;
-#endif
-#ifdef ENOMEDIUM
- case ENOMEDIUM:
- error = _("No medium (in tape drive)");
- break;
-#endif
-#ifdef ENOSHARE
- case ENOSHARE:
- error = _("No such host or network path");
- break;
-#endif
-#ifdef ECASECLASH
- case ECASECLASH:
- error = _("Filename exists with different case");
- break;
-#endif
- case 0:
- error = _("No error");
- break;
- default:
- error = _("Unknown error");
- fprintf(stderr,
- _("ERROR: Unknown error %i in %s\n"),
- errnum,
- __FUNCTION__);
- break;
- }
-
- return error;
-}
-
-#if !HAVE_ATOLL
-long long atoll(const char *nptr)
-{
- return atol(nptr);
-}
-#endif
-
-#if !HAVE_STRNDUP
-/**
- * return a malloc'd copy of at most the specified
- * number of bytes of a string
- * @author glibc-Team
- */
-char *strndup (const char *s, size_t n)
-{
- size_t len = strnlen (s, n);
- char *new = (char *) malloc (len + 1);
-
- if (new == NULL)
- return NULL;
-
- new[len] = '\0';
- return (char *) memcpy (new, s, len);
-}
-#endif
-
-#if !HAVE_STRNLEN
-/**
- * Determine the length of a fixed-size string
- * @author Jakub Jelinek <jakub at redhat dot com>
- */
-size_t strnlen (const char *str, size_t maxlen)
-{
- const char *char_ptr, *end_ptr = str + maxlen;
- const unsigned long int *longword_ptr;
- unsigned long int longword, magic_bits, himagic, lomagic;
-
- if (maxlen == 0)
- return 0;
-
- if (__builtin_expect (end_ptr < str, 0))
- end_ptr = (const char *) ~0UL;
-
- /* Handle the first few characters by reading one character at a time.
- Do this until CHAR_PTR is aligned on a longword boundary. */
- for (char_ptr = str; ((unsigned long int) char_ptr
- & (sizeof (longword) - 1)) != 0;
- ++char_ptr)
- if (*char_ptr == '\0')
- {
- if (char_ptr > end_ptr)
- char_ptr = end_ptr;
- return char_ptr - str;
- }
-
- /* All these elucidatory comments refer to 4-byte longwords,
- but the theory applies equally well to 8-byte longwords. */
-
- longword_ptr = (unsigned long int *) char_ptr;
-
- /* Bits 31, 24, 16, and 8 of this number are zero. Call these bits
- the "holes." Note that there is a hole just to the left of
- each byte, with an extra at the end:
-
- bits: 01111110 11111110 11111110 11111111
- bytes: AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD
-
- The 1-bits make sure that carries propagate to the next 0-bit.
- The 0-bits provide holes for carries to fall into. */
- magic_bits = 0x7efefeffL;
- himagic = 0x80808080L;
- lomagic = 0x01010101L;
- if (sizeof (longword) > 4)
- {
- /* 64-bit version of the magic. */
- /* Do the shift in two steps to avoid a warning if long has 32 bits. */
- magic_bits = ((0x7efefefeL << 16) << 16) | 0xfefefeffL;
- himagic = ((himagic << 16) << 16) | himagic;
- lomagic = ((lomagic << 16) << 16) | lomagic;
- }
- if (sizeof (longword) > 8)
- abort ();
-
- /* Instead of the traditional loop which tests each character,
- we will test a longword at a time. The tricky part is testing
- if *any of the four* bytes in the longword in question are zero. */
- while (longword_ptr < (unsigned long int *) end_ptr)
- {
- /* We tentatively exit the loop if adding MAGIC_BITS to
- LONGWORD fails to change any of the hole bits of LONGWORD. */
-
- longword = *longword_ptr++;
-
- if ((longword - lomagic) & himagic)
- {
- /* Which of the bytes was the zero? If none of them were, it was
- a misfire; continue the search. */
-
- const char *cp = (const char *) (longword_ptr - 1);
-
- char_ptr = cp;
- if (cp[0] == 0)
- break;
- char_ptr = cp + 1;
- if (cp[1] == 0)
- break;
- char_ptr = cp + 2;
- if (cp[2] == 0)
- break;
- char_ptr = cp + 3;
- if (cp[3] == 0)
- break;
- if (sizeof (longword) > 4)
- {
- char_ptr = cp + 4;
- if (cp[4] == 0)
- break;
- char_ptr = cp + 5;
- if (cp[5] == 0)
- break;
- char_ptr = cp + 6;
- if (cp[6] == 0)
- break;
- char_ptr = cp + 7;
- if (cp[7] == 0)
- break;
- }
- }
- char_ptr = end_ptr;
- }
-
- if (char_ptr > end_ptr)
- char_ptr = end_ptr;
- return char_ptr - str;
-}
-#endif
-
-/**
- * language information
- */
-#ifndef HAVE_LANGINFO_H
-char *nl_langinfo(int item)
-{
- unsigned int loc;
-
- loc = GetThreadLocale();
-
- switch(item)
- {
- case CODESET:
- {
- unsigned int cp = GetACP();
-
- if (cp)
- sprintf(__langinfo, "CP%u", cp);
- else
- strcpy(__langinfo, "UTF-8"); /* ? */
- return __langinfo;
- }
- case D_T_FMT:
- case T_FMT_AMPM:
- case ERA_D_T_FMT:
- strcpy(__langinfo, "%c");
- return __langinfo;
- case D_FMT:
- case ERA_D_FMT:
- strcpy(__langinfo, "%x");
- return __langinfo;
- case T_FMT:
- case ERA_T_FMT:
- strcpy(__langinfo, "%X");
- return __langinfo;
- case AM_STR:
- GetLocaleInfo(loc, LOCALE_S1159, __langinfo, 251);
- return __langinfo;
- case PM_STR:
- GetLocaleInfo(loc, LOCALE_S2359, __langinfo, 251);
- return __langinfo;
- case DAY_1:
- GetLocaleInfo(loc, LOCALE_SDAYNAME1, __langinfo, 251);
- return __langinfo;
- case DAY_2:
- GetLocaleInfo(loc, LOCALE_SDAYNAME2, __langinfo, 251);
- return __langinfo;
- case DAY_3:
- GetLocaleInfo(loc, LOCALE_SDAYNAME3, __langinfo, 251);
- return __langinfo;
- case DAY_4:
- GetLocaleInfo(loc, LOCALE_SDAYNAME4, __langinfo, 251);
- return __langinfo;
- case DAY_5:
- GetLocaleInfo(loc, LOCALE_SDAYNAME5, __langinfo, 251);
- return __langinfo;
- case DAY_6:
- GetLocaleInfo(loc, LOCALE_SDAYNAME6, __langinfo, 251);
- return __langinfo;
- case DAY_7:
- GetLocaleInfo(loc, LOCALE_SDAYNAME7, __langinfo, 251);
- return __langinfo;
- case ABDAY_1:
- GetLocaleInfo(loc, LOCALE_SABBREVDAYNAME1, __langinfo, 251);
- return __langinfo;
- case ABDAY_2:
- GetLocaleInfo(loc, LOCALE_SABBREVDAYNAME2, __langinfo, 251);
- return __langinfo;
- case ABDAY_3:
- GetLocaleInfo(loc, LOCALE_SABBREVDAYNAME3, __langinfo, 251);
- return __langinfo;
- case ABDAY_4:
- GetLocaleInfo(loc, LOCALE_SABBREVDAYNAME4, __langinfo, 251);
- return __langinfo;
- case ABDAY_5:
- GetLocaleInfo(loc, LOCALE_SABBREVDAYNAME5, __langinfo, 251);
- return __langinfo;
- case ABDAY_6:
- GetLocaleInfo(loc, LOCALE_SABBREVDAYNAME6, __langinfo, 251);
- return __langinfo;
- case ABDAY_7:
- GetLocaleInfo(loc, LOCALE_SABBREVDAYNAME7, __langinfo, 251);
- return __langinfo;
- case MON_1:
- GetLocaleInfo(loc, LOCALE_SMONTHNAME1, __langinfo, 251);
- return __langinfo;
- case MON_2:
- GetLocaleInfo(loc, LOCALE_SMONTHNAME2, __langinfo, 251);
- return __langinfo;
- case MON_3:
- GetLocaleInfo(loc, LOCALE_SMONTHNAME3, __langinfo, 251);
- return __langinfo;
- case MON_4:
- GetLocaleInfo(loc, LOCALE_SMONTHNAME4, __langinfo, 251);
- return __langinfo;
- case MON_5:
- GetLocaleInfo(loc, LOCALE_SMONTHNAME5, __langinfo, 251);
- return __langinfo;
- case MON_6:
- GetLocaleInfo(loc, LOCALE_SMONTHNAME6, __langinfo, 251);
- return __langinfo;
- case MON_7:
- GetLocaleInfo(loc, LOCALE_SMONTHNAME7, __langinfo, 251);
- return __langinfo;
- case MON_8:
- GetLocaleInfo(loc, LOCALE_SMONTHNAME8, __langinfo, 251);
- return __langinfo;
- case MON_9:
- GetLocaleInfo(loc, LOCALE_SMONTHNAME9, __langinfo, 251);
- return __langinfo;
- case MON_10:
- GetLocaleInfo(loc, LOCALE_SMONTHNAME10, __langinfo, 251);
- return __langinfo;
- case MON_11:
- GetLocaleInfo(loc, LOCALE_SMONTHNAME11, __langinfo, 251);
- return __langinfo;
- case MON_12:
- GetLocaleInfo(loc, LOCALE_SMONTHNAME12, __langinfo, 251);
- return __langinfo;
- case ABMON_1:
- GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME1, __langinfo, 251);
- return __langinfo;
- case ABMON_2:
- GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME2, __langinfo, 251);
- return __langinfo;
- case ABMON_3:
- GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME3, __langinfo, 251);
- return __langinfo;
- case ABMON_4:
- GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME4, __langinfo, 251);
- return __langinfo;
- case ABMON_5:
- GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME5, __langinfo, 251);
- return __langinfo;
- case ABMON_6:
- GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME6, __langinfo, 251);
- return __langinfo;
- case ABMON_7:
- GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME7, __langinfo, 251);
- return __langinfo;
- case ABMON_8:
- GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME8, __langinfo, 251);
- return __langinfo;
- case ABMON_9:
- GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME9, __langinfo, 251);
- return __langinfo;
- case ABMON_10:
- GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME10, __langinfo, 251);
- return __langinfo;
- case ABMON_11:
- GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME11, __langinfo, 251);
- return __langinfo;
- case ABMON_12:
- GetLocaleInfo(loc, LOCALE_SABBREVMONTHNAME12, __langinfo, 251);
- return __langinfo;
- case ERA:
- /* Not implemented */
- __langinfo[0] = 0;
- return __langinfo;
- case ALT_DIGITS:
- GetLocaleInfo(loc, LOCALE_SNATIVEDIGITS, __langinfo, 251);
- return __langinfo;
- case RADIXCHAR:
- GetLocaleInfo(loc, LOCALE_SDECIMAL, __langinfo, 251);
- return __langinfo;
- case THOUSEP:
- GetLocaleInfo(loc, LOCALE_STHOUSAND, __langinfo, 251);
- return __langinfo;
- case YESEXPR:
- /* Not localized */
- strcpy(__langinfo, "^[yY]");
- return __langinfo;
- case NOEXPR:
- /* Not localized */
- strcpy(__langinfo, "^[nN]");
- return __langinfo;
- case CRNCYSTR:
- GetLocaleInfo(loc, LOCALE_STHOUSAND, __langinfo, 251);
- if (__langinfo[0] == '0' || __langinfo[0] == '2')
- __langinfo[0] = '-';
- else
- __langinfo[0] = '+';
- GetLocaleInfo(loc, LOCALE_SCURRENCY, __langinfo + 1, 251);
- default:
- __langinfo[0] = 0;
- return __langinfo;
- }
-}
-#endif
-
-#ifdef __cplusplus
-}
-#endif
+/* end of winproc.c */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r714 - in Extractor: . src/include src/main,
durner <=