Esempio n. 1
0
int verif (char *tab[],int n) {

	int i;
	for(i=0;i<n;i++)
		{
			if(optionHelp(tab[i])) return 1;
		}
	return 0;

}
Esempio n. 2
0
File: main.cpp Progetto: kost/massws
int main (int argc, char *argv[]) {
	QApplication::setApplicationName("massws");
	QApplication::setApplicationVersion("1.0");

	QCommandLineParser parser;
	parser.setApplicationDescription("MassWebShotter v1.0. Copyright (C) Kost. Distributed under GPL.");
	parser.addHelpOption();
	parser.addVersionOption();

	QCommandLineOption optionHelp(QStringList() << "h" << "help",
	    QCoreApplication::translate("main", "Show help."));
	parser.addOption(optionHelp);

	QCommandLineOption optionIgnoreSSL(QStringList() << "s" << "ignoressl",
	    QCoreApplication::translate("main", "Ignore SSL verification errors"));
	parser.addOption(optionIgnoreSSL);

	QCommandLineOption optionOutputFN(QStringList() << "o" << "output",
		QCoreApplication::translate("main", "Save output to <filename>."),
   		QCoreApplication::translate("main", "filename"));
	parser.addOption(optionOutputFN);

	QCommandLineOption optionWidth(QStringList() << "x" << "width",
		QCoreApplication::translate("main", "Make screenshot with <width>."),
		QCoreApplication::translate("main", "width"));
	parser.addOption(optionWidth);

	QCommandLineOption optionHeight(QStringList() << "y" << "height",
		QCoreApplication::translate("main", "Make screenshot with <height>."),
		QCoreApplication::translate("main", "heigth"));
	parser.addOption(optionHeight);

	parser.addPositionalArgument("url", "URL to take screenshot");

	qDebug() << "Starting...\n";

	QApplication app(argc,argv);

	parser.process(app);

	if (parser.isSet(optionHelp)) {
		parser.showHelp();
		exit(0);
	}

	const QStringList positionalArguments = parser.positionalArguments();
	if (positionalArguments.isEmpty()) {
		qWarning() << "You have to specify at least one URL";
		exit(1);
	}

	qDebug() << "Taking ss..\n";

	Screenshot ss;

	if (parser.isSet(optionIgnoreSSL)) {
		ss.ignoreSSL=1;
	}
	if (parser.isSet(optionWidth)) {
		ss.sizex=parser.value(optionWidth).toInt();
	}
	if (parser.isSet(optionHeight)) {
		ss.sizey=parser.value(optionHeight).toInt();
	}

	QString urltoss=positionalArguments.first();

	if (parser.isSet(optionOutputFN)) {
		ss.filename=parser.value(optionOutputFN);
	} else {
		QString genfilename=urltoss;
		escapeFN(genfilename);
		ss.filename=genfilename + ".png";
	}

	qWarning() << "Taking screenshot of: " << urltoss << " to " << ss.filename;

	ss.takeshot(QUrl(urltoss));

	ss.myapp = &app;

	qDebug() << "Pre-exec...\n";

	app.exec();

	qDebug() << "End...\n";
}
Esempio n. 3
0
int main( int argc, char **argv )
#endif
{
    ONScripterLabel ons;

#ifdef PSP
    ons.disableRescale();
    ons.enableButtonShortCut();
#endif

#ifdef WII
    fatInitDefault();
#endif

#ifdef ENABLE_1BYTE_CHAR
    // Check filename: we want binaries named "onscripter-en" to
    // default to English mode.  We actually match the regex
    // /(^|[/\\])onscripter[^a-z]en/i, which should allow all likely
    // variants without being terribly likely to produce unexpected
    // results.
    //
    // The code is ugly because Windows, unlike other mainstream
    // platforms fails to provide basic regex support in its libc; I'm
    // loathe to add an entire third-party library just for a single
    // test, so we do this the hard way.  Thanks, Mr Gates.
    {
	char fname[256];
	strncpy(fname, argv[0], 256);
	char* it = fname + strlen(fname);
	if (it > fname + 255) it = fname + 255;
	while (it >= fname && *it != '/' && *it != '\\') --it;
	++it;
	int len = strlen(it);
	if (len >= 13) {
	    it[13] = 0;
	    for (int i = 0; i < 13; ++i) it[i] = tolower(it[i]);
	    if (it[10] < 'a' || it[10] > 'z') {
		it[10] = '-';
		if (strcmp(it, "onscripter-en") == 0) {
		    printf("Setting English mode based on filename\n");
		    ons.setEnglishMode();
		}
	    }
	}
    }
#endif

    // ----------------------------------------
    // Parse options
    bool hasArchivePath = false;
    argv++;
    while( argc > 1 ){
        if ( argv[0][0] == '-' ){
            if ( !strcmp( argv[0]+1, "h" ) || !strcmp( argv[0]+1, "-help" ) ){
                optionHelp();
            }
            else if ( !strcmp( argv[0]+1, "v" ) || !strcmp( argv[0]+1, "-version" ) ){
                optionVersion();
            }
            else if ( !strcmp( argv[0]+1, "-cdaudio" ) ){
                ons.enableCDAudio();
            }
            else if ( !strcmp( argv[0]+1, "-cdnumber" ) ){
                argc--;
                argv++;
                ons.setCDNumber(atoi(argv[0]));
            }
            else if ( !strcmp( argv[0]+1, "f" ) || !strcmp( argv[0]+1, "-font" ) ){
                argc--;
                argv++;
                ons.setFontFile(argv[0]);
            }
            else if ( !strcmp( argv[0]+1, "-registry" ) ){
                argc--;
                argv++;
                ons.setRegistryFile(argv[0]);
            }
            else if ( !strcmp( argv[0]+1, "-dll" ) ){
                argc--;
                argv++;
                ons.setDLLFile(argv[0]);
            }
#ifdef ENABLE_1BYTE_CHAR
            else if ( !strcmp( argv[0]+1, "-english" ) ){
                ons.setEnglishMode();
            }
#endif
            else if ( !strcmp( argv[0]+1, "r" ) || !strcmp( argv[0]+1, "-root" ) ){
		hasArchivePath = true;
		argc--;
                argv++;
                ons.setArchivePath(argv[0]);
            }
            else if ( !strcmp( argv[0]+1, "s" ) || !strcmp( argv[0]+1, "-save" ) ){
                argc--;
                argv++;
                ons.setSavePath(argv[0]);
            }
            else if ( !strcmp( argv[0]+1, "-fullscreen" ) ){
                ons.setFullscreenMode();
            }
            else if ( !strcmp( argv[0]+1, "-window" ) ){
                ons.setWindowMode();
            }
            else if ( !strcmp( argv[0]+1, "-force-button-shortcut" ) ){
                ons.enableButtonShortCut();
            }
            else if ( !strcmp( argv[0]+1, "-enable-wheeldown-advance" ) ){
                ons.enableWheelDownAdvance();
            }
            else if ( !strcmp( argv[0]+1, "-debug" ) ){
                ons.set_debug_level(2);
            }
            else if ( !strcmp( argv[0]+1, "-disable-rescale" ) ){
                ons.disableRescale();
            }
            else if ( !strcmp( argv[0]+1, "-edit" ) ){
                ons.enableEdit();
            }
            else if ( !strcmp( argv[0]+1, "-key-exe" ) ){
                argc--;
                argv++;
                ons.setKeyEXE(argv[0]);
            }
#ifdef RCA_SCALE
            else if ( !strcmp( argv[0]+1, "-widescreen" ) ){
                ons.setWidescreen();
            }
            else if ( !strcmp( argv[0]+1, "-scale" ) ){
                ons.setScaled();
            }
#endif
	    else if ( !strcmp( argv[0]+1, "-force-png-alpha" ) ){
		ons.setMaskType( 1 );
	    }
	    else if ( !strcmp( argv[0]+1, "-force-png-nscmask" ) ){
		ons.setMaskType( 2 );
	    }
            else{
                printf(" unknown option %s\n", argv[0] );
            }
        }
        else if (!hasArchivePath) {
	    hasArchivePath = true;
            ons.setArchivePath(argv[0]);
            argc--;
            argv++;
        }
        else{
            optionHelp();
        }
        argc--;
        argv++;
    }

#ifdef WII
    if (MainMenu(&ons) == MENU_EXIT)
	exit(0);
#endif

    // ----------------------------------------
    // Run ONScripter
    if (ons.init()) {
#ifdef WII
	SDL_ShowConsole(1);
	fprintf(stderr, "Onsripter Init Failed\n");
	while(1) {
		WPAD_ScanPads();
		u32 pressed = WPAD_ButtonsDown(0);
		if ( pressed & WPAD_BUTTON_HOME ) exit(-1);
		VIDEO_WaitVSync();
	}
#else
	exit(-1);
#endif
    }
#ifdef WII
#endif
    ons.eventLoop();
    exit(0);
}
Esempio n. 4
0
static void parseOptions(int argc, char **argv, PonscripterLabel &ons,
                         pstring &preferred_script, bool &hasArchivePath)
{
    argv++;
    while (argc > 1) {
        if (argv[0][0] == '-') {
            if (!strcmp(argv[0] + 1, "d") || !strcmp(argv[0] + 1, "-debug")) {
                ons.setDebugMode();
            }
            else if (!strcmp(argv[0] + 1, "h") || !strcmp(argv[0] + 1, "-help")) {
                optionHelp();
            }
            else if (!strcmp(argv[0] + 1, "v") || !strcmp(argv[0] + 1, "-version")) {
                optionVersion();
            }
            else if (!strcmp(argv[0] + 1, "-registry")) {
                argc--;
                argv++;
                ons.setRegistryFile(argv[0]);
            }
            else if (!strcmp(argv[0] + 1, "-dll")) {
                argc--;
                argv++;
                ons.setDLLFile(argv[0]);
            }
            else if (!strcmp(argv[0] + 1, "r") || !strcmp(argv[0] + 1, "-root")) {
                argc--;
                argv++;
                ons.setArchivePath(argv[0]);
            }
            else if (!strcmp(argv[0] + 1, "s") || !strcmp(argv[0] + 1, "-save")) {
                argc--;
                argv++;
                ons.setSavePath(argv[0]);
            }
            else if (!strcmp(argv[0] + 1, "-script")) {
                argc--;
                argv++;
                preferred_script = argv[0];
            }
#ifdef WIN32
            else if ( !strcmp( argv[0]+1, "-current-user-appdata" ) ){
                ons.setUserAppData();
            }
#endif
            else if ( !strcmp( argv[0]+1, "-use-app-icons" ) ){
                ons.setUseAppIcons();
            }
            else if (!strcmp(argv[0] + 1, "-fullscreen")) {
                ons.setFullscreenMode();
            }
            else if (!strcmp(argv[0] + 1, "-window")) {
                ons.setWindowMode();
            }
            else if ( !strcmp( argv[0]+1, "-window-width" ) ){
                argc--;
                argv++;
                ons.setPreferredWidth(argv[0]);
            }
            else if ( !strcmp( argv[0]+1, "-gameid" ) ){
                argc--;
                argv++;
                ons.setGameIdentifier(argv[0]);
            }
            else if ( !strcmp( argv[0]+1, "-nsa-offset" ) ){
                argc--;
                argv++;
                ons.setNsaOffset(argv[0]);
            }
            else if (!strcmp(argv[0] + 1, "-force-button-shortcut")) {
                ons.enableButtonShortCut();
            }
            else if (!strcmp(argv[0] + 1, "-enable-wheeldown-advance")) {
                ons.enableWheelDownAdvance();
            }
#if defined (USE_X86_GFX) || defined(USE_PPC_GFX)
            else if ( !strcmp( argv[0]+1, "-disable-cpu-gfx" ) ){
                ons.disableCpuGfx();
                printf("disabling CPU accelerated graphics routines\n");
            }
#endif
            else if (!strcmp(argv[0] + 1, "-disable-rescale")) {
                ons.disableRescale();
            }
//            else if ( !strcmp( argv[0]+1, "-allow-break-outside-loop" ) ){
//                ons.allow_break_outside_loop = true;
//            }
//            else if ( !strcmp( argv[0]+1, "-allow-color-type-only" ) ){
//                ons.allow_color_type_only = true;
//            }
//            else if ( !strcmp( argv[0]+1, "-set-tag-page-origin-to-1" ) ){
//                ons.set_tag_page_origin_to_1 = true;
//            }
//            else if ( !strcmp( argv[0]+1, "-answer-dialog-with-yes-ok" ) ){
//                ons.answer_dialog_with_yes_ok = true;
//            }
            else if (!strcmp(argv[0] + 1, "-edit")) {
                ons.enableEdit();
            }
            else if (!strcmp(argv[0] + 1, "-key-exe")) {
                argc--;
                argv++;
                ons.setKeyEXE(argv[0]);
            }
            else if (!strcmp(argv[0] + 1, "-force-png-alpha")) {
                ons.setMaskType(1);
            }
            else if (!strcmp(argv[0] + 1, "-force-png-nscmask")) {
                ons.setMaskType(2);
            }
            else {
                printf(" unknown option %s\n", argv[0]);
            }
        }
        else if (!ons.hasArchivePath() || !preferred_script) {
            // Split parameter appropriately.
            pstring path = argv[0];
            pstring file = "";
            int i = path.reversefind(DELIMITER, path.length());
            if (ons.hasArchivePath()) {
                file = path;
                path = "";
            }
            else {
                // If the item is visible and a directory, take it as
                // the archive path; otherwise assume it must be a
                // script filename.
                struct stat info;
                if (stat(path, &info) == -1 ||
                    !S_ISDIR(info.st_mode))
                {
                    if (i >= 0) {
                        file = path.midstr(i + 1, path.length() - i);
                        path.trunc(i);
                    }
                    else {
                        file = path;
                        path = "";
                    }
                }
            }
                
            if (path) ons.setArchivePath(path);
            if (file) {
                if (preferred_script)
                    optionHelp();
                else
                    preferred_script = file;
            }
        }
        else {
            optionHelp();
        }

        argc--;
        argv++;
    }
}