[RFC] Add getHostname convenience function to kdelibs? (was: Re: [PATCH] Make the default sending domain configurable)

Waldo Bastian bastian at kde.org
Sat Apr 20 21:26:31 BST 2002


On Saturday 20 April 2002 05:35 am, Thiago Macieira wrote:
> Ingo Klöcker wrote
>
> >QCString <classname>::getHostname( bool fallback_to_localhost )
> >{
> >  char str[256];
> >  if ( !gethostname( str, 255 ) )
> >    // str is not guaranteed to be NUL-terminated if it has full length
> >    str[255] = 0;
> >  else
> >    str[0] = 0;
> >
> >  if( !*str && fallback_to_localhost )
> >    return QCString( "localhost" );
> >  else
> >    return QCString( str );
> >}
>
> For lack of better place, I'll add that as a static function to
> KExtendedSocket, without the bool argument.
>
> Or does anyone have a better suggestion? KGlobal? KSystem?

I think QCString KGlobal::hostname() would be appropriate.

Cheers,
Waldo
-- 
bastian at kde.org  |   SuSE Labs KDE Developer  |  bastian at suse.com





More information about the kde-core-devel mailing list