-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathtext.rb
More file actions
46 lines (36 loc) · 1.03 KB
/
text.rb
File metadata and controls
46 lines (36 loc) · 1.03 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
# frozen_string_literal: true
module OpenSCAP
class Text
attr_reader :raw
def initialize
@raw = OpenSCAP.oscap_text_new
end
def text=(str)
OpenSCAP.raise! unless OpenSCAP.oscap_text_set_text(raw, str)
end
def text
OpenSCAP.oscap_text_get_text(raw)
end
def destroy
OpenSCAP.oscap_text_free(raw)
@raw = nil
end
end
class TextList
def initialize(oscap_text_iterator)
@raw = oscap_text_iterator
end
def plaintext(lang = nil)
OpenSCAP.oscap_textlist_get_preferred_plaintext @raw, lang
end
def destroy
OpenSCAP.oscap_text_iterator_free @raw
end
end
attach_function :oscap_text_new, [], :pointer
attach_function :oscap_text_set_text, %i[pointer string], :bool
attach_function :oscap_text_get_text, [:pointer], :string
attach_function :oscap_text_free, [:pointer], :void
attach_function :oscap_textlist_get_preferred_plaintext, %i[pointer string], :string
attach_function :oscap_text_iterator_free, [:pointer], :void
end