windows-pr 0.8.2 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,13 @@
1
+ = 0.8.3 - 26-Apr-2008
2
+ * Now requires windows-api 0.2.3 or later to take advantage of the
3
+ improvements in auto constant generation.
4
+ * Fixed a scope resolution bug in the custom memcpy method in the
5
+ Windows::MSVCRT::Buffer module.
6
+ * Added some more Windows::MSVCRT::String functions.
7
+ * Added the FSCTL_ENUM_USN_DATA macro method in Windows::DeviceIO.
8
+ * Some modules were refactored to take advantage of the improvements in
9
+ windows-api 0.2.3. This resulted in a net reduction of code.
10
+
1
11
  = 0.8.2 - 17-Apr-2008
2
12
  * Most of the MSVCRT modules now use the MSVCRT_DLL from the Windows::API
3
13
  library. This helps resolve an obscure bug where state information from a
@@ -190,4 +200,4 @@
190
200
  * Fixed signature and dll mistakes in the File module.
191
201
 
192
202
  = 0.1.0 - 4-Apr-2006
193
- * Initial release
203
+ * Initial release
@@ -30,5 +30,5 @@ In practice most LPVOID types should be designated as 'L' because this
30
30
  usually means the function is looking for an address. Check the documentation
31
31
  for details.
32
32
 
33
- If using the win32-api library, you can use 'B' instead of 'I' for the return
33
+ If using the windows-api library, you can use 'B' instead of 'I' for the return
34
34
  type for functions that return a BOOL.
@@ -88,6 +88,10 @@ module Windows
88
88
  CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 16, METHOD_BUFFERED, 3)
89
89
  end
90
90
 
91
+ def FSCTL_ENUM_USN_DATA
92
+ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 44, METHOD_NEITHER, 0)
93
+ end
94
+
91
95
  def FSCTL_READ_USN_JOURNAL
92
96
  CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 46, METHOD_NEITHER, 0)
93
97
  end
@@ -4,43 +4,19 @@ include Windows
4
4
  module Windows
5
5
  module Handle
6
6
  API.auto_namespace = 'Windows::Handle'
7
- API.auto_constant = false # Due to some functions with leading '_'.
8
- API.auto_method = false
7
+ API.auto_constant = true
8
+ API.auto_method = true
9
9
  API.auto_unicode = false
10
10
 
11
11
  INVALID_HANDLE_VALUE = -1
12
12
  HANDLE_FLAG_INHERIT = 0x00000001
13
13
  HANDLE_FLAG_PROTECT_FROM_CLOSE = 0x00000002
14
14
 
15
- CloseHandle = API.new('CloseHandle', 'L', 'I')
16
- DuplicateHandle = API.new('DuplicateHandle', 'LLLLLIL', 'I')
17
- GetHandleInformation = API.new('GetHandleInformation', 'LL', 'I')
18
- SetHandleInformation = API.new('SetHandleInformation', 'LLL', 'I')
19
- GetOSFHandle = API.new('_get_osfhandle', 'I', 'L', MSVCRT_DLL)
20
- OpenOSFHandle = API.new('_open_osfhandle', 'LI', 'I', MSVCRT_DLL)
21
-
22
- def CloseHandle(handle)
23
- CloseHandle.call(handle) != 0
24
- end
25
-
26
- def DuplicateHandle(sphandle, shandle, thandle, access, ihandle, opts)
27
- DuplicateHandle.call(sphandle, shandle, thandle, access, ihandle, opts) != 0
28
- end
29
-
30
- def GetHandleInformation(handle, flags)
31
- GetHandleInformation.call(handle, flags) != 0
32
- end
33
-
34
- def SetHandleInformation(handle, mask, flags)
35
- SetHandleInformation.call(handle, mask, flags) != 0
36
- end
37
-
38
- def get_osfhandle(fd)
39
- GetOSFHandle.call(fd)
40
- end
41
-
42
- def open_osfhandle(handle, flags)
43
- OpenOSFHandle.call(handle, flags)
44
- end
15
+ API.new('CloseHandle', 'L', 'B')
16
+ API.new('DuplicateHandle', 'LLLLLIL', 'B')
17
+ API.new('GetHandleInformation', 'LL', 'B')
18
+ API.new('SetHandleInformation', 'LLL', 'B')
19
+ API.new('_get_osfhandle', 'I', 'L', MSVCRT_DLL)
20
+ API.new('_open_osfhandle', 'LI', 'I', MSVCRT_DLL)
45
21
  end
