rem
stringlengths
0
83.5k
add
stringlengths
0
223k
context
stringlengths
10
471k
meta
stringlengths
120
236
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 (pw->pw_uid) { // Only propagate KDEHOME for non-root users, // root uses KDEROOTHOME // Translate the KDEHOME of this user to the new user. QString kdeHome = KGlobal::dirs()->relativeLocation("home", KGlobal::dirs()->localkdedir()); if (kdeHome[0] != '/') kdeHome.prepend("~/"); else kdeHome=QString::null; // Use default env << ("KDEHOME="+ QFile::encodeName(kdeHome)); } 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); }}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/a15fc46ae247aaa93909392ddc4ca7d2609ed34b/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
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 (pw->pw_uid) { // Only propagate KDEHOME for non-root users, // root uses KDEROOTHOME // Translate the KDEHOME of this user to the new user. QString kdeHome = KGlobal::dirs()->relativeLocation("home", KGlobal::dirs()->localkdedir()); if (kdeHome[0] != '/') kdeHome.prepend("~/"); else kdeHome=QString::null; // Use default env << ("KDEHOME="+ QFile::encodeName(kdeHome)); } 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); }}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/a15fc46ae247aaa93909392ddc4ca7d2609ed34b/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp
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 (pw->pw_uid) { // Only propagate KDEHOME for non-root users, // root uses KDEROOTHOME // Translate the KDEHOME of this user to the new user. QString kdeHome = KGlobal::dirs()->relativeLocation("home", KGlobal::dirs()->localkdedir()); if (kdeHome[0] != '/') kdeHome.prepend("~/"); else kdeHome=QString::null; // Use default env << ("KDEHOME="+ QFile::encodeName(kdeHome)); } 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); }}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/a15fc46ae247aaa93909392ddc4ca7d2609ed34b/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp
KStartupInfoId id; id.initId( app->startupId()); id.setupStartupEnv();
KStartupInfoId id; id.initId( app->startupId()); id.setupStartupEnv();
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 (pw->pw_uid) { // Only propagate KDEHOME for non-root users, // root uses KDEROOTHOME // Translate the KDEHOME of this user to the new user. QString kdeHome = KGlobal::dirs()->relativeLocation("home", KGlobal::dirs()->localkdedir()); if (kdeHome[0] != '/') kdeHome.prepend("~/"); else kdeHome=QString::null; // Use default env << ("KDEHOME="+ QFile::encodeName(kdeHome)); } 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); }}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/a15fc46ae247aaa93909392ddc4ca7d2609ed34b/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp
if (args->isSet("s"))
int result = startApp(); if (result == 127)
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 (pw->pw_uid) { // Only propagate KDEHOME for non-root users, // root uses KDEROOTHOME // Translate the KDEHOME of this user to the new user. QString kdeHome = KGlobal::dirs()->relativeLocation("home", KGlobal::dirs()->localkdedir()); if (kdeHome[0] != '/') kdeHome.prepend("~/"); else kdeHome=QString::null; // Use default env << ("KDEHOME="+ QFile::encodeName(kdeHome)); } 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); }}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/a15fc46ae247aaa93909392ddc4ca7d2609ed34b/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp
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);
KMessageBox::sorry(0, i18n("Command '%1' not found.").arg(command));
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 (pw->pw_uid) { // Only propagate KDEHOME for non-root users, // root uses KDEROOTHOME // Translate the KDEHOME of this user to the new user. QString kdeHome = KGlobal::dirs()->relativeLocation("home", KGlobal::dirs()->localkdedir()); if (kdeHome[0] != '/') kdeHome.prepend("~/"); else kdeHome=QString::null; // Use default env << ("KDEHOME="+ QFile::encodeName(kdeHome)); } 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); }}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/a15fc46ae247aaa93909392ddc4ca7d2609ed34b/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp
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); 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(); } 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"; } 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); }} if (!change_uid) return system(command); 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; } 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 (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)); } if (!new_dcop) { QCString ksycoca = "KDESYCOCA="+QFile::encodeName(locateLocal("tmp", "ksycoca")); env << ksycoca; options += "xf"; } if (keep && !terminal && !just_started) { client.setPriority(priority); client.setScheduler(scheduler); if (client.exec(command, user, options, env) != -1) return 0; } struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 0; if (setrlimit(RLIMIT_CORE, &rlim)) { kdError(1206) << "rlimit(): " << ERR << "\n"; exit(1); } KConfig *config = KGlobal::config(); config->setGroup("Passwords"); int timeout = config->readNumEntry("Timeout", defTimeout); 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"; } 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 ); } app->processEvents(); if (!change_uid) return system(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); }
return result;
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 (pw->pw_uid) { // Only propagate KDEHOME for non-root users, // root uses KDEROOTHOME // Translate the KDEHOME of this user to the new user. QString kdeHome = KGlobal::dirs()->relativeLocation("home", KGlobal::dirs()->localkdedir()); if (kdeHome[0] != '/') kdeHome.prepend("~/"); else kdeHome=QString::null; // Use default env << ("KDEHOME="+ QFile::encodeName(kdeHome)); } 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); }}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/a15fc46ae247aaa93909392ddc4ca7d2609ed34b/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp
client[i]->unmount();
int main(int argc, char **argv) { cout << "fakefuse starting" << endl; MDCluster *mdc = new MDCluster(NUMMDS, NUMOSD); // start messenger thread fakemessenger_startthread(); g_timer.add_event_after(5.0, new C_Test2); g_timer.add_event_after(10.0, new C_Test); // create mds MDS *mds[NUMMDS]; for (int i=0; i<NUMMDS; i++) { mds[i] = new MDS(mdc, i, new FakeMessenger(MSG_ADDR_MDS(i))); mds[i]->init(); } // create osd OSD *osd[NUMOSD]; for (int i=0; i<NUMOSD; i++) { osd[i] = new OSD(i, new FakeMessenger(MSG_ADDR_OSD(i))); osd[i]->init(); } // create client Client *client[NUMCLIENT]; for (int i=0; i<NUMCLIENT; i++) { // build a serialized fakemessenger... FakeMessenger *fake = new FakeMessenger(MSG_ADDR_CLIENT(0)); CheesySerializer *serializer = new CheesySerializer(fake); fake->set_dispatcher(serializer); client[i] = new Client(mdc, i, serializer); client[i]->init(); // start up fuse // use my argc, argv (make sure you pass a mount point!) cout << "starting fuse on pid " << getpid() << endl; ceph_fuse_main(client[i], argc, argv); cout << "fuse finished on pid " << getpid() << endl; client[i]->shutdown(); } // wait for it to finish cout << "DONE -----" << endl; fakemessenger_stopthread(); // blocks until messenger stops // shutdown /* cout << "---- check ----" << endl; for (int i=0; i<NUMMDS; i++) { if (myrank != MPI_DEST_TO_RANK(MSG_ADDR_MDS(i),world)) continue; mds[i]->mdcache->shutdown_pass(); } */ // cleanup for (int i=0; i<NUMMDS; i++) { delete mds[i]; } for (int i=0; i<NUMOSD; i++) { delete osd[i]; } for (int i=0; i<NUMCLIENT; i++) { delete client[i]; } delete mdc; return 0;}
2690 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2690/df500177ae6e5046343fde6b67f1721e19faee15/fakefuse.cc/clean/ceph/fakefuse.cc
kdDebug() << "Initializing " << libName << ": " << factory << endl;
kdDebug(1208) << "Initializing " << libName << ": " << factory << endl;
int main(int argc, char *argv[]){ KLocale::setMainCatalogue("kcontrol"); KAboutData aboutData( "kcminit", I18N_NOOP("KCMInit"), "$Id$", I18N_NOOP("KCMInit - runs startups initialization for Control Modules.")); KCmdLineArgs::init(argc, argv, &aboutData); KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. KApplication app; KLocale::setMainCatalogue(0); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); QCString arg; if (args->count() == 1) { arg = args->arg(0); } // get the library loader instance KLibLoader *loader = KLibLoader::self(); KService::List list; if (!arg.isEmpty()) { QString path = KCGlobal::baseGroup(); path += arg; path += ".desktop"; KService::Ptr serv = KService::serviceByDesktopPath( path ); if (!serv) { // Path didn't work. Trying as a name serv = KService::serviceByDesktopName( arg ); } if ( !serv || serv->library().isEmpty() || serv->init().isEmpty()) { kdError(1208) << i18n("Module %1 not found!").arg(arg) << endl; return -1; } else list.append(serv); } else { // locate the desktop files list = KService::allInitServices(); } // look for X-KDE-Init=... entries for(KService::List::Iterator it = list.begin(); it != list.end(); ++it) { KService::Ptr service = (*it); if (service->library().isEmpty() || service->init().isEmpty()) continue; // Skip // try to load the library QString libName = QString("libkcm_%1").arg(service->library()); KLibrary *lib = loader->library(QFile::encodeName(libName)); if (lib) { // get the init_ function QString factory = QString("init_%1").arg(service->init()); void *init = lib->symbol(factory.utf8()); if (init) { // initialize the module kdDebug() << "Initializing " << libName << ": " << factory << endl; void (*func)() = (void(*)())init; func(); } loader->unloadLibrary(QFile::encodeName(libName)); } } if ( !kapp->dcopClient()->isAttached() ) kapp->dcopClient()->attach(); kapp->dcopClient()->send( "ksplash", "", "upAndRunning(QString)", QString("kcminit")); return 0;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/1358c70a9564cd327c27ff2fe7ae98d914f2e449/kcminit.cpp/buggy/kcontrol/kcontrol/kcminit.cpp
if ( qgis->addRasterLayer(argv[i]) ) { continue;
if(!qgis->addProject(path)){ bool ok = qgis->addRasterLayer(path); if(!ok){ ok = qgis->addLayer(argv[i]); if(!ok){ std::cout << "Unable to load " << argv[i] << std::endl; } }
int main(int argc, char *argv[]){ 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 (argc == 2) { QString translation = "qgis_" + QString(argv[1]); 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(); a.setMainWidget(qgis); qgis->show(); // // autoload any filenames that were passed in on the command line // for (int i = 1; i < argc; i++) {#ifdef QGISDEBUG printf("%d: %s\n", i, argv[i]);#endif // try to add all these layers - any unsupported file types will // be refected automatically if ( qgis->addRasterLayer(argv[i]) ) { // NOP continue; } else if ( qgis->addLayer(argv[i]) ) { // NOP continue; } else { // XXX should have complaint here about file not being valid#ifdef QGISDEBUG std::cerr << argv[i] << " is not a recognized file\n"; #endif } } a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); // //turn control over to the main application loop... // int result = a.exec(); return result;}
1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/511274d7fa4e78c85f6177fd98e2b4655092781c/main.cpp/clean/src/main.cpp
else if ( qgis->addLayer(argv[i]) ) { continue; } else { #ifdef QGISDEBUG std::cerr << argv[i] << " is not a recognized file\n"; #endif }
int main(int argc, char *argv[]){ 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 (argc == 2) { QString translation = "qgis_" + QString(argv[1]); 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(); a.setMainWidget(qgis); qgis->show(); // // autoload any filenames that were passed in on the command line // for (int i = 1; i < argc; i++) {#ifdef QGISDEBUG printf("%d: %s\n", i, argv[i]);#endif // try to add all these layers - any unsupported file types will // be refected automatically if ( qgis->addRasterLayer(argv[i]) ) { // NOP continue; } else if ( qgis->addLayer(argv[i]) ) { // NOP continue; } else { // XXX should have complaint here about file not being valid#ifdef QGISDEBUG std::cerr << argv[i] << " is not a recognized file\n"; #endif } } a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); // //turn control over to the main application loop... // int result = a.exec(); return result;}
1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/511274d7fa4e78c85f6177fd98e2b4655092781c/main.cpp/clean/src/main.cpp
int main( int, char ** ){ signal(SIGCHLD, KIOProtocol::sigchld_handler);// signal(SIGSEGV, IOProtocol::sigsegv_handler); KInstance instance( "kio_http" ); KIOConnection parent( 0, 1 ); HTTPProtocol http( &parent ); http.dispatchLoop();}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/44dcf0b4be0c963268919da8ed27f3f996bec89c/http.cc/clean/kioslave/http/http.cc
kdebug( KDEBUG_INFO, 7103, "Done" );
int main( int, char ** ){ signal(SIGCHLD, KIOProtocol::sigchld_handler);// signal(SIGSEGV, IOProtocol::sigsegv_handler); KInstance instance( "kio_http" ); KIOConnection parent( 0, 1 ); HTTPProtocol http( &parent ); http.dispatchLoop();}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/44dcf0b4be0c963268919da8ed27f3f996bec89c/http.cc/clean/kioslave/http/http.cc
/*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. */ a.processEvents();
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(); 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; } } } ///////////////////////////////////////////////////////////////////// // Load a project file if one was specified ///////////////////////////////////////////////////////////////////// if(myProjectFileName!="") { qgis->addProject(myProjectFileName); } ///////////////////////////////////////////////////////////////////// // 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();}
1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/760892cdbbdd6c7f8e05045392561a932fb473a1/main.cpp/clean/src/main.cpp
a.processEvents(); qgis->hide();
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(); 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; } } } ///////////////////////////////////////////////////////////////////// // Load a project file if one was specified ///////////////////////////////////////////////////////////////////// if(myProjectFileName!="") { qgis->addProject(myProjectFileName); } ///////////////////////////////////////////////////////////////////// // 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();}
1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/760892cdbbdd6c7f8e05045392561a932fb473a1/main.cpp/clean/src/main.cpp
int main( int argc, char* argv[] ){ 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; KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); QCString signal = args->getOption( "signal" ); int signalnum = signal.toInt(); QCString appname = args->getOption( "appname" ); Toplevel *w = new Toplevel(signalnum, appname); return w->exec();}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/543fefc2e7119726ce000ba5f390d3f3db1a6e01/main.cpp/buggy/drkonqi/main.cpp
int main(int argc, char *argv[]){ KAboutData aboutData( "khelpcenter", I18N_NOOP("KDE HelpCenter"), HELPCENTER_VERSION, description, KAboutData::License_GPL, "(c) 1999-2000, Matthias Elter"); aboutData.addAuthor("Matthias Elter",0, "[email protected]"); KCmdLineArgs::init( argc, argv, &aboutData );// KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. KApplication app( false, false ); // no GUI in this process app.dcopClient()->attach(); // we want to get applicationRegistered app.dcopClient()->setNotifications( true ); Listener listener; QObject::connect( app.dcopClient(), SIGNAL( applicationRegistered( const QCString& ) ), &listener, SLOT( slotAppRegistered( const QCString & ) ) ); system( "konqueror --silent &" ); app.exec();}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/f13060a46eca565e5315bdaccc13bfaa1e4aead0/khc_main.cc/buggy/khelpcenter/khc_main.cc
if(myProjectFileName!="") { qgis->addProject(myProjectFileName); }
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 /////////////////////////////////////////////////////////////////////#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; } } } ///////////////////////////////////////////////////////////////////// // Load a project file if one was specified ///////////////////////////////////////////////////////////////////// if(myProjectFileName!="") { qgis->addProject(myProjectFileName); } ///////////////////////////////////////////////////////////////////// // 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();}
1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/dd2ff5ef0c4bf4f011fe1d5a13263aed446d1f8d/main.cpp/buggy/src/main.cpp
KAboutData aboutData("crashtext", "Crash Test for DrKonqi", "1.1", "Crash Test for DrKonqi", KAboutData::License_GPL, "(c) 2000-2002 David Faure, Waldo Bastian");
KAboutData aboutData("crashtext", "Crash Test for DrKonqi", "1.1", "Crash Test for DrKonqi", KAboutData::License_GPL, "(c) 2000-2002 David Faure, Waldo Bastian");
int main(int argc, char *argv[]){ KAboutData aboutData("crashtext", "Crash Test for DrKonqi", "1.1", "Crash Test for DrKonqi", KAboutData::License_GPL, "(c) 2000-2002 David Faure, Waldo Bastian"); KCmdLineArgs::init(argc, argv, &aboutData); KCmdLineArgs::addCmdLineOptions(options); KApplication app(false,false); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); QCString type = args->arg(0); int crashtype = Crash; if (type == "malloc") crashtype = Malloc; else if (type == "div0") crashtype = Div0; else if (type == "assert") crashtype = Assert; level1(crashtype); return app.exec();}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/da930ed6a3bdf1bf8a5ed02103cadc8f923d64c5/crashtest.cpp/buggy/drkonqi/crashtest.cpp
KApplication app(false,false);
KApplication app(false, false);
int main(int argc, char *argv[]){ KAboutData aboutData("crashtext", "Crash Test for DrKonqi", "1.1", "Crash Test for DrKonqi", KAboutData::License_GPL, "(c) 2000-2002 David Faure, Waldo Bastian"); KCmdLineArgs::init(argc, argv, &aboutData); KCmdLineArgs::addCmdLineOptions(options); KApplication app(false,false); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); QCString type = args->arg(0); int crashtype = Crash; if (type == "malloc") crashtype = Malloc; else if (type == "div0") crashtype = Div0; else if (type == "assert") crashtype = Assert; level1(crashtype); return app.exec();}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/da930ed6a3bdf1bf8a5ed02103cadc8f923d64c5/crashtest.cpp/buggy/drkonqi/crashtest.cpp
crashtype = Malloc;
crashtype = Malloc;
int main(int argc, char *argv[]){ KAboutData aboutData("crashtext", "Crash Test for DrKonqi", "1.1", "Crash Test for DrKonqi", KAboutData::License_GPL, "(c) 2000-2002 David Faure, Waldo Bastian"); KCmdLineArgs::init(argc, argv, &aboutData); KCmdLineArgs::addCmdLineOptions(options); KApplication app(false,false); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); QCString type = args->arg(0); int crashtype = Crash; if (type == "malloc") crashtype = Malloc; else if (type == "div0") crashtype = Div0; else if (type == "assert") crashtype = Assert; level1(crashtype); return app.exec();}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/da930ed6a3bdf1bf8a5ed02103cadc8f923d64c5/crashtest.cpp/buggy/drkonqi/crashtest.cpp
crashtype = Div0;
crashtype = Div0;
int main(int argc, char *argv[]){ KAboutData aboutData("crashtext", "Crash Test for DrKonqi", "1.1", "Crash Test for DrKonqi", KAboutData::License_GPL, "(c) 2000-2002 David Faure, Waldo Bastian"); KCmdLineArgs::init(argc, argv, &aboutData); KCmdLineArgs::addCmdLineOptions(options); KApplication app(false,false); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); QCString type = args->arg(0); int crashtype = Crash; if (type == "malloc") crashtype = Malloc; else if (type == "div0") crashtype = Div0; else if (type == "assert") crashtype = Assert; level1(crashtype); return app.exec();}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/da930ed6a3bdf1bf8a5ed02103cadc8f923d64c5/crashtest.cpp/buggy/drkonqi/crashtest.cpp
crashtype = Assert;
crashtype = Assert;
int main(int argc, char *argv[]){ KAboutData aboutData("crashtext", "Crash Test for DrKonqi", "1.1", "Crash Test for DrKonqi", KAboutData::License_GPL, "(c) 2000-2002 David Faure, Waldo Bastian"); KCmdLineArgs::init(argc, argv, &aboutData); KCmdLineArgs::addCmdLineOptions(options); KApplication app(false,false); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); QCString type = args->arg(0); int crashtype = Crash; if (type == "malloc") crashtype = Malloc; else if (type == "div0") crashtype = Div0; else if (type == "assert") crashtype = Assert; level1(crashtype); return app.exec();}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/da930ed6a3bdf1bf8a5ed02103cadc8f923d64c5/crashtest.cpp/buggy/drkonqi/crashtest.cpp
if (app.startServiceByDesktopName("konqueror", "--silent", dcopService, error))
if (app.startServiceByDesktopName("konqueror", QString::fromLatin1("--silent"), &error))
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); exit(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", "--silent", dcopService, error)) { warning("Could not launch browser:\n%s\n", error.local8Bit().data()); return 1; } app.exec();}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/8f9a1a02698faeed8ec0ccfb3ad61c8376f2e03c/khc_main.cc/buggy/khelpcenter/khc_main.cc
KDEsuDialog *dlg = new KDEsuDialog(user, auth_user, keep && !terminal); dlg->addLine(i18n("Command:"), command);
KStartupInfoId id; id.initId( app->startupId()); KStartupInfoData data; data.setSuspend( KStartupInfoData::Yes ); KStartupInfo::sendChange( id, data ); KDEsuDialog dlg(user, auth_user, keep && !terminal); dlg.addLine(i18n("Command:"), command);
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; // 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; 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) { KDEsuDialog *dlg = new KDEsuDialog(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) exit(0); if (ret == KDEsuDialog::AsUser) change_uid = false; password = dlg->password(); keep = dlg->keep(); delete dlg; } // 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); }}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/89a62e4f821365c0007edac03f43d5c7edabb7a0/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp
dlg->addLine(i18n("Priority:"), prio); } int ret = dlg->exec();
dlg.addLine(i18n("Priority:"), prio); } int ret = dlg.exec();
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; // 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; 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) { KDEsuDialog *dlg = new KDEsuDialog(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) exit(0); if (ret == KDEsuDialog::AsUser) change_uid = false; password = dlg->password(); keep = dlg->keep(); delete dlg; } // 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); }}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/89a62e4f821365c0007edac03f43d5c7edabb7a0/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp
password = dlg->password(); keep = dlg->keep(); delete dlg;
password = dlg.password(); keep = dlg.keep(); data.setSuspend( KStartupInfoData::No ); KStartupInfo::sendChange( id, data );
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; // 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; 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) { KDEsuDialog *dlg = new KDEsuDialog(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) exit(0); if (ret == KDEsuDialog::AsUser) change_uid = false; password = dlg->password(); keep = dlg->keep(); delete dlg; } // 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); }}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/89a62e4f821365c0007edac03f43d5c7edabb7a0/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp
proc.setEnvironment(env); }
} proc.setEnvironment(env);
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; // 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; 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) { KDEsuDialog *dlg = new KDEsuDialog(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) exit(0); if (ret == KDEsuDialog::AsUser) change_uid = false; password = dlg->password(); keep = dlg->keep(); delete dlg; } // 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); }}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/89a62e4f821365c0007edac03f43d5c7edabb7a0/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp
HelpCenterCom *helpcentercom = new HelpCenterCom;
HelpCenterCom *helpcentercom; helpcentercom = new HelpCenterCom;
int main(int argc, char *argv[]){ // error handler for man stuff Error.SetHandler( (void (*)(int, const char *))errorHandler ); // create local data directory if necessary QDir dir; dir.setPath(KApplication::localkdedir() + "/share/apps"); if (!dir.exists()) dir.mkdir(KApplication::localkdedir() + "/share/apps"); dir.setPath(KApplication::localkdedir() + "/share/apps/khelpcenter"); if (!dir.exists()) dir.mkdir(KApplication::localkdedir() + "/share/apps/khelpcenter"); // init app KOMApplication app(argc, argv, "khelpcenter.bin"); HelpCenterCom *helpcentercom = new HelpCenterCom; app.boa()->impl_is_ready(CORBA::ImplementationDef::_nil()); kdebug(KDEBUG_INFO,1401,"KOM interface ready: IDL:KHelpCenter/HelpCenterCom:1.0"); app.exec(); return 0;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/ab8e4aefcf69f4350992d925d273d3f1d51622b1/main.cpp/buggy/khelpcenter/helpcenter/main.cpp
aboutData->addAuthor("Daniel Molkentin", I18N_NOOP("Current Maintainer"), "[email protected]");
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]");
int main(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-2002, 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-2002, The KDE Control Center Developers")); QCString argv_0 = argv[0]; KAboutData *aboutData; if (argv_0.right(11) == "kinfocenter") { aboutData = &aboutKInfoCenter; KCGlobal::setIsInfoCenter(true); } else { aboutData = &aboutKControl; KCGlobal::setIsInfoCenter(false); } 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();}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/7640f7a942ebacd1e64c87ccf55ea633755f4772/main.cpp/clean/kcontrol/kcontrol/main.cpp
KGlobal::locale()->setLanguage(args->getOption("lang"));
int main(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-2001, 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]"); 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" ); if (args->isSet("list")) { QStringList files; KGlobal::dirs()->findAllResources("apps", KCGlobal::baseGroup() + "*.desktop", true, true, files); QStringList modules; QStringList descriptions; uint maxwidth = 0; for (QStringList::ConstIterator it = files.begin(); it != files.end(); it++) { if (KDesktopFile::isDesktopFile(*it)) { KDesktopFile file(*it, true); if (file.readEntry("Hidden") == "true") continue; QString module = *it; if (module.startsWith(KCGlobal::baseGroup())) module = module.mid(KCGlobal::baseGroup().length()); if (module.right(8) == ".desktop") module.truncate(module.length() - 8); modules.append(module); if (module.length() > maxwidth) maxwidth = module.length(); descriptions.append(QString("%2 (%3)").arg(file.readName()).arg(file.readComment())); } } QByteArray vl; vl.fill(' ', 80); QString verylong = vl; for (uint i = 0; i < modules.count(); i++) { fprintf(stdout, "%s%s - %s\n", (*modules.at(i)).local8Bit().data(), verylong.left(maxwidth - (*modules.at(i)).length()).local8Bit().data(), (*descriptions.at(i)).local8Bit().data()); }#if defined(QT_THREAD_SUPPORT) app.unlock();#endif 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; } QString path = locateModule(args->arg(0)); if (path.isEmpty()) {#if defined(QT_THREAD_SUPPORT) app.unlock();#endif return 0; } // load the module ModuleInfo info(path); KCModule *module = ModuleLoader::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 ); dlg->setCaption(info.name()); // 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.name(), "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(); } ModuleLoader::unloadModule(info); return 0; } KMessageBox::detailedError(0, i18n("There was an error loading the module."),i18n("<qt><p>The diagnostics is:<br>%1" "<p>Possible reasons:</p><ul><li>An error occurred during your last " "KDE upgrade leaving an orphaned control module<li>You have old third party " "modules lying around.</ul><p>Check these points carefully and try to remove " "the module mentioned in the error message. If this fails, consider contacting " "your distributor or packager.</p></qt>") .arg(KLibLoader::self()->lastErrorMessage())); return 0; } // multiple control modules QStringList modules; for (int i = 0; i < args->count(); i++) { QString path = locateModule(args->arg(i)); if(!path.isEmpty()) modules.append(path); } if (modules.count() < 1) return -1; // create the dialog KExtendedCDialog * dlg = new KExtendedCDialog(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 (QStringList::ConstIterator it = modules.begin(); it != modules.end(); ++it) dlg->addModule(*it, false); // 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; } } // run the dialog dlg->exec(); delete dlg; return 0;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/8af10cb6a2636985ff3d63f64fd291850c0ef286/kcmshell.cpp/buggy/kcontrol/kcontrol/kcmshell.cpp
debug( "kio_http : Starting");
int main( int argc, char **argv ){ signal(SIGCHLD, sigchld_handler); signal(SIGSEGV, sigsegv_handler); debug( "kio_http : Starting"); Connection parent( 0, 1 ); HTTPProtocol http( &parent ); http.dispatchLoop(); debug( "kio_http : Done" );}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/c6007327ffc73edc2cfab5b19436db706542cba4/http.cc/clean/kioslave/http/http.cc
debug( "kio_http : Done" );
int main( int argc, char **argv ){ signal(SIGCHLD, sigchld_handler); signal(SIGSEGV, sigsegv_handler); debug( "kio_http : Starting"); Connection parent( 0, 1 ); HTTPProtocol http( &parent ); http.dispatchLoop(); debug( "kio_http : Done" );}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/c6007327ffc73edc2cfab5b19436db706542cba4/http.cc/clean/kioslave/http/http.cc
HELPCENTER_VERSION, description, KAboutData::GPL,
HELPCENTER_VERSION, description, KAboutData::License_GPL,
int main(int argc, char *argv[]){ KAboutData aboutData( "khelpcenter", I18N_NOOP("KDE HelpCenter"), HELPCENTER_VERSION, description, KAboutData::GPL, "(c) 1999-2000, Matthias Elter"); aboutData.addAuthor("Matthias Elter",0, "[email protected]"); KCmdLineArgs::init( argc, argv, &aboutData );// KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. KApplication app( false, false ); // no GUI in this process app.dcopClient()->attach(); // we want to get applicationRegistered app.dcopClient()->setNotifications( true ); Listener listener; QObject::connect( app.dcopClient(), SIGNAL( applicationRegistered( const QCString& ) ), &listener, SLOT( slotAppRegistered( const QCString & ) ) ); system( "konqueror --silent &" ); app.exec();}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/7e47a70e095a598a0da02a337f678c7238ad2b30/khc_main.cc/buggy/khelpcenter/khc_main.cc
KCDialog dlg(module, info.docPath(), 0, 0, true);
KCDialog dlg(module, module->buttons(), info.docPath(), 0, 0, true);
int main(int _argc, char *_argv[]){ KCmdLineArgs::init( _argc, _argv, "kcmshell", I18N_NOOP("A tool to start single kcontrol modules"), "2.0pre" ); KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. KLocale::setMainCatalogue("kcontrol"); KApplication app; // It has to be unset, if not it will break modules like kcmlocale KLocale::setMainCatalogue(0); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); if (args->isSet("list")) { QStringList files; KGlobal::dirs()->findAllResources("apps", "Settings/*.desktop", true, true, files); QStringList modules; QStringList descriptions; uint maxwidth = 0; for (QStringList::ConstIterator it = files.begin(); it != files.end(); it++) { if (KDesktopFile::isDesktopFile(*it)) { KDesktopFile file(*it, true); QString module = *it; if (module.left(9) == "Settings/") module = module.mid(9); if (module.right(8) == ".desktop") module.truncate(module.length() - 8); modules.append(module); if (module.length() > maxwidth) maxwidth = module.length(); descriptions.append(QString("%2 (%3)").arg(file.readName()).arg(file.readComment())); } } QByteArray vl; vl.fill(' ', 80); QString verylong = vl; for (uint i = 0; i < modules.count(); i++) { cout << (*modules.at(i)).latin1(); cout << verylong.left(maxwidth - (*modules.at(i)).length()); cout << " - "; cout << (*descriptions.at(i)).local8Bit(); cout << endl; } return 0; } if (args->count() != 1) { args->usage(); return -1; } // locate the desktop file QStringList files; if (args->arg(0)[0] == '/') files.append(args->arg(0)); else files = KGlobal::dirs()-> findAllResources("apps", QString("Settings/%1.desktop").arg(args->arg(0)), true); // check the matches if (files.count() > 1) cerr << i18n("Module name not unique. Taking the first match.") << endl; if (files.count() <= 0) { cerr << i18n("Module %1 not found!").arg(args->arg(0)) << endl; return -1; } args->clear(); // load the module ModuleInfo info(files[0]); KCModule *module = ModuleLoader::module(info); if (module) { // create the dialog KCDialog dlg(module, info.docPath(), 0, 0, true); dlg.setCaption(info.name()); // Needed for modules that use d'n'd (not really the right // solution for this though, I guess) dlg.setAcceptDrops(true); // run the dialog return dlg.exec(); } return 0;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/a7c7876ab8c360ad35ee03030d66dcdf25aa2943/kcmshell.cpp/clean/kcontrol/kcontrol/kcmshell.cpp
int pid = getpid();
int main(int oargc, char **oargv) { //cerr << "fakesyn starting" << 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]; list<int> syn_modes; list<int> syn_iargs; list<string> syn_sargs; int mkfs = 0; for (int i=1; i<argc; i++) { cout << "asdf" << endl; 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],"--syn") == 0) { ++i; if (strcmp(argv[i],"writefile") == 0) { syn_modes.push_back( SYNCLIENT_MODE_WRITEFILE ); syn_iargs.push_back( atoi(argv[++i]) ); syn_iargs.push_back( atoi(argv[++i]) ); } else if (strcmp(argv[i],"readfile") == 0) { syn_modes.push_back( SYNCLIENT_MODE_READFILE ); syn_iargs.push_back( atoi(argv[++i]) ); syn_iargs.push_back( atoi(argv[++i]) ); } else if (strcmp(argv[i],"makedirs") == 0) { syn_modes.push_back( SYNCLIENT_MODE_MAKEDIRS ); syn_iargs.push_back( atoi(argv[++i]) ); syn_iargs.push_back( atoi(argv[++i]) ); syn_iargs.push_back( atoi(argv[++i]) ); } else if (strcmp(argv[i],"fullwalk") == 0) { syn_modes.push_back( SYNCLIENT_MODE_FULLWALK ); //syn_sargs.push_back( atoi(argv[++i]) ); } else if (strcmp(argv[i],"randomwalk") == 0) { syn_modes.push_back( SYNCLIENT_MODE_RANDOMWALK ); syn_iargs.push_back( atoi(argv[++i]) ); } else if (strcmp(argv[i],"trace_include") == 0) { syn_modes.push_back( SYNCLIENT_MODE_TRACEINCLUDE ); syn_iargs.push_back( atoi(argv[++i]) ); } else if (strcmp(argv[i],"trace_lib") == 0) { syn_modes.push_back( SYNCLIENT_MODE_TRACELIB ); syn_iargs.push_back( atoi(argv[++i]) ); } else if (strcmp(argv[i],"trace_openssh") == 0) { syn_modes.push_back( SYNCLIENT_MODE_TRACEOPENSSH ); syn_iargs.push_back( atoi(argv[++i]) ); } else if (strcmp(argv[i],"trace_opensshlib") == 0) { syn_modes.push_back( SYNCLIENT_MODE_TRACEOPENSSHLIB ); syn_iargs.push_back( atoi(argv[++i]) ); } else if (strcmp(argv[i],"trace") == 0) { syn_modes.push_back( SYNCLIENT_MODE_TRACE ); syn_sargs.push_back( argv[++i] ); syn_iargs.push_back( atoi(argv[++i]) ); } else if (strcmp(argv[i],"until") == 0) { syn_modes.push_back( SYNCLIENT_MODE_UNTIL ); syn_iargs.push_back( atoi(argv[++i]) ); } else { cerr << "unknown syn mode " << argv[i] << endl; return -1; } } else { // unknown arg, pass it on. nargv[nargc++] = argv[i]; } } 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++) { //cerr << "mds" << i << " on rank " << myrank << " " << hostname << "." << pid << endl; mds[i] = new MDS(mdc, i, new FakeMessenger(MSG_ADDR_MDS(i))); start++; } // create osd OSD *osd[NUMOSD]; for (int i=0; i<NUMOSD; i++) { //cerr << "osd" << i << " on rank " << myrank << " " << hostname << "." << pid << endl; osd[i] = new OSD(i, new FakeMessenger(MSG_ADDR_OSD(i))); start++; } // create client Client *client[NUMCLIENT]; SyntheticClient *syn[NUMCLIENT]; for (int i=0; i<NUMCLIENT; i++) { //cerr << "client" << i << " on rank " << myrank << " " << hostname << "." << pid << endl; client[i] = new Client(mdc, i, new FakeMessenger(MSG_ADDR_CLIENT(i))); start++; } // start message loop fakemessenger_startthread(); // init for (int i=0; i<NUMMDS; i++) { mds[i]->init(); } for (int i=0; i<NUMOSD; i++) { osd[i]->init(); } // create client for (int i=0; i<NUMCLIENT; i++) { 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 " << endl; syn[i] = new SyntheticClient(client[i]); syn[i]->modes = syn_modes; syn[i]->sargs = syn_sargs; syn[i]->iargs = syn_iargs; syn[i]->start_thread(); } for (int i=0; i<NUMCLIENT; i++) { cout << "waiting for synthetic client " << i << " to finish" << endl; syn[i]->join_thread(); delete syn[i]; client[i]->unmount(); //cout << "unmounted" << endl; client[i]->shutdown(); } // wait for it to finish fakemessenger_wait(); // cleanup for (int i=0; i<NUMMDS; i++) { delete mds[i]; } for (int i=0; i<NUMOSD; i++) { delete osd[i]; } for (int i=0; i<NUMCLIENT; i++) { delete client[i]; } delete mdc; free(argv); delete[] nargv; cout << "fakesyn done" << endl; return 0;}
2690 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2690/8c7283a709cbd1031e4adc5c129a44d81b7a0f8d/fakesyn.cc/clean/ceph/fakesyn.cc
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; break; default: std::cerr << argv[0] << ": getopt returned character code " << optionChar << "\n"; return 1; } } #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++]); } }
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; break; default: std::cerr << argv[0] << ": getopt returned character code " << optionChar << "\n"; return 1; } } #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++]); } }
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 because you have no DISPLAY environment variable set." << std::endl; } QApplication a(argc, argv, myUseGuiFlag ); // 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); ///////////////////////////////////////////////////////////////////// // 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; // 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();}
1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/28381cebf7f4deced30b78727b0b3fe14d88d928/main.cpp/clean/src/main.cpp
qDebug( "kio_smb : main 3");
int main( int argc, char **argv ){ signal(SIGCHLD, sigchld_handler); signal(SIGSEGV, sigsegv_handler); qDebug( "kio_smb : Starting"); QtApp = new QApplication( argc, argv ); Connection parent( 0, 1 ); SmbProtocol smb( &parent ); smb.dispatchLoop(); qDebug( "kio_smb : Done" );}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/d22621f8ccc13bd6e7ea0fd15e00c4df221296b7/kio_smb.cc/clean/kioslave/smb/kio_smb.cc
"\n If you do not specify a regular expression for the windows title,"
"\n If you do not specify a regular expression for the windows title,"
int main( int argc, char *argv[] ){ if (argc <= 2) { printf(KSTART_VERSION); 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]); ::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(i18n("\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();}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/f3704c0a54d556fc18c3ab7bfff86c7aa41c2e6d/kstart.C/buggy/kstart/kstart.C
int main( int argc, char *argv[] ){ if (argc <= 2) { printf(KSTART_VERSION); 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]); ::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(i18n("\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();}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/f3704c0a54d556fc18c3ab7bfff86c7aa41c2e6d/kstart.C/buggy/kstart/kstart.C
int main( int argc, char *argv[] ){ if (argc <= 2) { printf(KSTART_VERSION); 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]); ::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(i18n("\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();}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/f3704c0a54d556fc18c3ab7bfff86c7aa41c2e6d/kstart.C/buggy/kstart/kstart.C
QCoreApplication::setOrganizationName("QuantumGIS"); QCoreApplication::setOrganizationDomain("qgis.org"); QCoreApplication::setApplicationName("qgis");
int main(int argc, char *argv[]){ // Set up the custom qWarning/qDebug custom handler qInstallMsgHandler( myMessageOutput ); ///////////////////////////////////////////////////////////////// // 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 set initial extent of map canvas QString myInitialExtent=""; // This behaviour will allow you to force the use of a translation file // which is useful for testing QString myTranslationCode="";#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'}, {"extent", required_argument, 0, 'e'}, {0, 0, 0, 0} }; /* getopt_long stores the option index here. */ int option_index = 0; optionChar = getopt_long (argc, argv, "slpe", 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 = QDir::convertSeparators(QFileInfo(QFile::decodeName(optarg)).absFilePath()); break; case 'l': myTranslationCode = optarg; break; case 'p': myProjectFileName = QDir::convertSeparators(QFileInfo(QFile::decodeName(optarg)).absFilePath()); break; case 'e': myInitialExtent = 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(QDir::convertSeparators(QFileInfo(QFile::decodeName(argv[optind++])).absFilePath())); } } }#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 );#ifdef Q_OS_MACX // Install OpenDocuments AppleEvent handler after application object is initialized // but before any other event handling (including dialogs or splash screens) occurs. // If an OpenDocuments event has been created before the application was launched, // it must be handled before some other event handler runs and dismisses it as unknown. // If run at startup, the handler will set either or both of myProjectFileName and myFileList. AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, openDocumentsAEHandler, 0, false);#endif // 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 QString i18nPath = QString(PKGDATAPATH) + "/i18n"; if (myTranslationCode.isEmpty()) { myTranslationCode = QTextCodec::locale(); }#ifdef QGISDEBUG std::cout << "Setting translation to " << i18nPath.toLocal8Bit().data() << "/qgis_" << myTranslationCode.toLocal8Bit().data() << std::endl;#endif /* Translation file for Qt. * The strings from the QMenuBar context section are used by Qt/Mac to shift * the About, Preferences and Quit items to the Mac Application menu. * These items must be translated identically in both qt_ and qgis_ files. */ QTranslator qttor(0); if (qttor.load(QString("qt_") + myTranslationCode, i18nPath)) { a.installTranslator(&qttor); } /* Translation file for QGIS. */ QTranslator qgistor(0); if (qgistor.load(QString("qgis_") + myTranslationCode, i18nPath)) { a.installTranslator(&qgistor); } /* 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 = QDir::convertSeparators(QFileInfo(QFile::decodeName(argv[i])).absFilePath()); if(arg.contains(".qgs")) { myProjectFileName = arg; break; } } } ///////////////////////////////////////////////////////////////////// // Load a project file if one was specified ///////////////////////////////////////////////////////////////////// if( ! myProjectFileName.isEmpty() ) { qgis->openProject(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).toLocal8Bit().data() << std::endl;#endif QString myLayerName = *myIterator; // don't load anything with a .qgs extension - these are project files if(!myLayerName.contains(".qgs")) { qgis->openLayer(myLayerName); } } ///////////////////////////////////////////////////////////////////// // Set initial extent if requested ///////////////////////////////////////////////////////////////////// if ( ! myInitialExtent.isEmpty() ) { double coords[4]; int pos, posOld = 0; bool ok; // XXX is it necessary to switch to "C" locale? // parse values from string // extent is defined by string "xmin,ymin,xmax,ymax" for (int i = 0; i < 3; i++) { // find comma and get coordinate 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; } // parse last coordinate if (ok) coords[3] = QString( myInitialExtent.mid(posOld) ).toDouble(&ok); if (!ok) std::cout << "Error while parsing initial extent!" << std::endl; else { // set extent from parsed values QgsRect rect(coords[0],coords[1],coords[2],coords[3]); qgis->setExtent(rect); } } ///////////////////////////////////////////////////////////////////// // 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();}
1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/a4ac1363b1941a122c8668589e79b1ce1ac29b35/main.cpp/clean/src/main.cpp
int i; QString url, initDoc; for (i = 1; i < argc; i++) { if ( argv[i][0] == '-' ) { if ( strcasecmp( argv[i], "-caption" ) == 0 ) i++; if ( strcasecmp( argv[i], "-icon" ) == 0 ) i++; if ( strcasecmp( argv[i], "-miniicon" ) == 0 ) i++; continue; } initDoc = argv[i]; } if ( initDoc.isEmpty() ) { initDoc = "file:"; initDoc += kapp->kde_htmldir().copy(); initDoc += "/default/khelpcenter/main.html"; } url = initDoc; if ( !strchr( url, ':' ) ) { if ( initDoc[0] == '.' || initDoc[0] != '/' ) { QFileInfo fi( initDoc ); initDoc = fi.absFilePath(); } url = "file:"; url += initDoc; }
int main(int argc, char *argv[]){ int i; QString url, initDoc; // pase command line parameters for (i = 1; i < argc; i++) { if ( argv[i][0] == '-' ) { // skip -caption, -icon, -miniicon if ( strcasecmp( argv[i], "-caption" ) == 0 ) i++; if ( strcasecmp( argv[i], "-icon" ) == 0 ) i++; if ( strcasecmp( argv[i], "-miniicon" ) == 0 ) i++; continue; } initDoc = argv[i]; } if ( initDoc.isEmpty() ) // no url parameter...use main.html { initDoc = "file:"; initDoc += kapp->kde_htmldir().copy(); initDoc += "/default/khelpcenter/main.html"; } url = initDoc; if ( !strchr( url, ':' ) ) { if ( initDoc[0] == '.' || initDoc[0] != '/' ) { QFileInfo fi( initDoc ); initDoc = fi.absFilePath(); } url = "file:"; url += initDoc; } // error handler for info and man stuff Error.SetHandler( (void (*)(int, const char *))errorHandler ); // create local data directory if necessary QDir dir; dir.setPath(KApplication::localkdedir() + "/share/apps"); if (!dir.exists()) dir.mkdir(KApplication::localkdedir() + "/share/apps"); dir.setPath(KApplication::localkdedir() + "/share/apps/khelpcenter"); if (!dir.exists()) dir.mkdir(KApplication::localkdedir() + "/share/apps/khelpcenter"); // init app KApplication app(argc, argv, "khelpcenter"); HelpCenter *toplevel; if (app.isRestored()) { int n = 1; while ( KTMainWindow::canBeRestored( n ) ) { toplevel = new HelpCenter; toplevel->restore( n ); n++; } return app.exec(); } else { toplevel = new HelpCenter; app.setMainWidget(toplevel); app.setTopWidget(toplevel); toplevel->openURL(url); toplevel->show(); return app.exec(); }}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/716cf70cac3840287c8862462c9bcd9cf51ad2cf/main.cpp/buggy/khelpcenter/helpcenter/main.cpp
KApplication app(argc, argv, "khelpcenter");
KOMApplication app(argc, argv, "khelpcenter.bin");
int main(int argc, char *argv[]){ int i; QString url, initDoc; // pase command line parameters for (i = 1; i < argc; i++) { if ( argv[i][0] == '-' ) { // skip -caption, -icon, -miniicon if ( strcasecmp( argv[i], "-caption" ) == 0 ) i++; if ( strcasecmp( argv[i], "-icon" ) == 0 ) i++; if ( strcasecmp( argv[i], "-miniicon" ) == 0 ) i++; continue; } initDoc = argv[i]; } if ( initDoc.isEmpty() ) // no url parameter...use main.html { initDoc = "file:"; initDoc += kapp->kde_htmldir().copy(); initDoc += "/default/khelpcenter/main.html"; } url = initDoc; if ( !strchr( url, ':' ) ) { if ( initDoc[0] == '.' || initDoc[0] != '/' ) { QFileInfo fi( initDoc ); initDoc = fi.absFilePath(); } url = "file:"; url += initDoc; } // error handler for info and man stuff Error.SetHandler( (void (*)(int, const char *))errorHandler ); // create local data directory if necessary QDir dir; dir.setPath(KApplication::localkdedir() + "/share/apps"); if (!dir.exists()) dir.mkdir(KApplication::localkdedir() + "/share/apps"); dir.setPath(KApplication::localkdedir() + "/share/apps/khelpcenter"); if (!dir.exists()) dir.mkdir(KApplication::localkdedir() + "/share/apps/khelpcenter"); // init app KApplication app(argc, argv, "khelpcenter"); HelpCenter *toplevel; if (app.isRestored()) { int n = 1; while ( KTMainWindow::canBeRestored( n ) ) { toplevel = new HelpCenter; toplevel->restore( n ); n++; } return app.exec(); } else { toplevel = new HelpCenter; app.setMainWidget(toplevel); app.setTopWidget(toplevel); toplevel->openURL(url); toplevel->show(); return app.exec(); }}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/716cf70cac3840287c8862462c9bcd9cf51ad2cf/main.cpp/buggy/khelpcenter/helpcenter/main.cpp
HelpCenter *toplevel;
int main(int argc, char *argv[]){ int i; QString url, initDoc; // pase command line parameters for (i = 1; i < argc; i++) { if ( argv[i][0] == '-' ) { // skip -caption, -icon, -miniicon if ( strcasecmp( argv[i], "-caption" ) == 0 ) i++; if ( strcasecmp( argv[i], "-icon" ) == 0 ) i++; if ( strcasecmp( argv[i], "-miniicon" ) == 0 ) i++; continue; } initDoc = argv[i]; } if ( initDoc.isEmpty() ) // no url parameter...use main.html { initDoc = "file:"; initDoc += kapp->kde_htmldir().copy(); initDoc += "/default/khelpcenter/main.html"; } url = initDoc; if ( !strchr( url, ':' ) ) { if ( initDoc[0] == '.' || initDoc[0] != '/' ) { QFileInfo fi( initDoc ); initDoc = fi.absFilePath(); } url = "file:"; url += initDoc; } // error handler for info and man stuff Error.SetHandler( (void (*)(int, const char *))errorHandler ); // create local data directory if necessary QDir dir; dir.setPath(KApplication::localkdedir() + "/share/apps"); if (!dir.exists()) dir.mkdir(KApplication::localkdedir() + "/share/apps"); dir.setPath(KApplication::localkdedir() + "/share/apps/khelpcenter"); if (!dir.exists()) dir.mkdir(KApplication::localkdedir() + "/share/apps/khelpcenter"); // init app KApplication app(argc, argv, "khelpcenter"); HelpCenter *toplevel; if (app.isRestored()) { int n = 1; while ( KTMainWindow::canBeRestored( n ) ) { toplevel = new HelpCenter; toplevel->restore( n ); n++; } return app.exec(); } else { toplevel = new HelpCenter; app.setMainWidget(toplevel); app.setTopWidget(toplevel); toplevel->openURL(url); toplevel->show(); return app.exec(); }}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/716cf70cac3840287c8862462c9bcd9cf51ad2cf/main.cpp/buggy/khelpcenter/helpcenter/main.cpp
if (app.isRestored()) { int n = 1; while ( KTMainWindow::canBeRestored( n ) ) { toplevel = new HelpCenter; toplevel->restore( n ); n++; } return app.exec(); } else { toplevel = new HelpCenter;
HelpCenterCom *helpcentercom = new HelpCenterCom(); app.boa()->impl_is_ready( CORBA::ImplementationDef::_nil() );
int main(int argc, char *argv[]){ int i; QString url, initDoc; // pase command line parameters for (i = 1; i < argc; i++) { if ( argv[i][0] == '-' ) { // skip -caption, -icon, -miniicon if ( strcasecmp( argv[i], "-caption" ) == 0 ) i++; if ( strcasecmp( argv[i], "-icon" ) == 0 ) i++; if ( strcasecmp( argv[i], "-miniicon" ) == 0 ) i++; continue; } initDoc = argv[i]; } if ( initDoc.isEmpty() ) // no url parameter...use main.html { initDoc = "file:"; initDoc += kapp->kde_htmldir().copy(); initDoc += "/default/khelpcenter/main.html"; } url = initDoc; if ( !strchr( url, ':' ) ) { if ( initDoc[0] == '.' || initDoc[0] != '/' ) { QFileInfo fi( initDoc ); initDoc = fi.absFilePath(); } url = "file:"; url += initDoc; } // error handler for info and man stuff Error.SetHandler( (void (*)(int, const char *))errorHandler ); // create local data directory if necessary QDir dir; dir.setPath(KApplication::localkdedir() + "/share/apps"); if (!dir.exists()) dir.mkdir(KApplication::localkdedir() + "/share/apps"); dir.setPath(KApplication::localkdedir() + "/share/apps/khelpcenter"); if (!dir.exists()) dir.mkdir(KApplication::localkdedir() + "/share/apps/khelpcenter"); // init app KApplication app(argc, argv, "khelpcenter"); HelpCenter *toplevel; if (app.isRestored()) { int n = 1; while ( KTMainWindow::canBeRestored( n ) ) { toplevel = new HelpCenter; toplevel->restore( n ); n++; } return app.exec(); } else { toplevel = new HelpCenter; app.setMainWidget(toplevel); app.setTopWidget(toplevel); toplevel->openURL(url); toplevel->show(); return app.exec(); }}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/716cf70cac3840287c8862462c9bcd9cf51ad2cf/main.cpp/buggy/khelpcenter/helpcenter/main.cpp
app.setMainWidget(toplevel); app.setTopWidget(toplevel); toplevel->openURL(url); toplevel->show(); return app.exec(); }
app.exec(); return 0;
int main(int argc, char *argv[]){ int i; QString url, initDoc; // pase command line parameters for (i = 1; i < argc; i++) { if ( argv[i][0] == '-' ) { // skip -caption, -icon, -miniicon if ( strcasecmp( argv[i], "-caption" ) == 0 ) i++; if ( strcasecmp( argv[i], "-icon" ) == 0 ) i++; if ( strcasecmp( argv[i], "-miniicon" ) == 0 ) i++; continue; } initDoc = argv[i]; } if ( initDoc.isEmpty() ) // no url parameter...use main.html { initDoc = "file:"; initDoc += kapp->kde_htmldir().copy(); initDoc += "/default/khelpcenter/main.html"; } url = initDoc; if ( !strchr( url, ':' ) ) { if ( initDoc[0] == '.' || initDoc[0] != '/' ) { QFileInfo fi( initDoc ); initDoc = fi.absFilePath(); } url = "file:"; url += initDoc; } // error handler for info and man stuff Error.SetHandler( (void (*)(int, const char *))errorHandler ); // create local data directory if necessary QDir dir; dir.setPath(KApplication::localkdedir() + "/share/apps"); if (!dir.exists()) dir.mkdir(KApplication::localkdedir() + "/share/apps"); dir.setPath(KApplication::localkdedir() + "/share/apps/khelpcenter"); if (!dir.exists()) dir.mkdir(KApplication::localkdedir() + "/share/apps/khelpcenter"); // init app KApplication app(argc, argv, "khelpcenter"); HelpCenter *toplevel; if (app.isRestored()) { int n = 1; while ( KTMainWindow::canBeRestored( n ) ) { toplevel = new HelpCenter; toplevel->restore( n ); n++; } return app.exec(); } else { toplevel = new HelpCenter; app.setMainWidget(toplevel); app.setTopWidget(toplevel); toplevel->openURL(url); toplevel->show(); return app.exec(); }}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/716cf70cac3840287c8862462c9bcd9cf51ad2cf/main.cpp/buggy/khelpcenter/helpcenter/main.cpp
KOMApplication app( argc, argv, "khelpcenterd.bin");
KOMApplication app(argc, argv, "KDE HelpCenter");
int main(int argc, char *argv[]){ // create local data directory if necessary QDir dir; dir.setPath(KApplication::localkdedir() + "/share/apps"); if (!dir.exists()) dir.mkdir(KApplication::localkdedir() + "/share/apps"); dir.setPath(KApplication::localkdedir() + "/share/apps/khelpcenter"); if (!dir.exists()) dir.mkdir(KApplication::localkdedir() + "/share/apps/khelpcenter"); // init app KOMApplication app( argc, argv, "khelpcenterd.bin"); KOMAutoLoader<HelpWindowFactory_Impl> HelpWindowFactoryLoader("IDL:KHelpCenter/HelpWindowFactory:1.0" , "KHelpCenter"); app.exec(); return 0;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/c588d99991a8254ece04971ea0a66c6da5ed516e/main.cpp/clean/khelpcenter/main.cpp
QDir dir; dir.setPath(KApplication::localkdedir() + "/share/apps"); if (!dir.exists()) dir.mkdir(KApplication::localkdedir() + "/share/apps"); dir.setPath(KApplication::localkdedir() + "/share/apps/khelpcenter"); if (!dir.exists()) dir.mkdir(KApplication::localkdedir() + "/share/apps/khelpcenter");
KGlobal::dirs()->addResourceType("plugins", KStandardDirs::kde_default("data") + "khelpcenter/plugins");
int main(int argc, char *argv[]){ bool standalone = false; HelpCenter *hc; // create local data directory if necessary QDir dir; dir.setPath(KApplication::localkdedir() + "/share/apps"); if (!dir.exists()) dir.mkdir(KApplication::localkdedir() + "/share/apps"); dir.setPath(KApplication::localkdedir() + "/share/apps/khelpcenter"); if (!dir.exists()) dir.mkdir(KApplication::localkdedir() + "/share/apps/khelpcenter"); for (int i=0; i< argc; i++) { if (strcmp(argv[i], "--standalone") == 0) standalone = true; } if (standalone) { KApplication app(argc, argv, "KDE HelpCenter"); hc = new HelpCenter; QString _url = "file:"; _url += kapp->kde_htmldir().copy(); _url += "/default/khelpcenter/main.html"; hc->show(); hc->openURL(_url, true); int rv = app.exec(); if (hc) delete hc; return rv; } else { // init KOM server app KOMApplication app(argc, argv, "KDE HelpCenter"); KOMAutoLoader<HelpWindowFactory_Impl> HelpWindowFactoryLoader("IDL:KHelpCenter/HelpWindowFactory:1.0" , "KHelpCenter"); app.exec(); return 0; } }
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/2b23347a449e2ded31b5fa8ea20e5536f8edc7ee/main.cpp/buggy/khelpcenter/main.cpp
QString _url = "file:"; _url += kapp->kde_htmldir().copy(); _url += "/default/khelpcenter/main.html";
QString _url = "file:" + locate("html", "default/khelpcenter/main.html");
int main(int argc, char *argv[]){ bool standalone = false; HelpCenter *hc; // create local data directory if necessary QDir dir; dir.setPath(KApplication::localkdedir() + "/share/apps"); if (!dir.exists()) dir.mkdir(KApplication::localkdedir() + "/share/apps"); dir.setPath(KApplication::localkdedir() + "/share/apps/khelpcenter"); if (!dir.exists()) dir.mkdir(KApplication::localkdedir() + "/share/apps/khelpcenter"); for (int i=0; i< argc; i++) { if (strcmp(argv[i], "--standalone") == 0) standalone = true; } if (standalone) { KApplication app(argc, argv, "KDE HelpCenter"); hc = new HelpCenter; QString _url = "file:"; _url += kapp->kde_htmldir().copy(); _url += "/default/khelpcenter/main.html"; hc->show(); hc->openURL(_url, true); int rv = app.exec(); if (hc) delete hc; return rv; } else { // init KOM server app KOMApplication app(argc, argv, "KDE HelpCenter"); KOMAutoLoader<HelpWindowFactory_Impl> HelpWindowFactoryLoader("IDL:KHelpCenter/HelpWindowFactory:1.0" , "KHelpCenter"); app.exec(); return 0; } }
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/2b23347a449e2ded31b5fa8ea20e5536f8edc7ee/main.cpp/buggy/khelpcenter/main.cpp
QXEmbed::embedClientIntoWindow(dlg, id);
{ QXEmbed::embedClientIntoWindow(dlg, id); delete dlg; ModuleLoader::unloadModule(info); return 0; }
int main(int _argc, char *_argv[]){ KAboutData aboutData( "kcmshell", I18N_NOOP("KDE Control Module"), "2.0", I18N_NOOP("A tool to start single KDE control modules"), KAboutData::License_GPL, "(c) 1999-2000, The KDE Developers"); aboutData.addAuthor("Matthias Hoelzer-Kluepfel",0, "[email protected]"); aboutData.addAuthor("Matthias Elter",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" ); if (args->isSet("list")) { QStringList files; KGlobal::dirs()->findAllResources("apps", KCGlobal::baseGroup() + "*.desktop", true, true, files); QStringList modules; QStringList descriptions; uint maxwidth = 0; for (QStringList::ConstIterator it = files.begin(); it != files.end(); it++) { if (KDesktopFile::isDesktopFile(*it)) { KDesktopFile file(*it, true); QString module = *it; if (module.startsWith(KCGlobal::baseGroup())) module = module.mid(KCGlobal::baseGroup().length()); if (module.right(8) == ".desktop") module.truncate(module.length() - 8); modules.append(module); if (module.length() > maxwidth) maxwidth = module.length(); descriptions.append(QString("%2 (%3)").arg(file.readName()).arg(file.readComment())); } } QByteArray vl; vl.fill(' ', 80); QString verylong = vl; for (uint i = 0; i < modules.count(); i++) { fprintf(stdout, "%s%s - %s\n", (*modules.at(i)).local8Bit().data(), verylong.left(maxwidth - (*modules.at(i)).length()).local8Bit().data(), (*descriptions.at(i)).local8Bit().data()); } 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; } QString path = locateModule(args->arg(0)); if (path.isEmpty()) return 0; // load the module ModuleInfo info(path); KCModule *module = ModuleLoader::loadModule(info, false); if (module) { // create the dialog KCDialog * dlg = new KCDialog(module, module->buttons(), info.docPath(), 0, 0, true); dlg->setCaption(info.name()); // Needed for modules that use d'n'd (not really the right // solution for this though, I guess) dlg->setAcceptDrops(true); // 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) QXEmbed::embedClientIntoWindow(dlg, id); } // run the dialog int ret = dlg->exec(); delete dlg; ModuleLoader::unloadModule(info); return ret; } KMessageBox::error(0, i18n("There was an error loading the module.\nThe diagnostics is:\n%1") .arg(KLibLoader::self()->lastErrorMessage())); return 0; } // multiple control modules QStringList modules; for (int i = 0; i < args->count(); i++) { QString path = locateModule(args->arg(i)); if(!path.isEmpty()) modules.append(path); } if (modules.count() < 1) return -1; // create the dialog KExtendedCDialog * dlg = new KExtendedCDialog(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 (QStringList::ConstIterator it = modules.begin(); it != modules.end(); ++it) dlg->addModule(*it, false); // 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) QXEmbed::embedClientIntoWindow(dlg, id); } // run the dialog int ret = dlg->exec(); delete dlg; return ret;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/8b02914f96deebbe3f7cf7cb9642b81543f3cd0e/kcmshell.cpp/clean/kcontrol/kcontrol/kcmshell.cpp
int main(int _argc, char *_argv[]){ KAboutData aboutData( "kcmshell", I18N_NOOP("KDE Control Module"), "2.0", I18N_NOOP("A tool to start single KDE control modules"), KAboutData::License_GPL, "(c) 1999-2000, The KDE Developers"); aboutData.addAuthor("Matthias Hoelzer-Kluepfel",0, "[email protected]"); aboutData.addAuthor("Matthias Elter",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" ); if (args->isSet("list")) { QStringList files; KGlobal::dirs()->findAllResources("apps", KCGlobal::baseGroup() + "*.desktop", true, true, files); QStringList modules; QStringList descriptions; uint maxwidth = 0; for (QStringList::ConstIterator it = files.begin(); it != files.end(); it++) { if (KDesktopFile::isDesktopFile(*it)) { KDesktopFile file(*it, true); QString module = *it; if (module.startsWith(KCGlobal::baseGroup())) module = module.mid(KCGlobal::baseGroup().length()); if (module.right(8) == ".desktop") module.truncate(module.length() - 8); modules.append(module); if (module.length() > maxwidth) maxwidth = module.length(); descriptions.append(QString("%2 (%3)").arg(file.readName()).arg(file.readComment())); } } QByteArray vl; vl.fill(' ', 80); QString verylong = vl; for (uint i = 0; i < modules.count(); i++) { fprintf(stdout, "%s%s - %s\n", (*modules.at(i)).local8Bit().data(), verylong.left(maxwidth - (*modules.at(i)).length()).local8Bit().data(), (*descriptions.at(i)).local8Bit().data()); } 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; } QString path = locateModule(args->arg(0)); if (path.isEmpty()) return 0; // load the module ModuleInfo info(path); KCModule *module = ModuleLoader::loadModule(info, false); if (module) { // create the dialog KCDialog * dlg = new KCDialog(module, module->buttons(), info.docPath(), 0, 0, true); dlg->setCaption(info.name()); // Needed for modules that use d'n'd (not really the right // solution for this though, I guess) dlg->setAcceptDrops(true); // 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) QXEmbed::embedClientIntoWindow(dlg, id); } // run the dialog int ret = dlg->exec(); delete dlg; ModuleLoader::unloadModule(info); return ret; } KMessageBox::error(0, i18n("There was an error loading the module.\nThe diagnostics is:\n%1") .arg(KLibLoader::self()->lastErrorMessage())); return 0; } // multiple control modules QStringList modules; for (int i = 0; i < args->count(); i++) { QString path = locateModule(args->arg(i)); if(!path.isEmpty()) modules.append(path); } if (modules.count() < 1) return -1; // create the dialog KExtendedCDialog * dlg = new KExtendedCDialog(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 (QStringList::ConstIterator it = modules.begin(); it != modules.end(); ++it) dlg->addModule(*it, false); // 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) QXEmbed::embedClientIntoWindow(dlg, id); } // run the dialog int ret = dlg->exec(); delete dlg; return ret;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/8b02914f96deebbe3f7cf7cb9642b81543f3cd0e/kcmshell.cpp/clean/kcontrol/kcontrol/kcmshell.cpp
int ret = dlg->exec();
dlg->exec();
int main(int _argc, char *_argv[]){ KAboutData aboutData( "kcmshell", I18N_NOOP("KDE Control Module"), "2.0", I18N_NOOP("A tool to start single KDE control modules"), KAboutData::License_GPL, "(c) 1999-2000, The KDE Developers"); aboutData.addAuthor("Matthias Hoelzer-Kluepfel",0, "[email protected]"); aboutData.addAuthor("Matthias Elter",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" ); if (args->isSet("list")) { QStringList files; KGlobal::dirs()->findAllResources("apps", KCGlobal::baseGroup() + "*.desktop", true, true, files); QStringList modules; QStringList descriptions; uint maxwidth = 0; for (QStringList::ConstIterator it = files.begin(); it != files.end(); it++) { if (KDesktopFile::isDesktopFile(*it)) { KDesktopFile file(*it, true); QString module = *it; if (module.startsWith(KCGlobal::baseGroup())) module = module.mid(KCGlobal::baseGroup().length()); if (module.right(8) == ".desktop") module.truncate(module.length() - 8); modules.append(module); if (module.length() > maxwidth) maxwidth = module.length(); descriptions.append(QString("%2 (%3)").arg(file.readName()).arg(file.readComment())); } } QByteArray vl; vl.fill(' ', 80); QString verylong = vl; for (uint i = 0; i < modules.count(); i++) { fprintf(stdout, "%s%s - %s\n", (*modules.at(i)).local8Bit().data(), verylong.left(maxwidth - (*modules.at(i)).length()).local8Bit().data(), (*descriptions.at(i)).local8Bit().data()); } 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; } QString path = locateModule(args->arg(0)); if (path.isEmpty()) return 0; // load the module ModuleInfo info(path); KCModule *module = ModuleLoader::loadModule(info, false); if (module) { // create the dialog KCDialog * dlg = new KCDialog(module, module->buttons(), info.docPath(), 0, 0, true); dlg->setCaption(info.name()); // Needed for modules that use d'n'd (not really the right // solution for this though, I guess) dlg->setAcceptDrops(true); // 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) QXEmbed::embedClientIntoWindow(dlg, id); } // run the dialog int ret = dlg->exec(); delete dlg; ModuleLoader::unloadModule(info); return ret; } KMessageBox::error(0, i18n("There was an error loading the module.\nThe diagnostics is:\n%1") .arg(KLibLoader::self()->lastErrorMessage())); return 0; } // multiple control modules QStringList modules; for (int i = 0; i < args->count(); i++) { QString path = locateModule(args->arg(i)); if(!path.isEmpty()) modules.append(path); } if (modules.count() < 1) return -1; // create the dialog KExtendedCDialog * dlg = new KExtendedCDialog(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 (QStringList::ConstIterator it = modules.begin(); it != modules.end(); ++it) dlg->addModule(*it, false); // 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) QXEmbed::embedClientIntoWindow(dlg, id); } // run the dialog int ret = dlg->exec(); delete dlg; return ret;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/8b02914f96deebbe3f7cf7cb9642b81543f3cd0e/kcmshell.cpp/clean/kcontrol/kcontrol/kcmshell.cpp
return ret;
return 0;
int main(int _argc, char *_argv[]){ KAboutData aboutData( "kcmshell", I18N_NOOP("KDE Control Module"), "2.0", I18N_NOOP("A tool to start single KDE control modules"), KAboutData::License_GPL, "(c) 1999-2000, The KDE Developers"); aboutData.addAuthor("Matthias Hoelzer-Kluepfel",0, "[email protected]"); aboutData.addAuthor("Matthias Elter",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" ); if (args->isSet("list")) { QStringList files; KGlobal::dirs()->findAllResources("apps", KCGlobal::baseGroup() + "*.desktop", true, true, files); QStringList modules; QStringList descriptions; uint maxwidth = 0; for (QStringList::ConstIterator it = files.begin(); it != files.end(); it++) { if (KDesktopFile::isDesktopFile(*it)) { KDesktopFile file(*it, true); QString module = *it; if (module.startsWith(KCGlobal::baseGroup())) module = module.mid(KCGlobal::baseGroup().length()); if (module.right(8) == ".desktop") module.truncate(module.length() - 8); modules.append(module); if (module.length() > maxwidth) maxwidth = module.length(); descriptions.append(QString("%2 (%3)").arg(file.readName()).arg(file.readComment())); } } QByteArray vl; vl.fill(' ', 80); QString verylong = vl; for (uint i = 0; i < modules.count(); i++) { fprintf(stdout, "%s%s - %s\n", (*modules.at(i)).local8Bit().data(), verylong.left(maxwidth - (*modules.at(i)).length()).local8Bit().data(), (*descriptions.at(i)).local8Bit().data()); } 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; } QString path = locateModule(args->arg(0)); if (path.isEmpty()) return 0; // load the module ModuleInfo info(path); KCModule *module = ModuleLoader::loadModule(info, false); if (module) { // create the dialog KCDialog * dlg = new KCDialog(module, module->buttons(), info.docPath(), 0, 0, true); dlg->setCaption(info.name()); // Needed for modules that use d'n'd (not really the right // solution for this though, I guess) dlg->setAcceptDrops(true); // 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) QXEmbed::embedClientIntoWindow(dlg, id); } // run the dialog int ret = dlg->exec(); delete dlg; ModuleLoader::unloadModule(info); return ret; } KMessageBox::error(0, i18n("There was an error loading the module.\nThe diagnostics is:\n%1") .arg(KLibLoader::self()->lastErrorMessage())); return 0; } // multiple control modules QStringList modules; for (int i = 0; i < args->count(); i++) { QString path = locateModule(args->arg(i)); if(!path.isEmpty()) modules.append(path); } if (modules.count() < 1) return -1; // create the dialog KExtendedCDialog * dlg = new KExtendedCDialog(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 (QStringList::ConstIterator it = modules.begin(); it != modules.end(); ++it) dlg->addModule(*it, false); // 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) QXEmbed::embedClientIntoWindow(dlg, id); } // run the dialog int ret = dlg->exec(); delete dlg; return ret;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/8b02914f96deebbe3f7cf7cb9642b81543f3cd0e/kcmshell.cpp/clean/kcontrol/kcontrol/kcmshell.cpp
QXEmbed::embedClientIntoWindow(dlg, id);
{ QXEmbed::embedClientIntoWindow(dlg, id); delete dlg; return 0; }
int main(int _argc, char *_argv[]){ KAboutData aboutData( "kcmshell", I18N_NOOP("KDE Control Module"), "2.0", I18N_NOOP("A tool to start single KDE control modules"), KAboutData::License_GPL, "(c) 1999-2000, The KDE Developers"); aboutData.addAuthor("Matthias Hoelzer-Kluepfel",0, "[email protected]"); aboutData.addAuthor("Matthias Elter",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" ); if (args->isSet("list")) { QStringList files; KGlobal::dirs()->findAllResources("apps", KCGlobal::baseGroup() + "*.desktop", true, true, files); QStringList modules; QStringList descriptions; uint maxwidth = 0; for (QStringList::ConstIterator it = files.begin(); it != files.end(); it++) { if (KDesktopFile::isDesktopFile(*it)) { KDesktopFile file(*it, true); QString module = *it; if (module.startsWith(KCGlobal::baseGroup())) module = module.mid(KCGlobal::baseGroup().length()); if (module.right(8) == ".desktop") module.truncate(module.length() - 8); modules.append(module); if (module.length() > maxwidth) maxwidth = module.length(); descriptions.append(QString("%2 (%3)").arg(file.readName()).arg(file.readComment())); } } QByteArray vl; vl.fill(' ', 80); QString verylong = vl; for (uint i = 0; i < modules.count(); i++) { fprintf(stdout, "%s%s - %s\n", (*modules.at(i)).local8Bit().data(), verylong.left(maxwidth - (*modules.at(i)).length()).local8Bit().data(), (*descriptions.at(i)).local8Bit().data()); } 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; } QString path = locateModule(args->arg(0)); if (path.isEmpty()) return 0; // load the module ModuleInfo info(path); KCModule *module = ModuleLoader::loadModule(info, false); if (module) { // create the dialog KCDialog * dlg = new KCDialog(module, module->buttons(), info.docPath(), 0, 0, true); dlg->setCaption(info.name()); // Needed for modules that use d'n'd (not really the right // solution for this though, I guess) dlg->setAcceptDrops(true); // 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) QXEmbed::embedClientIntoWindow(dlg, id); } // run the dialog int ret = dlg->exec(); delete dlg; ModuleLoader::unloadModule(info); return ret; } KMessageBox::error(0, i18n("There was an error loading the module.\nThe diagnostics is:\n%1") .arg(KLibLoader::self()->lastErrorMessage())); return 0; } // multiple control modules QStringList modules; for (int i = 0; i < args->count(); i++) { QString path = locateModule(args->arg(i)); if(!path.isEmpty()) modules.append(path); } if (modules.count() < 1) return -1; // create the dialog KExtendedCDialog * dlg = new KExtendedCDialog(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 (QStringList::ConstIterator it = modules.begin(); it != modules.end(); ++it) dlg->addModule(*it, false); // 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) QXEmbed::embedClientIntoWindow(dlg, id); } // run the dialog int ret = dlg->exec(); delete dlg; return ret;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/8b02914f96deebbe3f7cf7cb9642b81543f3cd0e/kcmshell.cpp/clean/kcontrol/kcontrol/kcmshell.cpp
int ret = dlg->exec();
dlg->exec();
int main(int _argc, char *_argv[]){ KAboutData aboutData( "kcmshell", I18N_NOOP("KDE Control Module"), "2.0", I18N_NOOP("A tool to start single KDE control modules"), KAboutData::License_GPL, "(c) 1999-2000, The KDE Developers"); aboutData.addAuthor("Matthias Hoelzer-Kluepfel",0, "[email protected]"); aboutData.addAuthor("Matthias Elter",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" ); if (args->isSet("list")) { QStringList files; KGlobal::dirs()->findAllResources("apps", KCGlobal::baseGroup() + "*.desktop", true, true, files); QStringList modules; QStringList descriptions; uint maxwidth = 0; for (QStringList::ConstIterator it = files.begin(); it != files.end(); it++) { if (KDesktopFile::isDesktopFile(*it)) { KDesktopFile file(*it, true); QString module = *it; if (module.startsWith(KCGlobal::baseGroup())) module = module.mid(KCGlobal::baseGroup().length()); if (module.right(8) == ".desktop") module.truncate(module.length() - 8); modules.append(module); if (module.length() > maxwidth) maxwidth = module.length(); descriptions.append(QString("%2 (%3)").arg(file.readName()).arg(file.readComment())); } } QByteArray vl; vl.fill(' ', 80); QString verylong = vl; for (uint i = 0; i < modules.count(); i++) { fprintf(stdout, "%s%s - %s\n", (*modules.at(i)).local8Bit().data(), verylong.left(maxwidth - (*modules.at(i)).length()).local8Bit().data(), (*descriptions.at(i)).local8Bit().data()); } 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; } QString path = locateModule(args->arg(0)); if (path.isEmpty()) return 0; // load the module ModuleInfo info(path); KCModule *module = ModuleLoader::loadModule(info, false); if (module) { // create the dialog KCDialog * dlg = new KCDialog(module, module->buttons(), info.docPath(), 0, 0, true); dlg->setCaption(info.name()); // Needed for modules that use d'n'd (not really the right // solution for this though, I guess) dlg->setAcceptDrops(true); // 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) QXEmbed::embedClientIntoWindow(dlg, id); } // run the dialog int ret = dlg->exec(); delete dlg; ModuleLoader::unloadModule(info); return ret; } KMessageBox::error(0, i18n("There was an error loading the module.\nThe diagnostics is:\n%1") .arg(KLibLoader::self()->lastErrorMessage())); return 0; } // multiple control modules QStringList modules; for (int i = 0; i < args->count(); i++) { QString path = locateModule(args->arg(i)); if(!path.isEmpty()) modules.append(path); } if (modules.count() < 1) return -1; // create the dialog KExtendedCDialog * dlg = new KExtendedCDialog(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 (QStringList::ConstIterator it = modules.begin(); it != modules.end(); ++it) dlg->addModule(*it, false); // 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) QXEmbed::embedClientIntoWindow(dlg, id); } // run the dialog int ret = dlg->exec(); delete dlg; return ret;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/8b02914f96deebbe3f7cf7cb9642b81543f3cd0e/kcmshell.cpp/clean/kcontrol/kcontrol/kcmshell.cpp
return ret;
return 0;
int main(int _argc, char *_argv[]){ KAboutData aboutData( "kcmshell", I18N_NOOP("KDE Control Module"), "2.0", I18N_NOOP("A tool to start single KDE control modules"), KAboutData::License_GPL, "(c) 1999-2000, The KDE Developers"); aboutData.addAuthor("Matthias Hoelzer-Kluepfel",0, "[email protected]"); aboutData.addAuthor("Matthias Elter",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" ); if (args->isSet("list")) { QStringList files; KGlobal::dirs()->findAllResources("apps", KCGlobal::baseGroup() + "*.desktop", true, true, files); QStringList modules; QStringList descriptions; uint maxwidth = 0; for (QStringList::ConstIterator it = files.begin(); it != files.end(); it++) { if (KDesktopFile::isDesktopFile(*it)) { KDesktopFile file(*it, true); QString module = *it; if (module.startsWith(KCGlobal::baseGroup())) module = module.mid(KCGlobal::baseGroup().length()); if (module.right(8) == ".desktop") module.truncate(module.length() - 8); modules.append(module); if (module.length() > maxwidth) maxwidth = module.length(); descriptions.append(QString("%2 (%3)").arg(file.readName()).arg(file.readComment())); } } QByteArray vl; vl.fill(' ', 80); QString verylong = vl; for (uint i = 0; i < modules.count(); i++) { fprintf(stdout, "%s%s - %s\n", (*modules.at(i)).local8Bit().data(), verylong.left(maxwidth - (*modules.at(i)).length()).local8Bit().data(), (*descriptions.at(i)).local8Bit().data()); } 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; } QString path = locateModule(args->arg(0)); if (path.isEmpty()) return 0; // load the module ModuleInfo info(path); KCModule *module = ModuleLoader::loadModule(info, false); if (module) { // create the dialog KCDialog * dlg = new KCDialog(module, module->buttons(), info.docPath(), 0, 0, true); dlg->setCaption(info.name()); // Needed for modules that use d'n'd (not really the right // solution for this though, I guess) dlg->setAcceptDrops(true); // 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) QXEmbed::embedClientIntoWindow(dlg, id); } // run the dialog int ret = dlg->exec(); delete dlg; ModuleLoader::unloadModule(info); return ret; } KMessageBox::error(0, i18n("There was an error loading the module.\nThe diagnostics is:\n%1") .arg(KLibLoader::self()->lastErrorMessage())); return 0; } // multiple control modules QStringList modules; for (int i = 0; i < args->count(); i++) { QString path = locateModule(args->arg(i)); if(!path.isEmpty()) modules.append(path); } if (modules.count() < 1) return -1; // create the dialog KExtendedCDialog * dlg = new KExtendedCDialog(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 (QStringList::ConstIterator it = modules.begin(); it != modules.end(); ++it) dlg->addModule(*it, false); // 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) QXEmbed::embedClientIntoWindow(dlg, id); } // run the dialog int ret = dlg->exec(); delete dlg; return ret;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/8b02914f96deebbe3f7cf7cb9642b81543f3cd0e/kcmshell.cpp/clean/kcontrol/kcontrol/kcmshell.cpp
QCString signal = args->getOption( "signal" ); int signalnum = signal.toInt(); if (signalnum < 0) signalnum = 11; QString appname = QFile::decodeName(args->getOption( "appname" ));
int signalnum = args->getOption( "signal" ).toInt();
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 KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); QCString signal = args->getOption( "signal" ); int signalnum = signal.toInt(); if (signalnum < 0) signalnum = 11; QString appname = QFile::decodeName(args->getOption( "appname" )); Toplevel *w = new Toplevel(signalnum, appname); return w->exec();}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/9cf83e17709d1ef04e9b8e8b93d92dc724d99243/main.cpp/buggy/drkonqi/main.cpp
Toplevel *w = new Toplevel(signalnum, appname);
KAboutData oldabout(args->getOption("appname"), args->getOption("programname"), args->getOption("appversion"), 0, 0, 0, 0, 0, args->getOption("bugaddress")); Toplevel *w = new Toplevel(signalnum, oldabout);
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 KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); QCString signal = args->getOption( "signal" ); int signalnum = signal.toInt(); if (signalnum < 0) signalnum = 11; QString appname = QFile::decodeName(args->getOption( "appname" )); Toplevel *w = new Toplevel(signalnum, appname); return w->exec();}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/9cf83e17709d1ef04e9b8e8b93d92dc724d99243/main.cpp/buggy/drkonqi/main.cpp
ModuleInfo info(path);
KCModuleInfo info(path);
int main(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")) { QStringList files; KGlobal::dirs()->findAllResources("apps", KCGlobal::baseGroup() + "*.desktop", true, true, files); QStringList modules; QStringList descriptions; uint maxwidth = 0; for (QStringList::ConstIterator it = files.begin(); it != files.end(); it++) { if (KDesktopFile::isDesktopFile(*it)) { KDesktopFile file(*it, true); if (file.readEntry("Hidden") == "true") continue; QString module = *it; if (module.startsWith(KCGlobal::baseGroup())) module = module.mid(KCGlobal::baseGroup().length()); if (module.right(8) == ".desktop") module.truncate(module.length() - 8); modules.append(module); if (module.length() > maxwidth) maxwidth = module.length(); descriptions.append(QString("%2 (%3)").arg(file.readName()).arg(file.readComment())); } } QByteArray vl; vl.fill(' ', 80); QString verylong = vl; for (uint i = 0; i < modules.count(); i++) { fprintf(stdout, "%s%s - %s\n", (*modules.at(i)).local8Bit().data(), verylong.left(maxwidth - (*modules.at(i)).length()).local8Bit().data(), (*descriptions.at(i)).local8Bit().data()); }#if defined(QT_THREAD_SUPPORT) app.unlock();#endif 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; } QString path = locateModule(args->arg(0)); if (path.isEmpty()) {#if defined(QT_THREAD_SUPPORT) app.unlock();#endif return 0; } // load the module ModuleInfo info(path); 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 ); dlg->setCaption(info.name()); // 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.name(), "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 QStringList modules; for (int i = 0; i < args->count(); i++) { QString path = locateModule(args->arg(i)); if(!path.isEmpty()) modules.append(path); } 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 (QStringList::ConstIterator it = modules.begin(); it != modules.end(); ++it) dlg->addModule(*it, false); // 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; } } // run the dialog dlg->exec(); delete dlg; return 0;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/ff091e495cfa677a421869abdb518c4619752cd3/kcmshell.cpp/clean/kcontrol/kcontrol/kcmshell.cpp
KHelpBrowser *khb = new KHelpBrowser;
khcMainWindow *khb = new khcMainWindow;
int main(int argc, char *argv[]){ bool server = false; // create local data directory if necessary QDir dir; dir.setPath(KApplication::localkdedir() + "/share/apps"); if (!dir.exists()) dir.mkdir(KApplication::localkdedir() + "/share/apps"); dir.setPath(KApplication::localkdedir() + "/share/apps/khelpcenter"); if (!dir.exists()) dir.mkdir(KApplication::localkdedir() + "/share/apps/khelpcenter"); for (int i=0; i< argc; i++) { if (strcmp(argv[i], "--server") == 0 || strcmp(argv[i], "-s") == 0) server = true; } if (server) { // activate autoloader for interface "HelpBrowserFactory" OPApplication app(argc, argv, "khelpcenter"); KOMAutoLoader<HelpBrowserFactory_Impl> HelpBrowserFactoryLoader("IDL:KHelpCenter/HelpBrowserFactory:1.0" , "HelpBrowser"); app.exec(); return 0; } else { // standalone app OPApplication app(argc, argv, "khelpcenter"); KHelpBrowser *khb = new KHelpBrowser; khb->show(); app.exec(); if (khb) delete khb; return 0; }}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/563b6421c6af32801c741278f64fde1426b7204d/khc_main.cc/clean/khelpcenter/khc_main.cc
int main(int argc, char *argv[]){ KApplication app(argc, argv, "kwelcome"); // check for --kdestartup KConfig *conf = kapp->getConfig(); conf->setGroup("General Settings"); QString tmp = conf->readEntry("AutostartOnKDEStartup", "true"); for (i = 1; i < argc; i++) { if ( argv[i][0] == '-' ) { // skip caption if ( strcasecmp( argv[i], "-caption" ) == 0 ) i++; if ( strcasecmp( argv[i], "-icon" ) == 0 ) i++; if ( strcasecmp( argv[i], "-miniicon" ) == 0 ) i++; continue; } QString arg = argv[i]; } if ((arg == "--kdestartup") && (tmp != "true")) return 0; KWelcome *widget = new KWelcome(); app.setMainWidget(widget); app.setTopWidget(widget); widget->show(); return app.exec();}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/b6cb2b99641104dbec1d79fb6078e25222602fcd/main.cpp/clean/khelpcenter/kwelcome/main.cpp
for (i = 1; i < argc; i++)
for (int i = 1; i < argc; i++)
int main(int argc, char *argv[]){ KApplication app(argc, argv, "kwelcome"); // check for --kdestartup KConfig *conf = kapp->getConfig(); conf->setGroup("General Settings"); QString tmp = conf->readEntry("AutostartOnKDEStartup", "true"); for (i = 1; i < argc; i++) { if ( argv[i][0] == '-' ) { // skip caption if ( strcasecmp( argv[i], "-caption" ) == 0 ) i++; if ( strcasecmp( argv[i], "-icon" ) == 0 ) i++; if ( strcasecmp( argv[i], "-miniicon" ) == 0 ) i++; continue; } QString arg = argv[i]; } if ((arg == "--kdestartup") && (tmp != "true")) return 0; KWelcome *widget = new KWelcome(); app.setMainWidget(widget); app.setTopWidget(widget); widget->show(); return app.exec();}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/b6cb2b99641104dbec1d79fb6078e25222602fcd/main.cpp/clean/khelpcenter/kwelcome/main.cpp
if ( argv[i][0] == '-' ) { if ( strcasecmp( argv[i], "-caption" ) == 0 ) i++; if ( strcasecmp( argv[i], "-icon" ) == 0 ) i++; if ( strcasecmp( argv[i], "-miniicon" ) == 0 ) i++; continue; }
int main(int argc, char *argv[]){ KApplication app(argc, argv, "kwelcome"); // check for --kdestartup KConfig *conf = kapp->getConfig(); conf->setGroup("General Settings"); QString tmp = conf->readEntry("AutostartOnKDEStartup", "true"); for (i = 1; i < argc; i++) { if ( argv[i][0] == '-' ) { // skip caption if ( strcasecmp( argv[i], "-caption" ) == 0 ) i++; if ( strcasecmp( argv[i], "-icon" ) == 0 ) i++; if ( strcasecmp( argv[i], "-miniicon" ) == 0 ) i++; continue; } QString arg = argv[i]; } if ((arg == "--kdestartup") && (tmp != "true")) return 0; KWelcome *widget = new KWelcome(); app.setMainWidget(widget); app.setTopWidget(widget); widget->show(); return app.exec();}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/b6cb2b99641104dbec1d79fb6078e25222602fcd/main.cpp/clean/khelpcenter/kwelcome/main.cpp
if ((arg == "--kdestartup") && (tmp != "true")) return 0;
int main(int argc, char *argv[]){ KApplication app(argc, argv, "kwelcome"); // check for --kdestartup KConfig *conf = kapp->getConfig(); conf->setGroup("General Settings"); QString tmp = conf->readEntry("AutostartOnKDEStartup", "true"); for (i = 1; i < argc; i++) { if ( argv[i][0] == '-' ) { // skip caption if ( strcasecmp( argv[i], "-caption" ) == 0 ) i++; if ( strcasecmp( argv[i], "-icon" ) == 0 ) i++; if ( strcasecmp( argv[i], "-miniicon" ) == 0 ) i++; continue; } QString arg = argv[i]; } if ((arg == "--kdestartup") && (tmp != "true")) return 0; KWelcome *widget = new KWelcome(); app.setMainWidget(widget); app.setTopWidget(widget); widget->show(); return app.exec();}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/b6cb2b99641104dbec1d79fb6078e25222602fcd/main.cpp/clean/khelpcenter/kwelcome/main.cpp
return app.exec();
int rc = app.exec(); if (widget != 0) delete widget; return rc;
int main(int argc, char *argv[]){ KApplication app(argc, argv, "kwelcome"); // check for --kdestartup KConfig *conf = kapp->getConfig(); conf->setGroup("General Settings"); QString tmp = conf->readEntry("AutostartOnKDEStartup", "true"); for (i = 1; i < argc; i++) { if ( argv[i][0] == '-' ) { // skip caption if ( strcasecmp( argv[i], "-caption" ) == 0 ) i++; if ( strcasecmp( argv[i], "-icon" ) == 0 ) i++; if ( strcasecmp( argv[i], "-miniicon" ) == 0 ) i++; continue; } QString arg = argv[i]; } if ((arg == "--kdestartup") && (tmp != "true")) return 0; KWelcome *widget = new KWelcome(); app.setMainWidget(widget); app.setTopWidget(widget); widget->show(); return app.exec();}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/b6cb2b99641104dbec1d79fb6078e25222602fcd/main.cpp/clean/khelpcenter/kwelcome/main.cpp
I18N_NOOP("The KDE Crash Handler"), version, description, KAboutData::License_BSD, "(C) 2000, Hans Petter Bieker");
I18N_NOOP("The KDE Crash Handler"), version, description, KAboutData::License_BSD, "(C) 2000-2003, Hans Petter Bieker");
int main( int argc, char* argv[] ){ // Drop privs. setgid(getgid()); setuid(getuid()); // 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::disableAutoDcopRegistration(); KApplication a; a.disableSessionManagement(); KrashConfig krashconf; Toplevel w(&krashconf); return w.exec();}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/da930ed6a3bdf1bf8a5ed02103cadc8f923d64c5/main.cpp/buggy/drkonqi/main.cpp
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]" ); 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)) + " "; desktop = args->getOption( "desktop" ).toInt(); if ( args->isSet ( "alldesktops") ) desktop = NETWinInfo::OnAllDesktops; window = args->getOption( "window" ); 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 windowtype = NET::Normal; } if ( args->isSet( "ontop" ) ) { state |= NET::StaysOnTop; mask |= NET::StaysOnTop; } if ( args->isSet( "skiptaskbar" ) ) { state |= NET::SkipTaskbar; mask |= NET::SkipTaskbar; } activate = args->isSet("activate"); if ( args->isSet("maximize") ) { state |= NET::Max; mask |= NET::Max; } iconify = args->isSet("iconify"); fcntl(ConnectionNumber(qt_xdisplay()), F_SETFD, 1); args->clear(); KStart start; return app.exec();}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/db59fd19fb041ab9843b9e1e4b18b9941ce21747/kstart.C/buggy/kstart/kstart.C
else
else
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]" ); 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)) + " "; desktop = args->getOption( "desktop" ).toInt(); if ( args->isSet ( "alldesktops") ) desktop = NETWinInfo::OnAllDesktops; window = args->getOption( "window" ); 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 windowtype = NET::Normal; } if ( args->isSet( "ontop" ) ) { state |= NET::StaysOnTop; mask |= NET::StaysOnTop; } if ( args->isSet( "skiptaskbar" ) ) { state |= NET::SkipTaskbar; mask |= NET::SkipTaskbar; } activate = args->isSet("activate"); if ( args->isSet("maximize") ) { state |= NET::Max; mask |= NET::Max; } iconify = args->isSet("iconify"); fcntl(ConnectionNumber(qt_xdisplay()), F_SETFD, 1); args->clear(); KStart start; return app.exec();}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/db59fd19fb041ab9843b9e1e4b18b9941ce21747/kstart.C/buggy/kstart/kstart.C
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]" ); 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)) + " "; desktop = args->getOption( "desktop" ).toInt(); if ( args->isSet ( "alldesktops") ) desktop = NETWinInfo::OnAllDesktops; window = args->getOption( "window" ); 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 windowtype = NET::Normal; } if ( args->isSet( "ontop" ) ) { state |= NET::StaysOnTop; mask |= NET::StaysOnTop; } if ( args->isSet( "skiptaskbar" ) ) { state |= NET::SkipTaskbar; mask |= NET::SkipTaskbar; } activate = args->isSet("activate"); if ( args->isSet("maximize") ) { state |= NET::Max; mask |= NET::Max; } iconify = args->isSet("iconify"); fcntl(ConnectionNumber(qt_xdisplay()), F_SETFD, 1); args->clear(); KStart start; return app.exec();}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/db59fd19fb041ab9843b9e1e4b18b9941ce21747/kstart.C/buggy/kstart/kstart.C
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]" ); 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)) + " "; desktop = args->getOption( "desktop" ).toInt(); if ( args->isSet ( "alldesktops") ) desktop = NETWinInfo::OnAllDesktops; window = args->getOption( "window" ); 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 windowtype = NET::Normal; } if ( args->isSet( "ontop" ) ) { state |= NET::StaysOnTop; mask |= NET::StaysOnTop; } if ( args->isSet( "skiptaskbar" ) ) { state |= NET::SkipTaskbar; mask |= NET::SkipTaskbar; } activate = args->isSet("activate"); if ( args->isSet("maximize") ) { state |= NET::Max; mask |= NET::Max; } iconify = args->isSet("iconify"); fcntl(ConnectionNumber(qt_xdisplay()), F_SETFD, 1); args->clear(); KStart start; return app.exec();}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/db59fd19fb041ab9843b9e1e4b18b9941ce21747/kstart.C/buggy/kstart/kstart.C
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]" ); 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)) + " "; desktop = args->getOption( "desktop" ).toInt(); if ( args->isSet ( "alldesktops") ) desktop = NETWinInfo::OnAllDesktops; window = args->getOption( "window" ); 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 windowtype = NET::Normal; } if ( args->isSet( "ontop" ) ) { state |= NET::StaysOnTop; mask |= NET::StaysOnTop; } if ( args->isSet( "skiptaskbar" ) ) { state |= NET::SkipTaskbar; mask |= NET::SkipTaskbar; } activate = args->isSet("activate"); if ( args->isSet("maximize") ) { state |= NET::Max; mask |= NET::Max; } iconify = args->isSet("iconify"); fcntl(ConnectionNumber(qt_xdisplay()), F_SETFD, 1); args->clear(); KStart start; return app.exec();}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/db59fd19fb041ab9843b9e1e4b18b9941ce21747/kstart.C/buggy/kstart/kstart.C
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]" ); 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)) + " "; desktop = args->getOption( "desktop" ).toInt(); if ( args->isSet ( "alldesktops") ) desktop = NETWinInfo::OnAllDesktops; window = args->getOption( "window" ); 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 windowtype = NET::Normal; } if ( args->isSet( "ontop" ) ) { state |= NET::StaysOnTop; mask |= NET::StaysOnTop; } if ( args->isSet( "skiptaskbar" ) ) { state |= NET::SkipTaskbar; mask |= NET::SkipTaskbar; } activate = args->isSet("activate"); if ( args->isSet("maximize") ) { state |= NET::Max; mask |= NET::Max; } iconify = args->isSet("iconify"); fcntl(ConnectionNumber(qt_xdisplay()), F_SETFD, 1); args->clear(); KStart start; return app.exec();}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/db59fd19fb041ab9843b9e1e4b18b9941ce21747/kstart.C/buggy/kstart/kstart.C
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]" ); 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)) + " "; desktop = args->getOption( "desktop" ).toInt(); if ( args->isSet ( "alldesktops") ) desktop = NETWinInfo::OnAllDesktops; window = args->getOption( "window" ); 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 windowtype = NET::Normal; } if ( args->isSet( "ontop" ) ) { state |= NET::StaysOnTop; mask |= NET::StaysOnTop; } if ( args->isSet( "skiptaskbar" ) ) { state |= NET::SkipTaskbar; mask |= NET::SkipTaskbar; } activate = args->isSet("activate"); if ( args->isSet("maximize") ) { state |= NET::Max; mask |= NET::Max; } iconify = args->isSet("iconify"); fcntl(ConnectionNumber(qt_xdisplay()), F_SETFD, 1); args->clear(); KStart start; return app.exec();}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/db59fd19fb041ab9843b9e1e4b18b9941ce21747/kstart.C/buggy/kstart/kstart.C
qgis->getMapCanvas()->setExtent(rect);
qgis->setExtent(rect);
int main(int argc, char *argv[]){ // Set up the custom qWarning/qDebug custom handler qInstallMsgHandler( myMessageOutput ); ///////////////////////////////////////////////////////////////// // 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 set initial extent of map canvas QString myInitialExtent=""; // This behaviour will allow you to force the use of a translation file // which is useful for testing QString myTranslationFileName="";#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'}, {"extent", required_argument, 0, 'e'}, {0, 0, 0, 0} }; /* getopt_long stores the option index here. */ int option_index = 0; optionChar = getopt_long (argc, argv, "slpe", 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 'e': myInitialExtent = 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 );#ifdef Q_OS_MACX // Install OpenDocuments AppleEvent handler after application object is initialized // but before any other event handling (including dialogs or splash screens) occurs. // If an OpenDocuments event has been created before the application was launched, // it must be handled before some other event handler runs and dismisses it as unknown. // If run at startup, the handler will set either or both of myProjectFileName and myFileList. AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, openDocumentsAEHandler, 0, false);#endif // 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() ) { qgis->openProject(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).local8Bit() << std::endl;#endif QString myLayerName = *myIterator; // don't load anything with a .qgs extension - these are project files if(!myLayerName.contains(".qgs")) { qgis->openLayer(myLayerName); } } ///////////////////////////////////////////////////////////////////// // Set initial extent if requested ///////////////////////////////////////////////////////////////////// if ( ! myInitialExtent.isEmpty() ) { double coords[4]; int pos, posOld = 0; bool ok; // XXX is it necessary to switch to "C" locale? // parse values from string // extent is defined by string "xmin,ymin,xmax,ymax" for (int i = 0; i < 3; i++) { // find comma and get coordinate 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; } // parse last coordinate if (ok) coords[3] = QString( myInitialExtent.mid(posOld) ).toDouble(&ok); if (!ok) std::cout << "Error while parsing initial extent!" << std::endl; else { // set extent from parsed values QgsRect rect(coords[0],coords[1],coords[2],coords[3]); qgis->getMapCanvas()->setExtent(rect); } } ///////////////////////////////////////////////////////////////////// // 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();}
1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/08774d5013b5ae480794576c2d139e3ef750c17c/main.cpp/buggy/src/main.cpp
if ( !doit() ) { debug( "kio_file : Could not do it :-("); exit(1); }
Connection parent( 0, 1 ); FileProtocol file( &parent ); file.dispatchLoop();
int main( int argc, char **argv ){ signal(SIGCHLD,sig_handler); signal(SIGSEGV,sig_handler2); ProtocolManager manager; debug( "kio_file : Starting"); if ( !doit() ) { debug( "kio_file : Could not do it :-("); exit(1); } debug( "kio_file : Done" );}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/6414d70f0526d601897746a3967704aa193d5461/file.cc/buggy/kioslave/file/file.cc
QString myArgString; QFile myQFile; QStringList myVectorFileStringList, myRasterFileStringList; bool myFileExistsFlag;
int main(int argc, char *argv[]){ 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(argc == 2){ QString translation = "qgis_" + QString(argv[1]); 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(); a.setMainWidget(qgis); qgis->show(); a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); // //turn control over to the main application loop... // int result = a.exec(); return result;}
1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/0b9c2debd98851a1dabaa19dcc938c40f5a95fd8/main.cpp/buggy/src/main.cpp
if(argc == 2){ QString translation = "qgis_" + QString(argv[1]); tor.load(translation,"."); }else{ tor.load(QString("qgis_") + QTextCodec::locale(), "."); }
if(argc == 2){ QString translation = "qgis_" + QString(argv[1]); tor.load(translation,"."); }else{ tor.load(QString("qgis_") + QTextCodec::locale(), "."); }
int main(int argc, char *argv[]){ 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(argc == 2){ QString translation = "qgis_" + QString(argv[1]); 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(); a.setMainWidget(qgis); qgis->show(); a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); // //turn control over to the main application loop... // int result = a.exec(); return result;}
1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/0b9c2debd98851a1dabaa19dcc938c40f5a95fd8/main.cpp/buggy/src/main.cpp
for(int myIteratorInt = 1; myIteratorInt < argc; myIteratorInt++) { #ifdef DEBUG printf("%d: %s\n", myIteratorInt, argv[myIteratorInt]); #endif myQFile.setName(argv[myIteratorInt]); myFileExistsFlag = myQFile.open(IO_ReadOnly); myQFile.close(); if(myFileExistsFlag) { #ifdef DEBUG printf("OK\n"); #endif myArgString = argv[myIteratorInt]; if(myArgString.endsWith(".shp", FALSE)) { myVectorFileStringList.append(myArgString); #ifdef DEBUG printf("Vector count: %d\n",myVectorFileStringList.count()); #endif } else if (myArgString.endsWith(".adf", FALSE) || myArgString.endsWith(".asc", FALSE) || myArgString.endsWith(".grd", FALSE) || myArgString.endsWith(".img", FALSE) || myArgString.endsWith(".tif", FALSE) || myArgString.endsWith(".png", FALSE) || myArgString.endsWith(".jpg", FALSE) || myArgString.endsWith(".dem", FALSE) || myArgString.endsWith(".ddf", FALSE)) { myRasterFileStringList.append(myArgString); #ifdef DEBUG printf("Raster count: %d\n",myRasterFileStringList.count()); #endif } } } #ifdef DEBUG printf("vCount: %d\n",myVectorFileStringList.count()); printf("rCount: %d\n",myRasterFileStringList.count()); #endif if(!myVectorFileStringList.isEmpty()) { #ifdef DEBUG printf("Loading vector files...\n"); #endif qgis->addLayer(myVectorFileStringList); } if(!myRasterFileStringList.isEmpty()) { #ifdef DEBUG printf("Load raster files...\n"); #endif }
int main(int argc, char *argv[]){ 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(argc == 2){ QString translation = "qgis_" + QString(argv[1]); 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(); a.setMainWidget(qgis); qgis->show(); a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); // //turn control over to the main application loop... // int result = a.exec(); return result;}
1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/0b9c2debd98851a1dabaa19dcc938c40f5a95fd8/main.cpp/buggy/src/main.cpp
int main(int argc, char *argv[]){ // create local data directory if necessary QDir dir; dir.setPath(KApplication::localkdedir() + "/share/apps"); if (!dir.exists()) dir.mkdir(KApplication::localkdedir() + "/share/apps"); dir.setPath(KApplication::localkdedir() + "/share/apps/khelpcenter"); if (!dir.exists()) dir.mkdir(KApplication::localkdedir() + "/share/apps/khelpcenter"); // init app KOMApplication app(argc, argv, "KDE HelpCenter"); KOMAutoLoader<HelpWindowFactory_Impl> HelpWindowFactoryLoader("IDL:KHelpCenter/HelpWindowFactory:1.0" , "KHelpCenter"); app.exec(); return 0;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/bee787a1a1f43b433f2b456459b174d1444f046a/main.cpp/buggy/khelpcenter/main.cpp
KGlobal::locale()->insertCatalogue("filetypes");
int main(int argc, char ** argv){ KServiceTypeProfile::setConfigurationMode(); KLocale::setMainCatalogue("filetypes"); KAboutData aboutData( "keditfiletype", I18N_NOOP("KEditFileType"), "1.0", I18N_NOOP("KDE file type editor - simplified version for editing a single file type"), KAboutData::License_GPL, I18N_NOOP("(c) 2000, KDE developers") ); aboutData.addAuthor("Preston Brown",0, "[email protected]"); aboutData.addAuthor("David Faure",0, "[email protected]"); KCmdLineArgs::init( argc, argv, &aboutData ); KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. KApplication app; KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); KGlobal::locale()->insertCatalogue("filetypes"); if (args->count() == 0) KCmdLineArgs::usage(); KMimeType::Ptr mime = KMimeType::mimeType( args->arg(0) ); if (!mime) kdFatal() << "Mimetype " << args->arg(0) << " not found" << endl; args->clear(); FileTypeDialog * dlg = new FileTypeDialog( mime ); dlg->setCaption( i18n("Edit File Type %1").arg(mime->name()) ); dlg->exec(); delete dlg; return 0;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/2a21065da7dc498746254764d227af7e1f1f86b7/keditfiletype.cpp/clean/keditfiletype/keditfiletype.cpp
if ((args->count() == 0)&(!args->isSet("c"))) KCmdLineArgs::usage(i18n("No command specified!"));
int main(int argc, char *argv[]){ 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 *app = new KApplication; // Check command // CJM - probably a hack here - but need to check for a "c" for backwords compat. if ((args->count() == 0)&(!args->isSet("c"))) KCmdLineArgs::usage(i18n("No command specified!")); // 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++) { command += " "; command += args->arg(i); } } else { command = args->arg(0); for (int i=1; i<args->count(); i++) { command += " "; command += args->arg(i); }}// 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"); if (keep && !terminal && !just_started) { client.setPriority(priority); client.setScheduler(scheduler); if (client.exec(command, user) != -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); // Start the dialog KDEsuDialog *dlg = new KDEsuDialog(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) exit(0); if (ret == KDEsuDialog::AsUser) change_uid = false; QCString password = dlg->password(); int k = dlg->keep(); delete dlg; // Some events may need to be handled (like a button animation) app->processEvents(); if (!change_uid) return system(command); // Run command if (k && have_daemon) { client.setPass(password, timeout); client.setPriority(priority); client.setScheduler(scheduler); return client.exec(command, user); } else { SuProcess proc; proc.setTerminal(terminal); proc.setErase(true); proc.setUser(user); proc.setPriority(priority); proc.setScheduler(scheduler); proc.setCommand(command); return proc.exec(password); }}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/6290cd17198c6b705dba3ee2541dd076796436a9/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp
int main(int argc, char *argv[]){ 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 *app = new KApplication; // Check command // CJM - probably a hack here - but need to check for a "c" for backwords compat. if ((args->count() == 0)&(!args->isSet("c"))) KCmdLineArgs::usage(i18n("No command specified!")); // 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++) { command += " "; command += args->arg(i); } } else { command = args->arg(0); for (int i=1; i<args->count(); i++) { command += " "; command += args->arg(i); }}// 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"); if (keep && !terminal && !just_started) { client.setPriority(priority); client.setScheduler(scheduler); if (client.exec(command, user) != -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); // Start the dialog KDEsuDialog *dlg = new KDEsuDialog(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) exit(0); if (ret == KDEsuDialog::AsUser) change_uid = false; QCString password = dlg->password(); int k = dlg->keep(); delete dlg; // Some events may need to be handled (like a button animation) app->processEvents(); if (!change_uid) return system(command); // Run command if (k && have_daemon) { client.setPass(password, timeout); client.setPriority(priority); client.setScheduler(scheduler); return client.exec(command, user); } else { SuProcess proc; proc.setTerminal(terminal); proc.setErase(true); proc.setUser(user); proc.setPriority(priority); proc.setScheduler(scheduler); proc.setCommand(command); return proc.exec(password); }}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/6290cd17198c6b705dba3ee2541dd076796436a9/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp
if( args->count() == 0 ) { KCmdLineArgs::usage(i18n("No command specified!")); exit(1); }
int main(int argc, char *argv[]){ 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 *app = new KApplication; // Check command // CJM - probably a hack here - but need to check for a "c" for backwords compat. if ((args->count() == 0)&(!args->isSet("c"))) KCmdLineArgs::usage(i18n("No command specified!")); // 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++) { command += " "; command += args->arg(i); } } else { command = args->arg(0); for (int i=1; i<args->count(); i++) { command += " "; command += args->arg(i); }}// 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"); if (keep && !terminal && !just_started) { client.setPriority(priority); client.setScheduler(scheduler); if (client.exec(command, user) != -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); // Start the dialog KDEsuDialog *dlg = new KDEsuDialog(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) exit(0); if (ret == KDEsuDialog::AsUser) change_uid = false; QCString password = dlg->password(); int k = dlg->keep(); delete dlg; // Some events may need to be handled (like a button animation) app->processEvents(); if (!change_uid) return system(command); // Run command if (k && have_daemon) { client.setPass(password, timeout); client.setPriority(priority); client.setScheduler(scheduler); return client.exec(command, user); } else { SuProcess proc; proc.setTerminal(terminal); proc.setErase(true); proc.setUser(user); proc.setPriority(priority); proc.setScheduler(scheduler); proc.setCommand(command); return proc.exec(password); }}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/6290cd17198c6b705dba3ee2541dd076796436a9/kdesu.cpp/buggy/kdesu/kdesu/kdesu.cpp
int main(int argc, char *argv[]){ KApplication app(argc, argv, "kcminit"); QStringList libs; QString libname, funcname, call; // locate the desktop files QStringList files; files = KGlobal::dirs()->findAllResources("apps", "Settings/*.desktop", true); // look for Init=... entries QStringList::Iterator it; for (it = files.begin(); it != files.end(); ++it) { KDesktopFile desktop(*it); libname = desktop.readEntry("X-KDE-Library"); funcname = desktop.readEntry("X-KDE-Init"); call = funcname+"@"+libname; if (!funcname.isEmpty() && !libname.isEmpty() && !libs.contains(call)) libs.append(call); } // get the library loader instance KLibLoader *loader = KLibLoader::self(); for (it = libs.begin(); it != libs.end(); ++it) { int pos = (*it).find("@"); funcname = (*it).left(pos); libname = (*it).mid(pos+1); // try to load the library QString ln("libkcm_%1"); KLibrary *lib = loader->library(ln.arg(libname)); if (lib) { // get the init_ function QString factory("init_%1"); void *init = lib->symbol(factory.arg(funcname)); if (init) { // initialize the module kdDebug() << "Initializing " << libname << ": " << funcname << endl; void (*func)() = (void(*)())init; func(); } } } return 0;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/1ee68e6d695e1f430161296a51d8011293816068/kcminit.cpp/clean/kcontrol/kcontrol/kcminit.cpp
libs.append(call);
libs.append(call);
int main(int argc, char *argv[]){ KApplication app(argc, argv, "kcminit"); QStringList libs; QString libname, funcname, call; // locate the desktop files QStringList files; files = KGlobal::dirs()->findAllResources("apps", "Settings/*.desktop", true); // look for Init=... entries QStringList::Iterator it; for (it = files.begin(); it != files.end(); ++it) { KDesktopFile desktop(*it); libname = desktop.readEntry("X-KDE-Library"); funcname = desktop.readEntry("X-KDE-Init"); call = funcname+"@"+libname; if (!funcname.isEmpty() && !libname.isEmpty() && !libs.contains(call)) libs.append(call); } // get the library loader instance KLibLoader *loader = KLibLoader::self(); for (it = libs.begin(); it != libs.end(); ++it) { int pos = (*it).find("@"); funcname = (*it).left(pos); libname = (*it).mid(pos+1); // try to load the library QString ln("libkcm_%1"); KLibrary *lib = loader->library(ln.arg(libname)); if (lib) { // get the init_ function QString factory("init_%1"); void *init = lib->symbol(factory.arg(funcname)); if (init) { // initialize the module kdDebug() << "Initializing " << libname << ": " << funcname << endl; void (*func)() = (void(*)())init; func(); } } } return 0;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/1ee68e6d695e1f430161296a51d8011293816068/kcminit.cpp/clean/kcontrol/kcontrol/kcminit.cpp
{ QString factory("init_%1"); void *init = lib->symbol(factory.arg(funcname)); if (init) { kdDebug() << "Initializing " << libname << ": " << funcname << endl;
{ QString factory("init_%1"); void *init = lib->symbol(factory.arg(funcname)); if (init) { kdDebug() << "Initializing control module " << libname << ": " << funcname << endl;
int main(int argc, char *argv[]){ KApplication app(argc, argv, "kcminit"); QStringList libs; QString libname, funcname, call; // locate the desktop files QStringList files; files = KGlobal::dirs()->findAllResources("apps", "Settings/*.desktop", true); // look for Init=... entries QStringList::Iterator it; for (it = files.begin(); it != files.end(); ++it) { KDesktopFile desktop(*it); libname = desktop.readEntry("X-KDE-Library"); funcname = desktop.readEntry("X-KDE-Init"); call = funcname+"@"+libname; if (!funcname.isEmpty() && !libname.isEmpty() && !libs.contains(call)) libs.append(call); } // get the library loader instance KLibLoader *loader = KLibLoader::self(); for (it = libs.begin(); it != libs.end(); ++it) { int pos = (*it).find("@"); funcname = (*it).left(pos); libname = (*it).mid(pos+1); // try to load the library QString ln("libkcm_%1"); KLibrary *lib = loader->library(ln.arg(libname)); if (lib) { // get the init_ function QString factory("init_%1"); void *init = lib->symbol(factory.arg(funcname)); if (init) { // initialize the module kdDebug() << "Initializing " << libname << ": " << funcname << endl; void (*func)() = (void(*)())init; func(); } } } return 0;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/1ee68e6d695e1f430161296a51d8011293816068/kcminit.cpp/clean/kcontrol/kcontrol/kcminit.cpp
void (*func)() = (void(*)())init; func(); } }
void (*func)() = (void(*)())init; func(); } loader->unloadLibrary(ln.arg(libname)); }
int main(int argc, char *argv[]){ KApplication app(argc, argv, "kcminit"); QStringList libs; QString libname, funcname, call; // locate the desktop files QStringList files; files = KGlobal::dirs()->findAllResources("apps", "Settings/*.desktop", true); // look for Init=... entries QStringList::Iterator it; for (it = files.begin(); it != files.end(); ++it) { KDesktopFile desktop(*it); libname = desktop.readEntry("X-KDE-Library"); funcname = desktop.readEntry("X-KDE-Init"); call = funcname+"@"+libname; if (!funcname.isEmpty() && !libname.isEmpty() && !libs.contains(call)) libs.append(call); } // get the library loader instance KLibLoader *loader = KLibLoader::self(); for (it = libs.begin(); it != libs.end(); ++it) { int pos = (*it).find("@"); funcname = (*it).left(pos); libname = (*it).mid(pos+1); // try to load the library QString ln("libkcm_%1"); KLibrary *lib = loader->library(ln.arg(libname)); if (lib) { // get the init_ function QString factory("init_%1"); void *init = lib->symbol(factory.arg(funcname)); if (init) { // initialize the module kdDebug() << "Initializing " << libname << ": " << funcname << endl; void (*func)() = (void(*)())init; func(); } } } return 0;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/1ee68e6d695e1f430161296a51d8011293816068/kcminit.cpp/clean/kcontrol/kcontrol/kcminit.cpp
"v2.0pre", "The KDE Control Centre", KAboutData::GPL,
"v2.0pre", "The KDE Control Centre", KAboutData::License_GPL,
int main(int argc, char *argv[]){ KAboutData aboutData( "kcontrol", I18N_NOOP("KDE Control Centre"), "v2.0pre", "The KDE Control Centre", KAboutData::GPL, "(c) 1998-2000, The KDE Control Centre Developers"); aboutData.addAuthor("Matthias Hoelzer-Kluepfel",0, "[email protected]"); KCmdLineArgs::init( argc, argv, &aboutData ); KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. if (!MyApplication::start()) exit(0); // Don't do anything if we are already running MyApplication app; //&aboutData // TODO: MyApplication (a KUniqueApplication) doesn't // support KApplication::KApplication(KAboutData *) // So, I'm leaving this alone, and will let the // maintainter of kcontrol finish it up! // show the whole stuff app.mainWidget()->show(); return app.exec();}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/7e47a70e095a598a0da02a337f678c7238ad2b30/main.cpp/buggy/kcontrol/kcontrol/main.cpp
"v2.0pre", "The KDE Control Center", KAboutData::License_GPL,
"v2.0pre", I18N_NOOP("The KDE Control Center"), KAboutData::License_GPL,
int main(int argc, char *argv[]){ KAboutData aboutData( "kcontrol", I18N_NOOP("KDE Control Center"), "v2.0pre", "The KDE Control Center", KAboutData::License_GPL, "(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();}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/9d1fc530ab3c1a3c1dc8ecb8fe0d2a29ec798762/main.cpp/clean/kcontrol/kcontrol/main.cpp
exit(1);
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 because you have no DISPLAY environment variable set." << std::endl; } QApplication a(argc, argv, myUseGuiFlag ); // 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();}
1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/4a2f0af82107b2bd6d4389de3bfe1d3ec9d25fa2/main.cpp/clean/src/main.cpp
/* else files = KGlobal::dirs()-> findAllResources("apps", QString("Settings/%1.desktop").arg(args->arg(0)), true); if (files.count() > 1) cerr << i18n("Module name not unique. Taking the first match.") << endl; */
int main(int _argc, char *_argv[]){ KCmdLineArgs::init( _argc, _argv, "kcmshell", I18N_NOOP("A tool to start single kcontrol modules"), "2.0pre" ); KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. KLocale::setMainCatalogue("kcontrol"); KApplication app; // It has to be unset, if not it will break modules like kcmlocale KLocale::setMainCatalogue(0); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); if (args->isSet("list")) { QStringList files; KGlobal::dirs()->findAllResources("apps", "Settings/*.desktop", true, true, files); QStringList modules; QStringList descriptions; uint maxwidth = 0; for (QStringList::ConstIterator it = files.begin(); it != files.end(); it++) { if (KDesktopFile::isDesktopFile(*it)) { KDesktopFile file(*it, true); QString module = *it; if (module.left(9) == "Settings/") module = module.mid(9); if (module.right(8) == ".desktop") module.truncate(module.length() - 8); modules.append(module); if (module.length() > maxwidth) maxwidth = module.length(); descriptions.append(QString("%2 (%3)").arg(file.readName()).arg(file.readComment())); } } QByteArray vl; vl.fill(' ', 80); QString verylong = vl; for (uint i = 0; i < modules.count(); i++) { cout << (*modules.at(i)).latin1(); cout << verylong.left(maxwidth - (*modules.at(i)).length()); cout << " - "; cout << (*descriptions.at(i)).local8Bit(); cout << endl; } return 0; } if (args->count() != 1) { args->usage(); return -1; } QCString arg = args->arg(0); // locate the desktop file //QStringList files; if (arg[0] == '/') { kdDebug() << "Full path given to kcmshell - not supported yet" << endl; // (because of KService::findServiceByDesktopPath) //files.append(args->arg(0)); } QCString path = "Settings/"; path += arg; path += ".desktop"; /* else files = KGlobal::dirs()-> findAllResources("apps", QString("Settings/%1.desktop").arg(args->arg(0)), true); // check the matches if (files.count() > 1) cerr << i18n("Module name not unique. Taking the first match.") << endl; */ if (!KService::serviceByDesktopPath( path )) { // Path didn't work. Trying as a name KService::Ptr serv = KService::serviceByDesktopName( arg ); if ( serv ) path = serv->entryPath(); else { cerr << i18n("Module %1 not found!").arg(arg) << endl; return -1; } } args->clear(); // load the module ModuleInfo info(path); KCModule *module = ModuleLoader::module(info); if (module) { // create the dialog KCDialog dlg(module, module->buttons(), info.docPath(), 0, 0, true); dlg.setCaption(info.name()); // Needed for modules that use d'n'd (not really the right // solution for this though, I guess) dlg.setAcceptDrops(true); // run the dialog return dlg.exec(); } return 0;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/1ee68e6d695e1f430161296a51d8011293816068/kcmshell.cpp/clean/kcontrol/kcontrol/kcmshell.cpp
KCModule *module = ModuleLoader::module(info);
KCModule *module = ModuleLoader::loadModule(info);
int main(int _argc, char *_argv[]){ KCmdLineArgs::init( _argc, _argv, "kcmshell", I18N_NOOP("A tool to start single kcontrol modules"), "2.0pre" ); KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. KLocale::setMainCatalogue("kcontrol"); KApplication app; // It has to be unset, if not it will break modules like kcmlocale KLocale::setMainCatalogue(0); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); if (args->isSet("list")) { QStringList files; KGlobal::dirs()->findAllResources("apps", "Settings/*.desktop", true, true, files); QStringList modules; QStringList descriptions; uint maxwidth = 0; for (QStringList::ConstIterator it = files.begin(); it != files.end(); it++) { if (KDesktopFile::isDesktopFile(*it)) { KDesktopFile file(*it, true); QString module = *it; if (module.left(9) == "Settings/") module = module.mid(9); if (module.right(8) == ".desktop") module.truncate(module.length() - 8); modules.append(module); if (module.length() > maxwidth) maxwidth = module.length(); descriptions.append(QString("%2 (%3)").arg(file.readName()).arg(file.readComment())); } } QByteArray vl; vl.fill(' ', 80); QString verylong = vl; for (uint i = 0; i < modules.count(); i++) { cout << (*modules.at(i)).latin1(); cout << verylong.left(maxwidth - (*modules.at(i)).length()); cout << " - "; cout << (*descriptions.at(i)).local8Bit(); cout << endl; } return 0; } if (args->count() != 1) { args->usage(); return -1; } QCString arg = args->arg(0); // locate the desktop file //QStringList files; if (arg[0] == '/') { kdDebug() << "Full path given to kcmshell - not supported yet" << endl; // (because of KService::findServiceByDesktopPath) //files.append(args->arg(0)); } QCString path = "Settings/"; path += arg; path += ".desktop"; /* else files = KGlobal::dirs()-> findAllResources("apps", QString("Settings/%1.desktop").arg(args->arg(0)), true); // check the matches if (files.count() > 1) cerr << i18n("Module name not unique. Taking the first match.") << endl; */ if (!KService::serviceByDesktopPath( path )) { // Path didn't work. Trying as a name KService::Ptr serv = KService::serviceByDesktopName( arg ); if ( serv ) path = serv->entryPath(); else { cerr << i18n("Module %1 not found!").arg(arg) << endl; return -1; } } args->clear(); // load the module ModuleInfo info(path); KCModule *module = ModuleLoader::module(info); if (module) { // create the dialog KCDialog dlg(module, module->buttons(), info.docPath(), 0, 0, true); dlg.setCaption(info.name()); // Needed for modules that use d'n'd (not really the right // solution for this though, I guess) dlg.setAcceptDrops(true); // run the dialog return dlg.exec(); } return 0;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/1ee68e6d695e1f430161296a51d8011293816068/kcmshell.cpp/clean/kcontrol/kcontrol/kcmshell.cpp
return dlg.exec();
int ret = dlg.exec(); ModuleLoader::unloadModule(info); return ret;
int main(int _argc, char *_argv[]){ KCmdLineArgs::init( _argc, _argv, "kcmshell", I18N_NOOP("A tool to start single kcontrol modules"), "2.0pre" ); KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. KLocale::setMainCatalogue("kcontrol"); KApplication app; // It has to be unset, if not it will break modules like kcmlocale KLocale::setMainCatalogue(0); KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); if (args->isSet("list")) { QStringList files; KGlobal::dirs()->findAllResources("apps", "Settings/*.desktop", true, true, files); QStringList modules; QStringList descriptions; uint maxwidth = 0; for (QStringList::ConstIterator it = files.begin(); it != files.end(); it++) { if (KDesktopFile::isDesktopFile(*it)) { KDesktopFile file(*it, true); QString module = *it; if (module.left(9) == "Settings/") module = module.mid(9); if (module.right(8) == ".desktop") module.truncate(module.length() - 8); modules.append(module); if (module.length() > maxwidth) maxwidth = module.length(); descriptions.append(QString("%2 (%3)").arg(file.readName()).arg(file.readComment())); } } QByteArray vl; vl.fill(' ', 80); QString verylong = vl; for (uint i = 0; i < modules.count(); i++) { cout << (*modules.at(i)).latin1(); cout << verylong.left(maxwidth - (*modules.at(i)).length()); cout << " - "; cout << (*descriptions.at(i)).local8Bit(); cout << endl; } return 0; } if (args->count() != 1) { args->usage(); return -1; } QCString arg = args->arg(0); // locate the desktop file //QStringList files; if (arg[0] == '/') { kdDebug() << "Full path given to kcmshell - not supported yet" << endl; // (because of KService::findServiceByDesktopPath) //files.append(args->arg(0)); } QCString path = "Settings/"; path += arg; path += ".desktop"; /* else files = KGlobal::dirs()-> findAllResources("apps", QString("Settings/%1.desktop").arg(args->arg(0)), true); // check the matches if (files.count() > 1) cerr << i18n("Module name not unique. Taking the first match.") << endl; */ if (!KService::serviceByDesktopPath( path )) { // Path didn't work. Trying as a name KService::Ptr serv = KService::serviceByDesktopName( arg ); if ( serv ) path = serv->entryPath(); else { cerr << i18n("Module %1 not found!").arg(arg) << endl; return -1; } } args->clear(); // load the module ModuleInfo info(path); KCModule *module = ModuleLoader::module(info); if (module) { // create the dialog KCDialog dlg(module, module->buttons(), info.docPath(), 0, 0, true); dlg.setCaption(info.name()); // Needed for modules that use d'n'd (not really the right // solution for this though, I guess) dlg.setAcceptDrops(true); // run the dialog return dlg.exec(); } return 0;}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/1ee68e6d695e1f430161296a51d8011293816068/kcmshell.cpp/clean/kcontrol/kcontrol/kcmshell.cpp
QVector<ConnectionHandler> handler;
QPtrVector<ConnectionHandler> handler;
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; 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; 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";}
3322 /local/tlutelli/issta_data/temp/c/2005_temp/2005/3322/873f87cb3f46438ac9fc75d218b12f18fff133a2/kdesud.cpp/buggy/kdesu/kdesud/kdesud.cpp
#ifdef Q_OS_MACX QString PKGDATAPATH = qApp->applicationDirPath() + "/share/qgis"; #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();#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; // "QgisApp" used to find canonical instance qgis->setName( "QgisApp" ); a.setMainWidget(qgis); ///////////////////////////////////////////////////////////////////// // 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; // 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();}
1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/3be0826be266536595ea3d3445ee029550d99386/main.cpp/buggy/src/main.cpp
#ifdef Q_OS_MACX
#if defined(Q_OS_MACX) || defined(WIN32)
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 because you have no DISPLAY environment variable set." << std::endl; } QApplication a(argc, argv, myUseGuiFlag ); // a.setFont(QFont("helvetica", 11));#ifdef Q_OS_MACX QString PKGDATAPATH = qApp->applicationDirPath() + "/share/qgis";#endif 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; // "QgisApp" used to find canonical instance qgis->setName( "QgisApp" ); a.setMainWidget(qgis); ///////////////////////////////////////////////////////////////////// // 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; // 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();}
1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/ecba5c0a326a197b4347302ec884949cec023001/main.cpp/buggy/src/main.cpp
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 because you have no DISPLAY environment variable set." << std::endl; } QApplication a(argc, argv, myUseGuiFlag ); // a.setFont(QFont("helvetica", 11));#ifdef Q_OS_MACX QString PKGDATAPATH = qApp->applicationDirPath() + "/share/qgis";#endif 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; // "QgisApp" used to find canonical instance qgis->setName( "QgisApp" ); a.setMainWidget(qgis); ///////////////////////////////////////////////////////////////////// // 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; // 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();}
1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/ecba5c0a326a197b4347302ec884949cec023001/main.cpp/buggy/src/main.cpp
#ifdef QGISDEBUG std::cout << "Setting translation to " << PKGDATAPATH << "/i18n/qgis_" << QTextCodec::locale() << std::endl; #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();#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 because you have no DISPLAY environment variable set." << std::endl; } QApplication a(argc, argv, myUseGuiFlag ); // a.setFont(QFont("helvetica", 11));#ifdef Q_OS_MACX QString PKGDATAPATH = qApp->applicationDirPath() + "/share/qgis";#endif 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; // "QgisApp" used to find canonical instance qgis->setName( "QgisApp" ); a.setMainWidget(qgis); ///////////////////////////////////////////////////////////////////// // 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; // 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();}
1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/ecba5c0a326a197b4347302ec884949cec023001/main.cpp/buggy/src/main.cpp
#ifdef QGISDEBUG printf("Trying to load file : %s\n", myLayerName); #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 print some help text to console and exit // without doing anything further int myHelpFlag=false; // 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, &myHelpFlag, 1}, /* 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 '?': myHelpFlag=1; break; default: abort (); } } // Add any remaining args to the file list - we will attempt to load them // as layers in the map view further down.... if (optind < argc) { while (optind < argc) 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(); a.setMainWidget(qgis); ///////////////////////////////////////////////////////////////////// // Print help text and exit if so required - program will terminate afterwards ///////////////////////////////////////////////////////////////////// if (myHelpFlag) { std::cout << "Quantum GIS - Version 0.2 'Pumpkin'" << std::endl; std::cout << "Quantum GIS (QGIS) is a viewer for spatial data sets, including" << std::endl; std::cout << "raster and vector data." << std::endl << std::endl; std::cout << "Usage: qgis --help | --snapshot filename | [--project filename.qgs] [--lang iso-language-name] [FILES]" << std::endl ; std::cout << " --help - Display help (this information)" << std::endl ; std::cout << " FILES:" << std::endl ; std::cout << " Files specified on the command line can include rasters, " << std::endl ; std::cout << " vectors, and QGIS project files (.qgs): " << std::endl ; std::cout << " 1. Rasters - Supported formats include GeoTiff, DEM " << std::endl ; std::cout << " and others supported by GDAL" << std::endl ; return 0; } ///////////////////////////////////////////////////////////////////// // Load a project file if one was specified ///////////////////////////////////////////////////////////////////// if(myProjectFileName!="") { qgis->addProject(myProjectFileName); } ///////////////////////////////////////////////////////////////////// // autoload any filenames that were passed in on the command line ///////////////////////////////////////////////////////////////////// for ( QStringList::Iterator myIterator = myFileList->begin(); myIterator != myFileList->end(); ++myIterator ) { QString myLayerName = *myIterator;#ifdef QGISDEBUG printf("Trying to load file : %s\n", myLayerName);#endif // 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(myProjectFileName!="") { qgis->saveMapAsImage(mySnapshotFileName); return 1; } ///////////////////////////////////////////////////////////////////// // Continue on to interactive gui... ///////////////////////////////////////////////////////////////////// qgis->show(); a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit())); // //turn control over to the main application loop... // int result = a.exec(); return result;}
1753 /local/tlutelli/issta_data/temp/c/2005_temp/2005/1753/41cd5c408da6a4e8ef1e05c2bfb7f2b819785637/main.cpp/buggy/src/main.cpp