win32-api 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +10 -0
- data/ext/Makefile +181 -0
- data/ext/api-i386-mswin32.def +2 -0
- data/ext/api-i386-mswin32.exp +0 -0
- data/ext/api-i386-mswin32.lib +0 -0
- data/ext/api-i386-mswin32.pdb +0 -0
- data/ext/api.obj +0 -0
- data/ext/extconf.rb +2 -1
- data/ext/mkmf.log +28 -0
- data/ext/vc60.pdb +0 -0
- data/ext/win32/api.c +23 -13
- data/ext/win32/api.so +0 -0
- data/test/tc_win32_api.rb +6 -1
- metadata +12 -3
data/CHANGES
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
= 1.0.6 - 18-Apr-2008
|
2
|
+
* Added the effective_function_name method. This allows you to see what the
|
3
|
+
actual function name is that was defined, e.g. GetUserNameA vs GetUserNameW.
|
4
|
+
* Replaced an instance of _tcscmp with strcmp. The case in question was always
|
5
|
+
going to be ASCII.
|
6
|
+
* Cleaned up some -W3 warnings.
|
7
|
+
* Added the build_manifest task to the Rakefile, which is automatically run if
|
8
|
+
you're using a version of Ruby built with VC++ 8 or later. This builds a
|
9
|
+
ruby.exe.manifest file (if it doesn't already exist).
|
10
|
+
|
1
11
|
= 1.0.5 - 20-Nov-2007
|
2
12
|
* The API.new method now defaults to "W" (wide character functions) before "A"
|
3
13
|
(ANSI functions) if the $KCODE global variable is set to 'u' (UTF8).
|
data/ext/Makefile
ADDED
@@ -0,0 +1,181 @@
|
|
1
|
+
|
2
|
+
SHELL = /bin/sh
|
3
|
+
|
4
|
+
#### Start of system configuration section. ####
|
5
|
+
|
6
|
+
srcdir = win32
|
7
|
+
topdir = C:/ruby/lib/ruby/1.8/i386-mswin32
|
8
|
+
hdrdir = $(topdir)
|
9
|
+
VPATH = $(srcdir);$(topdir);$(hdrdir)
|
10
|
+
|
11
|
+
DESTDIR = C:
|
12
|
+
prefix = $(DESTDIR)/ruby
|
13
|
+
exec_prefix = $(DESTDIR)/ruby
|
14
|
+
sitedir = $(prefix)/lib/ruby/site_ruby
|
15
|
+
rubylibdir = $(libdir)/ruby/$(ruby_version)
|
16
|
+
top_srcdir = $(DESTDIR)/develop/win/ruby/ruby-1.8.5
|
17
|
+
archdir = $(rubylibdir)/$(arch)
|
18
|
+
sbindir = $(exec_prefix)/sbin
|
19
|
+
datadir = $(prefix)/share
|
20
|
+
includedir = $(prefix)/include
|
21
|
+
infodir = $(prefix)/info
|
22
|
+
sysconfdir = $(prefix)/etc
|
23
|
+
mandir = $(prefix)/man
|
24
|
+
libdir = $(DESTDIR)/ruby/lib
|
25
|
+
sharedstatedir = $(DESTDIR)/etc
|
26
|
+
oldincludedir = $(DESTDIR)/usr/include
|
27
|
+
sitearchdir = $(sitelibdir)/$(sitearch)
|
28
|
+
localstatedir = $(DESTDIR)/var
|
29
|
+
bindir = $(exec_prefix)/bin
|
30
|
+
sitelibdir = $(sitedir)/$(ruby_version)
|
31
|
+
libexecdir = $(exec_prefix)/libexec
|
32
|
+
|
33
|
+
CC = cl -nologo
|
34
|
+
LIBRUBY = $(RUBY_SO_NAME).lib
|
35
|
+
LIBRUBY_A = msvcrt-ruby18-static.lib
|
36
|
+
LIBRUBYARG_SHARED = $(LIBRUBY)
|
37
|
+
LIBRUBYARG_STATIC = $(LIBRUBY_A)
|
38
|
+
|
39
|
+
RUBY_EXTCONF_H =
|
40
|
+
CFLAGS = -MD -Zi -O2b2xg- -G6
|
41
|
+
INCFLAGS = -I. -I. -IC:/ruby/lib/ruby/1.8/i386-mswin32 -I.
|
42
|
+
CPPFLAGS =
|
43
|
+
CXXFLAGS = $(CFLAGS)
|
44
|
+
DLDFLAGS = -link -incremental:no -debug -opt:ref -opt:icf -dll $(LIBPATH) -def:$(DEFFILE) -implib:$(*F:.so=)-$(arch).lib -pdb:$(*F:.so=)-$(arch).pdb
|
45
|
+
LDSHARED = cl -nologo -LD
|
46
|
+
AR = lib -nologo
|
47
|
+
EXEEXT = .exe
|
48
|
+
|
49
|
+
RUBY_INSTALL_NAME = ruby
|
50
|
+
RUBY_SO_NAME = msvcrt-ruby18
|
51
|
+
arch = i386-mswin32
|
52
|
+
sitearch = i386-msvcrt
|
53
|
+
ruby_version = 1.8
|
54
|
+
ruby = C:/ruby/bin/ruby
|
55
|
+
RUBY = $(ruby:/=\)
|
56
|
+
RM = $(RUBY) -run -e rm -- -f
|
57
|
+
MAKEDIRS = @$(RUBY) -run -e mkdir -- -p
|
58
|
+
INSTALL = copy > nul
|
59
|
+
INSTALL_PROG = $(INSTALL)
|
60
|
+
INSTALL_DATA = $(INSTALL)
|
61
|
+
COPY = copy > nul
|
62
|
+
|
63
|
+
#### End of system configuration section. ####
|
64
|
+
|
65
|
+
preload =
|
66
|
+
|
67
|
+
libpath = $(libdir)
|
68
|
+
LIBPATH = -libpath:"$(libdir)"
|
69
|
+
DEFFILE = $(TARGET)-$(arch).def
|
70
|
+
|
71
|
+
CLEANFILES =
|
72
|
+
DISTCLEANFILES = vc*.pdb $(DEFFILE)
|
73
|
+
|
74
|
+
extout =
|
75
|
+
extout_prefix =
|
76
|
+
target_prefix = /win32
|
77
|
+
LOCAL_LIBS =
|
78
|
+
LIBS = $(LIBRUBYARG_SHARED) oldnames.lib user32.lib advapi32.lib wsock32.lib
|
79
|
+
SRCS = api.c
|
80
|
+
OBJS = api.obj
|
81
|
+
TARGET = api
|
82
|
+
DLLIB = $(TARGET).so
|
83
|
+
EXTSTATIC =
|
84
|
+
STATIC_LIB =
|
85
|
+
|
86
|
+
RUBYCOMMONDIR = $(sitedir)$(target_prefix)
|
87
|
+
RUBYLIBDIR = $(sitelibdir)$(target_prefix)
|
88
|
+
RUBYARCHDIR = $(sitearchdir)$(target_prefix)
|
89
|
+
|
90
|
+
TARGET_SO = $(DLLIB)
|
91
|
+
CLEANLIBS = $(TARGET).so $(TARGET).il? $(TARGET).tds $(TARGET).map
|
92
|
+
CLEANOBJS = *.obj *.lib *.s[ol] *.pdb *.exp *.bak
|
93
|
+
|
94
|
+
all: $(DLLIB)
|
95
|
+
static: $(STATIC_LIB)
|
96
|
+
|
97
|
+
clean:
|
98
|
+
@-$(RM) $(CLEANLIBS:/=\) $(CLEANOBJS:/=\) $(CLEANFILES:/=\)
|
99
|
+
|
100
|
+
distclean: clean
|
101
|
+
@-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
|
102
|
+
@-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES:/=\)
|
103
|
+
|
104
|
+
realclean: distclean
|
105
|
+
install: install-so install-rb
|
106
|
+
|
107
|
+
install-so: $(RUBYARCHDIR)
|
108
|
+
install-so: $(RUBYARCHDIR)/$(DLLIB)
|
109
|
+
$(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
|
110
|
+
$(INSTALL_PROG) $(DLLIB:/=\) $(RUBYARCHDIR:/=\)
|
111
|
+
install-rb: pre-install-rb install-rb-default
|
112
|
+
install-rb-default: pre-install-rb-default
|
113
|
+
pre-install-rb: Makefile
|
114
|
+
pre-install-rb-default: Makefile
|
115
|
+
$(RUBYARCHDIR):
|
116
|
+
$(MAKEDIRS) $@
|
117
|
+
|
118
|
+
site-install: site-install-so site-install-rb
|
119
|
+
site-install-so: install-so
|
120
|
+
site-install-rb: install-rb
|
121
|
+
|
122
|
+
.SUFFIXES: .c .m .cc .cxx .cpp .obj
|
123
|
+
|
124
|
+
{$(srcdir)}.cc{}.obj:
|
125
|
+
$(CXX) $(INCFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c -Tp$(<:\=/)
|
126
|
+
|
127
|
+
{$(topdir)}.cc{}.obj:
|
128
|
+
$(CXX) $(INCFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c -Tp$(<:\=/)
|
129
|
+
|
130
|
+
{$(hdrdir)}.cc{}.obj:
|
131
|
+
$(CXX) $(INCFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c -Tp$(<:\=/)
|
132
|
+
|
133
|
+
.cc.obj:
|
134
|
+
$(CXX) $(INCFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c -Tp$(<:\=/)
|
135
|
+
|
136
|
+
{$(srcdir)}.cxx{}.obj:
|
137
|
+
$(CXX) $(INCFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c -Tp$(<:\=/)
|
138
|
+
|
139
|
+
{$(topdir)}.cxx{}.obj:
|
140
|
+
$(CXX) $(INCFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c -Tp$(<:\=/)
|
141
|
+
|
142
|
+
{$(hdrdir)}.cxx{}.obj:
|
143
|
+
$(CXX) $(INCFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c -Tp$(<:\=/)
|
144
|
+
|
145
|
+
.cxx.obj:
|
146
|
+
$(CXX) $(INCFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c -Tp$(<:\=/)
|
147
|
+
|
148
|
+
{$(srcdir)}.cpp{}.obj:
|
149
|
+
$(CXX) $(INCFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c -Tp$(<:\=/)
|
150
|
+
|
151
|
+
{$(topdir)}.cpp{}.obj:
|
152
|
+
$(CXX) $(INCFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c -Tp$(<:\=/)
|
153
|
+
|
154
|
+
{$(hdrdir)}.cpp{}.obj:
|
155
|
+
$(CXX) $(INCFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c -Tp$(<:\=/)
|
156
|
+
|
157
|
+
.cpp.obj:
|
158
|
+
$(CXX) $(INCFLAGS) $(CXXFLAGS) $(CPPFLAGS) -c -Tp$(<:\=/)
|
159
|
+
|
160
|
+
{$(srcdir)}.c{}.obj:
|
161
|
+
$(CC) $(INCFLAGS) $(CFLAGS) $(CPPFLAGS) -c -Tc$(<:\=/)
|
162
|
+
|
163
|
+
{$(topdir)}.c{}.obj:
|
164
|
+
$(CC) $(INCFLAGS) $(CFLAGS) $(CPPFLAGS) -c -Tc$(<:\=/)
|
165
|
+
|
166
|
+
{$(hdrdir)}.c{}.obj:
|
167
|
+
$(CC) $(INCFLAGS) $(CFLAGS) $(CPPFLAGS) -c -Tc$(<:\=/)
|
168
|
+
|
169
|
+
.c.obj:
|
170
|
+
$(CC) $(INCFLAGS) $(CFLAGS) $(CPPFLAGS) -c -Tc$(<:\=/)
|
171
|
+
|
172
|
+
$(DLLIB): $(DEFFILE) $(OBJS)
|
173
|
+
@-$(RM) $@
|
174
|
+
$(LDSHARED) -Fe$(@) $(OBJS) $(LIBS) $(LOCAL_LIBS) $(DLDFLAGS)
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
$(DEFFILE):
|
179
|
+
$(RUBY) -e "puts 'EXPORTS', 'Init_$(TARGET)'" > $@
|
180
|
+
|
181
|
+
$(OBJS): {.;$(srcdir);$(topdir);$(hdrdir)}ruby.h {.;$(srcdir);$(topdir);$(hdrdir)}defines.h
|
Binary file
|
Binary file
|
Binary file
|
data/ext/api.obj
ADDED
Binary file
|
data/ext/extconf.rb
CHANGED
data/ext/mkmf.log
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
have_func: checking for strncpy_s()... -------------------- no
|
2
|
+
|
3
|
+
"cl -nologo -Feconftest -I. -IC:/ruby/lib/ruby/1.8/i386-mswin32 -I. -IC:/ruby/lib/ruby/1.8/i386-mswin32 -MD -Zi -O2b2xg- -G6 conftest.c msvcrt-ruby18-static.lib oldnames.lib user32.lib advapi32.lib wsock32.lib -link -libpath:"C:/ruby/lib" -stack:0x2000000"
|
4
|
+
conftest.c
|
5
|
+
conftest.obj : error LNK2001: unresolved external symbol _strncpy_s
|
6
|
+
conftest.exe : fatal error LNK1120: 1 unresolved externals
|
7
|
+
checked program was:
|
8
|
+
/* begin */
|
9
|
+
1: /*top*/
|
10
|
+
2: int main() { return 0; }
|
11
|
+
3: int t() { strncpy_s(); return 0; }
|
12
|
+
/* end */
|
13
|
+
|
14
|
+
"cl -nologo -Feconftest -I. -IC:/ruby/lib/ruby/1.8/i386-mswin32 -I. -IC:/ruby/lib/ruby/1.8/i386-mswin32 -MD -Zi -O2b2xg- -G6 conftest.c msvcrt-ruby18-static.lib oldnames.lib user32.lib advapi32.lib wsock32.lib -link -libpath:"C:/ruby/lib" -stack:0x2000000"
|
15
|
+
conftest.c
|
16
|
+
conftest.c(6) : error C2065: 'strncpy_s' : undeclared identifier
|
17
|
+
checked program was:
|
18
|
+
/* begin */
|
19
|
+
1: #include <windows.h>
|
20
|
+
2: #include <winsock.h>
|
21
|
+
3:
|
22
|
+
4: /*top*/
|
23
|
+
5: int main() { return 0; }
|
24
|
+
6: int t() { void ((*volatile p)()); p = (void ((*)()))strncpy_s; return 0; }
|
25
|
+
/* end */
|
26
|
+
|
27
|
+
--------------------
|
28
|
+
|
data/ext/vc60.pdb
ADDED
Binary file
|
data/ext/win32/api.c
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
#include <windows.h>
|
3
3
|
|
4
4
|
#define MAX_BUF 1024
|
5
|
-
#define WINDOWS_API_VERSION "1.0.
|
5
|
+
#define WINDOWS_API_VERSION "1.0.6"
|
6
6
|
|
7
7
|
#define _T_VOID 0
|
8
8
|
#define _T_LONG 1
|
@@ -71,7 +71,7 @@ static VALUE callback_init(int argc, VALUE* argv, VALUE self)
|
|
71
71
|
VALUE v_proto, v_return, v_proc;
|
72
72
|
int i;
|
73
73
|
|
74
|
-
rb_scan_args(argc, argv, "11", &v_proto, &v_return);
|
74
|
+
rb_scan_args(argc, argv, "11&", &v_proto, &v_return, &v_proc);
|
75
75
|
|
76
76
|
/* Validate prototype characters */
|
77
77
|
for(i = 0; i < RSTRING(v_proto)->len; i++){
|
@@ -87,14 +87,9 @@ static VALUE callback_init(int argc, VALUE* argv, VALUE self)
|
|
87
87
|
if(NIL_P(v_return) || RARRAY(v_return)->len == 0)
|
88
88
|
v_return = rb_str_new2("L");
|
89
89
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
v_proc = Qnil;
|
94
|
-
|
95
|
-
rb_iv_set(self, "@function", v_proc);
|
96
|
-
rb_iv_set(self, "@prototype", v_proto);
|
97
|
-
rb_iv_set(self, "@return_type", v_return);
|
90
|
+
rb_iv_set(self, "@function", v_proc);
|
91
|
+
rb_iv_set(self, "@prototype", v_proto);
|
92
|
+
rb_iv_set(self, "@return_type", v_return);
|
98
93
|
|
99
94
|
return self;
|
100
95
|
}
|
@@ -148,7 +143,7 @@ static VALUE api_init(int argc, VALUE* argv, VALUE self)
|
|
148
143
|
int i;
|
149
144
|
char* first = "A";
|
150
145
|
char* second = "W";
|
151
|
-
VALUE v_proc, v_proto, v_return, v_dll
|
146
|
+
VALUE v_proc, v_proto, v_return, v_dll;
|
152
147
|
|
153
148
|
rb_scan_args(argc, argv, "13", &v_proc, &v_proto, &v_return, &v_dll);
|
154
149
|
|
@@ -198,7 +193,7 @@ static VALUE api_init(int argc, VALUE* argv, VALUE self)
|
|
198
193
|
fProc = GetProcAddress(hLibrary, TEXT(RSTRING(v_proc)->ptr));
|
199
194
|
|
200
195
|
/* The order of 'A' and 'W' is reversed if $KCODE is set to 'UTF8'. */
|
201
|
-
if(!
|
196
|
+
if(!strcmp(rb_get_kcode(), "UTF8")){
|
202
197
|
first = "W";
|
203
198
|
second = "A";
|
204
199
|
}
|
@@ -223,8 +218,17 @@ static VALUE api_init(int argc, VALUE* argv, VALUE self)
|
|
223
218
|
StringError(GetLastError())
|
224
219
|
);
|
225
220
|
}
|
221
|
+
else{
|
222
|
+
rb_iv_set(self, "@effective_function_name", v_unicode);
|
223
|
+
}
|
224
|
+
}
|
225
|
+
else{
|
226
|
+
rb_iv_set(self, "@effective_function_name", v_ascii);
|
226
227
|
}
|
227
228
|
}
|
229
|
+
else{
|
230
|
+
rb_iv_set(self, "@effective_function_name", v_proc);
|
231
|
+
}
|
228
232
|
|
229
233
|
ptr->function = fProc;
|
230
234
|
|
@@ -508,9 +512,15 @@ void Init_api(){
|
|
508
512
|
/* The name of the DLL that exports the API function */
|
509
513
|
rb_define_attr(cAPI, "dll_name", 1, 0);
|
510
514
|
|
511
|
-
/* The name of the function */
|
515
|
+
/* The name of the function passed to the constructor */
|
512
516
|
rb_define_attr(cAPI, "function_name", 1, 0);
|
513
517
|
|
518
|
+
/* The name of the actual function that is returned by the constructor.
|
519
|
+
* For example, if you passed 'GetUserName' to the constructor, then the
|
520
|
+
* effective function name would be either 'GetUserNameA' or 'GetUserNameW'.
|
521
|
+
*/
|
522
|
+
rb_define_attr(cAPI, "effective_function_name", 1, 0);
|
523
|
+
|
514
524
|
/* The prototype, returned as an array of characters */
|
515
525
|
rb_define_attr(cAPI, "prototype", 1, 0);
|
516
526
|
|
data/ext/win32/api.so
ADDED
Binary file
|
data/test/tc_win32_api.rb
CHANGED
@@ -16,7 +16,7 @@ class TC_Win32_API < Test::Unit::TestCase
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_version
|
19
|
-
assert_equal('1.0.
|
19
|
+
assert_equal('1.0.6', API::VERSION)
|
20
20
|
end
|
21
21
|
|
22
22
|
def test_call
|
@@ -40,6 +40,11 @@ class TC_Win32_API < Test::Unit::TestCase
|
|
40
40
|
assert_equal('GetCurrentDirectory', @api.function_name)
|
41
41
|
end
|
42
42
|
|
43
|
+
def test_effective_function_name
|
44
|
+
assert_respond_to(@api, :effective_function_name)
|
45
|
+
assert_equal('GetCurrentDirectoryA', @api.effective_function_name)
|
46
|
+
end
|
47
|
+
|
43
48
|
def test_prototype
|
44
49
|
assert_respond_to(@api, :prototype)
|
45
50
|
assert_equal(['L', 'P'], @api.prototype)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: win32-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel J. Berger
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2008-04-18 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -25,9 +25,18 @@ extra_rdoc_files:
|
|
25
25
|
- MANIFEST
|
26
26
|
- ext/win32/api.c
|
27
27
|
files:
|
28
|
+
- ext/api-i386-mswin32.def
|
29
|
+
- ext/api-i386-mswin32.exp
|
30
|
+
- ext/api-i386-mswin32.lib
|
31
|
+
- ext/api-i386-mswin32.pdb
|
32
|
+
- ext/api.obj
|
28
33
|
- ext/extconf.rb
|
34
|
+
- ext/Makefile
|
35
|
+
- ext/mkmf.log
|
36
|
+
- ext/vc60.pdb
|
29
37
|
- ext/win32
|
30
38
|
- ext/win32/api.c
|
39
|
+
- ext/win32/api.so
|
31
40
|
- test/tc_win32_api.rb
|
32
41
|
- test/tc_win32_api_callback.rb
|
33
42
|
- README
|
@@ -55,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
55
64
|
requirements: []
|
56
65
|
|
57
66
|
rubyforge_project: win32utils
|
58
|
-
rubygems_version:
|
67
|
+
rubygems_version: 1.1.1
|
59
68
|
signing_key:
|
60
69
|
specification_version: 2
|
61
70
|
summary: A superior replacement for Win32API
|