46
22
  end
@@ -4,9 +4,9 @@ include Windows
4
4
  module Windows
5
5
  module MSVCRT
6
6
  module Buffer
7
- API.auto_constant = false
8
- API.auto_method = false
9
- API.auto_unicode = false
7
+ API.auto_constant = false # We want multiple versions
8
+ API.auto_method = false
9
+ API.auto_unicode = false
10
10
 
11
11
  Memcpy = API.new('memcpy', 'PLL', 'P', MSVCRT_DLL)
12
12
  Memccpy = API.new('_memccpy', 'PPIL', 'P', MSVCRT_DLL)
@@ -27,14 +27,14 @@ module Windows
27
27
  # defaults to the length of +src+.
28
28
  #
29
29
  def memcpy(dest, src, size = src.length)
30
- if dest.is_a?(Integer)
31
- if src.is_a?(String)
30
+ if dest.is_a?(::Integer)
31
+ if src.is_a?(::String)
32
32
  MemcpyLPL.call(dest, src, size)
33
33
  else
34
34
  MemcpyLLL.call(dest, src, size)
35
35
  end
36
36
  else
37
- if src.is_a?(String)
37
+ if src.is_a?(::String)
38
38
  MemcpyPPL.call(dest, src, size)
39
39
  else
40
40
  MemcpyPLL.call(dest, src, size)
@@ -4,90 +4,27 @@ include Windows
4
4
  module Windows
5
5
  module MSVCRT
6
6
  module Directory
7
- API.auto_method = false
8
- API.auto_constant = false
9
- API.auto_unicode = false
10
-
11
- Chdir = API.new('_chdir', 'P', 'I', MSVCRT_DLL)
12
- Wchdir = API.new('_wchdir', 'P', 'I', MSVCRT_DLL)
13
- Chdrive = API.new('_chdrive', 'I', 'I', MSVCRT_DLL)
14
- Getcwd = API.new('_getcwd', 'PI', 'P', MSVCRT_DLL)
15
- Wgetcwd = API.new('_wgetcwd', 'PI', 'P', MSVCRT_DLL)
16
- Getdcwd = API.new('_getdcwd', 'IPI', 'P', MSVCRT_DLL)
17
- Wgetdcwd = API.new('_wgetdcwd', 'IPI', 'P', MSVCRT_DLL)
18
- Getdiskfree = API.new('_getdiskfree', 'IP', 'I', MSVCRT_DLL)
19
- Getdrive = API.new('_getdrive', 'V', 'I', MSVCRT_DLL)
20
- Getdrives = API.new('_getdrives', 'V', 'L', MSVCRT_DLL)
21
- Mkdir = API.new('_mkdir', 'P', 'I', MSVCRT_DLL)
22
- Wmkdir = API.new('_wmkdir', 'P', 'I', MSVCRT_DLL)
23
- Rmdir = API.new('_rmdir', 'P', 'I', MSVCRT_DLL)
24
- Wrmdir = API.new('_wrmdir', 'P', 'I', MSVCRT_DLL)
25
- Searchenv = API.new('_searchenv', 'PPP', 'V', MSVCRT_DLL)
26
- Wsearchenv = API.new('_wsearchenv', 'PPP', 'V', MSVCRT_DLL)
27
-
28
- def chdir(dirname)
29
- Chdir.call(dirname)
30
- end
31
-
32
- def wchdir(dirname)
33
- Wchdir.call(dirname)
34
- end
35
-
36
- def chdrive(drive_number)
37
- Chdrive.call(drive_number)
38
- end
39
-
40
- def getcwd(buffer, maxlen)
41
- Getcwd.call(buffer, maxlen)
42
- end
43
-
44
- def wgetcwd(buffer, maxlen)
45
- Wgetcwd.call(buffer, maxlen)
46
- end
47
-
48
- def getdcwd(drive, buffer, maxlen)
49
- Getdcwd.call(drive, buffer, maxlen)
50
- end
51
-
52
- def wgetdcwd(drive, buffer, maxlen)
53
- Wgetdcwd.call(drive, buffer, maxlen)
54
- end
55
-
56
- def getdiskfree(drive, struct_ptr)
57
- Getdiskfree.call(drive, struct_ptr)
58
- end
59
-
60
- def getdrive
61
- Getdrive.call
62
- end
63
-
64
- def getdrives
65
- Getdrives.call
66
- end
67
-
68
- def mkdir(dirname)
69
- Mkdir.call(dirname)
70
- end
71
-
72
- def wmkdir(dirname)
73
- Wmkdir.call(dirname)
74
- end
75
-
76
- def rmdir(dirname)
77
- Rmdir.call(dirname)
78
- end
79
-
80
- def wrmdir(dirname)
81
- Wrmdir.call(dirname)
82
- end
83
-
84
- def searchenv(filename, varname, pathname)
85
- Searchenv.call(filename, varname, pathname)
86
- end
87
-
88
- def wsearchenv(filename, varname, pathname)
89
- Wsearchenv.call(filename, varname, pathname)
90
- end
7
+ API.auto_namespace = 'Windows::MSVCRT::Directory'
8
+ API.auto_method = true
9
+ API.auto_constant = true
10
+ API.auto_unicode = false
11
+
12
+ API.new('_chdir', 'P', 'I', MSVCRT_DLL)
13
+ API.new('_wchdir', 'P', 'I', MSVCRT_DLL)
14
+ API.new('_chdrive', 'I', 'I', MSVCRT_DLL)
15
+ API.new('_getcwd', 'PI', 'P', MSVCRT_DLL)
16
+ API.new('_wgetcwd', 'PI', 'P', MSVCRT_DLL)
17
+ API.new('_getdcwd', 'IPI', 'P', MSVCRT_DLL)
18
+ API.new('_wgetdcwd', 'IPI', 'P', MSVCRT_DLL)
19
+ API.new('_getdiskfree', 'IP', 'I', MSVCRT_DLL)
20
+ API.new('_getdrive', 'V', 'I', MSVCRT_DLL)
21
+ API.new('_getdrives', 'V', 'L', MSVCRT_DLL)
22
+ API.new('_mkdir', 'P', 'I', MSVCRT_DLL)
23
+ API.new('_wmkdir', 'P', 'I', MSVCRT_DLL)
24
+ API.new('_rmdir', 'P', 'I', MSVCRT_DLL)
25
+ API.new('_wrmdir', 'P', 'I', MSVCRT_DLL)
26
+ API.new('_searchenv', 'PPP', 'V', MSVCRT_DLL)
27
+ API.new('_wsearchenv', 'PPP', 'V', MSVCRT_DLL)
91
28
  end
