bool djvConvertContext::commandLineParse(QStringList & in) throw (QString) { //DJV_DEBUG("djvConvertContext::commandLineParse"); //DJV_DEBUG_PRINT("in = " << in); if (! djvImageContext::commandLineParse(in)) return false; if (in.isEmpty()) { print("\n" + commandLineHelp()); return false; } QStringList args; QString arg; try { while (! in.isEmpty()) { in >> arg; // Parse the options. if ( qApp->translate("djvConvertContext", "-mirror_h") == arg) { _options.mirror.x = true; } else if ( qApp->translate("djvConvertContext", "-mirror_v") == arg) { _options.mirror.y = true; } else if ( qApp->translate("djvConvertContext", "-scale") == arg) { in >> _options.scale.x; _options.scale.y = _options.scale.x; } else if ( qApp->translate("djvConvertContext", "-scale_separate") == arg) { in >> _options.scale; }
/* processCommandLine (argc, argv) ** ** This routine processes the command line options. */ void processCommandLine (int argc, char ** argv) { int argCount; /* Each iteration of this loop looks at the next argument. In some cases (like "-o a.out") one iteration will scan two tokens. */ for (argc--, argv++; argc > 0; argc -= argCount, argv += argCount) { argCount = 1; /* Scan the -h option */ if (!strcmp (*argv, "-h")) { commandLineHelp (); exit (1); /* Scan the -d option, which should be followed by a file name */ } else if (!strcmp (*argv, "-d")) { if (argc <= 1) { badOption ("Expecting filename after -d option"); } else { argCount++; if (diskFileName == NULL) { diskFileName = *(argv+1); } else { badOption ("Invalid command line - multiple DISK files"); } } /* Scan the -w option, which should be followed by a file name and an integer */ } else if (!strcmp (*argv, "-w")) { if (commandOptionW) { badOption ("Invalid command line - multiple occurences of -w"); } else { commandOptionW = 1; if (argc <= 1) { badOption ("Expecting UnixFileName after -w option"); } else if (argc <= 2) { badOption ("Expecting SectorNumber after -w UnixFileName"); } else { argCount++; argCount++; unixFileName = *(argv+1); startingSectorNumber = atoi (*(argv+2)); /* Extra chars after int ignored */ } } /* Scan the -c option, which should be followed by a file name and an integer */ } else if (!strcmp (*argv, "-c")) { if (commandOptionC) { badOption ("Invalid command line - multiple occurences of -c"); } else { commandOptionC = 1; if (argc <= 1) { badOption ("Expecting BlitzFileName after -c option"); } else if (argc <= 2) { badOption ("Expecting an integer (the size in bytes) after -c BlitzFileName"); } else { argCount++; argCount++; blitzFileName = *(argv+1); sizeInBytes = atoi (*(argv+2)); /* Extra chars after int ignored */ } } /* Scan the -a option, which should be followed by two file names */ } else if (!strcmp (*argv, "-a")) { if (commandOptionA) { badOption ("Invalid command line - multiple occurences of -a"); } else { commandOptionA = 1; if (argc <= 1) { badOption ("Expecting UnixFileName after -a option"); } else if (argc <= 2) { badOption ("Expecting BlitzFileName after -a UnixFileName"); } else { argCount++; argCount++; unixFileName = *(argv+1); blitzFileName = *(argv+2); } } /* Scan the -e option, which should be followed by two file names */ } else if (!strcmp (*argv, "-e")) { if (commandOptionE) { badOption ("Invalid command line - multiple occurences of -e"); } else { commandOptionE = 1; if (argc <= 1) { badOption ("Expecting BlitzFileName after -e option"); } else if (argc <= 2) { badOption ("Expecting UnixFileName after -e BlitzFileName"); } else { argCount++; argCount++; blitzFileName = *(argv+1); unixFileName = *(argv+2); } } /* Scan the -r option, which should be followed by a file name */ } else if (!strcmp (*argv, "-r")) { if (commandOptionR) { badOption ("Invalid command line - multiple occurences of -r"); } else { commandOptionR = 1; if (argc <= 1) { badOption ("Expecting FileName after -r option"); } else { argCount++; blitzFileName = *(argv+1); } } /* Scan the -l option */ } else if (!strcmp (*argv, "-l")) { if (commandOptionL) { badOption ("Invalid command line - multiple occurences of -l"); } else { commandOptionL = 1; } /* Scan the -v option */ } else if (!strcmp (*argv, "-v")) { if (commandOptionV) { badOption ("Invalid command line - multiple occurences of -v"); } else { commandOptionV = 1; } /* Scan the -i option */ } else if (!strcmp (*argv, "-i")) { if (commandOptionI) { badOption ("Invalid command line - multiple occurences of -i"); } else { commandOptionI = 1; } /* Anything remaining else on the command line is invalid */ } else { fprintf ( stderr, "BLITZ Disk Utility Error: Invalid command line option (%s); Use -h for help display\n", *argv); exit (1); } } /* Figure out the name of the DISK file. */ if (diskFileName == NULL) { diskFileName = "DISK"; } /* Make sure that only one of -i, -l, -c, -r, -a, -e, -w was used. */ if (commandOptionI + commandOptionL + commandOptionC + commandOptionR + commandOptionA + commandOptionE + commandOptionW != 1) { badOption ("Invalid command line - Must use exactly one of -i, -l, -c, -r, -a, -e, -w"); } }