mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* dln.c: Ruby no longer supports Windows CE.
* eval.c: ditto. * include/ruby/defines.h: ditto. * include/ruby/win32.h: ditto. * ruby.c: ditto. * strftime.c: ditto. * win32/Makefile.sub: ditto. * win32/win32.c: ditto. * ext/tk/extconf.rb: ditto. * lib/fileutils.rb: ditto. * test/fileutils/test_fileutils.rb: ditto. * wince/*: removed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19681 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
642e081879
commit
a8c3540b32
48 changed files with 38 additions and 3388 deletions
26
ChangeLog
26
ChangeLog
|
@ -1,3 +1,29 @@
|
|||
Sat Oct 4 22:44:23 2008 Yuki Sonoda (Yugui) <yugui@yugui.jp>
|
||||
|
||||
* dln.c: Ruby no longer supports Windows CE.
|
||||
|
||||
* eval.c: ditto.
|
||||
|
||||
* include/ruby/defines.h: ditto.
|
||||
|
||||
* include/ruby/win32.h: ditto.
|
||||
|
||||
* ruby.c: ditto.
|
||||
|
||||
* strftime.c: ditto.
|
||||
|
||||
* win32/Makefile.sub: ditto.
|
||||
|
||||
* win32/win32.c: ditto.
|
||||
|
||||
* ext/tk/extconf.rb: ditto.
|
||||
|
||||
* lib/fileutils.rb: ditto.
|
||||
|
||||
* test/fileutils/test_fileutils.rb: ditto.
|
||||
|
||||
* wince/*: removed.
|
||||
|
||||
Sat Oct 4 22:35:06 2008 Yuki Sonoda (Yugui) <yugui@yugui.jp>
|
||||
|
||||
* dln.c: Ruby no longer supports MacOS 9 or before.
|
||||
|
|
9
dln.c
9
dln.c
|
@ -1105,15 +1105,6 @@ dln_sym(const char *name)
|
|||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
#undef FormatMessage
|
||||
#define FormatMessage FormatMessageA
|
||||
#undef LoadLibrary
|
||||
#define LoadLibrary LoadLibraryA
|
||||
#undef GetProcAddress
|
||||
#define GetProcAddress GetProcAddressA
|
||||
#endif
|
||||
|
||||
static const char *
|
||||
dln_strerror(void)
|
||||
{
|
||||
|
|
2
eval.c
2
eval.c
|
@ -31,8 +31,6 @@ VALUE rb_eSysStackError;
|
|||
|
||||
#if defined(__APPLE__)
|
||||
#define environ (*_NSGetEnviron())
|
||||
#elif !defined(_WIN32) && defined(_WIN32_WCE)
|
||||
extern char **environ;
|
||||
#endif
|
||||
char **rb_origenviron;
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require 'mkmf'
|
||||
|
||||
is_win32 = (/mswin|mingw|cygwin|bccwin|wince/ =~ RUBY_PLATFORM)
|
||||
is_win32 = (/mswin|mingw|cygwin|bccwin/ =~ RUBY_PLATFORM)
|
||||
#is_macosx = (/darwin/ =~ RUBY_PLATFORM)
|
||||
|
||||
have_func("ruby_native_thread_p", "ruby.h")
|
||||
|
|
|
@ -105,10 +105,8 @@ void xfree(void*);
|
|||
|
||||
#if defined(_WIN32) || defined(__EMX__)
|
||||
#define DOSISH 1
|
||||
#ifndef _WIN32_WCE
|
||||
# define DOSISH_DRIVE_LETTER
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__NeXT__) || defined(__APPLE__)
|
||||
/* Do not trust WORDS_BIGENDIAN from configure since -arch compiler flag may
|
||||
|
|
|
@ -33,11 +33,6 @@ extern "C" {
|
|||
|
||||
#define NT 1 /* deprecated */
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
#undef CharNext
|
||||
#define CharNext CharNextA
|
||||
#endif
|
||||
|
||||
//
|
||||
// We're not using Microsoft's "extensions" to C for
|
||||
// Structured Exception Handling (SEH) so we can nuke these
|
||||
|
@ -164,7 +159,7 @@ extern DWORD rb_w32_osid(void);
|
|||
|
||||
#undef execv
|
||||
#define execv(path,argv) rb_w32_aspawn(P_OVERLAY,path,argv)
|
||||
#if !defined(__BORLANDC__) && !defined(_WIN32_WCE)
|
||||
#if !defined(__BORLANDC__)
|
||||
#undef isatty
|
||||
#define isatty(h) rb_w32_isatty(h)
|
||||
#endif
|
||||
|
@ -265,7 +260,7 @@ extern int kill(int, int);
|
|||
extern int fcntl(int, int, ...);
|
||||
extern rb_pid_t rb_w32_getpid(void);
|
||||
extern rb_pid_t rb_w32_getppid(void);
|
||||
#if !defined(__BORLANDC__) && !defined(_WIN32_WCE)
|
||||
#if !defined(__BORLANDC__)
|
||||
extern int rb_w32_isatty(int);
|
||||
#endif
|
||||
extern int rb_w32_mkdir(const char *, int);
|
||||
|
|
|
@ -524,7 +524,7 @@ module FileUtils
|
|||
OPT_TABLE['move'] = [:force, :noop, :verbose, :secure]
|
||||
|
||||
def rename_cannot_overwrite_file? #:nodoc:
|
||||
/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM
|
||||
/cygwin|mswin|mingw|bccwin|emx/ =~ RUBY_PLATFORM
|
||||
end
|
||||
private_module_function :rename_cannot_overwrite_file?
|
||||
|
||||
|
@ -1041,7 +1041,7 @@ module FileUtils
|
|||
private
|
||||
|
||||
def fu_windows?
|
||||
/mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM
|
||||
/mswin|mingw|bccwin|emx/ =~ RUBY_PLATFORM
|
||||
end
|
||||
|
||||
def fu_copy_stream0(src, dest, blksize = nil) #:nodoc:
|
||||
|
|
4
ruby.c
4
ruby.c
|
@ -15,10 +15,6 @@
|
|||
#include <windows.h>
|
||||
#include <sys/cygwin.h>
|
||||
#endif
|
||||
#ifdef _WIN32_WCE
|
||||
#include <winsock.h>
|
||||
#include "ruby/wince.h"
|
||||
#endif
|
||||
#include "ruby/ruby.h"
|
||||
#include "ruby/encoding.h"
|
||||
#include "eval_intern.h"
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#endif
|
||||
#if defined(TM_IN_SYS_TIME) || !defined(GAWK) && !defined(_WIN32_WCE)
|
||||
#if defined(TM_IN_SYS_TIME) || !defined(GAWK)
|
||||
#include <sys/types.h>
|
||||
#if HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
|
|
|
@ -20,7 +20,7 @@ def have_drive_letter?
|
|||
end
|
||||
|
||||
def have_file_perm?
|
||||
/mswin|mingw|bcc|wince|emx/ !~ RUBY_PLATFORM
|
||||
/mswin|mingw|bcc|emx/ !~ RUBY_PLATFORM
|
||||
end
|
||||
|
||||
$fileutils_rb_have_symlink = nil
|
||||
|
|
|
@ -373,9 +373,7 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/win32/Makefile.sub $(win_srcdir)/Makefile.sub
|
|||
#define FUNC_FASTCALL(x) __fastcall x
|
||||
#define RUBY_EXTERN extern __declspec(dllimport)
|
||||
#define HAVE_DECL_SYS_NERR 1
|
||||
!if !defined(WIN32_WCE)
|
||||
#define HAVE_LIMITS_H 1
|
||||
!endif
|
||||
#define HAVE_FCNTL_H 1
|
||||
#define HAVE_SYS_UTIME_H 1
|
||||
#define HAVE_FLOAT_H 1
|
||||
|
@ -409,9 +407,7 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/win32/Makefile.sub $(win_srcdir)/Makefile.sub
|
|||
!endif
|
||||
#define GETGROUPS_T int
|
||||
#define RETSIGTYPE void
|
||||
!if !defined(WIN32_WCE)
|
||||
#define HAVE_ALLOCA 1
|
||||
!endif
|
||||
#define HAVE_DUP2 1
|
||||
#define HAVE_MEMCMP 1
|
||||
#define HAVE_MEMMOVE 1
|
||||
|
@ -444,9 +440,7 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/win32/Makefile.sub $(win_srcdir)/Makefile.sub
|
|||
#define HAVE_TIMES 1
|
||||
#define HAVE_FCNTL 1
|
||||
#define HAVE_LINK 1
|
||||
!if !defined(WIN32_WCE)
|
||||
#define HAVE__SETJMP 1
|
||||
!endif
|
||||
#define HAVE_TELLDIR 1
|
||||
#define HAVE_SEEKDIR 1
|
||||
#define HAVE_MKTIME 1
|
||||
|
@ -484,29 +478,6 @@ $(BANG)if "$(RUBY_SO_NAME)"!="$$(RUBY_SO_NAME)" || "$(ARCH)-$(PLATFORM)"!="$$(AR
|
|||
config.h: nul
|
||||
$(BANG)endif
|
||||
#endif
|
||||
!if defined(WIN32_WCE)
|
||||
#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
|
||||
!endif
|
||||
<<
|
||||
@exit > $(@:/=\)
|
||||
|
||||
|
@ -529,9 +500,6 @@ config.status: $(MKFILES) $(srcdir)/win32/Makefile.sub $(win_srcdir)/Makefile.su
|
|||
@exit <<$@
|
||||
# Generated automatically by Makefile.sub.
|
||||
s,@SHELL@,$$(COMSPEC),;t t
|
||||
!if defined(WIN32_WCE)
|
||||
s,@MAIN_DOES_NOTHING@,int WinMain(HINSTANCE h, HINSTANCE hp, LPWSTR s, int n) {return 0;},;t t
|
||||
!endif
|
||||
s,@BUILD_FILE_SEPARATOR@,\,;t t
|
||||
s,@PATH_SEPARATOR@,;,;t t
|
||||
s,@CFLAGS@,$(CFLAGS),;t t
|
||||
|
@ -733,9 +701,6 @@ $(RUBY_INSTALL_NAME).rc $(RUBYW_INSTALL_NAME).rc $(RUBY_SO_NAME).rc: $(RBCONFIG)
|
|||
-ruby_name=$(RUBY_INSTALL_NAME) \
|
||||
-rubyw_name=$(RUBYW_INSTALL_NAME) \
|
||||
-so_name=$(RUBY_SO_NAME) \
|
||||
!if defined(WIN32_WCE)
|
||||
-wce_ver=$(SUBSYSVERSION) \
|
||||
!endif
|
||||
. $(icondirs) $(win_srcdir)
|
||||
|
||||
fake.rb: $(MKFILES)
|
||||
|
|
|
@ -33,9 +33,6 @@
|
|||
#endif
|
||||
#include "ruby/win32.h"
|
||||
#include "win32/dir.h"
|
||||
#ifdef _WIN32_WCE
|
||||
#include "wince.h"
|
||||
#endif
|
||||
#ifndef index
|
||||
#define index(x, y) strchr((x), (y))
|
||||
#endif
|
||||
|
@ -46,7 +43,7 @@
|
|||
#undef close
|
||||
#undef setsockopt
|
||||
|
||||
#if defined __BORLANDC__ || defined _WIN32_WCE
|
||||
#if defined __BORLANDC__
|
||||
# define _filbuf _fgetc
|
||||
# define _flsbuf _fputc
|
||||
# define enough_to_get(n) (--(n) >= 0)
|
||||
|
@ -67,11 +64,7 @@
|
|||
static struct ChildRecord *CreateChild(const char *, const char *, SECURITY_ATTRIBUTES *, HANDLE, HANDLE, HANDLE);
|
||||
static int has_redirection(const char *);
|
||||
int rb_w32_wait_events(HANDLE *events, int num, DWORD timeout);
|
||||
#if !defined(_WIN32_WCE)
|
||||
static int rb_w32_open_osfhandle(intptr_t osfhandle, int flags);
|
||||
#else
|
||||
#define rb_w32_open_osfhandle(osfhandle, flags) _open_osfhandle(osfhandle, flags)
|
||||
#endif
|
||||
|
||||
#define RUBY_CRITICAL(expr) do { expr; } while (0)
|
||||
|
||||
|
@ -508,11 +501,6 @@ rb_w32_sysinit(int *argc, char ***argv)
|
|||
|
||||
// Initialize Winsock
|
||||
StartSockets();
|
||||
|
||||
#ifdef _WIN32_WCE
|
||||
// free commandline buffer
|
||||
wce_FreeCommandLine();
|
||||
#endif
|
||||
}
|
||||
|
||||
char *
|
||||
|
@ -1698,7 +1686,7 @@ typedef struct {
|
|||
#define _CRTIMP __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#if !defined(__BORLANDC__) && !defined(_WIN32_WCE)
|
||||
#if !defined(__BORLANDC__)
|
||||
EXTERN_C _CRTIMP ioinfo * __pioinfo[];
|
||||
|
||||
#define IOINFO_L2E 5
|
||||
|
@ -3759,7 +3747,7 @@ catch_interrupt(void)
|
|||
RUBY_CRITICAL(rb_w32_wait_events(NULL, 0, 0));
|
||||
}
|
||||
|
||||
#if defined __BORLANDC__ || defined _WIN32_WCE
|
||||
#if defined __BORLANDC__
|
||||
#undef read
|
||||
int
|
||||
read(int fd, void *buf, size_t size)
|
||||
|
@ -3779,15 +3767,13 @@ int
|
|||
rb_w32_getc(FILE* stream)
|
||||
{
|
||||
int c;
|
||||
#ifndef _WIN32_WCE
|
||||
if (enough_to_get(stream->FILE_COUNT)) {
|
||||
c = (unsigned char)*stream->FILE_READPTR++;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
c = _filbuf(stream);
|
||||
#if defined __BORLANDC__ || defined _WIN32_WCE
|
||||
#if defined __BORLANDC__
|
||||
if ((c == EOF) && (errno == EPIPE)) {
|
||||
clearerr(stream);
|
||||
}
|
||||
|
@ -3801,12 +3787,10 @@ rb_w32_getc(FILE* stream)
|
|||
int
|
||||
rb_w32_putc(int c, FILE* stream)
|
||||
{
|
||||
#ifndef _WIN32_WCE
|
||||
if (enough_to_put(stream->FILE_COUNT)) {
|
||||
c = (unsigned char)(*stream->FILE_READPTR++ = (char)c);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
c = _flsbuf(c, stream);
|
||||
catch_interrupt();
|
||||
|
@ -4673,7 +4657,7 @@ rb_w32_unlink(const char *path)
|
|||
return ret;
|
||||
}
|
||||
|
||||
#if !defined(__BORLANDC__) && !defined(_WIN32_WCE)
|
||||
#if !defined(__BORLANDC__)
|
||||
int
|
||||
rb_w32_isatty(int fd)
|
||||
{
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
# -*- makefile -*-
|
||||
|
||||
CROSS_COMPILING = 1
|
||||
LARGEFILE_SUPPORT = 0
|
||||
|
||||
!ifndef win_srcdir
|
||||
win_srcdir = $(srcdir)/wince
|
||||
!endif
|
||||
|
||||
!if !defined(OS) || !defined(RT)
|
||||
OS = mswince
|
||||
RT = $(OS)
|
||||
!endif
|
||||
|
||||
!if !defined(WARNFLAGS)
|
||||
WARNFLAGS = -w
|
||||
!endif
|
||||
ARCHDEFS = $(CECPUDEF) -DUNDER_CE -D_WIN32_WCE=$(SUBSYSVERSION:.=) \
|
||||
-DFILENAME_MAX=MAX_PATH -DTLS_OUT_OF_INDEXES=0xFFFFFFFF \
|
||||
-DBUFSIZ=512 -D_UNICODE -DUNICODE
|
||||
!if !defined(LDFLAGS)
|
||||
LDFLAGS = -link -incremental:yes -pdb:none -machine:$(MACHINE) -subsystem:$(SUBSYSTEM)
|
||||
!endif
|
||||
!if !defined(XLDFLAGS)
|
||||
XLDFLAGS = -stack:$(STACK) -subsystem:$(SUBSYSTEM)
|
||||
!endif
|
||||
LIBS = coredll.lib ceshell.lib winsock.lib $(EXTLIBS)
|
||||
MISSING = acosh.obj cbrt.obj crypt.obj dup2.obj erf.obj hypot.obj \
|
||||
isinf.obj isnan.obj lgamma.obj strftime.obj strlcat.obj strlcpy.obj
|
||||
tgamma.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
|
||||
LIBOBJS = isinf.obj isnan.obj
|
||||
COMMON_LIBS = coredll winsock
|
||||
COMMON_MACROS = WIN32_LEAN_AND_MEAN
|
||||
COMMON_HEADERS = winsock.h windows.h
|
||||
|
||||
XCFLAGS = -I$(srcdir)/wince
|
||||
|
||||
!if !defined(STACK_COMMIT)
|
||||
STACK_COMMIT = 0x10000
|
||||
!endif
|
||||
WINMAINOBJ = wincemain.$(OBJEXT)
|
||||
|
||||
!include $(srcdir)/win32/Makefile.sub
|
|
@ -1,122 +0,0 @@
|
|||
=begin
|
||||
|
||||
= How to build ruby using eMbedded Visual C++
|
||||
|
||||
== Requirement
|
||||
|
||||
(1) eMbedded Visual C++ 3.0 or later.
|
||||
|
||||
(2) ruby executable on the compiling host environment.
|
||||
|
||||
(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%))'
|
||||
You can also specify the install directory.
|
||||
For example, run `((%configure --prefix=<install_directory>%))'
|
||||
Default of the install directory is /usr .
|
||||
|
||||
(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 --prefix=/usr/local
|
||||
nmake
|
||||
nmake 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 --prefix=/usr/local
|
||||
nmake
|
||||
nmake 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 --prefix=C:/usr/local
|
||||
nmake
|
||||
nmake 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
|
|
@ -1,11 +0,0 @@
|
|||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include "assert.h"
|
||||
|
||||
|
||||
void assert( int expression )
|
||||
{
|
||||
if( expression==0 )
|
||||
exit(2);
|
||||
}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
#ifndef _ASSERT_H_
|
||||
#define _ASSERT_H_
|
||||
|
||||
void assert( int expression );
|
||||
|
||||
#endif
|
|
@ -1,109 +0,0 @@
|
|||
@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" == "--with-baseruby" goto :baseruby
|
||||
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
|
||||
:baseruby
|
||||
echo>> ~tmp~.mak "BASERUBY=%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 []
|
||||
echo System types:
|
||||
echo --target=TARGET configure for TARGET [i386-mswin32]
|
||||
echo Optional Package:
|
||||
echo --with-baseruby=RUBY use RUBY as baseruby [ruby]
|
||||
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
|
|
@ -1,54 +0,0 @@
|
|||
/***************************************************************
|
||||
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;
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
#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
|
|
@ -1,11 +0,0 @@
|
|||
/***************************************************************
|
||||
errno.c
|
||||
***************************************************************/
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
|
||||
int errno;
|
||||
int _doserrno;
|
||||
int _sys_nerr;
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
#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
|
|
@ -1,42 +0,0 @@
|
|||
|
||||
#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
|
76
wince/io.h
76
wince/io.h
|
@ -1,76 +0,0 @@
|
|||
|
||||
#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
|
||||
|
230
wince/io_wce.c
230
wince/io_wce.c
|
@ -1,230 +0,0 @@
|
|||
/***************************************************************
|
||||
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;
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
#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
|
|
@ -1,47 +0,0 @@
|
|||
/***************************************************************
|
||||
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;
|
||||
}
|
||||
|
254
wince/setup.mak
254
wince/setup.mak
|
@ -1,254 +0,0 @@
|
|||
# -*- 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
|
||||
!if defined(BASERUBY)
|
||||
BASERUBY = $(BASERUBY)
|
||||
!endif
|
||||
<<
|
||||
@$(CPP) -I$(srcdir) <<"Creating $(MAKEFILE)" >> $(MAKEFILE)
|
||||
#define RUBY_REVISION 0
|
||||
#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-: -encs-
|
||||
|
||||
-encs-: nul
|
||||
@$(MAKE) -l -f $(srcdir)/win32/enc-setup.mak srcdir="$(srcdir)" MAKEFILE=$(MAKEFILE)
|
||||
|
||||
-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).
|
|
@ -1,71 +0,0 @@
|
|||
#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
|
|
@ -1,26 +0,0 @@
|
|||
/***************************************************************
|
||||
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
|
|
@ -1,5 +0,0 @@
|
|||
|
||||
#ifndef _STDDEF_H_
|
||||
#define _STDDEF_H_
|
||||
|
||||
#endif
|
|
@ -1,36 +0,0 @@
|
|||
/***************************************************************
|
||||
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;
|
||||
}
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
/***************************************************************
|
||||
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;
|
||||
}
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
/***************************************************************
|
||||
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
|
102
wince/sys/stat.c
102
wince/sys/stat.c
|
@ -1,102 +0,0 @@
|
|||
/***************************************************************
|
||||
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;
|
||||
}
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
#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
|
|
@ -1,25 +0,0 @@
|
|||
/***************************************************************
|
||||
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;
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
#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
|
|
@ -1,60 +0,0 @@
|
|||
#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
|
|
@ -1,44 +0,0 @@
|
|||
/***************************************************************
|
||||
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;
|
||||
}
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
#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
|
63
wince/time.h
63
wince/time.h
|
@ -1,63 +0,0 @@
|
|||
#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
|
301
wince/time_wce.c
301
wince/time_wce.c
|
@ -1,301 +0,0 @@
|
|||
/***************************************************************
|
||||
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
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
|
||||
#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
|
583
wince/wince.c
583
wince/wince.c
|
@ -1,583 +0,0 @@
|
|||
/***************************************************************
|
||||
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;
|
||||
}
|
191
wince/wince.h
191
wince/wince.h
|
@ -1,191 +0,0 @@
|
|||
|
||||
#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_ */
|
|
@ -1,18 +0,0 @@
|
|||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include "wince.h"
|
||||
|
||||
extern int main(int, 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);
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
|
||||
#ifndef _WINCON_H_
|
||||
#define _WINCON_H_
|
||||
|
||||
#define CTRL_C_EVENT 0
|
||||
|
||||
#endif
|
338
wince/winsock2.c
338
wince/winsock2.c
|
@ -1,338 +0,0 @@
|
|||
/***************************************************************
|
||||
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
|
Loading…
Reference in a new issue