92
29
  end
93
30
  end
@@ -4,9 +4,10 @@ include Windows
4
4
  module Windows
5
5
  module MSVCRT
6
6
  module File
7
- API.auto_method = false
8
- API.auto_constant = false
9
- API.auto_unicode = false
7
+ API.auto_namespace = 'Windows::MSVCRT::File'
8
+ API.auto_method = true
9
+ API.auto_constant = true
10
+ API.auto_unicode = false
10
11
 
11
12
  S_IFMT = 0170000 # file type mask
12
13
  S_IFDIR = 0040000 # directory
@@ -17,72 +18,24 @@ module Windows
17
18
  S_IWRITE = 0000200 # write permission, owner
18
19
  S_IEXEC = 0000100 # execute/search permission, owner
19
20
 
20
- Chmod = API.new('_chmod', 'PI', 'I', MSVCRT_DLL)
21
- Chsize = API.new('_chsize', 'IL', 'I', MSVCRT_DLL)
22
- Mktemp = API.new('_mktemp', 'P', 'P', MSVCRT_DLL)
23
- Stat = API.new('_stat', 'PP', 'I', 'msvcrt')
24
- Stat64 = API.new('_stat64', 'PP', 'I', MSVCRT_DLL)
25
- Wchmod = API.new('_wchmod', 'PI', 'I', MSVCRT_DLL)
26
- Wmktemp = API.new('_wmktemp', 'P', 'P', MSVCRT_DLL)
27
- Wstat = API.new('_wstat', 'PP', 'I', 'msvcrt')
28
- Wstat64 = API.new('_wstat64', 'PP', 'I', MSVCRT_DLL)
21
+ API.new('_chmod', 'PI', 'I', MSVCRT_DLL)
22
+ API.new('_chsize', 'IL', 'I', MSVCRT_DLL)
23
+ API.new('_mktemp', 'P', 'P', MSVCRT_DLL)
24
+ API.new('_stat', 'PP', 'I', 'msvcrt')
25
+ API.new('_stat64', 'PP', 'I', MSVCRT_DLL)
26
+ API.new('_wchmod', 'PI', 'I', MSVCRT_DLL)
27
+ API.new('_wmktemp', 'P', 'P', MSVCRT_DLL)
28
+ API.new('_wstat', 'PP', 'I', 'msvcrt')
29
+ API.new('_wstat64', 'PP', 'I', MSVCRT_DLL)
29
30
 
