-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathsds.rb
More file actions
48 lines (40 loc) · 1.36 KB
/
sds.rb
File metadata and controls
48 lines (40 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
# frozen_string_literal: true
require 'openscap/source'
module OpenSCAP
module DS
class Sds
attr_reader :raw
def initialize(param)
@raw = case param
when OpenSCAP::Source
OpenSCAP.ds_sds_session_new_from_source param.raw
when Hash
OpenSCAP.ds_sds_session_new_from_source param[:source].raw
end
OpenSCAP.raise! if @raw.null?
end
def select_checklist(p = {})
source_p = OpenSCAP.ds_sds_session_select_checklist(@raw, p[:datastream_id], p[:component_id], nil)
OpenSCAP::Source.new source_p
end
def select_checklist!(p = {})
checklist = select_checklist(p)
OpenSCAP.raise! if checklist.nil? or checklist.raw.null?
checklist
end
def html_guide(profile = nil)
html = OpenSCAP.ds_sds_session_get_html_guide(@raw, profile)
OpenSCAP.raise! if html.nil?
html
end
def destroy
OpenSCAP.ds_sds_session_free(@raw)
@raw = nil
end
end
end
attach_function :ds_sds_session_new_from_source, [:pointer], :pointer
attach_function :ds_sds_session_free, [:pointer], :void
attach_function :ds_sds_session_select_checklist, %i[pointer string string string], :pointer
attach_function :ds_sds_session_get_html_guide, %i[pointer string], :string
end