rem
stringlengths
0
274k
add
stringlengths
0
169k
context
stringlengths
9
471k
QByteArray data; QByteArray param; QCString retType; QStringList retVal; QDataStream streamout(param,IO_WriteOnly); streamout<<deviceName; if ( m_dcopClient->call( "kmobile", "kmobileIface", "kio_devices_deviceInfo(QString)", param,retType,data,false ) ) { QDataStream streamin(data,IO_ReadOnly); streamin>>retVal; } return retVal;
QByteArray data; QByteArray param; QCString retType; QStringList retVal; QDataStream streamout(param,IO_WriteOnly); streamout<<deviceName; if ( dcopClient()->call( "kmobile", "kmobileIface", "kio_devices_deviceInfo(QString)", param,retType,data,false ) ) { QDataStream streamin(data,IO_ReadOnly); streamin>>retVal; } return retVal;
QStringList DevicesProtocol::kmobile_list(const QString deviceName){ QByteArray data; QByteArray param; QCString retType; QStringList retVal; QDataStream streamout(param,IO_WriteOnly); streamout<<deviceName; if ( m_dcopClient->call( "kmobile", "kmobileIface", "kio_devices_deviceInfo(QString)", param,retType,data,false ) ) { QDataStream streamin(data,IO_ReadOnly); streamin>>retVal; } return retVal;}
kdDebug()<<"DevicesProtocol::listdir: "<<url.url()<<endl; if ((url==KURL("devices:/")) || (url==KURL("system:/")))
kdDebug(7126) << "listdir: " << url << endl; if (url.path().length() <= 1) {
void DevicesProtocol::listDir(const KURL& url){ kdDebug()<<"DevicesProtocol::listdir: "<<url.url()<<endl; if ((url==KURL("devices:/")) || (url==KURL("system:/"))) listRoot(); else { QStringList info=deviceInfo(url.fileName()); if (info.empty()) { error(KIO::ERR_SLAVE_DEFINED,i18n("Unknown device %1").arg(url.fileName())); return; } QStringList::Iterator it=info.begin(); if (it!=info.end()) { QString device=*it; ++it; if (it!=info.end()) { ++it; if (it!=info.end()) { QString mp=*it; ++it;++it; if (it!=info.end()) { bool mounted=((*it)=="true"); if (mounted) {// if (mp=="/") mp=""; redirection(KURL( mp )); finished(); } else { if (mp.startsWith("file:/")) { KProcess *proc = new KProcess; *proc << "kio_devices_mounthelper"; *proc << "-m" << url.url(); proc->start(KProcess::Block); int ec=0; if (proc->normalExit()) ec=proc->exitStatus(); delete proc; if (ec) { error(KIO::ERR_SLAVE_DEFINED,i18n("Device not mounted")); finished(); } else { redirection(KURL( mp )); finished(); } } else error(KIO::ERR_SLAVE_DEFINED,i18n("Device not accessible")); } return; } } } } error(KIO::ERR_SLAVE_DEFINED,i18n("Illegal data received")); }}
else { QStringList info=deviceInfo(url.fileName());
return; }
void DevicesProtocol::listDir(const KURL& url){ kdDebug()<<"DevicesProtocol::listdir: "<<url.url()<<endl; if ((url==KURL("devices:/")) || (url==KURL("system:/"))) listRoot(); else { QStringList info=deviceInfo(url.fileName()); if (info.empty()) { error(KIO::ERR_SLAVE_DEFINED,i18n("Unknown device %1").arg(url.fileName())); return; } QStringList::Iterator it=info.begin(); if (it!=info.end()) { QString device=*it; ++it; if (it!=info.end()) { ++it; if (it!=info.end()) { QString mp=*it; ++it;++it; if (it!=info.end()) { bool mounted=((*it)=="true"); if (mounted) {// if (mp=="/") mp=""; redirection(KURL( mp )); finished(); } else { if (mp.startsWith("file:/")) { KProcess *proc = new KProcess; *proc << "kio_devices_mounthelper"; *proc << "-m" << url.url(); proc->start(KProcess::Block); int ec=0; if (proc->normalExit()) ec=proc->exitStatus(); delete proc; if (ec) { error(KIO::ERR_SLAVE_DEFINED,i18n("Device not mounted")); finished(); } else { redirection(KURL( mp )); finished(); } } else error(KIO::ERR_SLAVE_DEFINED,i18n("Device not accessible")); } return; } } } } error(KIO::ERR_SLAVE_DEFINED,i18n("Illegal data received")); }}
if (info.empty()) { error(KIO::ERR_SLAVE_DEFINED,i18n("Unknown device %1").arg(url.fileName())); return; } QStringList::Iterator it=info.begin(); if (it!=info.end()) { QString device=*it; ++it; if (it!=info.end()) { ++it; if (it!=info.end()) { QString mp=*it; ++it;++it; if (it!=info.end()) { bool mounted=((*it)=="true"); if (mounted) { redirection(KURL( mp )); finished(); } else { if (mp.startsWith("file:/")) { KProcess *proc = new KProcess; *proc << "kio_devices_mounthelper"; *proc << "-m" << url.url(); proc->start(KProcess::Block); int ec=0; if (proc->normalExit()) ec=proc->exitStatus(); delete proc; if (ec) { error(KIO::ERR_SLAVE_DEFINED,i18n("Device not mounted")); finished(); } else { redirection(KURL( mp )); finished(); } } else error(KIO::ERR_SLAVE_DEFINED,i18n("Device not accessible")); } return; } } } } error(KIO::ERR_SLAVE_DEFINED,i18n("Illegal data received")); }
mountAndRedirect(url);
void DevicesProtocol::listDir(const KURL& url){ kdDebug()<<"DevicesProtocol::listdir: "<<url.url()<<endl; if ((url==KURL("devices:/")) || (url==KURL("system:/"))) listRoot(); else { QStringList info=deviceInfo(url.fileName()); if (info.empty()) { error(KIO::ERR_SLAVE_DEFINED,i18n("Unknown device %1").arg(url.fileName())); return; } QStringList::Iterator it=info.begin(); if (it!=info.end()) { QString device=*it; ++it; if (it!=info.end()) { ++it; if (it!=info.end()) { QString mp=*it; ++it;++it; if (it!=info.end()) { bool mounted=((*it)=="true"); if (mounted) {// if (mp=="/") mp=""; redirection(KURL( mp )); finished(); } else { if (mp.startsWith("file:/")) { KProcess *proc = new KProcess; *proc << "kio_devices_mounthelper"; *proc << "-m" << url.url(); proc->start(KProcess::Block); int ec=0; if (proc->normalExit()) ec=proc->exitStatus(); delete proc; if (ec) { error(KIO::ERR_SLAVE_DEFINED,i18n("Device not mounted")); finished(); } else { redirection(KURL( mp )); finished(); } } else error(KIO::ERR_SLAVE_DEFINED,i18n("Device not accessible")); } return; } } } } error(KIO::ERR_SLAVE_DEFINED,i18n("Illegal data received")); }}
QByteArray data; QByteArray param; QCString retType; bool retVal=false; QDataStream streamout(param,IO_WriteOnly); streamout<<id; if ( m_dcopClient->call( "kded", "mountwatcher", "mounted(int)", param,retType,data,false ) ) { QDataStream streamin(data,IO_ReadOnly); streamin>>retVal; } return retVal;
QByteArray data; QByteArray param; QCString retType; bool retVal=false; QDataStream streamout(param,IO_WriteOnly); streamout<<id; if ( dcopClient()->call( "kded", "mountwatcher", "mounted(int)", param,retType,data,false ) ) { QDataStream streamin(data,IO_ReadOnly); streamin>>retVal; } return retVal;
bool DevicesProtocol::deviceMounted(int id){ QByteArray data; QByteArray param; QCString retType; bool retVal=false; QDataStream streamout(param,IO_WriteOnly); streamout<<id; if ( m_dcopClient->call( "kded", "mountwatcher", "mounted(int)", param,retType,data,false ) ) { QDataStream streamin(data,IO_ReadOnly); streamin>>retVal; } return retVal;}
kdDebug()<<"list dir: Fullmode=="<<fullMode<<endl;
kdDebug(7126)<<"list dir: Fullmode=="<<fullMode<<endl;
QStringList DevicesProtocol::deviceList(){ QByteArray data; QByteArray param; QCString retType; QStringList retVal; QDataStream streamout(param,IO_WriteOnly); kdDebug()<<"list dir: Fullmode=="<<fullMode<<endl; QString dcopFun=fullMode?"basicSystemList()":"basicList()"; if ( m_dcopClient->call( "kded", "mountwatcher", dcopFun.utf8(), param,retType,data,false ) ) { QDataStream streamin(data,IO_ReadOnly); streamin>>retVal; } else { retVal.append(QString::fromLatin1("!!!ERROR!!!")); } // add mobile devices info (kmobile) retVal += kmobile_list(QString::null); return retVal;}
if ( m_dcopClient->call( "kded", "mountwatcher", dcopFun.utf8(), param,retType,data,false ) ) { QDataStream streamin(data,IO_ReadOnly); streamin>>retVal; }
if ( dcopClient()->call( "kded", "mountwatcher", dcopFun.utf8(), param,retType,data,false ) ) { QDataStream streamin(data,IO_ReadOnly); streamin>>retVal; }
QStringList DevicesProtocol::deviceList(){ QByteArray data; QByteArray param; QCString retType; QStringList retVal; QDataStream streamout(param,IO_WriteOnly); kdDebug()<<"list dir: Fullmode=="<<fullMode<<endl; QString dcopFun=fullMode?"basicSystemList()":"basicList()"; if ( m_dcopClient->call( "kded", "mountwatcher", dcopFun.utf8(), param,retType,data,false ) ) { QDataStream streamin(data,IO_ReadOnly); streamin>>retVal; } else { retVal.append(QString::fromLatin1("!!!ERROR!!!")); } // add mobile devices info (kmobile) retVal += kmobile_list(QString::null); return retVal;}
QByteArray data; QByteArray param; QCString retType; QString retVal; QDataStream streamout(param,IO_WriteOnly); streamout<<dev; if ( m_dcopClient->call( "kded", "mountwatcher", "mountpoint(QString)", param,retType,data,false ) ) { QDataStream streamin(data,IO_ReadOnly); streamin>>retVal; } return retVal;
QByteArray data; QByteArray param; QCString retType; QString retVal; QDataStream streamout(param,IO_WriteOnly); streamout<<dev; if ( dcopClient()->call( "kded", "mountwatcher", "mountpoint(QString)", param,retType,data,false ) ) { QDataStream streamin(data,IO_ReadOnly); streamin>>retVal; } return retVal;
QString DevicesProtocol::mountPoint(const QString dev){ QByteArray data; QByteArray param; QCString retType; QString retVal; QDataStream streamout(param,IO_WriteOnly); streamout<<dev; if ( m_dcopClient->call( "kded", "mountwatcher", "mountpoint(QString)", param,retType,data,false ) ) { QDataStream streamin(data,IO_ReadOnly); streamin>>retVal; } return retVal;}
if ( m_dcopClient->call( "kded",
if ( dcopClient()->call( "kded",
QString DevicesProtocol::deviceNode(uint id){ QByteArray data; QByteArray param; QCString retType; QString retVal; QDataStream streamout(param,IO_WriteOnly); streamout<<id; if ( m_dcopClient->call( "kded", "mountwatcher", "devicenode(int)", param,retType,data,false ) ) { QDataStream streamin(data,IO_ReadOnly); streamin>>retVal; } return retVal;}
QByteArray data; QByteArray param; QCString retType; QStringList retVal; QDataStream streamout(param,IO_WriteOnly); streamout<<name; if ( m_dcopClient->call( "kded", "mountwatcher", "basicDeviceInfo(QString)", param,retType,data,false ) ) { QDataStream streamin(data,IO_ReadOnly); streamin>>retVal; }
QByteArray data; QByteArray param; QCString retType; QStringList retVal; QDataStream streamout(param,IO_WriteOnly); streamout<<name; if ( dcopClient()->call( "kded", "mountwatcher", "basicDeviceInfo(QString)", param,retType,data,false ) ) { QDataStream streamin(data,IO_ReadOnly); streamin>>retVal; }
QStringList DevicesProtocol::deviceInfo(QString name){ QByteArray data; QByteArray param; QCString retType; QStringList retVal; QDataStream streamout(param,IO_WriteOnly); streamout<<name; if ( m_dcopClient->call( "kded", "mountwatcher", "basicDeviceInfo(QString)", param,retType,data,false ) ) { QDataStream streamin(data,IO_ReadOnly); streamin>>retVal; } // kmobile support if (retVal.isEmpty()) retVal = kmobile_list(name); return retVal;}
kdDebug()<<"DevicesProtocol: Called with slavename:"<<protocol<<endl;
kdDebug(7126)<<"Called with slavename: " << protocol << endl;
DevicesProtocol::DevicesProtocol( const QCString& protocol, const QCString &pool, const QCString &app): SlaveBase(protocol, pool, app ){ kdDebug()<<"DevicesProtocol: Called with slavename:"<<protocol<<endl; if (protocol=="system") fullMode=true; else fullMode=false; m_dcopClient=new DCOPClient(); if (!m_dcopClient->attach()) { kdDebug()<<"ERROR WHILE CONNECTING TO DCOPSERVER"<<endl; }}
m_dcopClient=new DCOPClient(); if (!m_dcopClient->attach()) { kdDebug()<<"ERROR WHILE CONNECTING TO DCOPSERVER"<<endl; }
DevicesProtocol::DevicesProtocol( const QCString& protocol, const QCString &pool, const QCString &app): SlaveBase(protocol, pool, app ){ kdDebug()<<"DevicesProtocol: Called with slavename:"<<protocol<<endl; if (protocol=="system") fullMode=true; else fullMode=false; m_dcopClient=new DCOPClient(); if (!m_dcopClient->attach()) { kdDebug()<<"ERROR WHILE CONNECTING TO DCOPSERVER"<<endl; }}
QByteArray data; QByteArray param; QCString retType; QString retVal; QDataStream streamout(param,IO_WriteOnly); streamout<<id; if ( m_dcopClient->call( "kded", "mountwatcher", "type(int)", param,retType,data,false ) ) { QDataStream streamin(data,IO_ReadOnly); streamin>>retVal; } return retVal;
QByteArray data; QByteArray param; QCString retType; QString retVal; QDataStream streamout(param,IO_WriteOnly); streamout<<id; if ( dcopClient()->call( "kded", "mountwatcher", "type(int)", param,retType,data,false ) ) { QDataStream streamin(data,IO_ReadOnly); streamin>>retVal; } return retVal;
QString DevicesProtocol::deviceType(int id){ QByteArray data; QByteArray param; QCString retType; QString retVal; QDataStream streamout(param,IO_WriteOnly); streamout<<id; if ( m_dcopClient->call( "kded", "mountwatcher", "type(int)", param,retType,data,false ) ) { QDataStream streamin(data,IO_ReadOnly); streamin>>retVal; } return retVal;}
kio_sftpProtocol slave(argv[2], argv[3]);
sftpProtocol slave(argv[2], argv[3]);
int kdemain( int argc, char **argv ) { KInstance instance( "kio_sftp" ); kdDebug(KIO_SFTP_DB) << "*** Starting kio_sftp " << endl; if (argc != 4) { kdDebug(KIO_SFTP_DB) << "Usage: kio_sftp protocol domain-socket1 domain-socket2" << endl; exit(-1); } kio_sftpProtocol slave(argv[2], argv[3]); slave.dispatchLoop(); kdDebug(KIO_SFTP_DB) << "*** kio_sftp Done" << endl; return 0; }
cinode_pins[by]--;
void put(int by) { if (ref == 0 || ref_set.count(by) != 1) { dout(7) << " bad put " << *this << " by " << by << " " << cinode_pin_names[by] << " was " << ref << " (" << ref_set << ")" << endl; assert(ref_set.count(by) == 1); assert(ref > 0); } ref--; ref_set.erase(by); if (ref == 0) lru_unpin(); dout(7) << " put " << *this << " by " << by << " " << cinode_pin_names[by] << " now " << ref << " (" << ref_set << ")" << endl; }
configMustDeleted=true; }
int main(int argc, char **argv){ KAboutData aboutData("kreadconfig", I18N_NOOP("KReadConfig"), "1.0.1", I18N_NOOP("Read KConfig entries - for use in shell scripts"), KAboutData::License_GPL, "(c) 2001 Red Hat, Inc."); aboutData.addAuthor("Bernhard Rosenkraenzer", 0, "[email protected]"); KCmdLineArgs::init(argc, argv, &aboutData); KCmdLineArgs::addCmdLineOptions(options); KCmdLineArgs *args=KCmdLineArgs::parsedArgs(); QString group=QString::fromLocal8Bit(args->getOption("group")); QString key=QString::fromLocal8Bit(args->getOption("key")); QString file=QString::fromLocal8Bit(args->getOption("file")); QCString dflt=args->getOption("default"); QCString type=args->getOption("type").lower(); if (key.isNull()) { KCmdLineArgs::usage(); return 1; } KInstance inst(&aboutData); KConfig *konfig; if (file.isEmpty()) konfig = KGlobal::config(); else konfig = new KConfig(file, true, false); konfig->setGroup(group); if(type=="bool") { dflt=dflt.lower(); bool def=(dflt=="true" || dflt=="on" || dflt=="yes" || dflt=="1"); return !konfig->readBoolEntry(key, def); } else if(type=="num") { return konfig->readLongNumEntry(key, dflt.toLong()); } else { /* Assume it's a string... */ fprintf(stdout, "%s\n", konfig->readEntry(key, dflt).local8Bit().data()); return 0; }}
return !konfig->readBoolEntry(key, def);
bool retValue = !konfig->readBoolEntry(key, def); if ( configMustDeleted ) delete konfig; return retValue;
int main(int argc, char **argv){ KAboutData aboutData("kreadconfig", I18N_NOOP("KReadConfig"), "1.0.1", I18N_NOOP("Read KConfig entries - for use in shell scripts"), KAboutData::License_GPL, "(c) 2001 Red Hat, Inc."); aboutData.addAuthor("Bernhard Rosenkraenzer", 0, "[email protected]"); KCmdLineArgs::init(argc, argv, &aboutData); KCmdLineArgs::addCmdLineOptions(options); KCmdLineArgs *args=KCmdLineArgs::parsedArgs(); QString group=QString::fromLocal8Bit(args->getOption("group")); QString key=QString::fromLocal8Bit(args->getOption("key")); QString file=QString::fromLocal8Bit(args->getOption("file")); QCString dflt=args->getOption("default"); QCString type=args->getOption("type").lower(); if (key.isNull()) { KCmdLineArgs::usage(); return 1; } KInstance inst(&aboutData); KConfig *konfig; if (file.isEmpty()) konfig = KGlobal::config(); else konfig = new KConfig(file, true, false); konfig->setGroup(group); if(type=="bool") { dflt=dflt.lower(); bool def=(dflt=="true" || dflt=="on" || dflt=="yes" || dflt=="1"); return !konfig->readBoolEntry(key, def); } else if(type=="num") { return konfig->readLongNumEntry(key, dflt.toLong()); } else { /* Assume it's a string... */ fprintf(stdout, "%s\n", konfig->readEntry(key, dflt).local8Bit().data()); return 0; }}
return konfig->readLongNumEntry(key, dflt.toLong());
long retValue = konfig->readLongNumEntry(key, dflt.toLong()); if ( configMustDeleted ) delete konfig; return retValue;
int main(int argc, char **argv){ KAboutData aboutData("kreadconfig", I18N_NOOP("KReadConfig"), "1.0.1", I18N_NOOP("Read KConfig entries - for use in shell scripts"), KAboutData::License_GPL, "(c) 2001 Red Hat, Inc."); aboutData.addAuthor("Bernhard Rosenkraenzer", 0, "[email protected]"); KCmdLineArgs::init(argc, argv, &aboutData); KCmdLineArgs::addCmdLineOptions(options); KCmdLineArgs *args=KCmdLineArgs::parsedArgs(); QString group=QString::fromLocal8Bit(args->getOption("group")); QString key=QString::fromLocal8Bit(args->getOption("key")); QString file=QString::fromLocal8Bit(args->getOption("file")); QCString dflt=args->getOption("default"); QCString type=args->getOption("type").lower(); if (key.isNull()) { KCmdLineArgs::usage(); return 1; } KInstance inst(&aboutData); KConfig *konfig; if (file.isEmpty()) konfig = KGlobal::config(); else konfig = new KConfig(file, true, false); konfig->setGroup(group); if(type=="bool") { dflt=dflt.lower(); bool def=(dflt=="true" || dflt=="on" || dflt=="yes" || dflt=="1"); return !konfig->readBoolEntry(key, def); } else if(type=="num") { return konfig->readLongNumEntry(key, dflt.toLong()); } else { /* Assume it's a string... */ fprintf(stdout, "%s\n", konfig->readEntry(key, dflt).local8Bit().data()); return 0; }}
if ( configMustDeleted ) delete konfig;
int main(int argc, char **argv){ KAboutData aboutData("kreadconfig", I18N_NOOP("KReadConfig"), "1.0.1", I18N_NOOP("Read KConfig entries - for use in shell scripts"), KAboutData::License_GPL, "(c) 2001 Red Hat, Inc."); aboutData.addAuthor("Bernhard Rosenkraenzer", 0, "[email protected]"); KCmdLineArgs::init(argc, argv, &aboutData); KCmdLineArgs::addCmdLineOptions(options); KCmdLineArgs *args=KCmdLineArgs::parsedArgs(); QString group=QString::fromLocal8Bit(args->getOption("group")); QString key=QString::fromLocal8Bit(args->getOption("key")); QString file=QString::fromLocal8Bit(args->getOption("file")); QCString dflt=args->getOption("default"); QCString type=args->getOption("type").lower(); if (key.isNull()) { KCmdLineArgs::usage(); return 1; } KInstance inst(&aboutData); KConfig *konfig; if (file.isEmpty()) konfig = KGlobal::config(); else konfig = new KConfig(file, true, false); konfig->setGroup(group); if(type=="bool") { dflt=dflt.lower(); bool def=(dflt=="true" || dflt=="on" || dflt=="yes" || dflt=="1"); return !konfig->readBoolEntry(key, def); } else if(type=="num") { return konfig->readLongNumEntry(key, dflt.toLong()); } else { /* Assume it's a string... */ fprintf(stdout, "%s\n", konfig->readEntry(key, dflt).local8Bit().data()); return 0; }}
KApplication app( false, true);
KApplication app( true);
int kdemain(int argc, char **argv){#ifdef HAVE_NICE nice( 5 );#endif#ifdef USE_KINSTANCE KInstance instance("kio_thumbnail");#else // creating KApplication in a slave in not a very good idea, // as dispatchLoop() doesn't allow it to process its messages, // so it for example wouldn't reply to ksmserver - on the other // hand, this slave uses QPixmaps for some reason, and they // need QApplication // and HTML previews need even KApplication :( putenv(strdup("SESSION_MANAGER=")); KApplication::disableAutoDcopRegistration(); KAboutData about("kio_thumbnail", "kio_thumbmail", "KDE 4.x.x"); KCmdLineArgs::init(&about); KApplication app( false, true);#endif if (argc != 4) { kdError(7115) << "Usage: kio_thumbnail protocol domain-socket1 domain-socket2" << endl; exit(-1); } ThumbnailProtocol slave(argv[2], argv[3]); slave.dispatchLoop(); return 0;}
CheesySerializer *serializer = new CheesySerializer( new TCPMessenger(MSG_ADDR_CLIENT(i)) ); client[i] = new Client(mdc, i, serializer);
client[i] = new Client(mdc, i, new TCPMessenger(MSG_ADDR_CLIENT(i)) );
int main(int oargc, char **oargv) { //cerr << "tcpsyn starting " << myrank << "/" << world << endl; int argc; char **argv; parse_config_options(oargc, oargv, argc, argv); int start = 0; // build new argc+argv for fuse typedef char* pchar; int nargc = 0; char **nargv = new pchar[argc]; nargv[nargc++] = argv[0]; string syn_sarg1; int syn_mode = SYNCLIENT_MODE_WRITEFILE; int syn_iarg1, syn_iarg2, syn_iarg3; int mkfs = 0; for (int i=1; i<argc; i++) { if (strcmp(argv[i], "--fastmkfs") == 0) { mkfs = MDS_MKFS_FAST; } else if (strcmp(argv[i], "--fullmkfs") == 0) { mkfs = MDS_MKFS_FULL; } else if (strcmp(argv[i],"--synsarg1") == 0) syn_sarg1 = argv[++i]; else if (strcmp(argv[i],"--syniarg1") == 0) syn_iarg1 = atoi(argv[++i]); else if (strcmp(argv[i],"--syniarg2") == 0) syn_iarg2 = atoi(argv[++i]); else if (strcmp(argv[i],"--syniarg3") == 0) syn_iarg3 = atoi(argv[++i]); else if (strcmp(argv[i],"--synmode") == 0) { ++i; if (strcmp(argv[i],"writefile") == 0) syn_mode = SYNCLIENT_MODE_WRITEFILE; else if (strcmp(argv[i],"makedirs") == 0) syn_mode = SYNCLIENT_MODE_MAKEDIRS; else if (strcmp(argv[i],"fullwalk") == 0) syn_mode = SYNCLIENT_MODE_FULLWALK; else if (strcmp(argv[i],"randomwalk") == 0) syn_mode = SYNCLIENT_MODE_RANDOMWALK; else { cerr << "unknown syn mode " << argv[i] << endl; return -1; } } else { // unknown arg, pass it on. nargv[nargc++] = argv[i]; } } int myrank = tcpmessenger_init(argc, argv); int world = tcpmessenger_world(); if (myrank == 0) cerr << "nummds " << NUMMDS << " numosd " << NUMOSD << " numclient " << NUMCLIENT << endl; assert(NUMMDS + NUMOSD + 1 <= world); MDCluster *mdc = new MDCluster(NUMMDS, NUMOSD); char hostname[100]; gethostname(hostname,100); int pid = getpid(); // create mds MDS *mds[NUMMDS]; for (int i=0; i<NUMMDS; i++) { if (myrank != MPI_DEST_TO_RANK(MSG_ADDR_MDS(i),world)) continue; cerr << "mds" << i << " on rank " << myrank << " " << hostname << "." << pid << endl; mds[i] = new MDS(mdc, i, new TCPMessenger(MSG_ADDR_MDS(i))); start++; } // create osd OSD *osd[NUMOSD]; for (int i=0; i<NUMOSD; i++) { if (myrank != MPI_DEST_TO_RANK(MSG_ADDR_OSD(i),world)) continue; cerr << "osd" << i << " on rank " << myrank << " " << hostname << "." << pid << endl; osd[i] = new OSD(i, new TCPMessenger(MSG_ADDR_OSD(i))); start++; } // create client Client *client[NUMCLIENT]; SyntheticClient *syn[NUMCLIENT]; for (int i=0; i<NUMCLIENT; i++) { if (myrank != MPI_DEST_TO_RANK(MSG_ADDR_CLIENT(i),world)) continue; cerr << "client" << i << " on rank " << myrank << " " << hostname << "." << pid << endl; CheesySerializer *serializer = new CheesySerializer( new TCPMessenger(MSG_ADDR_CLIENT(i)) ); client[i] = new Client(mdc, i, serializer); start++; } // start message loop if (start) { tcpmessenger_start(); // init for (int i=0; i<NUMMDS; i++) { if (myrank != MPI_DEST_TO_RANK(MSG_ADDR_MDS(i),world)) continue; mds[i]->init(); } for (int i=0; i<NUMOSD; i++) { if (myrank != MPI_DEST_TO_RANK(MSG_ADDR_OSD(i),world)) continue; osd[i]->init(); } // create client for (int i=0; i<NUMCLIENT; i++) { if (myrank != MPI_DEST_TO_RANK(MSG_ADDR_CLIENT(i),world)) continue; client[i]->init(); // use my argc, argv (make sure you pass a mount point!) //cout << "mounting" << endl; client[i]->mount(mkfs); //cout << "starting synthetic client on rank " << myrank << endl; syn[i] = new SyntheticClient(client[i]); char s[20]; sprintf(s,"syn.%d", i); syn[i]->sarg1 = s; syn[i]->mode = syn_mode; syn[i]->iarg1 = syn_iarg1; syn[i]->iarg2 = syn_iarg2; syn[i]->iarg3 = syn_iarg3; syn[i]->start_thread(); } for (int i=0; i<NUMCLIENT; i++) { if (myrank != MPI_DEST_TO_RANK(MSG_ADDR_CLIENT(i),world)) continue; cout << "waiting for synthetic client" << i << " to finish" << endl; syn[i]->join_thread(); delete syn[i]; client[i]->unmount(); //cout << "client" << i << " unmounted" << endl; client[i]->shutdown(); } // wait for it to finish tcpmessenger_wait(); //assert(0); } else { cerr << "IDLE rank " << myrank << endl; } tcpmessenger_shutdown(); // cleanup for (int i=0; i<NUMMDS; i++) { if (myrank != MPI_DEST_TO_RANK(MSG_ADDR_MDS(i),world)) continue; delete mds[i]; } for (int i=0; i<NUMOSD; i++) { if (myrank != MPI_DEST_TO_RANK(MSG_ADDR_OSD(i),world)) continue; delete osd[i]; } for (int i=0; i<NUMCLIENT; i++) { if (myrank != MPI_DEST_TO_RANK(MSG_ADDR_CLIENT(i),world)) continue; delete client[i]; } delete mdc; return 0;}
optionChar = getopt_long (argc, argv, "slp",
optionChar = getopt_long (argc, argv, "slpe",
int main(int argc, char *argv[]){ ///////////////////////////////////////////////////////////////// // Command line options 'behaviour' flag setup //////////////////////////////////////////////////////////////// // // Parse the command line arguments, looking to see if the user has asked for any // special behaviours. Any remaining non command arguments will be kept aside to // be passed as a list of layers and / or a project that should be loaded. // // This behaviour is used to load the app, snapshot the map, // save the image to disk and then exit QString mySnapshotFileName=""; // This behaviour will cause QGIS to autoload a project QString myProjectFileName=""; // This behaviour will allow you to force the use of a translation file // which is useful for testing QString myTranslationFileName=""; // This is the 'leftover' arguments collection QStringList * myFileList=new QStringList();#ifndef WIN32 if ( !bundleclicked(argc, argv) ) { //////////////////////////////////////////////////////////////// // USe the GNU Getopts utility to parse cli arguments // Invokes ctor `GetOpt (int argc, char **argv, char *optstring);' /////////////////////////////////////////////////////////////// int optionChar; while (1) { static struct option long_options[] = { /* These options set a flag. */ {"help", no_argument, 0, 'h'}, /* These options don't set a flag. * We distinguish them by their indices. */ {"snapshot", required_argument, 0, 's'}, {"lang", required_argument, 0, 'l'}, {"project", required_argument, 0, 'p'}, {0, 0, 0, 0} }; /* getopt_long stores the option index here. */ int option_index = 0; optionChar = getopt_long (argc, argv, "slp", long_options, &option_index); /* Detect the end of the options. */ if (optionChar == -1) break; switch (optionChar) { case 0: /* If this option set a flag, do nothing else now. */ if (long_options[option_index].flag != 0) break; printf ("option %s", long_options[option_index].name); if (optarg) printf (" with arg %s", optarg); printf ("\n"); break; case 's': mySnapshotFileName = optarg; break; case 'l': myTranslationFileName = optarg; break; case 'p': myProjectFileName = optarg; break; case 'h': case '?': usage( argv[0] ); return 2; // XXX need standard exit codes break; default: std::cerr << argv[0] << ": getopt returned character code " << optionChar << "\n"; return 1; // XXX need standard exit codes } } // Add any remaining args to the file list - we will attempt to load them // as layers in the map view further down....#ifdef QGISDEBUG std::cout << "Files specified on command line: " << optind << std::endl;#endif if (optind < argc) { while (optind < argc) {#ifdef QGISDEBUG int idx = optind; std::cout << idx << ": " << argv[idx] << std::endl;#endif myFileList->append(argv[optind++]); } } }#endif //WIN32 ///////////////////////////////////////////////////////////////////// // Now we have the handlers for the different behaviours... //////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// // Initialise the application and the translation stuff /////////////////////////////////////////////////////////////////////#ifdef Q_WS_X11 bool myUseGuiFlag = getenv( "DISPLAY" ) != 0;#else bool myUseGuiFlag = TRUE;#endif if (!myUseGuiFlag) { std::cerr << "QGIS starting in non-interactive mode not supported.\n You are seeing this message most likely because you have no DISPLAY environment variable set." << std::endl; exit(1); //exit for now until a version of qgis is capabable of running non interactive } QApplication a(argc, argv, myUseGuiFlag ); // Check to see if qgis was started from the source directory. // This is done by looking for Makefile in the directory where qgis was // started from. If running from the src directory, exit gracefully // Get the application path. This method is required to support qt 3.1.2 // which does not support the applicationFilePath and applicationDirPath // functions. We assume that OS X and Win32 systems will be using at least // Qt 3.2 and therefore support the required functions.#if defined(Q_OS_MACX) || defined(WIN32) QString appPath = qApp->applicationFilePath(); QString appDir = qApp->applicationDirPath(); QString testFile = "Makefile";#else QString appPath = argv[0]; QString appDir = appPath.left(appPath.findRev("/")); QString testFile = "lt-qgis";#endif if(appPath.contains("/src/")) { // check to see if configure is present in the directory QFileInfo fi(appDir + "/" + testFile); if(fi.exists()) { QMessageBox::critical(0,"QGIS Not Installed", "You appear to be running QGIS from the source directory.\n" "You must install QGIS using make install and run it from the " "installed directory."); exit(1); } } // a.setFont(QFont("helvetica", 11));#if defined(Q_OS_MACX) || defined(WIN32) QString PKGDATAPATH = qApp->applicationDirPath() + "/share/qgis";#endif QTranslator tor(0); // For WIN32, get the locale if (myTranslationFileName!="") { QString translation = "qgis_" + myTranslationFileName; tor.load(translation, QString(PKGDATAPATH) + "/i18n"); } else {#ifdef QGISDEBUG std::cout << "Setting translation to " << PKGDATAPATH << "/i18n/qgis_" << QTextCodec::locale() << std::endl; #endif tor.load(QString("qgis_") + QTextCodec::locale(), QString(PKGDATAPATH) + "/i18n"); } //tor.load("qgis_go", "." ); a.installTranslator(&tor); /* uncomment the following line, if you want a Windows 95 look */ //a.setStyle("Windows"); QgisApp *qgis = new QgisApp; // "QgisApp" used to find canonical instance qgis->setName( "QgisApp" ); a.setMainWidget(qgis); ///////////////////////////////////////////////////////////////////// // If no --project was specified, parse the args to look for a // // .qgs file and set myProjectFileName to it. This allows loading // // of a project file by clicking on it in various desktop managers // // where an appropriate mime-type has been set up. // ///////////////////////////////////////////////////////////////////// if(myProjectFileName.isEmpty()) { // check for a .qgs for(int i = 0; i < argc; i++) { QString arg = argv[i]; if(arg.contains(".qgs")) { myProjectFileName = argv[i]; break; } } } ///////////////////////////////////////////////////////////////////// // Load a project file if one was specified ///////////////////////////////////////////////////////////////////// if( ! myProjectFileName.isEmpty() ) {// if ( ! qgis->addProject(myProjectFileName) )// {// #ifdef QGISDEBUG// std::cerr << "unable to load project " << myProjectFileName << "\n";// #endif// } try { if ( ! qgis->addProject(myProjectFileName) ) {#ifdef QGISDEBUG std::cerr << "unable to load project " << myProjectFileName << "\n";#endif } } catch ( QgsIOException & io_exception ) { QMessageBox::critical( 0x0, "QGIS: Unable to load project", "Unable to load project " + myProjectFileName ); } } ///////////////////////////////////////////////////////////////////// // autoload any filenames that were passed in on the command line /////////////////////////////////////////////////////////////////////#ifdef QGISDEBUG std::cout << "Number of files in myFileList: " << myFileList->count() << std::endl;#endif for ( QStringList::Iterator myIterator = myFileList->begin(); myIterator != myFileList->end(); ++myIterator ) {#ifdef QGISDEBUG std::cout << "Trying to load file : " << *myIterator << std::endl;#endif QString myLayerName = *myIterator; // don't load anything with a .qgs extension - these are project files if(!myLayerName.contains(".qgs")) { // try to add all these layers - any unsupported file types will // be rejected automatically // The funky bool ok is so this can be debugged a bit easier... //nope - try and load it as raster bool ok = qgis->addRasterLayer(QFileInfo(myLayerName), false); if(!ok){ //nope - try and load it as a shape/ogr ok = qgis->addLayer(QFileInfo(myLayerName)); //we have no idea what this layer is... if(!ok){ std::cout << "Unable to load " << myLayerName << std::endl; } } } } ///////////////////////////////////////////////////////////////////// // Take a snapshot of the map view then exit if snapshot mode requested ///////////////////////////////////////////////////////////////////// if(mySnapshotFileName!="") { /*You must have at least one paintEvent() delivered for the window to be rendered properly. It looks like you don't run the event loop in non-interactive mode, so the event is never occuring. To achieve this without runing the event loop: show the window, then call qApp->processEvents(), grab the pixmap, save it, hide the window and exit. */ //qgis->show(); a.processEvents(); QPixmap * myQPixmap = new QPixmap(800,600); myQPixmap->fill(); qgis->saveMapAsImage(mySnapshotFileName,myQPixmap); a.processEvents(); qgis->hide(); return 1; } ///////////////////////////////////////////////////////////////////// // Continue on to interactive gui... ///////////////////////////////////////////////////////////////////// qgis->show(); a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); return a.exec();}
if ( ! myInitialExtent.isEmpty() ) { double coords[4]; int pos, posOld = 0; bool ok; for (int i = 0; i < 3; i++) { pos = myInitialExtent.find(',', posOld); if (pos == -1) { ok = false; break; } coords[i] = QString( myInitialExtent.mid(posOld, pos - posOld) ).toDouble(&ok); if (!ok) break; posOld = pos+1; } if (ok) coords[3] = QString( myInitialExtent.mid(posOld) ).toDouble(&ok); if (!ok) std::cout << "Error while parsing initial extent!" << std::endl; else { QgsRect rect(coords[0],coords[1],coords[2],coords[3]); qgis->getMapCanvas()->setExtent(rect); } }
int main(int argc, char *argv[]){ ///////////////////////////////////////////////////////////////// // Command line options 'behaviour' flag setup //////////////////////////////////////////////////////////////// // // Parse the command line arguments, looking to see if the user has asked for any // special behaviours. Any remaining non command arguments will be kept aside to // be passed as a list of layers and / or a project that should be loaded. // // This behaviour is used to load the app, snapshot the map, // save the image to disk and then exit QString mySnapshotFileName=""; // This behaviour will cause QGIS to autoload a project QString myProjectFileName=""; // This behaviour will allow you to force the use of a translation file // which is useful for testing QString myTranslationFileName=""; // This is the 'leftover' arguments collection QStringList * myFileList=new QStringList();#ifndef WIN32 if ( !bundleclicked(argc, argv) ) { //////////////////////////////////////////////////////////////// // USe the GNU Getopts utility to parse cli arguments // Invokes ctor `GetOpt (int argc, char **argv, char *optstring);' /////////////////////////////////////////////////////////////// int optionChar; while (1) { static struct option long_options[] = { /* These options set a flag. */ {"help", no_argument, 0, 'h'}, /* These options don't set a flag. * We distinguish them by their indices. */ {"snapshot", required_argument, 0, 's'}, {"lang", required_argument, 0, 'l'}, {"project", required_argument, 0, 'p'}, {0, 0, 0, 0} }; /* getopt_long stores the option index here. */ int option_index = 0; optionChar = getopt_long (argc, argv, "slp", long_options, &option_index); /* Detect the end of the options. */ if (optionChar == -1) break; switch (optionChar) { case 0: /* If this option set a flag, do nothing else now. */ if (long_options[option_index].flag != 0) break; printf ("option %s", long_options[option_index].name); if (optarg) printf (" with arg %s", optarg); printf ("\n"); break; case 's': mySnapshotFileName = optarg; break; case 'l': myTranslationFileName = optarg; break; case 'p': myProjectFileName = optarg; break; case 'h': case '?': usage( argv[0] ); return 2; // XXX need standard exit codes break; default: std::cerr << argv[0] << ": getopt returned character code " << optionChar << "\n"; return 1; // XXX need standard exit codes } } // Add any remaining args to the file list - we will attempt to load them // as layers in the map view further down....#ifdef QGISDEBUG std::cout << "Files specified on command line: " << optind << std::endl;#endif if (optind < argc) { while (optind < argc) {#ifdef QGISDEBUG int idx = optind; std::cout << idx << ": " << argv[idx] << std::endl;#endif myFileList->append(argv[optind++]); } } }#endif //WIN32 ///////////////////////////////////////////////////////////////////// // Now we have the handlers for the different behaviours... //////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// // Initialise the application and the translation stuff /////////////////////////////////////////////////////////////////////#ifdef Q_WS_X11 bool myUseGuiFlag = getenv( "DISPLAY" ) != 0;#else bool myUseGuiFlag = TRUE;#endif if (!myUseGuiFlag) { std::cerr << "QGIS starting in non-interactive mode not supported.\n You are seeing this message most likely because you have no DISPLAY environment variable set." << std::endl; exit(1); //exit for now until a version of qgis is capabable of running non interactive } QApplication a(argc, argv, myUseGuiFlag ); // Check to see if qgis was started from the source directory. // This is done by looking for Makefile in the directory where qgis was // started from. If running from the src directory, exit gracefully // Get the application path. This method is required to support qt 3.1.2 // which does not support the applicationFilePath and applicationDirPath // functions. We assume that OS X and Win32 systems will be using at least // Qt 3.2 and therefore support the required functions.#if defined(Q_OS_MACX) || defined(WIN32) QString appPath = qApp->applicationFilePath(); QString appDir = qApp->applicationDirPath(); QString testFile = "Makefile";#else QString appPath = argv[0]; QString appDir = appPath.left(appPath.findRev("/")); QString testFile = "lt-qgis";#endif if(appPath.contains("/src/")) { // check to see if configure is present in the directory QFileInfo fi(appDir + "/" + testFile); if(fi.exists()) { QMessageBox::critical(0,"QGIS Not Installed", "You appear to be running QGIS from the source directory.\n" "You must install QGIS using make install and run it from the " "installed directory."); exit(1); } } // a.setFont(QFont("helvetica", 11));#if defined(Q_OS_MACX) || defined(WIN32) QString PKGDATAPATH = qApp->applicationDirPath() + "/share/qgis";#endif QTranslator tor(0); // For WIN32, get the locale if (myTranslationFileName!="") { QString translation = "qgis_" + myTranslationFileName; tor.load(translation, QString(PKGDATAPATH) + "/i18n"); } else {#ifdef QGISDEBUG std::cout << "Setting translation to " << PKGDATAPATH << "/i18n/qgis_" << QTextCodec::locale() << std::endl; #endif tor.load(QString("qgis_") + QTextCodec::locale(), QString(PKGDATAPATH) + "/i18n"); } //tor.load("qgis_go", "." ); a.installTranslator(&tor); /* uncomment the following line, if you want a Windows 95 look */ //a.setStyle("Windows"); QgisApp *qgis = new QgisApp; // "QgisApp" used to find canonical instance qgis->setName( "QgisApp" ); a.setMainWidget(qgis); ///////////////////////////////////////////////////////////////////// // If no --project was specified, parse the args to look for a // // .qgs file and set myProjectFileName to it. This allows loading // // of a project file by clicking on it in various desktop managers // // where an appropriate mime-type has been set up. // ///////////////////////////////////////////////////////////////////// if(myProjectFileName.isEmpty()) { // check for a .qgs for(int i = 0; i < argc; i++) { QString arg = argv[i]; if(arg.contains(".qgs")) { myProjectFileName = argv[i]; break; } } } ///////////////////////////////////////////////////////////////////// // Load a project file if one was specified ///////////////////////////////////////////////////////////////////// if( ! myProjectFileName.isEmpty() ) {// if ( ! qgis->addProject(myProjectFileName) )// {// #ifdef QGISDEBUG// std::cerr << "unable to load project " << myProjectFileName << "\n";// #endif// } try { if ( ! qgis->addProject(myProjectFileName) ) {#ifdef QGISDEBUG std::cerr << "unable to load project " << myProjectFileName << "\n";#endif } } catch ( QgsIOException & io_exception ) { QMessageBox::critical( 0x0, "QGIS: Unable to load project", "Unable to load project " + myProjectFileName ); } } ///////////////////////////////////////////////////////////////////// // autoload any filenames that were passed in on the command line /////////////////////////////////////////////////////////////////////#ifdef QGISDEBUG std::cout << "Number of files in myFileList: " << myFileList->count() << std::endl;#endif for ( QStringList::Iterator myIterator = myFileList->begin(); myIterator != myFileList->end(); ++myIterator ) {#ifdef QGISDEBUG std::cout << "Trying to load file : " << *myIterator << std::endl;#endif QString myLayerName = *myIterator; // don't load anything with a .qgs extension - these are project files if(!myLayerName.contains(".qgs")) { // try to add all these layers - any unsupported file types will // be rejected automatically // The funky bool ok is so this can be debugged a bit easier... //nope - try and load it as raster bool ok = qgis->addRasterLayer(QFileInfo(myLayerName), false); if(!ok){ //nope - try and load it as a shape/ogr ok = qgis->addLayer(QFileInfo(myLayerName)); //we have no idea what this layer is... if(!ok){ std::cout << "Unable to load " << myLayerName << std::endl; } } } } ///////////////////////////////////////////////////////////////////// // Take a snapshot of the map view then exit if snapshot mode requested ///////////////////////////////////////////////////////////////////// if(mySnapshotFileName!="") { /*You must have at least one paintEvent() delivered for the window to be rendered properly. It looks like you don't run the event loop in non-interactive mode, so the event is never occuring. To achieve this without runing the event loop: show the window, then call qApp->processEvents(), grab the pixmap, save it, hide the window and exit. */ //qgis->show(); a.processEvents(); QPixmap * myQPixmap = new QPixmap(800,600); myQPixmap->fill(); qgis->saveMapAsImage(mySnapshotFileName,myQPixmap); a.processEvents(); qgis->hide(); return 1; } ///////////////////////////////////////////////////////////////////// // Continue on to interactive gui... ///////////////////////////////////////////////////////////////////// qgis->show(); a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); return a.exec();}
KInstance instance("mac");
KInstance instance("kio_mac");
int kdemain(int, char **argv) { KInstance instance("mac"); MacProtocol slave(argv[2], argv[3]); slave.dispatchLoop(); return 0; }
bool ok = qgis->addRasterLayer(myLayerName);
bool ok = qgis->addRasterLayer(myLayerName, false);
int main(int argc, char *argv[]){ ///////////////////////////////////////////////////////////////// // Command line options 'behaviour' flag setup //////////////////////////////////////////////////////////////// // // Parse the command line arguments, looking to see if the user has asked for any // special behaviours. Any remaining non command arguments will be kept aside to // be passed as a list of layers and / or a project that should be loaded. // // This behaviour is used to load the app, snapshot the map, // save the image to disk and then exit QString mySnapshotFileName=""; // This behaviour will cause QGIS to autoload a project QString myProjectFileName=""; // This behaviour will allow you to force the use of a translation file // which is useful for testing QString myTranslationFileName=""; // This is the 'leftover' arguments collection QStringList * myFileList=new QStringList();#ifndef WIN32 //////////////////////////////////////////////////////////////// // USe the GNU Getopts utility to parse cli arguments // Invokes ctor `GetOpt (int argc, char **argv, char *optstring);' /////////////////////////////////////////////////////////////// int optionChar; while (1) { static struct option long_options[] = { /* These options set a flag. */ {"help", no_argument, 0, 'h'}, /* These options don't set a flag. * We distinguish them by their indices. */ {"snapshot", required_argument, 0, 's'}, {"lang", required_argument, 0, 'l'}, {"project", required_argument, 0, 'p'}, {0, 0, 0, 0} }; /* getopt_long stores the option index here. */ int option_index = 0; optionChar = getopt_long (argc, argv, "slp", long_options, &option_index); /* Detect the end of the options. */ if (optionChar == -1) break; switch (optionChar) { case 0: /* If this option set a flag, do nothing else now. */ if (long_options[option_index].flag != 0) break; printf ("option %s", long_options[option_index].name); if (optarg) printf (" with arg %s", optarg); printf ("\n"); break; case 's': mySnapshotFileName=optarg; break; case 'l': myTranslationFileName=optarg; break; case 'p': myProjectFileName=optarg; break; case 'h': case '?': usage( argv[0] ); return 2; // XXX need standard exit codes break; default: std::cerr << argv[0] << ": getopt returned character code " << optionChar << "\n"; return 1; // XXX need standard exit codes } } // Add any remaining args to the file list - we will attempt to load them // as layers in the map view further down....#ifdef QGISDEBUG std::cout << "Files specified on command line: " << optind << std::endl;#endif if (optind < argc) { while (optind < argc) {#ifdef QGISDEBUG int idx = optind; std::cout << idx << ": " << argv[idx] << std::endl;#endif myFileList->append(argv[optind++]); } }#endif //WIN32 ///////////////////////////////////////////////////////////////////// // Now we have the handlers for the different behaviours... //////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// // Initialise the application and the translation stuff /////////////////////////////////////////////////////////////////////#ifdef Q_WS_X11 bool myUseGuiFlag = getenv( "DISPLAY" ) != 0;#else bool myUseGuiFlag = TRUE;#endif if (!myUseGuiFlag) { std::cerr << "QGIS starting in non-interactive mode because you have no DISPLAY environment variable set." << std::endl; } QApplication a(argc, argv, myUseGuiFlag ); // a.setFont(QFont("helvetica", 11)); QTranslator tor(0); // set the location where your .qm files are in load() below as the last parameter instead of "." // for development, use "/" to use the english original as // .qm files are stored in the base project directory. if (myTranslationFileName!="") { QString translation = "qgis_" + myTranslationFileName; tor.load(translation, QString(PKGDATAPATH) + "/i18n"); } else { tor.load(QString("qgis_") + QTextCodec::locale(), QString(PKGDATAPATH) + "/i18n"); } //tor.load("qgis_go", "." ); a.installTranslator(&tor); /* uncomment the following line, if you want a Windows 95 look */ //a.setStyle("Windows"); QgisApp *qgis = new QgisApp(); a.setMainWidget(qgis); ///////////////////////////////////////////////////////////////////// // Load a project file if one was specified ///////////////////////////////////////////////////////////////////// if(myProjectFileName!="") { if ( ! qgis->addProject(myProjectFileName) ) {#ifdef QGISDEBUG std::cerr << "unable to load project " << myProjectFileName << "\n";#endif } } ///////////////////////////////////////////////////////////////////// // autoload any filenames that were passed in on the command line /////////////////////////////////////////////////////////////////////#ifdef QGISDEBUG std::cout << "Number of files in myFileList: " << myFileList->count() << std::endl;#endif for ( QStringList::Iterator myIterator = myFileList->begin(); myIterator != myFileList->end(); ++myIterator ) {#ifdef QGISDEBUG std::cout << "Trying to load file : " << *myIterator << std::endl;#endif QString myLayerName = *myIterator; // try to add all these layers - any unsupported file types will // be rejected automatically // The funky bool ok is so this can be debugged a bit easier... //nope - try and load it as raster bool ok = qgis->addRasterLayer(myLayerName); if(!ok){ //nope - try and load it as a shape/ogr ok = qgis->addLayer(myLayerName); //we have no idea what this layer is... if(!ok){ std::cout << "Unable to load " << myLayerName << std::endl; } } } ///////////////////////////////////////////////////////////////////// // Take a snapshot of the map view then exit if snapshot mode requested ///////////////////////////////////////////////////////////////////// if(mySnapshotFileName!="") { /*You must have at least one paintEvent() delivered for the window to be rendered properly. It looks like you don't run the event loop in non-interactive mode, so the event is never occuring. To achieve this without runing the event loop: show the window, then call qApp->processEvents(), grab the pixmap, save it, hide the window and exit. */ //qgis->show(); a.processEvents(); QPixmap * myQPixmap = new QPixmap(800,600); myQPixmap->fill(); qgis->saveMapAsImage(mySnapshotFileName,myQPixmap); a.processEvents(); qgis->hide(); return 1; } ///////////////////////////////////////////////////////////////////// // Continue on to interactive gui... ///////////////////////////////////////////////////////////////////// qgis->show(); a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); return a.exec();}
if ( m_dcopClient->call( "kded",
if ( dcopClient()->call( "kded",
uint DevicesProtocol::mountpointMappingCount(){ QByteArray data; QByteArray param; QCString retType; uint count=0; if ( m_dcopClient->call( "kded", "mountwatcher", "mountpointMappingCount()", param,retType,data,false ) ) { QDataStream stream1(data,IO_ReadOnly); stream1>>count; } return count;}
QString sectionName(const QString& section)
static QString sectionName(const QString& section)
QString sectionName(const QString& section){ if (section == "1") return i18n("User Commands"); else if (section == "2") return i18n("System Calls"); else if (section == "3") return i18n("Subroutines"); else if (section == "3p") return i18n("Perl Modules"); else if (section == "3n") return i18n("Network Functions"); else if (section == "4") return i18n("Devices"); else if (section == "5") return i18n("File Formats"); else if (section == "6") return i18n("Games"); else if (section == "7") return i18n("Miscellaneous"); else if (section == "8") return i18n("System Administration"); else if (section == "9") return i18n("Kernel"); else if (section == "l") return i18n("Local Documentation"); else if (section == "n") return i18n("New"); return QString::null;}
kdDebug(KIO_SMB) << "Smb: kdemain: starting" << endl;
int kdemain( int argc, char **argv ){ KLocale::setMainCatalogue("kio_smbro"); KInstance instance( "kio_smb" ); if (argc != 4) { fprintf(stderr, "Usage: kio_smb protocol domain-socket1 domain-socket2\n"); exit(-1); } //kdDebug(KIO_SMB) << "Smb: kdemain: starting" << endl; SmbProtocol slave(argv[2], argv[3]); slave.dispatchLoop(); kdDebug(KIO_SMB)<<"exiting normally"<<endl; return 0;}
kdDebug() << "Could not find module '" << args->arg(0) << "'." << endl;
kdWarning() << "Could not find module '" << args->arg(0) << "'." << endl;
extern "C" int kdemain(int _argc, char *_argv[]){ KAboutData aboutData( "kcmshell", I18N_NOOP("KDE Control Module"), KCONTROL_VERSION, I18N_NOOP("A tool to start single KDE control modules"), KAboutData::License_GPL, "(c) 1999-2002, The KDE Developers"); aboutData.addAuthor("Daniel Molkentin", I18N_NOOP("Current Maintainer"), "[email protected]"); aboutData.addAuthor("Matthias Hoelzer-Kluepfel",0, "[email protected]"); aboutData.addAuthor("Matthias Elter",0, "[email protected]"); aboutData.addAuthor("Matthias Ettrich",0, "[email protected]"); aboutData.addAuthor("Waldo Bastian",0, "[email protected]"); KCmdLineArgs::init(_argc, _argv, &aboutData); KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. KLocale::setMainCatalogue("kcontrol"); kcmApplication app; KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); KGlobal::iconLoader()->addAppDir( "kcontrol" ); KGlobal::locale()->setLanguage(args->getOption("lang")); if (args->isSet("list")) { cout << i18n("The following modules are available:").local8Bit() << endl; ConfigModuleList modules; modules.readDesktopEntries(); ConfigModule *module = 0; int maxLen=0; for (module=modules.first(); module != 0; module=modules.next()) { int len = stripPath(module->fileName()).length(); if (len > maxLen) maxLen = len; } for (module=modules.first(); module != 0; module=modules.next()) { QString entry("%1 - %2"); entry = entry.arg(stripPath(module->fileName()).leftJustify(maxLen, ' ')); entry = entry.arg(!module->comment().isEmpty() ? module->comment() : i18n("No description available")); cout << entry.local8Bit() << endl; } return 0; } if (args->count() < 1) { args->usage(); return -1; } if (args->count() == 1) { app.setDCOPName(args->arg(0)); if (app.isRunning()) { app.waitForExit(); return 0; } KService::Ptr service = locateModule(args->arg(0)); if (!service) { kdDebug() << "Could not find module '" << args->arg(0) << "'." << endl; return 1; // error } // load the module KCModuleInfo info(service); KCModule *module = KCModuleLoader::loadModule(info, false); if (module) { // create the dialog QCString embedStr = args->getOption("embed"); bool embed = false; int id = -1; if (!embedStr.isEmpty()) id = embedStr.toInt(&embed); if (!args->isSet("silent")) { if (!embed) { KCDialog * dlg = new KCDialog(module, module->buttons(), info.docPath(), 0, 0, true ); QString caption = (kapp->caption() != i18n("KDE Control Module")) ? kapp->caption() : info.moduleName(); if (kapp->iconName() != kapp->name()) setIcon(dlg, kapp->iconName()); else setIcon(dlg, info.icon()); dlg->setPlainCaption(i18n("Configure - %1").arg(caption)); // Needed for modules that use d'n'd (not really the right // solution for this though, I guess) dlg->setAcceptDrops(true); // run the dialog dlg->exec(); delete dlg; } // if we are going to be embedded, embed else { QWidget *dlg = new ProxyWidget(module, info.moduleName(), "kcmshell", false); // Needed for modules that use d'n'd (not really the right // solution for this though, I guess) dlg->setAcceptDrops(true); QXEmbed::embedClientIntoWindow(dlg, id); kapp->exec(); delete dlg; } } else { //Silent kapp->exec(); } KCModuleLoader::unloadModule(info); return 0; } KCModuleLoader::showLastLoaderError(0L); return 0; } // multiple control modules KService::List modules; for (int i = 0; i < args->count(); i++) { KService::Ptr service = locateModule(args->arg(i)); if (service ) { modules.append(service); continue; } kdDebug() << "Could not find module '" << args->arg(i) << "'." << endl; } if (modules.count() < 1) return -1; // create the dialog KCMultiDialog * dlg = new KCMultiDialog(0, 0, true); // Needed for modules that use d'n'd (not really the right // solution for this though, I guess) dlg->setAcceptDrops(true); // add modules for (KService::List::ConstIterator it = modules.begin(); it != modules.end(); ++it) dlg->addModule(KCModuleInfo(*it)); // if we are going to be embedded, embed QCString embed = args->getOption("embed"); if (!embed.isEmpty()) { bool ok; int id = embed.toInt(&ok); if (ok) { // NOTE: This has to be changed for QT 3.0. See above! QXEmbed::embedClientIntoWindow(dlg, id); delete dlg; return 0; } } if (kapp->iconName() != kapp->name()) setIcon(dlg, kapp->iconName()); dlg->setPlainCaption(i18n("Configure - %1").arg(kapp->caption())); // run the dialog dlg->exec(); delete dlg; return 0;}
kdDebug() << "Could not find module '" << args->arg(i) << "'." << endl;
kdWarning() << "Could not find module '" << args->arg(i) << "'." << endl;
extern "C" int kdemain(int _argc, char *_argv[]){ KAboutData aboutData( "kcmshell", I18N_NOOP("KDE Control Module"), KCONTROL_VERSION, I18N_NOOP("A tool to start single KDE control modules"), KAboutData::License_GPL, "(c) 1999-2002, The KDE Developers"); aboutData.addAuthor("Daniel Molkentin", I18N_NOOP("Current Maintainer"), "[email protected]"); aboutData.addAuthor("Matthias Hoelzer-Kluepfel",0, "[email protected]"); aboutData.addAuthor("Matthias Elter",0, "[email protected]"); aboutData.addAuthor("Matthias Ettrich",0, "[email protected]"); aboutData.addAuthor("Waldo Bastian",0, "[email protected]"); KCmdLineArgs::init(_argc, _argv, &aboutData); KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. KLocale::setMainCatalogue("kcontrol"); kcmApplication app; KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); KGlobal::iconLoader()->addAppDir( "kcontrol" ); KGlobal::locale()->setLanguage(args->getOption("lang")); if (args->isSet("list")) { cout << i18n("The following modules are available:").local8Bit() << endl; ConfigModuleList modules; modules.readDesktopEntries(); ConfigModule *module = 0; int maxLen=0; for (module=modules.first(); module != 0; module=modules.next()) { int len = stripPath(module->fileName()).length(); if (len > maxLen) maxLen = len; } for (module=modules.first(); module != 0; module=modules.next()) { QString entry("%1 - %2"); entry = entry.arg(stripPath(module->fileName()).leftJustify(maxLen, ' ')); entry = entry.arg(!module->comment().isEmpty() ? module->comment() : i18n("No description available")); cout << entry.local8Bit() << endl; } return 0; } if (args->count() < 1) { args->usage(); return -1; } if (args->count() == 1) { app.setDCOPName(args->arg(0)); if (app.isRunning()) { app.waitForExit(); return 0; } KService::Ptr service = locateModule(args->arg(0)); if (!service) { kdDebug() << "Could not find module '" << args->arg(0) << "'." << endl; return 1; // error } // load the module KCModuleInfo info(service); KCModule *module = KCModuleLoader::loadModule(info, false); if (module) { // create the dialog QCString embedStr = args->getOption("embed"); bool embed = false; int id = -1; if (!embedStr.isEmpty()) id = embedStr.toInt(&embed); if (!args->isSet("silent")) { if (!embed) { KCDialog * dlg = new KCDialog(module, module->buttons(), info.docPath(), 0, 0, true ); QString caption = (kapp->caption() != i18n("KDE Control Module")) ? kapp->caption() : info.moduleName(); if (kapp->iconName() != kapp->name()) setIcon(dlg, kapp->iconName()); else setIcon(dlg, info.icon()); dlg->setPlainCaption(i18n("Configure - %1").arg(caption)); // Needed for modules that use d'n'd (not really the right // solution for this though, I guess) dlg->setAcceptDrops(true); // run the dialog dlg->exec(); delete dlg; } // if we are going to be embedded, embed else { QWidget *dlg = new ProxyWidget(module, info.moduleName(), "kcmshell", false); // Needed for modules that use d'n'd (not really the right // solution for this though, I guess) dlg->setAcceptDrops(true); QXEmbed::embedClientIntoWindow(dlg, id); kapp->exec(); delete dlg; } } else { //Silent kapp->exec(); } KCModuleLoader::unloadModule(info); return 0; } KCModuleLoader::showLastLoaderError(0L); return 0; } // multiple control modules KService::List modules; for (int i = 0; i < args->count(); i++) { KService::Ptr service = locateModule(args->arg(i)); if (service ) { modules.append(service); continue; } kdDebug() << "Could not find module '" << args->arg(i) << "'." << endl; } if (modules.count() < 1) return -1; // create the dialog KCMultiDialog * dlg = new KCMultiDialog(0, 0, true); // Needed for modules that use d'n'd (not really the right // solution for this though, I guess) dlg->setAcceptDrops(true); // add modules for (KService::List::ConstIterator it = modules.begin(); it != modules.end(); ++it) dlg->addModule(KCModuleInfo(*it)); // if we are going to be embedded, embed QCString embed = args->getOption("embed"); if (!embed.isEmpty()) { bool ok; int id = embed.toInt(&ok); if (ok) { // NOTE: This has to be changed for QT 3.0. See above! QXEmbed::embedClientIntoWindow(dlg, id); delete dlg; return 0; } } if (kapp->iconName() != kapp->name()) setIcon(dlg, kapp->iconName()); dlg->setPlainCaption(i18n("Configure - %1").arg(kapp->caption())); // run the dialog dlg->exec(); delete dlg; return 0;}
prop = xmlGetNsProp(cur, (const xmlChar *)"version", XSLT_NAMESPACE);
prop = xsltGetNsProp(cur, (const xmlChar *)"version", XSLT_NAMESPACE);
xsltParseStylesheetProcess(xsltStylesheetPtr ret, xmlDocPtr doc) { xmlNodePtr cur; if (doc == NULL) return(NULL); if (ret == NULL) return(ret); /* * First steps, remove blank nodes, * locate the xsl:stylesheet element and the * namespace declaration. */ cur = xmlDocGetRootElement(doc); if (cur == NULL) { xsltGenericError(xsltGenericErrorContext, "xsltParseStylesheetProcess : empty stylesheet\n"); ret->doc = NULL; xsltFreeStylesheet(ret); return(NULL); } xsltPrecomputeStylesheet(ret); if ((IS_XSLT_ELEM(cur)) && ((IS_XSLT_NAME(cur, "stylesheet")) || (IS_XSLT_NAME(cur, "transform")))) {#ifdef WITH_XSLT_DEBUG_PARSING xsltGenericDebug(xsltGenericDebugContext, "xsltParseStylesheetProcess : found stylesheet\n");#endif xsltParseStylesheetTop(ret, cur); } else { xmlChar *prop; xsltTemplatePtr template; /* * the document itself might be the template, check xsl:version */ prop = xmlGetNsProp(cur, (const xmlChar *)"version", XSLT_NAMESPACE); if (prop == NULL) { xsltGenericError(xsltGenericErrorContext, "xsltParseStylesheetProcess : document is not a stylesheet\n"); ret->doc = NULL; xsltFreeStylesheet(ret); return(NULL); }#ifdef WITH_XSLT_DEBUG_PARSING xsltGenericDebug(xsltGenericDebugContext, "xsltParseStylesheetProcess : document is stylesheet\n");#endif if (!xmlStrEqual(prop, (const xmlChar *)"1.0")) { xsltGenericError(xsltGenericErrorContext, "xsl:version: only 1.0 features are supported\n"); /* TODO set up compatibility when not XSLT 1.0 */ ret->warnings++; } xmlFree(prop); /* * Create and link the template */ template = xsltNewTemplate(); if (template == NULL) { ret->doc = NULL; xsltFreeStylesheet(ret); return(NULL); } template->next = ret->templates; ret->templates = template; template->match = xmlStrdup((const xmlChar *)"/"); /* * parse the content and register the pattern */ xsltParseTemplateContent(ret, template, (xmlNodePtr) doc); xsltAddTemplate(ret, template, NULL, NULL); } return(ret);}
uriRef = xmlGetNsProp(cur, (const xmlChar *)"href", XSLT_NAMESPACE);
uriRef = xsltGetNsProp(cur, (const xmlChar *)"href", XSLT_NAMESPACE);
xsltParseStylesheetInclude(xsltStylesheetPtr style, xmlNodePtr cur) { xmlDocPtr oldDoc; xmlChar *base = NULL; xmlChar *uriRef = NULL; xmlChar *URI = NULL; xsltDocumentPtr include; if ((cur == NULL) || (style == NULL)) return; uriRef = xmlGetNsProp(cur, (const xmlChar *)"href", XSLT_NAMESPACE); if (uriRef == NULL) { xsltGenericError(xsltGenericErrorContext, "xsl:include : missing href attribute\n"); goto error; } base = xmlNodeGetBase(style->doc, cur); URI = xmlBuildURI(uriRef, base); if (URI == NULL) { xsltGenericError(xsltGenericErrorContext, "xsl:include : invalid URI reference %s\n", uriRef); goto error; } include = xsltLoadStyleDocument(style, URI); if (include == NULL) { xsltGenericError(xsltGenericErrorContext, "xsl:include : unable to load %s\n", URI); goto error; } oldDoc = style->doc; style->doc = include->doc; xsltParseStylesheetProcess(style, include->doc); style->doc = oldDoc;error: if (uriRef != NULL) xmlFree(uriRef); if (base != NULL) xmlFree(base); if (URI != NULL) xmlFree(URI);}
KLocale::setMainCatalogue("kio_fish");
int kdemain( int argc, char **argv ){ KInstance instance("fish"); myDebug( << "*** Starting fish " << endl); if (argc != 4) { myDebug( << "Usage: fish protocol domain-socket1 domain-socket2" << endl); exit(-1); } struct sigaction act; memset(&act,0,sizeof(act)); act.sa_handler = ripper; act.sa_flags = 0#ifdef SA_NOCLDSTOP | SA_NOCLDSTOP#endif#ifdef SA_RESTART | SA_RESTART#endif ; sigaction(SIGCHLD,&act,NULL); fishProtocol slave(argv[2], argv[3]); slave.dispatchLoop(); myDebug( << "*** fish Done" << endl); return 0;}
int kdemain(int, char **argv) {
int KDE_EXPORT kdemain(int, char **argv) {
int kdemain(int, char **argv) { KInstance instance("kio_mac"); MacProtocol slave(argv[2], argv[3]); slave.dispatchLoop(); return 0; }
NNTPProtocol slave(argv[2],argv[3]); slave.dispatchLoop();
NNTPProtocol *slave; if (strcasecmp(argv[1], "nntps") == 0) { slave = new NNTPProtocol(argv[2], argv[3], true); } else { slave = new NNTPProtocol(argv[2], argv[3], false); } slave->dispatchLoop(); delete slave;
int kdemain(int argc, char **argv) { KInstance instance ("kio_nntp"); if (argc != 4) { fprintf(stderr, "Usage: kio_nntp protocol domain-socket1 domain-socket2\n"); exit(-1); } NNTPProtocol slave(argv[2],argv[3]); slave.dispatchLoop(); return 0;}
SmbProtocol slave(argv[2], argv[3]); slave.dispatchLoop();
signal(SIGINT,&destruct); signal(SIGQUIT,&destruct); signal(SIGILL,&destruct); signal(SIGTRAP,&destruct); signal(SIGABRT,&destruct); signal(SIGBUS,&destruct); signal(SIGSEGV,&destruct); signal(SIGUSR2,&destruct); signal(SIGPIPE,&destruct); signal(SIGALRM,&destruct); signal(SIGTERM,&destruct); signal(SIGFPE,&destruct); #ifdef SIGPOLL signal(SIGPOLL, &destruct); #endif #ifdef SIGSYS signal(SIGSYS, &destruct); #endif #ifdef SIGVTALRM signal(SIGVTALRM, &destruct); #endif #ifdef SIGXCPU signal(SIGXCPU, &destruct); #endif #ifdef SIGXFSZ signal(SIGXFSZ, &destruct); #endif SmbProtocol *slave=new SmbProtocol(argv[2], argv[3]); globalSlave=slave; slave->dispatchLoop();
int kdemain( int argc, char **argv ){ KLocale::setMainCatalogue("kio_smbro"); KInstance instance( "kio_smb" ); if (argc != 4) { fprintf(stderr, "Usage: kio_smb protocol domain-socket1 domain-socket2\n"); exit(-1); } //kdDebug(7101) << "Smb: kdemain: starting" << endl; SmbProtocol slave(argv[2], argv[3]); slave.dispatchLoop(); return 0;}
{ kdDebug()<<"kdemain for devices"<<endl; KInstance instance( "kio_devices" ); DevicesProtocol slave(argv[1],argv[2], argv[3]); slave.dispatchLoop(); return 0; }
{ kdDebug(7126)<<"kdemain for devices"<<endl; KInstance instance( "kio_devices" ); DevicesProtocol slave(argv[1],argv[2], argv[3]); slave.dispatchLoop(); return 0; }
int kdemain( int, char **argv ) { kdDebug()<<"kdemain for devices"<<endl; KInstance instance( "kio_devices" ); DevicesProtocol slave(argv[1],argv[2], argv[3]); slave.dispatchLoop(); return 0; }
fprintf(stderr, "Usage: kio_file protocol domain-socket1 domain-socket2\n");
fprintf(stderr, "Usage: kio_info protocol domain-socket1 domain-socket2\n");
int kdemain( int argc, char **argv ){ KInstance instance( "kio_info" ); kdDebug() << "kio_info starting " << getpid() << endl; if (argc != 4) { fprintf(stderr, "Usage: kio_file protocol domain-socket1 domain-socket2\n"); exit(-1); } InfoProtocol slave( argv[2], argv[3] ); slave.dispatchLoop(); return 0;}
extern "C" int kdemain(int argc, char *argv[])
extern "C" KDE_EXPORT int kdemain(int argc, char *argv[])
extern "C" int kdemain(int argc, char *argv[]){ KLocale::setMainCatalogue("kcontrol"); KAboutData aboutKControl( "kcontrol", I18N_NOOP("KDE Control Center"), KCONTROL_VERSION, I18N_NOOP("The KDE Control Center"), KAboutData::License_GPL, I18N_NOOP("(c) 1998-2004, The KDE Control Center Developers")); KAboutData aboutKInfoCenter( "kinfocenter", I18N_NOOP("KDE Info Center"), KCONTROL_VERSION, I18N_NOOP("The KDE Info Center"), KAboutData::License_GPL, I18N_NOOP("(c) 1998-2004, The KDE Control Center Developers")); QCString argv_0 = argv[0]; KAboutData *aboutData; if (argv_0.right(11) == "kinfocenter") { aboutData = &aboutKInfoCenter; KCGlobal::setIsInfoCenter(true); kdDebug(1208) << "Running as KInfoCenter!\n" << endl; } else { aboutData = &aboutKControl; KCGlobal::setIsInfoCenter(false); } if (argv_0.right(11) == "kinfocenter") aboutData->addAuthor("Helge Deller", I18N_NOOP("Current Maintainer"), "[email protected]"); else aboutData->addAuthor("Daniel Molkentin", I18N_NOOP("Current Maintainer"), "[email protected]"); aboutData->addAuthor("Matthias Hoelzer-Kluepfel",0, "[email protected]"); aboutData->addAuthor("Matthias Elter",0, "[email protected]"); aboutData->addAuthor("Matthias Ettrich",0, "[email protected]"); aboutData->addAuthor("Waldo Bastian",0, "[email protected]"); KCmdLineArgs::init( argc, argv, aboutData ); KUniqueApplication::addCmdLineOptions(); KCGlobal::init(); if (!KControlApp::start()) { kdDebug(1208) << "kcontrol is already running!\n" << endl; return (0); } KControlApp app; // show the whole stuff app.mainWidget()->show(); return app.exec();}
if ( app.isRestored() ) { RESTORE( MainWindow ); }
extern "C" int kdemain( int argc, char **argv ){ KAboutData aboutData( "khelpcenter", I18N_NOOP("KDE Help Center"), HELPCENTER_VERSION, I18N_NOOP("The KDE Help Center"), KAboutData::License_GPL, I18N_NOOP("(c) 1999-2003, The KHelpCenter developers") ); aboutData.addAuthor( "Cornelius Schumacher", 0, "[email protected]" ); aboutData.addAuthor( "Frerich Raabe", 0, "[email protected]" ); aboutData.addAuthor( "Matthias Elter", I18N_NOOP("Original Author"), "[email protected]" ); aboutData.addAuthor( "Wojciech Smigaj", I18N_NOOP("Info page support"), "[email protected]" ); KCmdLineArgs::init( argc, argv, &aboutData ); KCmdLineArgs::addCmdLineOptions( options ); KApplication::addCmdLineOptions(); KHC::Application app; return app.exec();}
int kdemain( int argc, char **argv )
int KDE_EXPORT kdemain( int argc, char **argv )
int kdemain( int argc, char **argv ) { //KInstance instance( "kio_trash" ); // KApplication is necessary to use kio_file putenv(strdup("SESSION_MANAGER=")); KApplication::disableAutoDcopRegistration(); KCmdLineArgs::init(argc, argv, "kio_trash", 0, 0, 0, 0); KCmdLineArgs::addCmdLineOptions( options ); KApplication app( false, false ); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); TrashProtocol slave( args->arg(0), args->arg(1), args->arg(2) ); slave.dispatchLoop(); return 0; }
KLocale::setMainCatalogue("kdelibs");
int kdemain( int argc, char **argv ) { KLocale::setMainCatalogue("kdelibs"); KInstance instance("kio_man"); kdDebug(7107) << "STARTING " << getpid() << endl; if (argc != 4) { fprintf(stderr, "Usage: kio_man protocol domain-socket1 domain-socket2\n"); exit(-1); } MANProtocol slave(argv[2], argv[3]); slave.dispatchLoop(); kdDebug(7107) << "Done" << endl; return 0; }
int kdemain( int argc, char **argv ) {
int KDE_EXPORT kdemain( int argc, char **argv ) {
int kdemain( int argc, char **argv ) { KInstance instance("kio_about"); if (argc != 4) { fprintf(stderr, "Usage: kio_about protocol domain-socket1 domain-socket2\n"); exit(-1); } AboutProtocol slave(argv[2], argv[3]); slave.dispatchLoop(); return 0; }
kdDebug() << "kio_cgi starting " << getpid() << endl;
kdDebug(7124) << "kio_cgi starting " << getpid() << endl;
int kdemain( int argc, char **argv ){ KInstance instance( "kio_cgi" ); kdDebug() << "kio_cgi starting " << getpid() << endl; if (argc != 4) { fprintf(stderr, "Usage: kio_cgi protocol domain-socket1 domain-socket2\n"); exit(-1); } CgiProtocol slave( argv[2], argv[3] ); slave.dispatchLoop(); return 0;}
KApplication app( false, false );
KApplication app( false );
KDE_EXPORT int kdemain( int argc, char **argv ) { // KApplication is necessary to use other ioslaves putenv(strdup("SESSION_MANAGER=")); KCmdLineArgs::init(argc, argv, "kio_system", 0, 0, 0); KCmdLineArgs::addCmdLineOptions( options ); KApplication app( false, false ); // We want to be anonymous even if we use DCOP app.dcopClient()->attach(); DCOPRef ref( "kded", "kded" ); ref.call( "loadModule", "systemdirnotify" ); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); SystemProtocol slave( args->arg(0), args->arg(1), args->arg(2) ); slave.dispatchLoop(); return 0; }
extern "C" int kdemain(int argc, char **argv)
extern "C" KDE_EXPORT int kdemain(int argc, char **argv)
extern "C" int kdemain(int argc, char **argv){ KLocale::setMainCatalogue("kdelibs"); // GS 5/2001 - I changed the name to "KDE" to make it look better // in the titles of dialogs which are displayed. KAboutData aboutdata("kio_uiserver", I18N_NOOP("KDE"), "0.8", I18N_NOOP("KDE Progress Information UI Server"), KAboutData::License_GPL, "(C) 2000, David Faure & Matt Koss"); // Who's the maintainer ? :) aboutdata.addAuthor("David Faure",I18N_NOOP("Developer"),"[email protected]"); aboutdata.addAuthor("Matej Koss",I18N_NOOP("Developer"),"[email protected]"); KCmdLineArgs::init( argc, argv, &aboutdata ); // KCmdLineArgs::addCmdLineOptions( options ); KUniqueApplication::addCmdLineOptions(); if (!KUniqueApplication::start()) { kdDebug(7024) << "kio_uiserver is already running!" << endl; return (0); } KUniqueApplication app; // This app is started automatically, no need for session management app.disableSessionManagement(); app.dcopClient()->setDaemonMode( true ); uiserver = UIServer::createInstance();// app.setMainWidget( uiserver ); return app.exec();}
int kdemain( int argc, char **argv )
int KDE_EXPORT kdemain( int argc, char **argv )
int kdemain( int argc, char **argv ) { KInstance instance( "kio_sftp" ); kdDebug(KIO_SFTP_DB) << "*** Starting kio_sftp " << endl; if (argc != 4) { kdDebug(KIO_SFTP_DB) << "Usage: kio_sftp protocol domain-socket1 domain-socket2" << endl; exit(-1); } sftpProtocol slave(argv[2], argv[3]); slave.dispatchLoop(); kdDebug(KIO_SFTP_DB) << "*** kio_sftp Done" << endl; return 0; }
kdDebug(7101) << "NFS: kdemain: starting" << endl;
kdDebug(7121) << "NFS: kdemain: starting" << endl;
int kdemain( int argc, char **argv ){ KInstance instance( "kio_nfs" ); if (argc != 4) { fprintf(stderr, "Usage: kio_nfs protocol domain-socket1 domain-socket2\n"); exit(-1); } kdDebug(7101) << "NFS: kdemain: starting" << endl; NFSProtocol slave(argv[2], argv[3]); slave.dispatchLoop(); return 0;}
int kdemain( int, char **argv )
KDE_EXPORT int kdemain( int, char **argv )
int kdemain( int, char **argv ) { kdDebug() << "kdemain for settings kioslave" << endl; KInstance instance( "kio_settings" ); SettingsProtocol slave(argv[1], argv[2], argv[3]); slave.dispatchLoop(); return 0; }
qDebug ("IMAP4::kdemain");
kdDebug(7116) << "IMAP4::kdemain" << endl;
kdemain (int argc, char **argv){ qDebug ("IMAP4::kdemain"); KInstance instance ("kio_imap4"); if (argc != 4) { kdDebug () << " Usage: kio_imap4 protocol domain-socket1 domain-socket2" << endl; ::exit (-1); } //set debug handler#ifdef EBUGGING myDebug = fopen ("/tmp/imap_slave", "a"); fprintf (myDebug, "Debugging\n"); fflush (myDebug); qInstallMsgHandler (myHandler);#endif IMAP4Protocol *slave; if (strcasecmp (argv[1], "imaps") == 0) slave = new IMAP4Protocol (argv[2], argv[3], true); else if (strcasecmp (argv[1], "imap") == 0) slave = new IMAP4Protocol (argv[2], argv[3], false); else abort (); slave->dispatchLoop (); delete slave;#ifdef EBUGGING fclose (myDebug);#endif return 0;}
kdDebug () << " Usage: kio_imap4 protocol domain-socket1 domain-socket2" << endl;
fprintf(stderr, "Usage: kio_imap4 protocol domain-socket1 domain-socket2\n");
kdemain (int argc, char **argv){ qDebug ("IMAP4::kdemain"); KInstance instance ("kio_imap4"); if (argc != 4) { kdDebug () << " Usage: kio_imap4 protocol domain-socket1 domain-socket2" << endl; ::exit (-1); } //set debug handler#ifdef EBUGGING myDebug = fopen ("/tmp/imap_slave", "a"); fprintf (myDebug, "Debugging\n"); fflush (myDebug); qInstallMsgHandler (myHandler);#endif IMAP4Protocol *slave; if (strcasecmp (argv[1], "imaps") == 0) slave = new IMAP4Protocol (argv[2], argv[3], true); else if (strcasecmp (argv[1], "imap") == 0) slave = new IMAP4Protocol (argv[2], argv[3], false); else abort (); slave->dispatchLoop (); delete slave;#ifdef EBUGGING fclose (myDebug);#endif return 0;}
int kdemain( int argc, char **argv )
KDE_EXPORT int kdemain( int argc, char **argv )
int kdemain( int argc, char **argv ) { // KApplication is necessary to use other ioslaves putenv(strdup("SESSION_MANAGER=")); KCmdLineArgs::init(argc, argv, "kio_system", 0, 0, 0, 0); KCmdLineArgs::addCmdLineOptions( options ); KApplication app( false, false ); // We want to be anonymous even if we use DCOP //app.dcopClient()->attach(); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); SystemProtocol slave( args->arg(0), args->arg(1), args->arg(2) ); slave.dispatchLoop(); return 0; }
KCmdLineArgs::init(argc, argv, "kio_remote", 0, 0, 0);
KCmdLineArgs::init(argc, argv, "kio_remote", 0L, 0L, false);
int KDE_EXPORT kdemain( int argc, char **argv ) { // KApplication is necessary to use other ioslaves putenv(strdup("SESSION_MANAGER=")); KCmdLineArgs::init(argc, argv, "kio_remote", 0, 0, 0); KCmdLineArgs::addCmdLineOptions( options ); KApplication app( false, false ); // We want to be anonymous even if we use DCOP app.dcopClient()->attach(); DCOPRef ref( "kded", "kded" ); ref.call( "loadModule", "remotedirnotify" ); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); RemoteProtocol slave( args->arg(0), args->arg(1), args->arg(2) ); slave.dispatchLoop(); return 0; }
for( KService::List::ConstIterator it = m_modules.begin(); it != m_modules.end(); it++)
for( KService::List::ConstIterator it = m_modules.begin(); it != m_modules.end(); ++it)
extern "C" KDE_EXPORT int kdemain(int _argc, char *_argv[]){ KAboutData aboutData( "kcmshell", I18N_NOOP("KDE Control Module"), 0, I18N_NOOP("A tool to start single KDE control modules"), KAboutData::License_GPL, I18N_NOOP("(c) 1999-2004, The KDE Developers") ); aboutData.addAuthor("Frans Englich", I18N_NOOP("Maintainer"), "[email protected]"); aboutData.addAuthor("Daniel Molkentin", 0, "[email protected]"); aboutData.addAuthor("Matthias Hoelzer-Kluepfel",0, "[email protected]"); aboutData.addAuthor("Matthias Elter",0, "[email protected]"); aboutData.addAuthor("Matthias Ettrich",0, "[email protected]"); aboutData.addAuthor("Waldo Bastian",0, "[email protected]"); KGlobal::locale()->setMainCatalogue("kcmshell"); KCmdLineArgs::init(_argc, _argv, &aboutData); KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. KCMShell app; const KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); const QCString lang = args->getOption("lang"); if( !lang.isNull() ) KGlobal::locale()->setLanguage(lang); if (args->isSet("list")) { cout << i18n("The following modules are available:").local8Bit() << endl; listModules( "Settings/" ); int maxLen=0; for( KService::List::ConstIterator it = m_modules.begin(); it != m_modules.end(); it++) { int len = (*it)->desktopEntryName().length(); if (len > maxLen) maxLen = len; } for( KService::List::ConstIterator it = m_modules.begin(); it != m_modules.end(); it++) { QString entry("%1 - %2"); entry = entry.arg((*it)->desktopEntryName().leftJustify(maxLen, ' ')) .arg(!(*it)->comment().isEmpty() ? (*it)->comment() : i18n("No description available")); cout << entry.local8Bit() << endl; } return 0; } if (args->count() < 1) { args->usage(); return -1; } QCString dcopName; KService::List modules; for (int i = 0; i < args->count(); i++) { KService::Ptr service = locateModule(args->arg(i)); if( service ) { modules.append(service); if( !dcopName.isEmpty() ) dcopName += "_"; dcopName += args->arg(i); } } /* Check if this particular module combination is already running, but * allow the same module to run when embedding(root mode) */ app.setDCOPName(dcopName, ( args->isSet( "embed-proxy" ) || args->isSet( "embed" ))); if( app.isRunning() ) { app.waitForExit(); return 0; } KDialogBase::DialogType dtype = KDialogBase::Plain; if ( modules.count() < 1 ) return 0; else if( modules.count() > 1 ) dtype = KDialogBase::IconList; bool idValid; int id; if ( args->isSet( "embed-proxy" )) { id = args->getOption( "embed-proxy" ).toInt(&idValid); if( idValid ) { KCModuleProxy *module = new KCModuleProxy( modules.first()->desktopEntryName() ); module->realModule(); QXEmbed::embedClientIntoWindow( module, id); app.exec(); delete module; } else kdDebug(780) << "Supplied id '" << id << "' is not valid." << endl; return 0; } KCMShellMultiDialog *dlg = new KCMShellMultiDialog( dtype, i18n("Configure - %1").arg(kapp->caption()), 0, "", true ); for (KService::List::ConstIterator it = modules.begin(); it != modules.end(); ++it) dlg->addModule(KCModuleInfo(*it)); if ( args->isSet( "embed" )) { id = args->getOption( "embed" ).toInt(&idValid); if( idValid ) { QXEmbed::embedClientIntoWindow( dlg, id ); dlg->exec(); delete dlg; } else kdDebug(780) << "Supplied id '" << id << "' is not valid." << endl; } else { if (kapp->iconName() != kapp->name()) setIcon(dlg, kapp->iconName()); else if ( modules.count() == 1 ) setIcon(dlg, KCModuleInfo( modules.first()).icon()); dlg->exec(); delete dlg; } return 0;}
qgis->addProject(myProjectFileName);
if ( ! qgis->addProject(myProjectFileName) ) { #ifdef QGISDEBUG std::cerr << "unable to load project " << myProjectFileName << "\n"; #endif }
int main(int argc, char *argv[]){ ///////////////////////////////////////////////////////////////// // Command line options 'behaviour' flag setup //////////////////////////////////////////////////////////////// // // Parse the command line arguments, looking to see if the user has asked for any // special behaviours. Any remaining non command arguments will be kept aside to // be passed as a list of layers and / or a project that should be loaded. // // This behaviour is used to load the app, snapshot the map, // save the image to disk and then exit QString mySnapshotFileName=""; // This behaviour will cause QGIS to autoload a project QString myProjectFileName=""; // This behaviour will allow you to force the use of a translation file // which is useful for testing QString myTranslationFileName=""; // This is the 'leftover' arguments collection QStringList * myFileList=new QStringList(); //////////////////////////////////////////////////////////////// // USe the GNU Getopts utility to parse cli arguments // Invokes ctor `GetOpt (int argc, char **argv, char *optstring);' /////////////////////////////////////////////////////////////// int optionChar; while (1) { static struct option long_options[] = { /* These options set a flag. */ {"help", no_argument, 0, 'h'}, /* These options don't set a flag. * We distinguish them by their indices. */ {"snapshot", required_argument, 0, 's'}, {"lang", required_argument, 0, 'l'}, {"project", required_argument, 0, 'p'}, {0, 0, 0, 0} }; /* getopt_long stores the option index here. */ int option_index = 0; optionChar = getopt_long (argc, argv, "slp", long_options, &option_index); /* Detect the end of the options. */ if (optionChar == -1) break; switch (optionChar) { case 0: /* If this option set a flag, do nothing else now. */ if (long_options[option_index].flag != 0) break; printf ("option %s", long_options[option_index].name); if (optarg) printf (" with arg %s", optarg); printf ("\n"); break; case 's': mySnapshotFileName=optarg; break; case 'l': myTranslationFileName=optarg; break; case 'p': myProjectFileName=optarg; break; case 'h': case '?': usage( argv[0] ); return 2; // XXX need standard exit codes break; default: std::cerr << argv[0] << ": getopt returned character code " << optionChar << "\n"; return 1; // XXX need standard exit codes } } // Add any remaining args to the file list - we will attempt to load them // as layers in the map view further down....#ifdef QGISDEBUG std::cout << "Files specified on command line: " << optind << std::endl;#endif if (optind < argc) { while (optind < argc) {#ifdef QGISDEBUG int idx = optind; std::cout << idx << ": " << argv[idx] << std::endl;#endif myFileList->append(argv[optind++]); } } ///////////////////////////////////////////////////////////////////// // Now we have the handlers for the different behaviours... //////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// // Initialise the application and the translation stuff ///////////////////////////////////////////////////////////////////// QApplication a(argc, argv); // a.setFont(QFont("helvetica", 11)); QTranslator tor(0); // set the location where your .qm files are in load() below as the last parameter instead of "." // for development, use "/" to use the english original as // .qm files are stored in the base project directory. if (myTranslationFileName!="") { QString translation = "qgis_" + myTranslationFileName; tor.load(translation, "."); } else { tor.load(QString("qgis_") + QTextCodec::locale(), "."); } //tor.load("qgis_go", "." ); a.installTranslator(&tor); /* uncomment the following line, if you want a Windows 95 look */ //a.setStyle("Windows"); QgisApp *qgis = new QgisApp(); // // Now we can instantiate the splashscreen global that is declared in qgisapp.h // a.setMainWidget(qgis); ///////////////////////////////////////////////////////////////////// // Load a project file if one was specified ///////////////////////////////////////////////////////////////////// if(myProjectFileName!="") { qgis->addProject(myProjectFileName); } ///////////////////////////////////////////////////////////////////// // autoload any filenames that were passed in on the command line /////////////////////////////////////////////////////////////////////#ifdef QGISDEBUG std::cout << "Number of files in myFileList: " << myFileList->count() << std::endl;#endif for ( QStringList::Iterator myIterator = myFileList->begin(); myIterator != myFileList->end(); ++myIterator ) {#ifdef QGISDEBUG std::cout << "Trying to load file : " << *myIterator << std::endl;#endif QString myLayerName = *myIterator; // try to add all these layers - any unsupported file types will // be rejected automatically // The funky bool ok is so this can be debugged a bit easier... //nope - try and load it as raster bool ok = qgis->addRasterLayer(myLayerName); if(!ok){ //nope - try and load it as a shape/ogr ok = qgis->addLayer(myLayerName); //we have no idea what this layer is... if(!ok){ std::cout << "Unable to load " << myLayerName << std::endl; } } } ///////////////////////////////////////////////////////////////////// // Take a snapshot of the map view then exit if snapshot mode requested ///////////////////////////////////////////////////////////////////// if(mySnapshotFileName!="") { // qgis->show(); QPixmap * myQPixmap = new QPixmap(800,600); myQPixmap->fill(); qgis->saveMapAsImage(mySnapshotFileName,myQPixmap); return 1; } ///////////////////////////////////////////////////////////////////// // Continue on to interactive gui... ///////////////////////////////////////////////////////////////////// qgis->show(); a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); return a.exec();}
app.exec();
return app.exec();
int main(int argc, char *argv[]){ KAboutData aboutData( "khelpcenter", I18N_NOOP("KDE HelpCenter"), HELPCENTER_VERSION, I18N_NOOP("The KDE Help Center"), KAboutData::License_GPL, "(c) 1999-2000, Matthias Elter"); aboutData.addAuthor("Matthias Elter",0, "[email protected]"); KCmdLineArgs::init( argc, argv, &aboutData ); KCmdLineArgs::addCmdLineOptions( options ); KApplication::addCmdLineOptions(); KApplication app( false, false ); // no GUI in this process app.dcopClient()->attach(); Listener listener; QCString dcopService; QString error; // try to connect to an already running konqueror, if one exists QCStringList apps = app.dcopClient()->registeredApplications(); QCStringList::ConstIterator it; for (it = apps.begin(); it != apps.end(); ++it) if ((*it).left(9) == "konqueror") { createHelpWindow(*it); return 0; } // run a new konqueror instance app.dcopClient()->setNotifications( true ); QObject::connect( app.dcopClient(), SIGNAL( applicationRegistered( const QCString& ) ), &listener, SLOT( slotAppRegistered( const QCString & ) ) ); if (app.startServiceByDesktopName("konqueror", QString::fromLatin1("--silent"), &error)) { warning("Could not launch browser:\n%s\n", error.local8Bit().data()); return 1; } app.exec();}
printf("\n Copyright (C) 1997, 1998 Matthias Ettrich ([email protected])\n"); printf("\n Utility to launch legay applications with special KDE window properties"); printf("\n such as iconified, maximized, a certain virtual desktop, a special decoration"); printf("\n or sticky"); printf("\n "); printf("\n In addition, the -activate switch will jump to the window even if it is"); printf("\n started on a different virtual desktop"); printf("\n "); printf("\n Usage:"); printf("\n %s <command> [-window <regular expression>] [-desktop <number>]", argv[0]); printf("\n [-sticky] [-iconify] [-maximize] "); printf("\n [-decoration tiny|none] [-activate]"); printf("\n "); printf("\n If you do not specify a regular expression for the windows title," ); printf("\n then the very first window to appear will be taken. Not recommended!"); printf("\n "); printf("\n Example usage:"); printf("\n %s \"xclock -geometry 80x80-0+0\" -window xclock -decoration tiny -sticky", argv[0]); printf("\n puts a tiny decorated, sticky xclock on the top right corner of the screen."); printf("\n "); printf("\n ");
printf(i18n( "\n Copyright (C) 1997, 1998 Matthias Ettrich ([email protected])\n" "\n Utility to launch legay applications with special KDE window properties" "\n such as iconified, maximized, a certain virtual desktop, a special decoration" "\n or sticky" "\n " "\n In addition, the -activate switch will jump to the window even if it is" "\n started on a different virtual desktop" "\n " "\n Usage:" "\n %s <command> [-window <regular expression>] [-desktop <number>]" "\n [-sticky] [-iconify] [-maximize] " "\n [-decoration tiny|none] [-activate]" "\n " "\n If you do not specify a regular expression for the windows title," "\n then the very first window to appear will be taken. Not recommended!" "\n " "\n Example usage:" "\n %s \"xclock -geometry 80x80-0+0\" -window xclock -decoration tiny -sticky" "\n puts a tiny decorated, sticky xclock on the top right corner of the screen." "\n " "\n "), argv[0], argv[0]);
int main( int argc, char *argv[] ){ if (argc <= 2) { printf(KSTART_VERSION); printf("\n Copyright (C) 1997, 1998 Matthias Ettrich ([email protected])\n"); printf("\n Utility to launch legay applications with special KDE window properties"); printf("\n such as iconified, maximized, a certain virtual desktop, a special decoration"); printf("\n or sticky"); printf("\n "); printf("\n In addition, the -activate switch will jump to the window even if it is"); printf("\n started on a different virtual desktop"); printf("\n "); printf("\n Usage:"); printf("\n %s <command> [-window <regular expression>] [-desktop <number>]", argv[0]); printf("\n [-sticky] [-iconify] [-maximize] "); printf("\n [-decoration tiny|none] [-activate]"); printf("\n "); printf("\n If you do not specify a regular expression for the windows title," ); printf("\n then the very first window to appear will be taken. Not recommended!"); printf("\n "); printf("\n Example usage:"); printf("\n %s \"xclock -geometry 80x80-0+0\" -window xclock -decoration tiny -sticky", argv[0]); printf("\n puts a tiny decorated, sticky xclock on the top right corner of the screen."); printf("\n "); printf("\n "); ::exit(0); } int desktop = 0; char* window = 0; bool activate = FALSE; bool maximize = FALSE; bool iconify = FALSE; bool sticky = FALSE; int decoration = KWM::normalDecoration; for (int i = 2; i < argc; i++) { if (!strcmp(argv[i],"-version")) { printf(KSTART_VERSION); printf("\n Copyright (C) 1997, 1998 Matthias Ettrich ([email protected])\n"); ::exit(0); } if (!strcmp(argv[i],"-window") && i+1 < argc) { window = argv[++i]; } if (!strcmp(argv[i],"-desktop") && i+1 < argc) { QString s = argv[++i]; desktop = s.toInt(); } if (!strcmp(argv[i],"-decoration") && i+1 < argc) { QString s = argv[++i]; if (s == "tiny") decoration = KWM::tinyDecoration; if (s == "none") decoration = KWM::noDecoration; } if (!strcmp(argv[i],"-activate") ) activate = true; if (!strcmp(argv[i],"-maximize") ) maximize = true; if (!strcmp(argv[i],"-iconify") ) iconify = true; if (!strcmp(argv[i],"-sticky") ) sticky = true; } KWMModuleApplication a (argc, argv); fcntl(ConnectionNumber(qt_xdisplay()), F_SETFD, 1); new KStart(&a, argv[1], window, desktop, activate, maximize, iconify, sticky, decoration); return a.exec();}
printf("\n Copyright (C) 1997, 1998 Matthias Ettrich ([email protected])\n");
printf(i18n("\n Copyright (C) 1997, 1998 Matthias Ettrich ([email protected])\n"));
int main( int argc, char *argv[] ){ if (argc <= 2) { printf(KSTART_VERSION); printf("\n Copyright (C) 1997, 1998 Matthias Ettrich ([email protected])\n"); printf("\n Utility to launch legay applications with special KDE window properties"); printf("\n such as iconified, maximized, a certain virtual desktop, a special decoration"); printf("\n or sticky"); printf("\n "); printf("\n In addition, the -activate switch will jump to the window even if it is"); printf("\n started on a different virtual desktop"); printf("\n "); printf("\n Usage:"); printf("\n %s <command> [-window <regular expression>] [-desktop <number>]", argv[0]); printf("\n [-sticky] [-iconify] [-maximize] "); printf("\n [-decoration tiny|none] [-activate]"); printf("\n "); printf("\n If you do not specify a regular expression for the windows title," ); printf("\n then the very first window to appear will be taken. Not recommended!"); printf("\n "); printf("\n Example usage:"); printf("\n %s \"xclock -geometry 80x80-0+0\" -window xclock -decoration tiny -sticky", argv[0]); printf("\n puts a tiny decorated, sticky xclock on the top right corner of the screen."); printf("\n "); printf("\n "); ::exit(0); } int desktop = 0; char* window = 0; bool activate = FALSE; bool maximize = FALSE; bool iconify = FALSE; bool sticky = FALSE; int decoration = KWM::normalDecoration; for (int i = 2; i < argc; i++) { if (!strcmp(argv[i],"-version")) { printf(KSTART_VERSION); printf("\n Copyright (C) 1997, 1998 Matthias Ettrich ([email protected])\n"); ::exit(0); } if (!strcmp(argv[i],"-window") && i+1 < argc) { window = argv[++i]; } if (!strcmp(argv[i],"-desktop") && i+1 < argc) { QString s = argv[++i]; desktop = s.toInt(); } if (!strcmp(argv[i],"-decoration") && i+1 < argc) { QString s = argv[++i]; if (s == "tiny") decoration = KWM::tinyDecoration; if (s == "none") decoration = KWM::noDecoration; } if (!strcmp(argv[i],"-activate") ) activate = true; if (!strcmp(argv[i],"-maximize") ) maximize = true; if (!strcmp(argv[i],"-iconify") ) iconify = true; if (!strcmp(argv[i],"-sticky") ) sticky = true; } KWMModuleApplication a (argc, argv); fcntl(ConnectionNumber(qt_xdisplay()), F_SETFD, 1); new KStart(&a, argv[1], window, desktop, activate, maximize, iconify, sticky, decoration); return a.exec();}
if (pw->pw_uid) { QString kdeHome = KGlobal::dirs()->relativeLocation("home", KGlobal::dirs()->localkdedir()); if (kdeHome[0] != '/') kdeHome.prepend("~/"); else kdeHome=QString::null; env << ("KDEHOME="+ QFile::encodeName(kdeHome)); }
int main(int argc, char *argv[]){ // FIXME: this can be considered a poor man's solution, as it's not // directly obvious to a gui user. :) // anyway, i vote against removing it even when we have a proper gui // implementation. -- ossi const char *duser = ::getenv("ADMIN_ACCOUNT"); if (duser && duser[0]) options[3].def = duser; KAboutData aboutData("kdesu", I18N_NOOP("KDE su"), Version, I18N_NOOP("Runs a program with elevated privileges."), KAboutData::License_Artistic, "Copyright (c) 1998-2000 Geert Jansen, Pietro Iglio"); aboutData.addAuthor("Geert Jansen", I18N_NOOP("Maintainer"), "[email protected]", "http://www.stack.nl/~geertj/"); aboutData.addAuthor("Pietro Iglio", I18N_NOOP("Original author"), "[email protected]"); KCmdLineArgs::init(argc, argv, &aboutData); KCmdLineArgs::addCmdLineOptions(options); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); KApplication::disableAutoDcopRegistration(); KApplication *app = new KApplication; { KStartupInfoId id; id.initId( app->startupId()); id.setupStartupEnv(); // make KDE_STARTUP_ENV env. var. available again } // Stop daemon and exit? if (args->isSet("s")) { KDEsuClient client; if (client.ping() == -1) { kdError(1206) << "Daemon not running -- nothing to stop\n"; exit(1); } if (client.stopServer() != -1) { kdDebug(1206) << "Daemon stopped\n"; exit(0); } kdError(1206) << "Could not stop daemon\n"; exit(1); } // Get target uid QCString user = args->getOption("u"); QCString auth_user = user; struct passwd *pw = getpwnam(user); if (pw == 0L) { kdError(1206) << "User " << user << " does not exist\n"; exit(1); } bool change_uid = (getuid() != pw->pw_uid); // If file is writeable, do not change uid QString file = QFile::decodeName(args->getOption("f")); if (change_uid && !file.isEmpty()) { if (file.at(0) != '/') { KStandardDirs dirs; dirs.addKDEDefaults(); file = dirs.findResource("config", file); if (file.isEmpty()) { kdError(1206) << "Config file not found: " << file << "\n"; exit(1); } } QFileInfo fi(file); if (!fi.exists()) { kdError(1206) << "File does not exist: " << file << "\n"; exit(1); } change_uid = !fi.isWritable(); } // Get priority/scheduler QCString tmp = args->getOption("p"); bool ok; int priority = tmp.toInt(&ok); if (!ok || (priority < 0) || (priority > 100)) { KCmdLineArgs::usage(i18n("Illegal priority: %1").arg(tmp)); exit(1); } int scheduler = SuProcess::SchedNormal; if (args->isSet("r")) scheduler = SuProcess::SchedRealtime; if ((priority > 50) || (scheduler != SuProcess::SchedNormal)) { change_uid = true; auth_user = "root"; } // Get command if (args->isSet("c")) { command = args->getOption("c"); for (int i=0; i<args->count(); i++) { QString arg = QFile::decodeName(args->arg(i)); KRun::shellQuote(arg); command += " "; command += QFile::encodeName(arg); } } else { if( args->count() == 0 ) { KCmdLineArgs::usage(i18n("No command specified!")); exit(1); } command = args->arg(0); for (int i=1; i<args->count(); i++) { QString arg = QFile::decodeName(args->arg(i)); KRun::shellQuote(arg); command += " "; command += QFile::encodeName(arg); }}// CJM - Test lines remove when working// kdWarning(1206) << args->count();// kdWarning(1206) << command; // Don't change uid if we're don't need to. if (!change_uid) return system(command); // Check for daemon and start if necessary bool just_started = false; bool have_daemon = true; KDEsuClient client; if (!client.isServerSGID()) { kdWarning(1206) << "Daemon not safe (not sgid), not using it.\n"; have_daemon = false; } else if (client.ping() == -1) { if (client.startServer() == -1) { kdWarning(1206) << "Could not start daemon, reduced functionality.\n"; have_daemon = false; } just_started = true; } // Try to exec the command with kdesud. bool keep = !args->isSet("n") && have_daemon; bool terminal = args->isSet("t"); bool new_dcop = args->isSet("newdcop"); QCStringList env; QCString options; env << ( "KDE_STARTUP_ENV=" + kapp->startupId()); if (!new_dcop) { QCString ksycoca = "KDESYCOCA="+QFile::encodeName(locateLocal("tmp", "ksycoca")); env << ksycoca; options += "xf"; // X-only, dcop forwarding enabled. } if (keep && !terminal && !just_started) { client.setPriority(priority); client.setScheduler(scheduler); if (client.exec(command, user, options, env) != -1) return 0; } // Set core dump size to 0 because we will have // root's password in memory. struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) { kdError(1206) << "rlimit(): " << ERR << "\n"; exit(1); } // Read configuration KConfig *config = KGlobal::config(); config->setGroup("Passwords"); int timeout = config->readNumEntry("Timeout", defTimeout); // Check if we need a password SuProcess proc; proc.setUser(auth_user); int needpw = proc.checkNeedPassword(); if (needpw < 0) { QString err = i18n("Su returned with an error!\n"); KMessageBox::error(0L, err); exit(1); } if (needpw == 0) { keep = 0; kdDebug() << "Don't need password!!\n"; } // Start the dialog QCString password; if (needpw) { KStartupInfoId id; id.initId( app->startupId()); KStartupInfoData data; data.setSilent( KStartupInfoData::Yes ); KStartupInfo::sendChange( id, data ); KDEsuDialog dlg(user, auth_user, keep && !terminal); dlg.addLine(i18n("Command:"), command); if ((priority != 50) || (scheduler != SuProcess::SchedNormal)) { QString prio; if (scheduler == SuProcess::SchedRealtime) prio += i18n("realtime: "); prio += QString("%1/100").arg(priority); dlg.addLine(i18n("Priority:"), prio); } int ret = dlg.exec(); if (ret == KDEsuDialog::Rejected) { KStartupInfo::sendFinish( id ); exit(0); } if (ret == KDEsuDialog::AsUser) change_uid = false; password = dlg.password(); keep = dlg.keep(); data.setSilent( KStartupInfoData::No ); KStartupInfo::sendChange( id, data ); } // Some events may need to be handled (like a button animation) app->processEvents(); if (!change_uid) return system(command); // Run command if (keep && have_daemon) { client.setPass(password, timeout); client.setPriority(priority); client.setScheduler(scheduler); return client.exec(command, user, options, env); } else { SuProcess proc; proc.setTerminal(terminal); proc.setErase(true); proc.setUser(user); if (!new_dcop) { proc.setXOnly(true); proc.setDCOPForwarding(true); } proc.setEnvironment(env); proc.setPriority(priority); proc.setScheduler(scheduler); proc.setCommand(command); return proc.exec(password); }}
int main( int argc, char **argv )
int main( int , char ** )
int main( int argc, char **argv ){ signal (SIGCHLD, sig_handler); Connection parent( 0, 1 ); GZipProtocol prot( &parent ); prot.dispatchLoop(); while(1); return 0;}
kdDebug() << "kcontrol is already running!\n" << endl;
kdDebug(1208) << "kcontrol is already running!\n" << endl;
int main(int argc, char *argv[]){ KAboutData aboutData( "kcontrol", I18N_NOOP("KDE Control Center"), "v2.0", I18N_NOOP("The KDE Control Center"), KAboutData::License_GPL, I18N_NOOP("(c) 1998-2000, The KDE Control Center Developers")); aboutData.addAuthor("Matthias Hoelzer-Kluepfel",0, "[email protected]"); aboutData.addAuthor("Matthias Elter",0, "[email protected]"); KCmdLineArgs::init( argc, argv, &aboutData ); KUniqueApplication::addCmdLineOptions(); KCGlobal::init(); if (!KControlApp::start()) { kdDebug() << "kcontrol is already running!\n" << endl; return (0); } KControlApp app; // show the whole stuff app.mainWidget()->show(); return app.exec();}
debug( "kio_file : Starting");
qDebug( "kio_file : Starting");
int main( int , char ** ){ signal(SIGCHLD, sigchld_handler); signal(SIGSEGV, sigsegv_handler); debug( "kio_file : Starting"); Connection parent( 0, 1 ); FileProtocol file( &parent ); file.dispatchLoop(); debug( "kio_file : Done" );}
debug( "kio_file : Done" );
qDebug( "kio_file : Done" );
int main( int , char ** ){ signal(SIGCHLD, sigchld_handler); signal(SIGSEGV, sigsegv_handler); debug( "kio_file : Starting"); Connection parent( 0, 1 ); FileProtocol file( &parent ); file.dispatchLoop(); debug( "kio_file : Done" );}
if (setrlimit(RLIMIT_CORE, &rlim) < 0) { kDebugPError("setrlimit()");
if (setrlimit(RLIMIT_CORE, &rlim) < 0) { kdError(1205) << "setrlimit(): " << ERR << "\n";
int main(int argc, char *argv[]){ KAboutData aboutData("kdesud", I18N_NOOP("KDE su daemon"), Version, I18N_NOOP("Daemon used by kdesu"), KAboutData::License_Artistic, "Copyright (c) 1999,2000 Geert Jansen"); aboutData.addAuthor("Geert Jansen", I18N_NOOP("Author"), "[email protected]", "http://www.stack.nl/~geertj/"); KCmdLineArgs::init(argc, argv, &aboutData); // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { kDebugPError("setrlimit()"); exit(1); } // Create the Unix socket. int sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { kDebugPError("listen()"); kdesud_cleanup(); exit(1); } int maxfd = sockfd; // Ok, we're accepting connections. Fork to the background. pid_t pid = fork(); if (pid == -1) { kDebugPError("fork()"); kdesud_cleanup(); exit(1); } if (pid) exit(0); // Make sure we exit when the display gets closed. int x11Fd = initXconnection(); maxfd = QMAX(maxfd, x11Fd); repo = new Repository; QVector<ConnectionHandler> handler; handler.setAutoDelete(true); // Signal handlers struct sigaction sa; sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); sa.sa_handler = SIG_IGN; sigaction(SIGPIPE, &sa, 0L); // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; struct timeval tv; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); if (x11Fd != -1) FD_SET(x11Fd, &active_fds); while (1) { tmp_fds = active_fds; tv.tv_sec = 5; tv.tv_usec = 0; if (select(maxfd+1, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; kDebugPError("select()"); exit(1); } repo->expire(); for (int i=0; i<=maxfd; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == x11Fd) { // Discard X events XEvent event_return; if (x11Display) XNextEvent(x11Display, &event_return); } if (i == sockfd) { // Accept new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { kDebugPError("accept()"); continue; } if (fd+1 > (int) handler.size()) handler.resize(fd+1); handler.insert(fd, new ConnectionHandler(fd)); maxfd = QMAX(maxfd, fd); FD_SET(fd, &active_fds); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { handler.remove(i); FD_CLR(i, &active_fds); } } } kDebugWarning("???");}
if (listen(sockfd, 1) < 0) { kDebugPError("listen()");
if (listen(sockfd, 1) < 0) { kdError(1205) << "listen(): " << ERR << "\n";
int main(int argc, char *argv[]){ KAboutData aboutData("kdesud", I18N_NOOP("KDE su daemon"), Version, I18N_NOOP("Daemon used by kdesu"), KAboutData::License_Artistic, "Copyright (c) 1999,2000 Geert Jansen"); aboutData.addAuthor("Geert Jansen", I18N_NOOP("Author"), "[email protected]", "http://www.stack.nl/~geertj/"); KCmdLineArgs::init(argc, argv, &aboutData); // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { kDebugPError("setrlimit()"); exit(1); } // Create the Unix socket. int sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { kDebugPError("listen()"); kdesud_cleanup(); exit(1); } int maxfd = sockfd; // Ok, we're accepting connections. Fork to the background. pid_t pid = fork(); if (pid == -1) { kDebugPError("fork()"); kdesud_cleanup(); exit(1); } if (pid) exit(0); // Make sure we exit when the display gets closed. int x11Fd = initXconnection(); maxfd = QMAX(maxfd, x11Fd); repo = new Repository; QVector<ConnectionHandler> handler; handler.setAutoDelete(true); // Signal handlers struct sigaction sa; sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); sa.sa_handler = SIG_IGN; sigaction(SIGPIPE, &sa, 0L); // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; struct timeval tv; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); if (x11Fd != -1) FD_SET(x11Fd, &active_fds); while (1) { tmp_fds = active_fds; tv.tv_sec = 5; tv.tv_usec = 0; if (select(maxfd+1, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; kDebugPError("select()"); exit(1); } repo->expire(); for (int i=0; i<=maxfd; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == x11Fd) { // Discard X events XEvent event_return; if (x11Display) XNextEvent(x11Display, &event_return); } if (i == sockfd) { // Accept new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { kDebugPError("accept()"); continue; } if (fd+1 > (int) handler.size()) handler.resize(fd+1); handler.insert(fd, new ConnectionHandler(fd)); maxfd = QMAX(maxfd, fd); FD_SET(fd, &active_fds); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { handler.remove(i); FD_CLR(i, &active_fds); } } } kDebugWarning("???");}
if (pid == -1) { kDebugPError("fork()");
if (pid == -1) { kdError(1205) << "fork():" << ERR << "\n";
int main(int argc, char *argv[]){ KAboutData aboutData("kdesud", I18N_NOOP("KDE su daemon"), Version, I18N_NOOP("Daemon used by kdesu"), KAboutData::License_Artistic, "Copyright (c) 1999,2000 Geert Jansen"); aboutData.addAuthor("Geert Jansen", I18N_NOOP("Author"), "[email protected]", "http://www.stack.nl/~geertj/"); KCmdLineArgs::init(argc, argv, &aboutData); // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { kDebugPError("setrlimit()"); exit(1); } // Create the Unix socket. int sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { kDebugPError("listen()"); kdesud_cleanup(); exit(1); } int maxfd = sockfd; // Ok, we're accepting connections. Fork to the background. pid_t pid = fork(); if (pid == -1) { kDebugPError("fork()"); kdesud_cleanup(); exit(1); } if (pid) exit(0); // Make sure we exit when the display gets closed. int x11Fd = initXconnection(); maxfd = QMAX(maxfd, x11Fd); repo = new Repository; QVector<ConnectionHandler> handler; handler.setAutoDelete(true); // Signal handlers struct sigaction sa; sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); sa.sa_handler = SIG_IGN; sigaction(SIGPIPE, &sa, 0L); // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; struct timeval tv; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); if (x11Fd != -1) FD_SET(x11Fd, &active_fds); while (1) { tmp_fds = active_fds; tv.tv_sec = 5; tv.tv_usec = 0; if (select(maxfd+1, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; kDebugPError("select()"); exit(1); } repo->expire(); for (int i=0; i<=maxfd; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == x11Fd) { // Discard X events XEvent event_return; if (x11Display) XNextEvent(x11Display, &event_return); } if (i == sockfd) { // Accept new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { kDebugPError("accept()"); continue; } if (fd+1 > (int) handler.size()) handler.resize(fd+1); handler.insert(fd, new ConnectionHandler(fd)); maxfd = QMAX(maxfd, fd); FD_SET(fd, &active_fds); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { handler.remove(i); FD_CLR(i, &active_fds); } } } kDebugWarning("???");}
kDebugPError("select()");
kdError(1205) << "select(): " << ERR << "\n";
int main(int argc, char *argv[]){ KAboutData aboutData("kdesud", I18N_NOOP("KDE su daemon"), Version, I18N_NOOP("Daemon used by kdesu"), KAboutData::License_Artistic, "Copyright (c) 1999,2000 Geert Jansen"); aboutData.addAuthor("Geert Jansen", I18N_NOOP("Author"), "[email protected]", "http://www.stack.nl/~geertj/"); KCmdLineArgs::init(argc, argv, &aboutData); // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { kDebugPError("setrlimit()"); exit(1); } // Create the Unix socket. int sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { kDebugPError("listen()"); kdesud_cleanup(); exit(1); } int maxfd = sockfd; // Ok, we're accepting connections. Fork to the background. pid_t pid = fork(); if (pid == -1) { kDebugPError("fork()"); kdesud_cleanup(); exit(1); } if (pid) exit(0); // Make sure we exit when the display gets closed. int x11Fd = initXconnection(); maxfd = QMAX(maxfd, x11Fd); repo = new Repository; QVector<ConnectionHandler> handler; handler.setAutoDelete(true); // Signal handlers struct sigaction sa; sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); sa.sa_handler = SIG_IGN; sigaction(SIGPIPE, &sa, 0L); // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; struct timeval tv; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); if (x11Fd != -1) FD_SET(x11Fd, &active_fds); while (1) { tmp_fds = active_fds; tv.tv_sec = 5; tv.tv_usec = 0; if (select(maxfd+1, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; kDebugPError("select()"); exit(1); } repo->expire(); for (int i=0; i<=maxfd; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == x11Fd) { // Discard X events XEvent event_return; if (x11Display) XNextEvent(x11Display, &event_return); } if (i == sockfd) { // Accept new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { kDebugPError("accept()"); continue; } if (fd+1 > (int) handler.size()) handler.resize(fd+1); handler.insert(fd, new ConnectionHandler(fd)); maxfd = QMAX(maxfd, fd); FD_SET(fd, &active_fds); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { handler.remove(i); FD_CLR(i, &active_fds); } } } kDebugWarning("???");}
if (fd < 0) { kDebugPError("accept()");
if (fd < 0) { kdError(1205) << "accept():" << ERR << "\n";
int main(int argc, char *argv[]){ KAboutData aboutData("kdesud", I18N_NOOP("KDE su daemon"), Version, I18N_NOOP("Daemon used by kdesu"), KAboutData::License_Artistic, "Copyright (c) 1999,2000 Geert Jansen"); aboutData.addAuthor("Geert Jansen", I18N_NOOP("Author"), "[email protected]", "http://www.stack.nl/~geertj/"); KCmdLineArgs::init(argc, argv, &aboutData); // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { kDebugPError("setrlimit()"); exit(1); } // Create the Unix socket. int sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { kDebugPError("listen()"); kdesud_cleanup(); exit(1); } int maxfd = sockfd; // Ok, we're accepting connections. Fork to the background. pid_t pid = fork(); if (pid == -1) { kDebugPError("fork()"); kdesud_cleanup(); exit(1); } if (pid) exit(0); // Make sure we exit when the display gets closed. int x11Fd = initXconnection(); maxfd = QMAX(maxfd, x11Fd); repo = new Repository; QVector<ConnectionHandler> handler; handler.setAutoDelete(true); // Signal handlers struct sigaction sa; sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); sa.sa_handler = SIG_IGN; sigaction(SIGPIPE, &sa, 0L); // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; struct timeval tv; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); if (x11Fd != -1) FD_SET(x11Fd, &active_fds); while (1) { tmp_fds = active_fds; tv.tv_sec = 5; tv.tv_usec = 0; if (select(maxfd+1, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; kDebugPError("select()"); exit(1); } repo->expire(); for (int i=0; i<=maxfd; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == x11Fd) { // Discard X events XEvent event_return; if (x11Display) XNextEvent(x11Display, &event_return); } if (i == sockfd) { // Accept new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { kDebugPError("accept()"); continue; } if (fd+1 > (int) handler.size()) handler.resize(fd+1); handler.insert(fd, new ConnectionHandler(fd)); maxfd = QMAX(maxfd, fd); FD_SET(fd, &active_fds); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { handler.remove(i); FD_CLR(i, &active_fds); } } } kDebugWarning("???");}
kDebugWarning("???");
kdWarning(1205) << "???\n";
int main(int argc, char *argv[]){ KAboutData aboutData("kdesud", I18N_NOOP("KDE su daemon"), Version, I18N_NOOP("Daemon used by kdesu"), KAboutData::License_Artistic, "Copyright (c) 1999,2000 Geert Jansen"); aboutData.addAuthor("Geert Jansen", I18N_NOOP("Author"), "[email protected]", "http://www.stack.nl/~geertj/"); KCmdLineArgs::init(argc, argv, &aboutData); // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { kDebugPError("setrlimit()"); exit(1); } // Create the Unix socket. int sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { kDebugPError("listen()"); kdesud_cleanup(); exit(1); } int maxfd = sockfd; // Ok, we're accepting connections. Fork to the background. pid_t pid = fork(); if (pid == -1) { kDebugPError("fork()"); kdesud_cleanup(); exit(1); } if (pid) exit(0); // Make sure we exit when the display gets closed. int x11Fd = initXconnection(); maxfd = QMAX(maxfd, x11Fd); repo = new Repository; QVector<ConnectionHandler> handler; handler.setAutoDelete(true); // Signal handlers struct sigaction sa; sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); sa.sa_handler = SIG_IGN; sigaction(SIGPIPE, &sa, 0L); // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; struct timeval tv; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); if (x11Fd != -1) FD_SET(x11Fd, &active_fds); while (1) { tmp_fds = active_fds; tv.tv_sec = 5; tv.tv_usec = 0; if (select(maxfd+1, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; kDebugPError("select()"); exit(1); } repo->expire(); for (int i=0; i<=maxfd; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == x11Fd) { // Discard X events XEvent event_return; if (x11Display) XNextEvent(x11Display, &event_return); } if (i == sockfd) { // Accept new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { kDebugPError("accept()"); continue; } if (fd+1 > (int) handler.size()) handler.resize(fd+1); handler.insert(fd, new ConnectionHandler(fd)); maxfd = QMAX(maxfd, fd); FD_SET(fd, &active_fds); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { handler.remove(i); FD_CLR(i, &active_fds); } } } kDebugWarning("???");}
int main( int argc, char **argv )
int main( int, char ** )
int main( int argc, char **argv ){ signal(SIGCHLD, sigchld_handler); signal(SIGSEGV, sigsegv_handler); Connection parent( 0, 1 ); HTTPProtocol http( &parent ); http.dispatchLoop();}
kdebug( KDEBUG_INFO, 0, "Starting");
kdebug( KDEBUG_INFO, 7102, "Starting");
int main( int, char ** ){ signal(SIGCHLD, KIOProtocol::sigchld_handler); signal(SIGSEGV, KIOProtocol::sigsegv_handler); // KProtocolManager manager; KInstance instance( "kio_ftp" ); kdebug( KDEBUG_INFO, 0, "Starting"); KIOConnection parent( 0, 1 ); FtpProtocol ftp( &parent ); ftp.dispatchLoop(); kdebug( KDEBUG_INFO, 0, "Done");}
kdebug( KDEBUG_INFO, 0, "Done");
kdebug( KDEBUG_INFO, 7102, "Done");
int main( int, char ** ){ signal(SIGCHLD, KIOProtocol::sigchld_handler); signal(SIGSEGV, KIOProtocol::sigsegv_handler); // KProtocolManager manager; KInstance instance( "kio_ftp" ); kdebug( KDEBUG_INFO, 0, "Starting"); KIOConnection parent( 0, 1 ); FtpProtocol ftp( &parent ); ftp.dispatchLoop(); kdebug( KDEBUG_INFO, 0, "Done");}
struct timeval tv;
int main(int argc, char *argv[]){ KAboutData aboutData("kdesud", I18N_NOOP("KDE su daemon"), Version, I18N_NOOP("Daemon used by kdesu"), KAboutData::License_Artistic, "Copyright (c) 1999,2000 Geert Jansen"); aboutData.addAuthor("Geert Jansen", I18N_NOOP("Author"), "[email protected]", "http://www.stack.nl/~geertj/"); KCmdLineArgs::init(argc, argv, &aboutData); KInstance instance(&aboutData); // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { kdError(1205) << "setrlimit(): " << ERR << "\n"; exit(1); } // Create the Unix socket. int sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { kdError(1205) << "listen(): " << ERR << "\n"; kdesud_cleanup(); exit(1); } int maxfd = sockfd; // Ok, we're accepting connections. Fork to the background. pid_t pid = fork(); if (pid == -1) { kdError(1205) << "fork():" << ERR << "\n"; kdesud_cleanup(); exit(1); } if (pid) exit(0); // Make sure we exit when the display gets closed. int x11Fd = initXconnection(); maxfd = QMAX(maxfd, x11Fd); repo = new Repository; QPtrVector<ConnectionHandler> handler; handler.setAutoDelete(true); // Signal handlers struct sigaction sa; sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); sa.sa_handler = SIG_IGN; sigaction(SIGPIPE, &sa, 0L); // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; struct timeval tv; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); if (x11Fd != -1) FD_SET(x11Fd, &active_fds); while (1) { tmp_fds = active_fds; tv.tv_sec = 5; tv.tv_usec = 0; if (select(maxfd+1, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; kdError(1205) << "select(): " << ERR << "\n"; exit(1); } repo->expire(); for (int i=0; i<=maxfd; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == x11Fd) { // Discard X events XEvent event_return; if (x11Display) XNextEvent(x11Display, &event_return); } if (i == sockfd) { // Accept new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { kdError(1205) << "accept():" << ERR << "\n"; continue; } if (fd+1 > (int) handler.size()) handler.resize(fd+1); handler.insert(fd, new ConnectionHandler(fd)); maxfd = QMAX(maxfd, fd); FD_SET(fd, &active_fds); continue; } // handle alreay established connection if (handler[i] && handler[i]->handle() < 0) { handler.remove(i); FD_CLR(i, &active_fds); } } } kdWarning(1205) << "???\n";}
tmp_fds = active_fds; tv.tv_sec = 5; tv.tv_usec = 0; if (select(maxfd+1, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; kdError(1205) << "select(): " << ERR << "\n"; exit(1); } repo->expire(); for (int i=0; i<=maxfd; i++) { if (!FD_ISSET(i, &tmp_fds)) continue;
tmp_fds = active_fds; if (select(maxfd+1, &tmp_fds, 0L, 0L, 0L) < 0) { if (errno == EINTR) continue; kdError(1205) << "select(): " << ERR << "\n"; exit(1); } repo->expire(); for (int i=0; i<=maxfd; i++) { if (!FD_ISSET(i, &tmp_fds)) continue;
int main(int argc, char *argv[]){ KAboutData aboutData("kdesud", I18N_NOOP("KDE su daemon"), Version, I18N_NOOP("Daemon used by kdesu"), KAboutData::License_Artistic, "Copyright (c) 1999,2000 Geert Jansen"); aboutData.addAuthor("Geert Jansen", I18N_NOOP("Author"), "[email protected]", "http://www.stack.nl/~geertj/"); KCmdLineArgs::init(argc, argv, &aboutData); KInstance instance(&aboutData); // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { kdError(1205) << "setrlimit(): " << ERR << "\n"; exit(1); } // Create the Unix socket. int sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { kdError(1205) << "listen(): " << ERR << "\n"; kdesud_cleanup(); exit(1); } int maxfd = sockfd; // Ok, we're accepting connections. Fork to the background. pid_t pid = fork(); if (pid == -1) { kdError(1205) << "fork():" << ERR << "\n"; kdesud_cleanup(); exit(1); } if (pid) exit(0); // Make sure we exit when the display gets closed. int x11Fd = initXconnection(); maxfd = QMAX(maxfd, x11Fd); repo = new Repository; QPtrVector<ConnectionHandler> handler; handler.setAutoDelete(true); // Signal handlers struct sigaction sa; sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); sa.sa_handler = SIG_IGN; sigaction(SIGPIPE, &sa, 0L); // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; struct timeval tv; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); if (x11Fd != -1) FD_SET(x11Fd, &active_fds); while (1) { tmp_fds = active_fds; tv.tv_sec = 5; tv.tv_usec = 0; if (select(maxfd+1, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; kdError(1205) << "select(): " << ERR << "\n"; exit(1); } repo->expire(); for (int i=0; i<=maxfd; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == x11Fd) { // Discard X events XEvent event_return; if (x11Display) XNextEvent(x11Display, &event_return); } if (i == sockfd) { // Accept new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { kdError(1205) << "accept():" << ERR << "\n"; continue; } if (fd+1 > (int) handler.size()) handler.resize(fd+1); handler.insert(fd, new ConnectionHandler(fd)); maxfd = QMAX(maxfd, fd); FD_SET(fd, &active_fds); continue; } // handle alreay established connection if (handler[i] && handler[i]->handle() < 0) { handler.remove(i); FD_CLR(i, &active_fds); } } } kdWarning(1205) << "???\n";}
if (i == x11Fd) { XEvent event_return; if (x11Display) XNextEvent(x11Display, &event_return); }
if (i == pipeOfDeath[0]) { char buf[101]; read(pipeOfDeath[0], buf, 100); pid_t result; do { int status; result = waitpid((pid_t)-1, &status, WNOHANG); if (result > 0) { for(int j=handler.size(); j--;) { if (handler[j] && (handler[j]->m_pid == result)) { handler[j]->m_exitCode = WEXITSTATUS(status); handler[j]->m_hasExitCode = true; handler[j]->sendExitCode(); handler[j]->m_pid = 0; break; } } } } while(result > 0); }
int main(int argc, char *argv[]){ KAboutData aboutData("kdesud", I18N_NOOP("KDE su daemon"), Version, I18N_NOOP("Daemon used by kdesu"), KAboutData::License_Artistic, "Copyright (c) 1999,2000 Geert Jansen"); aboutData.addAuthor("Geert Jansen", I18N_NOOP("Author"), "[email protected]", "http://www.stack.nl/~geertj/"); KCmdLineArgs::init(argc, argv, &aboutData); KInstance instance(&aboutData); // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { kdError(1205) << "setrlimit(): " << ERR << "\n"; exit(1); } // Create the Unix socket. int sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { kdError(1205) << "listen(): " << ERR << "\n"; kdesud_cleanup(); exit(1); } int maxfd = sockfd; // Ok, we're accepting connections. Fork to the background. pid_t pid = fork(); if (pid == -1) { kdError(1205) << "fork():" << ERR << "\n"; kdesud_cleanup(); exit(1); } if (pid) exit(0); // Make sure we exit when the display gets closed. int x11Fd = initXconnection(); maxfd = QMAX(maxfd, x11Fd); repo = new Repository; QPtrVector<ConnectionHandler> handler; handler.setAutoDelete(true); // Signal handlers struct sigaction sa; sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); sa.sa_handler = SIG_IGN; sigaction(SIGPIPE, &sa, 0L); // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; struct timeval tv; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); if (x11Fd != -1) FD_SET(x11Fd, &active_fds); while (1) { tmp_fds = active_fds; tv.tv_sec = 5; tv.tv_usec = 0; if (select(maxfd+1, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; kdError(1205) << "select(): " << ERR << "\n"; exit(1); } repo->expire(); for (int i=0; i<=maxfd; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == x11Fd) { // Discard X events XEvent event_return; if (x11Display) XNextEvent(x11Display, &event_return); } if (i == sockfd) { // Accept new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { kdError(1205) << "accept():" << ERR << "\n"; continue; } if (fd+1 > (int) handler.size()) handler.resize(fd+1); handler.insert(fd, new ConnectionHandler(fd)); maxfd = QMAX(maxfd, fd); FD_SET(fd, &active_fds); continue; } // handle alreay established connection if (handler[i] && handler[i]->handle() < 0) { handler.remove(i); FD_CLR(i, &active_fds); } } } kdWarning(1205) << "???\n";}
if (i == sockfd) { int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { kdError(1205) << "accept():" << ERR << "\n"; continue; } if (fd+1 > (int) handler.size()) handler.resize(fd+1); handler.insert(fd, new ConnectionHandler(fd)); maxfd = QMAX(maxfd, fd); FD_SET(fd, &active_fds); continue; }
if (i == x11Fd) { XEvent event_return; if (x11Display) XNextEvent(x11Display, &event_return); }
int main(int argc, char *argv[]){ KAboutData aboutData("kdesud", I18N_NOOP("KDE su daemon"), Version, I18N_NOOP("Daemon used by kdesu"), KAboutData::License_Artistic, "Copyright (c) 1999,2000 Geert Jansen"); aboutData.addAuthor("Geert Jansen", I18N_NOOP("Author"), "[email protected]", "http://www.stack.nl/~geertj/"); KCmdLineArgs::init(argc, argv, &aboutData); KInstance instance(&aboutData); // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { kdError(1205) << "setrlimit(): " << ERR << "\n"; exit(1); } // Create the Unix socket. int sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { kdError(1205) << "listen(): " << ERR << "\n"; kdesud_cleanup(); exit(1); } int maxfd = sockfd; // Ok, we're accepting connections. Fork to the background. pid_t pid = fork(); if (pid == -1) { kdError(1205) << "fork():" << ERR << "\n"; kdesud_cleanup(); exit(1); } if (pid) exit(0); // Make sure we exit when the display gets closed. int x11Fd = initXconnection(); maxfd = QMAX(maxfd, x11Fd); repo = new Repository; QPtrVector<ConnectionHandler> handler; handler.setAutoDelete(true); // Signal handlers struct sigaction sa; sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); sa.sa_handler = SIG_IGN; sigaction(SIGPIPE, &sa, 0L); // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; struct timeval tv; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); if (x11Fd != -1) FD_SET(x11Fd, &active_fds); while (1) { tmp_fds = active_fds; tv.tv_sec = 5; tv.tv_usec = 0; if (select(maxfd+1, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; kdError(1205) << "select(): " << ERR << "\n"; exit(1); } repo->expire(); for (int i=0; i<=maxfd; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == x11Fd) { // Discard X events XEvent event_return; if (x11Display) XNextEvent(x11Display, &event_return); } if (i == sockfd) { // Accept new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { kdError(1205) << "accept():" << ERR << "\n"; continue; } if (fd+1 > (int) handler.size()) handler.resize(fd+1); handler.insert(fd, new ConnectionHandler(fd)); maxfd = QMAX(maxfd, fd); FD_SET(fd, &active_fds); continue; } // handle alreay established connection if (handler[i] && handler[i]->handle() < 0) { handler.remove(i); FD_CLR(i, &active_fds); } } } kdWarning(1205) << "???\n";}
if (handler[i] && handler[i]->handle() < 0) { handler.remove(i); FD_CLR(i, &active_fds); } }
if (i == sockfd) { int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { kdError(1205) << "accept():" << ERR << "\n"; continue; } if (fd+1 > (int) handler.size()) handler.resize(fd+1); handler.insert(fd, new ConnectionHandler(fd)); maxfd = QMAX(maxfd, fd); FD_SET(fd, &active_fds); continue; } if (handler[i] && handler[i]->handle() < 0) { handler.remove(i); FD_CLR(i, &active_fds); } }
int main(int argc, char *argv[]){ KAboutData aboutData("kdesud", I18N_NOOP("KDE su daemon"), Version, I18N_NOOP("Daemon used by kdesu"), KAboutData::License_Artistic, "Copyright (c) 1999,2000 Geert Jansen"); aboutData.addAuthor("Geert Jansen", I18N_NOOP("Author"), "[email protected]", "http://www.stack.nl/~geertj/"); KCmdLineArgs::init(argc, argv, &aboutData); KInstance instance(&aboutData); // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { kdError(1205) << "setrlimit(): " << ERR << "\n"; exit(1); } // Create the Unix socket. int sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { kdError(1205) << "listen(): " << ERR << "\n"; kdesud_cleanup(); exit(1); } int maxfd = sockfd; // Ok, we're accepting connections. Fork to the background. pid_t pid = fork(); if (pid == -1) { kdError(1205) << "fork():" << ERR << "\n"; kdesud_cleanup(); exit(1); } if (pid) exit(0); // Make sure we exit when the display gets closed. int x11Fd = initXconnection(); maxfd = QMAX(maxfd, x11Fd); repo = new Repository; QPtrVector<ConnectionHandler> handler; handler.setAutoDelete(true); // Signal handlers struct sigaction sa; sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); sa.sa_handler = SIG_IGN; sigaction(SIGPIPE, &sa, 0L); // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; struct timeval tv; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); if (x11Fd != -1) FD_SET(x11Fd, &active_fds); while (1) { tmp_fds = active_fds; tv.tv_sec = 5; tv.tv_usec = 0; if (select(maxfd+1, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; kdError(1205) << "select(): " << ERR << "\n"; exit(1); } repo->expire(); for (int i=0; i<=maxfd; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == x11Fd) { // Discard X events XEvent event_return; if (x11Display) XNextEvent(x11Display, &event_return); } if (i == sockfd) { // Accept new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { kdError(1205) << "accept():" << ERR << "\n"; continue; } if (fd+1 > (int) handler.size()) handler.resize(fd+1); handler.insert(fd, new ConnectionHandler(fd)); maxfd = QMAX(maxfd, fd); FD_SET(fd, &active_fds); continue; } // handle alreay established connection if (handler[i] && handler[i]->handle() < 0) { handler.remove(i); FD_CLR(i, &active_fds); } } } kdWarning(1205) << "???\n";}
int main( int argc, char **argv )
int main( int , char ** )
int main( int argc, char **argv ){ char caption[256]; KWidgetIdentification *id = new KWidgetIdentification(); id->getIdentifierByUser( caption ); printf("%s\n", caption);}
int sockfd, i; struct timeval tv; struct sigaction sa;
qInstallMsgHandler(msgHandler);
int main(int argc, char *argv[]){ int sockfd, i; struct timeval tv; struct sigaction sa; int c; while ((c = getopt(argc, argv, "hvdq")) != -1) { switch (c) { case 'h': cerr << "kdesud [OPTIONS]...\n"; cerr << "KDE su daemon (password keeper for KDE su).\n"; cerr << endl; cerr << "Options:\n"; cerr << " -d Give debug information\n"; cerr << " -q Be quiet (no warnings)\n"; cerr << " -v Show verion information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 'v': cerr << "kdesud version " << Version << endl; cerr << endl; cerr << " Copyright (c) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'd': _show_dbg++; break; case 'q': _show_wrn = 0; break; case '?': default: cerr << "kdesud: invalid option" << endl; cerr << Help << endl; exit(1); } } // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { xerror("setrlimit(): %s"); exit(1); } // Create the Unix socket. sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { xerror("listen(): %s"); exit(1); } // Allocate the repository repo = new Repository; // connection handlers vector<ConnectionHandler *> handler(FD_SETSIZE); // Signal handlers sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); // Expire at least every 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); while (1) { tmp_fds = active_fds; if (select(FD_SETSIZE, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; xerror("select(): %s"); exit(1); } tv.tv_sec = 5; tv.tv_usec = 0; repo->expire(); for (i=0; i<FD_SETSIZE; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == sockfd) { // new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { xerror("accept(): %s"); exit(1); } handler[fd] = new ConnectionHandler(fd); FD_SET(fd, &active_fds); debug("Accepted new connection on fd %d", fd); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { delete handler[i]; close(i); FD_CLR(i, &active_fds); } } } warning("???");}
cerr << "kdesud [OPTIONS]...\n"; cerr << "KDE su daemon (password keeper for KDE su).\n"; cerr << endl; cerr << "Options:\n"; cerr << " -d Give debug information\n"; cerr << " -q Be quiet (no warnings)\n"; cerr << " -v Show verion information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl;
printf("kdesud [OPTIONS]...\n"); printf("KDE su daemon (password keeper for KDE su).\n"); printf("\n"); printf("Options:\n"); printf(" -d Give debug information\n"); printf(" -q Be quiet (no warnings)\n"); printf(" -v Show verion information\n"); printf("\n"); printf("Please report bugs to %s\n", Email);
int main(int argc, char *argv[]){ int sockfd, i; struct timeval tv; struct sigaction sa; int c; while ((c = getopt(argc, argv, "hvdq")) != -1) { switch (c) { case 'h': cerr << "kdesud [OPTIONS]...\n"; cerr << "KDE su daemon (password keeper for KDE su).\n"; cerr << endl; cerr << "Options:\n"; cerr << " -d Give debug information\n"; cerr << " -q Be quiet (no warnings)\n"; cerr << " -v Show verion information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 'v': cerr << "kdesud version " << Version << endl; cerr << endl; cerr << " Copyright (c) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'd': _show_dbg++; break; case 'q': _show_wrn = 0; break; case '?': default: cerr << "kdesud: invalid option" << endl; cerr << Help << endl; exit(1); } } // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { xerror("setrlimit(): %s"); exit(1); } // Create the Unix socket. sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { xerror("listen(): %s"); exit(1); } // Allocate the repository repo = new Repository; // connection handlers vector<ConnectionHandler *> handler(FD_SETSIZE); // Signal handlers sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); // Expire at least every 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); while (1) { tmp_fds = active_fds; if (select(FD_SETSIZE, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; xerror("select(): %s"); exit(1); } tv.tv_sec = 5; tv.tv_usec = 0; repo->expire(); for (i=0; i<FD_SETSIZE; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == sockfd) { // new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { xerror("accept(): %s"); exit(1); } handler[fd] = new ConnectionHandler(fd); FD_SET(fd, &active_fds); debug("Accepted new connection on fd %d", fd); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { delete handler[i]; close(i); FD_CLR(i, &active_fds); } } } warning("???");}
cerr << "kdesud version " << Version << endl; cerr << endl; cerr << " Copyright (c) 1999 Geert Jansen " << Email << endl; cerr << endl;
printf("kdesud version %s\n", Version); printf("\n"); printf(" Copyright (c) 1999 Geert Jansen %s\n", Email); printf("\n");
int main(int argc, char *argv[]){ int sockfd, i; struct timeval tv; struct sigaction sa; int c; while ((c = getopt(argc, argv, "hvdq")) != -1) { switch (c) { case 'h': cerr << "kdesud [OPTIONS]...\n"; cerr << "KDE su daemon (password keeper for KDE su).\n"; cerr << endl; cerr << "Options:\n"; cerr << " -d Give debug information\n"; cerr << " -q Be quiet (no warnings)\n"; cerr << " -v Show verion information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 'v': cerr << "kdesud version " << Version << endl; cerr << endl; cerr << " Copyright (c) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'd': _show_dbg++; break; case 'q': _show_wrn = 0; break; case '?': default: cerr << "kdesud: invalid option" << endl; cerr << Help << endl; exit(1); } } // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { xerror("setrlimit(): %s"); exit(1); } // Create the Unix socket. sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { xerror("listen(): %s"); exit(1); } // Allocate the repository repo = new Repository; // connection handlers vector<ConnectionHandler *> handler(FD_SETSIZE); // Signal handlers sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); // Expire at least every 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); while (1) { tmp_fds = active_fds; if (select(FD_SETSIZE, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; xerror("select(): %s"); exit(1); } tv.tv_sec = 5; tv.tv_usec = 0; repo->expire(); for (i=0; i<FD_SETSIZE; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == sockfd) { // new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { xerror("accept(): %s"); exit(1); } handler[fd] = new ConnectionHandler(fd); FD_SET(fd, &active_fds); debug("Accepted new connection on fd %d", fd); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { delete handler[i]; close(i); FD_CLR(i, &active_fds); } } } warning("???");}
cerr << "kdesud: invalid option" << endl; cerr << Help << endl;
printf("kdesud: invalid option\n"); printf("%s\n", Help);
int main(int argc, char *argv[]){ int sockfd, i; struct timeval tv; struct sigaction sa; int c; while ((c = getopt(argc, argv, "hvdq")) != -1) { switch (c) { case 'h': cerr << "kdesud [OPTIONS]...\n"; cerr << "KDE su daemon (password keeper for KDE su).\n"; cerr << endl; cerr << "Options:\n"; cerr << " -d Give debug information\n"; cerr << " -q Be quiet (no warnings)\n"; cerr << " -v Show verion information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 'v': cerr << "kdesud version " << Version << endl; cerr << endl; cerr << " Copyright (c) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'd': _show_dbg++; break; case 'q': _show_wrn = 0; break; case '?': default: cerr << "kdesud: invalid option" << endl; cerr << Help << endl; exit(1); } } // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { xerror("setrlimit(): %s"); exit(1); } // Create the Unix socket. sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { xerror("listen(): %s"); exit(1); } // Allocate the repository repo = new Repository; // connection handlers vector<ConnectionHandler *> handler(FD_SETSIZE); // Signal handlers sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); // Expire at least every 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); while (1) { tmp_fds = active_fds; if (select(FD_SETSIZE, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; xerror("select(): %s"); exit(1); } tv.tv_sec = 5; tv.tv_usec = 0; repo->expire(); for (i=0; i<FD_SETSIZE; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == sockfd) { // new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { xerror("accept(): %s"); exit(1); } handler[fd] = new ConnectionHandler(fd); FD_SET(fd, &active_fds); debug("Accepted new connection on fd %d", fd); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { delete handler[i]; close(i); FD_CLR(i, &active_fds); } } } warning("???");}
xerror("setrlimit(): %s");
qWarning("setrlimit(): %s", strerror(errno));
int main(int argc, char *argv[]){ int sockfd, i; struct timeval tv; struct sigaction sa; int c; while ((c = getopt(argc, argv, "hvdq")) != -1) { switch (c) { case 'h': cerr << "kdesud [OPTIONS]...\n"; cerr << "KDE su daemon (password keeper for KDE su).\n"; cerr << endl; cerr << "Options:\n"; cerr << " -d Give debug information\n"; cerr << " -q Be quiet (no warnings)\n"; cerr << " -v Show verion information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 'v': cerr << "kdesud version " << Version << endl; cerr << endl; cerr << " Copyright (c) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'd': _show_dbg++; break; case 'q': _show_wrn = 0; break; case '?': default: cerr << "kdesud: invalid option" << endl; cerr << Help << endl; exit(1); } } // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { xerror("setrlimit(): %s"); exit(1); } // Create the Unix socket. sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { xerror("listen(): %s"); exit(1); } // Allocate the repository repo = new Repository; // connection handlers vector<ConnectionHandler *> handler(FD_SETSIZE); // Signal handlers sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); // Expire at least every 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); while (1) { tmp_fds = active_fds; if (select(FD_SETSIZE, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; xerror("select(): %s"); exit(1); } tv.tv_sec = 5; tv.tv_usec = 0; repo->expire(); for (i=0; i<FD_SETSIZE; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == sockfd) { // new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { xerror("accept(): %s"); exit(1); } handler[fd] = new ConnectionHandler(fd); FD_SET(fd, &active_fds); debug("Accepted new connection on fd %d", fd); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { delete handler[i]; close(i); FD_CLR(i, &active_fds); } } } warning("???");}
sockfd = create_socket();
int sockfd = create_socket();
int main(int argc, char *argv[]){ int sockfd, i; struct timeval tv; struct sigaction sa; int c; while ((c = getopt(argc, argv, "hvdq")) != -1) { switch (c) { case 'h': cerr << "kdesud [OPTIONS]...\n"; cerr << "KDE su daemon (password keeper for KDE su).\n"; cerr << endl; cerr << "Options:\n"; cerr << " -d Give debug information\n"; cerr << " -q Be quiet (no warnings)\n"; cerr << " -v Show verion information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 'v': cerr << "kdesud version " << Version << endl; cerr << endl; cerr << " Copyright (c) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'd': _show_dbg++; break; case 'q': _show_wrn = 0; break; case '?': default: cerr << "kdesud: invalid option" << endl; cerr << Help << endl; exit(1); } } // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { xerror("setrlimit(): %s"); exit(1); } // Create the Unix socket. sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { xerror("listen(): %s"); exit(1); } // Allocate the repository repo = new Repository; // connection handlers vector<ConnectionHandler *> handler(FD_SETSIZE); // Signal handlers sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); // Expire at least every 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); while (1) { tmp_fds = active_fds; if (select(FD_SETSIZE, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; xerror("select(): %s"); exit(1); } tv.tv_sec = 5; tv.tv_usec = 0; repo->expire(); for (i=0; i<FD_SETSIZE; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == sockfd) { // new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { xerror("accept(): %s"); exit(1); } handler[fd] = new ConnectionHandler(fd); FD_SET(fd, &active_fds); debug("Accepted new connection on fd %d", fd); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { delete handler[i]; close(i); FD_CLR(i, &active_fds); } } } warning("???");}
xerror("listen(): %s");
qWarning("listen(): %s", strerror(errno));
int main(int argc, char *argv[]){ int sockfd, i; struct timeval tv; struct sigaction sa; int c; while ((c = getopt(argc, argv, "hvdq")) != -1) { switch (c) { case 'h': cerr << "kdesud [OPTIONS]...\n"; cerr << "KDE su daemon (password keeper for KDE su).\n"; cerr << endl; cerr << "Options:\n"; cerr << " -d Give debug information\n"; cerr << " -q Be quiet (no warnings)\n"; cerr << " -v Show verion information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 'v': cerr << "kdesud version " << Version << endl; cerr << endl; cerr << " Copyright (c) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'd': _show_dbg++; break; case 'q': _show_wrn = 0; break; case '?': default: cerr << "kdesud: invalid option" << endl; cerr << Help << endl; exit(1); } } // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { xerror("setrlimit(): %s"); exit(1); } // Create the Unix socket. sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { xerror("listen(): %s"); exit(1); } // Allocate the repository repo = new Repository; // connection handlers vector<ConnectionHandler *> handler(FD_SETSIZE); // Signal handlers sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); // Expire at least every 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); while (1) { tmp_fds = active_fds; if (select(FD_SETSIZE, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; xerror("select(): %s"); exit(1); } tv.tv_sec = 5; tv.tv_usec = 0; repo->expire(); for (i=0; i<FD_SETSIZE; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == sockfd) { // new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { xerror("accept(): %s"); exit(1); } handler[fd] = new ConnectionHandler(fd); FD_SET(fd, &active_fds); debug("Accepted new connection on fd %d", fd); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { delete handler[i]; close(i); FD_CLR(i, &active_fds); } } } warning("???");}
vector<ConnectionHandler *> handler(FD_SETSIZE);
ConnectionHandler *handler[FD_SETSIZE];
int main(int argc, char *argv[]){ int sockfd, i; struct timeval tv; struct sigaction sa; int c; while ((c = getopt(argc, argv, "hvdq")) != -1) { switch (c) { case 'h': cerr << "kdesud [OPTIONS]...\n"; cerr << "KDE su daemon (password keeper for KDE su).\n"; cerr << endl; cerr << "Options:\n"; cerr << " -d Give debug information\n"; cerr << " -q Be quiet (no warnings)\n"; cerr << " -v Show verion information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 'v': cerr << "kdesud version " << Version << endl; cerr << endl; cerr << " Copyright (c) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'd': _show_dbg++; break; case 'q': _show_wrn = 0; break; case '?': default: cerr << "kdesud: invalid option" << endl; cerr << Help << endl; exit(1); } } // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { xerror("setrlimit(): %s"); exit(1); } // Create the Unix socket. sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { xerror("listen(): %s"); exit(1); } // Allocate the repository repo = new Repository; // connection handlers vector<ConnectionHandler *> handler(FD_SETSIZE); // Signal handlers sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); // Expire at least every 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); while (1) { tmp_fds = active_fds; if (select(FD_SETSIZE, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; xerror("select(): %s"); exit(1); } tv.tv_sec = 5; tv.tv_usec = 0; repo->expire(); for (i=0; i<FD_SETSIZE; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == sockfd) { // new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { xerror("accept(): %s"); exit(1); } handler[fd] = new ConnectionHandler(fd); FD_SET(fd, &active_fds); debug("Accepted new connection on fd %d", fd); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { delete handler[i]; close(i); FD_CLR(i, &active_fds); } } } warning("???");}
tv.tv_sec = 5; tv.tv_usec = 0;
int main(int argc, char *argv[]){ int sockfd, i; struct timeval tv; struct sigaction sa; int c; while ((c = getopt(argc, argv, "hvdq")) != -1) { switch (c) { case 'h': cerr << "kdesud [OPTIONS]...\n"; cerr << "KDE su daemon (password keeper for KDE su).\n"; cerr << endl; cerr << "Options:\n"; cerr << " -d Give debug information\n"; cerr << " -q Be quiet (no warnings)\n"; cerr << " -v Show verion information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 'v': cerr << "kdesud version " << Version << endl; cerr << endl; cerr << " Copyright (c) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'd': _show_dbg++; break; case 'q': _show_wrn = 0; break; case '?': default: cerr << "kdesud: invalid option" << endl; cerr << Help << endl; exit(1); } } // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { xerror("setrlimit(): %s"); exit(1); } // Create the Unix socket. sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { xerror("listen(): %s"); exit(1); } // Allocate the repository repo = new Repository; // connection handlers vector<ConnectionHandler *> handler(FD_SETSIZE); // Signal handlers sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); // Expire at least every 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); while (1) { tmp_fds = active_fds; if (select(FD_SETSIZE, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; xerror("select(): %s"); exit(1); } tv.tv_sec = 5; tv.tv_usec = 0; repo->expire(); for (i=0; i<FD_SETSIZE; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == sockfd) { // new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { xerror("accept(): %s"); exit(1); } handler[fd] = new ConnectionHandler(fd); FD_SET(fd, &active_fds); debug("Accepted new connection on fd %d", fd); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { delete handler[i]; close(i); FD_CLR(i, &active_fds); } } } warning("???");}
xerror("select(): %s"); exit(1);
qFatal("select(): %s", strerror(errno));
int main(int argc, char *argv[]){ int sockfd, i; struct timeval tv; struct sigaction sa; int c; while ((c = getopt(argc, argv, "hvdq")) != -1) { switch (c) { case 'h': cerr << "kdesud [OPTIONS]...\n"; cerr << "KDE su daemon (password keeper for KDE su).\n"; cerr << endl; cerr << "Options:\n"; cerr << " -d Give debug information\n"; cerr << " -q Be quiet (no warnings)\n"; cerr << " -v Show verion information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 'v': cerr << "kdesud version " << Version << endl; cerr << endl; cerr << " Copyright (c) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'd': _show_dbg++; break; case 'q': _show_wrn = 0; break; case '?': default: cerr << "kdesud: invalid option" << endl; cerr << Help << endl; exit(1); } } // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { xerror("setrlimit(): %s"); exit(1); } // Create the Unix socket. sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { xerror("listen(): %s"); exit(1); } // Allocate the repository repo = new Repository; // connection handlers vector<ConnectionHandler *> handler(FD_SETSIZE); // Signal handlers sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); // Expire at least every 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); while (1) { tmp_fds = active_fds; if (select(FD_SETSIZE, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; xerror("select(): %s"); exit(1); } tv.tv_sec = 5; tv.tv_usec = 0; repo->expire(); for (i=0; i<FD_SETSIZE; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == sockfd) { // new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { xerror("accept(): %s"); exit(1); } handler[fd] = new ConnectionHandler(fd); FD_SET(fd, &active_fds); debug("Accepted new connection on fd %d", fd); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { delete handler[i]; close(i); FD_CLR(i, &active_fds); } } } warning("???");}
for (i=0; i<FD_SETSIZE; i++) {
for (int i=0; i<FD_SETSIZE; i++) {
int main(int argc, char *argv[]){ int sockfd, i; struct timeval tv; struct sigaction sa; int c; while ((c = getopt(argc, argv, "hvdq")) != -1) { switch (c) { case 'h': cerr << "kdesud [OPTIONS]...\n"; cerr << "KDE su daemon (password keeper for KDE su).\n"; cerr << endl; cerr << "Options:\n"; cerr << " -d Give debug information\n"; cerr << " -q Be quiet (no warnings)\n"; cerr << " -v Show verion information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 'v': cerr << "kdesud version " << Version << endl; cerr << endl; cerr << " Copyright (c) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'd': _show_dbg++; break; case 'q': _show_wrn = 0; break; case '?': default: cerr << "kdesud: invalid option" << endl; cerr << Help << endl; exit(1); } } // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { xerror("setrlimit(): %s"); exit(1); } // Create the Unix socket. sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { xerror("listen(): %s"); exit(1); } // Allocate the repository repo = new Repository; // connection handlers vector<ConnectionHandler *> handler(FD_SETSIZE); // Signal handlers sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); // Expire at least every 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); while (1) { tmp_fds = active_fds; if (select(FD_SETSIZE, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; xerror("select(): %s"); exit(1); } tv.tv_sec = 5; tv.tv_usec = 0; repo->expire(); for (i=0; i<FD_SETSIZE; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == sockfd) { // new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { xerror("accept(): %s"); exit(1); } handler[fd] = new ConnectionHandler(fd); FD_SET(fd, &active_fds); debug("Accepted new connection on fd %d", fd); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { delete handler[i]; close(i); FD_CLR(i, &active_fds); } } } warning("???");}
xerror("accept(): %s"); exit(1);
qWarning("accept(): %s", strerror(errno)); continue;
int main(int argc, char *argv[]){ int sockfd, i; struct timeval tv; struct sigaction sa; int c; while ((c = getopt(argc, argv, "hvdq")) != -1) { switch (c) { case 'h': cerr << "kdesud [OPTIONS]...\n"; cerr << "KDE su daemon (password keeper for KDE su).\n"; cerr << endl; cerr << "Options:\n"; cerr << " -d Give debug information\n"; cerr << " -q Be quiet (no warnings)\n"; cerr << " -v Show verion information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 'v': cerr << "kdesud version " << Version << endl; cerr << endl; cerr << " Copyright (c) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'd': _show_dbg++; break; case 'q': _show_wrn = 0; break; case '?': default: cerr << "kdesud: invalid option" << endl; cerr << Help << endl; exit(1); } } // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { xerror("setrlimit(): %s"); exit(1); } // Create the Unix socket. sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { xerror("listen(): %s"); exit(1); } // Allocate the repository repo = new Repository; // connection handlers vector<ConnectionHandler *> handler(FD_SETSIZE); // Signal handlers sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); // Expire at least every 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); while (1) { tmp_fds = active_fds; if (select(FD_SETSIZE, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; xerror("select(): %s"); exit(1); } tv.tv_sec = 5; tv.tv_usec = 0; repo->expire(); for (i=0; i<FD_SETSIZE; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == sockfd) { // new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { xerror("accept(): %s"); exit(1); } handler[fd] = new ConnectionHandler(fd); FD_SET(fd, &active_fds); debug("Accepted new connection on fd %d", fd); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { delete handler[i]; close(i); FD_CLR(i, &active_fds); } } } warning("???");}
debug("Accepted new connection on fd %d", fd);
qDebug("Accepted new connection on fd %d", fd);
int main(int argc, char *argv[]){ int sockfd, i; struct timeval tv; struct sigaction sa; int c; while ((c = getopt(argc, argv, "hvdq")) != -1) { switch (c) { case 'h': cerr << "kdesud [OPTIONS]...\n"; cerr << "KDE su daemon (password keeper for KDE su).\n"; cerr << endl; cerr << "Options:\n"; cerr << " -d Give debug information\n"; cerr << " -q Be quiet (no warnings)\n"; cerr << " -v Show verion information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 'v': cerr << "kdesud version " << Version << endl; cerr << endl; cerr << " Copyright (c) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'd': _show_dbg++; break; case 'q': _show_wrn = 0; break; case '?': default: cerr << "kdesud: invalid option" << endl; cerr << Help << endl; exit(1); } } // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { xerror("setrlimit(): %s"); exit(1); } // Create the Unix socket. sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { xerror("listen(): %s"); exit(1); } // Allocate the repository repo = new Repository; // connection handlers vector<ConnectionHandler *> handler(FD_SETSIZE); // Signal handlers sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); // Expire at least every 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); while (1) { tmp_fds = active_fds; if (select(FD_SETSIZE, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; xerror("select(): %s"); exit(1); } tv.tv_sec = 5; tv.tv_usec = 0; repo->expire(); for (i=0; i<FD_SETSIZE; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == sockfd) { // new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { xerror("accept(): %s"); exit(1); } handler[fd] = new ConnectionHandler(fd); FD_SET(fd, &active_fds); debug("Accepted new connection on fd %d", fd); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { delete handler[i]; close(i); FD_CLR(i, &active_fds); } } } warning("???");}
warning("???");
qWarning("???");
int main(int argc, char *argv[]){ int sockfd, i; struct timeval tv; struct sigaction sa; int c; while ((c = getopt(argc, argv, "hvdq")) != -1) { switch (c) { case 'h': cerr << "kdesud [OPTIONS]...\n"; cerr << "KDE su daemon (password keeper for KDE su).\n"; cerr << endl; cerr << "Options:\n"; cerr << " -d Give debug information\n"; cerr << " -q Be quiet (no warnings)\n"; cerr << " -v Show verion information\n"; cerr << endl; cerr << "Please report bugs to " << Email << endl; exit(0); case 'v': cerr << "kdesud version " << Version << endl; cerr << endl; cerr << " Copyright (c) 1999 Geert Jansen " << Email << endl; cerr << endl; exit(0); case 'd': _show_dbg++; break; case 'q': _show_wrn = 0; break; case '?': default: cerr << "kdesud: invalid option" << endl; cerr << Help << endl; exit(1); } } // Set core dump size to 0 struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim) < 0) { xerror("setrlimit(): %s"); exit(1); } // Create the Unix socket. sockfd = create_socket(); if (sockfd < 0) exit(1); if (listen(sockfd, 1) < 0) { xerror("listen(): %s"); exit(1); } // Allocate the repository repo = new Repository; // connection handlers vector<ConnectionHandler *> handler(FD_SETSIZE); // Signal handlers sa.sa_handler = signal_exit; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sigaction(SIGHUP, &sa, 0L); sigaction(SIGINT, &sa, 0L); sigaction(SIGTERM, &sa, 0L); sigaction(SIGQUIT, &sa, 0L); sa.sa_handler = sigchld_handler; sa.sa_flags = SA_NOCLDSTOP; sigaction(SIGCHLD, &sa, 0L); // Expire at least every 5 seconds tv.tv_sec = 5; tv.tv_usec = 0; // Main execution loop ksize_t addrlen; struct sockaddr_un clientname; fd_set tmp_fds, active_fds; FD_ZERO(&active_fds); FD_SET(sockfd, &active_fds); while (1) { tmp_fds = active_fds; if (select(FD_SETSIZE, &tmp_fds, 0L, 0L, &tv) < 0) { if (errno == EINTR) continue; xerror("select(): %s"); exit(1); } tv.tv_sec = 5; tv.tv_usec = 0; repo->expire(); for (i=0; i<FD_SETSIZE; i++) { if (!FD_ISSET(i, &tmp_fds)) continue; if (i == sockfd) { // new connection int fd; addrlen = 64; fd = accept(sockfd, (struct sockaddr *) &clientname, &addrlen); if (fd < 0) { xerror("accept(): %s"); exit(1); } handler[fd] = new ConnectionHandler(fd); FD_SET(fd, &active_fds); debug("Accepted new connection on fd %d", fd); continue; } // handle alreay established connection if (handler[i]->handle() < 0) { delete handler[i]; close(i); FD_CLR(i, &active_fds); } } } warning("???");}
KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); int signalnum = args->getOption( "signal" ).toInt(); int pid = args->getOption( "pid" ).toInt();
KrashConfig krashconf;
int main( int argc, char* argv[] ){ // Make sure that DrKonqi doesn't start DrKonqi when it crashes :-] setenv("KDE_DEBUG", "true", 1); KAboutData aboutData( "drkonqi", I18N_NOOP("The KDE Crash Handler"), version, description, KAboutData::License_BSD, "(C) 2000, Hans Petter Bieker"); aboutData.addAuthor("Hans Petter Bieker", 0, "[email protected]"); KCmdLineArgs::init(argc, argv, &aboutData); KCmdLineArgs::addCmdLineOptions( options ); KApplication a; // parse command line arguments // FIXME: there is error checking here.. KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); int signalnum = args->getOption( "signal" ).toInt(); int pid = args->getOption( "pid" ).toInt(); KAboutData oldabout(args->getOption("appname"), args->getOption("programname"), args->getOption("appversion"), 0, 0, 0, 0, 0, args->getOption("bugaddress")); KrashConfig krashconf(&oldabout, signalnum, pid); Toplevel *w = new Toplevel(&krashconf); int i = w->exec(); delete w; return i;}
KAboutData oldabout(args->getOption("appname"), args->getOption("programname"), args->getOption("appversion"), 0, 0, 0, 0, 0, args->getOption("bugaddress"));
Toplevel w(&krashconf);
int main( int argc, char* argv[] ){ // Make sure that DrKonqi doesn't start DrKonqi when it crashes :-] setenv("KDE_DEBUG", "true", 1); KAboutData aboutData( "drkonqi", I18N_NOOP("The KDE Crash Handler"), version, description, KAboutData::License_BSD, "(C) 2000, Hans Petter Bieker"); aboutData.addAuthor("Hans Petter Bieker", 0, "[email protected]"); KCmdLineArgs::init(argc, argv, &aboutData); KCmdLineArgs::addCmdLineOptions( options ); KApplication a; // parse command line arguments // FIXME: there is error checking here.. KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); int signalnum = args->getOption( "signal" ).toInt(); int pid = args->getOption( "pid" ).toInt(); KAboutData oldabout(args->getOption("appname"), args->getOption("programname"), args->getOption("appversion"), 0, 0, 0, 0, 0, args->getOption("bugaddress")); KrashConfig krashconf(&oldabout, signalnum, pid); Toplevel *w = new Toplevel(&krashconf); int i = w->exec(); delete w; return i;}
KrashConfig krashconf(&oldabout, signalnum, pid); Toplevel *w = new Toplevel(&krashconf); int i = w->exec(); delete w; return i;
return w.exec();
int main( int argc, char* argv[] ){ // Make sure that DrKonqi doesn't start DrKonqi when it crashes :-] setenv("KDE_DEBUG", "true", 1); KAboutData aboutData( "drkonqi", I18N_NOOP("The KDE Crash Handler"), version, description, KAboutData::License_BSD, "(C) 2000, Hans Petter Bieker"); aboutData.addAuthor("Hans Petter Bieker", 0, "[email protected]"); KCmdLineArgs::init(argc, argv, &aboutData); KCmdLineArgs::addCmdLineOptions( options ); KApplication a; // parse command line arguments // FIXME: there is error checking here.. KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); int signalnum = args->getOption( "signal" ).toInt(); int pid = args->getOption( "pid" ).toInt(); KAboutData oldabout(args->getOption("appname"), args->getOption("programname"), args->getOption("appversion"), 0, 0, 0, 0, 0, args->getOption("bugaddress")); KrashConfig krashconf(&oldabout, signalnum, pid); Toplevel *w = new Toplevel(&krashconf); int i = w->exec(); delete w; return i;}
int main( int argc, char **argv )
int main( int, char ** )
int main( int argc, char **argv ){ signal(SIGCHLD,sig_handler); signal(SIGSEGV,sig_handler2); // KProtocolManager manager; debug( "kio_ftp : Starting"); Connection parent( 0, 1 ); FtpProtocol ftp( &parent ); ftp.dispatchLoop(); debug( "kio_ftp : Done" );}
KCmdLineArgs::init(argc, argv, "ktelnetservice", I18N_NOOP("telnet service"), I18N_NOOP("telnet protocol handler"));
KCmdLineArgs::init(argc, argv, "ktelnetservice", I18N_NOOP("telnet service"), I18N_NOOP("telnet protocol handler"), "unknown");
int main(int argc, char **argv){ KLocale::setMainCatalogue("kdelibs"); KCmdLineArgs::init(argc, argv, "ktelnetservice", I18N_NOOP("telnet service"), I18N_NOOP("telnet protocol handler")); KCmdLineArgs::addCmdLineOptions(options); KApplication app; KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); if (args->count() != 1) return 1; KURL url(args->arg(0)); QStringList cmd; cmd << "--noclose"; cmd << "-e"; if ( url.protocol() == "telnet" ) cmd << "telnet"; else if ( url.protocol() == "rlogin" ) cmd << "rlogin"; else { kdError() << "Invalid protocol " << url.protocol() << endl; return 2; } if (!app.authorize("shell_access")) { KMessageBox::sorry(0, i18n("You do not have permission to access the %1 protocol.").arg(url.protocol())); return 3; } if (!url.user().isEmpty()) { cmd << "-l"; cmd << url.user(); } if (!url.host().isEmpty()) cmd << url.host(); // telnet://host else if (!url.path().isEmpty()) cmd << url.path(); // telnet:host if (url.port()) cmd << QString::number(url.port()); app.kdeinitExec("konsole", cmd); return 0;}
smtp.clear(); smtp.metadata["sasl"] = "LOGIN"; mechs.clear(); mechs.append( "LOGIN" ); AuthCommand auth3( &smtp, mechs, "user", "pass" ); ts.clear(); ts2 = ts; assert( auth3.nextCommandLine( &ts ) == "AUTH LOGIN\r\n" ); assert( !auth3.isComplete() ); assert( auth3.needsResponse() ); r.clear(); r.parseLine( "334 VXNlcm5hbWU6" ); assert( auth3.processResponse( r, &ts ) == true ); assert( !auth3.needsResponse() ); assert( auth3.nextCommandLine( &ts ) == "dXNlcg==\r\n" ); assert( !auth3.isComplete() ); assert( auth3.needsResponse() ); r.clear(); r.parseLine( "334 go on" ); assert( auth3.processResponse( r, &ts ) == true ); assert( !auth3.needsResponse() ); assert( auth3.nextCommandLine( &ts ) == "cGFzcw==\r\n" ); assert( auth3.isComplete() ); assert( auth3.needsResponse() ); r.clear(); r.parseLine( "250 OK" ); assert( auth3.processResponse( r, &ts ) == true ); assert( !auth3.needsResponse() ); assert( !smtp.lastErrorCode ); assert( ts == ts2 );
int main( int, char** ) { SMTPProtocol smtp; Response r; TransactionState ts, ts2; // // EHLO / HELO // smtp.clear(); EHLOCommand ehlo( &smtp, "mail.example.com" ); // flags assert( ehlo.closeConnectionOnError() ); assert( ehlo.mustBeLastInPipeline() ); assert( !ehlo.mustBeFirstInPipeline() ); // initial state assert( !ehlo.isComplete() ); assert( !ehlo.doNotExecute( 0 ) ); assert( !ehlo.needsResponse() ); // dynamics 1: EHLO succeeds assert( ehlo.nextCommandLine( 0 ) == "EHLO mail.example.com\r\n" ); assert( !ehlo.isComplete() ); // EHLO may fail and we then try HELO assert( ehlo.needsResponse() ); r.clear(); r.parseLine( "250-mail.example.net\r\n" ); r.parseLine( "250-PIPELINING\r\n" ); r.parseLine( "250 8BITMIME\r\n" ); assert( ehlo.processResponse( r, 0 ) == true ); assert( ehlo.isComplete() ); assert( !ehlo.needsResponse() ); assert( smtp.lastErrorCode == 0 ); assert( smtp.lastErrorMessage.isNull() ); // dynamics 2: EHLO fails with "unknown command" smtp.clear(); EHLOCommand ehlo2( &smtp, "mail.example.com" ); ehlo2.nextCommandLine( 0 ); r.clear(); r.parseLine( "500 unknown command\r\n" ); assert( ehlo2.processResponse( r, 0 ) == true ); assert( !ehlo2.isComplete() ); assert( !ehlo2.needsResponse() ); assert( ehlo2.nextCommandLine( 0 ) == "HELO mail.example.com\r\n" ); assert( ehlo2.isComplete() ); assert( ehlo2.needsResponse() ); r.clear(); r.parseLine( "250 mail.example.net\r\n" ); assert( ehlo2.processResponse( r, 0 ) == true ); assert( !ehlo2.needsResponse() ); assert( smtp.lastErrorCode == 0 ); assert( smtp.lastErrorMessage.isNull() ); // dynamics 3: EHLO fails with unknown response code smtp.clear(); EHLOCommand ehlo3( &smtp, "mail.example.com" ); ehlo3.nextCommandLine( 0 ); r.clear(); r.parseLine( "545 you don't know me\r\n" ); assert( ehlo3.processResponse( r, 0 ) == false ); assert( ehlo3.isComplete() ); assert( !ehlo3.needsResponse() ); assert( smtp.lastErrorCode == KIO::ERR_UNKNOWN ); // dynamics 4: EHLO _and_ HELO fail with "command unknown" smtp.clear(); EHLOCommand ehlo4( &smtp, "mail.example.com" ); ehlo4.nextCommandLine( 0 ); r.clear(); r.parseLine( "500 unknown command\r\n" ); ehlo4.processResponse( r, 0 ); ehlo4.nextCommandLine( 0 ); r.clear(); r.parseLine( "500 unknown command\r\n" ); assert( ehlo4.processResponse( r, 0 ) == false ); assert( ehlo4.isComplete() ); assert( !ehlo4.needsResponse() ); assert( smtp.lastErrorCode == KIO::ERR_INTERNAL_SERVER ); // // STARTTLS // smtp.clear(); StartTLSCommand tls( &smtp ); // flags assert( tls.closeConnectionOnError() ); assert( tls.mustBeLastInPipeline() ); assert( !tls.mustBeFirstInPipeline() ); // initial state assert( !tls.isComplete() ); assert( !tls.doNotExecute( 0 ) ); assert( !tls.needsResponse() ); // dynamics 1: ok from server, TLS negotiation successful ts.clear(); ts2 = ts; assert( tls.nextCommandLine( &ts ) == "STARTTLS\r\n" ); assert( ts == ts2 ); assert( tls.isComplete() ); assert( tls.needsResponse() ); r.clear(); r.parseLine( "220 Go ahead" ); smtp.startTLSReturnCode = 1; assert( tls.processResponse( r, &ts ) == true ); assert( !tls.needsResponse() ); assert( smtp.lastErrorCode == 0 ); // dynamics 2: NAK from server smtp.clear(); StartTLSCommand tls2( &smtp ); ts.clear(); tls2.nextCommandLine( &ts ); r.clear(); r.parseLine( "454 TLS temporarily disabled" ); smtp.startTLSReturnCode = 1; assert( tls2.processResponse( r, &ts ) == false ); assert( !tls2.needsResponse() ); assert( smtp.lastErrorCode == KIO::ERR_SERVICE_NOT_AVAILABLE ); // dynamics 3: ok from server, TLS negotiation unsuccessful smtp.clear(); StartTLSCommand tls3( &smtp ); ts.clear(); tls3.nextCommandLine( &ts ); r.clear(); r.parseLine( "220 Go ahead" ); smtp.startTLSReturnCode = -1; assert( tls.processResponse( r, &ts ) == false ); assert( !tls.needsResponse() ); // // AUTH // smtp.clear(); QStrIList mechs; mechs.append( "PLAIN" ); smtp.metadata["sasl"] = "PLAIN"; AuthCommand auth( &smtp, mechs, "user", "pass" ); // flags assert( auth.closeConnectionOnError() ); assert( auth.mustBeLastInPipeline() ); assert( !auth.mustBeFirstInPipeline() ); // initial state assert( !auth.isComplete() ); assert( !auth.doNotExecute( 0 ) ); assert( !auth.needsResponse() ); // dynamics 1: TLS, so AUTH should include initial-response: smtp.usesTLS = true; ts.clear(); ts2 = ts; assert( auth.nextCommandLine( &ts ) == "AUTH PLAIN dXNlcgB1c2VyAHBhc3M=\r\n" ); assert( auth.isComplete() ); assert( auth.needsResponse() ); assert( ts == ts2 ); r.clear(); r.parseLine( "250 OK" ); // dynamics 2: No TLS, so AUTH should not include initial-response: smtp.clear(); smtp.metadata["sasl"] = "PLAIN"; smtp.usesTLS = false; AuthCommand auth2( &smtp, mechs, "user", "pass" ); ts.clear(); assert( auth2.nextCommandLine( &ts ) == "AUTH PLAIN\r\n" ); assert( !auth2.isComplete() ); assert( auth2.needsResponse() ); r.clear(); r.parseLine( "334 Go on" ); assert( auth2.processResponse( r, &ts ) == true ); assert( auth2.nextCommandLine( &ts ) == "dXNlcgB1c2VyAHBhc3M=\r\n" ); assert( auth2.isComplete() ); assert( auth2.needsResponse() ); // // MAIL FROM: // smtp.clear(); MailFromCommand mail( &smtp, "[email protected]" ); // flags assert( !mail.closeConnectionOnError() ); assert( !mail.mustBeLastInPipeline() ); assert( !mail.mustBeFirstInPipeline() ); // initial state assert( !mail.isComplete() ); assert( !mail.doNotExecute( 0 ) ); assert( !mail.needsResponse() ); // dynamics: success, no size, no 8bit ts.clear(); ts2 = ts; assert( mail.nextCommandLine( &ts ) == "MAIL FROM:<[email protected]>\r\n" ); assert( ts2 == ts ); assert( mail.isComplete() ); assert( mail.needsResponse() ); r.clear(); r.parseLine( "250 Ok" ); assert( mail.processResponse( r, &ts ) == true ); assert( !mail.needsResponse() ); assert( ts == ts2 ); assert( smtp.lastErrorCode == 0 ); // dynamics: success, size, 8bit, but no SIZE, 8BITMIME caps smtp.clear(); MailFromCommand mail2( &smtp, "[email protected]", true, 500 ); ts.clear(); ts2 = ts; assert( mail2.nextCommandLine( &ts ) == "MAIL FROM:<[email protected]>\r\n" ); assert( ts == ts2 ); // dynamics: success, size, 8bit, SIZE, 8BITMIME caps smtp.clear(); MailFromCommand mail3( &smtp, "[email protected]", true, 500 ); ts.clear(); ts2 = ts; smtp.caps << "SIZE" << "8BITMIME" ; assert( mail3.nextCommandLine( &ts ) == "MAIL FROM:<[email protected]> BODY=8BITMIME SIZE=500\r\n" ); assert( ts == ts2 ); // dynamics: failure smtp.clear(); MailFromCommand mail4( &smtp, "[email protected]" ); ts.clear(); mail4.nextCommandLine( &ts ); r.clear(); r.parseLine( "503 Bad sequence of commands" ); assert( mail4.processResponse( r, &ts ) == false ); assert( mail4.isComplete() ); assert( !mail4.needsResponse() ); assert( ts.failed() ); assert( !ts.failedFatally() ); assert( smtp.lastErrorCode == 0 ); // // RCPT TO: // smtp.clear(); RcptToCommand rcpt( &smtp, "[email protected]" ); // flags assert( !rcpt.closeConnectionOnError() ); assert( !rcpt.mustBeLastInPipeline() ); assert( !rcpt.mustBeFirstInPipeline() ); // initial state assert( !rcpt.isComplete() ); assert( !rcpt.doNotExecute( 0 ) ); assert( !rcpt.needsResponse() ); // dynamics: success ts.clear(); ts2 = ts; assert( rcpt.nextCommandLine( &ts ) == "RCPT TO:<[email protected]>\r\n" ); assert( ts == ts2 ); assert( rcpt.isComplete() ); assert( rcpt.needsResponse() ); r.clear(); r.parseLine( "250 Ok" ); assert( rcpt.processResponse( r, &ts ) == true ); assert( !rcpt.needsResponse() ); assert( ts.atLeastOneRecipientWasAccepted() ); assert( !ts.haveRejectedRecipients() ); assert( !ts.failed() ); assert( !ts.failedFatally() ); assert( smtp.lastErrorCode == 0 ); // dynamics: failure smtp.clear(); RcptToCommand rcpt2( &smtp, "[email protected]" ); ts.clear(); rcpt2.nextCommandLine( &ts ); r.clear(); r.parseLine( "530 5.7.1 Relaying not allowed!" ); assert( rcpt2.processResponse( r, &ts ) == false ); assert( rcpt2.isComplete() ); assert( !rcpt2.needsResponse() ); assert( !ts.atLeastOneRecipientWasAccepted() ); assert( ts.haveRejectedRecipients() ); assert( ts.rejectedRecipients().count() == 1 ); assert( ts.rejectedRecipients().front().recipient == "[email protected]" ); assert( ts.failed() ); assert( !ts.failedFatally() ); assert( smtp.lastErrorCode == 0 ); // dynamics: success and failure combined smtp.clear(); RcptToCommand rcpt3( &smtp, "[email protected]" ); RcptToCommand rcpt4( &smtp, "[email protected]" ); RcptToCommand rcpt5( &smtp, "[email protected]" ); ts.clear(); rcpt3.nextCommandLine( &ts ); r.clear(); r.parseLine( "530 5.7.1 Relaying not allowed!" ); rcpt3.processResponse( r, &ts ); rcpt4.nextCommandLine( &ts ); r.clear(); r.parseLine( "250 Ok" ); rcpt4.processResponse( r, &ts ); rcpt5.nextCommandLine( &ts ); r.clear(); r.parseLine( "250 Ok" ); assert( ts.failed() ); assert( !ts.failedFatally() ); assert( ts.haveRejectedRecipients() ); assert( ts.atLeastOneRecipientWasAccepted() ); assert( smtp.lastErrorCode == 0 ); // // DATA (init) // smtp.clear(); DataCommand data( &smtp ); // flags assert( !data.closeConnectionOnError() ); assert( data.mustBeLastInPipeline() ); assert( !data.mustBeFirstInPipeline() ); // initial state assert( !data.isComplete() ); assert( !data.doNotExecute( 0 ) ); assert( !data.needsResponse() ); // dynamics: success ts.clear(); assert( data.nextCommandLine( &ts ) == "DATA\r\n" ); assert( data.isComplete() ); assert( data.needsResponse() ); assert( ts.dataCommandIssued() ); assert( !ts.dataCommandSucceeded() ); r.clear(); r.parseLine( "354 Send data, end in <CR><LF>.<CR><LF>" ); assert( data.processResponse( r, &ts ) == true ); assert( !data.needsResponse() ); assert( ts.dataCommandSucceeded() ); assert( ts.dataResponse() == r ); assert( smtp.lastErrorCode == 0 ); // dynamics: failure smtp.clear(); DataCommand data2( &smtp ); ts.clear(); data2.nextCommandLine( &ts ); r.clear(); r.parseLine( "551 No valid recipients" ); assert( data2.processResponse( r, &ts ) == false ); assert( !data2.needsResponse() ); assert( !ts.dataCommandSucceeded() ); assert( ts.dataResponse() == r ); assert( smtp.lastErrorCode == 0 ); // // DATA (transfer) // TransferCommand xfer( &smtp, 0 ); // flags assert( !xfer.closeConnectionOnError() ); assert( !xfer.mustBeLastInPipeline() ); assert( xfer.mustBeFirstInPipeline() ); // initial state assert( !xfer.isComplete() ); assert( !xfer.needsResponse() ); // dynamics 1: DATA command failed ts.clear(); r.clear(); r.parseLine( "551 no valid recipients" ); ts.setDataCommandIssued( true ); ts.setDataCommandSucceeded( false, r ); assert( xfer.doNotExecute( &ts ) ); // dynamics 2: some recipients rejected, but not all smtp.clear(); TransferCommand xfer2( &smtp, 0 ); ts.clear(); ts.setRecipientAccepted(); ts.addRejectedRecipient( "[email protected]", "No relaying allowed" ); ts.setDataCommandIssued( true ); r.clear(); r.parseLine( "354 go on" ); ts.setDataCommandSucceeded( true, r ); // ### will change with allow-partial-delivery option: assert( xfer.doNotExecute( &ts ) ); // successful dynamics with all combinations of: enum { EndInLF = 1, PerformDotStuff = 2, UngetLast = 4, Preloading = 8, Error = 16, EndOfOptions = 32 }; for ( unsigned int i = 0 ; i < EndOfOptions ; ++i ) checkSuccessfulTransferCommand( i & Error, i & Preloading, i & UngetLast, i & PerformDotStuff, i & EndInLF ); // // NOOP // smtp.clear(); NoopCommand noop( &smtp ); // flags assert( !noop.closeConnectionOnError() ); assert( noop.mustBeLastInPipeline() ); assert( !noop.mustBeFirstInPipeline() ); // initial state assert( !noop.isComplete() ); assert( !noop.doNotExecute( &ts ) ); assert( !noop.needsResponse() ); // dynamics: success (failure is tested with RSET) assert( noop.nextCommandLine( 0 ) == "NOOP\r\n" ); assert( noop.isComplete() ); assert( noop.needsResponse() ); r.clear(); r.parseLine( "250 Ok" ); assert( noop.processResponse( r, 0 ) == true ); assert( noop.isComplete() ); assert( !noop.needsResponse() ); assert( smtp.lastErrorCode == 0 ); assert( smtp.lastErrorMessage.isNull() ); // // RSET // smtp.clear(); RsetCommand rset( &smtp ); // flags assert( rset.closeConnectionOnError() ); assert( !rset.mustBeLastInPipeline() ); assert( !rset.mustBeFirstInPipeline() ); // initial state assert( !rset.isComplete() ); assert( !rset.doNotExecute( &ts ) ); assert( !rset.needsResponse() ); // dynamics: failure (success is tested with NOOP/QUIT) assert( rset.nextCommandLine( 0 ) == "RSET\r\n" ); assert( rset.isComplete() ); assert( rset.needsResponse() ); r.clear(); r.parseLine( "502 command not implemented" ); assert( rset.processResponse( r, 0 ) == false ); assert( rset.isComplete() ); assert( !rset.needsResponse() ); assert( smtp.lastErrorCode == 0 ); // an RSET failure isn't worth it, is it? assert( smtp.lastErrorMessage.isNull() ); // // QUIT // smtp.clear(); QuitCommand quit( &smtp ); // flags assert( quit.closeConnectionOnError() ); assert( quit.mustBeLastInPipeline() ); assert( !quit.mustBeFirstInPipeline() ); // initial state assert( !quit.isComplete() ); assert( !quit.doNotExecute( 0 ) ); assert( !quit.needsResponse() ); // dynamics 1: success assert( quit.nextCommandLine( 0 ) == "QUIT\r\n" ); assert( quit.isComplete() ); assert( quit.needsResponse() ); r.clear(); r.parseLine( "221 Goodbye" ); assert( quit.processResponse( r, 0 ) == true ); assert( quit.isComplete() ); assert( !quit.needsResponse() ); assert( smtp.lastErrorCode == 0 ); assert( smtp.lastErrorMessage.isNull() ); // dynamics 2: success smtp.clear(); QuitCommand quit2( &smtp ); quit2.nextCommandLine( 0 ); r.clear(); r.parseLine( "500 unknown command" ); assert( quit2.processResponse( r, 0 ) == false ); assert( quit2.isComplete() ); assert( !quit2.needsResponse() ); assert( smtp.lastErrorCode == 0 ); // an QUIT failure isn't worth it, is it? assert( smtp.lastErrorMessage.isNull() ); return 0;}
if ( args->isSet("maximize-vertical") ) { state |= NET::MaxVert; mask |= NET::MaxVert; } if ( args->isSet("maximize-horizontal") ) { state |= NET::MaxHoriz; mask |= NET::MaxHoriz; }
int main( int argc, char *argv[] ){ // David, 05/03/2000 KAboutData aboutData( "kstart", I18N_NOOP("KStart"), KSTART_VERSION, I18N_NOOP("" "Utility to launch applications with special window properties \n" "such as iconified, maximized, a certain virtual desktop, a special decoration\n" "and so on." ), KAboutData::License_GPL, "(C) 1997-2000 Matthias Ettrich ([email protected])" ); aboutData.addAuthor( "Matthias Ettrich", 0, "[email protected]" ); aboutData.addAuthor( "David Faure", 0, "[email protected]" ); aboutData.addAuthor( "Richard J. Moore", 0, "[email protected]" ); KCmdLineArgs::init( argc, argv, &aboutData ); KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. KApplication app; KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); if ( args->count() == 0 ) KCmdLineArgs::usage(i18n("No command specified")); // Perhaps we should use a konsole-like solution here (shell, list of args...) for(int i=0; i < args->count(); i++) command += QCString(args->arg(i)) + " "; kwinmodule = new KWinModule; desktop = args->getOption( "desktop" ).toInt(); if ( args->isSet ( "alldesktops") ) desktop = NETWinInfo::OnAllDesktops; if ( args->isSet ( "currentdesktop") ) desktop = kwinmodule->currentDesktop(); window = args->getOption( "window" ); if( window.isEmpty()) kdWarning() << "Omitting --window argument is not recommended" << endl; QCString s = args->getOption( "type" ); if ( !s.isEmpty() ) { s = s.lower(); if ( s == "desktop" ) windowtype = NET::Desktop; else if ( s == "dock" ) windowtype = NET::Dock; else if ( s == "tool" ) windowtype = NET::Tool; else if ( s == "menu" ) windowtype = NET::Menu; else if ( s == "dialog" ) windowtype = NET::Dialog; else if ( s == "override" ) windowtype = NET::Override; else if ( s == "topmenu" ) windowtype = NET::TopMenu; else windowtype = NET::Normal; } if ( args->isSet( "keepabove" ) ) { state |= NET::KeepAbove; mask |= NET::KeepAbove; } else if ( args->isSet( "keepbelow" ) ) { state |= NET::KeepBelow; mask |= NET::KeepBelow; } if ( args->isSet( "skiptaskbar" ) ) { state |= NET::SkipTaskbar; mask |= NET::SkipTaskbar; } if ( args->isSet( "skippager" ) ) { state |= NET::SkipPager; mask |= NET::SkipPager; } activate = args->isSet("activate"); if ( args->isSet("maximize") ) { state |= NET::Max; mask |= NET::Max; } iconify = args->isSet("iconify"); toSysTray = args->isSet("tosystray"); if ( args->isSet("fullscreen") ) { NETRootInfo i( qt_xdisplay(), NET::Supported ); if( i.isSupported( NET::FullScreen )) { state |= NET::FullScreen; mask |= NET::FullScreen; } else { windowtype = NET::Override; fullscreen = true; } } fcntl(ConnectionNumber(qt_xdisplay()), F_SETFD, 1); args->clear(); KStart start; QTimer::singleShot( 120 * 1000, &app, SLOT( quit())); // quit if nothing happens in 2 minutes return app.exec();}
CheesySerializer *serializer = new CheesySerializer( new TCPMessenger(MSG_ADDR_CLIENT(i)) ); client[i] = new Client(mdc, i, serializer);
client[i] = new Client(mdc, i, new TCPMessenger(MSG_ADDR_CLIENT(i)));
int main(int oargc, char **oargv) { //cerr << "tcpfuse starting " << myrank << "/" << world << endl; int argc; char **argv; parse_config_options(oargc, oargv, argc, argv); int start = 0; // build new argc+argv for fuse typedef char* pchar; int nargc = 0; char **nargv = new pchar[argc]; nargv[nargc++] = argv[0]; int mkfs = 0; for (int i=1; i<argc; i++) { if (strcmp(argv[i], "--fastmkfs") == 0) { mkfs = MDS_MKFS_FAST; } else if (strcmp(argv[i], "--fullmkfs") == 0) { mkfs = MDS_MKFS_FULL; } else { // unknown arg, pass it on. nargv[nargc++] = argv[i]; } } int myrank = tcpmessenger_init(argc, argv); int world = tcpmessenger_world(); assert(NUMMDS + NUMOSD + NUMCLIENT <= world); MDCluster *mdc = new MDCluster(NUMMDS, NUMOSD); char hostname[100]; gethostname(hostname,100); int pid = getpid(); // create mds MDS *mds[NUMMDS]; for (int i=0; i<NUMMDS; i++) { if (myrank != MPI_DEST_TO_RANK(MSG_ADDR_MDS(i),world)) continue; cerr << "mds" << i << " on rank " << myrank << " " << hostname << "." << pid << endl; mds[i] = new MDS(mdc, i, new TCPMessenger(MSG_ADDR_MDS(i))); start++; } // create osd OSD *osd[NUMOSD]; for (int i=0; i<NUMOSD; i++) { if (myrank != MPI_DEST_TO_RANK(MSG_ADDR_OSD(i),world)) continue; cerr << "osd" << i << " on rank " << myrank << " " << hostname << "." << pid << endl; osd[i] = new OSD(i, new TCPMessenger(MSG_ADDR_OSD(i))); start++; } // create client Client *client[NUMCLIENT]; for (int i=0; i<NUMCLIENT; i++) { if (myrank != MPI_DEST_TO_RANK(MSG_ADDR_CLIENT(i),world)) continue; cerr << "client" << i << " on rank " << myrank << " " << hostname << "." << pid << endl; CheesySerializer *serializer = new CheesySerializer( new TCPMessenger(MSG_ADDR_CLIENT(i)) ); client[i] = new Client(mdc, i, serializer); start++; } // start message loop if (start) { tcpmessenger_start(); // init for (int i=0; i<NUMMDS; i++) { if (myrank != MPI_DEST_TO_RANK(MSG_ADDR_MDS(i),world)) continue; mds[i]->init(); } for (int i=0; i<NUMOSD; i++) { if (myrank != MPI_DEST_TO_RANK(MSG_ADDR_OSD(i),world)) continue; osd[i]->init(); } // create client for (int i=0; i<NUMCLIENT; i++) { if (myrank != MPI_DEST_TO_RANK(MSG_ADDR_CLIENT(i),world)) continue; client[i]->init(); // start up fuse // use my argc, argv (make sure you pass a mount point!) cout << "mounting" << endl; client[i]->mount(mkfs); cout << "starting fuse on rank " << myrank << " pid " << getpid() << endl; ceph_fuse_main(client[i], nargc, nargv); cout << "fuse finished on rank " << myrank << " pid " << getpid() << endl; } for (int i=0; i<NUMCLIENT; i++) { if (myrank != MPI_DEST_TO_RANK(MSG_ADDR_CLIENT(i),world)) continue; client[i]->unmount(); cout << "unmounted" << endl; client[i]->shutdown(); } // wait for it to finish tcpmessenger_wait(); } else { cerr << "IDLE rank " << myrank << endl; } tcpmessenger_shutdown(); // shutdown MPI // cleanup for (int i=0; i<NUMMDS; i++) { if (myrank != MPI_DEST_TO_RANK(MSG_ADDR_MDS(i),world)) continue; delete mds[i]; } for (int i=0; i<NUMOSD; i++) { if (myrank != MPI_DEST_TO_RANK(MSG_ADDR_OSD(i),world)) continue; delete osd[i]; } for (int i=0; i<NUMCLIENT; i++) { if (myrank != MPI_DEST_TO_RANK(MSG_ADDR_CLIENT(i),world)) continue; delete client[i]; } delete mdc; return 0;}