30
31
  # VC++ 8.0 or later
31
32
  begin
32
- Chsize_s = API.new('_chsize_s', 'IL', 'I', MSVCRT_DLL)
33
- Mktemp_s = API.new('_mktemp_s', 'PL', 'L', MSVCRT_DLL)
34
- Wmktemp_s = API.new('_wmktemp_s', 'PL', 'L', MSVCRT_DLL)
33
+ API.new('_chsize_s', 'IL', 'I', MSVCRT_DLL)
34
+ API.new('_mktemp_s', 'PL', 'L', MSVCRT_DLL)
35
+ API.new('_wmktemp_s', 'PL', 'L', MSVCRT_DLL)
35
36
  rescue RuntimeError
36
37
  # Ignore - you must check for it via 'defined?'
37
38
  end
38
-
39
- def chmod(file, mode)
40
- Chmod.call(file, mode)
41
- end
42
-
43
- def chsize(fd, size)
44
- Chsize.call(fd, size)
45
- end
46
-
47
- def chsize_s(fd, size)
48
- Chsize_s.call(fd, size)
49
- end
50
-
51
- def mktemp(template)
52
- Mktemp.call(template)
53
- end
54
-
55
- def mktemp_s(template, size)
56
- Mktemp_s.call(template, size)
57
- end
58
-
59
- def stat(path, buffer)
60
- Stat.call(path, buffer)
61
- end
62
-
63
- def stat64(path, buffer)
64
- Stat64.call(path, buffer)
65
- end
66
-
67
- def wchmod(file, mode)
68
- Wchmod.call(file, mode)
69
- end
70
-
71
- def wmktemp(template)
72
- Wmktemp.call(template)
73
- end
74
-
75
- def wmktemp_s(template, size)
76
- Wmktemp_s.call(template, size)
77
- end
78
-
79
- def wstat(path, buffer)
80
- Wstat.call(path, buffer)
81
- end
82
-
83
- def wstat64(path, buffer)
84
- Wstat64.call(path, buffer)
85
- end
86
39
  end
87
40
  end
88
41
  end
@@ -5,9 +5,10 @@ include Windows
5
5
  module Windows
6
6
  module MSVCRT
7
7
  module IO
8
- API.auto_constant = false
9
- API.auto_method = false
10
- API.auto_unicode = false
8
+ API.auto_namespace = 'Windows::MSVCRT::IO'
9
+ API.auto_constant = true
10
+ API.auto_method = true
11
+ API.auto_unicode = false
11
12
 
12
13
  S_IFMT = 0170000 # file type mask
13
14
  S_IFDIR = 0040000 # directory
@@ -18,168 +19,44 @@ module Windows
18
19
  S_IWRITE = 0000200 # write permission, owner
19
20
  S_IEXEC = 0000100 # execute/search permission, owner
20
21
 
