ez most fut, de a logger meg bena
[gp-arc-client-c.git] / ruby / test.rb
1 require 'ffi'
2 require 'pp'
3
4 jobdesc = File.read "/Users/tamas/quick/arc/arex/simple.jsdl"
5 args = [""]#enelkul lemaradt a -c, az optionparser nyilvan levagja
6 args += "-c ARC1:https://localhost:60000/arex -e".split
7 args << jobdesc
8
9 module ArcClientCLibrary
10
11   class SubmitResult < FFI::Struct
12     layout      :message,  :string,\
13                         :job_id,  :string
14   end
15
16
17   extend FFI::Library
18   
19   ffi_lib "/Users/tamas/work/iface/grid/ws/gp-arc-client-c/build/Debug/libarcclientc.dylib"
20   
21   attach_function :initialize, [], :string
22   
23   attach_function :submit, [:int, :pointer], :pointer
24
25 end
26
27 argv = FFI::MemoryPointer.new(:pointer, args.size)
28 argv.write_array_of_pointer(args.map {|arg| FFI::MemoryPointer.from_string(arg.to_s)})  
29
30 p "the version is: " + ArcClientCLibrary.initialize
31
32 p "args:" + args.inspect
33 result = ArcClientCLibrary.submit(args.size, argv)
34
35 p (ArcClientCLibrary::SubmitResult.new(result))[:message].to_s
36 p (ArcClientCLibrary::SubmitResult.new(result))[:job_id].to_s
37
38 p "Done."