Index: /trunk/src/ash/win/dirent.c
===================================================================
--- /trunk/src/ash/win/dirent.c	(revision 636)
+++ /trunk/src/ash/win/dirent.c	(revision 636)
@@ -0,0 +1,206 @@
+/* Directory entry code for Window platforms.
+Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+2006 Free Software Foundation, Inc.
+This file is part of GNU Make.
+
+GNU Make 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.
+
+GNU Make 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
+GNU Make; see the file COPYING.  If not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.  */
+
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include "dirent.h"
+
+
+DIR*
+opendir(const char* pDirName)
+{
+	struct stat sb;
+	DIR*	pDir;
+	char*	pEndDirName;
+	int	nBufferLen;
+
+	/* sanity checks */
+	if (!pDirName) {
+		errno = EINVAL;
+		return NULL;
+	}
+	if (stat(pDirName, &sb) != 0) {
+		errno = ENOENT;
+		return NULL;
+	}
+	if ((sb.st_mode & S_IFMT) != S_IFDIR) {
+		errno = ENOTDIR;
+		return NULL;
+	}
+
+	/* allocate a DIR structure to return */
+	pDir = (DIR *) malloc(sizeof (DIR));
+
+	if (!pDir)
+		return NULL;
+
+	/* input directory name length */
+	nBufferLen = strlen(pDirName);
+
+	/* copy input directory name to DIR buffer */
+	strcpy(pDir->dir_pDirectoryName, pDirName);
+
+	/* point to end of the copied directory name */
+	pEndDirName = &pDir->dir_pDirectoryName[nBufferLen - 1];
+
+	/* if directory name did not end in '/' or '\', add '/' */
+	if ((*pEndDirName != '/') && (*pEndDirName != '\\')) {
+		pEndDirName++;
+		*pEndDirName = '/';
+	}
+
+	/* now append the wildcard character to the buffer */
+	pEndDirName++;
+	*pEndDirName = '*';
+	pEndDirName++;
+	*pEndDirName = '\0';
+
+	/* other values defaulted */
+	pDir->dir_nNumFiles = 0;
+	pDir->dir_hDirHandle = INVALID_HANDLE_VALUE;
+	pDir->dir_ulCookie = __DIRENT_COOKIE;
+
+	return pDir;
+}
+
+void
+closedir(DIR *pDir)
+{
+	/* got a valid pointer? */
+	if (!pDir) {
+		errno = EINVAL;
+		return;
+	}
+
+	/* sanity check that this is a DIR pointer */
+	if (pDir->dir_ulCookie != __DIRENT_COOKIE) {
+		errno = EINVAL;
+		return;
+	}
+
+	/* close the WINDOWS32 directory handle */
+	if (pDir->dir_hDirHandle != INVALID_HANDLE_VALUE)
+		FindClose(pDir->dir_hDirHandle);
+
+	free(pDir);
+
+	return;
+}
+
+struct dirent *
+readdir(DIR* pDir)
+{
+	WIN32_FIND_DATA wfdFindData;
+
+	if (!pDir) {
+		errno = EINVAL;
+		return NULL;
+	}
+
+	/* sanity check that this is a DIR pointer */
+	if (pDir->dir_ulCookie != __DIRENT_COOKIE) {
+		errno = EINVAL;
+		return NULL;
+	}
+
+	if (pDir->dir_nNumFiles == 0) {
+		pDir->dir_hDirHandle = FindFirstFile(pDir->dir_pDirectoryName, &wfdFindData);
+		if (pDir->dir_hDirHandle == INVALID_HANDLE_VALUE)
+			return NULL;
+	} else if (!FindNextFile(pDir->dir_hDirHandle, &wfdFindData))
+			return NULL;
+
+	/* bump count for next call to readdir() or telldir() */
+	pDir->dir_nNumFiles++;
+
+	/* fill in struct dirent values */
+	pDir->dir_sdReturn.d_ino = -1;
+	strcpy(pDir->dir_sdReturn.d_name, wfdFindData.cFileName);
+
+	return &pDir->dir_sdReturn;
+}
+
+void
+rewinddir(DIR* pDir)
+{
+	if (!pDir) {
+		errno = EINVAL;
+		return;
+	}
+
+	/* sanity check that this is a DIR pointer */
+	if (pDir->dir_ulCookie != __DIRENT_COOKIE) {
+		errno = EINVAL;
+		return;
+	}
+
+	/* close the WINDOWS32 directory handle */
+	if (pDir->dir_hDirHandle != INVALID_HANDLE_VALUE)
+		if (!FindClose(pDir->dir_hDirHandle))
+			errno = EBADF;
+
+	/* reset members which control readdir() */
+	pDir->dir_hDirHandle = INVALID_HANDLE_VALUE;
+	pDir->dir_nNumFiles = 0;
+
+	return;
+}
+
+int
+telldir(DIR* pDir)
+{
+	if (!pDir) {
+		errno = EINVAL;
+		return -1;
+	}
+
+	/* sanity check that this is a DIR pointer */
+	if (pDir->dir_ulCookie != __DIRENT_COOKIE) {
+		errno = EINVAL;
+		return -1;
+	}
+
+	/* return number of times readdir() called */
+	return pDir->dir_nNumFiles;
+}
+
+void
+seekdir(DIR* pDir, long nPosition)
+{
+	if (!pDir)
+		return;
+
+	/* sanity check that this is a DIR pointer */
+	if (pDir->dir_ulCookie != __DIRENT_COOKIE)
+		return;
+
+	/* go back to beginning of directory */
+	rewinddir(pDir);
+
+	/* loop until we have found position we care about */
+	for (--nPosition; nPosition && readdir(pDir); nPosition--);
+
+	/* flag invalid nPosition value */
+	if (nPosition)
+		errno = EINVAL;
+
+	return;
+}
Index: /trunk/src/ash/win/mscfakes.c
===================================================================
--- /trunk/src/ash/win/mscfakes.c	(revision 635)
+++ /trunk/src/ash/win/mscfakes.c	(revision 636)
@@ -31,7 +31,11 @@
 #include <io.h>
 #include <fcntl.h>