21
- Clearerr = API.new('clearerr', 'I', 'V', MSVCRT_DLL)
22
- Close = API.new('_close', 'I', 'V', MSVCRT_DLL)
23
- Fclose = API.new('fclose', 'I', 'I', MSVCRT_DLL)
24
- Fcloseall = API.new('_fcloseall', 'V', 'I', MSVCRT_DLL)
25
- Fdopen = API.new('_fdopen', 'IP', 'I', MSVCRT_DLL)
26
- Feof = API.new('feof', 'I', 'I', MSVCRT_DLL)
27
- Ferror = API.new('ferror', 'L', 'I', MSVCRT_DLL)
28
- Fflush = API.new('fflush', 'I', 'I', MSVCRT_DLL)
29
- Fgetc = API.new('fgetc', 'L', 'I', MSVCRT_DLL)
30
- Fgetpos = API.new('fgetpos', 'LP', 'I', MSVCRT_DLL)
31
- Fgetwc = API.new('fgetwc', 'L', 'I', MSVCRT_DLL)
32
- Fgets = API.new('fgets', 'PIL', 'P', MSVCRT_DLL)
33
- Fgetws = API.new('fgetws', 'PIL', 'P', MSVCRT_DLL)
34
- Fileno = API.new('_fileno', 'I', 'I', MSVCRT_DLL)
35
- Flushall = API.new('_flushall', 'V', 'I', MSVCRT_DLL)
36
- Fopen = API.new('fopen', 'PP', 'I', MSVCRT_DLL)
37
- Fputs = API.new('fputs', 'PL', 'I', MSVCRT_DLL)
38
- Fputws = API.new('fputws', 'PL', 'I', MSVCRT_DLL)
39
- Getc = API.new('getc', 'L', 'I', MSVCRT_DLL)
40
- Getwc = API.new('getwc', 'L', 'L', MSVCRT_DLL)
41
- Open = API.new('_open', 'PPI', 'I', MSVCRT_DLL)
42
- Rmtmp = API.new('_rmtmp', 'V', 'I', MSVCRT_DLL)
43
- Setmode = API.new('_setmode', 'II', 'I', MSVCRT_DLL)
44
- Tempnam = API.new('_tempnam', 'PP', 'P', MSVCRT_DLL)
45
- Tmpfile = API.new('tmpfile', 'V', 'L', MSVCRT_DLL)
46
- Tmpnam = API.new('tmpnam', 'P', 'P', MSVCRT_DLL)
47
- Wopen = API.new('_wopen', 'PPI', 'I', MSVCRT_DLL)
48
- Wfdopen = API.new('_wfdopen', 'IP', 'I', MSVCRT_DLL)
49
- Wfopen = API.new('_wfopen', 'PPI', 'I', MSVCRT_DLL)
50
- Wtempnam = API.new('_wtempnam', 'PP', 'P', MSVCRT_DLL)
51
- Wtmpnam = API.new('_wtmpnam', 'P', 'P', MSVCRT_DLL)
22
+ API.new('clearerr', 'I', 'V', MSVCRT_DLL)
23
+ API.new('_close', 'I', 'V', MSVCRT_DLL)
24
+ API.new('fclose', 'I', 'I', MSVCRT_DLL)
25
+ API.new('_fcloseall', 'V', 'I', MSVCRT_DLL)
26
+ API.new('_fdopen', 'IP', 'I', MSVCRT_DLL)
27
+ API.new('feof', 'I', 'I', MSVCRT_DLL)
28
+ API.new('ferror', 'L', 'I', MSVCRT_DLL)
29
+ API.new('fflush', 'I', 'I', MSVCRT_DLL)
30
+ API.new('fgetc', 'L', 'I', MSVCRT_DLL)
31
+ API.new('fgetpos', 'LP', 'I', MSVCRT_DLL)
32
+ API.new('fgetwc', 'L', 'I', MSVCRT_DLL)
33
+ API.new('fgets', 'PIL', 'P', MSVCRT_DLL)
34
+ API.new('fgetws', 'PIL', 'P', MSVCRT_DLL)
35
+ API.new('_fileno', 'I', 'I', MSVCRT_DLL)
36
+ API.new('_flushall', 'V', 'I', MSVCRT_DLL)
37
+ API.new('fopen', 'PP', 'I', MSVCRT_DLL)
38
+ API.new('fputs', 'PL', 'I', MSVCRT_DLL)
39
+ API.new('fputws', 'PL', 'I', MSVCRT_DLL)
40
+ API.new('getc', 'L', 'I', MSVCRT_DLL)
41
+ API.new('getwc', 'L', 'L', MSVCRT_DLL)
42
+ API.new('_open', 'PPI', 'I', MSVCRT_DLL)
43
+ API.new('_rmtmp', 'V', 'I', MSVCRT_DLL)
44
+ API.new('_setmode', 'II', 'I', MSVCRT_DLL)
45
+ API.new('_tempnam', 'PP', 'P', MSVCRT_DLL)
46
+ API.new('tmpfile', 'V', 'L', MSVCRT_DLL)
47
+ API.new('tmpnam', 'P', 'P', MSVCRT_DLL)
48
+ API.new('_wopen', 'PPI', 'I', MSVCRT_DLL)
49
+ API.new('_wfdopen', 'IP', 'I', MSVCRT_DLL)
50
+ API.new('_wfopen', 'PPI', 'I', MSVCRT_DLL)
51
+ API.new('_wtempnam', 'PP', 'P', MSVCRT_DLL)
52
+ API.new('_wtmpnam', 'P', 'P', MSVCRT_DLL)
52
53
 
53
54
  # VC++ 8.0 or later
54
55
  begin
