getopt.cpp
来自「把doc文档转成pdf后刻录成CD,用VC++开发,用了Nero的SDK和CXI」· C++ 代码 · 共 1,042 行 · 第 1/3 页
CPP
1,042 行
/******************************************************************************
|* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
|* ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
|* PARTICULAR PURPOSE.
|*
|* Copyright 1995-2004 Ahead Software AG. All Rights Reserved.
|*-----------------------------------------------------------------------------
|* NeroSDK / NeroCmd
|*
|* PROGRAM: getopt.cpp
|*
|* PURPOSE: Constructors for PARAMETERS class
|* Decoding of argument list
|* Help function
|* Parsing of parameter file
******************************************************************************/
#include "stdafx.h"
#include "getopt.h"
#include "parameters.h"
#if defined(__BORLANDC__)
#include <algorithm.h>
#endif
// Forward declarations. These are the functions used before they are
// defined.
//
static void Usage (void);
static bool ReadParameterFile (PARAMETERS & params, LPCSTR psFilename);
// These are error strings that correspond to the CLE_xxx error codes.
static LPCSTR s_cle[CLE_MAX] = {
"Everything fine.",
"Multiple commands were specified from the following set: listdrives, cdinfo, read, write, erase, eject, load. Only one command is allowed at one time.",
"Missing drive name parameter after --drivename.",
"Missing artist parameter after --artist.",
"Missing title parameter after --title.",
"Missing speed parameter after --speed.",
"Supplied speed parameter is invalid.",
"Missing volume name parameter after --iso.",
"Invalid -- parameter.",
"Multiple burn types were specified from the following set: iso/audio, videocd, svideocd, image. Only one burn type is allowed at one time.",
"Missing file name after --XX parameter.",
"Maximum number of 99 tracks has been reached.",
"Parameter file was already processed. It cannot be done recursively!",
"Missing image filename parameter after --image.",
"Missing error log filename parameter after --error_log.",
"Missing import session parameter after --import.",
"Supplied import session parameter is invalid.",
"Iso/Audio and (S)VideoCD need at least one track!",
"Burn type was not specified! Use a proper combination of --audio, --videocd, --svideocd and --iso.",
"No command was specified!",
"Missing temporary path parameter after --temp_path.",
"Missing media type parameter after --media_type.",
"Missing output image filename parameter after --output_image.",
"Missing image info filename parameter after --imageinfo.",
"Missing system identifier parameter after --system_identifier.",
"Missing volume set parameter after --volume_set.",
"Missing publisher parameter after --publisher.",
"Missing data preparer parameter after --data_preparer.",
"Missing application parameter after --application.",
"Missing copyright parameter after --copyright.",
"Missing abstract parameter after --abstract.",
"Missing bibliographic parameter after --bibliographic.",
"Missing resolution parameter after --video_resolution.",
"Bad resolution parameter after --video_resolution. Only PAL and NTSC are allowed.",
};
// This function decodes the argument list.
bool getopt (PARAMETERS & params, int argc, char ** argv)
{
if ((0 == argc) && !params.GetProcessedParameterFile())
{
Usage ();
return false;
}
COMMAND_LINE_ERRORS ecl = CLE_NO_ERROR;
try
{
for (; argc>0; argc--, argv++)
{
if (CLE_NO_ERROR != ecl)
{
throw ecl;
}
else if (stricmp (*argv, "--listdrives") == 0)
{
ecl = params.SetCommand(COMMAND_LISTDRIVES);
}
else if (stricmp (*argv, "--version") == 0)
{
ecl = params.SetCommand(COMMAND_VERSION);
}
else if (stricmp (*argv, "--cdinfo") == 0)
{
ecl = params.SetCommand(COMMAND_CDINFO);
}
else if (stricmp (*argv, "--read") == 0)
{
ecl = params.SetCommand(COMMAND_READ);
}
else if (stricmp (*argv, "--write") == 0)
{
ecl = params.SetCommand(COMMAND_WRITE);
}
else if (stricmp (*argv, "--erase") == 0)
{
ecl = params.SetCommand(COMMAND_ERASE);
}
else if (stricmp (*argv, "--eject") == 0)
{
ecl = params.SetCommand(COMMAND_EJECT);
}
else if (stricmp (*argv, "--load") == 0)
{
ecl = params.SetCommand(COMMAND_LOAD);
}
else if (stricmp (*argv, "--driveinfo") == 0)
{
ecl = params.SetCommand(COMMAND_DRIVE_INFO);
}
else if (stricmp (*argv, "--listformats") == 0)
{
ecl = params.SetCommand(COMMAND_LISTFORMATS);
}
else if (stricmp (*argv, "--get_speeds") == 0)
{
ecl = params.SetCommand(COMMAND_GET_SPEEDS);
}
else if (stricmp (*argv, "--estimate") == 0)
{
ecl = params.SetCommand(COMMAND_ESTIMATE);
}
else if (stricmp (*argv, "--internal") == 0)
{
ecl = params.SetCommand(COMMAND_INTERNAL);
}
else if (stricmp (*argv, "--drivename") == 0)
{
ecl = params.SetDriveName(argc, argv);
}
else if (stricmp (*argv, "--no_user_interaction") == 0)
{
ecl = params.SetNoUserInteraction ();
}
else if (stricmp (*argv, "--real") == 0)
{
ecl = params.SetUseReal();
}
else if (stricmp (*argv, "--tao") == 0)
{
ecl = params.SetUseTAO();
}
else if (stricmp (*argv, "--underrun_prot") == 0)
{
ecl = params.SetUseUnderRunProt();
}
else if (stricmp (*argv, "--no_error_log") == 0)
{
ecl = params.SetWriteErrorLog();
}
else if (stricmp (*argv, "--speedtest") == 0)
{
ecl = params.SetSpeedTest();
}
else if (stricmp (*argv, "--enable_abort") == 0)
{
ecl = params.SetEnableAbort();
}
else if (stricmp (*argv, "--close_session") == 0)
{
ecl = params.SetCloseSession();
}
else if (stricmp (*argv, "--detect_non_empty_cdrw") == 0)
{
ecl = params.SetDetectNonEmptyCDRW();
}
else if (stricmp (*argv, "--cd_text") == 0)
{
ecl = params.SetUseCDText();
}
else if (stricmp (*argv, "--japanese_cd_text") == 0)
{
ecl = params.SetJapaneseCDText();
}
else if (stricmp (*argv, "--booktype_dvdrom") == 0)
{
ecl = params.SetBooktypeDVDROM();
}
else if (stricmp (*argv, "--no_booktype_change") == 0)
{
ecl = params.SetNoBooktypeChange();
}
else if (stricmp (*argv, "--use_rockridge") == 0)
{
ecl = params.SetUseRockridge();
}
else if (stricmp (*argv, "--create_iso_fs") == 0)
{
ecl = params.SetCreateIsoFs();
}
else if (stricmp (*argv, "--create_udf_fs") == 0)
{
ecl = params.SetCreateUdfFs();
}
else if (stricmp (*argv, "--dvdvideo_realloc") == 0)
{
ecl = params.SetDVDVideoRealloc();
}
else if (stricmp (*argv, "--dvdvideo_cmpt") == 0)
{
ecl = params.SetDVDVideoCmpt();
}
else if (stricmp (*argv, "--use_allspace") == 0)
{
params.SetUseAllSpace();
}
else if (stricmp (*argv, "--relax_joliet") == 0)
{
params.SetRelaxJoliet();
}
else if (stricmp (*argv, "--import_rockridge") == 0)
{
// NIITEF_IMPORT_ROCKRIDGE flag is obsolete so we commented the
// code below but keep the command line option for
// compatibility.
//
// ecl = params.SetImportRockridge();
}
else if (stricmp (*argv, "--import_udf") == 0)
{
ecl = params.SetImportUDF();
}
else if (stricmp (*argv, "--import_vms_session") == 0)
{
ecl = params.SetImportVMSSession();
}
else if (stricmp (*argv, "--import_iso_only") == 0)
{
// if this flag is given, do as if --import is given
ecl = params.SetSessionToImport(argc, argv);
}
else if (stricmp (*argv, "--prefer_rockridge") == 0)
{
// ecl = params.SetPreferRockridge();
}
else if (stricmp (*argv, "--disable_eject") == 0)
{
ecl = params.SetDisableEject();
}
else if (stricmp (*argv, "--verify") == 0)
{
ecl = params.SetVerify();
}
else if (stricmp (*argv, "--error_log") == 0)
{
ecl = params.SetErrorLogName(argc, argv);
}
else if (stricmp (*argv, "--artist") == 0)
{
ecl = params.SetArtist(argc, argv);
}
else if (stricmp (*argv, "--title") == 0)
{
ecl = params.SetTitle(argc, argv);
}
else if (stricmp (*argv, "--read_speed") == 0)
{
ecl = params.SetReadSpeed(argc, argv);
}
else if (stricmp (*argv, "--speed") == 0)
{
ecl = params.SetSpeed(argc, argv);
}
else if (stricmp (*argv, "--speed_in_kbps") == 0)
{
ecl = params.SetSpeedInKbps(argc, argv);
}
else if (stricmp (*argv, "--import") == 0)
{
ecl = params.SetSessionToImport(argc, argv);
}
else if (stricmp (*argv, "--cdextra") == 0)
{
params.SetCDExtra();
}
else if (stricmp (*argv, "--iso") == 0)
{
ecl = params.SetISOSelected(argc, argv);
}
else if (stricmp (*argv, "--iso-no-joliet") == 0)
{
params.SetDontUseJoliet();
}
else if (stricmp (*argv, "--iso-mode2") == 0)
{
params.SetUseMode2();
}
else if (stricmp (*argv, "--audio") == 0)
{
ecl = params.SetAudioSelected();
}
else if (stricmp (*argv, "--videocd") == 0)
{
ecl = params.SetBurnType(BURNTYPE_VIDEOCD);
}
else if (stricmp (*argv, "--svideocd") == 0)
{
ecl = params.SetBurnType(BURNTYPE_SVIDEOCD);
}
else if (stricmp (*argv, "--image") == 0)
{
params.SetImageBurnType(argc, argv);
}
else if (stricmp (*argv, "--freestyle_mode1") == 0 ||
stricmp (*argv, "--freestyle_mode2") == 0 ||
stricmp (*argv, "--freestyle_audio") == 0)
{
params.SetFreestyleBurnType(argc, argv);
}
else if (stricmp (*argv, "--entire") == 0)
{
ecl = params.SetEraseMode(NEROAPI_ERASE_ENTIRE);
}
else if (stricmp (*argv, "--dvd") == 0)
{
ecl = params.SetUseDVD();
}
else if (stricmp (*argv, "--dvd_high_compatibility") == 0)
{
ecl = params.SetUseDVDHighCompatibility();
}
else if (stricmp (*argv, "--recursive") == 0)
{
ecl = params.SetRecursive();
}
else if (stricmp (*argv, "--nero_log_timestamp") == 0)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?