summaryrefslogtreecommitdiff
path: root/windows-NT/unistd.c
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2005-10-03 13:43:40 +0000
committer <>2014-09-25 11:25:48 +0000
commit10de491ef0bc43827ab8631a4c02860134e620a9 (patch)
tree22e734337cc9aa5d9b1d7c71261d160b6a60634d /windows-NT/unistd.c
downloadcvs-tarball-10de491ef0bc43827ab8631a4c02860134e620a9.tar.gz
Imported from /home/lorry/working-area/delta_cvs-tarball/cvs-1.12.13.tar.bz2.HEADcvs-1.12.13master
Diffstat (limited to 'windows-NT/unistd.c')
-rw-r--r--windows-NT/unistd.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/windows-NT/unistd.c b/windows-NT/unistd.c
new file mode 100644
index 0000000..6ff09c8
--- /dev/null
+++ b/windows-NT/unistd.c
@@ -0,0 +1,71 @@
+/*
+ * windows-NT/unitstd.c
+ * POSIX/UNIX functions not provided by Win32 platform
+ * and declared in <unistd.h> header file
+ */
+
+#include "unistd.h"
+
+#include <stdio.h>
+#include <conio.h>
+
+#include <sys/socket.h> /* This does: #include <windows.h> */
+
+/* Please order functions by name if possible */
+
+
+
+char *
+getpass (const char *prompt)
+{
+ static char pwd_buf[128];
+ size_t i;
+
+ fputs (prompt, stderr);
+ fflush (stderr);
+ for (i = 0; i < sizeof (pwd_buf) - 1; ++i)
+ {
+ pwd_buf[i] = _getch ();
+ if (pwd_buf[i] == '\r')
+ break;
+ }
+ pwd_buf[i] = '\0';
+ fputs ("\n", stderr);
+ return pwd_buf;
+}
+
+
+
+/* This is just a call to GetCurrentProcessID */
+pid_t
+getpid (void)
+{
+ return (pid_t) GetCurrentProcessId();
+}
+
+
+
+unsigned int sleep (unsigned seconds)
+{
+ Sleep (1000*seconds);
+ return 0;
+}
+
+
+
+/*
+ * Sleep at least some number of microseconds
+ */
+int usleep (useconds_t microseconds)
+{
+ if ( microseconds )
+ {
+ const useconds_t one_second = 1000000;
+ struct timeval tv_delay;
+
+ tv_delay.tv_sec = microseconds / one_second;
+ tv_delay.tv_usec = microseconds % one_second;
+ return select (0, NULL, NULL, NULL, &tv_delay);
+ }
+ return 0;
+}