55
- Tmpfile_s = API.new('_tmpfile_s', 'P', 'L', MSVCRT_DLL)
56
+ API.new('_tmpfile_s', 'P', 'L', MSVCRT_DLL)
56
57
  rescue RuntimeError
57
58
  # Ignore - you must check for it via 'defined?'
58
59
  end
59
-
60
- def clearerr(stream)
61
- Clearerr.call(stream)
62
- end
63
-
64
- def close(fd)
65
- Close.call(fd)
66
- end
67
-
68
- def fclose(stream)
69
- Fclose.call(stream)
70
- end
71
-
72
- def fcloseall
73
- Fcloseall.call
74
- end
75
-
76
- def fdopen(fd, mode)
77
- Fdopen.call(fd, mode)
78
- end
79
-
80
- def feof(stream)
81
- Feof.call(stream)
82
- end
83
-
84
- def ferror(stream)
85
- Ferror.call(stream)
86
- end
87
-
88
- def fflush(stream)
89
- Fflush.call(stream)
90
- end
91
-
92
- def fgetc(stream)
93
- Fgetc.call(stream)
94
- end
95
-
96
- def fgetpos(stream, pos)
97
- Fgetpos.call(stream, pos)
98
- end
99
-
100
- def fgets(str, n, stream)
101
- Fgets.call(str, n, stream)
102
- end
103
-
104
- def fgetws(str, n, stream)
105
- Fgetws.call(str, n, stream)
106
- end
107
-
108
- def fgetwc(stream)
109
- Fgetwc.call(stream)
110
- end
111
-
112
- def fileno(stream)
113
- Fileno.call(stream)
114
- end
115
-
116
- def flushall
117
- Flushall.call()
118
- end
119
-
120
- def fopen(file, mode)
121
- Fopen.call(file, mode)
122
- end
123
-
124
- def fputs(str, stream)
125
- Fputs.call(str, stream)
126
- end
127
-
128
- def fputws(str, stream)
129
- Fputws.call(str, stream)
130
- end
131
-
132
- def getc(stream)
133
- Getc.call(stream)
134
- end
135
-
136
- def getwc(stream)
137
- Getwc.call(stream)
138
- end
139
-
140
- def open(file, flag, mode)
141
- Open.call(file, flag, mode)
142
- end
143
-
144
- def setmode(fd, mode)
145
- Setmode.call(fd, mode)
146
- end
147
-
148
- def tmpfile()
149
- Tmpfile.call
150
- end
151
-
152
- def tmpfile_s(file_ptr)
153
- Tmpfile_s.call(file_ptr)
154
- end
155
-
156
- def tempnam(dir, prefix)
157
- Tempnam.call(dir, prefix)
158
- end
159
-
160
- def tmpnam(template)
161
- Tmpnam.call(template)
162
- end
163
-
164
- def wopen(file, flag, mode)
165
- Wopen.call(file, flag, mode)
166
- end
167
-
168
- def wfdopen(fd, mode)
169
- Wfdopen.call(fd, mode)
170
- end
171
-
172
- def wfopen(file, mode)
173
- Wfopen.call(file, mode)
174
- end
175
-
176
- def wtempnam(dir, prefix)
177
- Wtempnam.call(dir, prefix)
178
- end
179
-
180
- def wtmpnam(template)
181
- Wtmpnam.call(template)
182
- end
183
60
  end
184
61
  end
185
62
  end
@@ -4,17 +4,21 @@ include Windows
4
4
  module Windows
5
5
  module MSVCRT
6
6
  module String
7
- API.auto_constant = false
8
- API.auto_method = false
9
- API.auto_unicode = false
7
+ API.auto_constant = false # We want multiple versions
8
+ API.auto_method = false # We need to handle 0 & nil explicitly
9
+ API.auto_unicode = false
10
10
 
11
+ Strchr = API.new('strchr', 'PI', 'P', MSVCRT_DLL)
11
12
  Strcmp = API.new('strcmp', 'PP', 'I', MSVCRT_DLL)
12
13
  Strcpy = API.new('strcpy', 'PL', 'L', MSVCRT_DLL)
13
14
  Strcspn = API.new('strcspn', 'PP', 'L', MSVCRT_DLL)
14
15
  Strlen = API.new('strlen', 'P', 'L', MSVCRT_DLL)
15
16
  Strncpy = API.new('strncpy', 'PPL', 'P', MSVCRT_DLL)
