// Copyright (c) 2008 Ole Weidner // // 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 #include "saga-replica.hpp" #include #include /////////////////////////////////////////////////////////////////////////////// static int argc_; void printUsage() { std::cout << "Usage: saga-replica " << std::endl; std::cout << "" << std::endl; std::cout << " Commands: Options:\n" << std::endl; std::cout << " list_directory " << std::endl; std::cout << " add_directory " << std::endl; std::cout << " remove_directory " << std::endl; std::cout << "" << std::endl; std::cout << " add_lfn " << std::endl; std::cout << " remove_lfn " << std::endl; std::cout << "" << std::endl; std::cout << " list_pfns " << std::endl; std::cout << " add_pfn " << std::endl; std::cout << " remove_pfn " << std::endl; std::cout << "" << std::endl; std::cout << " list_attributes " << std::endl; std::cout << " set_attribute " << std::endl; std::cout << " remove_attribute " << std::endl; std::cout << "" << std::endl; std::cout << " (ldn/lfn url: {any|lfn}://host:port/path) " << std::endl; std::cout << "" << std::endl; std::cout << "This is a SAGA-based tool for replica management."<< 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_REPLICA) || !defined(SAGA_HAVE_PACKAGE_NAMESPACE) std::cerr << "saga-advert: saga has been compiled without the replica or " "namespace packages, bailing out" << std::endl; #else argc_ = argc; ExitIfArgcLessThan(2); SAGA_GUARDED_EXEC ( if(!strcmp(argv[1], "list_directory")) { ExitIfArgcLessThan(3); replica_list_directory(std::string(argv[2])); } else if(!strcmp(argv[1], "add_directory")) { ExitIfArgcLessThan(3); replica_add_directory(std::string(argv[2])); } else if(!strcmp(argv[1], "remove_directory")) { ExitIfArgcLessThan(3); replica_remove_directory(std::string(argv[2])); } else if(!strcmp(argv[1], "list_pfns")) { ExitIfArgcLessThan(3); replica_list_pfns(std::string(argv[2])); } else if(!strcmp(argv[1], "add_lfn")) { ExitIfArgcLessThan(3); replica_add_lfn(std::string(argv[2])); } else if(!strcmp(argv[1], "remove_lfn")) { ExitIfArgcLessThan(3); replica_remove_lfn(std::string(argv[2])); } else if(!strcmp(argv[1], "add_pfn")) { ExitIfArgcLessThan(4); replica_add_pfn(std::string(argv[2]), std::string(argv[3])); } else if(!strcmp(argv[1], "remove_pfn")) { ExitIfArgcLessThan(4); replica_remove_pfn(std::string(argv[2]), std::string(argv[3])); } else if(!strcmp(argv[1], "list_attributes")) { ExitIfArgcLessThan(3); replica_list_attributes(std::string(argv[2])); } else if(!strcmp(argv[1], "set_attribute")) { ExitIfArgcLessThan(5); replica_set_attribute (std::string(argv[2]), std::string(argv[3]), std::string(argv[4])); } else if(!strcmp(argv[1], "remove_attribute")) { ExitIfArgcLessThan(4); replica_remove_attribute(std::string(argv[2]), std::string(argv[3])); } else { std::cout << "Unknown command: " << std::string(argv[1]) << std::endl; printUsage(); exit(-1); } ) #endif return 0; }