Staf 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/Staf/Staf.rb +97 -0
  2. metadata +67 -0
data/Staf/Staf.rb ADDED
@@ -0,0 +1,97 @@
1
+ require 'dl/import'
2
+ require 'dl/struct'
3
+ require 'singleton'
4
+
5
+ module Staf
6
+ VERSION = "1.0.0"
7
+
8
+ extend DL::Importable
9
+ dlload("libSTAF.so")
10
+
11
+ UIPointer = struct [
12
+ "int value"
13
+ ]
14
+
15
+ CPPointer = struct [
16
+ "char* value"
17
+ ]
18
+
19
+ import("STAFRegister", "unsigned int", ["char*", "unsigned int*"])
20
+ import("STAFUnRegister", "unsigned int", ["unsigned int"])
21
+ import("STAFSubmit", "unsigned int", ["unsigned int", "char*", "char*",
22
+ "char*", "unsigned int", "char **", "unsigned int*"])
23
+
24
+ ###############################################################################
25
+ # Register -- function
26
+ # This function calls StafRegister.
27
+ #
28
+ # Input:
29
+ # name: The name of you connection to register with.
30
+ #
31
+ # Output:
32
+ # returns a hash {'err', 'handle'}, err is the staf return code, and
33
+ # handle is the staf connection handle.
34
+ #
35
+ ###############################################################################
36
+ def Staf.Register(name)
37
+ h = UIPointer.malloc()
38
+ err = nil
39
+
40
+ err = sTAFRegister(name, h)
41
+
42
+ return {"err" => err, "handle" => h.value}
43
+ end
44
+
45
+ ###############################################################################
46
+ # Unregister -- function
47
+ # This function calls StafUnregister.
48
+ #
49
+ # Input:
50
+ # h: the staf handle to unregister.
51
+ #
52
+ # Output:
53
+ # returns the staf error code.
54
+ #
55
+ ###############################################################################
56
+ def Staf.Unregister(h)
57
+ err = nil
58
+
59
+ err = sTAFUnRegister(h)
60
+
61
+ return err
62
+ end
63
+
64
+ ###############################################################################
65
+ # Submit -- function
66
+ # This function calls Staf Submit.
67
+ #
68
+ # Input:
69
+ # h: The staf handle.
70
+ # where: This is where to execute the staf command.
71
+ # service: The staf service to call.
72
+ # request: The request to the staf service.
73
+ #
74
+ # Output:
75
+ # returns a hash {err, result}, the error is a staf error, and the result
76
+ # is the result from the staf service.
77
+ #
78
+ ###############################################################################
79
+ def Staf.Submit(h, where, service, request)
80
+ err = nil
81
+ result = CPPointer.malloc()
82
+ result_len = UIPointer.malloc()
83
+
84
+ err = sTAFSubmit(
85
+ h,
86
+ where,
87
+ service,
88
+ request,
89
+ request.length,
90
+ result,
91
+ result_len)
92
+
93
+ return {'result' => result.value, 'err' => err}
94
+ end
95
+
96
+ end
97
+
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: Staf
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Trampus Richmond
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-11-01 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: A simple ruby module to call staf api functions..
23
+ email: trampus@twistedminds.org
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - Staf/Staf.rb
32
+ has_rdoc: true
33
+ homepage: http://www.twistedminds.org
34
+ licenses: []
35
+
36
+ post_install_message:
37
+ rdoc_options: []
38
+
39
+ require_paths:
40
+ - Staf
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ hash: 3
47
+ segments:
48
+ - 0
49
+ version: "0"
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ hash: 3
56
+ segments:
57
+ - 0
58
+ version: "0"
59
+ requirements: []
60
+
61
+ rubyforge_project: Staf
62
+ rubygems_version: 1.3.7
63
+ signing_key:
64
+ specification_version: 3
65
+ summary: A simple ruby warapper around the staf c api.
66
+ test_files: []
67
+