17
+ Strpbrk = API.new('strpbrk', 'PP', 'P', MSVCRT_DLL)
16
18
  Strrchr = API.new('strrchr', 'PI', 'P', MSVCRT_DLL)
17
19
  Strrev = API.new('_strrev', 'P', 'P', MSVCRT_DLL)
20
+ Strspn = API.new('strspn', 'PP', 'L', MSVCRT_DLL)
21
+ Strstr = API.new('strstr', 'PP', 'P', MSVCRT_DLL)
18
22
  Strtok = API.new('strtok', 'PP', 'P', MSVCRT_DLL)
19
23
 
20
24
  Mbscmp = API.new('_mbscmp', 'PP', 'I', 'msvcrt')
@@ -33,6 +37,11 @@ module Windows
33
37
  rescue RuntimeError
34
38
  # Do nothing. Not supported on your system.
35
39
  end
40
+
41
+ def strchr(string, char)
42
+ return nil if string == 0 || char == 0
43
+ Strchr.call(string, char)
44
+ end
36
45
 
37
46
  def strcmp(str1, str2)
38
47
  if str1 == 0 || str2 == 0
@@ -59,7 +68,12 @@ module Windows
59
68
  def strncpy(dest, source, count)
60
69
  return nil if source == 0
61
70
  Strncpy.call(dest, source, count)
62
- end
71
+ end
72
+
73
+ def strpbrk(string, charset)
74
+ return nil if string == 0 || charset == 0
75
+ Strpbrk.call(string, charset)
76
+ end
63
77
 
64
78
  def strrchr(string, int)
65
79
  return nil if string == 0
@@ -70,6 +84,16 @@ module Windows
70
84
  return nil if str == 0
71
85
  Strrev.call(str)
72
86
  end
87
+
88
+ def strspn(string, charset)
89
+ return nil if string == 0 || charset == 0
90
+ Strspn.call(string, charset)
91
+ end
92
+
93
+ def strstr(string, search)
94
+ return nil if string == 0 || search == 0
95
+ Strstr.call(string, search)
96
+ end
73
97
 
74
98
  def strtok(token, delimeter)
75
99
  return nil if token == 0 || delimeter == 0
@@ -4,9 +4,9 @@ include Windows
4
4
  module Windows
5
5
  module MSVCRT
6
6
  module Time
7
- API.auto_constant = false
8
- API.auto_method = false
9
- API.auto_unicode = false
7
+ API.auto_constant = false # Avoid name clash with Ruby
8
+ API.auto_method = false
9
+ API.auto_unicode = false
10
10
 
11
11
  Asctime = API.new('asctime', 'P', 'P', MSVCRT_DLL)
12
12
  Clock = API.new('clock', 'V', 'L', MSVCRT_DLL)
data/lib/windows/sound.rb CHANGED
@@ -4,9 +4,9 @@ include Windows
4
4
  module Windows
5
5
  module Sound
6
6
  API.auto_namespace = 'Windows::Sound'
7
- API.auto_constant = false # Because of lowercase method names
7
+ API.auto_constant = true
8
8
  API.auto_method = true
9
- API.auto_unicode = true
9
+ API.auto_unicode = false
10
10
 
11
11
  SND_SYNC = 0x0000 # play synchronously (default)
12
12
  SND_ASYNC = 0x0001 # play asynchronously
@@ -24,15 +24,15 @@ module Windows
24
24
  SND_PURGE = 0x0040 # purge non-static events for task
25
25
  SND_APPLICATION = 0x0080 # look for application specific association
26
26
 
27
- Beep = API.new('Beep', 'LL', 'B')
28
- PlaySound = API.new('PlaySound', 'PPL', 'B', 'winmm')
29
- WaveOutSetVolume = API.new('waveOutSetVolume', 'PL', 'I', 'winmm')
30
- WaveOutGetVolume = API.new('waveOutGetVolume', 'IP', 'I', 'winmm')
31
- WaveOutGetNumDevs = API.new('waveOutGetNumDevs', 'V', 'I', 'winmm')
32
- WaveInGetNumDevs = API.new('waveInGetNumDevs', 'V', 'I', 'winmm')
33
- MidiOutGetNumDevs = API.new('midiOutGetNumDevs', 'V', 'I', 'winmm')
34
- MidiInGetNumDevs = API.new('midiInGetNumDevs', 'V', 'I', 'winmm')
35
- AuxGetNumDevs = API.new('auxGetNumDevs', 'V', 'I', 'winmm')
36
- MixerGetNumDevs = API.new('mixerGetNumDevs', 'V', 'I', 'winmm')
27
+ API.new('Beep', 'LL', 'B')
28
+ API.new('PlaySound', 'PPL', 'B', 'winmm')
29
+ API.new('waveOutSetVolume', 'PL', 'I', 'winmm')
30
+ API.new('waveOutGetVolume', 'LP', 'I', 'winmm')
31
+ API.new('waveOutGetNumDevs', 'V', 'I', 'winmm')
32
+ API.new('waveInGetNumDevs', 'V', 'I', 'winmm')
33
+ API.new('midiOutGetNumDevs', 'V', 'I', 'winmm')
34
+ API.new('midiInGetNumDevs', 'V', 'I', 'winmm')
35
+ API.new('auxGetNumDevs', 'V', 'I', 'winmm')
36
+ API.new('mixerGetNumDevs', 'V', 'I', 'winmm')
37
37
  end
