本文整理汇总了C++中Daemon::fullHostname方法的典型用法代码示例。如果您正苦于以下问题:C++ Daemon::fullHostname方法的具体用法?C++ Daemon::fullHostname怎么用?C++ Daemon::fullHostname使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Daemon
的用法示例。
在下文中一共展示了Daemon::fullHostname方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: strdup
int
CollectorList::resortLocal( const char *preferred_collector )
{
// Find the collector in the list that is best suited for
// this host. This is determined either by
// a) preferred_collector passed in
// b) the collector that has the same hostname as this negotiator
char * tmp_preferred_collector = NULL;
if ( !preferred_collector ) {
// figure out our hostname for plan b) above
MyString _hostname_str = get_local_fqdn();
const char * _hostname = _hostname_str.Value();
if (!(*_hostname)) {
// Can't get our hostname??? fuck off
return -1;
}
tmp_preferred_collector = strdup(_hostname);
preferred_collector = tmp_preferred_collector; // So we know to free later
}
// First, pick out collector(s) that is on this host
Daemon *daemon;
SimpleList<Daemon*> prefer_list;
this->list.Rewind();
while ( this->list.Next(daemon) ) {
if ( same_host (preferred_collector, daemon->fullHostname()) ) {
this->list.DeleteCurrent();
prefer_list.Prepend( daemon );
}
}
// Walk through the list of preferred collectors,
// stuff 'em in the main "list"
this->list.Rewind();
prefer_list.Rewind();
while ( prefer_list.Next(daemon) ) {
this->list.Prepend( daemon );
}
free(tmp_preferred_collector); // Warning, preferred_collector (may have) just became invalid, so do this just before returning.
return 0;
}