summaryrefslogtreecommitdiff
path: root/ruby_1_8_5/wince
diff options
context:
space:
mode:
Diffstat (limited to 'ruby_1_8_5/wince')
-rw-r--r--ruby_1_8_5/wince/Makefile.sub505
-rw-r--r--ruby_1_8_5/wince/README.wince121
-rw-r--r--ruby_1_8_5/wince/assert.c11
-rw-r--r--ruby_1_8_5/wince/assert.h6
-rwxr-xr-xruby_1_8_5/wince/configure.bat102
-rw-r--r--ruby_1_8_5/wince/direct.c54
-rw-r--r--ruby_1_8_5/wince/direct.h22
-rw-r--r--ruby_1_8_5/wince/errno.c11
-rw-r--r--ruby_1_8_5/wince/errno.h55
-rw-r--r--ruby_1_8_5/wince/fcntl.h42
-rw-r--r--ruby_1_8_5/wince/io.h76
-rw-r--r--ruby_1_8_5/wince/io_wce.c230
-rw-r--r--ruby_1_8_5/wince/mkconfig_wce.rb7
-rw-r--r--ruby_1_8_5/wince/mkexports.rb35
-rw-r--r--ruby_1_8_5/wince/process.h46
-rw-r--r--ruby_1_8_5/wince/process_wce.c47
-rw-r--r--ruby_1_8_5/wince/resource.rb96
-rw-r--r--ruby_1_8_5/wince/setup.mak245
-rw-r--r--ruby_1_8_5/wince/signal.h71
-rw-r--r--ruby_1_8_5/wince/signal_wce.c26
-rw-r--r--ruby_1_8_5/wince/stddef.h5
-rw-r--r--ruby_1_8_5/wince/stdio.c36
-rw-r--r--ruby_1_8_5/wince/stdlib.c57
-rw-r--r--ruby_1_8_5/wince/string_wce.c89
-rw-r--r--ruby_1_8_5/wince/sys/stat.c102
-rw-r--r--ruby_1_8_5/wince/sys/stat.h68
-rw-r--r--ruby_1_8_5/wince/sys/timeb.c25
-rw-r--r--ruby_1_8_5/wince/sys/timeb.h26
-rw-r--r--ruby_1_8_5/wince/sys/types.h60
-rw-r--r--ruby_1_8_5/wince/sys/utime.c44
-rw-r--r--ruby_1_8_5/wince/sys/utime.h27
-rw-r--r--ruby_1_8_5/wince/time.h63
-rw-r--r--ruby_1_8_5/wince/time_wce.c301
-rw-r--r--ruby_1_8_5/wince/varargs.h34
-rw-r--r--ruby_1_8_5/wince/wince.c583
-rw-r--r--ruby_1_8_5/wince/wince.h191
-rw-r--r--ruby_1_8_5/wince/wincemain.c19
-rw-r--r--ruby_1_8_5/wince/wincon.h7
-rw-r--r--ruby_1_8_5/wince/winsock2.c338
39 files changed, 3883 insertions, 0 deletions
diff --git a/ruby_1_8_5/wince/Makefile.sub b/ruby_1_8_5/wince/Makefile.sub
new file mode 100644
index 0000000000..2cb4aba983
--- /dev/null
+++ b/ruby_1_8_5/wince/Makefile.sub
@@ -0,0 +1,505 @@
+# -*- makefile -*-
+
+SHELL = $(COMSPEC)
+MKFILES = Makefile
+NULL = nul
+
+#### Start of system configuration section. ####
+
+## variables may be overridden by $(compile_dir)/Makefile
+!ifndef srcdir
+srcdir = ..
+!endif
+!ifndef RUBY_INSTALL_NAME
+RUBY_INSTALL_NAME = ruby
+!endif
+!if !defined(RUBYW_INSTALL_NAME) || "$(RUBYW_INSTALL_NAME)" == "$(RUBY_INSTALL_NAME)"
+RUBYW_INSTALL_NAME = $(RUBY_INSTALL_NAME:ruby=rubyw)
+!endif
+!if "$(RUBYW_INSTALL_NAME)" == "$(RUBY_INSTALL_NAME)"
+RUBYW_INSTALL_NAME = $(RUBY_INSTALL_NAME)w
+!endif
+!if !defined(icondirs) && defined(ICONDIRS)
+icondirs=$(ICONDIRS)
+!endif
+!if defined(icondirs)
+icondirs=$(icondirs:\=/)
+iconinc=-I$(icondirs: = -I)
+!endif
+###############
+
+VPATH = $(srcdir);$(srcdir)/missing;$(srcdir)/wince
+.SUFFIXES: .y .def .lib
+
+!if !defined(CC)
+CC = cl
+!endif
+!if !defined(CPP)
+CPP = $(CC) -E
+!endif
+!if !defined(YACC)
+YACC = byacc
+!endif
+AR = lib -nologo
+PURIFY =
+AUTOCONF = autoconf
+RM = $(srcdir)\win32\rm.bat
+
+!if !defined(PROCESSOR_ARCHITECTURE)
+PROCESSOR_ARCHITECTURE = x86
+!endif
+MACHINE = $(PROCESSOR_ARCHITECTURE)
+!if "$(PROCESSOR_ARCHITECTURE)" == "x86"
+!if !defined(PROCESSOR_LEVEL)
+PROCESSOR_LEVEL = 5
+!endif
+!if 6 < $(PROCESSOR_LEVEL)
+PROCESSOR_LEVEL = 6
+!endif
+PROCESSOR_FLAG = -G$(PROCESSOR_LEVEL)
+CPU = i$(PROCESSOR_LEVEL)86
+ARCH = i386
+!else
+CPU = $(PROCESSOR_ARCHITECTURE)
+ARCH = $(PROCESSOR_ARCHITECTURE)
+!endif
+!if !defined(DEBUGFLAGS)
+DEBUGFLAGS = -Zi
+!endif
+!if !defined(OPTFLAGS)
+OPTFLAGS = -w -O2b2xg-
+!endif
+!if !defined(OS) || !defined(RT)
+OS = mswince
+RT = $(OS)
+!endif
+
+!ifndef RUBY_SO_NAME
+RUBY_SO_NAME = $(RT)-$(RUBY_INSTALL_NAME)$(MAJOR)$(MINOR)
+!endif
+!ifndef RUBY_PLATFORM
+RUBY_PLATFORM = $(ARCH)-$(OS)
+!endif
+
+!if !defined(prefix)
+prefix = /usr
+!endif
+!if !defined(exec_prefix)
+exec_prefix = $(prefix)
+!endif
+!if !defined(libdir)
+libdir = $(exec_prefix)/lib
+!endif
+!if !defined(datadir)
+datadir = /share
+!endif
+!ifndef EXTOUT
+EXTOUT = .ext
+!endif
+!ifndef RIDATADIR
+RIDATADIR = $(DESTDIR)$(datadir)/ri/$(MAJOR).$(MINOR)/system
+!endif
+!ifndef RDOCTARGET
+RDOCTARGET = install-doc
+!endif
+
+OUTFLAG = -Fe
+!if !defined(CFLAGS)
+CFLAGS = $(DEBUGFLAGS) $(OPTFLAGS) $(PROCESSOR_FLAG)
+!endif
+!if !defined(CPPFLAGS)
+CPPFLAGS = $(CECPUDEF) -DUNDER_CE -D_WIN32_WCE=$(SUBSYSVERSION:.=) \
+ -DFILENAME_MAX=MAX_PATH -DTLS_OUT_OF_INDEXES=0xFFFFFFFF \
+ -DBUFSIZ=512 -D_UNICODE -DUNICODE
+!endif
+!if !defined(LDFLAGS)
+LDFLAGS = -link -incremental:yes -pdb:none -machine:$(MACHINE) -subsystem:$(SUBSYSTEM)
+!endif
+!if !defined(XLDFLAGS)
+XLDFLAGS = -stack:$(STACK) -subsystem:$(SUBSYSTEM)
+!endif
+!if !defined(RFLAGS)
+RFLAGS = -r
+!endif
+!if !defined(EXTLIBS)
+EXTLIBS =
+!endif
+LIBS = coredll.lib ceshell.lib winsock.lib $(EXTLIBS)
+MISSING = acosh.obj crypt.obj dup2.obj erf.obj hypot.obj \
+ isinf.obj isnan.obj strftime.obj win32.obj \
+ assert.obj direct.obj errno.obj io_wce.obj process_wce.obj \
+ signal_wce.obj stdio.obj stdlib.obj string_wce.obj \
+ time_wce.obj wince.obj winsock2.obj \
+ stat.obj timeb.obj utime.obj
+
+ARFLAGS = -machine:$(MACHINE) -out:
+CC = $(CC) -nologo
+LD = $(CC)
+LDSHARED = $(LD) -LD
+XCFLAGS = -DRUBY_EXPORT -I. -I$(srcdir) -I$(srcdir)/missing -I$(srcdir)/wince
+DLDFLAGS = $(LDFLAGS) -dll
+SOLIBS =
+
+LIBRUBY_LDSHARED = $(LDSHARED)
+LIBRUBY_DLDFLAGS = $(EXTLDFLAGS) -def:$(RUBYDEF)
+
+EXEEXT = .exe
+PROGRAM=$(RUBY_INSTALL_NAME)$(EXEEXT)
+RUBYDEF = $(RUBY_SO_NAME).def
+MINIRUBY = $(RUBY) -I$(MAKEDIR) -rfake
+RUNRUBY = $(MINIRUBY) "$(srcdir)/runruby.rb" --extout="$(EXTOUT)" --
+!ifndef RUBY
+RUBY = ruby
+!endif
+
+!if !defined(STACK)
+STACK = 0x200000,0x10000
+!endif
+ORGLIBPATH = $(LIB)
+
+#### End of system configuration section. ####
+
+LIBRUBY_A = $(RUBY_SO_NAME)-static.lib
+LIBRUBY_SO = $(RUBY_SO_NAME).dll
+LIBRUBY = $(RUBY_SO_NAME).lib
+LIBRUBYARG = $(LIBRUBY)
+
+PREP = fake.rb
+
+!if !defined(EXTSTATIC)
+EXTSTATIC =
+!endif
+
+OBJEXT = obj
+
+WINMAINOBJ = wincemain.$(OBJEXT)
+
+all: $(srcdir)/wince/Makefile.sub $(srcdir)/common.mk
+ruby: $(PROGRAM)
+
+CONFIG_H = ./.config.h.time
+
+config: config.status
+
+config.status: $(CONFIG_H)
+
+BANG = !
+
+!if exist(config.h)
+!include config.h
+!endif
+
+$(CONFIG_H): $(MKFILES) $(srcdir)/wince/Makefile.sub
+ @echo Creating config.h
+ @$(srcdir:/=\)\win32\ifchange.bat config.h <<
+#define STDC_HEADERS 1
+#define HAVE_SYS_TYPES_H 1
+#define HAVE_SYS_STAT_H 1
+#define HAVE_STDLIB_H 1
+#define HAVE_STRING_H 1
+#define HAVE_MEMORY_H 1
+#define HAVE_OFF_T 1
+#define SIZEOF_INT 4
+#define SIZEOF_SHORT 2
+#define SIZEOF_LONG 4
+#define SIZEOF_LONG_LONG 0
+#define SIZEOF___INT64 8
+#define SIZEOF_OFF_T 4
+#define SIZEOF_VOIDP 4
+#define SIZEOF_FLOAT 4
+#define SIZEOF_DOUBLE 8
+#define SIZEOF_TIME_T 4
+#define HAVE_PROTOTYPES 1
+#define TOKEN_PASTE(x,y) x##y
+#define HAVE_STDARG_PROTOTYPES 1
+!if $(MSC_VER) > 1100
+#define NORETURN(x) __declspec(noreturn) x
+!endif
+#define RUBY_EXTERN extern __declspec(dllimport)
+#define HAVE_DECL_SYS_NERR 1
+#define HAVE_FCNTL_H 1
+#define HAVE_SYS_UTIME_H 1
+#define HAVE_FLOAT_H 1
+#define rb_uid_t int
+#define rb_gid_t int
+#define rb_pid_t int
+#define HAVE_STRUCT_STAT_ST_RDEV 1
+#define HAVE_ST_RDEV 1
+#define GETGROUPS_T int
+#define RETSIGTYPE void
+#define HAVE_MEMCMP 1
+#define HAVE_MEMMOVE 1
+#define HAVE_MKDIR 1
+#define HAVE_STRCASECMP 1
+#define HAVE_STRNCASECMP 1
+#define HAVE_STRERROR 1
+#define HAVE_STRFTIME 1
+#define HAVE_STRCHR 1
+#define HAVE_STRSTR 1
+#define HAVE_STRTOD 1
+#define HAVE_STRTOL 1
+#define HAVE_STRTOUL 1
+#define HAVE_FLOCK 1
+#define HAVE_VSNPRINTF 1
+#define HAVE_FINITE 1
+#define HAVE_HYPOT 1
+#define HAVE_FMOD 1
+#define HAVE_FREXP 1
+#define HAVE_MODF 1
+#define HAVE_WAITPID 1
+#define HAVE_GETCWD 1
+#define HAVE_CHSIZE 0
+#define HAVE_TIMES 1
+#define HAVE_FCNTL 1
+#define HAVE_TELLDIR 1
+#define HAVE_SEEKDIR 1
+#define HAVE_MKTIME 1
+#define HAVE_COSH 1
+#define HAVE_SINH 1
+#define HAVE_TANH 1
+#define HAVE_TZNAME 1
+#define HAVE_DAYLIGHT 1
+#define SETPGRP_VOID 1
+#define RSHIFT(x,y) ((x)>>(int)y)
+#define inline __inline
+#define NEED_IO_SEEK_BETWEEN_RW 1
+#define DEFAULT_KCODE KCODE_NONE
+#define DLEXT ".so"
+#define RUBY_LIB "/lib/ruby/$(MAJOR).$(MINOR)"
+#define RUBY_SITE_LIB "/lib/ruby/site_ruby"
+#define RUBY_SITE_LIB2 "/lib/ruby/site_ruby/$(MAJOR).$(MINOR)"
+#define RUBY_PLATFORM "$(ARCH)-$(OS)"
+#define RUBY_ARCHLIB "/lib/ruby/$(MAJOR).$(MINOR)/$(ARCH)-$(OS)"
+#define RUBY_SITE_ARCHLIB "/lib/ruby/site_ruby/$(MAJOR).$(MINOR)/$(ARCH)-$(RT)"
+#define LIBRUBY_SO "$(LIBRUBY_SO)"
+#if 0
+$(BANG)if "$(RUBY_SO_NAME)"!="$$(RUBY_SO_NAME)" || "$(ARCH)-$(OS)"!="$$(ARCH)-$$(OS)"
+config.h: nul
+$(BANG)endif
+#endif
+#define GC_MALLOC_LIMIT 4000000
+#define stricmp _stricmp
+#define fopen wce_fopen
+#define open _open
+#define read _read
+#define write _write
+#define lseek _lseek
+
+#if _WIN32_WCE < 300
+ #define isascii(c) ( (c>=0x00&&c<=0x7f)?1:0 )
+ #define isspace(c) ( ((c>=0x09&&c<=0x0d)||c==0x20)?1:0 )
+ #define isdigit(c) ( (c>=0x30&&c<=0x39)?1:0 )
+ #define isupper(c) ( (c>='A'&&c<='Z')?1:0 )
+ #define isalpha(c) ( ((c>='A'&&c<='Z')||(c>='a'&&c<='z'))?1:0 )
+ #define isprint(c) ( (c>=0x20&&c<=0x7e)?1:0 )
+ #define isalnum(c) ( (isalpha(c)||isdigit(c))?1:0 )
+ #define iscntrl(c) ( ((c>=0x00&&c<=0x1f)||c==0x7f)?1:0 )
+ #define islower(c) ( (c>='a'&&c<='z')?1:0 )
+ #define ispunct(c) ( !(isalnum(c)||isspace(c))?1:0 )
+ #define isxdigit(c) ( ((c>=0&&c<=9)||(c>='A'&&c<='F')||(c>='a'&&c<='f'))?1:0 )
+#endif
+<<
+ @exit > $(@:/=\)
+
+config.status: $(MKFILES) $(srcdir)/wince/Makefile.sub $(srcdir)/common.mk
+ @echo Creating $@
+ @exit <<$@
+# Generated automatically by Makefile.sub.
+s,@SHELL@,$$(COMSPEC),;t t
+s,@BUILD_FILE_SEPARATOR@,\,;t t
+s,@PATH_SEPARATOR@,;,;t t
+s,@CFLAGS@,$(CFLAGS),;t t
+s,@CPPFLAGS@,$(CPPFLAGS),;t t
+s,@CXXFLAGS@,$(CXXFLAGS),;t t
+s,@FFLAGS@,$(FFLAGS),;t t
+s,@LDFLAGS@,,;t t
+s,@LIBS@,$(LIBS),;t t
+s,@exec_prefix@,$${prefix},;t t
+s,@prefix@,,;t t
+s,@program_transform_name@,s,,,,;t t
+s,@bindir@,$${exec_prefix}/bin,;t t
+s,@sbindir@,$${exec_prefix}/sbin,;t t
+s,@libexecdir@,$${exec_prefix}/libexec,;t t
+s,@datadir@,$${prefix}/share,;t t
+s,@sysconfdir@,$${prefix}/etc,;t t
+s,@sharedstatedir@,/etc,;t t
+s,@localstatedir@,/var,;t t
+s,@libdir@,$${exec_prefix}/lib,;t t
+s,@includedir@,$${prefix}/include,;t t
+s,@oldincludedir@,/usr/include,;t t
+s,@infodir@,$${prefix}/info,;t t
+s,@mandir@,$${prefix}/man,;t t
+s,@build@,$(CPU)-pc-$(OS),;t t
+s,@build_alias@,$(CPU)-$(OS),;t t
+s,@build_cpu@,$(CPU),;t t
+s,@build_vendor@,pc,;t t
+s,@build_os@,$(OS),;t t
+s,@host@,$(CPU)-pc-$(OS),;t t
+s,@host_alias@,$(CPU)-$(OS),;t t
+s,@host_cpu@,$(CPU),;t t
+s,@host_vendor@,pc,;t t
+s,@host_os@,$(OS),;t t
+s,@target@,$(ARCH)-pc-$(OS),;t t
+s,@target_alias@,$(ARCH)-$(OS),;t t
+s,@target_cpu@,$(ARCH),;t t
+s,@target_vendor@,pc,;t t
+s,@target_os@,$(OS),;t t
+s,@CC@,$(CC),;t t
+s,@CPP@,$(CPP),;t t
+s,@YACC@,$(YACC),;t t
+s,@RANLIB@,,;t t
+s,@AR@,$(AR),;t t
+s,@ARFLAGS@,$(ARFLAGS),;t t
+s,@LN_S@,$(LN_S),;t t
+s,@SET_MAKE@,$(SET_MAKE),;t t
+s,@CP@,copy > nul,;t t
+s,@INSTALL@,copy > nul,;t t
+s,@INSTALL_PROG@,$$(INSTALL),;t t
+s,@INSTALL_DATA@,$$(INSTALL),;t t
+s,@LIBOBJS@, acosh.obj crypt.obj erf.obj win32.obj isinf.obj isnan.obj,;t t
+s,@ALLOCA@,$(ALLOCA),;t t
+s,@DEFAULT_KCODE@,$(DEFAULT_KCODE),;t t
+s,@EXEEXT@,.exe,;t t
+s,@OBJEXT@,$(OBJEXT),;t t
+s,@XCFLAGS@,$(XCFLAGS),;t t
+s,@XLDFLAGS@,$(XLDFLAGS),;t t
+s,@DLDFLAGS@,$(DLDFLAGS) $$(LIBPATH) -def:$$(DEFFILE) -implib:$$(*F:.so=)-$$(arch).lib -pdb:$$(*F:.so=)-$$(arch).pdb,;t t
+s,@ARCH_FLAG@,$(ARCH_FLAG),;t t
+s,@STATIC@,$(STATIC),;t t
+s,@CCDLFLAGS@,,;t t
+s,@LDSHARED@,$(LDSHARED),;t t
+s,@DLEXT@,so,;t t
+s,@LIBEXT@,lib,;t t
+s,@STRIP@,$(STRIP),;t t
+s,@EXTSTATIC@,$(EXTSTATIC),;t t
+s,@setup@,Setup,;t t
+s,@MINIRUBY@,$(MINIRUBY),;t t
+s,@PREP@,miniruby$(EXEEXT),;t t
+s,@RUNRUBY@,$(RUNRUBY),;t t
+s,@EXTOUT@,$(EXTOUT),;t t
+s,@ARCHFILE@,,;t t
+s,@RDOCTARGET@,,;t t
+s,@LIBRUBY_LDSHARED@,$(LIBRUBY_LDSHARED),;t t
+s,@LIBRUBY_DLDFLAGS@,$(LIBRUBY_DLDFLAGS),;t t
+s,@RUBY_INSTALL_NAME@,$(RUBY_INSTALL_NAME),;t t
+s,@rubyw_install_name@,$(RUBYW_INSTALL_NAME),;t t
+s,@RUBYW_INSTALL_NAME@,$(RUBYW_INSTALL_NAME),;t t
+s,@RUBY_SO_NAME@,$(RUBY_SO_NAME),;t t
+s,@LIBRUBY_A@,$$(RUBY_SO_NAME)-static.lib,;t t
+s,@LIBRUBY_SO@,$$(RUBY_SO_NAME).dll,;t t
+s,@LIBRUBY_ALIASES@,$(LIBRUBY_ALIASES),;t t
+s,@LIBRUBY@,$$(RUBY_SO_NAME).lib,;t t
+s,@LIBRUBYARG@,$$(LIBRUBYARG_SHARED),;t t
+s,@LIBRUBYARG_STATIC@,$$(LIBRUBY_A),;t t
+s,@LIBRUBYARG_SHARED@,$$(LIBRUBY),;t t
+s,@SOLIBS@,$(SOLIBS),;t t
+s,@DLDLIBS@,$(DLDLIBS),;t t
+s,@ENABLE_SHARED@,yes,;t t
+s,@OUTFLAG@,$(OUTFLAG),;t t
+s,@CPPOUTFILE@,-P,;t t
+s,@LIBPATHFLAG@, -libpath:"%s",;t t
+s,@RPATHFLAG@,,;t t
+s,@LIBARG@,%s.lib,;t t
+s,@LINK_SO@,$$(LDSHARED) -Fe$$(@) $$(OBJS) $$(LIBS) $$(LOCAL_LIBS) $$(DLDFLAGS),;t t
+s,@COMPILE_C@,$$(CC) $$(INCFLAGS) $$(CFLAGS) $$(CPPFLAGS) -c -Tc$$(<:\=/),;t t
+s,@COMPILE_CXX@,$$(CXX) $$(INCFLAGS) $$(CXXFLAGS) $$(CPPFLAGS) -c -Tp$$(<:\=/),;t t
+s,@COMPILE_RULES@,{$$(srcdir)}.%s{}.%s: {$$(topdir)}.%s{}.%s: {$$(hdrdir)}.%s{}.%s: .%s.%s:,;t t
+s,@RULE_SUBST@,{.;$$(srcdir);$$(topdir);$$(hdrdir)}%s,;t t
+s,@TRY_LINK@,$$(CC) -Feconftest $$(INCFLAGS) -I$$(hdrdir) $$(CPPFLAGS) $$(CFLAGS) $$(src) $$(LOCAL_LIBS) $$(LIBS) -link $$(LDFLAGS) $$(LIBPATH) $$(XLDFLAGS),;t t
+s,@COMMON_LIBS@,coredll winsock,;t t
+s,@COMMON_MACROS@,WIN32_LEAN_AND_MEAN;t t
+s,@COMMON_HEADERS@,winsock.h windows.h,;t t
+s,@EXPORT_PREFIX@, ,;t t
+s,@arch@,$(ARCH)-$(OS),;t t
+s,@sitearch@,$(ARCH)-$(RT),;t t
+s,@sitedir@,$${prefix}/lib/ruby/site_ruby,;t t
+s,@configure_args@,--with-make-prog=nmake --enable-shared $(configure_args),;t t
+s,@configure_input@,$$configure_input,;t t
+s,@srcdir@,$(srcdir),;t t
+s,@top_srcdir@,$(srcdir),;t t
+<<KEEP
+
+$(PROGRAM): $(MAINOBJ) $(WINMAINOBJ) $(LIBRUBY_SO) $*.res
+ $(PURIFY) $(CC) $(MAINOBJ) $(WINMAINOBJ) $*.res \
+ -Fe$@ $(LIBRUBYARG) $(LDFLAGS) $(XLDFLAGS)
+
+$(LIBRUBY_A): $(OBJS) $(DMYEXT)
+ $(AR) $(ARFLAGS)$@ $(OBJS) $(DMYEXT)
+
+$(LIBRUBY): $(RUBYDEF)
+ $(AR) $(ARFLAGS)$@ -def:$(RUBYDEF)
+
+$(LIBRUBY_SO): $(LIBRUBY_A) $(DLDOBJS) $(RUBYDEF) $(RUBY_SO_NAME).res
+ @echo. $(DLDOBJS)
+ $(LDSHARED) $(MAINOBJ) $(DLDOBJS) $(LIBRUBY_A) \
+ $(RUBY_SO_NAME).res $(LIBS) -Fe$@ $(LDFLAGS) \
+ $(LIBRUBY_DLDFLAGS)
+
+$(RUBYDEF): $(LIBRUBY_A) $(PREP)
+ $(MINIRUBY) $(srcdir)/win32/mkexports.rb \
+ -output=$@ -arch=$(ARCH) $(LIBRUBY_A)
+
+{$(srcdir)/wince}.def.lib:
+ $(AR) $(ARFLAGS)$@ -def:$<
+
+clean-local::
+ @$(RM) ext\extinit.c ext\extinit.$(OBJEXT) ext\vc*.pdb
+ @$(RM) $(RUBY_INSTALL_NAME).res $(RUBYW_INSTALL_NAME).res $(RUBY_SO_NAME).res
+
+distclean-local::
+ @$(RM) ext\config.cache $(RBCONFIG:/=\)
+ @$(RM) *.map *.pdb *.ilk *.exp $(RUBYDEF)
+ @$(RM) $(RUBY_INSTALL_NAME).rc $(RUBYW_INSTALL_NAME).rc $(RUBY_SO_NAME).rc
+
+$(RUBY_INSTALL_NAME).rc $(RUBYW_INSTALL_NAME).rc $(RUBY_SO_NAME).rc: $(RBCONFIG)
+ @$(MINIRUBY) $(srcdir)/win32/resource.rb \
+ -ruby_name=$(RUBY_INSTALL_NAME) \
+ -rubyw_name=$(RUBYW_INSTALL_NAME) \
+ -so_name=$(RUBY_SO_NAME) \
+ -wce_ver=$(SUBSYSVERSION) \
+ . $(icondirs) $(srcdir)/wince
+
+fake.rb: $(MKFILES)
+ @echo Creating <<$@
+class Object
+ CROSS_COMPILING = RUBY_PLATFORM
+ remove_const :RUBY_PLATFORM
+ remove_const :RUBY_VERSION
+ RUBY_PLATFORM = "$(ARCH)"
+ RUBY_VERSION = "$(MAJOR).$(MINOR).$(TEENY)"
+end
+class File
+ remove_const :ALT_SEPARATOR
+ ALT_SEPARATOR = "\\"
+end
+<<KEEP
+
+{$(srcdir)/missing}.c.obj:
+ $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -c -Tc$(<:\=/)
+{$(srcdir)/win32}.c.obj:
+ $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -c -Tc$(<:\=/)
+{$(srcdir)/wince}.c.obj:
+ $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -c -Tc$(<:\=/)
+{$(srcdir)/wince/sys}.c.obj:
+ $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -c -Tc$(<:\=/)
+{$(srcdir)}.c.obj:
+ $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -c -Tc$(<:\=/)
+.c.obj:
+ $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -c -Tc$(<:\=/)
+
+.rc.res:
+ $(RC) -I. -I$(<D) $(iconinc) -I$(srcdir)/win32 $(RFLAGS) -fo$@ $(<:\=/)
+
+{$(srcdir)}.y.c:
+ $(YACC) $(YFLAGS) $(<:\=/)
+ sed -e "s!^ *extern char \*getenv();!/* & */!;s/^\(#.*\)y\.tab/\1parse/" y.tab.c > $@
+ @del y.tab.c
+
+!include $(srcdir)/common.mk
+
+$(OBJS): {$(srcdir)}win32/win32.h
+
+dir.$(OBJEXT): {$(srcdir)}win32/dir.h
+
+ext/extinit.obj: ext/extinit.c $(SETUP)
+ $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) -Fo$@ -c ext/extinit.c
diff --git a/ruby_1_8_5/wince/README.wince b/ruby_1_8_5/wince/README.wince
new file mode 100644
index 0000000000..795dc710e6
--- /dev/null
+++ b/ruby_1_8_5/wince/README.wince
@@ -0,0 +1,121 @@
+=begin
+
+= How to build ruby using eMbedded Visual C++
+
+== Requirement
+
+(1) eMbedded Visual C++ 3.0 or later.
+
+(2) If you want to run `((%nmake clean%))' or `((%nmake distclean%))'
+ properly, you must install UNIX compatible `((%rm%))' command on
+ your ((|PATH|)) if you want to clean after compile.
+
+(3) Please set environment variable (({INCLUDE})), (({LIB})), (({PATH})),
+ (({CE_TOOLS_DIR})), (({EMBEDDED_TOOLS_DIR})) to run required commands
+ properly from the command line.
+
+ Note: building ruby requires following commands.
+ * nmake
+ * clarm or clmips or shcl
+ * lib
+ * dumpbin
+
+== How to compile and install
+
+(1) Execute wince\configure.bat on your build directory.
+ You can specify the target platform as an argument.
+ For example, run `((%configure arm-hpc2k-wince%))'
+
+(2) Change ((|RUBY_INSTALL_NAME|)) and ((|RUBY_SO_NAME|)) in (({Makefile}))
+ if you want to change the name of the executable files.
+
+(3) Run `((%nmake%))'
+
+(4) Run `((%nmake DESTDIR=<install_directory> install%))'
+
+ This command will create following directories and copy (not install :-P)
+ files onto them.
+ * <install_directory>\bin
+ * <install_directory>\lib
+ * <install_directory>\lib\ruby
+ * <install_directory>\lib\ruby\<MAJOR>.<MINOR>
+ * <install_directory>\lib\ruby\<MAJOR>.<MINOR>\<PLATFORM>
+ * <install_directory>\lib\ruby\site_ruby
+ * <install_directory>\lib\ruby\site_ruby\<MAJOR>.<MINOR>
+ * <install_directory>\lib\ruby\site_ruby\<MAJOR>.<MINOR>\<PLATFORM>
+ * <install_directory>\man\man1
+ If Ruby's version is `x.y.z', the ((|<MAJOR>|)) is `x' and the ((|<MINOR>|)) is `y'.
+ In case of `mips-hpc2k-wince', The ((|<PLATFORM>|)) is `(({mips-mswince}))'.
+
+(5) Copy <install_directory> to your WindowsCE machine.
+
+== Icons
+
+Any icon files(*.ico) in the build directory, directories specified with
+((|icondirs|)) make variable and (({win32})) directory under the ruby
+source directory will be included in DLL or executable files, according
+to their base names.
+ $(RUBY_INSTALL_NAME).ico or ruby.ico --> $(RUBY_INSTALL_NAME).exe
+ $(RUBYW_INSTALL_NAME).ico or rubyw.ico --> $(RUBYW_INSTALL_NAME).exe
+ the others --> $(RUBY_SO_NAME).dll
+
+Although no icons are distributed with the ruby source or in the official
+site, you can use anything you like. For example, followings are written
+in Japanese, but you can download at least.
+
+* ((<URL:http://member.nifty.ne.jp/ueivu/rubyico.html>)) or
+ ((<zipped icons|URL:http://member.nifty.ne.jp/ueivu/Ruby_ico.zip>))
+* ((<URL:http://homepage1.nifty.com/a_nakata/ruby/>)) or
+ ((<icon itself|URL:http://homepage1.nifty.com/a_nakata/ruby/RubyIcon.ico>))
+
+== Build examples
+
+* Build on the ruby source directory.
+
+ ex.)
+ ruby source directory: C:\ruby
+ build directory: C:\ruby
+ install directory: C:\usr\local
+
+ C:
+ cd \ruby
+ win32\configure
+ nmake
+ nmake DESTDIR=/usr/local install
+
+* Build on the relative directory from the ruby source directory.
+
+ ex.)
+ ruby source directory: C:\ruby
+ build directory: C:\ruby\mswin32
+ install directory: C:\usr\local
+
+ C:
+ cd \ruby
+ mkdir mswin32
+ cd mswin32
+ ..\win32\configure
+ nmake
+ nmake DESTDIR=/usr/local install
+
+* Build on the different drive.
+
+ ex.)
+ ruby source directory: C:\src\ruby
+ build directory: D:\build\ruby
+ install directory: C:\usr\local
+
+ D:
+ cd D:\build\ruby
+ C:\src\ruby\win32\configure
+ nmake
+ nmake DESTDIR=C:/usr/local install
+
+== Bugs
+
+You can ((*NOT*)) use a path name contains any white space characters as
+the ruby source directory, this restriction comes from the behavior of
+(({!INCLUDE})) directives of (({NMAKE})).
+((- you may call it a bug. -))
+
+=end
diff --git a/ruby_1_8_5/wince/assert.c b/ruby_1_8_5/wince/assert.c
new file mode 100644
index 0000000000..0f4be68497
--- /dev/null
+++ b/ruby_1_8_5/wince/assert.c
@@ -0,0 +1,11 @@
+#include <windows.h>
+#include <tchar.h>
+#include "assert.h"
+
+
+void assert( int expression )
+{
+ if( expression==0 )
+ exit(2);
+}
+
diff --git a/ruby_1_8_5/wince/assert.h b/ruby_1_8_5/wince/assert.h
new file mode 100644
index 0000000000..c2a4e3ebb7
--- /dev/null
+++ b/ruby_1_8_5/wince/assert.h
@@ -0,0 +1,6 @@
+#ifndef _ASSERT_H_
+#define _ASSERT_H_
+
+void assert( int expression );
+
+#endif
diff --git a/ruby_1_8_5/wince/configure.bat b/ruby_1_8_5/wince/configure.bat
new file mode 100755
index 0000000000..66837bb646
--- /dev/null
+++ b/ruby_1_8_5/wince/configure.bat
@@ -0,0 +1,102 @@
+@echo off
+::: Don't set environment variable in batch file other than autoexec.bat
+::: to avoid "Out of environment space" problem on Windows 95/98.
+::: set TMPMAKE=~tmp~.mak
+
+echo> ~tmp~.mak ####
+echo>> ~tmp~.mak conf = %0
+echo>> ~tmp~.mak $(conf:\=/): nul
+echo>> ~tmp~.mak @del ~tmp~.mak
+echo>> ~tmp~.mak @-$(MAKE) -l$(MAKEFLAGS) -f $(@D)/setup.mak \
+:loop
+if "%1" == "" goto :end
+if "%1" == "--prefix" goto :prefix
+if "%1" == "--srcdir" goto :srcdir
+if "%1" == "srcdir" goto :srcdir
+if "%1" == "--target" goto :target
+if "%1" == "target" goto :target
+if "%1" == "--with-static-linked-ext" goto :extstatic
+if "%1" == "--program-suffix" goto :suffix
+if "%1" == "--program-name" goto :progname
+if "%1" == "--enable-install-doc" goto :enable-rdoc
+if "%1" == "--disable-install-doc" goto :disable-rdoc
+if "%1" == "--extout" goto :extout
+if "%1" == "-h" goto :help
+if "%1" == "--help" goto :help
+if "%1" == "CC" goto :define
+if "%1" == "EMBEDDED_TOOLS_DIR" goto :define
+if "%1" == "CE_TOOLS_DIR" goto :define
+if "%1" == "EMBEDDED_TOOLS4_DIR" goto :define
+if "%1" == "CE_TOOLS4_DIR" goto :define
+ echo>> ~tmp~.mak "%1" \
+ shift
+goto :loop
+:srcdir
+ echo>> ~tmp~.mak "srcdir=%2" \
+ shift
+ shift
+goto :loop
+:prefix
+ echo>> ~tmp~.mak "prefix=%2" \
+ shift
+ shift
+goto :loop
+:suffix
+ echo>> ~tmp~.mak "RUBY_SUFFIX=%2" \
+ shift
+ shift
+goto :loop
+:installname
+ echo>> ~tmp~.mak "RUBY_INSTALL_NAME=%2" \
+ shift
+ shift
+goto :loop
+:soname
+ echo>> ~tmp~.mak "RUBY_SO_NAME=%2" \
+ shift
+ shift
+goto :loop
+:define
+ echo>> ~tmp~.mak "%1=%2" \
+ shift
+ shift
+goto :loop
+:target
+ echo>> ~tmp~.mak "%2" \
+ shift
+ shift
+goto :loop
+:extstatic
+ echo>> ~tmp~.mak "EXTSTATIC=static" \
+ shift
+goto :loop
+:enable-rdoc
+ echo>> ~tmp~.mak "RDOCTARGET=install-doc" \
+ shift
+goto :loop
+:disable-rdoc
+ echo>> ~tmp~.mak "RDOCTARGET=install-nodoc" \
+ shift
+goto :loop
+:extout
+ echo>> ~tmp~.mak "EXTOUT=%2" \
+ shift
+ shift
+goto :loop
+:help
+ echo Configuration:
+ echo --help display this help
+ echo --srcdir=DIR find the sources in DIR [configure dir or `..']
+ echo Installation directories:
+ echo --prefix=PREFIX install files in PREFIX (ignored currently)
+ echo System types:
+ echo --target=TARGET configure for TARGET [i386-mswin32]
+ echo Optional Package:
+ echo --with-static-linked-ext link external modules statically
+ echo --enable-install-doc install rdoc indexes during install
+ del ~tmp~.mak
+goto :exit
+:end
+echo>> ~tmp~.mak WIN32DIR=$(@D)
+nmake -alf ~tmp~.mak
+:exit
diff --git a/ruby_1_8_5/wince/direct.c b/ruby_1_8_5/wince/direct.c
new file mode 100644
index 0000000000..bf0d7cd224
--- /dev/null
+++ b/ruby_1_8_5/wince/direct.c
@@ -0,0 +1,54 @@
+/***************************************************************
+ direct.c
+***************************************************************/
+
+#include <windows.h>
+#include <tchar.h>
+#include <direct.h>
+#include "wince.h" /* for wce_mbtowc */
+
+/* global for chdir, getcwd */
+char _currentdir[MAX_PATH+1];
+
+
+char *getcwd(char* buffer, int maxlen)
+{
+ strcpy( buffer, _currentdir );
+ return buffer;
+}
+
+int _chdir(const char * dirname)
+{
+ if( MAX_PATH < strlen(dirname) )
+ return -1;
+
+ strcpy( _currentdir, dirname );
+ return 0;
+}
+
+int _rmdir(const char * dir)
+{
+ wchar_t *wdir;
+ BOOL rc;
+
+ /* replace with RemoveDirectory. */
+ wdir = wce_mbtowc(dir);
+ rc = RemoveDirectoryW(wdir);
+ free(wdir);
+
+ return rc==TRUE ? 0 : -1;
+}
+
+int _mkdir(const char * dir)
+{
+ wchar_t* wdir;
+ BOOL rc;
+
+ /* replace with CreateDirectory. */
+ wdir = wce_mbtowc(dir);
+ rc = CreateDirectoryW(wdir, NULL);
+ free(wdir);
+
+ return rc==TRUE ? 0 : -1;
+}
+
diff --git a/ruby_1_8_5/wince/direct.h b/ruby_1_8_5/wince/direct.h
new file mode 100644
index 0000000000..7c859b9d3b
--- /dev/null
+++ b/ruby_1_8_5/wince/direct.h
@@ -0,0 +1,22 @@
+#ifndef DIRECT_H
+#define DIRECT_H 1
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+char *getcwd(char* buffer, int maxlen);
+int _chdir(const char * dirname);
+int _rmdir(const char * dir);
+int _mkdir(const char * dir);
+
+#ifdef __cplusplus
+};
+#endif
+
+#define chdir _chdir
+#define rmdir _rmdir
+#define mkdir _mkdir
+
+#endif
diff --git a/ruby_1_8_5/wince/errno.c b/ruby_1_8_5/wince/errno.c
new file mode 100644
index 0000000000..705b25428e
--- /dev/null
+++ b/ruby_1_8_5/wince/errno.c
@@ -0,0 +1,11 @@
+/***************************************************************
+ errno.c
+***************************************************************/
+
+#include <errno.h>
+
+
+int errno;
+int _doserrno;
+int _sys_nerr;
+
diff --git a/ruby_1_8_5/wince/errno.h b/ruby_1_8_5/wince/errno.h
new file mode 100644
index 0000000000..2fdd325b32
--- /dev/null
+++ b/ruby_1_8_5/wince/errno.h
@@ -0,0 +1,55 @@
+#ifndef ERRNO_H
+#define ERRNO_H 1
+
+
+#define EPERM 1
+#define ENOENT 2
+#define ESRCH 3
+#define EINTR 4
+#define EIO 5
+#define ENXIO 6
+#define E2BIG 7
+#define ENOEXEC 8
+#define EBADF 9
+#define ECHILD 10
+#define EAGAIN 11
+#define ENOMEM 12
+#define EACCES 13
+#define EFAULT 14
+#define EOSERR 15 // rk
+#define EBUSY 16
+#define EEXIST 17
+#define EXDEV 18
+#define ENODEV 19
+#define ENOTDIR 20
+#define EISDIR 21
+#define EINVAL 22
+#define ENFILE 23
+#define EMFILE 24
+#define ENOTTY 25
+#define EFBIG 27
+#define ENOSPC 28
+#define ESPIPE 29
+#define EROFS 30
+#define EMLINK 31
+#define EPIPE 32
+#define EDOM 33
+#define ERANGE 34
+#define EDEADLK 36
+#define ENOSYS 37
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int errno;
+extern int _doserrno;
+extern int _sys_nerr;
+
+#define sys_nerr _sys_nerr
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif
diff --git a/ruby_1_8_5/wince/fcntl.h b/ruby_1_8_5/wince/fcntl.h
new file mode 100644
index 0000000000..5a6bdc71e6
--- /dev/null
+++ b/ruby_1_8_5/wince/fcntl.h
@@ -0,0 +1,42 @@
+
+#ifndef FCNTL_H
+#define FCNTL_H 1
+
+
+#define F_SETFL 1
+#define F_SETFD 2
+#define F_GETFL 3
+
+#define _O_RDONLY 0x0000 /* open for reading only */
+#define _O_WRONLY 0x0001 /* open for writing only */
+#define _O_RDWR 0x0002 /* open for reading and writing */
+
+#define _O_NONBLOCK 0x0004
+
+#define _O_APPEND 0x0008 /* writes done at eof */
+#define _O_CREAT 0x0100 /* create and open file */
+#define _O_TRUNC 0x0200 /* open and truncate */
+#define _O_EXCL 0x0400 /* open only if file doesn't already exist */
+#define _O_TEXT 0x4000 /* file mode is text (translated) */
+#define _O_BINARY 0x8000 /* file mode is binary (untranslated) */
+#define _O_ACCMODE 0x10000
+
+#define _O_NOINHERIT 0
+#define O_NOINHERIT _O_NOINHERIT
+
+#define O_RDONLY _O_RDONLY
+#define O_WRONLY _O_WRONLY
+#define O_RDWR _O_RDWR
+
+#define O_NONBLOCK _O_NONBLOCK
+
+#define O_APPEND _O_APPEND
+#define O_CREAT _O_CREAT
+#define O_TRUNC _O_TRUNC
+#define O_EXCL _O_EXCL
+#define O_TEXT _O_TEXT
+#define O_BINARY _O_BINARY
+#define O_ACCMODE _O_ACCMODE
+
+
+#endif
diff --git a/ruby_1_8_5/wince/io.h b/ruby_1_8_5/wince/io.h
new file mode 100644
index 0000000000..eb355a4916
--- /dev/null
+++ b/ruby_1_8_5/wince/io.h
@@ -0,0 +1,76 @@
+
+#ifndef _IO_WINCE_H_
+#define _IO_WINCE_H_
+
+#ifndef _TIME_T_DEFINED
+typedef unsigned long time_t;
+#define _TIME_T_DEFINED
+#endif
+
+#ifndef _FSIZE_T_DEFINED
+typedef unsigned long _fsize_t; /* Could be 64 bits for Win32 */
+#define _FSIZE_T_DEFINED
+#endif
+
+#ifndef _FINDDATA_T_DEFINED
+struct _finddata_t {
+ unsigned attrib;
+ time_t time_create; /* -1 for FAT file systems */
+ time_t time_access; /* -1 for FAT file systems */
+ time_t time_write;
+ _fsize_t size;
+ char name[260];
+};
+#define _FINDDATA_T_DEFINED
+#endif
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int _chsize(int handle, long size);
+int _rename (const char *oldname, const char *newname);
+int _unlink(const char *file);
+int _umask(int cmask);
+int _chmod(const char *path, int mode);
+int dup( int handle );
+//int dup2( int handle1, int handle2 );
+int _isatty(int fd);
+int _pipe(int *phandles, unsigned int psize, int textmode);
+int _access(const char *filename, int flags);
+int _open_osfhandle ( long osfhandle, int flags);
+long _get_osfhandle( int filehandle );
+int _open(const char *file, int mode,...);
+int close(int fd);
+int _read(int fd, void *buffer, int length);
+int _write(int fd, const void *buffer, unsigned count);
+long _lseek(int handle, long offset, int origin);
+long _findfirst( char *filespec, struct _finddata_t *fileinfo );
+int _findnext( long handle, struct _finddata_t *fileinfo );
+int _findclose( long handle );
+
+#ifdef __cplusplus
+};
+#endif
+
+#define chmod _chmod
+#define chsize _chsize
+#define rename _rename
+#define unlink _unlink
+#define open _open
+//#define close _close
+#define read _read
+#define write _write
+#define umask _umask
+//#define dup _dup
+#define isatty _isatty
+#define access _access
+#define pipe _pipe
+#define setmode _setmode
+#define lseek _lseek
+
+#define _close close
+
+#endif
+
diff --git a/ruby_1_8_5/wince/io_wce.c b/ruby_1_8_5/wince/io_wce.c
new file mode 100644
index 0000000000..613934aa66
--- /dev/null
+++ b/ruby_1_8_5/wince/io_wce.c
@@ -0,0 +1,230 @@
+/***************************************************************
+ io.c
+
+ author : uema2
+ date : Nov 30, 2002
+
+ You can freely use, copy, modify, and redistribute
+ the whole contents.
+***************************************************************/
+
+#include <windows.h>
+#include <stdlib.h>
+#include <io.h>
+#include <fcntl.h>
+#include <time.h>
+#include <errno.h>
+#include "wince.h" /* for wce_mbtowc */
+
+extern int _errno;
+
+
+int _rename(const char *oldname, const char *newname)
+{
+ wchar_t *wold, *wnew;
+ BOOL rc;
+
+ wold = wce_mbtowc(oldname);
+ wnew = wce_mbtowc(newname);
+
+ /* replace with MoveFile. */
+ rc = MoveFileW(wold, wnew);
+
+ free(wold);
+ free(wnew);
+
+ return rc==TRUE ? 0 : -1;
+}
+
+int _unlink(const char *file)
+{
+ wchar_t *wfile;
+ BOOL rc;
+
+ /* replace with DeleteFile. */
+ wfile = wce_mbtowc(file);
+ rc = DeleteFileW(wfile);
+ free(wfile);
+
+ return rc==TRUE ? 0 : -1;
+}
+
+/* replace "open" with "CreateFile", etc. */
+int _open(const char *file, int mode, va_list arg)
+{
+ wchar_t *wfile;
+ DWORD access=0, share=0, create=0;
+ HANDLE h;
+
+ if( (mode&_O_RDWR) != 0 )
+ access = GENERIC_READ|GENERIC_WRITE;
+ else if( (mode&_O_RDONLY) != 0 )
+ access = GENERIC_READ;
+ else if( (mode&_O_WRONLY) != 0 )
+ access = GENERIC_WRITE;
+
+ if( (mode&_O_CREAT) != 0 )
+ create = CREATE_ALWAYS;
+ else
+ create = OPEN_ALWAYS;
+
+ wfile = wce_mbtowc(file);
+
+ h = CreateFileW(wfile, access, share, NULL,
+ create, 0, NULL );
+
+ free(wfile);
+ return (int)h;
+}
+
+int close(int fd)
+{
+ CloseHandle( (HANDLE)fd );
+ return 0;
+}
+
+int _read(int fd, void *buffer, int length)
+{
+ DWORD dw;
+ ReadFile( (HANDLE)fd, buffer, length, &dw, NULL );
+ return (int)dw;
+}
+
+int _write(int fd, const void *buffer, unsigned count)
+{
+ DWORD dw;
+ WriteFile( (HANDLE)fd, buffer, count, &dw, NULL );
+ return (int)dw;
+}
+
+long _lseek(int handle, long offset, int origin)
+{
+ DWORD flag, ret;
+
+ switch(origin)
+ {
+ case SEEK_SET: flag = FILE_BEGIN; break;
+ case SEEK_CUR: flag = FILE_CURRENT; break;
+ case SEEK_END: flag = FILE_END; break;
+ default: flag = FILE_CURRENT; break;
+ }
+
+ ret = SetFilePointer( (HANDLE)handle, offset, NULL, flag );
+ return ret==0xFFFFFFFF ? -1 : 0;
+}
+
+/* _findfirst, _findnext, _findclose. */
+/* replace them with FindFirstFile, etc. */
+long _findfirst( char *file, struct _finddata_t *fi )
+{
+ HANDLE h;
+ WIN32_FIND_DATAA fda;
+
+ h = FindFirstFileA( file, &fda );
+ if( h==NULL )
+ {
+ errno = EINVAL; return -1;
+ }
+
+ fi->attrib = fda.dwFileAttributes;
+ fi->time_create = wce_FILETIME2time_t( &fda.ftCreationTime );
+ fi->time_access = wce_FILETIME2time_t( &fda.ftLastAccessTime );
+ fi->time_write = wce_FILETIME2time_t( &fda.ftLastWriteTime );
+ fi->size = fda.nFileSizeLow + (fda.nFileSizeHigh<<32);
+ strcpy( fi->name, fda.cFileName );
+
+ return (long)h;
+}
+
+int _findnext( long handle, struct _finddata_t *fi )
+{
+ WIN32_FIND_DATAA fda;
+ BOOL b;
+
+ b = FindNextFileA( (HANDLE)handle, &fda );
+
+ if( b==FALSE )
+ {
+ errno = ENOENT; return -1;
+ }
+
+ fi->attrib = fda.dwFileAttributes;
+ fi->time_create = wce_FILETIME2time_t( &fda.ftCreationTime );
+ fi->time_access = wce_FILETIME2time_t( &fda.ftLastAccessTime );
+ fi->time_write = wce_FILETIME2time_t( &fda.ftLastWriteTime );
+ fi->size = fda.nFileSizeLow + (fda.nFileSizeHigh<<32);
+ strcpy( fi->name, fda.cFileName );
+
+ return 0;
+}
+
+int _findclose( long handle )
+{
+ BOOL b;
+ b = FindClose( (HANDLE)handle );
+ return b==FALSE ? -1 : 0;
+}
+
+/* below functions unsupported... */
+/* I have no idea how to replace... */
+int _chsize(int handle, long size)
+{
+ errno = EACCES;
+ return -1;
+}
+
+int _umask(int cmask)
+{
+ return 0;
+}
+
+int _chmod(const char *path, int mode)
+{
+ return 0;
+}
+
+/* WinCE doesn't have dup and dup2. */
+/* so, we cannot use missing/dup2.c. */
+int dup( int handle )
+{
+ errno = EBADF;
+ return -1;
+}
+/*
+int dup2( int handle1, int handle2 )
+{
+ errno = EBADF;
+ return -1;
+}
+*/
+int _isatty(int fd)
+{
+ if( fd==(int)_fileno(stdin) ||
+ fd==(int)_fileno(stdout)||
+ fd==(int)_fileno(stderr) )
+ return 1;
+ else
+ return 0;
+}
+
+int _pipe(int *phandles, unsigned int psize, int textmode)
+{
+ return -1;
+}
+
+int _access(const char *filename, int flags)
+{
+ return 0;
+}
+
+int _open_osfhandle( long osfhandle, int flags)
+{
+/* return 0; */
+ return (int)osfhandle;
+}
+
+long _get_osfhandle( int filehandle )
+{
+/* return 0; */
+ return (long)filehandle;
+}
diff --git a/ruby_1_8_5/wince/mkconfig_wce.rb b/ruby_1_8_5/wince/mkconfig_wce.rb
new file mode 100644
index 0000000000..4d9671cde7
--- /dev/null
+++ b/ruby_1_8_5/wince/mkconfig_wce.rb
@@ -0,0 +1,7 @@
+f = File.open(ARGV[0], File::WRONLY|File::APPEND)
+f.write <<EOM
+class Object
+ remove_const :RUBY_PLATFORM
+ RUBY_PLATFORM = Config::CONFIG[\"RUBY_PLATFORM\"]
+end
+EOM
diff --git a/ruby_1_8_5/wince/mkexports.rb b/ruby_1_8_5/wince/mkexports.rb
new file mode 100644
index 0000000000..8e96649276
--- /dev/null
+++ b/ruby_1_8_5/wince/mkexports.rb
@@ -0,0 +1,35 @@
+#!./miniruby -s
+
+SYM = {}
+
+objs = ARGV.collect {|s| p s+'\n'; s.tr('/', '\\') }
+IO.foreach("|dumpbin -symbols " + objs.join(' ')) do |l|
+ next if /^[0-9A-F]+ 0+ UNDEF / =~ l
+ next unless l.sub!(/.*\sExternal\s+\|\s+/, '')
+ if ARGV[1]=~/sh/
+ if l.sub!(/^_/, '')
+ next if /@.*@/ =~ l || /@[0-9a-f]{16}$/ =~ l
+ elsif !l.sub!(/^(\S+) \([^@?\`\']*\)$/, '\1')
+ next
+ end
+ else
+ next if /@.*@/ =~ l || /@[0-9a-f]{16}$/ =~ l
+ end
+ SYM[l.strip] = true
+end
+
+
+exports = []
+if $name
+ exports << "Name " + $name
+elsif $library
+ exports << "Library " + $library
+end
+exports << "Description " + $description.dump if $description
+exports << "EXPORTS" << SYM.keys.sort
+
+if $output
+ open($output, 'w') {|f| f.puts exports.join("\n")}
+else
+ puts exports.join("\n")
+end
diff --git a/ruby_1_8_5/wince/process.h b/ruby_1_8_5/wince/process.h
new file mode 100644
index 0000000000..2ef72a4ac1
--- /dev/null
+++ b/ruby_1_8_5/wince/process.h
@@ -0,0 +1,46 @@
+#ifndef PROCESS_H
+#define PROCESS_H 1
+
+
+#define _P_WAIT 0
+#define _P_NOWAIT 1
+#define _P_OVERLAY 2
+#define _P_DETACH 4
+
+#define P_WAIT _P_WAIT
+#define P_NOWAIT _P_NOWAIT
+#define P_DETACH _P_DETACH
+#define P_OVERLAY _P_OVERLAY
+
+#ifndef _INTPTR_T_DEFINED
+typedef int intptr_t;
+#define _INTPTR_T_DEFINED
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int _getpid(void);
+
+int _cwait(int *, int, int);
+void abort(void);
+
+int _execl(const char *, const char *, ...);
+//int _execv(const char *, const char * const *);
+int execv(const char *path, char *const argv[]);
+
+intptr_t _spawnle(int, const char *, const char *, ...);
+intptr_t _spawnvpe(int, const char *, const char * const *,
+ const char * const *);
+
+#ifdef __cplusplus
+};
+#endif
+
+//#define getpid _getpid
+#define execl _execl
+#define execv _execv
+
+
+#endif
diff --git a/ruby_1_8_5/wince/process_wce.c b/ruby_1_8_5/wince/process_wce.c
new file mode 100644
index 0000000000..4415ad024e
--- /dev/null
+++ b/ruby_1_8_5/wince/process_wce.c
@@ -0,0 +1,47 @@
+/***************************************************************
+ process.c
+***************************************************************/
+
+#include <windows.h>
+#include "process.h"
+
+int _getpid(void)
+{
+ return (int)GetCurrentProcessId();
+}
+
+/* I wonder _exec and _swawn should be replaced with CreateProcess... */
+int _execl(const char *cmdname, const char *arg0,
+ va_list va_args)
+{
+ return 0;
+}
+
+int execv(const char *path, char *const argv[])
+{
+ return 0;
+}
+
+void abort(void)
+{
+}
+
+int _cwait( int *termstat, int procHandle, int action )
+{
+ return 0;
+}
+
+intptr_t _spawnle(int mode,
+ const char *cmdname, const char *arg0,
+ va_list va_argn)
+{
+ return 0;
+}
+
+intptr_t _spawnvpe(int mode,
+ const char *cmdname, const char *const *argv,
+ const char *const *envp)
+{
+ return 0;
+}
+
diff --git a/ruby_1_8_5/wince/resource.rb b/ruby_1_8_5/wince/resource.rb
new file mode 100644
index 0000000000..6da6cd017f
--- /dev/null
+++ b/ruby_1_8_5/wince/resource.rb
@@ -0,0 +1,96 @@
+#!./miniruby -sI.
+
+require 'rbconfig'
+
+CONFIG = Config::MAKEFILE_CONFIG
+
+fversion = "#{CONFIG['MAJOR']},#{CONFIG['MINOR']},#{CONFIG['TEENY']},0"
+
+$ruby_name ||= CONFIG["RUBY_INSTALL_NAME"]
+$rubyw_name ||= CONFIG["RUBYW_INSTALL_NAME"] || $ruby_name.sub(/ruby/, '\&w')
+$so_name ||= CONFIG["RUBY_SO_NAME"]
+
+icons = {}
+def icons.find(path)
+ if File.directory?(path)
+ Dir.open(File.expand_path(path)) do |d|
+ d.grep(/\.ico$/i) {|i| self[$`] = i}
+ end
+ else
+ self[File.basename(path, '.ico')] = path
+ end
+ self
+end
+
+if ARGV.empty?
+ icons.find('.')
+else
+ ARGV.each {|i| icons.find(i)}
+end
+
+ruby_icon = rubyw_icon = nil
+[$ruby_name, 'ruby'].each do |i|
+ if i = icons.delete(i)
+ ruby_icon = "1 ICON DISCARDABLE "+i.dump+"\n"
+ break
+ end
+end
+[$rubyw_name, 'rubyw'].each do |i|
+ if i = icons.delete(i)
+ rubyw_icon = "1 ICON DISCARDABLE "+i.dump+"\n"
+ break
+ end
+end
+dll_icons = []
+icons.keys.sort.each do |i|
+ dll_icons << "#{dll_icons.size + 1} ICON DISCARDABLE "+icons[i].dump+"\n"
+end
+
+[ # base name extension file type icons
+ [$ruby_name, CONFIG["EXEEXT"], 'VFT_APP', ruby_icon],
+ [$rubyw_name, CONFIG["EXEEXT"], 'VFT_APP', rubyw_icon],
+ [$so_name, '.dll', 'VFT_DLL', dll_icons],
+].each do |base, ext, type, icons|
+ open(base + '.rc', "w") { |f|
+ f.binmode if /mingw/ =~ RUBY_PLATFORM
+
+ f.print("#include <windows.h>\n")
+ f.print("#include <winver.h>\n") if $wce_ver=="2.11" or $wce_ver=="3.00"
+
+ f.print <<EOF
+
+#{icons}
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION #{fversion}
+ PRODUCTVERSION #{fversion}
+ FILEFLAGSMASK 0x3fL
+ FILEFLAGS 0x0L
+ FILEOS VOS__WINDOWS32
+ FILETYPE #{type}
+ FILESUBTYPE VFT2_UNKNOWN
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "000004b0"
+ BEGIN
+ VALUE "FileDescription", "Ruby interpreter\\0"
+ VALUE "FileVersion", "#{fversion}\\0"
+ VALUE "Home Page", "http://www.ruby-lang.org/\\0"
+ VALUE "InternalName", "#{base + ext}\\0"
+ VALUE "LegalCopyright", "Copyright (C) 1993-2003 Yukihiro Matsumoto\\0"
+ VALUE "OriginalFilename", "#{base + ext}\\0"
+ VALUE "Platform", "#{RUBY_PLATFORM}\\0"
+ VALUE "ProductVersion", "#{fversion}\\0"
+ VALUE "Release Date", "#{RUBY_RELEASE_DATE}\\0"
+ VALUE "Version", "#{RUBY_VERSION}\\0"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x0, 0x4b0
+ END
+END
+EOF
+ }
+end
+
diff --git a/ruby_1_8_5/wince/setup.mak b/ruby_1_8_5/wince/setup.mak
new file mode 100644
index 0000000000..7b729bf958
--- /dev/null
+++ b/ruby_1_8_5/wince/setup.mak
@@ -0,0 +1,245 @@
+# -*- makefile -*-
+
+!if "$(srcdir)" != ""
+WIN32DIR = $(srcdir)/win32
+!elseif "$(WIN32DIR)" == "win32"
+srcdir = .
+!elseif "$(WIN32DIR)" == "$(WIN32DIR:/win32=)/win32"
+srcdir = $(WIN32DIR:/win32=)
+!else
+srcdir = $(WIN32DIR)/..
+!endif
+!ifndef prefix
+prefix = /usr
+!endif
+OS = mswince
+RT = msvcrt
+INCLUDE = !include
+APPEND = echo>>$(MAKEFILE)
+!ifdef MAKEFILE
+MAKE = $(MAKE) -f $(MAKEFILE)
+!else
+MAKEFILE = Makefile
+!endif
+ARCH = PROCESSOR_ARCHITECTURE
+CPU = PROCESSOR_LEVEL
+CPP = cl -nologo -EP
+
+all: -prologue- -generic- -epilogue-
+i386-$(OS): -prologue- -i386- -epilogue-
+i486-$(OS): -prologue- -i486- -epilogue-
+i586-$(OS): -prologue- -i586- -epilogue-
+i686-$(OS): -prologue- -i686- -epilogue-
+alpha-$(OS): -prologue- -alpha- -epilogue-
+
+# CE
+mips-hpc2k-wince: -prologue- -mips- -hpc2k- -epilogue-
+mips-ppc-wince: -prologue- -mips- -ppc- -epilogue-
+mips-hpcpro-wince: -prologue- -mips- -hpcpro- -epilogue-
+arm-hpc2k-wince: -prologue- -arm- -hpc2k- -epilogue-
+arm-ppc-wince: -prologue- -arm- -ppc- -epilogue-
+arm-hpcpro-wince: -prologue- -arm- -hpcpro- -epilogue-
+sh3-ppc-wince: -prologue- -sh3- -ppc- -epilogue-
+sh3-hpcpro-wince: -prologue- -sh3- -hpcpro- -epilogue-
+sh4-hpcpro-wince: -prologue- -sh4- -hpcpro- -epilogue-
+armv4-.net41-wince: -prologue- -armv4- -.net41- -epilogue-
+armv4t-.net41-wince: -prologue- -armv4t- -.net41- -epilogue-
+armv4i-sig3-wince: -prologue- -armv4i- -sig3- -epilogue-
+
+-prologue-: nul
+ @type << > $(MAKEFILE)
+### Makefile for ruby $(OS) ###
+srcdir = $(srcdir:\=/)
+prefix = $(prefix:\=/)
+EXTSTATIC = $(EXTSTATIC)
+!if defined(RDOCTARGET)
+RDOCTARGET = $(RDOCTARGET)
+!endif
+!if defined(EXTOUT)
+EXTOUT = $(EXTOUT)
+!endif
+<<
+ @$(CPP) -I$(srcdir) <<"Creating $(MAKEFILE)" >> $(MAKEFILE)
+#include "version.h"
+MAJOR = RUBY_VERSION_MAJOR
+MINOR = RUBY_VERSION_MINOR
+TEENY = RUBY_VERSION_TEENY
+MSC_VER = _MSC_VER
+<<
+
+-generic-: nul
+!if defined($(ARCH)) || defined($(CPU))
+ @type << >>$(MAKEFILE)
+!if defined($(ARCH))
+$(ARCH) = $(PROCESSOR_ARCHITECTURE)
+!endif
+!if defined($(CPU))
+$(CPU) = $(PROCESSOR_LEVEL)
+!endif
+
+<<
+!endif
+
+-alpha-: nul
+ @$(APPEND) $(ARCH) = alpha
+-ix86-: nul
+ @$(APPEND) $(ARCH) = x86
+
+-i386-: -ix86-
+ @$(APPEND) $(CPU) = 3
+-i486-: -ix86-
+ @$(APPEND) $(CPU) = 4
+-i586-: -ix86-
+ @$(APPEND) $(CPU) = 5
+-i686-: -ix86-
+ @$(APPEND) $(CPU) = 6
+
+# CE
+-mips- -arm- -sh3- -sh4-::
+ @$(APPEND) $(ARCH) = $(@:-=)
+-mips- -arm-::
+ @$(APPEND) CC = cl$(@:-=)
+-sh3- -sh4-::
+ @$(APPEND) CC = shcl
+-armv4- -armv4i-::
+ @$(APPEND) CC = clarm
+ @$(APPEND) ARCHFOLDER = $(@:-=)
+-armv4t-::
+ @$(APPEND) CC = clthumb
+ @$(APPEND) ARCHFOLDER = $(@:-=)
+
+-arm-::
+ @$(APPEND) CECPUDEF = -DARM -D_ARM_
+-mips-::
+ @$(APPEND) CECPUDEF = -DMIPS -D_MIPS_
+-sh3-::
+ @$(APPEND) CECPUDEF = -DSHx -DSH3 -D_SH3_
+-sh4-::
+ @$(APPEND) CECPUDEF = -DSHx -DSH4 -D_SH4_
+ @$(APPEND) QSH4 = -Qsh4
+-armv4-::
+ @$(APPEND) CECPUDEF = -DARM -D_ARM_ -DARMV4
+ @$(APPEND) $(ARCH) = ARM
+-armv4t- -armv4i-::
+ @$(APPEND) CECPUDEF = -DARM -D_ARM_ -DARMV4T -DTHUMB -D_THUMB_
+ @$(APPEND) $(ARCH) = THUMB
+
+
+-hpc2k-: -hpc2000-
+-ppc-: "-MS Pocket PC-"
+-hpcpro2-: "-MS HPC Pro-"
+-hpcpro-: "-MS HPC Pro--"
+
+-mswin32-:
+ @type << >>$(MAKEFILE)
+OS = mswin32
+RT = msvcrt
+<<
+
+-mswince-:
+ @type << >>$(MAKEFILE)
+!ifdef CE_TOOLS_DIR
+CE_TOOLS_DIR = $(CE_TOOLS_DIR)
+!endif
+!ifdef EMBEDDED_TOOLS_DIR
+EMBEDDED_TOOLS_DIR = $(EMBEDDED_TOOLS_DIR)
+!endif
+
+OS = mswince
+RT = $$(OS)
+<<
+
+-mswince4-:
+ @type << >>$(MAKEFILE)
+!ifdef CE_TOOLS4_DIR
+CE_TOOLS4_DIR = $(CE_TOOLS4_DIR)
+!endif
+!ifdef EMBEDDED_TOOLS4_DIR
+EMBEDDED_TOOLS4_DIR = $(EMBEDDED_TOOLS4_DIR)
+!endif
+
+OS = mswince
+RT = $$(OS)
+<<
+
+
+-mswince-3.00 -mswince-2.11: -mswince-
+ @type << >>$(MAKEFILE)
+SUBSYSVERSION = $(@:-mswince-=)
+PATH = $$(EMBEDDED_TOOLS_DIR)/common/evc/bin;$$(EMBEDDED_TOOLS_DIR)/EVC/WCE$$(SUBSYSVERSION:.=)/bin
+<<
+
+-mswince-4.10: -mswince4-
+ @type << >>$(MAKEFILE)
+SUBSYSVERSION = $(@:-mswince-=)
+EXTLIBS = ws2.lib
+PATH = $$(EMBEDDED_TOOLS4_DIR)/common/evc/bin;$$(EMBEDDED_TOOLS4_DIR)/EVC/WCE$$(SUBSYSVERSION:.=)/bin
+<<
+
+-hpc2000- "-MS Pocket PC-": -mswince-3.00
+"-MS HPC Pro-" "-MS HPC Pro--": -mswince-2.11
+-.net41- -sig3-: -mswince-4.10
+
+-hpc2000-:
+ @type << >>$(MAKEFILE)
+SUBSYSTEM = windowsce,3.0
+INCLUDE = $$(CE_TOOLS_DIR)/wce$$(SUBSYSVERSION:.=)/$(@:-=)/include
+LIB = $$(CE_TOOLS_DIR)/wce$$(SUBSYSVERSION:.=)/$(@:-=)/lib/$$(PROCESSOR_ARCHITECTURE)
+<<
+
+"-MS Pocket PC-":
+ @type << >>$(MAKEFILE)
+SUBSYSTEM = windowsce,3.0
+INCLUDE = $$(CE_TOOLS_DIR)/wce$$(SUBSYSVERSION:.=)/MS Pocket PC/include
+LIB = $$(CE_TOOLS_DIR)/wce$$(SUBSYSVERSION:.=)/MS Pocket PC/lib/$$(PROCESSOR_ARCHITECTURE)
+<<
+
+
+"-MS HPC Pro--":
+ @type << >>$(MAKEFILE)
+SUBSYSTEM = windowsce,2.11
+INCLUDE = $$(CE_TOOLS_DIR)/wce$$(SUBSYSVERSION:.=)/MS HPC Pro/include
+LIB = $$(CE_TOOLS_DIR)/wce$$(SUBSYSVERSION:.=)/MS HPC Pro/lib/$$(PROCESSOR_ARCHITECTURE)
+<<
+
+-.net41-:
+ @type << >>$(MAKEFILE)
+SUBSYSTEM = windowsce,4.1
+INCLUDE = $$(CE_TOOLS4_DIR)/wce400/STANDARDSDK/include/$$(ARCHFOLDER)
+LIB = $$(CE_TOOLS4_DIR)/wce400/STANDARDSDK/lib/$$(ARCHFOLDER)
+<<
+
+-sig3-:
+ @type << >>$(MAKEFILE)
+SUBSYSTEM = windowsce,4.1
+INCLUDE = $$(CE_TOOLS4_DIR)/wce410/sigmarionIII SDK/include/$$(ARCHFOLDER)
+LIB = $$(CE_TOOLS4_DIR)/wce410/sigmarionIII SDK/lib/$$(ARCHFOLDER)
+<<
+
+-epilogue-: nul
+ @type << >>$(MAKEFILE)
+!ifdef RUBY_INSTALL_NAME
+RUBY_INSTALL_NAME = $(RUBY_INSTALL_NAME)
+!else ifdef RUBY_SUFFIX
+RUBY_INSTALL_NAME = ruby$(RUBY_SUFFIX)
+!endif
+!ifdef RUBY_SO_NAME
+RUBY_SO_NAME = $(RUBY_SO_NAME)
+!else
+# RUBY_SO_NAME = $$(RT)-$$(RUBY_INSTALL_NAME)$$(MAJOR)$$(MINOR)
+!endif
+# CFLAGS = -nologo $$(DEBUGFLAGS) $$(OPTFLAGS) $$(PROCESSOR_FLAG)
+CPPFLAGS = -I. -I$$(srcdir) -I$$(srcdir)/missing -I$$(srcdir)/wince \
+ $$(CECPUDEF) -DUNDER_CE -D_WIN32_WCE=$$(SUBSYSVERSION:.=) \
+ -DFILENAME_MAX=MAX_PATH -DTLS_OUT_OF_INDEXES=0xFFFFFFFF \
+ -DBUFSIZ=512 -D_UNICODE -DUNICODE $$(QSH4)
+# STACK = 0x10000,0x1000
+# LDFLAGS = $$(CFLAGS) -Fm
+# XLDFLAGS =
+# RFLAGS = -r
+# EXTLIBS =
+
+$(INCLUDE) $$(srcdir)/wince/Makefile.sub
+<<
+ @$(srcdir:/=\)\win32\rm.bat config.h config.status
+ @echo type `$(MAKE)' to make ruby for $(OS).
diff --git a/ruby_1_8_5/wince/signal.h b/ruby_1_8_5/wince/signal.h
new file mode 100644
index 0000000000..95f857dd88
--- /dev/null
+++ b/ruby_1_8_5/wince/signal.h
@@ -0,0 +1,71 @@
+#ifndef SIGNAL_H
+#define SIGNAL_H 1
+
+#include <sys/types.h>
+
+#define SIGHUP 1
+#define SIGINT 2
+#define SIGQUIT 3
+#define SIGILL 4
+#define SIGPIPE 5
+#define SIGFPE 8
+#define SIGUSR1 10
+#define SIGSEGV 11
+#define SIGUSR2 12
+#define SIGTERM 15
+#define SIGCHLD 17
+#define SIGTSTP 20
+#define SIGBREAK 21
+#define SIGABRT 22
+#define NSIG 22
+
+#define SA_NOCLDSTOP 1
+#define SA_SHIRQ 0x04000000
+#define SA_STACK 0x08000000
+#define SA_RESTART 0x10000000
+#define SA_INTERRUPT 0x20000000
+#define SA_NOMASK 0x40000000
+#define SA_ONESHOT 0x80000000
+
+/* signal action codes */
+
+#define SIG_DFL (void (*)(int))0 /* default signal action */
+#define SIG_IGN (void (*)(int))1 /* ignore signal */
+#define SIG_SGE (void (*)(int))3 /* signal gets error */
+#define SIG_ACK (void (*)(int))4 /* acknowledge */
+#define SIG_ERR (void (*)(int))-1 /* signal error value */
+
+#define SIG_BLOCK 0 /* for blocking signals */
+#define SIG_UNBLOCK 1 /* for unblocking signals */
+#define SIG_SETMASK 2 /* for setting the signal mask */
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef void (* SIGHANDLER)(int);
+typedef void (* sighandler_t)(int);
+
+typedef int sig_atomic_t;
+typedef unsigned int sigset_t;
+
+struct sigaction{
+ sighandler_t sa_handler;
+ sigset_t sa_mask;
+ unsigned long sa_flags;
+ void (*sa_restorer)(void);
+};
+
+int raise(int sig);
+//#ifndef _WIN32_WCE_EMULATION
+ void (* signal(int sig, void (__cdecl *func)(int)))(int);
+//#else
+// void (* signal(int sig, void (*func)));
+//#endif
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif
diff --git a/ruby_1_8_5/wince/signal_wce.c b/ruby_1_8_5/wince/signal_wce.c
new file mode 100644
index 0000000000..95f85e0ac8
--- /dev/null
+++ b/ruby_1_8_5/wince/signal_wce.c
@@ -0,0 +1,26 @@
+/***************************************************************
+ signal.c
+***************************************************************/
+
+#include <windows.h>
+#include "signal.h"
+
+/* lazy replacement... (^^; */
+int raise(int sig)
+{
+ return 0;
+}
+
+//#ifdef _WIN32_WCE
+//#ifdef _WIN32_WCE_EMULATION
+//void (* signal(int sig, void (*func)))
+//{
+// return sig;
+//}
+//#else
+void (* signal(int sig, void (__cdecl *func)(int)))(int)
+{
+ return sig;
+}
+//#endif
+//#endif
diff --git a/ruby_1_8_5/wince/stddef.h b/ruby_1_8_5/wince/stddef.h
new file mode 100644
index 0000000000..227725020e
--- /dev/null
+++ b/ruby_1_8_5/wince/stddef.h
@@ -0,0 +1,5 @@
+
+#ifndef _STDDEF_H_
+#define _STDDEF_H_
+
+#endif
diff --git a/ruby_1_8_5/wince/stdio.c b/ruby_1_8_5/wince/stdio.c
new file mode 100644
index 0000000000..877408d417
--- /dev/null
+++ b/ruby_1_8_5/wince/stdio.c
@@ -0,0 +1,36 @@
+/***************************************************************
+ stdio.c
+***************************************************************/
+
+#include <windows.h>
+#include "wince.h" /* for wce_mbtowc */
+
+
+FILE *freopen(const char *filename, const char *mode, FILE *file)
+{
+ wchar_t *wfilename, *wmode;
+ FILE *fp;
+
+ wfilename = wce_mbtowc(filename);
+ wmode = wce_mbtowc(mode);
+
+ fp = _wfreopen(wfilename, wmode, file);
+
+ free(wfilename);
+ free(wmode);
+
+ return fp;
+}
+
+FILE *fdopen( int handle, const char *mode )
+{
+ wchar_t *wmode;
+ FILE* fp;
+
+ wmode = wce_mbtowc(mode);
+ fp = _wfdopen( (void*)handle, wmode );
+
+ free(wmode);
+ return fp;
+}
+
diff --git a/ruby_1_8_5/wince/stdlib.c b/ruby_1_8_5/wince/stdlib.c
new file mode 100644
index 0000000000..d371b12f88
--- /dev/null
+++ b/ruby_1_8_5/wince/stdlib.c
@@ -0,0 +1,57 @@
+/***************************************************************
+ stdlib.c
+***************************************************************/
+
+#include <windows.h>
+
+char **environ;
+extern char * rb_w32_getenv(const char *);
+
+/* getenv should replace with rb_w32_getenv. */
+char *getenv(const char *env)
+{
+ return rb_w32_getenv(env);
+}
+
+char *_fullpath(char *absPath, const char *relPath,
+ size_t maxLength)
+{
+ strcpy( absPath, relPath );
+ return absPath;
+}
+
+int mblen(const char *mbstr, size_t count)
+{
+ const char *p = mbstr;
+ size_t i;
+ int n=0;
+
+ for( i=0; i<count; i++ )
+ {
+ if( *p=='\0' ) break;
+ if( IsDBCSLeadByteEx( CP_ACP, *p ) )
+ n+=2, p+=2;
+ else
+ n+=1, p+=1;
+ }
+
+ return n;
+}
+
+void *bsearch( const void *key, const void *base,
+ size_t num, size_t width,
+ int ( __cdecl *compare )(const void *, const void *))
+{
+ size_t i;
+ const void* p = base;
+ const char* px;
+
+ for( i=0; i<num; i++ )
+ {
+ if( 0==compare( key, p ) )
+ return (void*)p;
+ px = (const char*)p; px+=width; p=(const void*)px;
+ }
+ return NULL;
+}
+
diff --git a/ruby_1_8_5/wince/string_wce.c b/ruby_1_8_5/wince/string_wce.c
new file mode 100644
index 0000000000..257eee101d
--- /dev/null
+++ b/ruby_1_8_5/wince/string_wce.c
@@ -0,0 +1,89 @@
+/***************************************************************
+ string.c
+***************************************************************/
+
+#include <windows.h>
+#include "wince.h" /* for wce_mbtowc */
+
+/* _strdup already exists in stdlib.h? */
+char *strdup(const char * str)
+{
+ char *p;
+
+ p = malloc( strlen(str)+1 );
+ strcpy( p, str );
+ return p;
+}
+
+char* strerror(int errno)
+{
+ static char buf[32]="wince::strerror called.";
+ return buf;
+}
+
+/* strnicmp already exists in stdlib.h? */
+int strnicmp( const char *s1, const char *s2, size_t count )
+{
+ wchar_t *w1, *w2;
+ int n;
+
+ w1 = wce_mbtowc(s1);
+ w2 = wce_mbtowc(s2);
+
+ n = wcsnicmp(w1, w2, count);
+
+ free(w1);
+ free(w2);
+
+ return n;
+}
+
+#if _WIN32_WCE < 300
+#include "..\missing\strtoul.c"
+
+char *strrchr( const char *p, int c )
+{
+ char *pp;
+ for( pp=(char*)p+strlen(p); pp!=p; pp-- )
+ {
+ if( *pp==c ) break;
+ }
+ return pp==p ? NULL : pp;
+}
+
+int stricmp( const char *s1, const char *s2 )
+{
+ wchar_t *w1, *w2;
+ int n;
+
+ w1 = wce_mbtowc(s1);
+ w2 = wce_mbtowc(s2);
+
+ n = wcsicmp(w1, w2);
+
+ free(w1);
+ free(w2);
+
+ return n;
+}
+
+char *strpbrk(const char *str, const char *cs)
+{
+ wchar_t *wstr, *wcs, *w;
+ char *s = NULL;
+
+ wstr = wce_mbtowc(str);
+ wcs = wce_mbtowc(cs);
+
+ w = wcspbrk(wstr, wcs);
+
+ if( w!=NULL )
+ s = str + (wcs-wstr)/sizeof(wchar_t);
+
+ free(wstr);
+ free(wcs);
+
+ return s;
+}
+
+#endif
diff --git a/ruby_1_8_5/wince/sys/stat.c b/ruby_1_8_5/wince/sys/stat.c
new file mode 100644
index 0000000000..5d51dbf426
--- /dev/null
+++ b/ruby_1_8_5/wince/sys/stat.c
@@ -0,0 +1,102 @@
+/***************************************************************
+ stat.c
+
+ author : uema2
+ date : Nov 30, 2002
+
+ You can freely use, copy, modify, and redistribute
+ the whole contents.
+***************************************************************/
+
+#include <windows.h>
+#include <sys/stat.h>
+#include <time.h>
+#include "..\wince.h" /* for wce_mbtowc */
+
+
+int _stat(const char *filename, struct _stat *st)
+{
+ DWORD dwAttribute;
+ HANDLE h;
+ DWORD dwSizeLow=0, dwSizeHigh=0, dwError=0;
+ WIN32_FIND_DATAW fd;
+ wchar_t *wfilename;
+
+// wfilename = wce_mbtowc(filename);
+ wfilename = wce_replaceRelativeDir(filename);
+
+ dwAttribute = GetFileAttributesW(wfilename);
+ if(dwAttribute==0xFFFFFFFF)
+ {
+ free(wfilename);
+ return -1;
+ }
+
+ st->st_mode = 0;
+ if((dwAttribute & FILE_ATTRIBUTE_DIRECTORY) != 0)
+ st->st_mode += S_IFDIR;
+ else
+ st->st_mode += S_IFREG;
+
+ /* initialize */
+ st->st_atime = 0;
+ st->st_mtime = 0;
+ st->st_ctime = 0;
+ st->st_size = 0;
+ st->st_dev = 0;
+
+ h = FindFirstFileW(wfilename, &fd);
+ if(h == INVALID_HANDLE_VALUE)
+ {
+ if(wfilename[wcslen(wfilename)-1] == L'\\')
+ {
+ wfilename[wcslen(wfilename)-1] = L'\0';
+ h = FindFirstFileW(wfilename, &fd);
+ if(h == INVALID_HANDLE_VALUE)
+ {
+ free(wfilename);
+ return 0;
+ }
+ }
+ else
+ {
+ free(wfilename);
+ return 0;
+ }
+ }
+
+ /* FILETIME -> time_t */
+ st->st_atime = wce_FILETIME2time_t(&fd.ftLastAccessTime);
+ st->st_mtime = wce_FILETIME2time_t(&fd.ftLastWriteTime);
+ st->st_ctime = wce_FILETIME2time_t(&fd.ftCreationTime);
+ st->st_size = fd.nFileSizeLow;
+
+ FindClose( h );
+ free(wfilename);
+ return 0;
+}
+
+int fstat(int file, struct stat *sbuf)
+{
+ /* GetFileSize & GetFileTime */
+ DWORD dwSize;
+ FILETIME ctime, atime, mtime;
+
+ dwSize = GetFileSize( (HANDLE)file, NULL );
+ if( dwSize == 0xFFFFFFFF )
+ return -1;
+
+ sbuf->st_size = dwSize;
+ sbuf->st_dev = 0;
+ sbuf->st_rdev = 0;
+ sbuf->st_mode = _S_IFREG;
+ sbuf->st_nlink= 1;
+
+ GetFileTime( (HANDLE)file, &ctime, &atime, &mtime );
+ sbuf->st_ctime = wce_FILETIME2time_t(&ctime);
+ sbuf->st_atime = wce_FILETIME2time_t(&atime);
+ sbuf->st_mtime = wce_FILETIME2time_t(&mtime);
+
+ return 0;
+}
+
diff --git a/ruby_1_8_5/wince/sys/stat.h b/ruby_1_8_5/wince/sys/stat.h
new file mode 100644
index 0000000000..e3cdf8b8e7
--- /dev/null
+++ b/ruby_1_8_5/wince/sys/stat.h
@@ -0,0 +1,68 @@
+#ifndef SYS_STAT_H
+#define SYS_STAT_H 1
+
+#include <sys/types.h>
+
+#define _S_IFMT 0170000 /* file type mask */
+#define _S_IFDIR 0040000 /* directory */
+#define _S_IFCHR 0020000 /* character special */
+#define _S_IFIFO 0010000 /* pipe */
+#define _S_IFREG 0100000 /* regular */
+#define _S_IREAD 0000400 /* read permission, owner */
+#define _S_IWRITE 0000200 /* write permission, owner */
+#define _S_IEXEC 0000100 /* execute/search permission, owner */
+
+#define S_IFMT _S_IFMT
+#define S_IFREG _S_IFREG
+#define S_IFCHR _S_IFCHR
+#define S_IFDIR _S_IFDIR
+#define S_IREAD _S_IREAD
+#define S_IWRITE _S_IWRITE
+#define S_IEXEC _S_IEXEC
+
+#ifndef S_ISDIR
+#define S_ISDIR(X) (((X) & S_IFMT) == S_IFDIR)
+#endif
+#ifndef S_ISREG
+#define S_ISREG(X) (((X) & S_IFMT) == S_IFREG)
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// in sys/types.h
+//typedef unsigned int _dev_t;
+//typedef long _off_t;
+//typedef unsigned short _ino_t;
+
+#ifndef _STAT_DEFINED
+struct stat
+{
+ dev_t st_dev;
+ ino_t st_ino;
+ unsigned short st_mode;
+ short st_nlink;
+ short st_uid;
+ short st_gid;
+ dev_t st_rdev;
+ off_t st_size;
+ time_t st_atime;
+ time_t st_mtime;
+ time_t st_ctime;
+};
+#define _STAT_DEFINED
+#endif /* _STAT_DEFINED */
+
+#define _stat stat
+
+int _stat(const char *filename, struct _stat *stat);
+int fstat(int file, struct stat *sbuf);
+
+
+#ifdef __cplusplus
+};
+#endif
+
+
+#endif
diff --git a/ruby_1_8_5/wince/sys/timeb.c b/ruby_1_8_5/wince/sys/timeb.c
new file mode 100644
index 0000000000..838ae0798d
--- /dev/null
+++ b/ruby_1_8_5/wince/sys/timeb.c
@@ -0,0 +1,25 @@
+/***************************************************************
+ timeb.c
+***************************************************************/
+
+#include <windows.h>
+#include <time.h>
+#include <sys/timeb.h>
+
+
+int ftime(struct timeb *tp)
+{
+ SYSTEMTIME s;
+ FILETIME f;
+
+ GetLocalTime(&s);
+ SystemTimeToFileTime( &s, &f );
+
+ tp->dstflag = 0;
+ tp->timezone = _timezone/60;
+ tp->time = wce_FILETIME2time_t(&f);
+ tp->millitm = s.wMilliseconds;
+
+ return 0;
+}
+
diff --git a/ruby_1_8_5/wince/sys/timeb.h b/ruby_1_8_5/wince/sys/timeb.h
new file mode 100644
index 0000000000..e051b9058c
--- /dev/null
+++ b/ruby_1_8_5/wince/sys/timeb.h
@@ -0,0 +1,26 @@
+#ifndef SYS_TIMEB_H
+#define SYS_TIMEB_H 1
+
+#include <sys/types.h>
+
+struct _timeb {
+ time_t time;
+ unsigned short millitm;
+ short timezone;
+ short dstflag;
+};
+
+#define timeb _timeb
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int ftime(struct timeb *tp);
+
+#ifdef __cplusplus
+};
+#endif
+
+
+#endif
diff --git a/ruby_1_8_5/wince/sys/types.h b/ruby_1_8_5/wince/sys/types.h
new file mode 100644
index 0000000000..541d5e8361
--- /dev/null
+++ b/ruby_1_8_5/wince/sys/types.h
@@ -0,0 +1,60 @@
+#ifndef SYS_TYPES_H
+#define SYS_TYPES_H 1
+
+#define BIG_ENDIAN 1234
+#define LITTLE_ENDIAN 4321
+
+#ifdef MIPS
+#define BYTE_ORDER LITTLE_ENDIAN
+#endif
+
+//#if UNDER_CE > 201
+// typedef unsigned long time_t;
+// #define _TIME_T_DEFINED_
+//#endif
+typedef unsigned long dev_t;
+typedef unsigned long ino_t;
+#ifndef _MODE_T_DEFINED_
+ typedef unsigned long mode_t;
+ #define _MODE_T_DEFINED_
+#endif
+
+typedef long clock_t;
+
+#ifndef _PTRDIFF_T_DEFINED
+typedef long ptrdiff_t;
+#define _PTRDIFF_T_DEFINED
+#endif
+
+typedef long off_t;
+
+//typedef unsigned char u_char;
+//typedef unsigned short u_short;
+
+#ifndef _CADDR_T_DEFINED_
+typedef unsigned char * caddr_t;
+#define _CADDR_T_DEFINED_
+#endif
+
+#ifndef _SIZE_T_DEFINED_
+typedef unsigned int size_t;
+#define _SIZE_T_DEFINED_
+#endif
+
+//typedef unsigned char u_int8_t;
+
+//typedef short int16_t;
+//typedef unsigned short u_int16_t;
+
+//typedef int int32_t;
+//typedef unsigned int u_int32_t;
+
+//typedef unsigned long u_long;
+//typedef unsigned int u_int;
+
+//#ifndef _TIME_T_DEFINED_
+//typedef unsigned long time_t;
+//#define _TIME_T_DEFINED_
+//#endif
+
+#endif
diff --git a/ruby_1_8_5/wince/sys/utime.c b/ruby_1_8_5/wince/sys/utime.c
new file mode 100644
index 0000000000..0139c13828
--- /dev/null
+++ b/ruby_1_8_5/wince/sys/utime.c
@@ -0,0 +1,44 @@
+/***************************************************************
+ utime.c
+***************************************************************/
+
+#include <windows.h>
+#include <sys/utime.h>
+#include "..\wince.h" /* for wce_mbtowc */
+
+
+#ifdef _WIN32_WCE
+ #if _WIN32_WCE < 300
+ #define Int32x32To64(a, b) ((LONGLONG)((LONG)(a)) * (LONGLONG)((LONG)(b)))
+/* #define Int32x32To64(a, b) ((__int64)((LONG)(a)) * (__int64)((LONG)(b))) */
+ #endif
+#endif
+
+int utime(const char *f, struct utimbuf *t)
+{
+ HANDLE h;
+ FILETIME atime={0}, mtime={0};
+ __int64 time64;
+ BOOL rc;
+ wchar_t *w;
+
+ w = wce_mbtowc(f);
+ h = CreateFileW(w, GENERIC_WRITE,
+ FILE_SHARE_READ|FILE_SHARE_WRITE,
+ NULL, OPEN_EXISTING, 0, 0);
+ free(w);
+
+ if( h==INVALID_HANDLE_VALUE )
+ return -1;
+
+ time64 = Int32x32To64(t->actime, 10000000) + 116444736000000000;
+ atime.dwLowDateTime = (DWORD)time64;
+ atime.dwHighDateTime = (DWORD)(time64 >> 32);
+ time64 = Int32x32To64(t->modtime, 10000000) + 116444736000000000;
+ mtime.dwLowDateTime = (DWORD)time64;
+ mtime.dwHighDateTime = (DWORD)(time64 >> 32);
+
+ rc = SetFileTime(h, NULL, &atime, &mtime);
+ return rc==TRUE ? 0 : -1;
+}
+
diff --git a/ruby_1_8_5/wince/sys/utime.h b/ruby_1_8_5/wince/sys/utime.h
new file mode 100644
index 0000000000..b644f02a61
--- /dev/null
+++ b/ruby_1_8_5/wince/sys/utime.h
@@ -0,0 +1,27 @@
+#ifndef SYS_UTIME_H
+#define SYS_UTIME_H 1
+
+#include <time.h>
+
+struct utimbuf
+{
+ time_t actime;
+ time_t modtime;
+};
+
+#define _utimbuf utimbuf
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int utime(const char *f, struct utimbuf *t);
+
+#ifdef __cplusplus
+};
+#endif
+
+//#define utime _utime
+
+#endif
diff --git a/ruby_1_8_5/wince/time.h b/ruby_1_8_5/wince/time.h
new file mode 100644
index 0000000000..531b2aacfd
--- /dev/null
+++ b/ruby_1_8_5/wince/time.h
@@ -0,0 +1,63 @@
+#ifndef _TIME_WINCE_H
+#define _TIME_WINCE_H 1
+
+#include <winbase.h>
+#include <sys/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int daylight;
+extern int _timezone, timezone;
+extern char *tzname[2];
+
+#if 0
+#define _DAY_SEC (24L * 60L * 60L) /* secs in a day */
+#define _YEAR_SEC (365L * _DAY_SEC) /* secs in a year */
+#define _FOUR_YEAR_SEC (1461L * _DAY_SEC) /* secs in a 4 year interval */
+#define _DEC_SEC 315532800L /* secs in 1970-1979 */
+#define _BASE_YEAR 70L /* 1970 is the base year */
+#define _BASE_DOW 4 /* 01-01-70 was a Thursday */
+#define _LEAP_YEAR_ADJUST 17L /* Leap years 1900 - 1970 */
+#define _MAX_YEAR 138L /* 2038 is the max year */
+#endif
+
+#ifndef _TM_DEFINED
+struct tm {
+ int tm_sec; /* seconds after the minute - [0,59] */
+ int tm_min; /* minutes after the hour - [0,59] */
+ int tm_hour; /* hours since midnight - [0,23] */
+ int tm_mday; /* day of the month - [1,31] */
+ int tm_mon; /* months since January - [0,11] */
+ int tm_year; /* years since 1900 */
+ int tm_wday; /* days since Sunday - [0,6] */
+ int tm_yday; /* days since January 1 - [0,365] */
+ int tm_isdst; /* daylight savings time flag */
+};
+#define _TM_DEFINED
+#endif
+
+
+typedef struct {
+ int yr; // year of interest
+ int yd; // day of year
+ long ms; // milli-seconds in the day
+} transitionTime;
+
+time_t mktime(struct tm* pt);
+time_t time( time_t *timer );
+struct tm *localtime(const time_t *ptime);
+struct tm *gmtime(const time_t *tod);
+char* ctime( const time_t *t );
+char* asctime(const struct tm *tptr);
+void tzset();
+int clock(void);
+time_t wce_FILETIME2time_t(const FILETIME* pf);
+
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif
diff --git a/ruby_1_8_5/wince/time_wce.c b/ruby_1_8_5/wince/time_wce.c
new file mode 100644
index 0000000000..ed9b3386bd
--- /dev/null
+++ b/ruby_1_8_5/wince/time_wce.c
@@ -0,0 +1,301 @@
+/***************************************************************
+ time.c
+
+ author : uema2
+ date : Nov 30, 2002
+
+ You can freely use, copy, modify, and redistribute
+ the whole contents.
+***************************************************************/
+
+/*#define __SCRATCH_TIMEC_DEBUG__ */
+
+#include <windows.h>
+#include <tchar.h>
+#include <time.h>
+
+/* globals */
+const __int64 _onesec_in100ns = (__int64)10000000;
+int timezone, _timezone, altzone;
+int daylight;
+char *tzname[2];
+
+
+/* __int64 <--> FILETIME */
+static __int64 wce_FILETIME2int64(FILETIME f)
+{
+ __int64 t;
+
+ t = f.dwHighDateTime;
+ t <<= 32;
+ t |= f.dwLowDateTime;
+ return t;
+}
+
+static FILETIME wce_int642FILETIME(__int64 t)
+{
+ FILETIME f;
+
+ f.dwHighDateTime = (DWORD)((t >> 32) & 0x00000000FFFFFFFF);
+ f.dwLowDateTime = (DWORD)( t & 0x00000000FFFFFFFF);
+ return f;
+}
+
+/* FILETIME utility */
+static FILETIME wce_getFILETIMEFromYear(WORD year)
+{
+ SYSTEMTIME s={0};
+ FILETIME f;
+
+ s.wYear = year;
+ s.wMonth = 1;
+ s.wDayOfWeek = 1;
+ s.wDay = 1;
+
+ SystemTimeToFileTime( &s, &f );
+ return f;
+}
+
+static time_t wce_getYdayFromSYSTEMTIME(const SYSTEMTIME* s)
+{
+ __int64 t;
+ FILETIME f1, f2;
+
+ f1 = wce_getFILETIMEFromYear( s->wYear );
+ SystemTimeToFileTime( s, &f2 );
+
+ t = wce_FILETIME2int64(f2)-wce_FILETIME2int64(f1);
+
+ return (time_t)((t/_onesec_in100ns)/(60*60*24));
+}
+
+/* tm <--> SYSTEMTIME */
+static SYSTEMTIME wce_tm2SYSTEMTIME(struct tm *t)
+{
+ SYSTEMTIME s;
+
+ s.wYear = t->tm_year + 1900;
+ s.wMonth = t->tm_mon + 1;
+ s.wDayOfWeek = t->tm_wday;
+ s.wDay = t->tm_mday;
+ s.wHour = t->tm_hour;
+ s.wMinute = t->tm_min;
+ s.wSecond = t->tm_sec;
+ s.wMilliseconds = 0;
+
+ return s;
+}
+
+static struct tm wce_SYSTEMTIME2tm(SYSTEMTIME *s)
+{
+ struct tm t;
+
+ t.tm_year = s->wYear - 1900;
+ t.tm_mon = s->wMonth- 1;
+ t.tm_wday = s->wDayOfWeek;
+ t.tm_mday = s->wDay;
+ t.tm_yday = wce_getYdayFromSYSTEMTIME(s);
+ t.tm_hour = s->wHour;
+ t.tm_min = s->wMinute;
+ t.tm_sec = s->wSecond;
+ t.tm_isdst = 0;
+
+ return t;
+}
+
+/* FILETIME <--> time_t */
+time_t wce_FILETIME2time_t(const FILETIME* f)
+{
+ FILETIME f1601, f1970;
+ __int64 t, offset;
+
+ f1601 = wce_getFILETIMEFromYear(1601);
+ f1970 = wce_getFILETIMEFromYear(1970);
+
+ offset = wce_FILETIME2int64(f1970) - wce_FILETIME2int64(f1601);
+
+ t = wce_FILETIME2int64(*f);
+
+ t -= offset;
+ return (time_t)(t / _onesec_in100ns);
+}
+
+FILETIME wce_time_t2FILETIME(const time_t t)
+{
+ FILETIME f, f1970;
+ __int64 time;
+
+ f1970 = wce_getFILETIMEFromYear(1970);
+
+ time = t;
+ time *= _onesec_in100ns;
+ time += wce_FILETIME2int64(f1970);
+
+ f = wce_int642FILETIME(time);
+
+ return f;
+}
+
+/* time.h difinition */
+time_t time( time_t *timer )
+{
+ SYSTEMTIME s;
+ FILETIME f;
+
+ if( timer==NULL ) return 0;
+
+ GetSystemTime( &s );
+
+ SystemTimeToFileTime( &s, &f );
+
+ *timer = wce_FILETIME2time_t(&f);
+ return *timer;
+}
+
+struct tm *localtime( const time_t *timer )
+{
+ SYSTEMTIME ss, ls, s;
+ FILETIME sf, lf, f;
+ __int64 t, diff;
+ static struct tm tms;
+
+ GetSystemTime(&ss);
+ GetLocalTime(&ls);
+
+ SystemTimeToFileTime( &ss, &sf );
+ SystemTimeToFileTime( &ls, &lf );
+
+ diff = wce_FILETIME2int64(sf) - wce_FILETIME2int64(lf);
+
+ f = wce_time_t2FILETIME(*timer);
+ t = wce_FILETIME2int64(f) - diff;
+ f = wce_int642FILETIME(t);
+
+ FileTimeToSystemTime( &f, &s );
+
+ tms = wce_SYSTEMTIME2tm(&s);
+
+ return &tms;
+}
+
+time_t mktime(struct tm* pt)
+{
+ SYSTEMTIME ss, ls, s;
+ FILETIME sf, lf, f;
+ __int64 diff;
+
+ GetSystemTime(&ss);
+ GetLocalTime(&ls);
+ SystemTimeToFileTime( &ss, &sf );
+ SystemTimeToFileTime( &ls, &lf );
+
+ diff = (wce_FILETIME2int64(lf)-wce_FILETIME2int64(sf))/_onesec_in100ns;
+
+ s = wce_tm2SYSTEMTIME(pt);
+ SystemTimeToFileTime( &s, &f );
+ return wce_FILETIME2time_t(&f) - (time_t)diff;
+}
+
+struct tm *gmtime(const time_t *t)
+{
+ FILETIME f;
+ SYSTEMTIME s;
+ static struct tm tms;
+
+ f = wce_time_t2FILETIME(*t);
+ FileTimeToSystemTime(&f, &s);
+ tms = wce_SYSTEMTIME2tm(&s);
+ return &tms;
+}
+
+char* ctime( const time_t *t )
+{
+ // Wed Jan 02 02:03:55 1980\n\0
+ static char buf[30]={0};
+ char week[] = "Sun Mon Tue Wed Thr Fri Sat ";
+ char month[]= "Jan Feb Mar Apl May Jun Jul Aug Sep Oct Nov Dec ";
+ struct tm tms;
+
+ tms = *localtime(t);
+
+ strncpy( buf, week+tms.tm_wday*4, 4 );
+ strncpy( buf+4, month+tms.tm_mon*4, 4 );
+ sprintf( buf+8, "%02d ", tms.tm_mday );
+ sprintf( buf+11, "%02d:%02d:%02d %d\n",
+ tms.tm_hour, tms.tm_min, tms.tm_sec, tms.tm_year+1900 );
+ return buf;
+}
+
+char *asctime(const struct tm *pt)
+{
+ static char buf[30]={0};
+ char week[] = "Sun Mon Tue Wed Thr Fri Sat ";
+ char month[]= "Jan Feb Mar Apl May Jun Jul Aug Sep Oct Nov Dec ";
+
+ strncpy( buf, week+pt->tm_wday*4, 4 );
+ strncpy( buf+4, month+pt->tm_mon*4, 4 );
+ sprintf( buf+8, "%02d ", pt->tm_mday );
+ sprintf( buf+11, "%02d:%02d:%02d %d\n",
+ pt->tm_hour, pt->tm_min, pt->tm_sec, pt->tm_year+1900 );
+ return buf;
+}
+
+void tzset()
+{
+ daylight = 1;
+ _timezone = 28800;
+ timezone = 28800;
+}
+
+int clock(void)
+{
+ return 1;
+}
+
+//---------------------------------------------------------------
+#ifdef __SCRATCH_TIMEC_DEBUG__
+
+int main()
+{
+ time_t t1, t2;
+ struct tm tm1, tm2;
+
+ time( &t1 );
+ tm1 = *localtime(&t1);
+ t1 = mktime(&tm1);
+ tm1 = *gmtime(&t1);
+
+ _time( &t2 );
+ tm2 = *_localtime(&t2);
+ t2 = _mktime(&tm2);
+ tm2 = *_gmtime(&t2);
+
+ // time, mktime
+ if( t1==t2 )
+ OutputDebugString( "ok\n" );
+ else
+ {
+ static char buf[128];
+ wsprintf( buf, "ng : %d, %d\n", t1, t2 );
+ OutputDebugString( buf );
+ }
+
+ // localtime, gmtime
+ if( 0==memcmp( &tm1, &tm2, sizeof(struct tm) ) )
+ OutputDebugString( "ok\n" );
+ else
+ OutputDebugString( "ng\n" );
+
+ // ctime
+ OutputDebugString( ctime(&t1) );
+ OutputDebugString( _ctime(&t2) );
+
+ // asctime
+ OutputDebugString( asctime(&tm1) );
+ OutputDebugString( _asctime(&tm2) );
+
+ return 0;
+}
+
+#endif
+
diff --git a/ruby_1_8_5/wince/varargs.h b/ruby_1_8_5/wince/varargs.h
new file mode 100644
index 0000000000..2d1d476ccd
--- /dev/null
+++ b/ruby_1_8_5/wince/varargs.h
@@ -0,0 +1,34 @@
+
+#ifndef VARARGS_H
+#define VARARGS_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef _VA_LIST_DEFINED
+typedef char *va_list;
+#define _VA_LIST_DEFINED
+#endif
+
+//#ifdef MIPS
+#define va_alist __va_alist, __va_alist2, __va_alist3, __va_alist4
+#define va_dcl int __va_alist, __va_alist2, __va_alist3, __va_alist4;
+#define va_start(list) list = (char *) &__va_alist
+#define va_end(list)
+#define va_arg(list, mode) ((mode *)(list =\
+ (char *) ((((int)list + (__builtin_alignof(mode)<=4?3:7)) &\
+ (__builtin_alignof(mode)<=4?-4:-8))+sizeof(mode))))[-1]
+#else
+#define _INTSIZEOF(n) ( (sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1) )
+#define va_dcl va_list va_alist;
+#define va_start(ap) ap = (va_list)&va_alist
+#define va_arg(ap,t) ( *(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)) )
+#define va_end(ap) ap = (va_list)0
+//#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/ruby_1_8_5/wince/wince.c b/ruby_1_8_5/wince/wince.c
new file mode 100644
index 0000000000..c1a950c1c1
--- /dev/null
+++ b/ruby_1_8_5/wince/wince.c
@@ -0,0 +1,583 @@
+/***************************************************************
+ wince.c
+
+ author : uema2
+ date : Nov 30, 2002
+
+ You can freely use, copy, modify, and redistribute
+ the whole contents.
+***************************************************************/
+
+#include <windows.h>
+#include <tchar.h>
+#include "wince.h"
+
+/* global for GetCommandLineA */
+char *_commandLine;
+
+extern char _currentdir[];
+
+/* make up Win32API except wce_* functions. */
+
+DWORD GetModuleFileNameA(
+ HMODULE hModule, LPSTR lpFileName,
+ DWORD size )
+{
+ LPWSTR lpFileNameW;
+ LPSTR mb;
+ size_t ret;
+
+ if( size==0 ) return 0;
+
+ lpFileNameW = (LPWSTR)malloc( size*sizeof(wchar_t) );
+ ret = GetModuleFileNameW( hModule, lpFileNameW, size );
+ mb = wce_wctomb(lpFileNameW);
+ strcpy(lpFileName, mb);
+ free(mb);
+ free(lpFileNameW);
+
+ return ret;
+}
+
+#if _WIN32_WCE < 300
+FARPROC GetProcAddressA(HMODULE hModule, LPCSTR lpProcName)
+{
+ FARPROC p;
+ LPWSTR lpwProcName;
+
+ lpwProcName = wce_mbtowc( lpProcName );
+ p = GetProcAddressW( hModule, lpwProcName );
+ free( lpwProcName );
+ return p;
+}
+#endif
+
+char * GetCommandLineA(void)
+{
+ return _commandLine;
+}
+
+/* this is not Win32API. GetCommandLineA helper. */
+void wce_SetCommandLine(LPCWSTR wcmd)
+{
+ char* acmd;
+
+ acmd = wce_wctomb( wcmd );
+ _commandLine = (char*)malloc( strlen(acmd)+5 );
+ sprintf( _commandLine, "ruby %s", acmd );
+ free(acmd);
+}
+
+/* this is not Win32API. GetCommandLineA helper. */
+void wce_FreeCommandLine(void)
+{
+ free(_commandLine);
+ _commandLine = NULL;
+}
+
+/* I have no idea how to replace this. */
+BOOL GetProcessTimes(HANDLE hprocess,
+ LPFILETIME lpCreationTime, LPFILETIME lpExitTime,
+ LPFILETIME lpKernelTime, LPFILETIME lpUserTime)
+{
+ return 0;
+}
+
+/* -------------- file attributes functions. ------------------- */
+DWORD GetFileAttributesA(LPCSTR lpFileName)
+{
+ LPWSTR lpwFileName;
+ DWORD dw;
+
+ lpwFileName = wce_mbtowc(lpFileName);
+ dw = GetFileAttributesW(lpwFileName);
+ free(lpwFileName);
+ return dw;
+}
+
+BOOL SetFileAttributesA(
+ LPCSTR lpFileName, DWORD attributes)
+{
+ LPWSTR lpwFileName;
+ BOOL b;
+
+ lpwFileName = wce_mbtowc(lpFileName);
+ b = SetFileAttributesW(lpwFileName, attributes);
+ free(lpwFileName);
+ return b;
+}
+
+/* --------------- move and remove functions. ------------------- */
+BOOL MoveFileA(LPCSTR fn1, LPCSTR fn2)
+{
+ LPWSTR wfn1, wfn2;
+ BOOL b;
+
+ wfn1 = wce_mbtowc(fn1);
+ wfn2 = wce_mbtowc(fn2);
+ b = MoveFileW(wfn1, wfn2);
+ free(wfn1);
+ free(wfn2);
+ return 0;
+}
+
+BOOL MoveFileEx(LPCSTR oldname, LPCSTR newname, DWORD dwFlags)
+{
+ LPWSTR woldname, wnewname;
+ BOOL b;
+
+ woldname = wce_mbtowc(oldname);
+ wnewname = wce_mbtowc(newname);
+
+ if( (dwFlags&MOVEFILE_REPLACE_EXISTING)!=0 )
+ DeleteFileW( wnewname );
+
+ b = MoveFileW( woldname, wnewname );
+
+ free(woldname);
+ free(wnewname);
+
+ return b;
+}
+
+BOOL DeleteFileA(LPCSTR path)
+{
+ LPWSTR wpath;
+ BOOL b;
+
+ wpath = wce_mbtowc(path);
+ b = DeleteFileW(wpath);
+ free(wpath);
+ return 0;
+}
+
+/* --------------- EnvironmentVariable functions. ----------------- */
+DWORD GetEnvironmentVariable(
+ LPCSTR name, LPSTR value, DWORD size)
+{
+ /* use registry instead of "environment valuable". */
+ HKEY hk;
+ LONG lret;
+ LPBYTE lpData;
+ DWORD dwType=REG_SZ, cbData;
+ TCHAR buf[MAX_PATH]={0};
+ LPWSTR wname;
+ LPSTR avalue;
+
+ lret = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
+ _T("Software\\ruby_mswince"),
+ 0, KEY_QUERY_VALUE, &hk );
+
+ if ( lret != ERROR_SUCCESS )
+ {
+ strcpy( value, "" );
+ return 0;
+ }
+
+ lpData = (LPBYTE)buf;
+ cbData = MAX_PATH*sizeof(*buf);
+ wname = wce_mbtowc( name );
+
+ lret = RegQueryValueEx( hk, wname,
+ NULL, &dwType, lpData, &cbData );
+ RegCloseKey( hk );
+
+ if ( lret != ERROR_SUCCESS )
+ {
+ strcpy( value, "" );
+ free( wname );
+ return 0;
+ }
+
+ avalue = wce_wctomb( (LPCTSTR)lpData );
+ strcpy( value, avalue );
+ free( avalue );
+ free( wname );
+
+ return strlen(value);
+}
+
+BOOL SetEnvironmentVariable(LPCSTR name, LPCSTR value)
+{
+ /* use registry instead of "environment valuable". */
+ HKEY hk;
+ LONG lret;
+ LPBYTE lpData;
+ DWORD ret, dwType=REG_SZ, cbData;
+ LPWSTR wname, wvalue;
+
+ lret = RegCreateKeyEx( HKEY_LOCAL_MACHINE,
+ _T("Software\\ruby_mswince"),
+ 0, _T(""), 0,
+ 0, NULL, &hk, &ret );
+ if( lret != ERROR_SUCCESS )
+ return FALSE;
+
+ wname = wce_mbtowc(name);
+ wvalue = wce_mbtowc(value);
+
+ lpData = (LPBYTE)wvalue;
+ cbData = (wcslen(wvalue) + 1) * sizeof(*wvalue);
+ lret = RegSetValueEx( hk, wname,
+ 0, dwType, lpData, cbData );
+ RegCloseKey( hk );
+ free(wname);
+ free(wvalue);
+ return lret == ERROR_SUCCESS;
+}
+
+LPVOID GetEnvironmentStrings(VOID)
+{
+ return NULL;
+}
+
+BOOL FreeEnvironmentStrings(LPSTR lpszEnvironmentBlock)
+{
+ return FALSE;
+}
+
+/* DuplicateHandle, LockFile, etc... */
+/* I have no idea... */
+BOOL GenerateConsoleCtrlEvent(DWORD dwCtrlEvent,
+ DWORD dwProcessGroupID)
+{
+ return 0;
+}
+
+BOOL DuplicateHandle(
+ HANDLE source_process, HANDLE source,
+ HANDLE dest_process, HANDLE *dest,
+ DWORD access, BOOL inherit, DWORD options)
+{
+ return 0;
+}
+
+BOOL LockFile(HANDLE hFile,
+ DWORD dwFileOffsetLow, DWORD dwFileOffsetHigh,
+ DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh)
+{
+ return FALSE;
+}
+
+BOOL LockFileEx(HANDLE hFile,
+ DWORD dwFlags, DWORD dwReserved,
+ DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh,
+ LPOVERLAPPED lpOverlapped)
+{
+ return FALSE;
+}
+
+BOOL UnlockFile( HFILE hFile,
+ DWORD dwFileOffsetLow, DWORD dwFileOffsetHigh,
+ DWORD nNumberOfBytesToUnlockLow, DWORD nNumberOfBytesToUnlockHigh)
+{
+ return FALSE;
+}
+
+BOOL UnlockFileEx(HANDLE hFile,
+ DWORD dwReserved, DWORD nNumberOfBytesToUnlockLow,
+ DWORD nNumberOfBytesToUnlockHigh, LPOVERLAPPED lpOverlapped)
+{
+ return FALSE;
+}
+
+/* --------------------- etc, etc, etc... ----------------------- */
+BOOL GetVersionExA(OSVERSIONINFOA *v)
+{
+ OSVERSIONINFOW wv;
+ BOOL b;
+ LPSTR mb;
+
+ b = GetVersionExW(&wv);
+ mb = wce_wctomb(wv.szCSDVersion);
+
+ strcpy( v->szCSDVersion, mb );
+ free(mb);
+ return b;
+}
+
+DWORD WaitForMultipleObjectsEx(DWORD count,
+ const HANDLE *handles, BOOL wait_all,
+ DWORD timeout, BOOL alertable)
+{
+ return WaitForMultipleObjects(
+ count, handles, wait_all,
+ timeout );
+}
+
+BOOL CreateProcessA(LPCSTR appname, LPCSTR commandline,
+ LPSECURITY_ATTRIBUTES att, LPSECURITY_ATTRIBUTES threadatt,
+ BOOL bOpt, DWORD dwFlag, LPVOID lpEnv, LPSTR dir,
+ LPSTARTUPINFO lpsi, LPPROCESS_INFORMATION lppi)
+{
+ LPWSTR wappname, wcommandline, wdir;
+ BOOL b;
+
+ wappname = wce_mbtowc(appname);
+ wcommandline = wce_mbtowc(commandline);
+ wdir = wce_mbtowc(dir);
+
+ b = CreateProcessW(wappname, wcommandline,
+ att, threadatt, bOpt, dwFlag, lpEnv,
+ wdir, lpsi, lppi);
+
+ free(wappname);
+ free(wcommandline);
+ free(wdir);
+
+ return b;
+}
+
+HANDLE CreateEventA(SECURITY_ATTRIBUTES *sa,
+ BOOL manual_reset, BOOL initial_state, LPCSTR name)
+{
+ HANDLE h;
+ LPWSTR wname;
+
+ wname = wce_mbtowc(name);
+ h = CreateEventW(sa, manual_reset,
+ initial_state, wname);
+ free(wname);
+
+ return h;
+}
+
+DWORD FormatMessageA(DWORD dwFlags, LPCVOID lpSource,
+ DWORD dwMessageId, DWORD dwLanguageId, LPSTR lpBuffer,
+ DWORD nSize, va_list* args)
+{
+ DWORD dw;
+ LPWSTR lpWBuffer;
+
+ lpWBuffer = wce_mbtowc(lpBuffer);
+ dw = FormatMessageW( dwFlags, lpSource,
+ dwMessageId, dwLanguageId,
+ lpWBuffer, nSize, (va_list*)args );
+ free(lpWBuffer);
+ return dw;
+}
+
+/*---------------- FindFirstFile, FindNextFile ------------------ */
+HANDLE FindFirstFileA(LPCSTR path,
+ WIN32_FIND_DATAA *data)
+{
+ LPWSTR wpath;
+ LPSTR mb;
+ HANDLE h;
+ WIN32_FIND_DATAW wdata;
+
+ wpath = wce_mbtowc(path);
+ h = FindFirstFileW( wpath, &wdata );
+ free(wpath);
+
+ mb = wce_wctomb( wdata.cFileName );
+ strcpy( data->cFileName, mb );
+ free(mb);
+
+ return h;
+}
+
+BOOL FindNextFileA(HANDLE handle,
+ WIN32_FIND_DATAA *data)
+{
+ BOOL b;
+ WIN32_FIND_DATAW wdata;
+ LPSTR mb1;
+
+ b = FindNextFileW(handle, &wdata);
+
+ mb1 = wce_wctomb( wdata.cFileName );
+ strcpy( data->cFileName, mb1 );
+ free(mb1);
+
+ return b;
+}
+
+/* CreateFile doesn't support SECURITY_ATTRIBUTES in WinCE. */
+/* it must be NULL. */
+HANDLE CreateFileA(LPCSTR filename, DWORD access,
+ DWORD sharing, LPSECURITY_ATTRIBUTES sa,
+ DWORD creation, DWORD attributes, HANDLE template)
+{
+ LPWSTR wfilename;
+ HANDLE h;
+
+ wfilename = wce_mbtowc(filename);
+ h = CreateFileW(wfilename, access, sharing,
+ NULL, creation, 0, NULL);
+ free(wfilename);
+
+ return 0;
+}
+
+/* ---------------- CharNext, CharPrev. ---------------------*/
+LPSTR CharNextA(LPCSTR a)
+{
+ char *p=(char *)a;
+ if( TRUE==IsDBCSLeadByteEx(CP_ACP, (BYTE)*a) )
+ p+=2;
+ else
+ p++;
+
+ return p;
+}
+
+LPSTR CharPrevA(LPCSTR start, LPCSTR ptr)
+{
+ if( start==ptr ) return (LPSTR)start;
+ else if( start+1==ptr ) return (LPSTR)start;
+ else if( TRUE==IsDBCSLeadByteEx(CP_ACP, (BYTE)*(ptr-2)) )
+ return (LPSTR)(ptr-2);
+ else
+ return (LPSTR)(ptr-1);
+}
+
+/* WinCE doesn't have "drives". */
+DWORD GetLogicalDrives(VOID)
+{
+ return 0;
+}
+
+/* WinCE doesn't have "user name". */
+BOOL GetUserName(LPSTR lpBuffer, LPDWORD nSize)
+{
+ return 0;
+}
+
+/*------------------- LoadLibrary -----------------------*/
+HINSTANCE LoadLibraryA(LPCSTR libname)
+{
+ HINSTANCE h;
+ LPWSTR wlibname;
+
+ // if starts ".\", replace current directory.
+// wlibname = wce_replaceRelativeDir(libname);
+
+ wlibname = wce_mbtowc(libname);
+ h = LoadLibraryW(wlibname);
+ free(wlibname);
+ return h;
+}
+
+HINSTANCE LoadLibraryExA(LPCSTR lpLibFileName, HANDLE hFile,
+ DWORD dwFlags)
+{
+ HINSTANCE h;
+ LPWSTR wlibname;
+
+ wlibname = wce_mbtowc(lpLibFileName);
+// wlibname = wce_replaceRelativeDir(lpLibFileName);
+
+#if _WIN32_WCE < 300
+ h = LoadLibraryW(wlibname);
+#else
+ h = LoadLibraryExW(wlibname, hFile, dwFlags);
+#endif
+ free(wlibname);
+ return h;
+}
+
+/* WinCE doesn't have "CreatePipe". */
+BOOL CreatePipe(PHANDLE hReadPipe, PHANDLE hWritePipe,
+ LPSECURITY_ATTRIBUTES lpPipeAttributes, DWORD nSize)
+{
+ return FALSE;
+}
+
+/* WinCE doesn't have "Standard Devices". */
+HANDLE GetStdHandle(DWORD nStdHandle)
+{
+ return NULL;
+}
+
+BOOL SetStdHandle(DWORD nStdHandle, HANDLE h)
+{
+ return FALSE;
+}
+
+#if _WIN32_WCE < 300
+VOID ZeroMemory(PVOID p, DWORD length)
+{
+ memset(p,0,length);
+}
+#endif
+
+
+/* need in ruby/io.c. */
+int ReadDataPending()
+{
+ return 0;
+}
+
+/*---------------- helper functions. ---------------------------- */
+FILE *wce_fopen( const char *fname, const char *mode )
+{
+ TCHAR* tfname = wce_replaceRelativeDir(fname);
+ TCHAR* tmode = wce_mbtowc(mode);
+ FILE* fp = _tfopen(tfname, tmode);
+ free(tfname); free(tmode);
+ return fp;
+}
+
+void wce_SetCurrentDir()
+{
+ WCHAR tbuf[MAX_PATH+1]={0};
+ WCHAR *tp;
+ char *buf;
+
+ GetModuleFileNameW( NULL, tbuf, MAX_PATH );
+ tp = _tcsrchr( tbuf, '\\' );
+ if( tp!=NULL ) *tp=_T('\0');
+ buf = wce_wctomb(tbuf);
+ strcpy( _currentdir, buf );
+ free(buf);
+}
+
+TCHAR *wce_replaceRelativeDir(const char* str)
+{
+ TCHAR *tbuf;
+
+ if( 2<=strlen(str) && str[0]=='.' &&
+ (str[1]=='/' || str[1]=='\\') )
+ {
+ char *buf;
+ int len = strlen(str) + strlen(_currentdir);
+ buf = malloc( len+1 );
+ sprintf(buf, "%s%s", _currentdir, &str[1]);
+ tbuf = wce_mbtowc(buf);
+ free(buf);
+ }
+ else
+ tbuf = wce_mbtowc(str);
+ return tbuf;
+}
+
+/* char -> wchar_t */
+wchar_t* wce_mbtowc(const char* a)
+{
+ int length;
+ wchar_t *wbuf;
+
+ length = MultiByteToWideChar(CP_ACP, 0,
+ a, -1, NULL, 0);
+ wbuf = (wchar_t*)malloc( (length+1)*sizeof(wchar_t) );
+ MultiByteToWideChar(CP_ACP, 0,
+ a, -1, wbuf, length);
+
+ return wbuf;
+}
+
+/* wchar_t -> char */
+char* wce_wctomb(const wchar_t* w)
+{
+ DWORD charlength;
+ char* pChar;
+
+ charlength = WideCharToMultiByte(CP_ACP, 0, w,
+ -1, NULL, 0, NULL, NULL);
+ pChar = (char*)malloc(charlength+1);
+ WideCharToMultiByte(CP_ACP, 0, w,
+ -1, pChar, charlength, NULL, NULL);
+
+ return pChar;
+}
diff --git a/ruby_1_8_5/wince/wince.h b/ruby_1_8_5/wince/wince.h
new file mode 100644
index 0000000000..7a562f702a
--- /dev/null
+++ b/ruby_1_8_5/wince/wince.h
@@ -0,0 +1,191 @@
+
+#ifndef _EXT_CE_
+#define _EXT_CE_
+
+/* unique difinition in wince platform. */
+
+#ifndef _MIPS_
+ #define CONTEXT_FLOATING_POINT 0x00000002L
+#endif
+
+/* LockFile difinition. */
+#define LOCKFILE_FAIL_IMMEDIATELY 0x00000001
+#define LOCKFILE_EXCLUSIVE_LOCK 0x00000002
+
+/* Dual Mode difinition. */
+#define STARTF_USESHOWWINDOW 0x00000001
+#define STARTF_USESIZE 0x00000002
+#define STARTF_USEPOSITION 0x00000004
+#define STARTF_USECOUNTCHARS 0x00000008
+#define STARTF_USEFILLATTRIBUTE 0x00000010
+#define STARTF_RUNFULLSCREEN 0x00000020
+#define STARTF_FORCEONFEEDBACK 0x00000040
+#define STARTF_FORCEOFFFEEDBACK 0x00000080
+#define STARTF_USESTDHANDLES 0x00000100
+/* #define STARTF_USEHOTKEY 0x00000200 */
+
+#define STD_INPUT_HANDLE (DWORD)-10
+#define STD_OUTPUT_HANDLE (DWORD)-11
+#define STD_ERROR_HANDLE (DWORD)-12
+
+#define NORMAL_PRIORITY_CLASS 0x00000020
+#define IDLE_PRIORITY_CLASS 0x00000040
+#define HIGH_PRIORITY_CLASS 0x00000080
+#define REALTIME_PRIORITY_CLASS 0x00000100
+
+
+/* WINSOCK.H? */
+#define SO_SYNCHRONOUS_NONALERT 0x20
+
+/* MoveFileEx definition. */
+#define MOVEFILE_REPLACE_EXISTING 0x00000001
+/*
+#define MOVEFILE_COPY_ALLOWED 0x00000002
+#define MOVEFILE_DELAY_UNTIL_REBOOT 0x00000004
+#define MOVEFILE_WRITE_THROUGH 0x00000008
+#define MOVEFILE_CREATE_HARDLINK 0x00000010
+#define MOVEFILE_FAIL_IF_NOT_TRACKABLE 0x00000020
+*/
+
+#define _fgetc fgetc
+#define _fputc fputc
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Win32 API redifinition. */
+
+#undef GetCommandLine
+#define GetCommandLine GetCommandLineA
+
+#undef SetFileAttributes
+#define SetFileAttributes SetFileAttributesA
+
+#undef GetFileAttributes
+#define GetFileAttributes GetFileAttributesA
+
+#undef FormatMessage
+#define FormatMessage FormatMessageA
+
+#undef GetModuleFileName
+#define GetModuleFileName GetModuleFileNameA
+
+#undef CreateFile
+#define CreateFile CreateFileA
+
+#undef MoveFile
+#define MoveFile MoveFileA
+
+#undef DeleteFile
+#define DeleteFile DeleteFileA
+
+#undef CreateProcess
+#define CreateProcess CreateProcessA
+
+#undef CharNext
+#define CharNext CharNextA
+
+#undef CharPrev
+#define CharPrev CharPrevA
+
+#undef WIN32_FIND_DATA
+#define WIN32_FIND_DATA WIN32_FIND_DATAA
+
+#undef FindFirstFile
+#define FindFirstFile FindFirstFileA
+
+#undef FindNextFile
+#define FindNextFile FindNextFileA
+
+/* stdio.c */
+FILE *freopen(const char *filename, const char *mode, FILE *file);
+FILE *fdopen( int handle, const char *mode );
+
+//#define fdopen _fdopen
+
+/* stdlib.c */
+char *getenv(const char *charstuff);
+char *_fullpath(char *absPath, const char *relPath, size_t maxLength);
+
+/* string.c */
+char *strdup(const char * str);
+/* char *strerror(int errno); */
+int strnicmp( const char *s1, const char *s2, size_t count );
+
+//#define strnicmp _strnicmp
+#define stricmp _stricmp
+
+/* for win32.c */
+FARPROC GetProcAddressX(HMODULE hModule, LPCSTR lpProcName);
+
+BOOL MoveFileEx(LPCSTR oldname, LPCSTR newname, DWORD dwFlags);
+BOOL DuplicateHandle(
+ HANDLE source_process, HANDLE source,
+ HANDLE dest_process, HANDLE *dest,
+ DWORD access, BOOL inherit, DWORD options);
+BOOL LockFile(HANDLE hFile,
+ DWORD dwFileOffsetLow, DWORD dwFileOffsetHigh,
+ DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh);
+BOOL LockFileEx(HANDLE hFile,
+ DWORD dwFlags, DWORD dwReserved,
+ DWORD nNumberOfBytesToLockLow, DWORD nNumberOfBytesToLockHigh,
+ LPOVERLAPPED lpOverlapped);
+BOOL UnlockFile( HFILE hFile,
+ DWORD dwFileOffsetLow, DWORD dwFileOffsetHigh,
+ DWORD nNumberOfBytesToUnlockLow, DWORD nNumberOfBytesToUnlockHigh);
+BOOL UnlockFileEx(HANDLE hFile,
+ DWORD dwReserved, DWORD nNumberOfBytesToUnlockLow,
+ DWORD nNumberOfBytesToUnlockHigh, LPOVERLAPPED lpOverlapped);
+BOOL GetUserName(LPSTR lpBuffer, LPDWORD nSize);
+BOOL CreatePipe(PHANDLE hReadPipe, PHANDLE hWritePipe,
+ LPSECURITY_ATTRIBUTES lpPipeAttributes, DWORD nSize);
+HANDLE GetStdHandle(DWORD nStdHandle);
+BOOL SetStdHandle(DWORD nStdHandle, HANDLE h);
+DWORD GetLogicalDrives(VOID);
+DWORD WaitForMultipleObjectsEx(DWORD count,
+ const HANDLE *handles, BOOL wait_all,
+ DWORD timeout, BOOL alertable);
+DWORD GetEnvironmentVariable(LPCSTR name, LPSTR value, DWORD size);
+LPVOID GetEnvironmentStrings(VOID);
+BOOL FreeEnvironmentStrings(LPSTR lpszEnvironmentBlock);
+BOOL GenerateConsoleCtrlEvent(DWORD dwCtrlEvent,
+ DWORD dwProcessGroupID);
+BOOL GetProcessTimes(HANDLE hprocess,
+ LPFILETIME lpCreationTime, LPFILETIME lpExitTime,
+ LPFILETIME lpKernelTime, LPFILETIME lpUserTime);
+
+/* char -> wchar_t, wchar_t -> char */
+wchar_t* wce_mbtowc(const char* a);
+char* wce_wctomb(const wchar_t* w);
+/* other helpers. */
+void wce_SetCommandLine(LPCWSTR wcmd);
+void wce_FreeCommandLine(void);
+TCHAR *wce_replaceRelativeDir(const char* str);
+void wce_SetCurrentDir();
+
+#if _WIN32_WCE < 300
+ /* for Handheld PC Pro. */
+ char *strrchr( const char *p, int c );
+ int stricmp( const char *p1, const char *p2 );
+ VOID ZeroMemory(PVOID p, DWORD length);
+
+ #define isascii(c) ( (c>=0x00&&c<=0x7f)?1:0 )
+ #define isspace(c) ( ((c>=0x09&&c<=0x0d)||c==0x20)?1:0 )
+ #define isdigit(c) ( (c>=0x00&&c<=0x09)?1:0 )
+ #define isupper(c) ( (c>='A'&&c<='Z')?1:0 )
+ #define isalpha(c) ( ((c>='A'&&c<='Z')||(c>='a'&&c<='z'))?1:0 )
+ #define isprint(c) ( (c>=0x20&&c<=0x7e)?1:0 )
+ #define isalnum(c) ( (isalpha(c)||isdigit(c))?1:0 )
+ #define iscntrl(c) ( ((c>=0x00&&c<=0x1f)||c==0x7f)?1:0 )
+ #define islower(c) ( (c>='a'&&c<='z')?1:0 )
+ #define ispunct(c) ( !(isalnum(c)||isspace(c))?1:0 )
+ #define isxdigit(c) ( ((c>=0&&c<=9)||(c>='A'&&c<='F')||(c>='a'&&c<='f'))?1:0 )
+#endif
+
+#ifdef __cplusplus
+};
+#endif
+
+
+#endif /* _EXT_CE_ */
diff --git a/ruby_1_8_5/wince/wincemain.c b/ruby_1_8_5/wince/wincemain.c
new file mode 100644
index 0000000000..fb634a0eea
--- /dev/null
+++ b/ruby_1_8_5/wince/wincemain.c
@@ -0,0 +1,19 @@
+#include <windows.h>
+#include <stdio.h>
+#include "wince.h"
+
+extern int main(int, char**, char**);
+
+
+int WINAPI
+WinMain(HINSTANCE current, HINSTANCE prev, LPWSTR wcmd, int showcmd)
+{
+ /* wchar_t -> char */
+ wce_SetCommandLine(wcmd);
+
+ wce_SetCurrentDir();
+
+ /* main. */
+ return main(0, NULL, NULL);
+}
+
diff --git a/ruby_1_8_5/wince/wincon.h b/ruby_1_8_5/wince/wincon.h
new file mode 100644
index 0000000000..ea50c6ebc6
--- /dev/null
+++ b/ruby_1_8_5/wince/wincon.h
@@ -0,0 +1,7 @@
+
+#ifndef _WINCON_H_
+#define _WINCON_H_
+
+#define CTRL_C_EVENT 0
+
+#endif
diff --git a/ruby_1_8_5/wince/winsock2.c b/ruby_1_8_5/wince/winsock2.c
new file mode 100644
index 0000000000..9b2a5be600
--- /dev/null
+++ b/ruby_1_8_5/wince/winsock2.c
@@ -0,0 +1,338 @@
+/***************************************************************
+ winsock2.c
+***************************************************************/
+
+//#define _WINSOCK2_C_DEBUG_MAIN_
+
+#include <windows.h>
+#include "wince.h"
+#ifdef _WINSOCK2_C_DEBUG_MAIN_
+ #include <winsock.h>
+#endif
+
+#ifndef _WINSOCK2_C_DEBUG_MAIN_
+struct servent{
+ char* s_name; /* official service name */
+ char** s_aliases; /* alias list */
+ short s_port; /* port # */
+ char* s_proto; /* protocol to use */
+};
+struct protoent{
+ char* p_name; /* official protocol name */
+ char** p_aliases; /* alias list */
+ short p_proto; /* protocol # */
+};
+#endif
+
+struct sproto{
+ short num;
+ char name[10];
+};
+struct sserv{
+ short num;
+ char protoname[10];
+ char servname[20];
+};
+
+static struct sproto _proto_table[11]={
+ 0, "ip",
+ 1, "icmp",
+ 3, "ggp",
+ 6, "tcp",
+ 8, "egp",
+ 12, "pup",
+ 17, "udp",
+ 20, "hmp",
+ 22, "xns-idp",
+ 27, "rdp",
+ 66, "rvd",
+};
+
+static struct sserv _serv_table[142]={
+ 7, "tcp", "echo",
+ 7, "udp", "echo",
+ 9, "tcp", "discard",
+ 9, "udp", "discard",
+ 11, "tcp", "systat",
+ 11, "udp", "systat",
+ 13, "tcp", "daytime",
+ 13, "udp", "daytime",
+ 15, "tcp", "netstat",
+ 17, "tcp", "qotd",
+ 17, "udp", "qotd",
+ 19, "tcp", "chargen",
+ 19, "udp", "chargen",
+ 20, "tcp", "ftp-data",
+ 21, "tcp", "ftp",
+ 23, "tcp", "telnet",
+ 25, "tcp", "smtp",
+ 37, "tcp", "time",
+ 37, "udp", "time",
+ 39, "udp", "rlp",
+ 42, "tcp", "name",
+ 42, "udp", "name",
+ 43, "tcp", "whois",
+ 53, "tcp", "domain",
+ 53, "udp", "domain",
+ 53, "tcp", "nameserver",
+ 53, "udp", "nameserver",
+ 57, "tcp", "mtp",
+ 67, "udp", "bootp",
+ 69, "udp", "tftp",
+ 77, "tcp", "rje",
+ 79, "tcp", "finger",
+ 87, "tcp", "link",
+ 95, "tcp", "supdup",
+ 101, "tcp", "hostnames",
+ 102, "tcp", "iso-tsap",
+ 103, "tcp", "dictionary",
+ 103, "tcp", "x400",
+ 104, "tcp", "x400-snd",
+ 105, "tcp", "csnet-ns",
+ 109, "tcp", "pop",
+ 109, "tcp", "pop2",
+ 110, "tcp", "pop3",
+ 111, "tcp", "portmap",
+ 111, "udp", "portmap",
+ 111, "tcp", "sunrpc",
+ 111, "udp", "sunrpc",
+ 113, "tcp", "auth",
+ 115, "tcp", "sftp",
+ 117, "tcp", "path",
+ 117, "tcp", "uucp-path",
+ 119, "tcp", "nntp",
+ 123, "udp", "ntp",
+ 137, "udp", "nbname",
+ 138, "udp", "nbdatagram",
+ 139, "tcp", "nbsession",
+ 144, "tcp", "NeWS",
+ 153, "tcp", "sgmp",
+ 158, "tcp", "tcprepo",
+ 161, "tcp", "snmp",
+ 162, "tcp", "snmp-trap",
+ 170, "tcp", "print-srv",
+ 175, "tcp", "vmnet",
+ 315, "udp", "load",
+ 400, "tcp", "vmnet0",
+ 500, "udp", "sytek",
+ 512, "udp", "biff",
+ 512, "tcp", "exec",
+ 513, "tcp", "login",
+ 513, "udp", "who",
+ 514, "tcp", "shell",
+ 514, "udp", "syslog",
+ 515, "tcp", "printer",
+ 517, "udp", "talk",
+ 518, "udp", "ntalk",
+ 520, "tcp", "efs",
+ 520, "udp", "route",
+ 525, "udp", "timed",
+ 526, "tcp", "tempo",
+ 530, "tcp", "courier",
+ 531, "tcp", "conference",
+ 531, "udp", "rvd-control",
+ 532, "tcp", "netnews",
+ 533, "udp", "netwall",
+ 540, "tcp", "uucp",
+ 543, "tcp", "klogin",
+ 544, "tcp", "kshell",
+ 550, "udp", "new-rwho",
+ 556, "tcp", "remotefs",
+ 560, "udp", "rmonitor",
+ 561, "udp", "monitor",
+ 600, "tcp", "garcon",
+ 601, "tcp", "maitrd",
+ 602, "tcp", "busboy",
+ 700, "udp", "acctmaster",
+ 701, "udp", "acctslave",
+ 702, "udp", "acct",
+ 703, "udp", "acctlogin",
+ 704, "udp", "acctprinter",
+ 704, "udp", "elcsd",
+ 705, "udp", "acctinfo",
+ 706, "udp", "acctslave2",
+ 707, "udp", "acctdisk",
+ 750, "tcp", "kerberos",
+ 750, "udp", "kerberos",
+ 751, "tcp", "kerberos_master",
+ 751, "udp", "kerberos_master",
+ 752, "udp", "passwd_server",
+ 753, "udp", "userreg_server",
+ 754, "tcp", "krb_prop",
+ 888, "tcp", "erlogin",
+ 1109, "tcp", "kpop",
+ 1167, "udp", "phone",
+ 1524, "tcp", "ingreslock",
+ 1666, "udp", "maze",
+ 2049, "udp", "nfs",
+ 2053, "tcp", "knetd",
+ 2105, "tcp", "eklogin",
+ 5555, "tcp", "rmt",
+ 5556, "tcp", "mtb",
+ 9535, "tcp", "man",
+ 9536, "tcp", "w",
+ 9537, "tcp", "mantst",
+ 10000, "tcp", "bnews",
+ 10000, "udp", "rscs0",
+ 10001, "tcp", "queue",
+ 10001, "udp", "rscs1",
+ 10002, "tcp", "poker",
+ 10002, "udp", "rscs2",
+ 10003, "tcp", "gateway",
+ 10003, "udp", "rscs3",
+ 10004, "tcp", "remp",
+ 10004, "udp", "rscs4",
+ 10005, "udp", "rscs5",
+ 10006, "udp", "rscs6",
+ 10007, "udp", "rscs7",
+ 10008, "udp", "rscs8",
+ 10009, "udp", "rscs9",
+ 10010, "udp", "rscsa",
+ 10011, "udp", "rscsb",
+ 10012, "tcp", "qmaster",
+ 10012, "udp", "qmaster",
+};
+
+/* WinCE doesn't have /etc/protocols. */
+struct protoent* getprotobyname(const char* name)
+{
+ static struct protoent pe;
+ int i;
+ int len = strlen(name);
+
+ memset( &pe, 0, sizeof(struct protoent) );
+
+ for(i=0; i<9; i++)
+ {
+ if( 0==strnicmp(_proto_table[i].name, name, len) )
+ {
+ pe.p_name = _proto_table[i].name;
+ pe.p_proto= _proto_table[i].num;
+ break;
+ }
+ }
+
+ return &pe;
+}
+
+struct protoent* getprotobynumber(int proto)
+{
+ static struct protoent pe={0};
+ int i;
+
+ memset( &pe, 0, sizeof(struct protoent) );
+
+ for(i=0; i<9; i++)
+ {
+ if( proto == _proto_table[i].num )
+ {
+ pe.p_name = _proto_table[i].name;
+ pe.p_proto= _proto_table[i].num;
+ break;
+ }
+ }
+
+ return &pe;
+}
+
+/* WinCE doesn't have /etc/services. */
+struct servent* getservbyname(const char* name,
+ const char* proto)
+{
+ static struct servent se;
+ int i;
+ int slen = strlen(name), plen = strlen(proto);
+
+ memset( &se, 0, sizeof(struct servent) );
+
+ if( proto==NULL ) return NULL;
+ if( 0!=strnicmp( proto, "tcp", 3 ) &&
+ 0!=strnicmp( proto, "udp", 3 ) )
+ return NULL;
+
+ for( i=0; i<142; i++ )
+ {
+ if( 0==strnicmp( name, _serv_table[i].servname, slen ) &&
+ 0==strnicmp( proto, _serv_table[i].protoname, plen ) )
+ {
+ char hc, lc;
+ se.s_name = _serv_table[i].servname;
+ se.s_proto= _serv_table[i].protoname;
+ hc = (_serv_table[i].num&0xFF00)>>8;
+ lc = _serv_table[i].num&0xFF;
+ se.s_port = (lc<<8) + hc;
+ break;
+ }
+ }
+
+ return &se;
+}
+
+struct servent* getservbyport(int port, const char* proto)
+{
+ static struct servent se;
+ int i;
+ int plen = strlen(proto);
+ short sport;
+ char lc, hc;
+
+ hc = (port&0xFF00)>>8;
+ lc = port&0xFF;
+
+ sport = (lc<<8) + hc;
+
+ memset( &se, 0, sizeof(struct servent) );
+
+ if( proto==NULL ) return NULL;
+ if( 0!=strnicmp( proto, "tcp", 3 ) &&
+ 0!=strnicmp( proto, "udp", 3 ) )
+ return NULL;
+
+ for( i=0; i<142; i++ )
+ {
+ if( sport == _serv_table[i].num &&
+ 0==strnicmp( proto, _serv_table[i].protoname, plen ) )
+ {
+ se.s_name = _serv_table[i].servname;
+ se.s_proto= _serv_table[i].protoname;
+ se.s_port = port;
+ break;
+ }
+ }
+
+ return &se;
+}
+
+
+#ifdef _WINSOCK2_C_DEBUG_MAIN_
+
+int main()
+{
+ WORD wVersionRequested = MAKEWORD(1,1);
+ WSADATA wsaData;
+ int nErrorStatus;
+ struct protoent pe1, pe2;
+ struct servent se1, se2;
+
+ nErrorStatus = WSAStartup(wVersionRequested, &wsaData);
+ if(nErrorStatus != 0)
+ return -1;
+
+ pe1 = *getprotobyname("UDP");
+ pe2 = *_getprotobyname("UDP");
+
+// pe1 = *getprotobynumber(17);
+// pe2 = *_getprotobynumber(17);
+
+// se1 = *getservbyname("gateway", "tcp");
+// se2 = *_getservbyname("gateway", "tcp");
+
+ se1 = *getservbyport(0x1327, "tcp");
+ se2 = *_getservbyport(0x1327, "tcp");
+
+ WSACleanup();
+
+ return 0;
+}
+
+#endif