chef 0.10.8 → 0.10.10.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- data/distro/arch/etc/rc.d/chef-client +15 -1
- data/distro/common/html/chef-client.8.html +4 -4
- data/distro/common/html/chef-expander.8.html +4 -4
- data/distro/common/html/chef-expanderctl.8.html +4 -4
- data/distro/common/html/chef-server-webui.8.html +4 -4
- data/distro/common/html/chef-server.8.html +4 -4
- data/distro/common/html/chef-solo.8.html +4 -4
- data/distro/common/html/chef-solr.8.html +4 -4
- data/distro/common/html/knife-bootstrap.1.html +6 -10
- data/distro/common/html/knife-client.1.html +4 -4
- data/distro/common/html/knife-configure.1.html +4 -4
- data/distro/common/html/knife-cookbook-site.1.html +6 -6
- data/distro/common/html/knife-cookbook.1.html +4 -4
- data/distro/common/html/knife-data-bag.1.html +4 -4
- data/distro/common/html/knife-environment.1.html +4 -4
- data/distro/common/html/knife-exec.1.html +4 -4
- data/distro/common/html/knife-index.1.html +4 -4
- data/distro/common/html/knife-node.1.html +5 -5
- data/distro/common/html/knife-role.1.html +4 -4
- data/distro/common/html/knife-search.1.html +4 -4
- data/distro/common/html/knife-ssh.1.html +5 -6
- data/distro/common/html/knife-status.1.html +4 -4
- data/distro/common/html/knife-tag.1.html +4 -4
- data/distro/common/html/knife.1.html +7 -8
- data/distro/common/html/shef.1.html +4 -4
- data/distro/common/man/man1/knife-bootstrap.1 +4 -4
- data/distro/common/man/man1/knife-client.1 +1 -1
- data/distro/common/man/man1/knife-configure.1 +1 -1
- data/distro/common/man/man1/knife-cookbook-site.1 +4 -4
- data/distro/common/man/man1/knife-cookbook.1 +1 -1
- data/distro/common/man/man1/knife-data-bag.1 +1 -1
- data/distro/common/man/man1/knife-environment.1 +1 -1
- data/distro/common/man/man1/knife-exec.1 +1 -1
- data/distro/common/man/man1/knife-index.1 +1 -1
- data/distro/common/man/man1/knife-node.1 +2 -2
- data/distro/common/man/man1/knife-role.1 +1 -1
- data/distro/common/man/man1/knife-search.1 +1 -1
- data/distro/common/man/man1/knife-ssh.1 +3 -7
- data/distro/common/man/man1/knife-status.1 +1 -1
- data/distro/common/man/man1/knife-tag.1 +1 -1
- data/distro/common/man/man1/knife.1 +5 -9
- data/distro/common/man/man1/shef.1 +1 -1
- data/distro/common/man/man8/chef-client.8 +1 -1
- data/distro/common/man/man8/chef-expander.8 +1 -1
- data/distro/common/man/man8/chef-expanderctl.8 +1 -1
- data/distro/common/man/man8/chef-server-webui.8 +1 -1
- data/distro/common/man/man8/chef-server.8 +1 -1
- data/distro/common/man/man8/chef-solo.8 +1 -1
- data/distro/common/man/man8/chef-solr.8 +1 -1
- data/distro/common/markdown/man1/knife-bootstrap.mkd +3 -7
- data/distro/common/markdown/man1/knife-cookbook-site.mkd +3 -3
- data/distro/common/markdown/man1/knife-node.mkd +2 -2
- data/distro/common/markdown/man1/knife-ssh.mkd +2 -5
- data/distro/common/markdown/man1/knife.mkd +7 -9
- data/distro/debian/etc/init.d/chef-client +22 -1
- data/distro/redhat/etc/init.d/chef-client +12 -1
- data/distro/windows/service_manager.rb +164 -0
- data/lib/chef/application.rb +12 -6
- data/lib/chef/application/client.rb +4 -3
- data/lib/chef/application/knife.rb +7 -12
- data/lib/chef/application/solo.rb +2 -1
- data/lib/chef/application/windows_service.rb +224 -0
- data/lib/chef/checksum_cache.rb +1 -0
- data/lib/chef/client.rb +3 -16
- data/lib/chef/config.rb +42 -13
- data/lib/chef/cookbook/metadata.rb +1 -1
- data/lib/chef/cookbook/syntax_check.rb +2 -2
- data/lib/chef/cookbook_version.rb +5 -0
- data/lib/chef/daemon.rb +1 -1
- data/lib/chef/exceptions.rb +7 -1
- data/lib/chef/file_access_control.rb +13 -87
- data/lib/chef/file_access_control/unix.rb +119 -0
- data/lib/chef/file_access_control/windows.rb +257 -0
- data/lib/chef/handler/json_file.rb +7 -1
- data/lib/chef/knife.rb +10 -16
- data/lib/chef/knife/bootstrap.rb +15 -8
- data/lib/chef/knife/bootstrap/centos5-gems.erb +1 -1
- data/lib/chef/knife/bootstrap/chef-full.erb +59 -0
- data/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb +1 -0
- data/lib/chef/knife/configure.rb +2 -2
- data/lib/chef/knife/cookbook_site_download.rb +60 -21
- data/lib/chef/knife/cookbook_site_install.rb +16 -21
- data/lib/chef/knife/cookbook_upload.rb +77 -48
- data/lib/chef/knife/core/bootstrap_context.rb +3 -1
- data/lib/chef/knife/core/cookbook_scm_repo.rb +1 -1
- data/lib/chef/knife/core/node_editor.rb +1 -1
- data/lib/chef/knife/core/subcommand_loader.rb +1 -1
- data/lib/chef/knife/core/ui.rb +3 -2
- data/lib/chef/knife/help_topics.rb +1 -1
- data/lib/chef/knife/node_run_list_add.rb +14 -6
- data/lib/chef/knife/node_run_list_remove.rb +3 -3
- data/lib/chef/knife/ssh.rb +32 -13
- data/lib/chef/mash.rb +14 -0
- data/lib/chef/mixin/command.rb +1 -0
- data/lib/chef/mixin/command/unix.rb +5 -0
- data/lib/chef/mixin/convert_to_class_name.rb +2 -0
- data/lib/chef/mixin/deep_merge.rb +40 -18
- data/lib/chef/mixin/enforce_ownership_and_permissions.rb +39 -0
- data/lib/chef/mixin/language.rb +89 -3
- data/lib/chef/mixin/language_include_recipe.rb +8 -4
- data/lib/chef/mixin/path_sanity.rb +67 -0
- data/lib/chef/mixin/recipe_definition_dsl_core.rb +19 -11
- data/lib/chef/mixin/securable.rb +152 -0
- data/lib/chef/mixin/shell_out.rb +1 -1
- data/lib/chef/mixin/template.rb +8 -3
- data/lib/chef/mixins.rb +3 -0
- data/lib/chef/monkey_patches/moneta.rb +50 -0
- data/lib/chef/monkey_patches/string.rb +1 -1
- data/lib/chef/node.rb +2 -1
- data/lib/chef/platform.rb +34 -0
- data/lib/chef/provider.rb +23 -21
- data/lib/chef/provider/cron.rb +17 -12
- data/lib/chef/provider/cron/solaris.rb +6 -18
- data/lib/chef/provider/deploy.rb +14 -15
- data/lib/chef/provider/deploy/timestamped.rb +0 -1
- data/lib/chef/provider/directory.rb +1 -3
- data/lib/chef/provider/execute.rb +2 -2
- data/lib/chef/provider/file.rb +1 -75
- data/lib/chef/provider/git.rb +11 -9
- data/lib/chef/provider/group/gpasswd.rb +14 -9
- data/lib/chef/provider/link.rb +28 -59
- data/lib/chef/provider/mdadm.rb +2 -2
- data/lib/chef/provider/mount/mount.rb +1 -1
- data/lib/chef/provider/package.rb +10 -6
- data/lib/chef/provider/package/apt.rb +3 -1
- data/lib/chef/provider/package/dpkg.rb +1 -1
- data/lib/chef/provider/package/portage.rb +6 -3
- data/lib/chef/provider/package/rubygems.rb +75 -6
- data/lib/chef/provider/package/smartos.rb +84 -0
- data/lib/chef/provider/package/yum-dump.py +3 -2
- data/lib/chef/provider/package/yum.rb +51 -10
- data/lib/chef/provider/remote_directory.rb +24 -3
- data/lib/chef/provider/remote_file.rb +0 -6
- data/lib/chef/provider/route.rb +3 -3
- data/lib/chef/provider/service/debian.rb +2 -2
- data/lib/chef/provider/service/freebsd.rb +1 -1
- data/lib/chef/provider/service/macosx.rb +125 -0
- data/lib/chef/provider/service/windows.rb +5 -1
- data/lib/chef/provider/subversion.rb +10 -7
- data/lib/chef/providers.rb +3 -0
- data/lib/chef/resource.rb +181 -87
- data/lib/chef/resource/apt_package.rb +10 -1
- data/lib/chef/resource/chef_gem.rb +53 -0
- data/lib/chef/resource/conditional.rb +3 -0
- data/lib/chef/resource/cookbook_file.rb +12 -6
- data/lib/chef/resource/cron.rb +9 -0
- data/lib/chef/resource/directory.rb +14 -31
- data/lib/chef/resource/execute.rb +11 -9
- data/lib/chef/resource/file.rb +9 -33
- data/lib/chef/resource/link.rb +13 -8
- data/lib/chef/resource/mdadm.rb +10 -1
- data/lib/chef/resource/remote_directory.rb +13 -2
- data/lib/chef/resource/remote_file.rb +14 -7
- data/lib/chef/resource/smartos_package.rb +36 -0
- data/lib/chef/resource/template.rb +12 -5
- data/lib/chef/resource_platform_map.rb +153 -0
- data/lib/chef/resources.rb +2 -0
- data/lib/chef/rest.rb +55 -10
- data/lib/chef/rest/auth_credentials.rb +1 -0
- data/lib/chef/rest/rest_request.rb +24 -8
- data/lib/chef/role.rb +8 -2
- data/lib/chef/run_list.rb +1 -1
- data/lib/chef/run_list/run_list_expansion.rb +2 -2
- data/lib/chef/run_list/run_list_item.rb +7 -0
- data/lib/chef/runner.rb +4 -0
- data/lib/chef/shef.rb +2 -2
- data/lib/chef/shef/shef_session.rb +4 -5
- data/lib/chef/shell_out.rb +2 -245
- data/lib/chef/util/file_edit.rb +99 -89
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/api.rb +349 -0
- data/lib/chef/win32/api/error.rb +921 -0
- data/lib/chef/win32/api/file.rb +289 -0
- data/lib/chef/win32/api/memory.rb +105 -0
- data/lib/chef/win32/api/process.rb +40 -0
- data/lib/chef/win32/api/psapi.rb +51 -0
- data/lib/chef/win32/api/security.rb +341 -0
- data/lib/chef/win32/api/system.rb +192 -0
- data/lib/chef/win32/api/unicode.rb +178 -0
- data/lib/chef/win32/error.rb +73 -0
- data/lib/chef/win32/file.rb +117 -0
- data/lib/chef/win32/file/info.rb +100 -0
- data/lib/chef/win32/handle.rb +48 -0
- data/lib/chef/win32/memory.rb +101 -0
- data/lib/chef/win32/process.rb +84 -0
- data/lib/chef/win32/security.rb +489 -0
- data/lib/chef/win32/security/ace.rb +125 -0
- data/lib/chef/win32/security/acl.rb +101 -0
- data/lib/chef/win32/security/securable_object.rb +109 -0
- data/lib/chef/win32/security/security_descriptor.rb +93 -0
- data/lib/chef/win32/security/sid.rb +199 -0
- data/lib/chef/win32/security/token.rb +64 -0
- data/lib/chef/win32/unicode.rb +43 -0
- data/lib/chef/win32/version.rb +119 -0
- metadata +104 -158
- data/lib/chef/shell_out/unix.rb +0 -223
- data/lib/chef/shell_out/windows.rb +0 -588
data/lib/chef/util/file_edit.rb
CHANGED
@@ -6,9 +6,9 @@
|
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
7
|
# you may not use this file except in compliance with the License.
|
8
8
|
# You may obtain a copy of the License at
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
11
|
+
#
|
12
12
|
# Unless required by applicable law or agreed to in writing, software
|
13
13
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
14
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
@@ -20,56 +20,62 @@ require 'tempfile'
|
|
20
20
|
|
21
21
|
class Chef
|
22
22
|
class Util
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
23
|
+
class FileEdit
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
attr_accessor :original_pathname, :contents, :file_edited
|
28
|
+
|
29
|
+
public
|
30
|
+
|
31
|
+
def initialize(filepath)
|
32
|
+
@original_pathname = filepath
|
33
|
+
@file_edited = false
|
34
|
+
|
35
|
+
raise ArgumentError, "File doesn't exist" unless File.exist? @original_pathname
|
36
|
+
raise ArgumentError, "File is blank" unless (@contents = File.new(@original_pathname).readlines).length > 0
|
37
|
+
end
|
38
|
+
|
39
|
+
#search the file line by line and match each line with the given regex
|
40
|
+
#if matched, replace the whole line with newline.
|
41
|
+
def search_file_replace_line(regex, newline)
|
42
|
+
search_match(regex, newline, 'r', 1)
|
43
|
+
end
|
44
|
+
|
45
|
+
#search the file line by line and match each line with the given regex
|
46
|
+
#if matched, replace the match (all occurances) with the replace parameter
|
47
|
+
def search_file_replace(regex, replace)
|
48
|
+
search_match(regex, replace, 'r', 2)
|
49
|
+
end
|
50
|
+
|
51
|
+
#search the file line by line and match each line with the given regex
|
52
|
+
#if matched, delete the line
|
53
|
+
def search_file_delete_line(regex)
|
54
|
+
search_match(regex, " ", 'd', 1)
|
55
|
+
end
|
56
|
+
|
57
|
+
#search the file line by line and match each line with the given regex
|
58
|
+
#if matched, delete the match (all occurances) from the line
|
59
|
+
def search_file_delete(regex)
|
60
|
+
search_match(regex, " ", 'd', 2)
|
61
|
+
end
|
62
|
+
|
63
|
+
#search the file line by line and match each line with the given regex
|
64
|
+
#if matched, insert newline after each matching line
|
65
|
+
def insert_line_after_match(regex, newline)
|
66
|
+
search_match(regex, newline, 'i', 1)
|
67
|
+
end
|
68
|
+
|
69
|
+
#search the file line by line and match each line with the given regex
|
70
|
+
#if not matched, insert newline at the end of the file
|
71
|
+
def insert_line_if_no_match(regex, newline)
|
72
|
+
search_match(regex, newline, 'i', 2)
|
73
|
+
end
|
74
|
+
|
75
|
+
#Make a copy of old_file and write new file out (only if file changed)
|
76
|
+
def write_file
|
77
|
+
|
78
|
+
# file_edited is false when there was no match in the whole file and thus no contents have changed.
|
73
79
|
if file_edited
|
74
80
|
backup_pathname = original_pathname + ".old"
|
75
81
|
FileUtils.cp(original_pathname, backup_pathname, :preserve => true)
|
@@ -81,42 +87,46 @@ class Chef
|
|
81
87
|
end
|
82
88
|
end
|
83
89
|
self.file_edited = false
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
90
|
+
end
|
91
|
+
|
92
|
+
private
|
93
|
+
|
94
|
+
#helper method to do the match, replace, delete, and insert operations
|
95
|
+
#command is the switch of delete, replace, and insert ('d', 'r', 'i')
|
96
|
+
#method is to control operation on whole line or only the match (1 for line, 2 for match)
|
97
|
+
def search_match(regex, replace, command, method)
|
98
|
+
|
99
|
+
#convert regex to a Regexp object (if not already is one) and store it in exp.
|
100
|
+
exp = Regexp.new(regex)
|
101
|
+
|
102
|
+
#loop through contents and do the appropriate operation depending on 'command' and 'method'
|
103
|
+
new_contents = []
|
104
|
+
|
105
|
+
contents.each do |line|
|
106
|
+
if line.match(exp)
|
107
|
+
self.file_edited = true
|
108
|
+
case
|
109
|
+
when command == 'r'
|
110
|
+
new_contents << ((method == 1) ? replace : line.gsub!(exp, replace))
|
111
|
+
when command == 'd'
|
112
|
+
if method == 2
|
113
|
+
new_contents << line.gsub!(exp, "")
|
114
|
+
end
|
115
|
+
when command == 'i'
|
116
|
+
new_contents << line
|
117
|
+
new_contents << replace unless method == 2
|
118
|
+
end
|
119
|
+
else
|
120
|
+
new_contents << line
|
121
|
+
end
|
122
|
+
end
|
123
|
+
if command == 'i' && method == 2 && ! file_edited
|
124
|
+
new_contents << replace
|
125
|
+
self.file_edited = true
|
126
|
+
end
|
127
|
+
|
128
|
+
self.contents = new_contents
|
129
|
+
end
|
130
|
+
end
|
121
131
|
end
|
122
132
|
end
|
data/lib/chef/version.rb
CHANGED
@@ -0,0 +1,349 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Seth Chisamore (<schisamo@opscode.com>)
|
3
|
+
# Author:: John Keiser (<jkeiser@opscode.com>)
|
4
|
+
# Copyright:: Copyright 2011 Opscode, Inc.
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
require 'ffi'
|
21
|
+
|
22
|
+
class Chef
|
23
|
+
module Win32
|
24
|
+
module API
|
25
|
+
|
26
|
+
# put shared stuff (like constants) for all raw Win32 API calls
|
27
|
+
def self.extended(host)
|
28
|
+
host.extend FFI::Library
|
29
|
+
host.extend Macros
|
30
|
+
|
31
|
+
host.ffi_convention :stdcall
|
32
|
+
|
33
|
+
# Windows-specific type defs (ms-help://MS.MSDNQTR.v90.en/winprog/winprog/windows_data_types.htm):
|
34
|
+
host.typedef :ushort, :ATOM # Atom ~= Symbol: Atom table stores strings and corresponding identifiers. Application
|
35
|
+
# places a string in an atom table and receives a 16-bit integer, called an atom, that
|
36
|
+
# can be used to access the string. Placed string is called an atom name.
|
37
|
+
# See: http://msdn.microsoft.com/en-us/library/ms648708%28VS.85%29.aspx
|
38
|
+
host.typedef :bool, :BOOL
|
39
|
+
host.typedef :bool, :BOOLEAN
|
40
|
+
host.typedef :uchar, :BYTE # Byte (8 bits). Declared as unsigned char
|
41
|
+
#CALLBACK: K, # Win32.API gem-specific ?? MSDN: #define CALLBACK __stdcall
|
42
|
+
host.typedef :char, :CHAR # 8-bit Windows (ANSI) character. See http://msdn.microsoft.com/en-us/library/dd183415%28VS.85%29.aspx
|
43
|
+
host.typedef :uint32, :COLORREF # Red, green, blue (RGB) color value (32 bits). See COLORREF for more info.
|
44
|
+
host.typedef :uint32, :DWORD # 32-bit unsigned integer. The range is 0 through 4,294,967,295 decimal.
|
45
|
+
host.typedef :uint64, :DWORDLONG # 64-bit unsigned integer. The range is 0 through 18,446,744,073,709,551,615 decimal.
|
46
|
+
host.typedef :ulong, :DWORD_PTR # Unsigned long type for pointer precision. Use when casting a pointer to a long type
|
47
|
+
# to perform pointer arithmetic. (Also commonly used for general 32-bit parameters that have
|
48
|
+
# been extended to 64 bits in 64-bit Windows.) BaseTsd.h: #host.typedef ULONG_PTR DWORD_PTR;
|
49
|
+
host.typedef :uint32, :DWORD32
|
50
|
+
host.typedef :uint64, :DWORD64
|
51
|
+
host.typedef :int, :HALF_PTR # Half the size of a pointer. Use within a structure that contains a pointer and two small fields.
|
52
|
+
# BaseTsd.h: #ifdef (_WIN64) host.typedef int HALF_PTR; #else host.typedef short HALF_PTR;
|
53
|
+
host.typedef :ulong, :HACCEL # (L) Handle to an accelerator table. WinDef.h: #host.typedef HANDLE HACCEL;
|
54
|
+
# See http://msdn.microsoft.com/en-us/library/ms645526%28VS.85%29.aspx
|
55
|
+
host.typedef :ulong, :HANDLE # (L) Handle to an object. WinNT.h: #host.typedef PVOID HANDLE;
|
56
|
+
# todo: Platform-dependent! Need to change to :uint64 for Win64
|
57
|
+
host.typedef :ulong, :HBITMAP # (L) Handle to a bitmap: http://msdn.microsoft.com/en-us/library/dd183377%28VS.85%29.aspx
|
58
|
+
host.typedef :ulong, :HBRUSH # (L) Handle to a brush. http://msdn.microsoft.com/en-us/library/dd183394%28VS.85%29.aspx
|
59
|
+
host.typedef :ulong, :HCOLORSPACE # (L) Handle to a color space. http://msdn.microsoft.com/en-us/library/ms536546%28VS.85%29.aspx
|
60
|
+
host.typedef :ulong, :HCURSOR # (L) Handle to a cursor. http://msdn.microsoft.com/en-us/library/ms646970%28VS.85%29.aspx
|
61
|
+
host.typedef :ulong, :HCONV # (L) Handle to a dynamic data exchange (DDE) conversation.
|
62
|
+
host.typedef :ulong, :HCONVLIST # (L) Handle to a DDE conversation list. HANDLE - L ?
|
63
|
+
host.typedef :ulong, :HDDEDATA # (L) Handle to DDE data (structure?)
|
64
|
+
host.typedef :ulong, :HDC # (L) Handle to a device context (DC). http://msdn.microsoft.com/en-us/library/dd183560%28VS.85%29.aspx
|
65
|
+
host.typedef :ulong, :HDESK # (L) Handle to a desktop. http://msdn.microsoft.com/en-us/library/ms682573%28VS.85%29.aspx
|
66
|
+
host.typedef :ulong, :HDROP # (L) Handle to an internal drop structure.
|
67
|
+
host.typedef :ulong, :HDWP # (L) Handle to a deferred window position structure.
|
68
|
+
host.typedef :ulong, :HENHMETAFILE #(L) Handle to an enhanced metafile. http://msdn.microsoft.com/en-us/library/dd145051%28VS.85%29.aspx
|
69
|
+
host.typedef :uint, :HFILE # (I) Special file handle to a file opened by OpenFile, not CreateFile.
|
70
|
+
# WinDef.h: #host.typedef int HFILE;
|
71
|
+
host.typedef :ulong, :HFONT # (L) Handle to a font. http://msdn.microsoft.com/en-us/library/dd162470%28VS.85%29.aspx
|
72
|
+
host.typedef :ulong, :HGDIOBJ # (L) Handle to a GDI object.
|
73
|
+
host.typedef :ulong, :HGLOBAL # (L) Handle to a global memory block.
|
74
|
+
host.typedef :ulong, :HHOOK # (L) Handle to a hook. http://msdn.microsoft.com/en-us/library/ms632589%28VS.85%29.aspx
|
75
|
+
host.typedef :ulong, :HICON # (L) Handle to an icon. http://msdn.microsoft.com/en-us/library/ms646973%28VS.85%29.aspx
|
76
|
+
host.typedef :ulong, :HINSTANCE # (L) Handle to an instance. This is the base address of the module in memory.
|
77
|
+
# HMODULE and HINSTANCE are the same today, but were different in 16-bit Windows.
|
78
|
+
host.typedef :ulong, :HKEY # (L) Handle to a registry key.
|
79
|
+
host.typedef :ulong, :HKL # (L) Input locale identifier.
|
80
|
+
host.typedef :ulong, :HLOCAL # (L) Handle to a local memory block.
|
81
|
+
host.typedef :ulong, :HMENU # (L) Handle to a menu. http://msdn.microsoft.com/en-us/library/ms646977%28VS.85%29.aspx
|
82
|
+
host.typedef :ulong, :HMETAFILE # (L) Handle to a metafile. http://msdn.microsoft.com/en-us/library/dd145051%28VS.85%29.aspx
|
83
|
+
host.typedef :ulong, :HMODULE # (L) Handle to an instance. Same as HINSTANCE today, but was different in 16-bit Windows.
|
84
|
+
host.typedef :ulong, :HMONITOR # (L) Рandle to a display monitor. WinDef.h: if(WINVER >= 0x0500) host.typedef HANDLE HMONITOR;
|
85
|
+
host.typedef :ulong, :HPALETTE # (L) Handle to a palette.
|
86
|
+
host.typedef :ulong, :HPEN # (L) Handle to a pen. http://msdn.microsoft.com/en-us/library/dd162786%28VS.85%29.aspx
|
87
|
+
host.typedef :long, :HRESULT # Return code used by COM interfaces. For more info, Structure of the COM Error Codes.
|
88
|
+
# To test an HRESULT value, use the FAILED and SUCCEEDED macros.
|
89
|
+
host.typedef :ulong, :HRGN # (L) Handle to a region. http://msdn.microsoft.com/en-us/library/dd162913%28VS.85%29.aspx
|
90
|
+
host.typedef :ulong, :HRSRC # (L) Handle to a resource.
|
91
|
+
host.typedef :ulong, :HSZ # (L) Handle to a DDE string.
|
92
|
+
host.typedef :ulong, :HWINSTA # (L) Handle to a window station. http://msdn.microsoft.com/en-us/library/ms687096%28VS.85%29.aspx
|
93
|
+
host.typedef :ulong, :HWND # (L) Handle to a window. http://msdn.microsoft.com/en-us/library/ms632595%28VS.85%29.aspx
|
94
|
+
host.typedef :int, :INT # 32-bit signed integer. The range is -2147483648 through 2147483647 decimal.
|
95
|
+
host.typedef :int, :INT_PTR # Signed integer type for pointer precision. Use when casting a pointer to an integer
|
96
|
+
# to perform pointer arithmetic. BaseTsd.h:
|
97
|
+
#if defined(_WIN64) host.typedef __int64 INT_PTR; #else host.typedef int INT_PTR;
|
98
|
+
host.typedef :int32, :INT32 # 32-bit signed integer. The range is -2,147,483,648 through +...647 decimal.
|
99
|
+
host.typedef :int64, :INT64 # 64-bit signed integer. The range is –9,223,372,036,854,775,808 through +...807
|
100
|
+
host.typedef :ushort, :LANGID # Language identifier. For more information, see Locales. WinNT.h: #host.typedef WORD LANGID;
|
101
|
+
# See http://msdn.microsoft.com/en-us/library/dd318716%28VS.85%29.aspx
|
102
|
+
host.typedef :uint32, :LCID # Locale identifier. For more information, see Locales.
|
103
|
+
host.typedef :uint32, :LCTYPE # Locale information type. For a list, see Locale Information Constants.
|
104
|
+
host.typedef :uint32, :LGRPID # Language group identifier. For a list, see EnumLanguageGroupLocales.
|
105
|
+
host.typedef :long, :LONG # 32-bit signed integer. The range is -2,147,483,648 through +...647 decimal.
|
106
|
+
host.typedef :int32, :LONG32 # 32-bit signed integer. The range is -2,147,483,648 through +...647 decimal.
|
107
|
+
host.typedef :int64, :LONG64 # 64-bit signed integer. The range is –9,223,372,036,854,775,808 through +...807
|
108
|
+
host.typedef :int64, :LONGLONG # 64-bit signed integer. The range is –9,223,372,036,854,775,808 through +...807
|
109
|
+
host.typedef :long, :LONG_PTR # Signed long type for pointer precision. Use when casting a pointer to a long to
|
110
|
+
# perform pointer arithmetic. BaseTsd.h:
|
111
|
+
#if defined(_WIN64) host.typedef __int64 LONG_PTR; #else host.typedef long LONG_PTR;
|
112
|
+
host.typedef :long, :LPARAM # Message parameter. WinDef.h as follows: #host.typedef LONG_PTR LPARAM;
|
113
|
+
host.typedef :pointer, :LPBOOL # Pointer to a BOOL. WinDef.h as follows: #host.typedef BOOL far *LPBOOL;
|
114
|
+
host.typedef :pointer, :LPBYTE # Pointer to a BYTE. WinDef.h as follows: #host.typedef BYTE far *LPBYTE;
|
115
|
+
host.typedef :pointer, :LPCOLORREF # Pointer to a COLORREF value. WinDef.h as follows: #host.typedef DWORD *LPCOLORREF;
|
116
|
+
host.typedef :pointer, :LPCSTR # Pointer to a constant null-terminated string of 8-bit Windows (ANSI) characters.
|
117
|
+
# See Character Sets Used By Fonts. http://msdn.microsoft.com/en-us/library/dd183415%28VS.85%29.aspx
|
118
|
+
host.typedef :pointer, :LPCTSTR # An LPCWSTR if UNICODE is defined, an LPCSTR otherwise.
|
119
|
+
host.typedef :pointer, :LPCVOID # Pointer to a constant of any type. WinDef.h as follows: host.typedef CONST void *LPCVOID;
|
120
|
+
host.typedef :pointer, :LPCWSTR # Pointer to a constant null-terminated string of 16-bit Unicode characters.
|
121
|
+
host.typedef :pointer, :LPDWORD # Pointer to a DWORD. WinDef.h as follows: host.typedef DWORD *LPDWORD;
|
122
|
+
host.typedef :pointer, :LPHANDLE # Pointer to a HANDLE. WinDef.h as follows: host.typedef HANDLE *LPHANDLE;
|
123
|
+
host.typedef :pointer, :LPINT # Pointer to an INT.
|
124
|
+
host.typedef :pointer, :LPLONG # Pointer to an LONG.
|
125
|
+
host.typedef :pointer, :LPSECURITY_ATTRIBUTES # Pointer to SECURITY_ATTRIBUTES struct
|
126
|
+
host.typedef :pointer, :LPSTR # Pointer to a null-terminated string of 8-bit Windows (ANSI) characters.
|
127
|
+
host.typedef :pointer, :LPTSTR # An LPWSTR if UNICODE is defined, an LPSTR otherwise.
|
128
|
+
host.typedef :pointer, :LPVOID # Pointer to any type.
|
129
|
+
host.typedef :pointer, :LPWORD # Pointer to a WORD.
|
130
|
+
host.typedef :pointer, :LPWSTR # Pointer to a null-terminated string of 16-bit Unicode characters.
|
131
|
+
host.typedef :long, :LRESULT # Signed result of message processing. WinDef.h: host.typedef LONG_PTR LRESULT;
|
132
|
+
host.typedef :pointer, :LPWIN32_FIND_DATA # Pointer to WIN32_FIND_DATA struct
|
133
|
+
host.typedef :pointer, :LPBY_HANDLE_FILE_INFORMATION # Point to a BY_HANDLE_FILE_INFORMATION struct
|
134
|
+
host.typedef :pointer, :PBOOL # Pointer to a BOOL.
|
135
|
+
host.typedef :pointer, :PBOOLEAN # Pointer to a BOOL.
|
136
|
+
host.typedef :pointer, :PBYTE # Pointer to a BYTE.
|
137
|
+
host.typedef :pointer, :PCHAR # Pointer to a CHAR.
|
138
|
+
host.typedef :pointer, :PCSTR # Pointer to a constant null-terminated string of 8-bit Windows (ANSI) characters.
|
139
|
+
host.typedef :pointer, :PCTSTR # A PCWSTR if UNICODE is defined, a PCSTR otherwise.
|
140
|
+
host.typedef :pointer, :PCWSTR # Pointer to a constant null-terminated string of 16-bit Unicode characters.
|
141
|
+
host.typedef :pointer, :PDWORD # Pointer to a DWORD.
|
142
|
+
host.typedef :pointer, :PDWORDLONG # Pointer to a DWORDLONG.
|
143
|
+
host.typedef :pointer, :PDWORD_PTR # Pointer to a DWORD_PTR.
|
144
|
+
host.typedef :pointer, :PDWORD32 # Pointer to a DWORD32.
|
145
|
+
host.typedef :pointer, :PDWORD64 # Pointer to a DWORD64.
|
146
|
+
host.typedef :pointer, :PFLOAT # Pointer to a FLOAT.
|
147
|
+
host.typedef :pointer, :PHALF_PTR # Pointer to a HALF_PTR.
|
148
|
+
host.typedef :pointer, :PHANDLE # Pointer to a HANDLE.
|
149
|
+
host.typedef :pointer, :PHKEY # Pointer to an HKEY.
|
150
|
+
host.typedef :pointer, :PINT # Pointer to an INT.
|
151
|
+
host.typedef :pointer, :PINT_PTR # Pointer to an INT_PTR.
|
152
|
+
host.typedef :pointer, :PINT32 # Pointer to an INT32.
|
153
|
+
host.typedef :pointer, :PINT64 # Pointer to an INT64.
|
154
|
+
host.typedef :pointer, :PLCID # Pointer to an LCID.
|
155
|
+
host.typedef :pointer, :PLONG # Pointer to a LONG.
|
156
|
+
host.typedef :pointer, :PLONGLONG # Pointer to a LONGLONG.
|
157
|
+
host.typedef :pointer, :PLONG_PTR # Pointer to a LONG_PTR.
|
158
|
+
host.typedef :pointer, :PLONG32 # Pointer to a LONG32.
|
159
|
+
host.typedef :pointer, :PLONG64 # Pointer to a LONG64.
|
160
|
+
host.typedef :pointer, :PLUID # Pointer to a LUID.
|
161
|
+
host.typedef :pointer, :POINTER_32 # 32-bit pointer. On a 32-bit system, this is a native pointer. On a 64-bit system, this is a truncated 64-bit pointer.
|
162
|
+
host.typedef :pointer, :POINTER_64 # 64-bit pointer. On a 64-bit system, this is a native pointer. On a 32-bit system, this is a sign-extended 32-bit pointer.
|
163
|
+
host.typedef :pointer, :POINTER_SIGNED # A signed pointer.
|
164
|
+
host.typedef :pointer, :POINTER_UNSIGNED # An unsigned pointer.
|
165
|
+
host.typedef :pointer, :PSHORT # Pointer to a SHORT.
|
166
|
+
host.typedef :pointer, :PSIZE_T # Pointer to a SIZE_T.
|
167
|
+
host.typedef :pointer, :PSSIZE_T # Pointer to a SSIZE_T.
|
168
|
+
host.typedef :pointer, :PSTR # Pointer to a null-terminated string of 8-bit Windows (ANSI) characters. For more information, see Character Sets Used By Fonts.
|
169
|
+
host.typedef :pointer, :PTBYTE # Pointer to a TBYTE.
|
170
|
+
host.typedef :pointer, :PTCHAR # Pointer to a TCHAR.
|
171
|
+
host.typedef :pointer, :PTSTR # A PWSTR if UNICODE is defined, a PSTR otherwise.
|
172
|
+
host.typedef :pointer, :PUCHAR # Pointer to a UCHAR.
|
173
|
+
host.typedef :pointer, :PUHALF_PTR # Pointer to a UHALF_PTR.
|
174
|
+
host.typedef :pointer, :PUINT # Pointer to a UINT.
|
175
|
+
host.typedef :pointer, :PUINT_PTR # Pointer to a UINT_PTR.
|
176
|
+
host.typedef :pointer, :PUINT32 # Pointer to a UINT32.
|
177
|
+
host.typedef :pointer, :PUINT64 # Pointer to a UINT64.
|
178
|
+
host.typedef :pointer, :PULONG # Pointer to a ULONG.
|
179
|
+
host.typedef :pointer, :PULONGLONG # Pointer to a ULONGLONG.
|
180
|
+
host.typedef :pointer, :PULONG_PTR # Pointer to a ULONG_PTR.
|
181
|
+
host.typedef :pointer, :PULONG32 # Pointer to a ULONG32.
|
182
|
+
host.typedef :pointer, :PULONG64 # Pointer to a ULONG64.
|
183
|
+
host.typedef :pointer, :PUSHORT # Pointer to a USHORT.
|
184
|
+
host.typedef :pointer, :PVOID # Pointer to any type.
|
185
|
+
host.typedef :pointer, :PWCHAR # Pointer to a WCHAR.
|
186
|
+
host.typedef :pointer, :PWORD # Pointer to a WORD.
|
187
|
+
host.typedef :pointer, :PWSTR # Pointer to a null- terminated string of 16-bit Unicode characters.
|
188
|
+
# For more information, see Character Sets Used By Fonts.
|
189
|
+
host.typedef :ulong, :SC_HANDLE # (L) Handle to a service control manager database.
|
190
|
+
# See SCM Handles http://msdn.microsoft.com/en-us/library/ms685104%28VS.85%29.aspx
|
191
|
+
host.typedef :pointer, :SC_LOCK # Lock to a service control manager database. For more information, see SCM Handles.
|
192
|
+
host.typedef :ulong, :SERVICE_STATUS_HANDLE # (L) Handle to a service status value. See SCM Handles.
|
193
|
+
host.typedef :short, :SHORT # A 16-bit integer. The range is –32768 through 32767 decimal.
|
194
|
+
host.typedef :ulong, :SIZE_T # The maximum number of bytes to which a pointer can point. Use for a count that must span the full range of a pointer.
|
195
|
+
host.typedef :long, :SSIZE_T # Signed SIZE_T.
|
196
|
+
host.typedef :char, :TBYTE # A WCHAR if UNICODE is defined, a CHAR otherwise.TCHAR:
|
197
|
+
# http://msdn.microsoft.com/en-us/library/c426s321%28VS.80%29.aspx
|
198
|
+
host.typedef :char, :TCHAR # A WCHAR if UNICODE is defined, a CHAR otherwise.TCHAR:
|
199
|
+
host.typedef :uchar, :UCHAR # Unsigned CHAR (8 bit)
|
200
|
+
host.typedef :uint, :UHALF_PTR # Unsigned HALF_PTR. Use within a structure that contains a pointer and two small fields.
|
201
|
+
host.typedef :uint, :UINT # Unsigned INT. The range is 0 through 4294967295 decimal.
|
202
|
+
host.typedef :uint, :UINT_PTR # Unsigned INT_PTR.
|
203
|
+
host.typedef :uint32, :UINT32 # Unsigned INT32. The range is 0 through 4294967295 decimal.
|
204
|
+
host.typedef :uint64, :UINT64 # Unsigned INT64. The range is 0 through 18446744073709551615 decimal.
|
205
|
+
host.typedef :ulong, :ULONG # Unsigned LONG. The range is 0 through 4294967295 decimal.
|
206
|
+
host.typedef :ulong_long, :ULONGLONG # 64-bit unsigned integer. The range is 0 through 18446744073709551615 decimal.
|
207
|
+
host.typedef :ulong, :ULONG_PTR # Unsigned LONG_PTR.
|
208
|
+
host.typedef :uint32, :ULONG32 # Unsigned INT32. The range is 0 through 4294967295 decimal.
|
209
|
+
host.typedef :uint64, :ULONG64 # Unsigned LONG64. The range is 0 through 18446744073709551615 decimal.
|
210
|
+
host.typedef :pointer, :UNICODE_STRING # Pointer to some string structure??
|
211
|
+
host.typedef :ushort, :USHORT # Unsigned SHORT. The range is 0 through 65535 decimal.
|
212
|
+
host.typedef :ulong_long, :USN # Update sequence number (USN).
|
213
|
+
host.typedef :ushort, :WCHAR # 16-bit Unicode character. For more information, see Character Sets Used By Fonts.
|
214
|
+
# In WinNT.h: host.typedef wchar_t WCHAR;
|
215
|
+
#WINAPI: K, # Calling convention for system functions. WinDef.h: define WINAPI __stdcall
|
216
|
+
host.typedef :ushort, :WORD # 16-bit unsigned integer. The range is 0 through 65535 decimal.
|
217
|
+
host.typedef :uint, :WPARAM # Message parameter. WinDef.h as follows: host.typedef UINT_PTR WPARAM;
|
218
|
+
end
|
219
|
+
|
220
|
+
module Macros
|
221
|
+
|
222
|
+
###############################################
|
223
|
+
# winbase.h
|
224
|
+
###############################################
|
225
|
+
|
226
|
+
def LocalDiscard(pointer)
|
227
|
+
LocalReAlloc(pointer, 0, LMEM_MOVEABLE)
|
228
|
+
end
|
229
|
+
|
230
|
+
###############################################
|
231
|
+
# windef.h
|
232
|
+
###############################################
|
233
|
+
|
234
|
+
# Creates a WORD value by concatenating the specified values.
|
235
|
+
#
|
236
|
+
# http://msdn.microsoft.com/en-us/library/windows/desktop/ms632663(v=VS.85).aspx
|
237
|
+
def MAKEWORD(low, high)
|
238
|
+
((low & 0xff) | (high & 0xff)) << 8
|
239
|
+
end
|
240
|
+
|
241
|
+
# Creates a LONG value by concatenating the specified values.
|
242
|
+
#
|
243
|
+
# http://msdn.microsoft.com/en-us/library/windows/desktop/ms632660(v=vs.85).aspx
|
244
|
+
def MAKELONG(low, high)
|
245
|
+
((low & 0xffff) | (high & 0xffff)) << 16
|
246
|
+
end
|
247
|
+
|
248
|
+
# Retrieves the low-order word from the specified value.
|
249
|
+
#
|
250
|
+
# http://msdn.microsoft.com/en-us/library/windows/desktop/ms632659(v=VS.85).aspx
|
251
|
+
def LOWORD(l)
|
252
|
+
l & 0xffff
|
253
|
+
end
|
254
|
+
|
255
|
+
# Retrieves the high-order word from the specified 32-bit value.
|
256
|
+
#
|
257
|
+
# http://msdn.microsoft.com/en-us/library/windows/desktop/ms632657(v=VS.85).aspx
|
258
|
+
def HIWORD(l)
|
259
|
+
l >> 16
|
260
|
+
end
|
261
|
+
|
262
|
+
# Retrieves the low-order byte from the specified value.
|
263
|
+
#
|
264
|
+
# http://msdn.microsoft.com/en-us/library/windows/desktop/ms632658(v=VS.85).aspx
|
265
|
+
def LOBYTE(w)
|
266
|
+
w & 0xff
|
267
|
+
end
|
268
|
+
|
269
|
+
# Retrieves the high-order byte from the given 16-bit value.
|
270
|
+
#
|
271
|
+
# http://msdn.microsoft.com/en-us/library/windows/desktop/ms632656(v=VS.85).aspx
|
272
|
+
def HIBYTE(w)
|
273
|
+
w >> 8
|
274
|
+
end
|
275
|
+
|
276
|
+
###############################################
|
277
|
+
# winerror.h
|
278
|
+
###############################################
|
279
|
+
|
280
|
+
def IS_ERROR(status)
|
281
|
+
status >> 31 == 1
|
282
|
+
end
|
283
|
+
|
284
|
+
def MAKE_HRESULT(sev, fac, code)
|
285
|
+
sev << 31 | fac << 16 | code
|
286
|
+
end
|
287
|
+
|
288
|
+
def MAKE_SCODE(sev, fac, code)
|
289
|
+
sev << 31 | fac << 16 | code
|
290
|
+
end
|
291
|
+
|
292
|
+
def HRESULT_CODE(hr)
|
293
|
+
hr & 0xFFFF
|
294
|
+
end
|
295
|
+
|
296
|
+
def HRESULT_FACILITY(hr)
|
297
|
+
(hr >> 16) & 0x1fff
|
298
|
+
end
|
299
|
+
|
300
|
+
def HRESULT_FROM_NT(x)
|
301
|
+
x | 0x10000000 # FACILITY_NT_BIT
|
302
|
+
end
|
303
|
+
|
304
|
+
def HRESULT_FROM_WIN32(x)
|
305
|
+
if x <= 0
|
306
|
+
x
|
307
|
+
else
|
308
|
+
(x & 0x0000FFFF) | (7 << 16) | 0x80000000
|
309
|
+
end
|
310
|
+
end
|
311
|
+
|
312
|
+
def HRESULT_SEVERITY(hr)
|
313
|
+
(hr >> 31) & 0x1
|
314
|
+
end
|
315
|
+
|
316
|
+
def FAILED(status)
|
317
|
+
status < 0
|
318
|
+
end
|
319
|
+
|
320
|
+
def SUCCEEDED(status)
|
321
|
+
status >= 0
|
322
|
+
end
|
323
|
+
end
|
324
|
+
|
325
|
+
# Represents a 64-bit unsigned integer value.
|
326
|
+
#
|
327
|
+
# http://msdn.microsoft.com/en-us/library/windows/desktop/aa383742(v=vs.85).aspx
|
328
|
+
def make_uint64(low, high)
|
329
|
+
low + (high * (2**32))
|
330
|
+
end
|
331
|
+
|
332
|
+
# http://blogs.msdn.com/b/oldnewthing/archive/2009/03/06/9461176.aspx
|
333
|
+
# January 1, 1601
|
334
|
+
WIN32_EPOC_MINUS_POSIX_EPOC = 116444736000000000
|
335
|
+
|
336
|
+
# Convert 64-bit FILETIME integer into Time object.
|
337
|
+
#
|
338
|
+
# FILETIME structure contains a 64-bit value representing the number
|
339
|
+
# of 100-nanosecond intervals since January 1, 1601 (UTC).
|
340
|
+
#
|
341
|
+
# http://msdn.microsoft.com/en-us/library/ms724284(VS.85).aspx
|
342
|
+
#
|
343
|
+
def wtime_to_time(wtime)
|
344
|
+
Time.at((wtime - WIN32_EPOC_MINUS_POSIX_EPOC) / 10000000)
|
345
|
+
end
|
346
|
+
|
347
|
+
end
|
348
|
+
end
|
349
|
+
end
|