ez most fut, de a logger meg bena
authorTamas Jung <tamasjung@gmail.com>
Wed, 14 Apr 2010 09:38:22 +0000 (11:38 +0200)
committerTamas Jung <tamasjung@gmail.com>
Wed, 14 Apr 2010 09:38:22 +0000 (11:38 +0200)
ruby/test.rb
src/arcclientc.cpp
src/arcclientc.h
src/submit.cpp

index 672d2af..e83dcf4 100644 (file)
@@ -2,14 +2,24 @@ require 'ffi'
 require 'pp'
 
 jobdesc = File.read "/Users/tamas/quick/arc/arex/simple.jsdl"
 require 'pp'
 
 jobdesc = File.read "/Users/tamas/quick/arc/arex/simple.jsdl"
-
-args = "-c ARC1:https://localhost:60000/arex -e".split
+args = [""]#enelkul lemaradt a -c, az optionparser nyilvan levagja
+args += "-c ARC1:https://localhost:60000/arex -e".split
 args << jobdesc
 
 module ArcClientCLibrary
 args << jobdesc
 
 module ArcClientCLibrary
+
+  class SubmitResult < FFI::Struct
+    layout     :message,  :string,\
+                       :job_id,  :string
+  end
+
+
   extend FFI::Library
   extend FFI::Library
+  
   ffi_lib "/Users/tamas/work/iface/grid/ws/gp-arc-client-c/build/Debug/libarcclientc.dylib"
   ffi_lib "/Users/tamas/work/iface/grid/ws/gp-arc-client-c/build/Debug/libarcclientc.dylib"
+  
   attach_function :initialize, [], :string
   attach_function :initialize, [], :string
+  
   attach_function :submit, [:int, :pointer], :pointer
 
 end
   attach_function :submit, [:int, :pointer], :pointer
 
 end
@@ -19,6 +29,10 @@ argv.write_array_of_pointer(args.map {|arg| FFI::MemoryPointer.from_string(arg.t
 
 p "the version is: " + ArcClientCLibrary.initialize
 
 
 p "the version is: " + ArcClientCLibrary.initialize
 
+p "args:" + args.inspect
 result = ArcClientCLibrary.submit(args.size, argv)
 
 result = ArcClientCLibrary.submit(args.size, argv)
 
+p (ArcClientCLibrary::SubmitResult.new(result))[:message].to_s
+p (ArcClientCLibrary::SubmitResult.new(result))[:job_id].to_s
+
 p "Done."
\ No newline at end of file
 p "Done."
\ No newline at end of file
index e710a9f..457c060 100644 (file)
 #include "arcclientc.h"
 #include "logger.h"
 #include "arc_libs.h"
 #include "arcclientc.h"
 #include "logger.h"
 #include "arc_libs.h"
+#include "common_utils.h"
 
 
+#pragma GCC visibility push(default)
+extern "C" {
 
 
-const char* initialize(){
+char* initialize(){
        
        
-       setlocale(LC_ALL, "");//TBD: do we need this?
-       logger = new Arc::Logger(Arc::Logger::getRootLogger(), "arcclientc");
-       //TBD:  
-       Arc::LogStream logcerr(std::cerr);//TBD on the stack?
-       logcerr.setFormat(Arc::ShortFormat);
-       Arc::Logger::getRootLogger().addDestination(logcerr);
-       Arc::Logger::getRootLogger().setThreshold(Arc::WARNING);//TODO: read threshold from env
-       
-       Arc::ArcLocation::Init("");//set ARC_LOCATION !!!!!!
+
        
        
-       return ARCCLIENTC_VERSION;
+       return new_str(ARCCLIENTC_VERSION);
 }
 }
+}      
+#pragma GCC visibility pop
 
 
 
 
index 00e405c..9dc89a9 100644 (file)
@@ -17,7 +17,7 @@
 extern "C" {
 
 
 extern "C" {
 
 
-const char* initialize();
+char* initialize();
        
 }
 
        
 }
 
index d7337bb..981a164 100644 (file)
 extern "C" {
 submit_result_t* submit(int argc, char **argv) {
        
 extern "C" {
 submit_result_t* submit(int argc, char **argv) {
        
+       
+       
+       setlocale(LC_ALL, "");//TBD: do we need this?
+       logger = new Arc::Logger(Arc::Logger::getRootLogger(), "arcclientc");
+       //TBD:
+       
+       
+       
+       Arc::LogStream logcerr(std::cerr);
+       logcerr.setFormat(Arc::ShortFormat);
+       Arc::Logger::getRootLogger().addDestination(logcerr);
+       Arc::Logger::getRootLogger().setThreshold(Arc::DEBUG);
+       
+       
+       
+       /* Arc::LogStream logcerr = Arc::LogStream(std::cerr);//TBD on the stack?
+       logcerr.setFormat(Arc::ShortFormat);
+       Arc::Logger::getRootLogger().addDestination(logcerr);
+
+       Arc::Logger::getRootLogger().setThreshold(Arc::DEBUG);//TODO: read threshold from env */
+       
+       Arc::ArcLocation::Init("/opt/local");//set ARC_LOCATION !!!!!!
+       
+       
+       
+       
+       
+       
        submit_result_t* result = (submit_result_t*)malloc(sizeof(submit_result_t));
        if (!result) {
                return NULL;//TBD: throw sth?
        }
        result->message = NULL;
        result->job_id = NULL;
        submit_result_t* result = (submit_result_t*)malloc(sizeof(submit_result_t));
        if (!result) {
                return NULL;//TBD: throw sth?
        }
        result->message = NULL;
        result->job_id = NULL;
+       
+       
 
        //TODO: what necessary here?
        Arc::OptionParser options(istring("[filename ...]"),
 
        //TODO: what necessary here?
        Arc::OptionParser options(istring("[filename ...]"),
@@ -99,15 +129,13 @@ submit_result_t* submit(int argc, char **argv) {
        
        std::list<std::string> params = options.Parse(argc, argv);
        
        
        std::list<std::string> params = options.Parse(argc, argv);
        
-       std::cout << "conffile:";
-       std::cout << conffile.size();//TODO: clean
+       
        Arc::UserConfig usercfg(conffile);
        if (!usercfg) {
                result->message = new_str("Failed configuration initialization");
        Arc::UserConfig usercfg(conffile);
        if (!usercfg) {
                result->message = new_str("Failed configuration initialization");
-               return result;
+               return result;  
        }
        
        }
        
-       
        if (timeout > 0)
                usercfg.Timeout(timeout);
        
        if (timeout > 0)
                usercfg.Timeout(timeout);