38
38
  end
data/test/tc_handle.rb CHANGED
@@ -26,8 +26,8 @@ class TC_Windows_Handle < Test::Unit::TestCase
26
26
  assert_not_nil(HandleFoo::CloseHandle)
27
27
  assert_not_nil(HandleFoo::DuplicateHandle)
28
28
  assert_not_nil(HandleFoo::GetHandleInformation)
29
- assert_not_nil(HandleFoo::GetOSFHandle)
30
- assert_not_nil(HandleFoo::OpenOSFHandle)
29
+ assert_not_nil(HandleFoo::Get_osfhandle)
30
+ assert_not_nil(HandleFoo::Open_osfhandle)
31
31
  end
32
32
 
33
33
  def teardown
@@ -17,6 +17,10 @@ class TC_Windows_MSVCRT_Buffer < Test::Unit::TestCase
17
17
 
18
18
  def test_method_constants
19
19
  assert_not_nil(BufferFoo::Memcpy)
20
+ assert_not_nil(BufferFoo::MemcpyPLL)
21
+ assert_not_nil(BufferFoo::MemcpyLPL)
22
+ assert_not_nil(BufferFoo::MemcpyLLL)
23
+ assert_not_nil(BufferFoo::MemcpyPPL)
20
24
  assert_not_nil(BufferFoo::Memccpy)
21
25
  assert_not_nil(BufferFoo::Memchr)
22
26
  assert_not_nil(BufferFoo::Memcmp)
@@ -25,7 +29,7 @@ class TC_Windows_MSVCRT_Buffer < Test::Unit::TestCase
25
29
  assert_not_nil(BufferFoo::Memset)
26
30
  assert_not_nil(BufferFoo::Swab)
27
31
  end
28
-
32
+
29
33
  def test_memcpy
30
34
  assert_respond_to(@foo, :memcpy)
31
35
  end
@@ -61,4 +65,4 @@ class TC_Windows_MSVCRT_Buffer < Test::Unit::TestCase
61
65
  def teardown
62
66
  @foo = nil
63
67
  end
64
- end
68
+ end
data/windows-pr.gemspec CHANGED
@@ -2,7 +2,7 @@ require "rubygems"
2
2
 
3
3
  spec = Gem::Specification.new do |gem|
4
4
  gem.name = "windows-pr"
5
- gem.version = "0.8.2"
5
+ gem.version = "0.8.3"
6
6
  gem.author = "Daniel J. Berger"
7
7
  gem.email = "djberg96@gmail.com"
8
8
  gem.homepage = "http://www.rubyforge.org/projects/win32utils"
@@ -19,7 +19,7 @@ spec = Gem::Specification.new do |gem|
19
19
  gem.files.reject! { |fn| fn.include? "CVS" }
20
20
  gem.require_path = "lib"
21
21
  gem.extra_rdoc_files = ["MANIFEST", "README", "CHANGES"]
22
- gem.add_dependency("windows-api", ">= 0.2.2")
22
+ gem.add_dependency("windows-api", ">= 0.2.3")
23
23
  end
24
24
 
25
25
  if $0 == __FILE__
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: windows-pr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.8.3
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: 2008-04-18 00:00:00 -06:00
12
+ date: 2008-04-26 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -19,7 +19,7 @@ dependencies:
19
19
  requirements:
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 0.2.2
22
+ version: 0.2.3
23
23
  version:
24
24
  description: Windows functions and constants bundled via Win32::API
25
25
  email: djberg96@gmail.com