windows-pr 0.3.0-mswin32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,61 @@
1
+ #######################################################################
2
+ # synchronize.rb
3
+ #
4
+ # Defines the following functions:
5
+ #
6
+ # CreateEvent()
7
+ # CreateMutex()
8
+ # CreateSemaphore()
9
+ # MsgWaitForMultipleObjects()
10
+ # MsgWaitForMultipleObjectsEx()
11
+ # OpenEvent()
12
+ # OpenMutex()
13
+ # OpenSemaphore()
14
+ # WaitForDebugEvent()
15
+ # WaitForSingleObject()
16
+ # WaitForSingleObjectEx()
17
+ # WaitForMultipleObjects()
18
+ # WaitForMultipleObjectsEx()
19
+ # WaitForInputIdle()
20
+ #
21
+ # Defines the the following constants:
22
+ #
23
+ # WAIT_ABANDONED
24
+ # WAIT_OBJECT_0
25
+ # WAIT_TIMEOUT
26
+ # WAIT_FAILED
27
+ # INFINITE
28
+ #
29
+ # TODO:
30
+ #
31
+ # Add the rest of the synchronization functions.
32
+ #######################################################################
33
+ require "Win32API"
34
+
35
+ module Windows
36
+ module Synchronize
37
+ INFINITE = 0xFFFFFFFF
38
+ WAIT_OBJECT_0 = 0
39
+ WAIT_TIMEOUT = 0x102
40
+ WAIT_ABANDONED = 128
41
+ WAIT_FAILED = 0xFFFFFFFF
42
+
43
+ CreateEvent = Win32API.new('kernel32', 'CreateEvent', 'PIIP', 'L')
44
+ CreateMutex = Win32API.new('kernel32', 'CreateMutex', 'PIP', 'L')
45
+ CreateSemaphore = Win32API.new('kernel32', 'CreateSemaphore', 'PLLP', 'L')
46
+
47
+ MsgWaitForMultipleObjects = Win32API.new('user32', 'MsgWaitForMultipleObjects', 'LPILL', 'L')
48
+ MsgWaitForMultipleObjectsEx = Win32API.new('user32', 'MsgWaitForMultipleObjectsEx', 'LPLLL', 'L')
49
+
50
+ OpenEvent = Win32API.new('kernel32', 'OpenEvent', 'LIP', 'L')
51
+ OpenMutex = Win32API.new('kernel32', 'OpenMutex', 'LIP', 'L')
52
+ OpenSemaphore = Win32API.new('kernel32', 'OpenSemaphore', 'LIP', 'L')
53
+
54
+ WaitForDebugEvent = Win32API.new('kernel32', 'WaitForDebugEvent', 'PL', 'I')
55
+ WaitForMultipleObjects = Win32API.new('kernel32', 'WaitForMultipleObjects', 'LPIL', 'L')
56
+ WaitForMultipleObjectsEx = Win32API.new('kernel32', 'WaitForMultipleObjectsEx', 'LPILI', 'L')
57
+ WaitForSingleObject = Win32API.new('kernel32', 'WaitForSingleObject', 'LL', 'L')
58
+ WaitForSingleObjectEx = Win32API.new('kernel32', 'WaitForSingleObjectEx', 'LLI', 'L')
59
+ WaitForInputIdle = Win32API.new('user32', 'WaitForInputIdle', 'LL', 'L')
60
+ end
61
+ end
data/test/tc_error.rb ADDED
@@ -0,0 +1,57 @@
1
+ #####################################################################
2
+ # tc_error.rb
3
+ #
4
+ # Test case for the Windows::Error module.
5
+ #####################################################################
6
+ base = File.basename(Dir.pwd)
7
+ if base == 'test' || base =~ /windows-pr/
8
+ Dir.chdir '..' if base == 'test'
9
+ $LOAD_PATH.unshift Dir.pwd + '/lib'
10
+ Dir.chdir 'test' rescue nil
11
+ end
12
+
13
+ require "windows/error"
14
+ require "test/unit"
15
+
16
+ class Foo
17
+ include Windows::Error
18
+ end
19
+
20
+ class TC_Windows_Error < Test::Unit::TestCase
21
+
22
+ def setup
23
+ @foo = Foo.new
24
+ end
25
+
26
+ def test_numeric_constants
27
+ assert_equal(0x00000100, Foo::FORMAT_MESSAGE_ALLOCATE_BUFFER)
28
+ assert_equal(0x00000200, Foo::FORMAT_MESSAGE_IGNORE_INSERTS)
29
+ assert_equal(0x00000400, Foo::FORMAT_MESSAGE_FROM_STRING)
30
+ assert_equal(0x00000800, Foo::FORMAT_MESSAGE_FROM_HMODULE)
31
+ assert_equal(0x00001000, Foo::FORMAT_MESSAGE_FROM_SYSTEM)
32
+ assert_equal(0x00002000, Foo::FORMAT_MESSAGE_ARGUMENT_ARRAY)
33
+ assert_equal(0x000000FF, Foo::FORMAT_MESSAGE_MAX_WIDTH_MASK)
34
+ assert_equal(0x0001, Foo::SEM_FAILCRITICALERRORS)
35
+ assert_equal(0x0004, Foo::SEM_NOALIGNMENTFAULTEXCEPT)
36
+ assert_equal(0x0002, Foo::SEM_NOGPFAULTERRORBOX)
37
+ assert_equal(0x8000, Foo::SEM_NOOPENFILEERRORBOX)
38
+ end
39
+
40
+ def test_method_constants
41
+ assert_not_nil(Foo::GetLastError)
42
+ assert_not_nil(Foo::SetLastError)
43
+ assert_not_nil(Foo::SetLastErrorEx)
44
+ assert_not_nil(Foo::SetErrorMode)
45
+ assert_not_nil(Foo::FormatMessage)
46
+ end
47
+
48
+ def test_get_last_error
49
+ assert_respond_to(@foo, :get_last_error)
50
+ assert_nothing_raised{ @foo.get_last_error }
51
+ assert_kind_of(String, @foo.get_last_error)
52
+ end
53
+
54
+ def teardown
55
+ @foo = nil
56
+ end
57
+ end
@@ -0,0 +1,71 @@
1
+ #####################################################################
2
+ # tc_msvcrt_buffer.rb
3
+ #
4
+ # Test case for the Windows::MSVCRT::Buffer module.
5
+ #####################################################################
6
+ base = File.basename(Dir.pwd)
7
+ if base == 'test' || base =~ /windows-pr/
8
+ Dir.chdir '..' if base == 'test'
9
+ $LOAD_PATH.unshift Dir.pwd + '/lib'
10
+ Dir.chdir 'test' rescue nil
11
+ end
12
+
13
+ require "windows/msvcrt/buffer"
14
+ require "test/unit"
15
+
16
+ class Foo
17
+ include Windows::MSVCRT::Buffer
18
+ end
19
+
20
+ class TC_Windows_MSVCRT_Buffer < Test::Unit::TestCase
21
+ def setup
22
+ @foo = Foo.new
23
+ end
24
+
25
+ def test_method_constants
26
+ assert_not_nil(Foo::Memcpy)
27
+ assert_not_nil(Foo::Memccpy)
28
+ assert_not_nil(Foo::Memchr)
29
+ assert_not_nil(Foo::Memcmp)
30
+ assert_not_nil(Foo::Memicmp)
31
+ assert_not_nil(Foo::Memmove)
32
+ assert_not_nil(Foo::Memset)
33
+ assert_not_nil(Foo::Swab)
34
+ end
35
+
36
+ def test_memcpy
37
+ assert_respond_to(@foo, :memcpy)
38
+ end
39
+
40
+ def test_memccpy
41
+ assert_respond_to(@foo, :memccpy)
42
+ end
43
+
44
+ def test_memchr
45
+ assert_respond_to(@foo, :memchr)
46
+ end
47
+
48
+ def test_memcmp
49
+ assert_respond_to(@foo, :memcmp)
50
+ end
51
+
52
+ def test_memicmp
53
+ assert_respond_to(@foo, :memicmp)
54
+ end
55
+
56
+ def test_memmove
57
+ assert_respond_to(@foo, :memmove)
58
+ end
59
+
60
+ def test_memset
61
+ assert_respond_to(@foo, :memset)
62
+ end
63
+
64
+ def test_swab
65
+ assert_respond_to(@foo, :swab)
66
+ end
67
+
68
+ def teardown
69
+ @foo = nil
70
+ end
71
+ end
data/test/tc_path.rb ADDED
@@ -0,0 +1,97 @@
1
+ #####################################################################
2
+ # tc_path.rb
3
+ #
4
+ # Test case for the Windows::Path module.
5
+ #####################################################################
6
+ base = File.basename(Dir.pwd)
7
+ if base == 'test' || base =~ /windows-pr/
8
+ Dir.chdir '..' if base == 'test'
9
+ $LOAD_PATH.unshift Dir.pwd + '/lib'
10
+ Dir.chdir 'test' rescue nil
11
+ end
12
+
13
+ require "windows/path"
14
+ require "test/unit"
15
+
16
+ class Foo
17
+ include Windows::Path
18
+ end
19
+
20
+ class TC_Windows_Path < Test::Unit::TestCase
21
+ def setup
22
+ @foo = Foo.new
23
+ @path = "C:\\"
24
+ end
25
+
26
+ def test_numeric_constants
27
+ assert_equal(0x0000, Foo::GCT_INVALID)
28
+ assert_equal(0x0001, Foo::GCT_LFNCHAR)
29
+ assert_equal(0x0002, Foo::GCT_SHORTCHAR)
30
+ assert_equal(0x0004, Foo::GCT_WILD)
31
+ assert_equal(0x0008, Foo::GCT_SEPARATOR)
32
+ end
33
+
34
+ def test_method_constants
35
+ assert_not_nil(Foo::PathAddBackslash)
36
+ assert_not_nil(Foo::PathAddExtension)
37
+ assert_not_nil(Foo::PathAppend)
38
+ assert_not_nil(Foo::PathBuildRoot)
39
+ assert_not_nil(Foo::PathCanonicalize)
40
+ assert_not_nil(Foo::PathCombine)
41
+ assert_not_nil(Foo::PathCommonPrefix)
42
+ assert_not_nil(Foo::PathCompactPath)
43
+ assert_not_nil(Foo::PathCompactPathEx)
44
+ assert_not_nil(Foo::PathCreateFromUrl)
45
+ assert_not_nil(Foo::PathFileExists)
46
+ assert_not_nil(Foo::PathFindExtension)
47
+ assert_not_nil(Foo::PathFindFileName)
48
+ assert_not_nil(Foo::PathFindNextComponent)
49
+ assert_not_nil(Foo::PathFindOnPath)
50
+ assert_not_nil(Foo::PathFindSuffixArray)
51
+ assert_not_nil(Foo::PathGetArgs)
52
+ assert_not_nil(Foo::PathGetCharType)
53
+ assert_not_nil(Foo::PathGetDriveNumber)
54
+ assert_not_nil(Foo::PathIsContentType)
55
+ assert_not_nil(Foo::PathIsDirectory)
56
+ assert_not_nil(Foo::PathIsDirectoryEmpty)
57
+ assert_not_nil(Foo::PathIsFileSpec)
58
+ #assert_not_nil(Foo::PathIsHTMLFile)
59
+ assert_not_nil(Foo::PathIsLFNFileSpec)
60
+ assert_not_nil(Foo::PathIsNetworkPath)
61
+ assert_not_nil(Foo::PathIsPrefix)
62
+ assert_not_nil(Foo::PathIsRelative)
63
+ assert_not_nil(Foo::PathIsRoot)
64
+ assert_not_nil(Foo::PathIsSameRoot)
65
+ assert_not_nil(Foo::PathIsSystemFolder)
66
+ assert_not_nil(Foo::PathIsUNC)
67
+ assert_not_nil(Foo::PathIsUNCServer)
68
+ assert_not_nil(Foo::PathIsUNCServerShare)
69
+ assert_not_nil(Foo::PathIsURL)
70
+ assert_not_nil(Foo::PathMakePretty)
71
+ assert_not_nil(Foo::PathMakeSystemFolder)
72
+ assert_not_nil(Foo::PathMatchSpec)
73
+ assert_not_nil(Foo::PathParseIconLocation)
74
+ assert_not_nil(Foo::PathQuoteSpaces)
75
+ assert_not_nil(Foo::PathRelativePathTo)
76
+ assert_not_nil(Foo::PathRemoveArgs)
77
+ assert_not_nil(Foo::PathRemoveBackslash)
78
+ assert_not_nil(Foo::PathRemoveBlanks)
79
+ assert_not_nil(Foo::PathRemoveExtension)
80
+ assert_not_nil(Foo::PathRemoveFileSpec)
81
+ assert_not_nil(Foo::PathRenameExtension)
82
+ assert_not_nil(Foo::PathSearchAndQualify)
83
+ assert_not_nil(Foo::PathSetDlgItemPath)
84
+ assert_not_nil(Foo::PathSkipRoot)
85
+ assert_not_nil(Foo::PathStripPath)
86
+ assert_not_nil(Foo::PathStripToRoot)
87
+ assert_not_nil(Foo::PathUndecorate)
88
+ assert_not_nil(Foo::PathUnExpandEnvStrings)
89
+ assert_not_nil(Foo::PathUnmakeSystemFolder)
90
+ assert_not_nil(Foo::PathUnquoteSpaces)
91
+ end
92
+
93
+ def teardown
94
+ @foo = nil
95
+ @path = nil
96
+ end
97
+ end
@@ -0,0 +1,111 @@
1
+ #####################################################################
2
+ # tc_security.rb
3
+ #
4
+ # Test case for the Windows::Security module.
5
+ #####################################################################
6
+ base = File.basename(Dir.pwd)
7
+ if base == 'test' || base =~ /windows-pr/
8
+ Dir.chdir '..' if base == 'test'
9
+ $LOAD_PATH.unshift Dir.pwd + '/lib'
10
+ Dir.chdir 'test' rescue nil
11
+ end
12
+
13
+ require "windows/security"
14
+ require "test/unit"
15
+
16
+ class Foo
17
+ include Windows::Security
18
+ end
19
+
20
+ class TC_Windows_Path < Test::Unit::TestCase
21
+ def setup
22
+ @foo = Foo.new
23
+ end
24
+
25
+ def test_numeric_constants
26
+ assert_equal(2, Foo::ACL_REVISION)
27
+ assert_equal(2, Foo::ACL_REVISION2)
28
+ assert_equal(3, Foo::ACL_REVISION3)
29
+ assert_equal(4, Foo::ACL_REVISION4)
30
+ assert_equal(62, Foo::ALLOW_ACE_LENGTH)
31
+ assert_equal(4, Foo::DACL_SECURITY_INFORMATION)
32
+ assert_equal(4, Foo::SE_DACL_PRESENT)
33
+ assert_equal(20, Foo::SECURITY_DESCRIPTOR_MIN_LENGTH)
34
+ assert_equal(1, Foo::SECURITY_DESCRIPTOR_REVISION)
35
+ assert_equal(4026597376, Foo::GENERIC_RIGHTS_MASK)
36
+ assert_equal(4026531840, Foo::GENERIC_RIGHTS_CHK)
37
+ assert_equal(2097151, Foo::REST_RIGHTS_MASK)
38
+ end
39
+
40
+ def test_method_constants
41
+ assert_not_nil(Foo::AddAce)
42
+ assert_not_nil(Foo::CopySid)
43
+ assert_not_nil(Foo::GetAce)
44
+ assert_not_nil(Foo::GetFileSecurity)
45
+ assert_not_nil(Foo::GetLengthSid)
46
+ assert_not_nil(Foo::GetSecurityDescriptorControl)
47
+ assert_not_nil(Foo::GetSecurityDescriptorDacl)
48
+ assert_not_nil(Foo::InitializeAcl)
49
+ assert_not_nil(Foo::InitializeSecurityDescriptor)
50
+ assert_not_nil(Foo::LookupAccountName)
51
+ assert_not_nil(Foo::LookupAccountSid)
52
+ assert_not_nil(Foo::SetFileSecurity)
53
+ assert_not_nil(Foo::SetSecurityDescriptorDacl)
54
+ end
55
+
56
+ def test_add_ace
57
+ assert_respond_to(@foo, :AddAce)
58
+ end
59
+
60
+ def test_copy_sid
61
+ assert_respond_to(@foo, :CopySid)
62
+ end
63
+
64
+ def test_get_ace
65
+ assert_respond_to(@foo, :GetAce)
66
+ end
67
+
68
+ def test_get_file_security
69
+ assert_respond_to(@foo, :GetFileSecurity)
70
+ end
71
+
72
+ def test_get_length_sid
73
+ assert_respond_to(@foo, :GetLengthSid)
74
+ end
75
+
76
+ def test_security_descriptr_control
77
+ assert_respond_to(@foo, :GetSecurityDescriptorControl)
78
+ end
79
+
80
+ def test_security_descriptor_dacl
81
+ assert_respond_to(@foo, :GetSecurityDescriptorDacl)
82
+ end
83
+
84
+ def test_initialize_acl
85
+ assert_respond_to(@foo, :InitializeAcl)
86
+ end
87
+
88
+ def test_initialize_security_descriptor
89
+ assert_respond_to(@foo, :InitializeSecurityDescriptor)
90
+ end
91
+
92
+ def test_lookup_account_name
93
+ assert_respond_to(@foo, :LookupAccountName)
94
+ end
95
+
96
+ def test_lookup_account_sid
97
+ assert_respond_to(@foo, :LookupAccountSid)
98
+ end
99
+
100
+ def test_set_file_security
101
+ assert_respond_to(@foo, :SetFileSecurity)
102
+ end
103
+
104
+ def test_set_security_descriptor_dacl
105
+ assert_respond_to(@foo, :SetSecurityDescriptorDacl)
106
+ end
107
+
108
+ def teardown
109
+ @foo = nil
110
+ end
111
+ end
@@ -0,0 +1,43 @@
1
+ ##################################################################
2
+ # tc_synchronize.rb
3
+ #
4
+ # Test case for the windows/synchronize package.
5
+ ##################################################################
6
+ base = File.basename(Dir.pwd)
7
+ if base == 'test' || base =~ /windows-pr/
8
+ Dir.chdir '..' if base == 'test'
9
+ $LOAD_PATH.unshift Dir.pwd + '/lib'
10
+ Dir.chdir 'test' rescue nil
11
+ end
12
+
13
+ require "windows/synchronize"
14
+ require "test/unit"
15
+
16
+ class Foo
17
+ include Windows
18
+ end
19
+
20
+ class TC_Windows_Synchronize < Test::Unit::TestCase
21
+ def setup
22
+ @handle = (0.chr * 16).unpack('LLLL')
23
+ @foo = Foo.new
24
+ end
25
+
26
+ def test_numeric_constants
27
+ assert_not_nil(Foo::INFINITE)
28
+ end
29
+
30
+ def test_method_constants
31
+ assert_not_nil(Foo::WaitForSingleObject)
32
+ end
33
+
34
+ def test_wait_for_single_object
35
+ assert_respond_to(@foo, :wait_for_single_object)
36
+ assert_nothing_raised{ @foo.wait_for_single_object(@handle[0], 1) }
37
+ end
38
+
39
+ def teardown
40
+ @foo = nil
41
+ @handle = nil
42
+ end
43
+ end
data/test/ts_all.rb ADDED
@@ -0,0 +1,10 @@
1
+ $LOAD_PATH.unshift(Dir.pwd)
2
+ $LOAD_PATH.unshift(Dir.pwd + '/lib')
3
+ $LOAD_PATH.unshift(Dir.pwd + '/lib/windows')
4
+ $LOAD_PATH.unshift(Dir.pwd + '/lib/windows/msvcrt')
5
+ $LOAD_PATH.unshift(Dir.pwd + '/test')
6
+
7
+ Dir.chdir('test') rescue nil
8
+
9
+ require 'tc_error'
10
+ require 'tc_msvcrt_buffer'
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.8.11
3
+ specification_version: 1
4
+ name: windows-pr
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.3.0
7
+ date: 2006-04-22 00:00:00 -06:00
8
+ summary: Windows functions and constants predefined via Win32API
9
+ require_paths:
10
+ - lib
11
+ email: djberg96@gmail.com
12
+ homepage: http://www.rubyforge.org/projects/win32utils
13
+ rubyforge_project:
14
+ description: Windows functions and constants predefined via Win32API
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: mswin32
26
+ signing_key:
27
+ cert_chain:
28
+ authors:
29
+ - Daniel J. Berger
30
+ files:
31
+ - doc/conversion_guide.txt
32
+ - lib/windows/clipboard.rb
33
+ - lib/windows/device_io.rb
34
+ - lib/windows/error.rb
35
+ - lib/windows/file.rb
36
+ - lib/windows/filesystem.rb
37
+ - lib/windows/handle.rb
38
+ - lib/windows/limits.rb
39
+ - lib/windows/memory.rb
40
+ - lib/windows/path.rb
41
+ - lib/windows/security.rb
42
+ - lib/windows/sound.rb
43
+ - lib/windows/synchronize.rb
44
+ - test/ts_all.rb
45
+ - lib/windows/msvcrt/buffer.rb
46
+ - lib/windows/msvcrt/file.rb
47
+ - test/tc_error.rb
48
+ - test/tc_msvcrt_buffer.rb
49
+ - test/tc_path.rb
50
+ - test/tc_security.rb
51
+ - test/tc_synchronize.rb
52
+ - CHANGES
53
+ - MANIFEST
54
+ - README
55
+ test_files:
56
+ - test/ts_all.rb
57
+ rdoc_options: []
58
+
59
+ extra_rdoc_files:
60
+ - README
61
+ - CHANGES
62
+ executables: []
63
+
64
+ extensions: []
65
+
66
+ requirements: []
67
+
68
+ dependencies: []
69
+