caddr_t xv_form_prefix (ptrlong serial) { char str[60]; snprintf (str, sizeof (str), "t%lu", (unsigned long) serial); /* sprintf(str, "t%08x", (long) table_name);*/ return box_string(str); }
int Config::doSanityCheck(boost::program_options::options_description* options, std::vector<std::string>* nodes, std::vector<std::string>* hostnames, std::vector<std::string>* box_strings) { // check for help argument, print the help, and exit if (vm_.count("help")) { std::cout << *(options) << std::endl; return 1; } // checking nodes (need at least one) if (F_MSG_DEBUG) printf("config: checking nodes\n"); if ( nodes->size() >= 1 ) { // TODO add logic for non-bidirectional nodes // Let's make the nodes vector unique before turning it over std::vector<std::string>::iterator i; i = std::unique( nodes->begin(), nodes->end() ); nodes->resize( std::distance( nodes->begin(), i ) ); for (i = nodes->begin(); i != nodes->end(); ++i) { // check if the supplied node is connectible // only tcp is allowed // depending on the matched regex, the zmq protocol will be appended std::smatch sm; if ( std::regex_match( *i, sm, std::regex("(tcp://)?(.*)(:)([0-9]*)") ) ) { // prepare the node endpoint std::string endpoint = *i; if ( sm[1].length() == 0 ) endpoint = "tcp://" + endpoint; // add it to the config class for later use node_t new_node; new_node.endpoint = endpoint; new_node.f_subtype = F_SUBTYPE_TCP_BIDIR; new_node.last_timestamp = 0; new_node.offset = 0; this->nodes_vec_.push_back( new_node ); } else if ( F_MSG_DEBUG && std::regex_match( *i, sm, std::regex("(ipc://)(.*)") ) ) { // add it to the config class for later use node_t new_node; new_node.endpoint = *i; new_node.f_subtype = F_SUBTYPE_TCP_BIDIR; new_node.last_timestamp = 0; new_node.offset = 0; this->nodes_vec_.push_back( new_node ); } else { std::cerr << "[E] Cannot process node '" << *i << "'" << std::endl; return 1; } } } else { perror("[E] No nodes supplied, exiting..."); return 1; } // checking publishers if (F_MSG_DEBUG) printf("config: checking publishers\n"); if ( hostnames->size() >= 1 ) { // Let's make the nodes vector unique before turning it over std::vector<std::string>::iterator i; i = std::unique( hostnames->begin(), hostnames->end() ); hostnames->resize( std::distance( hostnames->begin(), i ) ); for ( i = hostnames->begin(); i != hostnames->end(); ++i) { // check if the supplied publisher is connectible // only tcp is allowed // depending on the matched regex, the zmq protocol will be appended std::smatch sm; if ( std::regex_match( *i, sm, std::regex("(tcp://)?(.*)(:)([0-9]*)") ) ) { // prepare the node endpoint std::string endpoint = *i; if ( sm[1].length() == 0 ) endpoint = "tcp://" + endpoint; host_t host; host.endpoint = endpoint; this->hosts_.push_back(host); } else if ( F_MSG_DEBUG && std::regex_match( *i, sm, std::regex("(ipc://)(.*)") ) ) { host_t host; host.endpoint = *i; this->hosts_.push_back(host); } else { std::cerr << "[E] Cannot process node '" << *i << "'" << std::endl; return 1; } } } else { perror("[E] No publishers supplied, exiting..."); return 1; } // checking boxes if (F_MSG_DEBUG) printf("config: checking boxes\n"); if ( box_strings->size() >= 1 ) { std::vector< std::string >::iterator i; for (i = box_strings->begin(); i != box_strings->end(); ++i) { std::istringstream box_string(*i); std::stringstream box_path_sstream; std::string box_name_string, box_path, box_path_temp; std::getline(box_string, box_name_string, '@'); Hash box_name(box_name_string); std::getline(box_string, box_path_temp, '@'); box_path_sstream << box_path_temp; while(std::getline(box_string, box_path_temp, '@')) { box_path_sstream << "@" << box_path_temp; } box_path = box_path_sstream.str(); // check if the box locations map to directories on the filesystem if ( !boost::filesystem::is_directory(box_path) ) { std::cerr << "[E] " << box_path << " is not a directory." << std::endl; return 1; } // check if the box location is already mapped or the box name has already been claimed for (std::vector<box_t>::iterator j = this->boxes_.begin(); j != this->boxes_.end(); ++j) { if (std::memcmp(box_name.getBytes(), j->uid, F_GENERIC_HASH_LEN) == 0 ) { std::cerr << "[E] " << box_name.getBytes() << " is already used." << std::endl; return 1; } if (box_path == j->base_path) { std::cerr << "[E] " << box_path << " is already mapped." << std::endl; return 1; } } // add new box strings to Config box_t new_box; std::memcpy(new_box.uid, box_name.getBytes(), F_GENERIC_HASH_LEN); new_box.base_path = box_path; this->boxes_.push_back( new_box ); } } else { perror("[E] No box locations supplied, exiting..."); return 1; } return 0; }
caddr_t bif_wikiv_name (caddr_t * qst, caddr_t * err, state_slot_t ** args) { return box_string ("WikiV"); }