+#include <sys/times.h>
 #include "err.h"
 #include "mscfakes.h"
 #undef mkdir
+
+
+int optind = 1;
 
 
@@ -151,2 +155,186 @@
 }
 
+
+int fcntl(int fd, int iCmd, ...)
+{
+    fprintf(stderr, "fcntl(%d, %d,..)\n", fd, iCmd);
+    return 0;
+}
+
+int ioctl(int fd, unsigned long iCmd, ...)
+{
+    fprintf(stderr, "ioctl(%d, %d,..)\n", fd, iCmd);
+    return 0;
+}   
+
+int tcsetpgrp(int fd, pid_t pgrp)
+{
+    fprintf(stderr, "tcgetpgrp(%d, %d)\n", fd, pgrp);
+    return 0;
+}
+
+pid_t tcgetpgrp(int fd)
+{
+    fprintf(stderr, "tcgetpgrp(%d)\n", fd);
+    return 0;
+}
+
+pid_t getpgrp(void)
+{
+    fprintf(stderr, "getpgrp\n");
+    return _getpid();
+}
+
+uid_t getuid(void)
+{
+    fprintf(stderr, "getuid\n");
+    return 0;
+}
+
+gid_t getgid(void)
+{
+    fprintf(stderr, "getgid\n");
+    return 0;
+}
+
+gid_t getegid(void)
+{
+    fprintf(stderr, "getegid\n");
+    return 0;
+}
+
+int setpgid(pid_t pid, pid_t pgid)
+{
+    fprintf(stderr, "setpgid(%d,%d)\n", pid, pgid);
+    return 0;
+}
+
+pid_t getpgid(pid_t pid)
+{
+    fprintf(stderr, "getpgid(%d)\n", pid);
+    return 0;
+}
+
+long sysconf(int name)
+{
+    fprintf(stderr, "sysconf(%d)\n", name);
+    return 0;
+}
+
+clock_t times(struct tms *pBuf)
+{
+    struct timeval tv = {0};
+    if (pBuf)
+    {
+        pBuf->tms_utime = clock();  /* clock () * HZ / CLOCKS_PER_SEC */
+        pBuf->tms_stime = pBuf->tms_cutime = pBuf->tms_cstime = 0;
+    }
+/*
+    gettimeofday(&tv, NULL); */
+    fprintf(stderr, "times(%p)\n", pBuf);
+    return CLK_TCK * tv.tv_sec + (CLK_TCK * tv.tv_usec) / 1000000;
+}
+
+struct passwd *getpwnam(const char *pszName)
+{
+    printf("getpwnam(%s)\n",  pszName);
+    return NULL;
+}
+
+int setrlimit(int iResId, const struct rlimit *pLimit)
+{
+    printf("setrlimit(%d,  %p)\n", iResId, pLimit);
+    return -1;
+}
+
+int getrlimit(int iResId, struct rlimit *pLimit)
+{
+    printf("getrlimit(%d,  %p)\n", iResId, pLimit);
+    return -1;
+}
+
+
+pid_t fork(void)
+{
+    fprintf(stderr, "fork()\n");
+    return -1;
+}
+
+pid_t wait3(int *piStatus, int fOptions, struct rusage *pRUsage)
+{
+    fprintf(stderr, "wait3()\n");
+    return -1;
+}
+
+
+/* signal stuff */
+
+int	sigprocmask(int iOperation, const sigset_t *pNew, sigset_t *pOld)
+{
+    fprintf(stderr, "sigprocmask(%d, %p, %p)\n", iOperation, pNew, pOld);
+    return 0;
+}
+
+int	sigemptyset(sigset_t *pSet)
+{
+    pSet->__bitmap[0] = 0;
+    return 0;
+}
+
+int siginterrupt(int iSignalNo, int fFlag)
+{
+    fprintf(stderr, "siginterrupt(%d, %#x)\n", iSignalNo, fFlag);
+    return 0;
+}
+
+int sigaction(int iSignalNo, const struct sigaction *pSigAct, struct sigaction *pSigActOld)
+{
+    fprintf(stderr, "sigaction(%d, %p, %p)\n", iSignalNo, pSigAct, pSigActOld);
+    return 0;
+}
+
+int kill(pid_t pid, int iSignalNo)
+{
+    fprintf(stderr, "kill(%d, %d)\n", pid, iSignalNo);
+    return 0;
+}
+
+int killpg(pid_t pgrp, int iSignalNo)
+{
+    if (pgrp < 0)
+    {
+        errno = EINVAL;
+        return -1;
+    }
+    return kill(-pgrp, iSignalNo);
+}
+
+const char * const  sys_siglist[NSIG] =
+{
+    "0",
+    "1",
+    "2",
+    "3",
+    "4",
+    "5",
+    "6",
+    "7",
+    "8",
+    "9",
+    "10",
+    "11",
+    "12",
+    "13",
+    "14",
+    "15",
+    "16",
+    "17",
+    "18",
+    "19",
+    "20",
+    "21",
+    "22"
+};
+
+
+/* */
Index: /trunk/src/ash/win/mscfakes.h
===================================================================
--- /trunk/src/ash/win/mscfakes.h	(revision 635)
+++ /trunk/src/ash/win/mscfakes.h	(revision 636)
@@ -34,4 +34,6 @@
 #include <fcntl.h>
 #include <limits.h>
