smi-ffi 0.0.0

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.
data/lib/smi/config.rb ADDED
@@ -0,0 +1,53 @@
1
+ module Smi
2
+ class Config
3
+ class << self
4
+ def init(name = nil)
5
+ Wrapper.smiInit(name)
6
+ end
7
+
8
+ def exit
9
+ Wrapper.smiExit
10
+ end
11
+
12
+ def error_level=(level)
13
+ Wrapper.setSmiErrorLevel(level)
14
+ end
15
+ def get_path
16
+ Wrapper.smiGetPath()
17
+ end
18
+
19
+ def get_flags
20
+ Wrapper.smiGetFlags()
21
+ end
22
+
23
+ def set_flags(flags)
24
+ Wrapper.smiSetFlags(flags)
25
+ end
26
+
27
+ def load_module(m)
28
+ Wrapper.smiLoadModule(m)
29
+ end
30
+
31
+ def is_loaded?(m)
32
+ Wrapper.smiIsLoaded(m)
33
+ end
34
+
35
+ def set_path(p)
36
+ Wrapper.smiSetPath(p)
37
+ end
38
+
39
+ def set_severity(pattern, severity)
40
+ Wrapper.smiSetSeverity(pattern, severity)
41
+ end
42
+
43
+ def read_config(filename, tag)
44
+ Wrapper.smiReadConfig(filename, tag)
45
+ end
46
+
47
+ def set_error_handler(&block)
48
+ Wrapper.smiSetErrorHandler(block)
49
+ end
50
+
51
+ end
52
+ end
53
+ end
data/lib/smi/module.rb ADDED
@@ -0,0 +1,39 @@
1
+ module Smi
2
+ class Module
3
+ extend Forwardable
4
+ attr_accessor :struct, :name, :path, :organization, :contactinfo, :description, :reference, :language, :conformance
5
+ def_delegators :@struct, :name, :path, :organization, :contactinfo, :description, :reference, :language, :conformance
6
+ class << self
7
+ def get_module(m)
8
+ ptr = Smi::Wrapper.smiGetModule(m)
9
+ new(ptr)
10
+ end
11
+ def get_modules
12
+ ptr = Smi::Wrapper.smiGetFirstModule
13
+ m = self.new(ptr)
14
+ modules = [m]
15
+ while ptr = Smi::Wrapper::smiGetNextModule(ptr)
16
+ break if ptr.pointer.null?
17
+ modules << new(ptr)
18
+ end
19
+ modules
20
+ end
21
+ end
22
+
23
+ def initialize(ptr)
24
+ @struct = ptr
25
+ end
26
+
27
+ def get_nodes(nodekind = Wrapper::SMI_NODEKIND_NODE)
28
+ ptr = Wrapper.smiGetFirstNode(@struct.pointer, nodekind)
29
+ n = Smi::Node.new(ptr)
30
+ nodes = [n]
31
+ while ptr = Smi::Wrapper::smiGetNextNode(ptr.pointer, nodekind)
32
+ break if ptr.pointer.null?
33
+ nodes << Smi::Node.new(ptr)
34
+ end
35
+ nodes
36
+ end
37
+
38
+ end
39
+ end
data/lib/smi/node.rb ADDED
@@ -0,0 +1,32 @@
1
+ module Smi
2
+ class Node
3
+ extend Forwardable
4
+ attr_accessor :struct
5
+ def_delegators :@struct, :pointer, :name, :decl, :access, :status, :format, :value, :units, :description, :reference, :indexkind, :implied, :create, :nodekind
6
+ def initialize(ptr)
7
+ @struct = ptr
8
+ end
9
+
10
+ def oid
11
+ @struct.oid.read_array_of_int(@struct.oidlen).join(".")
12
+ end
13
+
14
+ def self.get_node(oid)
15
+ struct = Wrapper::smiGetNode(nil, oid)
16
+ new(struct)
17
+ end
18
+
19
+ def children
20
+ nodes = []
21
+ node = Wrapper::smiGetFirstChildNode(struct.pointer)
22
+ node = self.class.new(node)
23
+ nodes << node
24
+ while !(node = Wrapper::smiGetNextChildNode(node.pointer)).null?
25
+ node = self.class.new(node)
26
+ nodes << node
27
+ end
28
+ nodes
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,412 @@
1
+
2
+ module Smi
3
+ module Wrapper
4
+
5
+ extend NiceFFI::Library
6
+ ffi_lib 'libsmi'
7
+ SMI_LIBRARY_VERSION = "2:27:0"
8
+ SMI_VERSION_MAJOR = 0
9
+ SMI_VERSION_MINOR = 4
10
+ SMI_VERSION_PATCHLEVEL = 8
11
+ SMI_VERSION_STRING = "0.4.8"
12
+ SMI_FLAG_NODESCR = 0x0800
13
+ SMI_FLAG_VIEWALL = 0x1000
14
+ SMI_FLAG_ERRORS = 0x2000
15
+ SMI_FLAG_RECURSIVE = 0x4000
16
+ SMI_FLAG_STATS = 0x8000
17
+ SMI_FLAG_MASK = (0x0800|0x1000|0x8000|0x4000|0x2000)
18
+ SMI_LANGUAGE_UNKNOWN = 0
19
+ SMI_LANGUAGE_SMIV1 = 1
20
+ SMI_LANGUAGE_SMIV2 = 2
21
+ SMI_LANGUAGE_SMING = 3
22
+ SMI_LANGUAGE_SPPI = 4
23
+
24
+ SMI_BASETYPE_UNKNOWN = 0
25
+ SMI_BASETYPE_INTEGER32 = 1
26
+ SMI_BASETYPE_ENUM = 10
27
+ SMI_BASETYPE_BITS = 11
28
+ SMI_BASETYPE_POINTER = 12
29
+ SMI_BASETYPE_OCTETSTRING = 2
30
+ SMI_BASETYPE_OBJECTIDENTIFIER = 3
31
+ SMI_BASETYPE_UNSIGNED32 = 4
32
+ SMI_BASETYPE_INTEGER64 = 5
33
+ SMI_BASETYPE_UNSIGNED64 = 6
34
+ SMI_BASETYPE_FLOAT32 = 7
35
+ SMI_BASETYPE_FLOAT64 = 8
36
+ SMI_BASETYPE_FLOAT128 = 9
37
+
38
+ SMI_BASETYPE_UNSIGNED32_MIN = 0
39
+ SMI_BASETYPE_UNSIGNED64_MIN = 0
40
+ SMI_STATUS_UNKNOWN = 0
41
+ SMI_STATUS_CURRENT = 1
42
+ SMI_STATUS_DEPRECATED = 2
43
+ SMI_STATUS_MANDATORY = 3
44
+ SMI_STATUS_OPTIONAL = 4
45
+ SMI_STATUS_OBSOLETE = 5
46
+
47
+ SMI_ACCESS_UNKNOWN = 0
48
+ SMI_ACCESS_NOT_IMPLEMENTED = 1
49
+ SMI_ACCESS_NOT_ACCESSIBLE = 2
50
+ SMI_ACCESS_NOTIFY = 3
51
+ SMI_ACCESS_READ_ONLY = 4
52
+ SMI_ACCESS_READ_WRITE = 5
53
+ SMI_ACCESS_INSTALL = 6
54
+ SMI_ACCESS_INSTALL_NOTIFY = 7
55
+ SMI_ACCESS_REPORT_ONLY = 8
56
+ SMI_ACCESS_EVENT_ONLY = 9
57
+
58
+ SMI_NODEKIND_UNKNOWN = 0x0000
59
+ SMI_NODEKIND_NODE = 0x0001
60
+ SMI_NODEKIND_SCALAR = 0x0002
61
+ SMI_NODEKIND_TABLE = 0x0004
62
+ SMI_NODEKIND_ROW = 0x0008
63
+ SMI_NODEKIND_COLUMN = 0x0010
64
+ SMI_NODEKIND_NOTIFICATION = 0x0020
65
+ SMI_NODEKIND_GROUP = 0x0040
66
+ SMI_NODEKIND_COMPLIANCE = 0x0080
67
+ SMI_NODEKIND_CAPABILITIES = 0x0100
68
+ SMI_NODEKIND_ANY = 0xffff
69
+ SMI_DECL_UNKNOWN = 0
70
+ SMI_DECL_IMPLICIT_TYPE = 1
71
+ SMI_DECL_TRAPTYPE = 10
72
+ SMI_DECL_OBJECTGROUP = 11
73
+ SMI_DECL_NOTIFICATIONGROUP = 12
74
+ SMI_DECL_MODULECOMPLIANCE = 13
75
+ SMI_DECL_AGENTCAPABILITIES = 14
76
+ SMI_DECL_TEXTUALCONVENTION = 15
77
+ SMI_DECL_MACRO = 16
78
+ SMI_DECL_COMPL_GROUP = 17
79
+ SMI_DECL_COMPL_OBJECT = 18
80
+ SMI_DECL_IMPL_OBJECT = 19
81
+ SMI_DECL_TYPEASSIGNMENT = 2
82
+ SMI_DECL_MODULE = 33
83
+ SMI_DECL_EXTENSION = 34
84
+ SMI_DECL_TYPEDEF = 35
85
+ SMI_DECL_NODE = 36
86
+ SMI_DECL_SCALAR = 37
87
+ SMI_DECL_TABLE = 38
88
+ SMI_DECL_ROW = 39
89
+ SMI_DECL_IMPL_SEQUENCEOF = 4
90
+ SMI_DECL_COLUMN = 40
91
+ SMI_DECL_NOTIFICATION = 41
92
+ SMI_DECL_GROUP = 42
93
+ SMI_DECL_COMPLIANCE = 43
94
+ SMI_DECL_IDENTITY = 44
95
+ SMI_DECL_CLASS = 45
96
+ SMI_DECL_ATTRIBUTE = 46
97
+ SMI_DECL_EVENT = 47
98
+ SMI_DECL_VALUEASSIGNMENT = 5
99
+ SMI_DECL_OBJECTTYPE = 6
100
+ SMI_DECL_OBJECTIDENTITY = 7
101
+ SMI_DECL_MODULEIDENTITY = 8
102
+ SMI_DECL_NOTIFICATIONTYPE = 9
103
+
104
+ SMI_INDEX_UNKNOWN = 0
105
+ SMI_INDEX_INDEX = 1
106
+ SMI_INDEX_AUGMENT = 2
107
+ SMI_INDEX_REORDER = 3
108
+ SMI_INDEX_SPARSE = 4
109
+ SMI_INDEX_EXPAND = 5
110
+
111
+ SMI_RENDER_NUMERIC = 0x01
112
+ SMI_RENDER_NAME = 0x02
113
+ SMI_RENDER_QUALIFIED = 0x04
114
+ SMI_RENDER_FORMAT = 0x08
115
+ SMI_RENDER_PRINTABLE = 0x10
116
+ SMI_RENDER_UNKNOWN = 0x20
117
+ SMI_RENDER_ALL = 0xff
118
+ SMI_UNKNOWN_LABEL = "<unknown>"
119
+
120
+ #FFI::SizeTypes.merge!({FFI::NativeType::FLOAT128 => 16})
121
+ #FFI::add_typedef(FFI::NativeType::FLOAT128, :long_double)
122
+
123
+
124
+
125
+ class SmiValueValue < FFI::Union
126
+ layout(
127
+ :unsigned64, :ulong_long,
128
+ :integer64, :long_long,
129
+ :unsigned32, :ulong,
130
+ :integer32, :long,
131
+ :float32, :float,
132
+ :float64, :double,
133
+ :float128, [:double, 2], #:long_double,
134
+ :oid, :pointer,
135
+ :ptr, :pointer
136
+ )
137
+
138
+ end
139
+
140
+ #puts "size of SmiValueValue = #{SmiValueValue.size}"
141
+ # FIXME: Nested structures are not correctly supported at the moment.
142
+ # Please check the order of the declarations in the structure below.
143
+ class SmiValue < NiceFFI::Struct
144
+ layout(
145
+ :basetype, :int,#enum
146
+ :len, :uint,
147
+ :value, SmiValueValue
148
+ # :padding, [:uint, 2]
149
+ )
150
+ end
151
+ #puts FFI.find_type(:int).size
152
+ #puts FFI.find_type(:uint).size
153
+ #puts "sizeof SmiValue = #{SmiValue.size}"
154
+ class SmiNamedNumber < NiceFFI::Struct
155
+ layout(
156
+ :name, :pointer,
157
+ :value, SmiValue
158
+ )
159
+ end
160
+ class SmiRange < NiceFFI::Struct
161
+ layout(
162
+ :minValue, SmiValue,
163
+ :maxValue, SmiValue
164
+ )
165
+ end
166
+ class SmiModule < NiceFFI::Struct
167
+ layout(
168
+ :name, :string,
169
+ :path, :string,
170
+ :organization, :string,
171
+ :contactinfo, :string,
172
+ :description, :string,
173
+ :reference, :string,
174
+ :language, :int,
175
+ :conformance, :int
176
+ )
177
+
178
+
179
+ end
180
+
181
+ #puts "size SmiModule = #{SmiModule.size}"
182
+ class SmiRevision < NiceFFI::Struct
183
+ layout(
184
+ :date, :time_t,
185
+ :description, :pointer
186
+ )
187
+ end
188
+ class SmiImport < NiceFFI::Struct
189
+ layout(
190
+ :module, :pointer,
191
+ :name, :pointer
192
+ )
193
+
194
+ end
195
+ class SmiMacro < NiceFFI::Struct
196
+ layout(
197
+ :name, :pointer,
198
+ :decl, :int,
199
+ :status, :int,
200
+ :description, :pointer,
201
+ :reference, :pointer,
202
+ :abnf, :pointer
203
+ )
204
+
205
+ end
206
+ class SmiIdentity < NiceFFI::Struct
207
+ layout(
208
+ :name, :pointer,
209
+ :decl, :int,
210
+ :status, :int,
211
+ :description, :pointer,
212
+ :reference, :pointer
213
+ )
214
+
215
+ end
216
+ class SmiType < NiceFFI::Struct
217
+ layout(
218
+ :name, :pointer,
219
+ :basetype, :int,
220
+ :decl, :int,
221
+ :format, :pointer,
222
+ :value, SmiValue,
223
+ :units, :pointer,
224
+ :status, :int,
225
+ :description, :pointer,
226
+ :reference, :pointer
227
+ )
228
+
229
+ end
230
+ class SmiNode < NiceFFI::Struct
231
+ #packed
232
+ #align 4
233
+ layout(
234
+ :name, :string,
235
+ :oidlen, :uint,
236
+ :oid, :pointer,
237
+ :decl, :int, #enum
238
+ :access, :int, #enum
239
+ :status, :int, #enum
240
+ :format, :string,
241
+ :value, SmiValue,
242
+ :units, :pointer,
243
+ :description, :string,
244
+ :reference, :string,
245
+ :indexkind, :int,
246
+ :implied, :int,
247
+ :create, :int,
248
+ :nodekind, :uint )
249
+
250
+ end
251
+
252
+ #puts "size SmiNode = #{SmiNode.size}"
253
+ class SmiElement < NiceFFI::Struct
254
+ layout(
255
+ :dummy, :char
256
+ )
257
+ end
258
+ class SmiOption < NiceFFI::Struct
259
+ layout(
260
+ :description, :pointer
261
+ )
262
+ end
263
+ class SmiRefinement < NiceFFI::Struct
264
+ layout(
265
+ :access, :int,
266
+ :description, :pointer
267
+ )
268
+ end
269
+ class SmiClass < NiceFFI::Struct
270
+ layout(
271
+ :name, :pointer,
272
+ :decl, :int,
273
+ :status, :int,
274
+ :description, :pointer,
275
+ :reference, :pointer
276
+ )
277
+ end
278
+ class SmiAttribute < NiceFFI::Struct
279
+ layout(
280
+ :name, :pointer,
281
+ :basetype, :int,
282
+ :decl, :int,
283
+ :format, :pointer,
284
+ :value, SmiValue,
285
+ :units, :pointer,
286
+ :status, :int,
287
+ :description, :pointer,
288
+ :reference, :pointer,
289
+ :access, :int
290
+ )
291
+ end
292
+ class SmiEvent < NiceFFI::Struct
293
+ layout(
294
+ :name, :pointer,
295
+ :decl, :int,
296
+ :status, :int,
297
+ :description, :pointer,
298
+ :reference, :pointer
299
+ )
300
+ end
301
+ attach_function :smiInit, [ :string ], :int
302
+ attach_function :smiExit, [ ], :void
303
+ attach_function :smiSetErrorLevel, [ :int ], :void
304
+ attach_function :smiGetFlags, [ ], :int
305
+ attach_function :smiSetFlags, [ :int ], :void
306
+ attach_function :smiGetPath, [ ], :string
307
+ attach_function :smiSetPath, [ :string ], :int
308
+ attach_function :smiSetSeverity, [ :string, :int ], :void
309
+ attach_function :smiReadConfig, [ :string, :string ], :int
310
+ attach_function :smiLoadModule, [ :string ], :string
311
+ attach_function :smiIsLoaded, [ :string ], :int
312
+ # attach_function :SmiErrorHandler, [ :string, :int, :int, :string, :string ], :void
313
+ attach_function :smiSetErrorHandler, [ :pointer ], :void
314
+ attach_function :smiGetModule, [ :string ], NiceFFI::TypedPointer(SmiModule)
315
+ attach_function :smiGetFirstModule, [ ], NiceFFI::TypedPointer( SmiModule )
316
+ attach_function :smiGetNextModule, [ :pointer ], NiceFFI::TypedPointer( SmiModule )
317
+ attach_function :smiGetModuleIdentityNode, [ :pointer ], :pointer
318
+ attach_function :smiGetFirstImport, [ :pointer ], :pointer
319
+ attach_function :smiGetNextImport, [ :pointer ], :pointer
320
+ attach_function :smiIsImported, [ :pointer, :pointer, :string ], :int
321
+ attach_function :smiGetFirstRevision, [ :pointer ], :pointer
322
+ attach_function :smiGetNextRevision, [ :pointer ], :pointer
323
+ attach_function :smiGetRevisionLine, [ :pointer ], :int
324
+ attach_function :smiGetFirstIdentity, [ :pointer ], :pointer
325
+ attach_function :smiGetNextIdentity, [ :pointer ], :pointer
326
+ attach_function :smiGetParentIdentity, [ :pointer ], :pointer
327
+ attach_function :smiGetIdentityLine, [ :pointer ], :int
328
+ attach_function :smiGetIdentityModule, [ :pointer ], :pointer
329
+ attach_function :smiGetIdentity, [ :pointer, :string ], :pointer
330
+ attach_function :smiGetType, [ :pointer, :string ], :pointer
331
+ attach_function :smiGetFirstType, [ :pointer ], :pointer
332
+ attach_function :smiGetNextType, [ :pointer ], :pointer
333
+ attach_function :smiGetParentType, [ :pointer ], :pointer
334
+ attach_function :smiGetTypeModule, [ :pointer ], :pointer
335
+ attach_function :smiGetTypeLine, [ :pointer ], :int
336
+ attach_function :smiGetFirstRange, [ :pointer ], :pointer
337
+ attach_function :smiGetNextRange, [ :pointer ], :pointer
338
+ attach_function :smiGetMinMaxRange, [ :pointer, :pointer, :pointer ], :int
339
+ attach_function :smiGetFirstNamedNumber, [ :pointer ], :pointer
340
+ attach_function :smiGetNextNamedNumber, [ :pointer ], :pointer
341
+ attach_function :smiGetFirstClass, [ :pointer ], :pointer
342
+ attach_function :smiGetNextClass, [ :pointer ], :pointer
343
+ attach_function :smiGetParentClass, [ :pointer ], :pointer
344
+ attach_function :smiGetClassModule, [ :pointer ], :pointer
345
+ attach_function :smiGetClass, [ :pointer, :string ], :pointer
346
+ attach_function :smiGetClassLine, [ :pointer ], :int
347
+ attach_function :smiGetAttribute, [ :pointer, :string ], :pointer
348
+ attach_function :smiGetFirstAttribute, [ :pointer ], :pointer
349
+ attach_function :smiGetNextAttribute, [ :pointer ], :pointer
350
+ attach_function :smiGetAttributeParentType, [ :pointer ], :pointer
351
+ attach_function :smiGetAttributeParentClass, [ :pointer ], :pointer
352
+ attach_function :smiGetFirstUniqueAttribute, [ :pointer ], :pointer
353
+ attach_function :smiGetNextUniqueAttribute, [ :pointer ], :pointer
354
+ attach_function :smiIsClassScalar, [ :pointer ], :int
355
+ attach_function :smiGetAttributeFirstNamedNumber, [ :pointer ], :pointer
356
+ attach_function :smiGetAttributeNextNamedNumber, [ :pointer ], :pointer
357
+ attach_function :smiGetAttributeFirstRange, [ :pointer ], :pointer
358
+ attach_function :smiGetAttributeNextRange, [ :pointer ], :pointer
359
+ attach_function :smiGetAttributeLine, [ :pointer ], :int
360
+ #attach_function :smiGetEvent, [ :pointer, :string ], :pointer
361
+ attach_function :smiGetFirstEvent, [ :pointer ], :pointer
362
+ attach_function :smiGetNextEvent, [ :pointer ], :pointer
363
+ attach_function :smiGetEventLine, [ :pointer ], :int
364
+ attach_function :smiGetMacro, [ :pointer, :string ], :pointer
365
+ attach_function :smiGetFirstMacro, [ :pointer ], :pointer
366
+ attach_function :smiGetNextMacro, [ :pointer ], :pointer
367
+ attach_function :smiGetMacroModule, [ :pointer ], :pointer
368
+ attach_function :smiGetMacroLine, [ :pointer ], :int
369
+ attach_function :smiGetNode, [ :pointer, :string ], NiceFFI::TypedPointer(SmiNode)
370
+ attach_function :smiGetNodeByOID, [ :uint, :pointer ], NiceFFI::TypedPointer(SmiNode)
371
+ attach_function :smiGetFirstNode, [ :pointer, :uint ], NiceFFI::TypedPointer(SmiNode)
372
+ attach_function :smiGetNextNode, [ :pointer, :uint ], NiceFFI::TypedPointer(SmiNode)
373
+ attach_function :smiGetParentNode, [ :pointer ], SmiNode.typed_pointer
374
+ attach_function :smiGetRelatedNode, [ :pointer ], SmiNode.typed_pointer
375
+ attach_function :smiGetFirstChildNode, [ :pointer ], NiceFFI::TypedPointer(SmiNode)
376
+ attach_function :smiGetNextChildNode, [ :pointer ], NiceFFI::TypedPointer(SmiNode)
377
+ attach_function :smiGetNodeModule, [ :pointer ], :pointer
378
+ attach_function :smiGetNodeType, [ :pointer ], :pointer
379
+ attach_function :smiGetNodeLine, [ :pointer ], :int
380
+ attach_function :smiGetFirstElement, [ :pointer ], :pointer
381
+ attach_function :smiGetNextElement, [ :pointer ], :pointer
382
+ attach_function :smiGetElementNode, [ :pointer ], :pointer
383
+ attach_function :smiGetFirstOption, [ :pointer ], :pointer
384
+ attach_function :smiGetNextOption, [ :pointer ], :pointer
385
+ attach_function :smiGetOptionNode, [ :pointer ], :pointer
386
+ attach_function :smiGetOptionLine, [ :pointer ], :int
387
+ attach_function :smiGetFirstRefinement, [ :pointer ], :pointer
388
+ attach_function :smiGetNextRefinement, [ :pointer ], :pointer
389
+ attach_function :smiGetRefinementNode, [ :pointer ], :pointer
390
+ attach_function :smiGetRefinementType, [ :pointer ], :pointer
391
+ attach_function :smiGetRefinementWriteType, [ :pointer ], :pointer
392
+ attach_function :smiGetRefinementLine, [ :pointer ], :int
393
+ attach_function :smiGetFirstUniquenessElement, [ :pointer ], :pointer
394
+ attach_function :smiRenderOID, [ :uint, :pointer, :int ], :string
395
+ attach_function :smiRenderValue, [ :pointer, :pointer, :int ], :string
396
+ attach_function :smiRenderNode, [ :pointer, :int ], :string
397
+ attach_function :smiRenderType, [ :pointer, :int ], :string
398
+
399
+ attach_function :smiGetMinSize, [ :pointer ], :uint
400
+ attach_function :smiGetMaxSize, [ :pointer ], :uint
401
+ attach_function :smiUnpack, [ :pointer, :pointer, :uint, :pointer, :pointer ], :int
402
+ #attach_function :smiPack, [ :pointer, :pointer, :int, :pointer, :pointer ], :int
403
+ attach_function :smiAsprintf, [ :pointer, :string, :varargs ], :int
404
+ attach_function :smiVasprintf, [ :pointer, :string, :varargs ], :int
405
+ attach_function :smiMalloc, [ :uint ], :pointer
406
+ attach_function :smiRealloc, [ :pointer, :uint ], :pointer
407
+ attach_function :smiStrdup, [ :string ], :string
408
+ attach_function :smiStrndup, [ :string, :uint ], :string
409
+ attach_function :smiFree, [ :pointer ], :void
410
+
411
+ end
412
+ end
data/lib/smi.rb ADDED
@@ -0,0 +1,25 @@
1
+ require 'forwardable'
2
+ require 'nice-ffi'
3
+ require 'smi/wrapper'
4
+ require 'smi/config'
5
+ require 'smi/module'
6
+ require 'smi/node'
7
+
8
+ #Smi::Wrapper.smiInit(nil)
9
+
10
+ #modules = ["IF-MIB", "RFC1213-MIB"]
11
+
12
+ #modules.each do |m|
13
+ # Smi::Wrapper.smiLoadModule("IF-MIB")
14
+ #end
15
+
16
+
17
+
18
+ module Smi
19
+ def self.translate(name)
20
+ node = Smi::Node.get_node(name)
21
+ index = name.split(node.name).last
22
+ node.oid + index
23
+ end
24
+
25
+ end
data/smi-ffi.gemspec ADDED
@@ -0,0 +1,69 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{smi-ffi}
8
+ s.version = "0.0.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["mixtli"]
12
+ s.date = %q{2010-12-29}
13
+ s.default_executable = %q{smidump.rb}
14
+ s.description = %q{ffi bindings for libsmi}
15
+ s.email = %q{ronmcclain75@gmail.com}
16
+ s.executables = ["smidump.rb"]
17
+ s.extra_rdoc_files = [
18
+ "LICENSE",
19
+ "README.rdoc"
20
+ ]
21
+ s.files = [
22
+ ".document",
23
+ ".gitignore",
24
+ "LICENSE",
25
+ "README.rdoc",
26
+ "Rakefile",
27
+ "VERSION",
28
+ "bin/smidump.rb",
29
+ "c/Makefile",
30
+ "c/a.out",
31
+ "c/test",
32
+ "c/test.c",
33
+ "c/test.o",
34
+ "interface/smi.h",
35
+ "lib/smi.rb",
36
+ "lib/smi/config.rb",
37
+ "lib/smi/module.rb",
38
+ "lib/smi/node.rb",
39
+ "lib/smi/wrapper.rb",
40
+ "smi-ffi.gemspec",
41
+ "spec/mibs/IF-MIB",
42
+ "spec/mibs/RFC1213-MIB",
43
+ "spec/smi-ffi_spec.rb",
44
+ "spec/spec_helper.rb"
45
+ ]
46
+ s.homepage = %q{http://github.com/mixtli/smi-ffi}
47
+ s.rdoc_options = ["--charset=UTF-8"]
48
+ s.require_paths = ["lib"]
49
+ s.rubygems_version = %q{1.3.7}
50
+ s.summary = %q{Ruby Interface to libsmi}
51
+ s.test_files = [
52
+ "spec/smi-ffi_spec.rb",
53
+ "spec/spec_helper.rb"
54
+ ]
55
+
56
+ if s.respond_to? :specification_version then
57
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
58
+ s.specification_version = 3
59
+
60
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
61
+ s.add_development_dependency(%q<rspec>, [">= 2.0.0"])
62
+ else
63
+ s.add_dependency(%q<rspec>, [">= 2.0.0"])
64
+ end
65
+ else
66
+ s.add_dependency(%q<rspec>, [">= 2.0.0"])
67
+ end
68
+ end
69
+