rem: QString subString = QString::fromLocal8Bit( args->getOption("query") ); if ( !subString.isEmpty() ) {   printf( "%s\n", i18n("Searching KDE addressbook...").local8Bit().data() );
add: KCmdLineArgs *args = KCmdLineArgs::parsedArgs();   const format_t format = (args->getOption("format") == "query") ? QueryCommand : Aliases;   const bool all = args->isSet( "all-addresses" );   const QString subString = QString::fromLocal8Bit( args->getOption( "query" ) ); if ( !subString.isEmpty() ) {   std::cout << i18n( "Searching KDE addressbook" ) << std::endl; }   const bool cs = !args->isSet( "ignore-case" );  KABC::AddressBook *ab = KABC::StdAddressBook::self(); KABC::StdAddressBook::setAutomaticSave( false );   KABC::AddressBook::ConstIterator iaddr; for ( iaddr = ab->begin(); iaddr != ab->end(); ++iaddr ) { const QString name = (*iaddr).givenName() + ' ' + (*iaddr).familyName(); if ( !subString.isEmpty() ) { bool match = (name.find(subString, 0, cs) > -1) || ((*iaddr).preferredEmail().find(subString, 0, cs) > -1 ); if ( !match ) continue;
context: int main( int argc, char **argv ){    KApplication::disableAutoDcopRegistration();    KCmdLineArgs::init( argc, argv, appName, programName, description, version );    KCmdLineArgs::addCmdLineOptions( k2moptions );    KApplication app( false, false );    KCmdLineArgs *args = KCmdLineArgs::parsedArgs();    // Handle --format option    QCString formatString = args->getOption("format");    enum { Aliases, QueryCommand } format;    if ( formatString == "query" )        format = QueryCommand;    else        format = Aliases;    // Handle --query option    QString subString = QString::fromLocal8Bit( args->getOption("query") );    if ( !subString.isEmpty() )    {        // Mutt wants a first line with some status message on it        // See http://mutt.org/doc/manual/manual-4.html#ss4.5        printf( "%s\n", i18n("Searching KDE addressbook...").local8Bit().data() );    }    bool cs = !args->isSet( "ignore-case" );    KABC::AddressBook *ab = KABC::StdAddressBook::self();    KABC::StdAddressBook::setAutomaticSave( false );    // print addressees    KABC::AddressBook::Iterator it;    for ( it = ab->begin(); it != ab->end(); ++it ) {      if ( (*it).preferredEmail().isEmpty() )        continue;      QString name = (*it).givenName() + ' ' + (*it).familyName();      if ( !subString.isEmpty() )      {        bool match = (name.find(subString, 0, cs) > -1) || ((*it).preferredEmail().find(subString, 0, cs) > -1 );        if ( !match )          continue;      }      if ( format == Aliases )      {          QString key = (*it).givenName().left( 3 ) + (*it).familyName().left( 3 );          printf( "alias %s\t%s <%s>\n", key.local8Bit().data(),                  name.local8Bit().data(),                  (*it).preferredEmail().local8Bit().data() );      } else {          printf( "%s\t%s\t\n", (*it).preferredEmail().local8Bit().data(),                  name.local8Bit().data() );      }    }    // print all distribution lists    KABC::DistributionListManager manager( ab );    manager.load();    QStringList dists = manager.listNames();    for ( QStringList::Iterator it = dists.begin(); it != dists.end(); ++it ) {      KABC::DistributionList *list = manager.list( *it );      if ( list ) {        if ( !subString.isEmpty() )        {          bool match = ((*it).find(subString) > -1);          if ( !match )            continue;        }        QStringList emails = list->emails();        if ( format == Aliases )            printf( "alias %s\t %s\n",                    (*it).replace( QRegExp( " " ), "_" ).local8Bit().data(),                    emails.join( "," ).local8Bit().data() );        else            printf( "%s\t%s\t\n",                    emails.join( "," ).local8Bit().data(),                    (*it).local8Bit().data() );    }  }  return 0;}