int main(int argc, char** argv) { QApplication app(argc, argv); app.setWindowIcon(QIcon::fromTheme(QStringLiteral("plasmadiscover"))); app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); app.setAttribute(Qt::AA_UseHighDpiPixmaps, true); KCrash::initialize(); KLocalizedString::setApplicationDomain("plasma-discover"); KAboutData about(QStringLiteral("discover"), i18n("Discover"), version, i18n("An application explorer"), KAboutLicense::GPL, i18n("© 2010-2016 Plasma Development Team")); about.addAuthor(i18n("Aleix Pol Gonzalez"), QString(), QStringLiteral("*****@*****.**")); about.addAuthor(i18n("Jonathan Thomas"), QString(), QStringLiteral("*****@*****.**")); about.setProductName("discover/discover"); KAboutData::setApplicationData(about); DiscoverMainWindow *mainWindow = nullptr; { QScopedPointer<QCommandLineParser> parser(createParser()); parser->process(app); about.processCommandLine(parser.data()); DiscoverBackendsFactory::processCommandLine(parser.data(), parser->isSet(QStringLiteral("test"))); if (parser->isSet(QStringLiteral("test"))) { QStandardPaths::setTestModeEnabled(true); } KDBusService* service = new KDBusService(KDBusService::Unique, &app); mainWindow = new DiscoverMainWindow(s_decodeCompactMode->value(parser->value(QStringLiteral("compact")), DiscoverMainWindow::Full)); QObject::connect(&app, &QCoreApplication::aboutToQuit, mainWindow, &DiscoverMainWindow::deleteLater); QObject::connect(service, &KDBusService::activateRequested, mainWindow, [mainWindow](const QStringList &arguments, const QString &/*workingDirectory*/){ mainWindow->rootObject()->raise(); if (arguments.isEmpty()) return; QScopedPointer<QCommandLineParser> parser(createParser()); parser->process(arguments); processArgs(parser.data(), mainWindow); }); processArgs(parser.data(), mainWindow); if(parser->isSet(QStringLiteral("listmodes"))) { QTextStream(stdout) << i18n("Available modes:\n"); foreach(const QString& mode, mainWindow->modes()) QTextStream(stdout) << " * " << mode << '\n'; return 0; } if (parser->isSet(QStringLiteral("test"))) { const QUrl testFile = QUrl::fromUserInput(parser->value(QStringLiteral("test")), {}, QUrl::AssumeLocalFile); Q_ASSERT(!testFile.isEmpty() && testFile.isLocalFile()); mainWindow->loadTest(testFile); } }
int main(int argc, char *argv[]){ PaStream *stream; sharedBuffer = (Packet *)malloc(sizeof(Packet) * BUFFER_SIZE); processArgs(argc, argv); if (!startAudio(stream, argv[1])){ exit(1); } // TODO - get rid of glut stuff and set up context manually setupGlut(argc, argv); GLenum err = glewInit(); if (GLEW_OK != err){ fprintf(stderr, "GLEW Error: %s\n", glewGetErrorString(err)); exit(1); } SetupRC(); glutMainLoop(); free(sharedBuffer); endAudio(stream); exit(0); }
/* a tester */ int main(int argc, char **argv) { int n=0; char infile[9]="infile value"; char outfile[256]="outfile value"; float fl=-1.0; double dbl = -1.0; int flag = 0; //Add arguments addArg("infile", 'i', 1, 's', infile, sizeof(infile), "input file name"); addArg("outfile", 'o', 1, 's', outfile, sizeof(infile), "output file name"); addArg("nSPUs", 'n', 1, 'i', &n, 0, "number of SPUs"); addArg("floater", 0, 1, 'f', &fl, 0, "floating number"); addArg("doubler", 'k', 1, 'd', &dbl, 0, "double number"); addArg("justFlag",'F', 0, 0, &flag, 0, "just a flag"); // print the argument help printArgs(); // process (and free) arguments processArgs(argc,argv); // print the variables in the code printf("Got n = %d\n",n); printf("Got fl = %f\n",fl); printf("Got dbl = %lf\n",dbl); printf("Got flag = %d\n",flag); printf("Got infile = %s\n",infile); printf("Got outfile = %s\n",outfile); printf("\n\n"); return 0; }
int main(int argc, char** argv) { processArgs(argc,argv); if (detach) child = fork(); if (!child) run(); // We are the child if we don't have a child so run debug("Shutting down"); return 0; }
int main( int argc, char** argv ) { int i, *inputPermutation, *permutation; processArgs(argc,argv); M2_MAX = NUM_PACKETS*(NUM_PACKETS-1)/2; if (0 == NUM_PACKETS % 2) // even M3_MAX = (NUM_PACKETS*NUM_PACKETS)/2; else // odd M3_MAX = (NUM_PACKETS*NUM_PACKETS - 1)/2; inputPermutation = (int*)malloc(sizeof(int)*NUM_PACKETS); permutation = (int*)malloc(sizeof(int)*NUM_PACKETS); /* init */ for (i=0;i<NUM_PACKETS;i++) inputPermutation[i] = i; // init initial permutation in perfect order m2_histogram = (int*)malloc(sizeof(int)*M2_MAX); m3_histogram = (int*)malloc(sizeof(int)*M3_MAX); /* initial call to permute items */ permuteAndMeasure(permutation, 0, inputPermutation); showFinalStats(); return EXIT_SUCCESS; }
int main(int argc, char **argv) { srand(time(NULL)); printIntro(); initStats(); processArgs(argc, argv); // Start the packet processor pthread_t packet_processor; pthread_create(&packet_processor, NULL, process_incoming, NULL); // Start the syn flood thread pthread_t syn_sender; pthread_create(&syn_sender, NULL, send_syns, NULL); pthread_t status_update; pthread_create(&status_update, NULL, print_status, NULL); // Wait for the threads to return, which is never. pthread_join(syn_sender, NULL); pthread_join(packet_processor, NULL); pthread_join(status_update, NULL); return 0; }
/** * Program entry point. */ int main(int argc, char *argv[ ]) { SetupSharedThread::install(); SetupSharedDebug::install(4096); { SetupSharedFoundation::Data data(SetupSharedFoundation::Data::D_console); #ifdef WIN32 char buffer[1024]; GetModuleFileName(GetModuleHandle(NULL), buffer, 1024); Filename configName; configName.setName(buffer); configName.setName("templateCompiler.cfg"); data.configFile = configName.getFullFilename().c_str(); #endif SetupSharedFoundation::install (data); } SetupSharedRegex::install(); SetupSharedCompression::install(); SetupSharedFile::install(false); // setup the random number generator // @todo need a better seed SetupSharedRandom::install(static_cast<uint32>(time(NULL))); int result = processArgs(argc, argv); // cleanup SetupSharedFoundation::remove(); PerThreadData::threadRemove(); return result; } // main
int main(int argc, char *argv[]) { unsigned val; nf2.device_name = DEFAULT_IFACE; processArgs(argc, argv); // Open the interface if possible if (check_iface(&nf2)) { exit(1); } if (openDescriptor(&nf2)) { exit(1); } // Increment the argument pointer argc -= optind; argv += optind; // Read the registers readRegisters(argc, argv); closeDescriptor(&nf2); return 0; }
int main(int argc, char *argv[]) { nf2.device_name = DEFAULT_IFACE; processArgs(argc, argv); // Open the interface if possible if (check_iface(&nf2)) { exit(1); } if (openDescriptor(&nf2)) { exit(1); } if(argc > 5){ printf("Numero de argumentos deve ser < 4\n"); argc=5; } for(int i=0; i< argc-1; i++){ pdrop[i] = atoi(argv[i+1]); } dumpCounts(); closeDescriptor(&nf2); return 0; }
/* Checks for commandline args, intializes globals, then begins code download. */ int main(int argc, char **argv) { nf2.device_name = DEFAULT_IFACE; processArgs(argc, argv); if (check_iface(&nf2)) { exit(1); } if (openDescriptor(&nf2)) { exit(1); } if (strncmp(log_file_name, "stdout",6)) { if ((log_file = fopen(log_file_name, "w")) == NULL) { printf("Error: unable to open logfile %s for writing.\n", log_file_name); exit(1); } } else log_file = stdout; InitGlobals(); BeginCodeDownload(bin_file_name); if (!cpci_reprog) ResetDevice(); /* reset the PHYs */ NF2_WR32(MDIO_0_CONTROL_REG, 0x8000); NF2_WR32(MDIO_1_CONTROL_REG, 0x8000); NF2_WR32(MDIO_2_CONTROL_REG, 0x8000); NF2_WR32(MDIO_3_CONTROL_REG, 0x8000); /* wait until the resets have been completed */ usleep(100); if (intr_enable) { /* PHY interrupt mask off for link status change */ NF2_WR32(MDIO_0_INTERRUPT_MASK_REG, 0xfffd); NF2_WR32(MDIO_1_INTERRUPT_MASK_REG, 0xfffd); NF2_WR32(MDIO_2_INTERRUPT_MASK_REG, 0xfffd); NF2_WR32(MDIO_3_INTERRUPT_MASK_REG, 0xfffd); } VerifyDevInfo(); fclose(log_file); closeDescriptor(&nf2); return SUCCESS; }
int main(int argc,char* argv[]) { FILE *fIN=NULL; FILE *fOUT=NULL; if(processArgs(argc,argv,&fIN,&fOUT)) readf(fIN); return 0; }
int main(int argc, char * argv[]) { Args args; processArgs(argc, argv, args); processFile(args.inputFile); return 0; }
int main(int argc, char **argv) { g_error1 = 0.01f; g_error2 = g_error1; processArgs( argc, argv ); OSG::osgInit(argc,argv); // GLUT init glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); int winid = glutCreateWindow("OpenSG"); glutReshapeFunc(reshape); glutDisplayFunc(display); glutIdleFunc(display); glutMouseFunc(mouse); glutMotionFunc(motion); glutKeyboardFunc(keyboard); { OSG::GLUTWindowRefPtr gwin = OSG::GLUTWindow::create(); gwin->setGlutId(winid); gwin->init(); // create the scene OSG::NodeRefPtr scene; scene = makeScene( ); if ( scene == NULL ) { std::cerr<<"makeScene returned NullFC, exiting..."<<std::endl; return -1; } // create the SimpleSceneManager helper mgr = new OSG::SimpleSceneManager; // create the window and initial camera/viewport mgr->setWindow( gwin ); // tell the manager what to manage mgr->setRoot ( scene ); // show the whole scene mgr->showAll(); mgr->redraw(); OSG::SolidBackgroundRefPtr bgr = OSG::SolidBackground::create(); bgr->setColor( OSG::Color3f( 0.7f, 0.7f, 0.7f )); mgr->getWindow()->getPort(0)->setBackground( bgr ); } // GLUT main loop glutMainLoop(); return 0; }
// usage : ray [option] in.ray out.bmp // Simply keying in ray will invoke a graphics mode version. // Use "ray --help" to see the detailed usage. // OK. I am lying. any illegal option such as "ray blahbalh" will print // out the usage // // Graphics mode will be substantially slower than text mode because of // event handling overhead. int main(int argc, char **argv) { progname=argv[0]; srand((unsigned)time(NULL)); if (argc!=1) { // text mode if (!processArgs(argc, argv)) { usage(); exit(1); } theRayTracer=new RayTracer(); theRayTracer->loadScene(rayName); if (theRayTracer->sceneLoaded()) { g_height = (int)(g_width / theRayTracer->aspectRatio() + 0.5); theRayTracer->traceSetup(g_width, g_height, 2, 1.0, 0.0001); clock_t start, end; start=clock(); theRayTracer->traceLines(0, g_height); end=clock(); // save image unsigned char* buf; theRayTracer->getBuffer(buf, g_width, g_height); if (buf) writeBMP(imgName, g_width, g_height, buf); if (bReport) { double t=(double)(end-start)/CLOCKS_PER_SEC; #ifdef WIN32 fl_message( "total time = %.3f seconds\n", t); #else fprintf( stderr, "total time = %.3f seconds\n", t); #endif } } return 1; } else { // graphics mode traceUI=new TraceUI(); theRayTracer=new RayTracer(); traceUI->setRayTracer(theRayTracer); Fl::visual(FL_DOUBLE|FL_INDEX); traceUI->show(); return Fl::run(); } }
int main(int argc, char *argv[]) { processArgs(argc, argv); cout << " NumIters " << NumIters << "," << " NumEntries " << NumEntries << endl; if (LockType == FallbackLock::MUTEX_LOCK) { GLock = new MutexFallbackLock(PmxLock); cout << "Allocated Pthread Mutex lock" << endl; } else if (LockType == FallbackLock::SPIN_LOCK) { GLock = new SpinFallbackLock(PspLock); cout << "Allocated Pthread Spin lock" << endl; } else if (LockType == FallbackLock::HLE_LOCK) { GLock = new HLELock(); cout << "Allocated HLE Spin lock" << endl; } else if (LockType == FallbackLock::CUSTOM_LOCK) { GLock = new CustomSpinLock(); cout << "Allocated Custom Spin lock" << endl; } else { cerr << "Error: invalid lock type specified, exiting..." << LockType; } SharedTable = new KaLib::HashTable<int>( NumEntries * NumThreads, GLock); for (int ec = NumThreads * NumEntries; ec > 0; --ec) { int v = rand(); SharedTable->insert(ec, v); } ThreadWorker_t worker = executeThreadLoopSimple; Timer coreTimer("Workers"); coreTimer.Start(); createWorkerThreads(NumThreads, worker); waitForThreads(NumThreads); coreTimer.Stop(); Timer checker("VerifyHashTable"); checker.Start(); checkTable(*SharedTable, NumThreads, NumEntries); checker.Stop(); delete SharedTable; coreTimer.PrintElapsedTime("RESULT: Filling up the hash table finished in "); checker.PrintElapsedTime("Verification of Hash table done in "); return 0; }
void MainWindow::dropEvent(QDropEvent* evt) { if(evt->mimeData()->hasUrls()){ QStringList paths; foreach(const QUrl& url, evt->mimeData()->urls()){ paths << url.toLocalFile(); } processArgs(paths); }
void Config::init(const QStringList *const args) { resetToDefaults(); QByteArray envSslCertDir = qgetenv("SSL_CERT_DIR"); if (!envSslCertDir.isEmpty()) setSslCertificatesPath(envSslCertDir); processArgs(*args); }
int main(int argc, char *argv[]) { int result = processArgs(argc, argv); if(result > 0) { QString fullVer = QString(QString::number(NVER1) + "." + QString::number(NVER2) + "." + QString::number(NVER3) + "." + QString::number(NVER4)); Translator a(argc, argv, "ZmqTcpTranslator_ver." + fullVer); return a.exec(); } return result; }
int main(int argc,char* argv[]) { FILE* fIN=NULL; FILE* fOUT=NULL; int n; if(processArgs(argc,argv,&fIN,&fOUT)) { double* array=readinp(fIN,&n); int beg=0;int end=n-1; double fin=divide(array,beg,end); fprintf(fOUT,"%g",fin); } return 0; }
// This fuction is used as the main loop in all game states. const StateEvent& BaseState::start(const StateArgs& args) { stateEvent.reset(); // Must reset the event in case the state still existed in memory after this returned processArgs(args); onStart(); handleEvents(); while (stateEvent.shouldContinue()) { update(); draw(); handleEvents(); // This is last so it doesn't have to update and draw an extra frame if the state is supposed to change } return stateEvent; }
int main (int argc, char * const argv[]) { GLTF::GLTFConverterContext converterContext; if (processArgs(argc, argv, &converterContext)) { if (converterContext.inputFilePath.length() == 0) { return -1; } const char* inputFilePathCStr = converterContext.inputFilePath.c_str(); if (!fileExists(converterContext.inputFilePath.c_str())) { printf("path:%s does not exists or is not accessible, please check file path and permissions\n",inputFilePathCStr); return -1; } clock_t start = clock(); #if !STDOUT_OUTPUT FILE* fd = fopen(converterContext.outputFilePath.c_str(), "w"); if (fd) { rapidjson::FileStream s(fd); #else rapidjson::FileStream s(stdout); #endif rapidjson::PrettyWriter <rapidjson::FileStream> jsonWriter(s); if (converterContext.outputProgress) { printf("convertion 0%%"); printf("\n\033[F\033[J"); } else { printf("converting:%s ... as %s \n",converterContext.inputFilePath.c_str(), converterContext.outputFilePath.c_str()); } GLTF::COLLADA2GLTFWriter* writer = new GLTF::COLLADA2GLTFWriter(converterContext, &jsonWriter); writer->write(); if (converterContext.outputProgress) { printf("convertion 100%%"); printf("\n"); } else { printf("[completed conversion]\n"); } #if !STDOUT_OUTPUT fclose(fd); delete writer; } #endif std::stringstream s; s << std::setiosflags(std::ios::fixed) << std::setprecision(2) << float(clock() - start) / CLK_TCK; std::cout << "Runtime: " << s.str() << " seconds" << std::endl; } return 0; }
int main( int argc, char** argv ) { int i, *inputPermutation, *permutation, total_permutations=1; processArgs(argc,argv); //output first line of output for (i=1;i<=NUM_PACKETS;i++) total_permutations *= i; printf("%d %d %d // numNodes(or hops) numPackets numSuccessfulRuns(or data sets)\n",1,NUM_PACKETS,total_permutations); inputPermutation = (int*)malloc(sizeof(int)*NUM_PACKETS); permutation = (int*)malloc(sizeof(int)*NUM_PACKETS); /* init */ for (i=0;i<NUM_PACKETS;i++) inputPermutation[i] = i; // init initial permutation in perfect order /* initial call to permute items */ makePermutation(permutation, 0, inputPermutation); return EXIT_SUCCESS; }
int main(int argc, char **argv) { QApplication app(argc, argv); QApplication::setApplicationName("Animator"); QApplication::setApplicationVersion("1.0"); QStringList files; float duration; float fps; std::tie(files, duration, fps) = processArgs(app); Animator animator(files, duration, fps); animator.show(); return app.exec(); }
int main(int argc, char *argv[]) { if (argc < 2) { return error( "usage: [path] [extensions]\n" "\tOR [filename]\n" //"usage: [filenames]\n" //"\tOR [path] -ext [extensions]\n" "Available options are: \n" " -mode EOL mode (unix, dos, mac)\n" " -skiperrors skip any errors when processing files\n" " -nolog hide logs (can increase speed)" // TODO: //" -depth max directory depth (-1 by default)\n" //" -b make backups\n" //" -bext backup extension (\"bak\" by default)\n" //" -bdir backup directory\n" //" -perf output processing time\n" ); } if (processArgs(argc, argv)) return 1; if (!createTempFile()) return error("failed to create a temporary file"); int res = 0; if (SearchFiles) { res = searchRecursive(searchpath, extensions); } else { if (!processFile(searchpath)) res = error("unable to open file"); } deleteTempFile(); return res; }
int main(int argc, char **argv) { #if !defined(Q_OS_WIN) // QtService stores service settings in SystemScope, which normally require root privileges. // To allow testing this example as non-root, we change the directory of the SystemScope settings file. QSettings::setPath(QSettings::NativeFormat, QSettings::SystemScope, QDir::tempPath()); qWarning("(Example uses dummy settings file: %s/QtSoftware.conf)", QDir::tempPath().toLatin1().constData()); #endif int result = processArgs(argc, argv); if (QString::fromLocal8Bit(argv[argc - 1]) == QLatin1String("-w") || QString::fromLocal8Bit(argv[argc - 1]) == QLatin1String("-wait")) { printf("\nPress Enter to continue..."); QFile input; input.open(stdin, QIODevice::ReadOnly); input.readLine(); printf("\n"); } return result; }
void CMain::exec() { ASSERT_THROW(m_parameters, ENOT_INITIALIZED); switch(m_cl_parse_result) { case Parse_none_found: printHelp(); break; case Parse_unknown_command: wrongUsage("Unknown command: %s", m_parameters->getUnknownCommand().c_str()); break; case Parse_success: if(m_parameters->getSwitch("help")) { printHelp(); } else if(m_parameters->getSwitch("version")) { printVersion(); } else { processArgs(); } break; } }
std::string ExecuteProcess(const std::string& file, std::vector<std::string> args) { // "The first argument, by convention, should point to // the filename associated with the file being executed." // NOTE: // spaces in the first argument or quoted file paths // are not supported on Windows, so translate <file> // to a short path there args.insert(args.begin(), GetShortFileName(file)); // "The array of pointers must be terminated by a NULL pointer." // --> include one extra argument string and leave it NULL std::vector<char*> processArgs(args.size() + 1, NULL); std::string execError; for (size_t a = 0; a < args.size(); ++a) { const std::string& arg = args[a]; const size_t argSize = arg.length() + 1; STRCPY_T(processArgs[a] = new char[argSize], argSize, arg.c_str()); } #ifdef WIN32 #define EXECVP _execvp #else #define EXECVP execvp #endif if (EXECVP(args[0].c_str(), &processArgs[0]) == -1) { LOG("[%s] error: \"%s\" %s (%d)", __FUNCTION__, args[0].c_str(), (execError = strerror(errno)).c_str(), errno); } #undef EXECVP for (size_t a = 0; a < args.size(); ++a) { delete[] processArgs[a]; } return execError; }
int main(int argc, char *argv[]) { nf2.device_name = DEFAULT_IFACE; processArgs(argc, argv); if (check_iface(&nf2)) { exit(1); } if (openDescriptor(&nf2)) { exit(1); } nf2_read_info(&nf2); display_info(&nf2); closeDescriptor(&nf2); return 0; }
int main( int argc, char** argv ) { if( processArgs( argc, argv ) ) { INPUT mouseMove = {}; mouseMove.type = INPUT_MOUSE; mouseMove.mi.dwFlags = MOUSEEVENTF_MOVE; printf( "MouseMover version %d.%d, use -h for help\n", MAJOR_VERSION, MINOR_VERSION ); printf( "Moving mouse every %d seconds...\n", waitTime / 1000 ); bool left = true; while( 1 ) { if( left ) { mouseMove.mi.dx = -10; mouseMove.mi.dy = -10; } else { mouseMove.mi.dx = 10; mouseMove.mi.dy = 10; } left = !left; SendInput( 1, &mouseMove, sizeof( mouseMove ) ); Sleep( waitTime ); } } return 0; }
/*! If this class hasn't been initialized in another instance, it performs the following operations: - creates a new MainWindow, - starts Coin by initializing SoQt, - initializes our Coin add on classes, - creates a new IVmgr, - sets the focus policy of the SoQt viewer so keyboard events are accepted - calls a method to process the command line arguments. */ GraspItGUI::GraspItGUI(int argc,char **argv) : mDispatch(NULL) { if (!initialized) { mainWindow = new MainWindow; SoQt::init(mainWindow->mWindow); // initialize my Inventor additions SoComplexShape::initClass(); SoArrow::initClass(); SoTorquePointer::initClass(); ivmgr = new IVmgr((QWidget *)mainWindow->mUI->viewerHolder,"myivmgr"); // mainWindow->viewerHolder->setFocusProxy(ivmgr->getViewer()->getWidget()); // mainWindow->viewerHolder->setFocusPolicy(QWidget::StrongFocus); ivmgr->getViewer()->getWidget()->setFocusPolicy(Qt::StrongFocus); initialized = true; graspItGUI = this; mExitCode = 0; initResult = processArgs(argc,argv); } }