+#include <stdlib.h>
+#include <process.h>
 #undef setmode
 //#include "getopt.h"
@@ -143,7 +145,11 @@
 #define O_NONBLOCK 0 /// @todo
 #define EWOULDBLOCK 512
-int fcntl (int, int, ...);
+int fcntl(int, int, ...);
+int ioctl(int, unsigned long, ...);
+pid_t tcgetpgrp(int fd);
+
 
 /* signal hacks */
+#include <signal.h>
 typedef struct sigset 
 {   
@@ -171,15 +177,13 @@
 #define SIG_SETMASK         3
 
-#define SIGTTIN 29
-#define SIGTSTP 28
-#define SIGTTOU 27
-#define SIGCONT 26
-#define SIGPIPE 25
-#define SIGQUIT 24
-#define SIGHUP 23
-#ifndef NSIG
-#define NSIG 32
-#endif 
-extern const char *const sys_siglist[NSIG];
+#define SIGTTIN 19
+#define SIGTSTP 18
+#define SIGTTOU 17
+#define SIGCONT 20
+#define SIGPIPE 12
+#define SIGQUIT 9
+#define SIGHUP  5
+
+extern const char *const sys_siglist[NSIG]; /* NSIG == 23 */
 
 int	kill(pid_t, int);
Index: /trunk/src/ash/win/unistd.h
===================================================================
--- /trunk/src/ash/win/unistd.h	(revision 635)
+++ /trunk/src/ash/win/unistd.h	(revision 636)
@@ -1,5 +1,9 @@
 #include "mscfakes.h"
 #include "getopt.h"
+#include "process.h"
 
 #define _SC_CLK_TCK 0x101
 long _sysconf(int);
+pid_t fork(void);
+pid_t getpid(void);
+
