// DiffRotDiscreteCircle::DiffRotDiscreteCircle() void DiffRotDiscreteCircle::init() { m_elastic = boost::dynamic_pointer_cast<ElasticDiffRotDiscreteCircle>( API::FunctionFactory::Instance().createFunction( "ElasticDiffRotDiscreteCircle")); addFunction(m_elastic); m_inelastic = boost::dynamic_pointer_cast<InelasticDiffRotDiscreteCircle>( API::FunctionFactory::Instance().createFunction( "InelasticDiffRotDiscreteCircle")); addFunction(m_inelastic); setAttributeValue("NumDeriv", true); declareAttribute("Q", API::IFunction::Attribute(0.5)); declareAttribute("N", API::IFunction::Attribute(3)); // Set the aliases setAlias("f1.Intensity", "Intensity"); setAlias("f1.Radius", "Radius"); setAlias("f1.Decay", "Decay"); setAlias("f1.Shift", "Shift"); // Set the ties between Elastic and Inelastic parameters addDefaultTies("f0.Height=f1.Intensity,f0.Radius=f1.Radius"); applyTies(); }
DisplayVersionCommand::DisplayVersionCommand() { osVersion = "0.001.001 BETA"; setAlias("ver"); setHelp("This command shows the current version of the running operating system."); setDesc("Shows the current operating system version number"); }
// DeviceInterface DeviceInterface::DeviceInterface(const QDBusObjectPath &path, const QVariantMap &properties, QObject *parent) : QDBusAbstractAdaptor(parent) , m_mediaPlayer(0) { setPath(path); setObjectParent(parent); setProperties(properties); setName(QStringLiteral("org.bluez.Device1")); // Alias needs special handling setAlias(properties.value(QStringLiteral("Alias")).toString()); // Create Input1 if (properties.contains(QStringLiteral("Input"))) { const QVariantMap &inputProps = qdbus_cast<QVariantMap>(properties.value(QStringLiteral("Input"))); InputInterface *input = new InputInterface(path, inputProps, parent); ObjectManager *manager = ObjectManager::self(); manager->addObject(input); QVariantMap props = properties; props.remove(QStringLiteral("Input")); setProperties(props); } }
void SIPAccount::setAccountDetails (std::map<std::string, std::string> details) { // Account setting common to SIP and IAX setAlias (details[CONFIG_ACCOUNT_ALIAS]); setType (details[CONFIG_ACCOUNT_TYPE]); setUsername (details[USERNAME]); setHostname (details[HOSTNAME]); setEnabled ( (details[CONFIG_ACCOUNT_ENABLE] == "true")); setRingtonePath (details[CONFIG_RINGTONE_PATH]); setRingtoneEnabled ( (details[CONFIG_RINGTONE_ENABLED] == "true")); setMailBox (details[CONFIG_ACCOUNT_MAILBOX]); // SIP specific account settings // general sip settings setDisplayName (details[DISPLAY_NAME]); setServiceRoute (details[ROUTESET]); setLocalInterface (details[LOCAL_INTERFACE]); setPublishedSameasLocal (details[PUBLISHED_SAMEAS_LOCAL] == "true"); setPublishedAddress (details[PUBLISHED_ADDRESS]); setLocalPort (atoi (details[LOCAL_PORT].c_str())); setPublishedPort (atoi (details[PUBLISHED_PORT].c_str())); setStunServer (details[STUN_SERVER]); setStunEnabled (details[STUN_ENABLE] == "true"); setDtmfType ( (details[ACCOUNT_DTMF_TYPE] == "overrtp") ? OVERRTP : SIPINFO); setResolveOnce (details[CONFIG_ACCOUNT_RESOLVE_ONCE] == "true"); setRegistrationExpire (details[CONFIG_ACCOUNT_REGISTRATION_EXPIRE]); setUseragent (details[USERAGENT]); // srtp settings setSrtpEnable (details[SRTP_ENABLE] == "true"); setSrtpFallback (details[SRTP_RTP_FALLBACK] == "true"); setZrtpDisplaySas (details[ZRTP_DISPLAY_SAS] == "true"); setZrtpDiaplaySasOnce (details[ZRTP_DISPLAY_SAS_ONCE] == "true"); setZrtpNotSuppWarning (details[ZRTP_NOT_SUPP_WARNING] == "true"); setZrtpHelloHash (details[ZRTP_HELLO_HASH] == "true"); setSrtpKeyExchange (details[SRTP_KEY_EXCHANGE]); // TLS settings // The TLS listener is unique and globally defined through IP2IP_PROFILE if (_accountID == IP2IP_PROFILE) setTlsListenerPort (atoi (details[TLS_LISTENER_PORT].c_str())); setTlsEnable (details[TLS_ENABLE]); setTlsCaListFile (details[TLS_CA_LIST_FILE]); setTlsCertificateFile (details[TLS_CERTIFICATE_FILE]); setTlsPrivateKeyFile (details[TLS_PRIVATE_KEY_FILE]); setTlsPassword (details[TLS_PASSWORD]); setTlsMethod (details[TLS_METHOD]); setTlsCiphers (details[TLS_CIPHERS]); setTlsServerName (details[TLS_SERVER_NAME]); setTlsVerifyServer (details[TLS_VERIFY_SERVER] == "true"); setTlsVerifyClient (details[TLS_VERIFY_CLIENT] == "true"); setTlsRequireClientCertificate (details[TLS_REQUIRE_CLIENT_CERTIFICATE] == "true"); setTlsNegotiationTimeoutSec (details[TLS_NEGOTIATION_TIMEOUT_SEC]); setTlsNegotiationTimeoutMsec (details[TLS_NEGOTIATION_TIMEOUT_MSEC]); }
DisplayHelpCommand::DisplayHelpCommand(std::vector<Command*>* cmdList) { setAlias("help"); setDesc("Displays help information about system or command"); setHelp("Follow this command with the name of another command to get more information \n about that command."); setCommandList(cmdList); }
void KeyManager::accept() { setFilePem(boxPem->value()); setFilePk8(boxPk8->value()); setFileKey(boxKey->value()); setIsKeyStore(radioKey->isChecked()); setAlias(editAlias->text()); setPassStore(editStorePass->text()); setPassAlias(editAliasPass->text()); QDialog::accept(); }
void GraphObject::registerAttributes() { addAttribute("alias", [&](const Values& args) { auto alias = args[0].as<string>(); setAlias(alias); return true; }, [&]() -> Values { return {getAlias()}; }, {'s'}); setAttributeDescription("alias", "Alias name"); addAttribute("setSavable", [&](const Values& args) { auto savable = args[0].as<bool>(); setSavable(savable); return true; }, {'n'}); addAttribute("priorityShift", [&](const Values& args) { _priorityShift = args[0].as<int>(); return true; }, [&]() -> Values { return {_priorityShift}; }, {'n'}); setAttributeDescription("priorityShift", "Shift to the default rendering priority value, for those cases where two objects should be rendered in a specific order. Higher value means lower priority"); addAttribute("switchLock", [&](const Values& args) { auto attribIterator = _attribFunctions.find(args[0].as<string>()); if (attribIterator == _attribFunctions.end()) return false; string status; auto& attribFunctor = attribIterator->second; if (attribFunctor.isLocked()) { status = "Unlocked"; attribFunctor.unlock(); } else { status = "Locked"; attribFunctor.lock(); } Log::get() << Log::MESSAGE << _name << "~~" << args[0].as<string>() << " - " << status << Log::endl; return true; }, {'s'}); }
void KeyManager::reject() { setFilePem(filePem); setFilePk8(filePk8); setFileKey(fileKey); setIsKeyStore(isKeystore); setAlias(alias); setPassStore(passStore); setPassAlias(passAlias); QDialog::reject(); }
void evaluateMissingDefaults(Block & block, const NamesAndTypesList & required_columns, const ColumnDefaults & column_defaults, const Context & context) { if (column_defaults.empty()) return; ASTPtr default_expr_list = std::make_shared<ASTExpressionList>(); for (const auto & column : required_columns) { if (block.has(column.name)) continue; const auto it = column_defaults.find(column.name); /// expressions must be cloned to prevent modification by the ExpressionAnalyzer if (it != column_defaults.end()) default_expr_list->children.emplace_back( setAlias(it->second.expression->clone(), it->first)); } /// nothing to evaluate if (default_expr_list->children.empty()) return; /** ExpressionAnalyzer eliminates "unused" columns, in order to ensure their safety * we are going to operate on a copy instead of the original block */ Block copy_block{block}; /// evaluate default values for defaulted columns NamesAndTypesList available_columns; for (size_t i = 0, size = block.columns(); i < size; ++i) available_columns.emplace_back(block.getByPosition(i).name, block.getByPosition(i).type); ExpressionAnalyzer{default_expr_list, context, {}, available_columns}.getActions(true)->execute(copy_block); /// move evaluated columns to the original block, materializing them at the same time for (auto & column_name_type : copy_block) { if (ColumnPtr converted = column_name_type.column->convertToFullColumnIfConst()) column_name_type.column = converted; block.insert(std::move(column_name_type)); } }
void MainWindow::onTextEnter() { bool stay = false; cmds_t cmds; QString text = ui->cmdText->text(); format_cmds(cmds, text.toStdString()); if(cmds.find("help") != cmds.end()) { QString help = "Commands: "; for(std::string cmd : list_cmd_types()) { help += QString::fromStdString(cmd); help += " "; } ui->noteText->append(help); stay = true; } if(cmds.find("delete") != cmds.end()) { delAlias(); stay = true; } if("" != cmds["set"]) { uint num = getSelWinNum(); setAlias(QString::fromStdString(cmds["set"]), num); stay = true; } if(cmds.find("aliases") != cmds.end()) { listAlias(); stay = true; } if(!stay) { if("" != cmds["get"]) { getAlias(QString::fromStdString(cmds["get"])); } else { onWitemActivate(ui->winView->currentIndex()); } } ui->cmdText->clear(); }
/* PMDObject::load: load model */ bool PMDObject::load(const char *fileName, const char *alias, btVector3 *offsetPos, btQuaternion *offsetRot, bool forcedPosition, PMDBone *assignBone, PMDObject *assignObject, BulletPhysics *bullet, SystemTexture *systex, LipSync *sysLipSync, bool useCartoonRendering, float cartoonEdgeWidth, btVector3 *light, float commentFrame) { int i; int len; char *buf; LipSync *lip; if (fileName == NULL || alias == NULL) return false; /* apply given parameters */ m_assignTo = assignObject; m_baseBone = assignBone; if (forcedPosition) { /* set offset by given parameters */ if (offsetPos) m_offsetPos = (*offsetPos); if (offsetRot) m_offsetRot = (*offsetRot); m_pmd.getRootBone()->setOffset(&m_offsetPos); m_pmd.getRootBone()->update(); } else { /* set offset by root bone */ m_pmd.getRootBone()->getOffset(&m_offsetPos); } /* copy absolute position flag */ for (i = 0; i < 3; i++) m_absPosFlag[i] = false; /* copy toon rendering flag */ m_useCartoonRendering = useCartoonRendering; /* copy flag for motion file drop or all motion */ if(assignBone || assignObject) m_allowMotionFileDrop = false; else m_allowMotionFileDrop = true; /* save position when position is fixed */ if (m_baseBone) m_origBasePos = m_baseBone->getTransform()->getOrigin(); /* set alpha frame */ m_alphaAppearFrame = PMDOBJECT_ALPHAFRAME; m_alphaDisappearFrame = 0.0; /* set comment frame */ m_displayCommentFrame = commentFrame; /* load model */ if (m_pmd.load(fileName, bullet, systex) == false) { clear(); return false; } /* set toon rendering flag */ m_pmd.setToonFlag(useCartoonRendering); /* set edge width */ m_pmd.setEdgeThin(cartoonEdgeWidth); /* load lip sync */ m_globalLipSync = sysLipSync; if(m_localLipSync != NULL) delete m_localLipSync; m_localLipSync = NULL; lip = new LipSync(); len = MMDAgent_strlen(fileName); if(len < 5) { delete lip; } else { buf = MMDAgent_strdup(fileName); buf[len - 4] = '.'; buf[len - 3] = 'l'; buf[len - 2] = 'i'; buf[len - 1] = 'p'; if(lip->load(buf) == true) { m_localLipSync = lip; } else delete lip; if(buf) free(buf); } /* set alias */ setAlias(alias); /* reset */ setLightForToon(light); m_moveSpeed = -1.0f; m_spinSpeed = -1.0f; /* set temporarily all body to Kinematic */ /* this is fixed at first simulation */ skipNextSimulation(); /* enable */ m_isEnable = true; return true; }
/// AST to the list of columns with types. Columns of Nested type are expanded into a list of real columns. static ColumnsAndDefaults parseColumns(const ASTExpressionList & column_list_ast, const Context & context) { /// list of table columns in correct order NamesAndTypesList columns{}; ColumnDefaults defaults{}; /// Columns requiring type-deduction or default_expression type-check std::vector<std::pair<NameAndTypePair *, ASTColumnDeclaration *>> defaulted_columns{}; /** all default_expressions as a single expression list, * mixed with conversion-columns for each explicitly specified type */ ASTPtr default_expr_list = std::make_shared<ASTExpressionList>(); default_expr_list->children.reserve(column_list_ast.children.size()); for (const auto & ast : column_list_ast.children) { auto & col_decl = typeid_cast<ASTColumnDeclaration &>(*ast); if (col_decl.type) { columns.emplace_back(col_decl.name, DataTypeFactory::instance().get(col_decl.type)); } else /// we're creating dummy DataTypeUInt8 in order to prevent the NullPointerException in ExpressionActions columns.emplace_back(col_decl.name, std::make_shared<DataTypeUInt8>()); /// add column to postprocessing if there is a default_expression specified if (col_decl.default_expression) { defaulted_columns.emplace_back(&columns.back(), &col_decl); /** for columns with explicitly-specified type create two expressions: * 1. default_expression aliased as column name with _tmp suffix * 2. conversion of expression (1) to explicitly-specified type alias as column name */ if (col_decl.type) { const auto & final_column_name = col_decl.name; const auto tmp_column_name = final_column_name + "_tmp"; const auto data_type_ptr = columns.back().type.get(); default_expr_list->children.emplace_back(setAlias( makeASTFunction("CAST", std::make_shared<ASTIdentifier>(tmp_column_name), std::make_shared<ASTLiteral>(Field(data_type_ptr->getName()))), final_column_name)); default_expr_list->children.emplace_back(setAlias(col_decl.default_expression->clone(), tmp_column_name)); } else default_expr_list->children.emplace_back(setAlias(col_decl.default_expression->clone(), col_decl.name)); } } /// set missing types and wrap default_expression's in a conversion-function if necessary if (!defaulted_columns.empty()) { const auto actions = ExpressionAnalyzer{default_expr_list, context, {}, columns}.getActions(true); const auto block = actions->getSampleBlock(); for (auto & column : defaulted_columns) { const auto name_and_type_ptr = column.first; const auto col_decl_ptr = column.second; const auto & column_name = col_decl_ptr->name; const auto has_explicit_type = nullptr != col_decl_ptr->type; auto & explicit_type = name_and_type_ptr->type; /// if column declaration contains explicit type, name_and_type_ptr->type is not null if (has_explicit_type) { const auto & tmp_column = block.getByName(column_name + "_tmp"); const auto & deduced_type = tmp_column.type; /// type mismatch between explicitly specified and deduced type, add conversion for non-array types if (!explicit_type->equals(*deduced_type)) { col_decl_ptr->default_expression = makeASTFunction("CAST", col_decl_ptr->default_expression, std::make_shared<ASTLiteral>(explicit_type->getName())); col_decl_ptr->children.clear(); col_decl_ptr->children.push_back(col_decl_ptr->type); col_decl_ptr->children.push_back(col_decl_ptr->default_expression); } } else /// no explicit type, name_and_type_ptr->type is null, set to deduced type explicit_type = block.getByName(column_name).type; defaults.emplace(column_name, ColumnDefault{ columnDefaultKindFromString(col_decl_ptr->default_specifier), col_decl_ptr->default_expression }); } } return {Nested::flatten(columns), defaults}; }
ExitCommand::ExitCommand() { setAlias("exit"); setDesc("Completely shuts down the operating system"); setHelp("This command shuts down the entire operating system."); }
void ProjectTreeModelDelegate::readSettings(QSettings &settings) { setAlias(settings.value("alias", name()).toString()); }
void ExecuteScalarSubqueriesMatcher::visit(const ASTSubquery & subquery, ASTPtr & ast, Data & data) { Context subquery_context = data.context; Settings subquery_settings = data.context.getSettings(); subquery_settings.max_result_rows = 1; subquery_settings.extremes = 0; subquery_context.setSettings(subquery_settings); ASTPtr subquery_select = subquery.children.at(0); BlockIO res = InterpreterSelectWithUnionQuery( subquery_select, subquery_context, {}, QueryProcessingStage::Complete, data.subquery_depth + 1).execute(); Block block; try { block = res.in->read(); if (!block) { /// Interpret subquery with empty result as Null literal auto ast_new = std::make_unique<ASTLiteral>(Null()); ast_new->setAlias(ast->tryGetAlias()); ast = std::move(ast_new); return; } if (block.rows() != 1 || res.in->read()) throw Exception("Scalar subquery returned more than one row", ErrorCodes::INCORRECT_RESULT_OF_SCALAR_SUBQUERY); } catch (const Exception & e) { if (e.code() == ErrorCodes::TOO_MANY_ROWS) throw Exception("Scalar subquery returned more than one row", ErrorCodes::INCORRECT_RESULT_OF_SCALAR_SUBQUERY); else throw; } size_t columns = block.columns(); if (columns == 1) { auto lit = std::make_unique<ASTLiteral>((*block.safeGetByPosition(0).column)[0]); lit->alias = subquery.alias; lit->prefer_alias_to_column_name = subquery.prefer_alias_to_column_name; ast = addTypeConversion(std::move(lit), block.safeGetByPosition(0).type->getName()); } else { auto tuple = std::make_shared<ASTFunction>(); tuple->alias = subquery.alias; ast = tuple; tuple->name = "tuple"; auto exp_list = std::make_shared<ASTExpressionList>(); tuple->arguments = exp_list; tuple->children.push_back(tuple->arguments); exp_list->children.resize(columns); for (size_t i = 0; i < columns; ++i) { exp_list->children[i] = addTypeConversion( std::make_unique<ASTLiteral>((*block.safeGetByPosition(i).column)[0]), block.safeGetByPosition(i).type->getName()); } } }
CTListItemAlias(const char *alias):CListItem() { setAlias(alias); }
void listenToClients(iguanaDev *idev, handleReaderFunc handleReader, clientConnectedFunc clientConnected, handleClientFunc handleClient) { PIPE_PTR listener; char name[4]; /* start the listener */ sprintf(name, "%d", idev->usbDev->id); listener = startListening(name); if (listener == INVALID_PIPE) message(LOG_ERROR, "Worker failed to start listening.\n"); else { fd_set fds, fdsin, fdserr; /* check the initial aliases */ getID(idev); /* loop while checking the pipes for activity */ FD_ZERO(&fdsin); FD_ZERO(&fdserr); while(true) { client *john; int max; FD_ZERO(&fds); /* first check the listener and read pipe for error */ if (FD_ISSET(listener, &fdserr) || FD_ISSET(idev->readerPipe[READ], &fdserr)) break; /* take care of messages from the reader */ if (FD_ISSET(idev->readerPipe[READ], &fdsin) && ! handleReader(idev)) break; FD_SET(idev->readerPipe[READ], &fds); max = idev->readerPipe[READ]; /* next handle incoming connections */ if (FD_ISSET(listener, &fdsin)) clientConnected(accept(listener, NULL, NULL), idev); FD_SET(listener, &fds); if (listener > max) max = listener; /* last check the clients */ for(john = (client*)idev->clientList.head; john != NULL;) { client *next; next = (client*)john->header.next; if ((! FD_ISSET(john->fd, &fdserr) && ! FD_ISSET(john->fd, &fdsin)) || handleClient(john)) { FD_SET(john->fd, &fds); if (john->fd > max) max = john->fd; } john = next; } /* wait until there is data ready */ fdsin = fdserr = fds; if (select(max + 1, &fdsin, NULL, &fdserr, NULL) < 0) { message(LOG_ERROR, "select failed: %s\n", translateError(errno)); break; } } setAlias(idev->usbDev->id, NULL); stopListening(listener, name); } }
XlPub::~XlPub() { setPublishedArea(NULL); setAlias(NULL); setSection(NULL); }
void Sinful::parseV1String() { std::vector< SourceRoute > v; if(! getSourceRoutes( v, & m_host, & m_port ) ) { m_valid = false; return; } // // To convert a list of source routes back into an original Sinful's // data structures, do the following: // // (1) Extract the spid from each route; they must all be the same. // Set the spid. // (2) Extract the alias from each route; they must all be the same. // Set the alias. // (3) Extract the private network name from each route; they must // all be the same. Set the private network name. // (4) Check all routes for ccbid. Each route with a ccbid goes // into the ccb contact list. // (5) All routes without a ccbid must be "Internet" addresses or // private network addresses. The former go into addrs (and // host is set to addrs[0]). Ignore all of the latter that // have an address in addrs (because those came from CCB). The // remaining address must be the private network address. // // Determine the shared port ID, if any. If any route has a // shared port ID, all must have one, and it must be the same. const std::string & sharedPortID = v[0].getSharedPortID(); if(! sharedPortID.empty() ) { setSharedPortID( v[0].getSharedPortID().c_str() ); for( unsigned i = 0; i < v.size(); ++i ) { if( v[i].getSharedPortID() != sharedPortID ) { m_valid = false; return; } } } // Determine the alias, if any. If more than one route has an alias, // each alias must be the same. std::string alias; for( unsigned i = 0; i < v.size(); ++i ) { if(! v[i].getAlias().empty()) { if(! alias.empty()) { if( alias != v[i].getAlias() ) { m_valid = false; return; } } else { alias = v[i].getAlias(); } } } if(! alias.empty() ) { setAlias( alias.c_str() ); } // Determine the private network name, if any. If more than one route // has a private network name, each private network name must be the same. std::string privateNetworkName; for( unsigned i = 0; i < v.size(); ++i ) { if( v[i].getNetworkName() != PUBLIC_NETWORK_NAME ) { if(! privateNetworkName.empty()) { if( v[i].getNetworkName() != privateNetworkName ) { m_valid = false; return; } } else { privateNetworkName = v[i].getNetworkName(); } } } if(! privateNetworkName.empty() ) { setPrivateNetworkName( privateNetworkName.c_str() ); } // // Determine the CCB contact string, if any. // // Each group of routes which shared a broker index must be converted // back into the single original Sinful from which it sprang; that // Sinful can than be added to the ccbList with its CCB ID. // StringList ccbList; std::map< unsigned, std::string > brokerCCBIDs; std::map< unsigned, std::vector< SourceRoute > > brokers; for( unsigned i = 0; i < v.size(); ++i ) { if( v[i].getCCBID().empty() ) { continue; } SourceRoute sr = v[i]; sr.setSharedPortID( sr.getCCBSharedPortID() ); sr.setCCBSharedPortID( "" ); sr.setCCBID( "" ); unsigned brokerIndex = sr.getBrokerIndex(); brokers[brokerIndex].push_back( sr ); brokerCCBIDs[brokerIndex] = v[i].getCCBID(); dprintf( D_ALWAYS, "broker %u = %s\n", brokerIndex, sr.serialize().c_str() ); } for( unsigned i = 0; i < brokers.size(); ++i ) { std::string brokerV1String = "{"; brokerV1String += brokers[i][0].serialize(); for( unsigned j = 0; j < brokers[i].size(); ++j ) { brokerV1String += ", "; brokerV1String += brokers[i][j].serialize(); } brokerV1String += "}"; Sinful s( brokerV1String.c_str() ); std::string ccbAddress = s.getCCBAddressString(); CCBID ccbID; if(! CCBServer::CCBIDFromString( ccbID, brokerCCBIDs[i].c_str() )) { m_valid = false; return; } MyString ccbContactString; CCBServer::CCBIDToContactString( ccbAddress.c_str(), ccbID, ccbContactString ); ccbList.append( ccbContactString.c_str() ); } if(! ccbList.isEmpty() ) { char * ccbID = ccbList.print_to_delimed_string( " " ); ASSERT( ccbID != NULL ); setCCBContact( ccbID ); free( ccbID ); } // Determine the set of public addresses. for( unsigned i = 0; i < v.size(); ++i ) { if( v[i].getProtocol() == CP_PRIMARY ) { continue; } if(! v[i].getCCBID().empty()) { continue; } if( v[i].getNetworkName() == PUBLIC_NETWORK_NAME ) { addAddrToAddrs( v[i].getSockAddr() ); } } // Determine the private network address, if any. for( unsigned i = 0; i < v.size(); ++i ) { if(! v[i].getCCBID().empty()) { continue; } if( v[i].getNetworkName() == PUBLIC_NETWORK_NAME ) { continue; } // A route with a public address may have a private network name // as a result of bypassing CCB. Those addresses are not private // addresses, so ignore them. condor_sockaddr sa = v[i].getSockAddr(); if( std::find( addrs.begin(), addrs.end(), sa ) != addrs.end() ) { continue; } // There can be only one private address. if( getPrivateAddr() != NULL ) { m_valid = false; return; } // setPrivateAddr( Sinful::privateAddressString( v[i].getSockAddr(), getSharedPortID() ).c_str() ); Sinful p( v[i].getSockAddr().to_ip_and_port_string().c_str() ); p.setSharedPortID( getSharedPortID() ); setPrivateAddr( p.getSinful() ); } // Set noUDP if any route sets it. for( unsigned i = 0; i < v.size(); ++i ) { if( v[i].getNoUDP() ) { setNoUDP( true ); break; } } m_valid = true; }
int parseSyncArgs(int argc, char **argv, struct SyncPrefs *prefs){ char OPT_LIST[11]; sprintf(OPT_LIST, "%c%c%c:%c:", OPT_HELP, OPT_VERSION, OPT_PORT, OPT_ALIAS); int status = SUCCESS; if (argc <= 1){ // The command line was empty prefs->errMsg = strdup(ERR_OPT_NO_ARGS); status = FAIL; } else { int opt; while ((opt = getopt(argc, argv, OPT_LIST)) != -1){ switch (opt){ case OPT_HELP: prefs->help = 1; status = SUCCESS; break; case OPT_VERSION: prefs->version = 1; status = SUCCESS; break; case OPT_PORT: status = setPort(prefs, optarg); break; case OPT_ALIAS: status = setAlias(prefs, optarg); break; default: status = FAIL; break; } // Check the 'status' value after each option, and stop if we see anything invalid if (status == FAIL){ break; } } if (status == SUCCESS && prefs->version == 0 && prefs->help == 0){ if (optind == argc){ prefs->errMsg = strdup(ERR_NO_HOST); status = FAIL; } else { if ((optind < argc - 1) && prefs->alias != NULL){ // multiple hosts with same alias, probably an error so stop prefs->errMsg = strdup(ERR_MULTIPLE_HOSTS_ONE_ALIAS); status = FAIL; } else { int hostCount = argc - optind; char **hosts = malloc(sizeof(char *) * hostCount); int i; for(i=optind; i<argc; i++){ hosts[i - optind] = strdup(argv[i]); } prefs->hosts = hosts; prefs->hostCount = hostCount; } } } } return status; }