summaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-08-13 05:45:20 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-08-13 05:45:20 +0000
commit65a5162550f58047974793cdc8067a970b2435c0 (patch)
tree082bb7d5568f3b2e36e3fe166e9f3039394fcf44 /win32
parentfcd020c83028f5610d382e85a2df00223e12bd7e (diff)
1.4.0
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@520 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
-rw-r--r--win32/Makefile265
-rw-r--r--win32/config.h43
-rw-r--r--win32/config.status65
-rwxr-xr-xwin32/ntsetup.bat4
-rw-r--r--win32/ruby.def273
-rw-r--r--win32/sdbm.c981
-rw-r--r--win32/sdbm.h84
-rw-r--r--win32/win32.c192
-rw-r--r--win32/win32.h87
9 files changed, 660 insertions, 1334 deletions
diff --git a/win32/Makefile b/win32/Makefile
index 152bdc8..5275069 100644
--- a/win32/Makefile
+++ b/win32/Makefile
@@ -7,34 +7,36 @@ VPATH = .:./missing
CC = cl
YACC = byacc
-RANLIB =
-AR =
-INSTALL = ginstall -c
-INSTALL_PROGRAM = $(INSTALL)
-INSTALL_DATA = $(INSTALL) -m 644
PURIFY =
+AUTOCONF = autoconf
-CFLAGS = -nologo -DNT=1 -Ox -I. -I./missing
-LDFLAGS = $(CFLAGS) -Fm
-#CFLAGS = -nologo -DNT=1 -Zi -MD
-#LDFLAGS = $(CFLAGS) -Fm -MD
-LIBS = $(EXTLIBS) advapi32.lib wsock32.lib
-MISSING = crypt.obj alloca.obj win32.obj
-
prefix =
-binprefix =
-exec_prefix =
-bindir =
-libdir =
+CFLAGS = -nologo -DNT=1 -Ox -I. -I./missing
+LDFLAGS = $(CFLAGS) -Fm
+#CFLAGS = -nologo -DNT=1 -Zi -I. -I./missing
+#LDFLAGS = $(CFLAGS) -Fm
+XLDFLAGS =
+#EXTLIBS =
+LIBS = advapi32.lib wsock32.lib $(EXTLIBS)
+MISSING = crypt.obj alloca.obj win32.obj fnmatch.obj isinf.obj isnan.obj
+LDSHARED =
+DLDFLAGS =
+SOLIBS =
+
+RUBY_INSTALL_NAME=ruby
+EXEEXT = .exe
+PROGRAM=$(RUBY_INSTALL_NAME)$(EXEEXT)
STACK = 0x200000
ORGLIBPATH = $(LIB)
#### End of system configuration section. ####
-
-LIBRUBY = libruby.lib
+LIBRUBY_A = libruby.lib
+LIBRUBY_SO = rubymw.dll
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBYARG = rubymw.lib
EXTOBJS = dmyext.obj
@@ -50,18 +52,17 @@ OBJS = array.obj \
error.obj \
eval.obj \
file.obj \
- fnmatch.obj \
gc.obj \
- glob.obj \
hash.obj \
inits.obj \
io.obj \
- math.obj \
marshal.obj \
+ math.obj \
numeric.obj \
object.obj \
pack.obj \
parse.obj \
+ prec.obj \
process.obj \
random.obj \
range.obj \
@@ -79,65 +80,71 @@ OBJS = array.obj \
version.obj \
$(MISSING)
-all: miniruby.exe ext/Setup $(MISCLIBS)
- cd ext
+all: miniruby$(EXEEXT) rbconfig.rb ext/extmk.rb ext/Setup.nt rubymw.lib $(MISCLIBS)
set LIB=..\..\win32;$(ORGLIBPATH)
- ..\miniruby .\extmk.rb static
-# ..\miniruby .\extmk.rb
- cd ..
+ @.\miniruby$(EXEEXT) -Xext extmk.rb
-miniruby.exe: $(OBJS) $(MAINOBJ) $(EXTOBJS)
+ext/extmk.rb: ext/extmk.rb.in rbconfig.rb
+ @echo Creating ext/extmk.rb
+ @.\miniruby$(EXEEXT) -Xext mswin32_extmk.rb
+
+miniruby$(EXEEXT): $(OBJS) $(MAINOBJ) $(EXTOBJS)
@echo $(EXTOBJS)
@echo $(LIBS)
- @rm -f miniruby.exe
- $(PURIFY) $(CC) $(LDFLAGS) $(MAINOBJ) $(OBJS) $(EXTOBJS) $(LIBS) -o miniruby.exe
+ @rm -f $@
+ $(PURIFY) $(CC) $(LDFLAGS) $(MAINOBJ) $(EXTOBJS) $(OBJS) $(LIBS) -o $@
+
+$(PROGRAM): $(LIBRUBY) $(MAINOBJ) $(LIBRUBY_SO)
+ @rm -f $@
+ $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ) -o $@ $(LIBRUBYARG) -link /STACK:$(STACK)
+
+$(LIBRUBY_A): $(OBJS)
+ lib -nologo /OUT:$@ $(OBJS)
-ruby.exe: $(LIBRUBY) $(MAINOBJ) $(EXTOBJS) rubymw.dll
- @rm -f ruby.exe
-# $(PURIFY) $(CC) $(LDFLAGS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBY) $(LIBS) -o ruby.exe
- $(CC) $(LDFLAGS) $(MAINOBJ) -o ruby.exe rubymw.lib -link /STACK:$(STACK)
+rubymw.lib: ruby.def
+ lib -nologo /OUT:$@ /DEF:ruby.def
-rubymw.dll: $(LIBRUBY) $(EXTOBJS)
+$(LIBRUBY_SO): $(LIBRUBY_A) $(EXTOBJS)
set LIB=.\win32;$(ORGLIBPATH)
- @rm -f rubymw.dll
- $(PURIFY) $(CC) $(LDFLAGS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBY) $(LIBS) -o rubymw.dll -link /DLL /DEF:ruby.def
+ @rm -f $@
+ $(CC) $(LDFLAGS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBY_A) $(LIBS) -o $@ -link /DLL /DEF:ruby.def
@mv rubymw.map rubydll.map
-$(LIBRUBY): $(OBJS)
- lib /OUT:$(LIBRUBY) $(OBJS)
-
-install:; $(INSTALL_PROGRAM) ruby.exe $(bindir)/ruby.exe
- @-strip $(bindir)/ruby
- @test -d $(libdir) || mkdir $(libdir)
- cd ext; ../miniruby ./extmk.rb install
- @for rb in `grep '^lib/' MANIFEST`; do \
- $(INSTALL_DATA) $$rb $(libdir); \
- done
-
-clean:; @rm -f $(OBJS) $(LIBRUBY) main.obj dmyext.obj *.pdb *.map *.exp
- @rm -f ext/extinit.c ext/extinit.obj
- cd ext
- ..\miniruby .\extmk.rb clean
- cd ..
-
-realclean: clean
- @rm -f Makefile ext/extmk.rb
- @rm -f config.cache config.h config.log config.status
- @rm -f core ruby miniruby *~
-
-test:; @-./ruby sample/test.rb > ./ruby_test 2>&1; \
- if grep '^end of test' ./ruby_test > /dev/null; then \
- echo "test succeeded"; \
- else \
- grep '^sample/test.rb' ./ruby_test; \
- grep '^not' ./ruby_test; \
- echo "test failed";\
- fi;\
- rm -f ./ruby_test
+install: rbconfig.rb
+ .\miniruby.exe $(srcdir)/instruby.rb $(DESTDIR)
+
+clean:; @rm -f $(OBJS) $(LIBRUBY_A) $(MAINOBJ) rbconfig.rb
+ @rm -f ext/extinit.c ext/extinit.obj ext/vc*.pdb *.obj
+ @-.\miniruby$(EXEEXT) -Xext extmk.rb clean
+
+distclean: clean
+ @rm -f Makefile ext/extmk.rb config.h
+ @rm -f ext/config.cache config.cache config.log config.status
+ @rm -f *~ core *.core gmon.out y.tab.c y.output ruby.imp
+ @rm -f *.map *.pdb *.ilk rubymw.* ruby.def
+ @rm -f $(PROGRAM) miniruby$(EXEEXT)
+
+realclean: distclean
+ @rm -f parse.c
+ @rm -f lex.c
+
+test: miniruby$(EXEEXT)
+ @.\miniruby$(EXEEXT) $(srcdir)/rubytest.rb
+
+rbconfig.rb: miniruby$(EXEEXT)
+ @.\miniruby$(EXEEXT) $(srcdir)/mkconfig.rb rbconfig.rb
+
+config.status: $(srcdir)/configure
+# $(SHELL) ./config.status --recheck
.c.obj:
$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
+parse.c: parse.y
+ $(YACC) $(YFLAGS) parse.y
+ sed -e "s!^extern char \*getenv();!/* & */!" y.tab.c > parse.c
+ @rm y.tab.c
+
alloca.obj: missing/alloca.c
$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c missing/alloca.c
@@ -147,84 +154,120 @@ crypt.obj: missing/crypt.c
dup2.obj: missing/dup2.c
$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c missing/dup2.c
+finite.obj: missing/finite.c
+ $(CC) -I. $(CFLAGS) $(CPPFLAGS) -c missing/finite.c
+
flock.obj: missing/flock.c
$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c missing/flock.c
+isinf.obj: missing/isinf.c
+ $(CC) -I. $(CFLAGS) $(CPPFLAGS) -c missing/isinf.c
+
+isnan.obj: missing/isnan.c
+ $(CC) -I. $(CFLAGS) $(CPPFLAGS) -c missing/isnan.c
+
+fnmatch.obj: missing/fnmatch.c
+ $(CC) -I. $(CFLAGS) $(CPPFLAGS) -c missing/fnmatch.c
+
+memcmp.obj: missing/memcmp.c
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c missing/memcmp.c
+
memmove.obj: missing/memmove.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c missing/memmove.c
mkdir.obj: missing/mkdir.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c missing/mkdir.c
-strerror.obj: missing/strerror.c
- $(CC) $(CFLAGS) $(CPPFLAGS) -c missing/strerror.c
+vsnprintf.obj: missing/vsnprintf.c
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c missing/vsnprintf.c
+
+strcasecmp.obj: missing/strcasecmp.c
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c missing/strcasecmp.c
+
+strncasecmp.obj: missing/strncasecmp.c
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c missing/strncasecmp.c
+
+strchr.obj: missing/strchr.c
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c missing/strchr.c
strdup.obj: missing/strdup.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c missing/strdup.c
+strerror.obj: missing/strerror.c
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c missing/strerror.c
+
strftime.obj: missing/strftime.c
$(CC) -I. $(CFLAGS) $(CPPFLAGS) -c missing/strftime.c
strstr.obj: missing/strstr.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c missing/strstr.c
+strtod.obj: missing/strtod.c
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c missing/strtod.c
+
strtol.obj: missing/strtol.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c missing/strtol.c
strtoul.obj: missing/strtoul.c
$(CC) $(CFLAGS) $(CPPFLAGS) -c missing/strtoul.c
+nt.obj: missing/nt.c
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c missing/nt.c
+
+x68.obj: missing/x68.c
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c missing/x68.c
+
+os2.obj: missing/os2.c
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c missing/os2.c
+
+dl_os2.obj: missing/dl_os2.c
+ $(CC) $(CFLAGS) $(CPPFLAGS) -c missing/dl_os2.c
+
# when I use -I., there is confliction at "OpenFile"
# so, set . into environment varible "include"
win32.obj: win32/win32.c
@set include=$(INCLUDE);.
$(CC) $(CFLAGS) $(CPPFLAGS) -c win32/win32.c
-parse.c: parse.y
- $(YACC) $(YFLAGS) parse.y
- sed -e "s!^extern char \*getenv();!/* & */!" y.tab.c > parse.c
- @rm y.tab.c
-
# Prevent GNU make v3 from overflowing arg limit on SysV.
.NOEXPORT:
###
-parse.obj : parse.y ruby.h defines.h config.h env.h node.h st.h regex.h
+parse.obj: parse.y ruby.h config.h defines.h intern.h env.h node.h st.h regex.h util.h lex.c
###
-array.obj: array.c ruby.h config.h defines.h
-bignum.obj: bignum.c ruby.h config.h defines.h
-class.obj: class.c ruby.h config.h defines.h node.h st.h
-compar.obj: compar.c ruby.h config.h defines.h
-dir.obj: dir.c ruby.h config.h defines.h
-dln.obj: dln.c config.h defines.h dln.h st.h
+array.obj: array.c ruby.h config.h defines.h intern.h
+bignum.obj: bignum.c ruby.h config.h defines.h intern.h
+class.obj: class.c ruby.h config.h defines.h intern.h node.h st.h
+compar.obj: compar.c ruby.h config.h defines.h intern.h
+dir.obj: dir.c ruby.h config.h defines.h intern.h
+dln.obj: dln.c config.h defines.h dln.h
dmyext.obj: dmyext.c
-enum.obj: enum.c ruby.h config.h defines.h
-error.obj: error.c ruby.h config.h defines.h env.h
-eval.obj: eval.c ruby.h config.h defines.h env.h node.h rubysig.h st.h dln.h
-file.obj: file.c ruby.h config.h defines.h rubyio.h rubysig.h
-fnmatch.obj: fnmatch.c config.h fnmatch.h
-gc.obj: gc.c ruby.h config.h defines.h env.h rubysig.h st.h node.h re.h regex.h
-glob.obj: glob.c config.h fnmatch.h
-hash.obj: hash.c ruby.h config.h defines.h st.h
-inits.obj: inits.c ruby.h config.h defines.h
-io.obj: io.c ruby.h config.h defines.h rubyio.h rubysig.h
-main.obj: main.c
-math.obj: math.c ruby.h config.h defines.h
-numeric.obj: numeric.c ruby.h config.h defines.h
-object.obj: object.c ruby.h config.h defines.h st.h
-pack.obj: pack.c ruby.h config.h defines.h
-process.obj: process.c ruby.h config.h defines.h rubysig.h st.h
-random.obj: random.c ruby.h config.h defines.h
-range.obj: range.c ruby.h config.h defines.h
-re.obj: re.c ruby.h config.h defines.h re.h regex.h
-regex.obj: regex.c config.h defines.h regex.h util.h
-ruby.obj: ruby.c ruby.h config.h defines.h re.h regex.h dln.h
-signal.obj: signal.c ruby.h config.h defines.h rubysig.h
-sprintf.obj: sprintf.c ruby.h config.h defines.h
+enum.obj: enum.c ruby.h config.h defines.h intern.h
+error.obj: error.c ruby.h config.h defines.h intern.h env.h
+eval.obj: eval.c ruby.h config.h defines.h intern.h node.h env.h rubysig.h st.h dln.h
+file.obj: file.c ruby.h config.h defines.h intern.h rubyio.h rubysig.h
+gc.obj: gc.c ruby.h config.h defines.h intern.h rubysig.h st.h node.h env.h re.h regex.h
+hash.obj: hash.c ruby.h config.h defines.h intern.h st.h rubysig.h util.h
+inits.obj: inits.c ruby.h config.h defines.h intern.h
+io.obj: io.c ruby.h config.h defines.h intern.h rubyio.h rubysig.h
+main.obj: main.c ruby.h config.h defines.h intern.h
+marshal.obj: marshal.c ruby.h config.h defines.h intern.h rubyio.h st.h
+prec.obj: prec.c ruby.h config.h defines.h intern.h
+math.obj: math.c ruby.h config.h defines.h intern.h
+numeric.obj: numeric.c ruby.h config.h defines.h intern.h
+object.obj: object.c ruby.h config.h defines.h intern.h st.h
+pack.obj: pack.c ruby.h config.h defines.h intern.h
+process.obj: process.c ruby.h config.h defines.h intern.h rubysig.h st.h
+random.obj: random.c ruby.h config.h defines.h intern.h
+range.obj: range.c ruby.h config.h defines.h intern.h
+re.obj: re.c ruby.h config.h defines.h intern.h re.h regex.h
+regex.obj: regex.c config.h regex.h util.h
+ruby.obj: ruby.c ruby.h config.h defines.h intern.h dln.h util.h
+signal.obj: signal.c ruby.h config.h defines.h intern.h rubysig.h
+sprintf.obj: sprintf.c ruby.h config.h defines.h intern.h
st.obj: st.c config.h st.h
-string.obj: string.c ruby.h config.h defines.h re.h regex.h
-struct.obj: struct.c ruby.h config.h defines.h
-time.obj: time.c ruby.h config.h defines.h
-util.obj: util.c defines.h config.h util.h
-variable.obj: variable.c ruby.h config.h defines.h env.h st.h
-version.obj: version.c ruby.h config.h defines.h version.h
-director.obj : director.c dir.h
+string.obj: string.c ruby.h config.h defines.h intern.h re.h regex.h
+struct.obj: struct.c ruby.h config.h defines.h intern.h
+time.obj: time.c ruby.h config.h defines.h intern.h
+util.obj: util.c ruby.h config.h defines.h intern.h util.h
+variable.obj: variable.c ruby.h config.h defines.h intern.h env.h node.h st.h
+version.obj: version.c ruby.h config.h defines.h intern.h version.h
diff --git a/win32/config.h b/win32/config.h
index 8385154..c871d70 100644
--- a/win32/config.h
+++ b/win32/config.h
@@ -1,7 +1,3 @@
-#define USE_THREAD 1
-#define SIZEOF_INT 4
-#define SIZEOF_LONG 4
-#define SIZEOF_VOIDP 4
#define HAVE_PROTOTYPES 1
#define HAVE_STDARG_PROTOTYPES 1
/* #define HAVE_ATTR_NORETURN 1 */
@@ -10,6 +6,7 @@
#define HAVE_STDLIB_H 1
#define HAVE_LIMITS_H 1
#define HAVE_SYS_FILE_H 1
+#define HAVE_FCNTL_H 1
/* #define HAVE_PWD_H 1 */
/* #define HAVE_SYS_TIME_H 1 */
/* #define HAVE_SYS_TIMES_H 1 */
@@ -27,7 +24,7 @@
#define vfork fork
#define HAVE_FMOD 1
/* #define HAVE_RANDOM 1 */
-/* #define HAVE_WAITPID 1 */
+#define HAVE_WAITPID 1
#define HAVE_GETCWD 1
/* #define HAVE_TRUNCATE 1 */
#define HAVE_CHSIZE 1
@@ -37,34 +34,18 @@
/* #define HAVE_SETITIMER 1 */
#define HAVE_GETGROUPS 1
/* #define HAVE_SIGPROCMASK 1 */
+#define HAVE_GETLOGIN 1
+
#define RSHIFT(x,y) ((x)>>y)
#define FILE_COUNT _cnt
#define DLEXT ".dll"
-#define RUBY_LIB ";/usr/local/lib/ruby;."
-#define RUBY_ARCHLIB "/usr/local/lib/ruby/i386-mswin32"
+#define RUBY_LIB "/usr/local/lib/ruby/1.4"
+#define RUBY_ARCHLIB "/usr/local/lib/ruby/1.4/i386-mswin32"
#define RUBY_PLATFORM "i386-mswin32"
-/* NNN */
-#define strcasecmp _strcmpi
-#define popen _popen
-#define pclose _pclose
-#define pipe _pipe
-#define bzero(x, y) memset(x, 0, y)
-#define snprintf _snprintf
-#define vsnprintf _vsnprintf
-
-
-#define S_IFMT _S_IFMT
-#define S_IFDIR _S_IFDIR
-#define S_IFCHR _S_IFCHR
-#define S_IFREG _S_IFREG
-#define S_IREAD _S_IREAD
-#define S_IWRITE _S_IWRITE
-#define S_IEXEC _S_IEXEC
-#define S_IFIFO _S_IFIFO
-
-#define UIDTYPE int
-#define GIDTYPE int
-#define pid_t int
-#define WNOHANG -1
-//#define NT
+#define SIZEOF_INT 4
+#define SIZEOF_SHORT 2
+#define SIZEOF_LONG 4
+#define SIZEOF_VOIDP 4
+#define SIZEOF_FLOAT 4
+#define SIZEOF_DOUBLE 8
diff --git a/win32/config.status b/win32/config.status
new file mode 100644
index 0000000..09b2465
--- /dev/null
+++ b/win32/config.status
@@ -0,0 +1,65 @@
+ac_given_srcdir=.
+s%@SHELL@%%g
+s%@CFLAGS@%-nologo -DNT=1 -Ox%g
+s%@CPPFLAGS@%%g
+s%@CXXFLAGS@%%g
+s%@FFLAGS@%%g
+s%@DEFS@%
+ -DUSE_THREAD -DSIZEOF_INT=4 -DSIZEOF_SHORT=2 -DSIZEOF_LONG=4 -DSIZEOF_VOIDP=4 -DSIZEOF_FLOAT=4 -DSIZEOF_DOUBLE=8 -DHAVE_PROTOTYPES=1 -DHAVE_STDARG_PROTOTYPES=1 -DHAVE_STDLIB_H=1 -DHAVE_LIMITS_H=1 -DHAVE_SYS_FILE_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ST_RDEV=1 -DGETGROUPS_T=int -DRETSIGTYPE=void -DHAVE_ALLOCA=1 -DHAVE_FMOD=1 -DHAVE_WAITPID=1 -DHAVE_GETCWD=1 -DHAVE_CHSIZE=1 -DHAVE_GETGROUPS=1 -DHAVE_GETLOGIN=1 -DRSHIFT=\(x,y\)\ \(\(x\)\>\>y\) -DFILE_COUNT=_cnt -DDLEXT=\".dll\" -DRUBY_LIB=\"/usr/local/lib/ruby/1.4\" -DRUBY_ARCHLIB=\"/usr/local/lib/ruby/1.4/i386-mswin32\" -DRUBY_PLATFORM=\"i386-mswin32\" %g
+s%@LDFLAGS@%%g
+s%@LIBS@%advapi32.lib wsock32.lib%g
+s%@exec_prefix@%${prefix}%g
+s%@prefix@%/usr/local%g
+s%@program_transform_name@%s,x,x,%g
+s%@bindir@%${exec_prefix}/bin%g
+s%@sbindir@%${exec_prefix}/sbin%g
+s%@libexecdir@%${exec_prefix}/libexec%g
+s%@datadir@%${prefix}/share%g
+s%@sysconfdir@%${prefix}/etc%g
+s%@sharedstatedir@%${prefix}/com%g
+s%@localstatedir@%${prefix}/var%g
+s%@libdir@%${exec_prefix}/lib%g
+s%@includedir@%${prefix}/include%g
+s%@oldincludedir@%/usr/include%g
+s%@infodir@%${prefix}/info%g
+s%@mandir@%${prefix}/man%g
+s%@host@%i386-pc-mswin32%g
+s%@host_alias@%i386-mswin32%g
+s%@host_cpu@%i386%g
+s%@host_vendor@%pc%g
+s%@host_os@%mswin32%g
+s%@CC@%cl%g
+s%@CPP@%cl -E%g
+s%@YACC@%byacc%g
+s%@RANLIB@%rem%g
+s%@AR@%lib -nologo%g
+s%@LN_S@%%g
+s%@SET_MAKE@%%g
+s%@LIBOBJS@% crypt.obj alloca.obj win32.obj fnmatch.obj isinf.obj isnan.obj%g
+s%@ALLOCA@%%g
+s%@DEFAULT_KCODE@%%g
+s%@EXEEXT@%.exe%g
+s%@OBJEXT@%obj%g
+s%@XLDFLAGS@%%g
+s%@DLDFLAGS@%%g
+s%@STATIC@%%g
+s%@CCDLFLAGS@%-DIMPORT%g
+s%@LDSHARED@%cl -LD%g
+s%@DLEXT@%dll%g
+s%@STRIP@%%g
+s%@EXTSTATIC@%%g
+s%@setup@%Setup.nt%g
+s%@LIBRUBY_LDSHARED@%%g
+s%@LIBRUBY_DLDFLAGS@%%g
+s%@RUBY_INSTALL_NAME@%ruby%g
+s%@LIBRUBY_A@%lib$(RUBY_INSTALL_NAME).lib%g
+s%@LIBRUBY_SO@%%g
+s%@LIBRUBY_ALIASES@%%g
+s%@LIBRUBY@%libruby.lib%g
+s%@LIBRUBYARG@%libruby.lib%g
+s%@SOLIBS@%%g
+s%@arch@%i386-mswin32%g
+s%@configure_args@%--with-make-prog=nmake%g
+s%@configure_input@%$configure_input%g
+s%@srcdir@%$srcdir%g
+s%@top_srcdir@%$top_srcdir%g
diff --git a/win32/ntsetup.bat b/win32/ntsetup.bat
index ee6294f..dc67b70 100755
--- a/win32/ntsetup.bat
+++ b/win32/ntsetup.bat
@@ -2,9 +2,7 @@
copy config.h ..
copy Makefile ..
copy ruby.def ..
-cd ..\ext
-copy Setup.nt Setup
-copy extmk.rb.nt extmk.rb
+copy config.status ..
cd ..
echo type `nmake' to make ruby for mswin32.
diff --git a/win32/ruby.def b/win32/ruby.def
index dfe63e5..126b4f2 100644
--- a/win32/ruby.def
+++ b/win32/ruby.def
@@ -2,65 +2,115 @@ LIBRARY rubymw.dll
DESCRIPTION 'win32 rubymw.dll'
EXPORTS
;;global objects
-;array.c:
+;array.c
rb_cArray
-;bignum.c:
+;bignum.c
rb_cBignum
+;compar.c
+ rb_mComparable
+;dir.c
+ rb_cDir
;enum.c
rb_mEnumerable
;error.c
- rb_eException;
+ rb_eException
rb_eSystemExit
rb_eInterrupt
- rb_eFatal;
- rb_eStandardError;
- rb_eRuntimeError;
- rb_eSyntaxError;
- rb_eTypeError;
- rb_eArgError;
- rb_eNameError;
- rb_eIndexError;
- rb_eLoadError;
- rb_eSecurityError;
- rb_eNotImpError;
- rb_eSystemCallError;
- rb_mErrno;
-;eval.c:
+ rb_eSignal
+ rb_eFatal
+ rb_eStandardError
+ rb_eRuntimeError
+ rb_eSyntaxError
+ rb_eTypeError
+ rb_eArgError
+ rb_eNameError
+ rb_eIndexError
+ rb_eLoadError
+ rb_eSecurityError
+ rb_eNotImpError
+ rb_eSystemCallError
+ rb_eZeroDivError
+ rb_mErrno
+;eval.c
rb_cProc
-;file.c:
+ rb_cThread
+ rb_thread_tick
+ rb_thread_critical
+;file.c
rb_cFile
-;hash.c:
+ rb_mFileTest
+;gc.c
+ rb_mGC
+;hash.c
rb_cHash
-;io.c:
+;io.c
rb_cIO
-;numeric.c:
+ rb_eEOFError
+ rb_eIOError
+;math.c
+ rb_mMath
+;numeric.c
rb_cNumeric
rb_cFloat
rb_cInteger
rb_cFixnum
+ rb_eFloatDomainError
;object.c
rb_mKernel
rb_cObject
rb_cModule
rb_cClass
rb_cData
-
rb_cNilClass
rb_cTrueClass
rb_cFalseClass
-;re.c:
+;prec.c
+ rb_mPrecision
+;process.c
+ rb_mProcess
+;range.c
+ rb_cRange
+;re.c
rb_cRegexp
-;string.c:
+;ruby.c
+ ruby_debug
+ ruby_verbose
+ rb_progname
+ rb_argv
+ rb_argv0
+;signal.c
+ rb_trap_pending
+ rb_trap_immediate
+ rb_prohibit_interrupt
+;string.c
rb_cString
rb_cStruct
+;time.c
+ rb_cTime
-; procedures/methods
-;missing/nt.c
+;;procedures/methods
+;missing/alloca.c
+ alloca
+;missing/crypt.c
+ definekey
+ encrypt
+ crypt
+;missing/fnmatch.c
+ fnmatch
+;missing/isinf.c
+ isinf
+;missing/isnan.c
+ isnan
+;win32/win32.c
NtInitialize
myfdopen
+ myfdclose
myaccept
mybind
myconnect
+ myfdset
+ myfdisset
+ myselect
mygetpeername
mygetsockname
mygetsockopt
@@ -80,10 +130,13 @@ EXPORTS
mygetprotobynumber
mygetservbyname
mygetservbyport
+ myget_osfhandle
+ win32_getenv
;array.c
+ rb_mem_clear
rb_ary_freeze
- rb_ary_new2
rb_ary_new
+ rb_ary_new2
rb_ary_new3
rb_ary_new4
rb_assoc_new
@@ -97,6 +150,8 @@ EXPORTS
rb_ary_each
rb_ary_join
rb_ary_to_s
+ rb_protect_inspect
+ rb_inspecting_p
rb_ary_reverse
rb_ary_sort_bang
rb_ary_sort
@@ -134,6 +189,7 @@ EXPORTS
rb_class_new
rb_singleton_class_new
rb_singleton_class_clone
+ rb_singleton_class_attached
rb_define_class_id
rb_define_class
rb_define_class_under
@@ -142,11 +198,17 @@ EXPORTS
rb_define_module
rb_define_module_under
rb_include_module
+ rb_mod_included_modules
+ rb_mod_ancestors
+ rb_class_instance_methods
+ rb_class_protected_instance_methods
+ rb_class_private_instance_methods
+ rb_obj_singleton_methods
rb_define_method_id
rb_define_method
- rb_undef_method
- rb_define_private_method
rb_define_protected_method
+ rb_define_private_method
+ rb_undef_method
rb_singleton_class
rb_define_singleton_method
rb_define_module_function
@@ -154,16 +216,14 @@ EXPORTS
rb_define_alias
rb_define_attr
rb_scan_args
-; dln.c
- dln_find_exe
- dln_find_file
+;dln.c
dln_load
dln_find_exe
dln_find_file
-; enum.c
+;enum.c
rb_each
rb_enum_length
-; error.c
+;error.c
rb_compile_error
rb_compile_error_append
rb_warn
@@ -180,12 +240,17 @@ EXPORTS
rb_sys_fail
;eval.c
rb_clear_cache
- rb_alias
rb_add_method
+ rb_alias
rb_remove_method
rb_disable_super
rb_enable_super
rb_method_boundp
+ rb_attr
+ rb_dvar_defined
+ rb_dvar_ref
+ rb_dvar_push
+ rb_dvar_asgn
rb_safe_level
rb_set_safe_level
rb_check_safe_str
@@ -194,55 +259,68 @@ EXPORTS
ruby_options
ruby_run
rb_eval_string
+ rb_eval_string_protect
+ rb_eval_string_wrap
rb_eval_cmd
- rb_trap_eval
- rb_test_false_or_nil
rb_respond_to
rb_exit
- rb_raise
- rb_fatal
+ rb_iter_break
+ rb_exc_raise
+ rb_exc_fatal
rb_interrupt
+ rb_jump_tag
rb_iterator_p
+ rb_yield
rb_iterate
rb_rescue
+ rb_protect
rb_ensure
+ rb_with_disable_interrupt
rb_apply
rb_funcall
rb_funcall2
rb_backtrace
rb_frame_last_func
+ rb_obj_instance_eval
rb_load
+ rb_load_protect
rb_provide
rb_f_require
- rb_obj_instance_eval
+ rb_require
rb_obj_call_init
rb_class_new_instance
rb_extend_object
- rb_f_global_variables
rb_set_end_proc
- rb_f_autoload
+ rb_exec_end_proc
rb_f_lambda
rb_gc_mark_threads
+ rb_thread_fd_close
rb_thread_schedule
rb_thread_wait_fd
rb_thread_fd_writable
rb_thread_wait_for
rb_thread_alone
rb_thread_select
+ rb_thread_current
+ rb_thread_main
+ rb_thread_wakeup
+ rb_thread_run
+ rb_thread_stop
rb_thread_sleep
rb_thread_sleep_forever
rb_thread_create
rb_thread_scope_shared_p
rb_thread_interrupt
+ rb_thread_signal_raise
rb_thread_trap_eval
+ rb_thread_local_aref
+ rb_thread_local_aset
rb_catch
rb_throw
- rb_yield
-; file.c
- rb_file_open
+;file.c
eaccess
rb_file_s_expand_path
-; gc.c
+;gc.c
xmalloc
xcalloc
xrealloc
@@ -250,61 +328,91 @@ EXPORTS
rb_newobj
rb_data_object_alloc
rb_gc_mark_locations
+ rb_mark_tbl
+ rb_mark_hash
rb_gc_mark_maybe
rb_gc_mark
rb_gc_force_recycle
rb_gc_mark_frame
rb_gc
-; hash.c
+ rb_gc_call_finalizer_at_exit
+;hash.c
rb_hash_freeze
rb_hash
rb_hash_new
rb_hash_aref
rb_hash_aset
-; inits.c
+ rb_path_check
+ rb_env_path_tainted
+ ruby_setenv
+ ruby_unsetenv
+;inits.c
rb_call_inits
-; io.c
+;io.c
rb_eof_error
+ rb_io_check_closed
+ rb_io_check_readable
+ rb_io_check_writable
+ rb_read_check
rb_io_write
+ rb_io_eof
rb_io_gets
rb_io_getc
+ rb_getc
rb_io_ungetc
rb_io_fptr_finalize
rb_io_close
+ rb_io_close_read
rb_io_binmode
rb_io_mode_flags
rb_fopen
rb_fdopen
+ rb_file_open
+ rb_file_sysopen
rb_io_unbuffered
- rb_io_reopen
+ rb_p
+ rb_gets
rb_str_setter
-; numeric.c
+;numeric.c
rb_num_zerodiv
rb_num_coerce_bin
rb_float_new
rb_num2long
rb_num2ulong
+ rb_num2int
+ rb_fix2int
rb_num2fix
rb_fix2str
-; object.c
+ rb_fix_upto
+;object.c
rb_equal
rb_eql
+ rb_obj_id
+ rb_obj_clone
rb_any_to_s
rb_inspect
rb_obj_is_instance_of
rb_obj_is_kind_of
+ rb_obj_tainted
+ rb_obj_taint
+ rb_obj_untaint
rb_obj_alloc
rb_to_id
- rb_class_of
- rb_type
- rb_special_const_p
+ rb_convert_type
rb_Integer
rb_Float
+ rb_num2dbl
+ rb_str2cstr
rb_String
rb_Array
-; parse.c
+;parse.c
+ rb_compile_string
+ rb_compile_cstr
+ rb_compile_file
rb_node_newnode
rb_id_attrset
+ rb_parser_append_print
+ rb_parser_while_loop
rb_intern
rb_id2name
rb_is_const_id
@@ -313,14 +421,15 @@ EXPORTS
rb_backref_set
rb_lastline_get
rb_lastline_set
-; process.c
+;process.c
rb_proc_exec
rb_syswait
-; range.c
+;range.c
rb_range_new
- rb_range_beg_end
-; re.c
+ rb_range_beg_len
+;re.c
rb_str_cicmp
+ rb_match_busy
rb_reg_search
rb_reg_nth_defined
rb_reg_nth_match
@@ -332,27 +441,33 @@ EXPORTS
rb_reg_regcomp
rb_reg_match
rb_reg_match2
+ rb_kcode
+ rb_reg_options
rb_reg_regsub
rb_get_kcode
rb_set_kcode
-; ruby.c
- ruby_require_modules
+;ruby.c
+ ruby_require_libraries
rb_load_file
ruby_script
ruby_prog_init
ruby_set_argv
ruby_process_options
-; signal.c
+;signal.c
+ rb_f_kill
rb_gc_mark_trap_list
rb_trap_exit
rb_trap_exec
-; sprintf.c
+ rb_trap_restore_mask
+;sprintf.c
rb_f_sprintf
-; st.c
+;st.c
st_init_table_with_size
st_init_table
st_init_numtable
+ st_init_numtable_with_size
st_init_strtable
+ st_init_strtable_with_size
st_free_table
st_lookup
st_insert
@@ -360,8 +475,9 @@ EXPORTS
st_copy
st_delete
st_delete_safe
+ st_cleanup_safe
st_foreach
-; string.c
+;string.c
rb_str_new
rb_str_new2
rb_tainted_str_new
@@ -379,30 +495,34 @@ EXPORTS
rb_str_dup_frozen
rb_str_resize
rb_str_cat
+ rb_str_concat
rb_str_hash
rb_str_cmp
rb_str_upto
rb_str_inspect
rb_str_split
-; struct.c
+;struct.c
rb_struct_getmember
rb_struct_define
rb_struct_alloc
rb_struct_new
rb_struct_aref
rb_struct_aset
-; time.c
+;time.c
rb_time_new
+ rb_time_interval
rb_time_timeval
-; util.c
+;util.c
rb_class_of
rb_type
rb_special_const_p
rb_test_false_or_nil
ruby_scan_oct
ruby_scan_hex
- rb_add_suffix
+ ruby_mktemp
+ ruby_qsort
;variable.c
+ rb_mod_name
rb_class_path
rb_set_class_path
rb_path2class
@@ -416,16 +536,26 @@ EXPORTS
rb_define_variable
rb_define_readonly_variable
rb_define_virtual_variable
+ rb_f_trace_var
+ rb_f_untrace_var
rb_gvar_get
rb_gvar_set
rb_gvar_set2
rb_gvar_defined
+ rb_f_global_variables
rb_alias_variable
+ rb_mark_generic_ivar
+ rb_mark_generic_ivar_tbl
+ rb_free_generic_ivar
+ rb_clone_generic_ivar
rb_ivar_get
rb_ivar_set
rb_ivar_defined
+ rb_obj_instance_variables
+ rb_obj_remove_instance_variable
rb_const_get_at
rb_const_get
+ rb_mod_remove_const
rb_mod_const_at
rb_mod_constants
rb_mod_const_of
@@ -437,7 +567,6 @@ EXPORTS
rb_define_global_const
rb_iv_get
rb_iv_set
-; version.c
+;version.c
ruby_show_version
ruby_show_copyright
-
diff --git a/win32/sdbm.c b/win32/sdbm.c
deleted file mode 100644
index d2d2171..0000000
--- a/win32/sdbm.c
+++ /dev/null
@@ -1,981 +0,0 @@
-/*
- * sdbm - ndbm work-alike hashed database library
- * based on Per-Aake Larson's Dynamic Hashing algorithms. BIT 18 (1978).
- * author: oz@nexus.yorku.ca
- * status: public domain.
- *
- * core routines
- */
-
-#ifndef lint
-/*char sdbm_rcsid[] = "$Id: sdbm.c,v 1.16 90/12/13 13:01:31 oz Exp $";*/
-#endif
-
-#include "sdbm.h"
-
-/*#include "tune.h"*/
-/*
- * sdbm - ndbm work-alike hashed database library
- * tuning and portability constructs [not nearly enough]
- * author: oz@nexus.yorku.ca
- */
-
-#define BYTESIZ 8
-
-#ifdef SVID
-#include <unistd.h>
-#endif
-
-#ifdef __GO32__
-#include <unistd.h>
-#endif
-
-#ifdef BSD42
-#define SEEK_SET L_SET
-#define memset(s,c,n) bzero(s, n) /* only when c is zero */
-#define memcpy(s1,s2,n) bcopy(s2, s1, n)
-#define memcmp(s1,s2,n) bcmp(s1,s2,n)
-#endif
-
-/*
- * important tuning parms (hah)
- */
-
-#define SEEDUPS /* always detect duplicates */
-#define BADMESS /* generate a message for worst case:
- cannot make room after SPLTMAX splits */
-/*
- * misc
- */
-#ifdef DEBUG
-#define debug(x) printf x
-#else
-#define debug(x)
-#endif
-
-#ifdef BIG_E
-#define GET_SHORT(p, i) (((unsigned)((unsigned char *)(p))[(i)*2] << 8) + (((unsigned char *)(p))[(i)*2 + 1]))
-#define PUT_SHORT(p, i, s) (((unsigned char *)(p))[(i)*2] = (unsigned char)((s) >> 8), ((unsigned char *)(p))[(i)*2 + 1] = (unsigned char)(s))
-#else
-#define GET_SHORT(p, i) ((p)[i])
-#define PUT_SHORT(p, i, s) ((p)[i] = (s))
-#endif
-
-/*#include "pair.h"*/
-static int fitpair proto((char *, int));
-static void putpair proto((char *, datum, datum));
-static datum getpair proto((char *, datum));
-static int delpair proto((char *, datum));
-static int chkpage proto((char *));
-static datum getnkey proto((char *, int));
-static void splpage proto((char *, char *, long));
-#ifdef SEEDUPS
-static int duppair proto((char *, datum));
-#endif
-
-#ifdef MSDOS
-#include <stdio.h>
-#include <stdlib.h>
-#include <io.h>
-#endif
-#include <sys/types.h>
-#include <sys/stat.h>
-#ifdef BSD42
-#include <sys/file.h>
-#else
-#include <fcntl.h>
-/*#include <memory.h>*/
-#endif
-#ifndef O_BINARY
-#define O_BINARY 0
-#endif
-
-#include <errno.h>
-#ifndef EPERM
-#define EPERM EACCES
-#endif
-#include <string.h>
-
-#ifdef __STDC__
-#include <stddef.h>
-#endif
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-/*
- * externals
- */
-#ifndef sun
-#ifndef MSDOS
-extern int errno;
-#endif
-#endif
-
-/*
- * forward
- */
-static int getdbit proto((DBM *, long));
-static int setdbit proto((DBM *, long));
-static int getpage proto((DBM *, long));
-static datum getnext proto((DBM *));
-static int makroom proto((DBM *, long, int));
-
-/*
- * useful macros
- */
-#define bad(x) ((x).dptr == NULL || (x).dsize < 0)
-#define exhash(item) dbm_hash((item).dptr, (item).dsize)
-#define ioerr(db) ((db)->flags |= DBM_IOERR)
-
-#define OFF_PAG(off) (long) (off) * PBLKSIZ
-#define OFF_DIR(off) (long) (off) * DBLKSIZ
-
-static long masks[] = {
- 000000000000L, 000000000001L, 000000000003L,
- 000000000007L, 000000000017L, 000000000037L,
- 000000000077L, 000000000177L, 000000000377L,
- 000000000777L, 000000001777L, 000000003777L,
- 000000007777L, 000000017777L, 000000037777L,
- 000000077777L, 000000177777L, 000000377777L,
- 000000777777L, 000001777777L, 000003777777L,
- 000007777777L, 000017777777L, 000037777777L,
- 000077777777L, 000177777777L, 000377777777L,
- 000777777777L, 001777777777L, 003777777777L,
- 007777777777L, 017777777777L
-};
-
-datum nullitem = {NULL, 0};
-
-DBM *
-dbm_open(file, flags, mode)
-register char *file;
-register int flags;
-register int mode;
-{
- register DBM *db;
- register char *dirname;
- register char *pagname;
- register int n;
-
- if (file == NULL || !*file)
- return errno = EINVAL, (DBM *) NULL;
-/*
- * need space for two seperate filenames
- */
- n = strlen(file) * 2 + strlen(DIRFEXT) + strlen(PAGFEXT) + 2;
-
- if ((dirname = malloc((unsigned) n)) == NULL)
- return errno = ENOMEM, (DBM *) NULL;
-/*
- * build the file names
- */
- dirname = strcat(strcpy(dirname, file), DIRFEXT);
- pagname = strcpy(dirname + strlen(dirname) + 1, file);
- pagname = strcat(pagname, PAGFEXT);
-
- db = dbm_prep(dirname, pagname, flags, mode);
- free((char *) dirname);
- return db;
-}
-
-DBM *
-dbm_prep(dirname, pagname, flags, mode)
-char *dirname;
-char *pagname;
-int flags;
-int mode;
-{
- register DBM *db;
- struct stat dstat;
-
- if ((db = (DBM *) malloc(sizeof(DBM))) == NULL)
- return errno = ENOMEM, (DBM *) NULL;
-
- db->flags = 0;
- db->hmask = 0;
- db->blkptr = 0;
- db->keyptr = 0;
-/*
- * adjust user flags so that WRONLY becomes RDWR,
- * as required by this package. Also set our internal
- * flag for RDONLY.
- */
- if (flags & O_WRONLY)
- flags = (flags & ~O_WRONLY) | O_RDWR;
- if (flags & O_RDONLY)
- db->flags = DBM_RDONLY;
-/*
- * open the files in sequence, and stat the dirfile.
- * If we fail anywhere, undo everything, return NULL.
- */
-#ifdef MSDOS
- flags |= O_BINARY;
-#endif
- if ((db->pagf = open(pagname, flags, mode)) > -1) {
- if ((db->dirf = open(dirname, flags, mode)) > -1) {
-/*
- * need the dirfile size to establish max bit number.
- */
- if (fstat(db->dirf, &dstat) == 0) {
-/*
- * zero size: either a fresh database, or one with a single,
- * unsplit data page: dirpage is all zeros.
- */
- db->dirbno = (!dstat.st_size) ? 0 : -1;
- db->pagbno = -1;
- db->maxbno = dstat.st_size * (long) BYTESIZ;
-
- (void) memset(db->pagbuf, 0, PBLKSIZ);
- (void) memset(db->dirbuf, 0, DBLKSIZ);
- /*
- * success
- */
- return db;
- }
- (void) close(db->dirf);
- }
- (void) close(db->pagf);
- }
- free((char *) db);
- return (DBM *) NULL;
-}
-
-void
-dbm_close(db)
-register DBM *db;
-{
- if (db == NULL)
- errno = EINVAL;
- else {
- (void) close(db->dirf);
- (void) close(db->pagf);
- free((char *) db);
- }
-}
-
-datum
-dbm_fetch(db, key)
-register DBM *db;
-datum key;
-{
- if (db == NULL || bad(key))
- return errno = EINVAL, nullitem;
-
- if (getpage(db, exhash(key)))
- return getpair(db->pagbuf, key);
-
- return ioerr(db), nullitem;
-}
-
-int
-dbm_delete(db, key)
-register DBM *db;
-datum key;
-{
- if (db == NULL || bad(key))
- return errno = EINVAL, -1;
- if (dbm_rdonly(db))
- return errno = EPERM, -1;
-
- if (getpage(db, exhash(key))) {
- if (!delpair(db->pagbuf, key))
- return -1;
-/*
- * update the page file
- */
- if (lseek(db->pagf, OFF_PAG(db->pagbno), SEEK_SET) < 0
- || write(db->pagf, db->pagbuf, PBLKSIZ) < 0)
- return ioerr(db), -1;
-
- return 0;
- }
-
- return ioerr(db), -1;
-}
-
-int
-dbm_store(db, key, val, flags)
-register DBM *db;
-datum key;
-datum val;
-int flags;
-{
- int need;
- register long hash;
-
- if (db == NULL || bad(key))
- return errno = EINVAL, -1;
- if (dbm_rdonly(db))
- return errno = EPERM, -1;
-
- need = key.dsize + val.dsize;
-/*
- * is the pair too big (or too small) for this database ??
- */
- if (need < 0 || need > PAIRMAX)
- return errno = EINVAL, -1;
-
- if (getpage(db, (hash = exhash(key)))) {
-/*
- * if we need to replace, delete the key/data pair
- * first. If it is not there, ignore.
- */
- if (flags == DBM_REPLACE)
- (void) delpair(db->pagbuf, key);
-#ifdef SEEDUPS
- else if (duppair(db->pagbuf, key))
- return 1;
-#endif
-/*
- * if we do not have enough room, we have to split.
- */
- if (!fitpair(db->pagbuf, need))
- if (!makroom(db, hash, need))
- return ioerr(db), -1;
-/*
- * we have enough room or split is successful. insert the key,
- * and update the page file.
- */
- (void) putpair(db->pagbuf, key, val);
-
- if (lseek(db->pagf, OFF_PAG(db->pagbno), SEEK_SET) < 0
- || write(db->pagf, db->pagbuf, PBLKSIZ) < 0)
- return ioerr(db), -1;
- /*
- * success
- */
- return 0;
- }
-
- return ioerr(db), -1;
-}
-
-/*
- * makroom - make room by splitting the overfull page
- * this routine will attempt to make room for SPLTMAX times before
- * giving up.
- */
-static int
-makroom(db, hash, need)
-register DBM *db;
-long hash;
-int need;
-{
- long newp;
- char twin[PBLKSIZ];
-#ifdef MSDOS
- char zer[PBLKSIZ];
-#endif
- char *pag = db->pagbuf;
- char *new = twin;
- register int smax = SPLTMAX;
- long oldtail;
-
- do {
-/*
- * split the current page
- */
- (void) splpage(pag, new, db->hmask + 1);
-/*
- * address of the new page
- */
- newp = (hash & db->hmask) | (db->hmask + 1);
- debug(("newp: %ld\n", newp));
-/*
- * write delay, read avoidence/cache shuffle:
- * select the page for incoming pair: if key is to go to the new page,
- * write out the previous one, and copy the new one over, thus making
- * it the current page. If not, simply write the new page, and we are
- * still looking at the page of interest. current page is not updated
- * here, as dbm_store will do so, after it inserts the incoming pair.
- */
-
-#ifdef MSDOS
- /*
- * Fill hole with 0 if made it.
- * (hole is NOT read as 0)
- */
- oldtail = lseek(db->pagf, 0L, SEEK_END);
- memset(zer, 0, PBLKSIZ);
- while (OFF_PAG(newp) > oldtail) {
- if (lseek(db->pagf, 0L, SEEK_END) < 0 ||
- write(db->pagf, zer, PBLKSIZ) < 0) {
-
- return 0;
- }
- oldtail += PBLKSIZ;
- }
-#endif
-
- if (hash & (db->hmask + 1)) {
- if (lseek(db->pagf, OFF_PAG(db->pagbno), SEEK_SET) < 0
- || write(db->pagf, db->pagbuf, PBLKSIZ) < 0)
- return 0;
- db->pagbno = newp;
- (void) memcpy(pag, new, PBLKSIZ);
- }
- else if (lseek(db->pagf, OFF_PAG(newp), SEEK_SET) < 0
- || write(db->pagf, new, PBLKSIZ) < 0)
- return 0;
-
- if (!setdbit(db, db->curbit))
- return 0;
-/*
- * see if we have enough room now
- */
- if (fitpair(pag, need))
- return 1;
-/*
- * try again... update curbit and hmask as getpage would have
- * done. because of our update of the current page, we do not
- * need to read in anything. BUT we have to write the current
- * [deferred] page out, as the window of failure is too great.
- */
- db->curbit = 2 * db->curbit +
- ((hash & (db->hmask + 1)) ? 2 : 1);
- db->hmask |= (db->hmask + 1);
-
- if (lseek(db->pagf, OFF_PAG(db->pagbno), SEEK_SET) < 0
- || write(db->pagf, db->pagbuf, PBLKSIZ) < 0)
- return 0;
-
- } while (--smax);
-/*
- * if we are here, this is real bad news. After SPLTMAX splits,
- * we still cannot fit the key. say goodnight.
- */
-#ifdef BADMESS
- (void) write(2, "sdbm: cannot insert after SPLTMAX attempts.\n", 44);
-#endif
- return 0;
-
-}
-
-/*
- * the following two routines will break if
- * deletions aren't taken into account. (ndbm bug)
- */
-datum
-dbm_firstkey(db)
-register DBM *db;
-{
- if (db == NULL)
- return errno = EINVAL, nullitem;
-/*
- * start at page 0
- */
- (void) memset(db->pagbuf, 0, PBLKSIZ);
- if (lseek(db->pagf, OFF_PAG(0), SEEK_SET) < 0
- || read(db->pagf, db->pagbuf, PBLKSIZ) < 0)
- return ioerr(db), nullitem;
- db->pagbno = 0;
- db->blkptr = 0;
- db->keyptr = 0;
-
- return getnext(db);
-}
-
-datum
-dbm_nextkey(db)
-register DBM *db;
-{
- if (db == NULL)
- return errno = EINVAL, nullitem;
- return getnext(db);
-}
-
-/*
- * all important binary trie traversal
- */
-static int
-getpage(db, hash)
-register DBM *db;
-register long hash;
-{
- register int hbit;
- register long dbit;
- register long pagb;
-
- dbit = 0;
- hbit = 0;
- while (dbit < db->maxbno && getdbit(db, dbit))
- dbit = 2 * dbit + ((hash & ((long) 1 << hbit++)) ? 2 : 1);
-
- debug(("dbit: %d...", dbit));
-
- db->curbit = dbit;
- db->hmask = masks[hbit];
-
- pagb = hash & db->hmask;
-/*
- * see if the block we need is already in memory.
- * note: this lookaside cache has about 10% hit rate.
- */
- if (pagb != db->pagbno) {
-/*
- * note: here, we assume a "hole" is read as 0s.
- * if not, must zero pagbuf first.
- */
- (void) memset(db->pagbuf, 0, PBLKSIZ);
-
- if (lseek(db->pagf, OFF_PAG(pagb), SEEK_SET) < 0
- || read(db->pagf, db->pagbuf, PBLKSIZ) < 0)
- return 0;
- if (!chkpage(db->pagbuf)) {
- return 0;
- }
- db->pagbno = pagb;
-
- debug(("pag read: %d\n", pagb));
- }
- return 1;
-}
-
-static int
-getdbit(db, dbit)
-register DBM *db;
-register long dbit;
-{
- register long c;
- register long dirb;
-
- c = dbit / BYTESIZ;
- dirb = c / DBLKSIZ;
-
- if (dirb != db->dirbno) {
- if (lseek(db->dirf, OFF_DIR(dirb), SEEK_SET) < 0
- || read(db->dirf, db->dirbuf, DBLKSIZ) < 0)
- return 0;
- db->dirbno = dirb;
-
- debug(("dir read: %d\n", dirb));
- }
-
- return db->dirbuf[c % DBLKSIZ] & (1 << (dbit % BYTESIZ));
-}
-
-static int
-setdbit(db, dbit)
-register DBM *db;
-register long dbit;
-{
- register long c;
- register long dirb;
-
- c = dbit / BYTESIZ;
- dirb = c / DBLKSIZ;
-
- if (dirb != db->dirbno) {
- if (lseek(db->dirf, OFF_DIR(dirb), SEEK_SET) < 0
- || read(db->dirf, db->dirbuf, DBLKSIZ) < 0)
- return 0;
- db->dirbno = dirb;
-
- debug(("dir read: %d\n", dirb));
- }
-
- db->dirbuf[c % DBLKSIZ] |= (1 << (dbit % BYTESIZ));
-
- if (dbit >= db->maxbno)
- db->maxbno += (long) DBLKSIZ * BYTESIZ;
-
- if (lseek(db->dirf, OFF_DIR(dirb), SEEK_SET) < 0
- || write(db->dirf, db->dirbuf, DBLKSIZ) < 0)
- return 0;
-
- return 1;
-}
-
-/*
- * getnext - get the next key in the page, and if done with
- * the page, try the next page in sequence
- */
-static datum
-getnext(db)
-register DBM *db;
-{
- datum key;
-
- for (;;) {
- db->keyptr++;
- key = getnkey(db->pagbuf, db->keyptr);
- if (key.dptr != NULL)
- return key;
-/*
- * we either run out, or there is nothing on this page..
- * try the next one... If we lost our position on the
- * file, we will have to seek.
- */
- db->keyptr = 0;
- if (db->pagbno != db->blkptr++)
- if (lseek(db->pagf, OFF_PAG(db->blkptr), SEEK_SET) < 0)
- break;
- db->pagbno = db->blkptr;
- if (read(db->pagf, db->pagbuf, PBLKSIZ) <= 0)
- break;
- if (!chkpage(db->pagbuf)) {
- break;
- }
- }
-
- return ioerr(db), nullitem;
-}
-
-/* pair.c */
-/*
- * sdbm - ndbm work-alike hashed database library
- * based on Per-Aake Larson's Dynamic Hashing algorithms. BIT 18 (1978).
- * author: oz@nexus.yorku.ca
- * status: public domain.
- *
- * page-level routines
- */
-
-#ifndef lint
-/*char pair_rcsid[] = "$Id: sdbm.c,v 1.1.1.1.2.1 1998/01/16 12:36:12 matz Exp $";*/
-#endif
-
-#ifndef BSD42
-/*#include <memory.h>*/
-#endif
-
-#define exhash(item) dbm_hash((item).dptr, (item).dsize)
-
-/*
- * forward
- */
-static int seepair proto((char *, int, char *, int));
-
-/*
- * page format:
- * +------------------------------+
- * ino | n | keyoff | datoff | keyoff |
- * +------------+--------+--------+
- * | datoff | - - - ----> |
- * +--------+---------------------+
- * | F R E E A R E A |
- * +--------------+---------------+
- * | <---- - - - | data |
- * +--------+-----+----+----------+
- * | key | data | key |
- * +--------+----------+----------+
- *
- * calculating the offsets for free area: if the number
- * of entries (ino[0]) is zero, the offset to the END of
- * the free area is the block size. Otherwise, it is the
- * nth (ino[ino[0]]) entry's offset.
- */
-
-static int
-fitpair(pag, need)
-char *pag;
-int need;
-{
- register int n;
- register int off;
- register int free;
- register short *ino = (short *) pag;
-
- off = ((n = GET_SHORT(ino,0)) > 0) ? GET_SHORT(ino,n) : PBLKSIZ;
- free = off - (n + 1) * sizeof(short);
- need += 2 * sizeof(short);
-
- debug(("free %d need %d\n", free, need));
-
- return need <= free;
-}
-
-static void
-putpair(pag, key, val)
-char *pag;
-datum key;
-datum val;
-{
- register int n;
- register int off;
- register short *ino = (short *) pag;
-
- off = ((n = GET_SHORT(ino,0)) > 0) ? GET_SHORT(ino,n) : PBLKSIZ;
-/*
- * enter the key first
- */
- off -= key.dsize;
- if (key.dsize)
- (void) memcpy(pag + off, key.dptr, key.dsize);
- PUT_SHORT(ino,n + 1,off);
-/*
- * now the data
- */
- off -= val.dsize;
- if (val.dsize)
- (void) memcpy(pag + off, val.dptr, val.dsize);
- PUT_SHORT(ino,n + 2,off);
-/*
- * adjust item count
- */
- PUT_SHORT(ino,0,GET_SHORT(ino,0) + 2);
-}
-
-static datum
-getpair(pag, key)
-char *pag;
-datum key;
-{
- register int i;
- register int n;
- datum val;
- register short *ino = (short *) pag;
-
- if ((n = GET_SHORT(ino,0)) == 0)
- return nullitem;
-
- if ((i = seepair(pag, n, key.dptr, key.dsize)) == 0)
- return nullitem;
-
- val.dptr = pag + GET_SHORT(ino,i + 1);
- val.dsize = GET_SHORT(ino,i) - GET_SHORT(ino,i + 1);
- return val;
-}
-
-#ifdef SEEDUPS
-static int
-duppair(pag, key)
-char *pag;
-datum key;
-{
- register short *ino = (short *) pag;
- return GET_SHORT(ino,0) > 0 &&
- seepair(pag, GET_SHORT(ino,0), key.dptr, key.dsize) > 0;
-}
-#endif
-
-static datum
-getnkey(pag, num)
-char *pag;
-int num;
-{
- datum key;
- register int off;
- register short *ino = (short *) pag;
-
- num = num * 2 - 1;
- if (GET_SHORT(ino,0) == 0 || num > GET_SHORT(ino,0))
- return nullitem;
-
- off = (num > 1) ? GET_SHORT(ino,num - 1) : PBLKSIZ;
-
- key.dptr = pag + GET_SHORT(ino,num);
- key.dsize = off - GET_SHORT(ino,num);
-
- return key;
-}
-
-static int
-delpair(pag, key)
-char *pag;
-datum key;
-{
- register int n;
- register int i;
- register short *ino = (short *) pag;
-
- if ((n = GET_SHORT(ino,0)) == 0)
- return 0;
-
- if ((i = seepair(pag, n, key.dptr, key.dsize)) == 0)
- return 0;
-/*
- * found the key. if it is the last entry
- * [i.e. i == n - 1] we just adjust the entry count.
- * hard case: move all data down onto the deleted pair,
- * shift offsets onto deleted offsets, and adjust them.
- * [note: 0 < i < n]
- */
- if (i < n - 1) {
- register int m;
- register char *dst = pag + (i == 1 ? PBLKSIZ : GET_SHORT(ino,i - 1));
- register char *src = pag + GET_SHORT(ino,i + 1);
- register int zoo = dst - src;
-
- debug(("free-up %d ", zoo));
-/*
- * shift data/keys down
- */
- m = GET_SHORT(ino,i + 1) - GET_SHORT(ino,n);
-#ifdef DUFF
-#define MOVB *--dst = *--src
-
- if (m > 0) {
- register int loop = (m + 8 - 1) >> 3;
-
- switch (m & (8 - 1)) {
- case 0: do {
- MOVB; case 7: MOVB;
- case 6: MOVB; case 5: MOVB;
- case 4: MOVB; case 3: MOVB;
- case 2: MOVB; case 1: MOVB;
- } while (--loop);
- }
- }
-#else
-#ifdef MEMMOVE
- memmove(dst, src, m);
-#else
- while (m--)
- *--dst = *--src;
-#endif
-#endif
-/*
- * adjust offset index up
- */
- while (i < n - 1) {
- PUT_SHORT(ino,i, GET_SHORT(ino,i + 2) + zoo);
- i++;
- }
- }
- PUT_SHORT(ino, 0, GET_SHORT(ino, 0) - 2);
- return 1;
-}
-
-/*
- * search for the key in the page.
- * return offset index in the range 0 < i < n.
- * return 0 if not found.
- */
-static int
-seepair(pag, n, key, siz)
-char *pag;
-register int n;
-register char *key;
-register int siz;
-{
- register int i;
- register int off = PBLKSIZ;
- register short *ino = (short *) pag;
-
- for (i = 1; i < n; i += 2) {
- if (siz == off - GET_SHORT(ino,i) &&
- memcmp(key, pag + GET_SHORT(ino,i), siz) == 0)
- return i;
- off = GET_SHORT(ino,i + 1);
- }
- return 0;
-}
-
-static void
-splpage(pag, new, sbit)
-char *pag;
-char *new;
-long sbit;
-{
- datum key;
- datum val;
-
- register int n;
- register int off = PBLKSIZ;
- char cur[PBLKSIZ];
- register short *ino = (short *) cur;
-
- (void) memcpy(cur, pag, PBLKSIZ);
- (void) memset(pag, 0, PBLKSIZ);
- (void) memset(new, 0, PBLKSIZ);
-
- n = GET_SHORT(ino,0);
- for (ino++; n > 0; ino += 2) {
- key.dptr = cur + GET_SHORT(ino,0);
- key.dsize = off - GET_SHORT(ino,0);
- val.dptr = cur + GET_SHORT(ino,1);
- val.dsize = GET_SHORT(ino,0) - GET_SHORT(ino,1);
-/*
- * select the page pointer (by looking at sbit) and insert
- */
- (void) putpair((exhash(key) & sbit) ? new : pag, key, val);
-
- off = GET_SHORT(ino,1);
- n -= 2;
- }
-
- debug(("%d split %d/%d\n", ((short *) cur)[0] / 2,
- ((short *) new)[0] / 2,
- ((short *) pag)[0] / 2));
-}
-
-/*
- * check page sanity:
- * number of entries should be something
- * reasonable, and all offsets in the index should be in order.
- * this could be made more rigorous.
- */
-static int
-chkpage(pag)
-char *pag;
-{
- register int n;
- register int off;
- register short *ino = (short *) pag;
-
- if ((n = GET_SHORT(ino,0)) < 0 || n > PBLKSIZ / sizeof(short))
- return 0;
-
- if (n > 0) {
- off = PBLKSIZ;
- for (ino++; n > 0; ino += 2) {
- if (GET_SHORT(ino,0) > off || GET_SHORT(ino,1) > off ||
- GET_SHORT(ino,1) > GET_SHORT(ino,0))
- return 0;
- off = GET_SHORT(ino,1);
- n -= 2;
- }
- }
- return 1;
-}
-
-/* hash.c */
-/*
- * sdbm - ndbm work-alike hashed database library
- * based on Per-Aake Larson's Dynamic Hashing algorithms. BIT 18 (1978).
- * author: oz@nexus.yorku.ca
- * status: public domain. keep it that way.
- *
- * hashing routine
- */
-
-/*
- * polynomial conversion ignoring overflows
- * [this seems to work remarkably well, in fact better
- * then the ndbm hash function. Replace at your own risk]
- * use: 65599 nice.
- * 65587 even better.
- */
-long
-dbm_hash(str, len)
-register char *str;
-register int len;
-{
- register unsigned long n = 0;
-
-#ifdef DUFF
-
-#define HASHC n = *str++ + 65599 * n
-
- if (len > 0) {
- register int loop = (len + 8 - 1) >> 3;
-
- switch(len & (8 - 1)) {
- case 0: do {
- HASHC; case 7: HASHC;
- case 6: HASHC; case 5: HASHC;
- case 4: HASHC; case 3: HASHC;
- case 2: HASHC; case 1: HASHC;
- } while (--loop);
- }
-
- }
-#else
- while (len--)
- n = ((*str++) & 255) + 65587L * n;
-#endif
- return n;
-}
diff --git a/win32/sdbm.h b/win32/sdbm.h
deleted file mode 100644
index 4b731c6..0000000
--- a/win32/sdbm.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * sdbm - ndbm work-alike hashed database library
- * based on Per-Ake Larson's Dynamic Hashing algorithms. BIT 18 (1978).
- * author: oz@nexus.yorku.ca
- * status: public domain.
- */
-#ifndef _NDBM_H_
-#define _NDBM_H_
-
-#define DBLKSIZ 4096
-#define PBLKSIZ 1024
-#define PAIRMAX 1008 /* arbitrary on PBLKSIZ-N */
-#define SPLTMAX 10 /* maximum allowed splits */
- /* for a single insertion */
-#define DIRFEXT ".dir"
-#define PAGFEXT ".pag"
-
-typedef struct {
- int dirf; /* directory file descriptor */
- int pagf; /* page file descriptor */
- int flags; /* status/error flags, see below */
- long maxbno; /* size of dirfile in bits */
- long curbit; /* current bit number */
- long hmask; /* current hash mask */
- long blkptr; /* current block for nextkey */
- int keyptr; /* current key for nextkey */
- long blkno; /* current page to read/write */
- long pagbno; /* current page in pagbuf */
- char pagbuf[PBLKSIZ]; /* page file block buffer */
- long dirbno; /* current block in dirbuf */
- char dirbuf[DBLKSIZ]; /* directory file block buffer */
-} DBM;
-
-#define DBM_RDONLY 0x1 /* data base open read-only */
-#define DBM_IOERR 0x2 /* data base I/O error */
-
-/*
- * utility macros
- */
-#define dbm_rdonly(db) ((db)->flags & DBM_RDONLY)
-#define dbm_error(db) ((db)->flags & DBM_IOERR)
-
-#define dbm_clearerr(db) ((db)->flags &= ~DBM_IOERR) /* ouch */
-
-#define dbm_dirfno(db) ((db)->dirf)
-#define dbm_pagfno(db) ((db)->pagf)
-
-typedef struct {
- char *dptr;
- int dsize;
-} datum;
-
-extern datum nullitem;
-
-#if defined(__STDC__) || defined(MSDOS)
-#define proto(p) p
-#else
-#define proto(p) ()
-#endif
-
-/*
- * flags to dbm_store
- */
-#define DBM_INSERT 0
-#define DBM_REPLACE 1
-
-/*
- * ndbm interface
- */
-extern DBM *dbm_open proto((char *, int, int));
-extern void dbm_close proto((DBM *));
-extern datum dbm_fetch proto((DBM *, datum));
-extern int dbm_delete proto((DBM *, datum));
-extern int dbm_store proto((DBM *, datum, datum, int));
-extern datum dbm_firstkey proto((DBM *));
-extern datum dbm_nextkey proto((DBM *));
-
-/*
- * other
- */
-extern DBM *dbm_prep proto((char *, char *, int, int));
-extern long dbm_hash proto((char *, int));
-
-#endif /* _NDBM_H_ */
diff --git a/win32/win32.c b/win32/win32.c
index 46489c4..fd70242 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -23,7 +23,7 @@
#include <windows.h>
#include <winbase.h>
#include <wincon.h>
-#include "nt.h"
+#include "win32.h"
#include "dir.h"
#ifndef index
#define index(x, y) strchr((x), (y))
@@ -33,6 +33,8 @@
#define bool int
#endif
+#define TO_SOCKET(x) _get_osfhandle(x)
+
bool NtSyncProcess = TRUE;
#if 0 // declared in header file
extern char **environ;
@@ -302,6 +304,14 @@ isInternalCmd(char *cmd)
}
+SOCKET
+myget_osfhandle(int fh)
+{
+ return _get_osfhandle(fh);
+
+}
+
+
FILE *
mypopen (char *cmd, char *mode)
{
@@ -1582,40 +1592,101 @@ valid_filename(char *s)
// if we can prevent perl from trying to do stdio on sockets.
//
+EXTERN_C int __cdecl _alloc_osfhnd(void);
+EXTERN_C int __cdecl _set_osfhnd(int fh, long value);
+EXTERN_C void __cdecl _lock_fhandle(int);
+EXTERN_C void __cdecl _unlock_fhandle(int);
+EXTERN_C void __cdecl _unlock(int);
+
+typedef struct {
+ long osfhnd; /* underlying OS file HANDLE */
+ char osfile; /* attributes of file (e.g., open in text mode?) */
+ char pipech; /* one char buffer for handles opened on pipes */
+#if defined (_MT) && !defined (DLL_FOR_WIN32S)
+ int lockinitflag;
+ CRITICAL_SECTION lock;
+#endif /* defined (_MT) && !defined (DLL_FOR_WIN32S) */
+} ioinfo;
+
+EXTERN_C ioinfo * __pioinfo[];
+
+#define IOINFO_L2E 5
+#define IOINFO_ARRAY_ELTS (1 << IOINFO_L2E)
+#define _pioinfo(i) (__pioinfo[i >> IOINFO_L2E] + (i & (IOINFO_ARRAY_ELTS - 1)))
+#define _osfile(i) (_pioinfo(i)->osfile)
+
+#define FOPEN 0x01 /* file handle open */
+#define FAPPEND 0x20 /* file handle opened O_APPEND */
+#define FDEV 0x40 /* file handle refers to device */
+#define FTEXT 0x80 /* file handle is in text mode */
+
+static int
+my_open_osfhandle(long osfhandle, int flags)
+{
+ int fh;
+ char fileflags; /* _osfile flags */
+
+ /* copy relevant flags from second parameter */
+ fileflags = FDEV;
+
+ if (flags & O_APPEND)
+ fileflags |= FAPPEND;
+
+ if (flags & O_TEXT)
+ fileflags |= FTEXT;
+
+ /* attempt to allocate a C Runtime file handle */
+ if ((fh = _alloc_osfhnd()) == -1) {
+ errno = EMFILE; /* too many open files */
+ _doserrno = 0L; /* not an OS error */
+ return -1; /* return error to caller */
+ }
+
+ /* the file is open. now, set the info in _osfhnd array */
+ _set_osfhnd(fh, osfhandle);
+
+ fileflags |= FOPEN; /* mark as open */
+
+ _osfile(fh) = fileflags; /* set osfile entry */
+// _unlock_fhandle(fh);
+
+ return fh; /* return handle */
+}
+
FILE *
myfdopen (int fd, const char *mode)
{
- FILE *fp;
char sockbuf[80];
int optlen;
int retval;
+ int fh;
extern int errno;
//fprintf(stderr, "myfdopen()\n");
+ optlen = sizeof(sockbuf);
retval = getsockopt((SOCKET)fd, SOL_SOCKET, SO_TYPE, sockbuf, &optlen);
if (retval == SOCKET_ERROR) {
int iRet;
iRet = WSAGetLastError();
if (iRet == WSAENOTSOCK || iRet == WSANOTINITIALISED)
- return (_fdopen(fd, mode));
+ return (_fdopen(fd, mode));
}
//
// If we get here, then fd is actually a socket.
//
- fp = xcalloc(sizeof(FILE), 1);
-#if _MSC_VER < 800
- fileno(fp) = fd;
-#else
- fp->_file = fd;
-#endif
- if (*mode == 'r')
- fp->_flag = _IOREAD;
- else
- fp->_flag = _IOWRT;
- return fp;
+
+ fh = my_open_osfhandle((SOCKET)fd, O_RDWR|O_BINARY);
+ return _fdopen(fh, mode); // return file pointer
+}
+
+
+void
+myfdclose(FILE *fp)
+{
+ fclose(fp);
}
@@ -1709,6 +1780,36 @@ ioctl(int i, unsigned int u, long data)
}
+#undef FD_SET
+
+void
+myfdset(int fd, fd_set *set)
+{
+ unsigned int i;
+ SOCKET s = TO_SOCKET(fd);
+
+ for (i = 0; i < set->fd_count; i++) {
+ if (set->fd_array[i] == s) {
+ return;
+ }
+ }
+ if (i == set->fd_count) {
+ if (set->fd_count < FD_SETSIZE) {
+ set->fd_array[i] = s;
+ set->fd_count++;
+ }
+ }
+}
+
+
+#undef FD_ISSET
+
+int
+myfdisset(int fd, fd_set *set)
+{
+ return __WSAFDIsSet(TO_SOCKET(fd), set);
+}
+
//
// Networking trampolines
// These are used to avoid socket startup/shutdown overhead in case
@@ -1737,6 +1838,7 @@ StartSockets () {
WORD version;
WSADATA retdata;
int ret;
+ int iSockOpt;
//
// initalize the winsock interface and insure that it\'s
@@ -1752,6 +1854,13 @@ StartSockets () {
rb_fatal("could not find version 1 of winsock dll\n");
atexit((void (*)(void)) WSACleanup);
+
+ iSockOpt = SO_SYNCHRONOUS_NONALERT;
+ /*
+ * Enable the use of sockets as filehandles
+ */
+ setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE,
+ (char *)&iSockOpt, sizeof(iSockOpt));
}
#undef accept
@@ -1764,7 +1873,7 @@ myaccept (SOCKET s, struct sockaddr *addr, int *addrlen)
if (!NtSocketsInitialized++) {
StartSockets();
}
- if ((r = accept (s, addr, addrlen)) == INVALID_SOCKET)
+ if ((r = accept (TO_SOCKET(s), addr, addrlen)) == INVALID_SOCKET)
errno = WSAGetLastError();
return r;
}
@@ -1808,7 +1917,7 @@ mygetpeername (SOCKET s, struct sockaddr *addr, int *addrlen)
if (!NtSocketsInitialized++) {
StartSockets();
}
- if ((r = getpeername (s, addr, addrlen)) == SOCKET_ERROR)
+ if ((r = getpeername (TO_SOCKET(s), addr, addrlen)) == SOCKET_ERROR)
errno = WSAGetLastError();
return r;
}
@@ -1822,7 +1931,7 @@ mygetsockname (SOCKET s, struct sockaddr *addr, int *addrlen)
if (!NtSocketsInitialized++) {
StartSockets();
}
- if ((r = getsockname (s, addr, addrlen)) == SOCKET_ERROR)
+ if ((r = getsockname (TO_SOCKET(s), addr, addrlen)) == SOCKET_ERROR)
errno = WSAGetLastError();
return r;
}
@@ -1850,7 +1959,7 @@ myioctlsocket (SOCKET s, long cmd, u_long *argp)
if (!NtSocketsInitialized++) {
StartSockets();
}
- if ((r = ioctlsocket (s, cmd, argp)) == SOCKET_ERROR)
+ if ((r = ioctlsocket (TO_SOCKET(s), cmd, argp)) == SOCKET_ERROR)
errno = WSAGetLastError();
return r;
}
@@ -1878,7 +1987,7 @@ myrecv (SOCKET s, char *buf, int len, int flags)
if (!NtSocketsInitialized++) {
StartSockets();
}
- if ((r = recv (s, buf, len, flags)) == SOCKET_ERROR)
+ if ((r = recv (TO_SOCKET(s), buf, len, flags)) == SOCKET_ERROR)
errno = WSAGetLastError();
return r;
}
@@ -1893,7 +2002,7 @@ myrecvfrom (SOCKET s, char *buf, int len, int flags,
if (!NtSocketsInitialized++) {
StartSockets();
}
- if ((r = recvfrom (s, buf, len, flags, from, fromlen)) == SOCKET_ERROR)
+ if ((r = recvfrom (TO_SOCKET(s), buf, len, flags, from, fromlen)) == SOCKET_ERROR)
errno = WSAGetLastError();
return r;
}
@@ -1907,7 +2016,7 @@ mysend (SOCKET s, char *buf, int len, int flags)
if (!NtSocketsInitialized++) {
StartSockets();
}
- if ((r = send (s, buf, len, flags)) == SOCKET_ERROR)
+ if ((r = send (TO_SOCKET(s), buf, len, flags)) == SOCKET_ERROR)
errno = WSAGetLastError();
return r;
}
@@ -1922,7 +2031,7 @@ mysendto (SOCKET s, char *buf, int len, int flags,
if (!NtSocketsInitialized++) {
StartSockets();
}
- if ((r = sendto (s, buf, len, flags, to, tolen)) == SOCKET_ERROR)
+ if ((r = sendto (TO_SOCKET(s), buf, len, flags, to, tolen)) == SOCKET_ERROR)
errno = WSAGetLastError();
return r;
}
@@ -1936,7 +2045,8 @@ mysetsockopt (SOCKET s, int level, int optname, char *optval, int optlen)
if (!NtSocketsInitialized++) {
StartSockets();
}
- if ((r = setsockopt (s, level, optname, optval, optlen)) == SOCKET_ERROR)
+ if ((r = setsockopt (s, level, optname, optval, optlen))
+ == SOCKET_ERROR)
errno = WSAGetLastError();
return r;
}
@@ -1950,7 +2060,7 @@ myshutdown (SOCKET s, int how)
if (!NtSocketsInitialized++) {
StartSockets();
}
- if ((r = shutdown (s, how)) == SOCKET_ERROR)
+ if ((r = shutdown (TO_SOCKET(s), how)) == SOCKET_ERROR)
errno = WSAGetLastError();
return r;
}
@@ -2120,7 +2230,7 @@ waitpid (pid_t pid, int *stat_loc, int options)
#include <sys/timeb.h>
-void _cdecl
+int _cdecl
gettimeofday(struct timeval *tv, struct timezone *tz)
{
struct timeb tb;
@@ -2128,6 +2238,8 @@ gettimeofday(struct timeval *tv, struct timezone *tz)
ftime(&tb);
tv->tv_sec = tb.time;
tv->tv_usec = tb.millitm * 1000;
+
+ return 0;
}
char *
@@ -2170,16 +2282,17 @@ str_grow(struct RString *str, size_t new_size)
}
int
-chown(char *path, int owner, int group)
+chown(const char *path, int owner, int group)
{
return 0;
}
+#include <signal.h>
int
kill(int pid, int sig)
{
#if 1
- if (pid == GetCurrentProcessId())
+ if ((unsigned int)pid == GetCurrentProcessId())
return raise(sig);
if (sig == 2 && pid > 0)
@@ -2204,3 +2317,28 @@ wait()
return 0;
}
+char *
+win32_getenv(const char *name)
+{
+ static char *curitem = NULL; /* XXX threadead */
+ static DWORD curlen = 0; /* XXX threadead */
+ DWORD needlen;
+ if (!curitem) {
+ curlen = 512;
+ curitem = ALLOC_N(char, curlen);
+ }
+
+ needlen = GetEnvironmentVariable(name,curitem,curlen);
+ if (needlen != 0) {
+ while (needlen > curlen) {
+ REALLOC_N(curitem, char, needlen);
+ curlen = needlen;
+ needlen = GetEnvironmentVariable(name, curitem, curlen);
+ }
+ }
+ else {
+ return NULL;
+ }
+
+ return curitem;
+}
diff --git a/win32/win32.h b/win32/win32.h
index a3d1f21..04cb192 100644
--- a/win32/win32.h
+++ b/win32/win32.h
@@ -85,6 +85,11 @@
#undef except
#undef finally
#undef leave
+
+#if defined(__cplusplus)
+}
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -94,10 +99,17 @@
#include <math.h>
#include <sys/types.h>
#include <sys/utime.h>
+#include <io.h>
+#include <malloc.h>
-//
-// Grrr...
-//
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+#define UIDTYPE int
+#define GIDTYPE int
+#define pid_t int
+#define WNOHANG -1
#define access _access
#define chmod _chmod
@@ -113,6 +125,7 @@
#define lseek _lseek
#define mktemp _mktemp
#define open _open
+#define perror _perror
#define read _read
#define setmode _setmode
#define sopen _sopen
@@ -129,6 +142,7 @@
#define execvp _execvp
#define execvpe _execvpe
#define getpid _getpid
+#define sleep(x) Sleep((x)*1000)
#define spawnl _spawnl
#define spawnle _spawnle
#define spawnlp _spawnlp
@@ -141,22 +155,29 @@
#define fileno _fileno
#endif
#define utime _utime
-//#define pipe _pipe
-#define perror _perror
-
-
+#define vsnprintf _vsnprintf
+#define snprintf _snprintf
+#define popen _popen
+#define pclose _pclose
+#define strcasecmp _stricmp
+#define strncasecmp _strnicmp
/* these are defined in nt.c */
extern int NtMakeCmdVector(char *, char ***, int);
-/* extern void NtInitialize(int *, char ***); */
+extern void NtInitialize(int *, char ***);
extern char *NtGetLib(void);
extern char *NtGetBin(void);
extern FILE *mypopen(char *, char *);
+extern int mypclose(FILE *);
extern int flock(int fd, int oper);
-extern FILE * myfdopen(int, char*);
+extern FILE * myfdopen(int, const char *);
+extern void myfdclose(FILE *);
extern SOCKET myaccept(SOCKET, struct sockaddr *, int *);
extern int mybind(SOCKET, struct sockaddr *, int);
extern int myconnect(SOCKET, struct sockaddr *, int);
+extern void myfdset(int, fd_set*);
+extern int myfdisset(int, fd_set*);
+extern long myselect(int, fd_set *, fd_set *, fd_set *, struct timeval *);
extern int mygetpeername(SOCKET, struct sockaddr *, int *);
extern int mygetsockname(SOCKET, struct sockaddr *, int *);
extern int mygetsockopt(SOCKET, int, int, char *, int *);
@@ -169,6 +190,7 @@ extern int mysendto(SOCKET, char *, int, int, struct sockaddr *, int);
extern int mysetsockopt(SOCKET, int, int, char *, int);
extern int myshutdown(SOCKET, int);
extern SOCKET mysocket(int, int, int);
+extern SOCKET myget_osfhandle(int);
extern struct hostent * mygethostbyaddr(char *, int, int);
extern struct hostent * mygethostbyname(char *);
extern int mygethostname(char *, int);
@@ -176,6 +198,17 @@ extern struct protoent * mygetprotobyname(char *);
extern struct protoent * mygetprotobynumber(int);
extern struct servent * mygetservbyname(char *, char *);
extern struct servent * mygetservbyport(int, char *);
+extern char *win32_getenv(const char *);
+
+extern int chown(const char *, int, int);
+extern int link(char *, char *);
+extern int gettimeofday(struct timeval *, struct timezone *);
+extern pid_t waitpid (pid_t, int *, int);
+extern int do_spawn(char *);
+extern int kill(int, int);
+extern int isinf(double);
+extern int isnan(double);
+
//
// define this so we can do inplace editing
@@ -186,14 +219,7 @@ extern struct servent * mygetservbyport(int, char *);
//
// stubs
//
-// extern int ioctl (int, unsigned int, char *);
extern int ioctl (int, unsigned int, long);
-#if 0
-extern void sleep (unsigned int);
-#else
-#define sleep(x) Sleep(x*1000)
-#endif
-
extern UIDTYPE getuid (void);
extern UIDTYPE geteuid (void);
extern GIDTYPE getgid (void);
@@ -202,8 +228,6 @@ extern int setuid (int);
extern int setgid (int);
-#undef IN /* confict in parse.c */
-
#if 0
extern int sys_nerr;
extern char *sys_errlist[];
@@ -214,11 +238,6 @@ extern char *mystrerror(int);
#define PIPE_BUF 1024
-#define HAVE_STDLIB_H 1
-#define HAVE_GETLOGIN 1
-#define HAVE_WAITPID 1
-#define HAVE_GETCWD 1
-
#define LOCK_SH 1
#define LOCK_EX 2
#define LOCK_NB 4
@@ -227,8 +246,6 @@ extern char *mystrerror(int);
#define EWOULDBLOCK 10035 /* EBASEERR + 35 (winsock.h) */
#endif
-#define O_BINARY 0x8000
-
#ifdef popen
#undef popen
#define popen mypopen
@@ -261,6 +278,15 @@ extern char *mystrerror(int);
#endif
#define connect myconnect
+#undef FD_SET
+#define FD_SET myfdset
+
+#undef FD_ISSET
+#define FD_ISSET myfdisset
+
+#undef select
+#define select myselect
+
#ifdef getpeername
#undef getpeername
#endif
@@ -355,4 +381,15 @@ extern char *mystrerror(int);
#undef getservbyport
#endif
#define getservbyport mygetservbyport
+
+#ifdef get_osfhandle
+#undef get_osfhandle
+#endif
+#define get_osfhandle myget_osfhandle
+
+#ifdef getenv
+#undef getenv
+#endif
+#define getenv win32_getenv
+
#endif