// Copyright (c) 2008 Hartmut Kaiser // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include #include #include "saga-sd.hpp" #include #include /////////////////////////////////////////////////////////////////////////////// static int argc_; void printUsage() { std::cout << "Usage: saga-sd " << std::endl; std::cout << "" << std::endl; std::cout << " Commands: Options:\n" << std::endl; std::cout << " list_services \"\" \"\" \"\"" << std::endl; std::cout << "" << std::endl; std::cout << " Example:" << std::endl; std::cout << " saga-sd list_services \"type = 'org.ogf.saga.service.job' \\" << std::endl; std::cout << " AND name = 'CERN-PROD-rb'\" \"RunningJobs > 10\"" << std::endl; std::cout << "" << std::endl; std::cout << "This is a SAGA-based tool for service discovery."<< std::endl; std::cout << "For additional information, see http://saga.cct.lsu.edu."<< std::endl; } void ExitIfArgcLessThan(int n) { if (argc_ < n) { printUsage(); exit(-1); } } /////////////////////////////////////////////////////////////////////////////// int main (int argc, char* argv[]) { #if !defined(SAGA_HAVE_PACKAGE_SD) std::cerr << "saga-sd: saga has been compiled without the sd " "package, bailing out" << std::endl; #else argc_ = argc; ExitIfArgcLessThan(2); if(!strcmp(argv[1], "list_services")) { ExitIfArgcLessThan(4); if ( argc == 4 ) { list_services(std::string(argv[2]), std::string(argv[3])); } else if ( argc == 5 ) { list_services(std::string(argv[2]), std::string(argv[3]), std::string(argv[4])); } } else { std::cout << "Unknown command: " << std::string(argv[1]) << std::endl; printUsage(); exit(-1); } #endif return 0; }