windows-pr 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,73 +1,73 @@
1
- require 'windows/api'
2
-
3
- # This module includes stream I/O, low level I/O, etc.
4
- module Windows
5
- module MSVCRT
6
- module IO
7
- API.auto_namespace = 'Windows::MSVCRT::IO'
8
- API.auto_constant = true
9
- API.auto_method = true
10
- API.auto_unicode = false
11
-
12
- private
13
-
14
- S_IFMT = 0170000 # file type mask
15
- S_IFDIR = 0040000 # directory
16
- S_IFCHR = 0020000 # character special
17
- S_IFIFO = 0010000 # pipe
18
- S_IFREG = 0100000 # regular
19
- S_IREAD = 0000400 # read permission, owner
20
- S_IWRITE = 0000200 # write permission, owner
21
- S_IEXEC = 0000100 # execute/search permission, owner
22
-
23
- SH_DENYNO = 0x40 # deny none mode
24
- SHORT_LIVED = 0x1000 # temporary file storage
25
-
26
- API.new('clearerr', 'I', 'V', MSVCRT_DLL)
27
- API.new('_close', 'I', 'V', MSVCRT_DLL)
28
- API.new('fclose', 'I', 'I', MSVCRT_DLL)
29
- API.new('_fcloseall', 'V', 'I', MSVCRT_DLL)
30
- API.new('_fdopen', 'IP', 'I', MSVCRT_DLL)
31
- API.new('feof', 'I', 'I', MSVCRT_DLL)
32
- API.new('ferror', 'L', 'I', MSVCRT_DLL)
33
- API.new('fflush', 'I', 'I', MSVCRT_DLL)
34
- API.new('fgetc', 'L', 'I', MSVCRT_DLL)
35
- API.new('fgetpos', 'LP', 'I', MSVCRT_DLL)
36
- API.new('fgetwc', 'L', 'I', MSVCRT_DLL)
37
- API.new('fgets', 'PIL', 'P', MSVCRT_DLL)
38
- API.new('fgetws', 'PIL', 'P', MSVCRT_DLL)
39
- API.new('_fileno', 'I', 'I', MSVCRT_DLL)
40
- API.new('_flushall', 'V', 'I', MSVCRT_DLL)
41
- API.new('fopen', 'PP', 'I', MSVCRT_DLL)
42
- API.new('fputs', 'PL', 'I', MSVCRT_DLL)
43
- API.new('fputws', 'PL', 'I', MSVCRT_DLL)
44
- API.new('getc', 'L', 'I', MSVCRT_DLL)
45
- API.new('getwc', 'L', 'L', MSVCRT_DLL)
46
- API.new('_open', 'PII', 'I', MSVCRT_DLL)
47
- API.new('_rmtmp', 'V', 'I', MSVCRT_DLL)
48
- API.new('_setmode', 'II', 'I', MSVCRT_DLL)
49
- API.new('_sopen', 'PIII', 'I', MSVCRT_DLL)
50
- API.new('_tempnam', 'PP', 'P', MSVCRT_DLL)
51
- API.new('tmpfile', 'V', 'L', MSVCRT_DLL)
52
- API.new('tmpnam', 'P', 'P', MSVCRT_DLL)
53
-
54
- # Wide character versions
55
-
56
- API.new('_wopen', 'PII', 'I', MSVCRT_DLL)
57
- API.new('_wfdopen', 'IP', 'I', MSVCRT_DLL)
58
- API.new('_wfopen', 'PPI', 'I', MSVCRT_DLL)
59
- API.new('_wsopen', 'PIII', 'I', MSVCRT_DLL)
60
- API.new('_wtempnam', 'PP', 'P', MSVCRT_DLL)
61
- API.new('_wtmpnam', 'P', 'P', MSVCRT_DLL)
62
-
63
- # VC++ 8.0 or later
64
- begin
65
- API.new('_sopen_s', 'PPIII', 'L', MSVCRT_DLL)
66
- API.new('_tmpfile_s', 'P', 'L', MSVCRT_DLL)
67
- API.new('_wsopen_s', 'PPIII', 'L', MSVCRT_DLL)
68
- rescue Win32::API::LoadLibraryError
69
- # Ignore - you must check for it via 'defined?'
70
- end
71
- end
72
- end
73
- end
1
+ require 'windows/api'
2
+
3
+ # This module includes stream I/O, low level I/O, etc.
4
+ module Windows
5
+ module MSVCRT
6
+ module IO
7
+ API.auto_namespace = 'Windows::MSVCRT::IO'
8
+ API.auto_constant = true
9
+ API.auto_method = true
10
+ API.auto_unicode = false
11
+
12
+ private
13
+
14
+ S_IFMT = 0170000 # file type mask
15
+ S_IFDIR = 0040000 # directory
16
+ S_IFCHR = 0020000 # character special
17
+ S_IFIFO = 0010000 # pipe
18
+ S_IFREG = 0100000 # regular
19
+ S_IREAD = 0000400 # read permission, owner
20
+ S_IWRITE = 0000200 # write permission, owner
21
+ S_IEXEC = 0000100 # execute/search permission, owner
22
+
23
+ SH_DENYNO = 0x40 # deny none mode
24
+ SHORT_LIVED = 0x1000 # temporary file storage
25
+
26
+ API.new('clearerr', 'I', 'V', MSVCRT_DLL)
27
+ API.new('_close', 'I', 'V', MSVCRT_DLL)
28
+ API.new('fclose', 'I', 'I', MSVCRT_DLL)
29
+ API.new('_fcloseall', 'V', 'I', MSVCRT_DLL)
30
+ API.new('_fdopen', 'IP', 'I', MSVCRT_DLL)
31
+ API.new('feof', 'I', 'I', MSVCRT_DLL)
32
+ API.new('ferror', 'L', 'I', MSVCRT_DLL)
33
+ API.new('fflush', 'I', 'I', MSVCRT_DLL)
34
+ API.new('fgetc', 'L', 'I', MSVCRT_DLL)
35
+ API.new('fgetpos', 'LP', 'I', MSVCRT_DLL)
36
+ API.new('fgetwc', 'L', 'I', MSVCRT_DLL)
37
+ API.new('fgets', 'PIL', 'P', MSVCRT_DLL)
38
+ API.new('fgetws', 'PIL', 'P', MSVCRT_DLL)
39
+ API.new('_fileno', 'I', 'I', MSVCRT_DLL)
40
+ API.new('_flushall', 'V', 'I', MSVCRT_DLL)
41
+ API.new('fopen', 'PP', 'I', MSVCRT_DLL)
42
+ API.new('fputs', 'PL', 'I', MSVCRT_DLL)
43
+ API.new('fputws', 'PL', 'I', MSVCRT_DLL)
44
+ API.new('getc', 'L', 'I', MSVCRT_DLL)
45
+ API.new('getwc', 'L', 'L', MSVCRT_DLL)
46
+ API.new('_open', 'PII', 'I', MSVCRT_DLL)
47
+ API.new('_rmtmp', 'V', 'I', MSVCRT_DLL)
48
+ API.new('_setmode', 'II', 'I', MSVCRT_DLL)
49
+ API.new('_sopen', 'PIII', 'I', MSVCRT_DLL)
50
+ API.new('_tempnam', 'PP', 'P', MSVCRT_DLL)
51
+ API.new('tmpfile', 'V', 'L', MSVCRT_DLL)
52
+ API.new('tmpnam', 'P', 'P', MSVCRT_DLL)
53
+
54
+ # Wide character versions
55
+
56
+ API.new('_wopen', 'PII', 'I', MSVCRT_DLL)
57
+ API.new('_wfdopen', 'IP', 'I', MSVCRT_DLL)
58
+ API.new('_wfopen', 'PPI', 'I', MSVCRT_DLL)
59
+ API.new('_wsopen', 'PIII', 'I', MSVCRT_DLL)
60
+ API.new('_wtempnam', 'PP', 'P', MSVCRT_DLL)
61
+ API.new('_wtmpnam', 'P', 'P', MSVCRT_DLL)
62
+
63
+ # VC++ 8.0 or later
64
+ begin
65
+ API.new('_sopen_s', 'PPIII', 'L', MSVCRT_DLL)
66
+ API.new('_tmpfile_s', 'P', 'L', MSVCRT_DLL)
67
+ API.new('_wsopen_s', 'PPIII', 'L', MSVCRT_DLL)
68
+ rescue Win32::API::LoadLibraryError
69
+ # Ignore - you must check for it via 'defined?'
70
+ end
71
+ end
72
+ end
73
+ end
@@ -1,182 +1,182 @@
1
- require 'windows/api'
2
-
3
- module Windows
4
- module MSVCRT
5
- module String
6
- API.auto_constant = false # We want multiple versions
7
- API.auto_method = false # We need to handle 0 & nil explicitly
8
- API.auto_unicode = false
9
-
10
- private
11
-
12
- Strchr = API.new('strchr', 'PI', 'P', MSVCRT_DLL)
13
- Strcmp = API.new('strcmp', 'PP', 'I', MSVCRT_DLL)
14
- Strcpy = API.new('strcpy', 'PL', 'L', MSVCRT_DLL)
15
- Strcspn = API.new('strcspn', 'PP', 'L', MSVCRT_DLL)
16
- Strlen = API.new('strlen', 'P', 'L', MSVCRT_DLL)
17
- Strncpy = API.new('strncpy', 'PPL', 'P', MSVCRT_DLL)
18
- Strpbrk = API.new('strpbrk', 'PP', 'P', MSVCRT_DLL)
19
- Strrchr = API.new('strrchr', 'PI', 'P', MSVCRT_DLL)
20
- Strrev = API.new('_strrev', 'P', 'P', MSVCRT_DLL)
21
- Strspn = API.new('strspn', 'PP', 'L', MSVCRT_DLL)
22
- Strstr = API.new('strstr', 'PP', 'P', MSVCRT_DLL)
23
- Strtok = API.new('strtok', 'PP', 'P', MSVCRT_DLL)
24
-
25
- StrcpyPL = API.new('strcpy', 'PL', 'L', MSVCRT_DLL)
26
- StrcpyPP = API.new('strcpy', 'PP', 'L', MSVCRT_DLL)
27
-
28
- Mbscmp = API.new('_mbscmp', 'PP', 'I', 'msvcrt')
29
- Mbscpy = API.new('_mbscpy', 'PL', 'L', 'msvcrt')
30
- Mbslen = API.new('_mbslen', 'P', 'L', 'msvcrt')
31
- Mbsrev = API.new('_mbsrev', 'P', 'P', 'msvcrt')
32
-
33
- MbscpyPL = API.new('_mbscpy', 'PL', 'L', 'msvcrt')
34
- MbscpyPP = API.new('_mbscpy', 'PP', 'L', 'msvcrt')
35
-
36
- Wcscmp = API.new('wcscmp', 'PP', 'I', MSVCRT_DLL)
37
- Wcscpy = API.new('wcscpy', 'PL', 'L', MSVCRT_DLL)
38
- Wcslen = API.new('wcslen', 'P', 'L', MSVCRT_DLL)
39
- Wcsncpy = API.new('wcsncpy', 'PPL', 'P', MSVCRT_DLL)
40
- Wcsrev = API.new('_wcsrev', 'P', 'P', MSVCRT_DLL)
41
-
42
- WcscpyPL = API.new('wcscpy', 'PL', 'L', MSVCRT_DLL)
43
- WcscpyPP = API.new('wcscpy', 'PP', 'L', MSVCRT_DLL)
44
-
45
- begin
46
- Strtok_s = API.new('strtok_s', 'PPI', 'P', MSVCRT_DLL)
47
- rescue Win32::API::LoadLibraryError
48
- # Do nothing. Not supported on your system.
49
- end
50
-
51
- def strchr(string, char)
52
- return nil if string == 0 || char == 0
53
- Strchr.call(string, char)
54
- end
55
-
56
- def strcmp(str1, str2)
57
- if str1 == 0 || str2 == 0
58
- return nil
59
- end
60
- Strcmp.call(str1, str2)
61
- end
62
-
63
- def strcpy(dest, src)
64
- if src.is_a?(Numeric)
65
- return nil if src == 0
66
- StrcpyPL.call(dest, src)
67
- else
68
- StrcpyPP.call(dest, src)
69
- end
70
- end
71
-
72
- def strlen(string)
73
- return nil if string == 0
74
- Strlen.call(string)
75
- end
76
-
77
- def strcspn(string, charset)
78
- return nil if string == 0
79
- Strcspn.call(string, charset)
80
- end
81
-
82
- def strncpy(dest, source, count)
83
- return nil if source == 0
84
- Strncpy.call(dest, source, count)
85
- end
86
-
87
- def strpbrk(string, charset)
88
- return nil if string == 0 || charset == 0
89
- Strpbrk.call(string, charset)
90
- end
91
-
92
- def strrchr(string, int)
93
- return nil if string == 0
94
- Strrchr.call(string, int)
95
- end
96
-
97
- def strrev(str)
98
- return nil if str == 0
99
- Strrev.call(str)
100
- end
101
-
102
- def strspn(string, charset)
103
- return nil if string == 0 || charset == 0
104
- Strspn.call(string, charset)
105
- end
106
-
107
- def strstr(string, search)
108
- return nil if string == 0 || search == 0
109
- Strstr.call(string, search)
110
- end
111
-
112
- def strtok(token, delimeter)
113
- return nil if token == 0 || delimeter == 0
114
- Strtok.call(token, delimeter)
115
- end
116
-
117
- if defined? Strtok_s
118
- def strtok_s(token, delimeter, context)
119
- return nil if [token, delimter, context].include?(0)
120
- Strtok_s.call(token, delimeter, context)
121
- end
122
- end
123
-
124
- def mbscmp(str1, str2)
125
- if str1 == 0 || str2 == 0
126
- return nil
127
- end
128
- Mbscmp.call(str1, str2)
129
- end
130
-
131
- def mbscpy(dest, src)
132
- if src.is_a?(Numeric)
133
- return nil if src == 0
134
- MbscpyPL.call(dest, src)
135
- else
136
- MbscpyPP.call(dest, src)
137
- end
138
- end
139
-
140
- def mbslen(string)
141
- return nil if string == 0
142
- Mbslen.call(string)
143
- end
144
-
145
- def mbsrev(str)
146
- return nil if str == 0
147
- Mbsrev.call(str)
148
- end
149
-
150
- def wcscmp(str1, str2)
151
- if str1 == 0 || str2 == 0
152
- return nil
153
- end
154
- Wcscmp.call(str1, str2)
155
- end
156
-
157
- def wcscpy(dest, src)
158
- if src.is_a?(Numeric)
159
- return nil if src == 0
160
- WcscpyPL.call(dest, src)
161
- else
162
- WcscpyPP.call(dest, src)
163
- end
164
- end
165
-
166
- def wcslen(string)
167
- return nil if string == 0
168
- Wcslen.call(string)
169
- end
170
-
171
- def wcsncpy(dest, source, count)
172
- return nil if source == 0
173
- Wcsncpy.call(dest, source, count)
174
- end
175
-
176
- def wcsrev(str)
177
- return nil if str == 0
178
- Wcsrev.call(str)
179
- end
180
- end
181
- end
182
- end
1
+ require 'windows/api'
2
+
3
+ module Windows
4
+ module MSVCRT
5
+ module String
6
+ API.auto_constant = false # We want multiple versions
7
+ API.auto_method = false # We need to handle 0 & nil explicitly
8
+ API.auto_unicode = false
9
+
10
+ private
11
+
12
+ Strchr = API.new('strchr', 'PI', 'P', MSVCRT_DLL)
13
+ Strcmp = API.new('strcmp', 'PP', 'I', MSVCRT_DLL)
14
+ Strcpy = API.new('strcpy', 'PL', 'L', MSVCRT_DLL)
15
+ Strcspn = API.new('strcspn', 'PP', 'L', MSVCRT_DLL)
16
+ Strlen = API.new('strlen', 'P', 'L', MSVCRT_DLL)
17
+ Strncpy = API.new('strncpy', 'PPL', 'P', MSVCRT_DLL)
18
+ Strpbrk = API.new('strpbrk', 'PP', 'P', MSVCRT_DLL)
19
+ Strrchr = API.new('strrchr', 'PI', 'P', MSVCRT_DLL)
20
+ Strrev = API.new('_strrev', 'P', 'P', MSVCRT_DLL)
21
+ Strspn = API.new('strspn', 'PP', 'L', MSVCRT_DLL)
22
+ Strstr = API.new('strstr', 'PP', 'P', MSVCRT_DLL)
23
+ Strtok = API.new('strtok', 'PP', 'P', MSVCRT_DLL)
24
+
25
+ StrcpyPL = API.new('strcpy', 'PL', 'L', MSVCRT_DLL)
26
+ StrcpyPP = API.new('strcpy', 'PP', 'L', MSVCRT_DLL)
27
+
28
+ Mbscmp = API.new('_mbscmp', 'PP', 'I', 'msvcrt')
29
+ Mbscpy = API.new('_mbscpy', 'PL', 'L', 'msvcrt')
30
+ Mbslen = API.new('_mbslen', 'P', 'L', 'msvcrt')
31
+ Mbsrev = API.new('_mbsrev', 'P', 'P', 'msvcrt')
32
+
33
+ MbscpyPL = API.new('_mbscpy', 'PL', 'L', 'msvcrt')
34
+ MbscpyPP = API.new('_mbscpy', 'PP', 'L', 'msvcrt')
35
+
36
+ Wcscmp = API.new('wcscmp', 'PP', 'I', MSVCRT_DLL)
37
+ Wcscpy = API.new('wcscpy', 'PL', 'L', MSVCRT_DLL)
38
+ Wcslen = API.new('wcslen', 'P', 'L', MSVCRT_DLL)
39
+ Wcsncpy = API.new('wcsncpy', 'PPL', 'P', MSVCRT_DLL)
40
+ Wcsrev = API.new('_wcsrev', 'P', 'P', MSVCRT_DLL)
41
+
42
+ WcscpyPL = API.new('wcscpy', 'PL', 'L', MSVCRT_DLL)
43
+ WcscpyPP = API.new('wcscpy', 'PP', 'L', MSVCRT_DLL)
44
+
45
+ begin
46
+ Strtok_s = API.new('strtok_s', 'PPI', 'P', MSVCRT_DLL)
47
+ rescue Win32::API::LoadLibraryError
48
+ # Do nothing. Not supported on your system.
49
+ end
50
+
51
+ def strchr(string, char)
52
+ return nil if string == 0 || char == 0
53
+ Strchr.call(string, char)
54
+ end
55
+
56
+ def strcmp(str1, str2)
57
+ if str1 == 0 || str2 == 0
58
+ return nil
59
+ end
60
+ Strcmp.call(str1, str2)
61
+ end
62
+
63
+ def strcpy(dest, src)
64
+ if src.is_a?(Numeric)
65
+ return nil if src == 0
66
+ StrcpyPL.call(dest, src)
67
+ else
68
+ StrcpyPP.call(dest, src)
69
+ end
70
+ end
71
+
72
+ def strlen(string)
73
+ return nil if string == 0
74
+ Strlen.call(string)
75
+ end
76
+
77
+ def strcspn(string, charset)
78
+ return nil if string == 0
79
+ Strcspn.call(string, charset)
80
+ end
81
+
82
+ def strncpy(dest, source, count)
83
+ return nil if source == 0
84
+ Strncpy.call(dest, source, count)
85
+ end
86
+
87
+ def strpbrk(string, charset)
88
+ return nil if string == 0 || charset == 0
89
+ Strpbrk.call(string, charset)
90
+ end
91
+
92
+ def strrchr(string, int)
93
+ return nil if string == 0
94
+ Strrchr.call(string, int)
95
+ end
96
+
97
+ def strrev(str)
98
+ return nil if str == 0
99
+ Strrev.call(str)
100
+ end
101
+
102
+ def strspn(string, charset)
103
+ return nil if string == 0 || charset == 0
104
+ Strspn.call(string, charset)
105
+ end
106
+
107
+ def strstr(string, search)
108
+ return nil if string == 0 || search == 0
109
+ Strstr.call(string, search)
110
+ end
111
+
112
+ def strtok(token, delimeter)
113
+ return nil if token == 0 || delimeter == 0
114
+ Strtok.call(token, delimeter)
115
+ end
116
+
117
+ if defined? Strtok_s
118
+ def strtok_s(token, delimeter, context)
119
+ return nil if [token, delimter, context].include?(0)
120
+ Strtok_s.call(token, delimeter, context)
121
+ end
122
+ end
123
+
124
+ def mbscmp(str1, str2)
125
+ if str1 == 0 || str2 == 0
126
+ return nil
127
+ end
128
+ Mbscmp.call(str1, str2)
129
+ end
130
+
131
+ def mbscpy(dest, src)
132
+ if src.is_a?(Numeric)
133
+ return nil if src == 0
134
+ MbscpyPL.call(dest, src)
135
+ else
136
+ MbscpyPP.call(dest, src)
137
+ end
138
+ end
139
+
140
+ def mbslen(string)
141
+ return nil if string == 0
142
+ Mbslen.call(string)
143
+ end
144
+
145
+ def mbsrev(str)
146
+ return nil if str == 0
147
+ Mbsrev.call(str)
148
+ end
149
+
150
+ def wcscmp(str1, str2)
151
+ if str1 == 0 || str2 == 0
152
+ return nil
153
+ end
154
+ Wcscmp.call(str1, str2)
155
+ end
156
+
157
+ def wcscpy(dest, src)
158
+ if src.is_a?(Numeric)
159
+ return nil if src == 0
160
+ WcscpyPL.call(dest, src)
161
+ else
162
+ WcscpyPP.call(dest, src)
163
+ end
164
+ end
165
+
166
+ def wcslen(string)
167
+ return nil if string == 0
168
+ Wcslen.call(string)
169
+ end
170
+
171
+ def wcsncpy(dest, source, count)
172
+ return nil if source == 0
173
+ Wcsncpy.call(dest, source, count)
174
+ end
175
+
176
+ def wcsrev(str)
177
+ return nil if str == 0
178
+ Wcsrev.call(str)
179
+ end
180
+ end
181
+ end
182
+ end