Author: cfinck Date: Sat Feb 2 17:32:44 2008 New Revision: 32089
URL: http://svn.reactos.org/svn/reactos?rev=32089&view=rev Log: - Add an -M option to specify, which compression codec shall be used (either "raw" or "mszip") - Enable the RAW codec in the SelectCodec() function - Don't initialize a codec in the CCabinet constructor, this will be done by the ParseCmdline() function - Fix parsing the -L and -P parameters, when there's no whitespace between the parameter and the value - Remove some unneeded casts - Remove the cabman vesion number, it was never updated, although there were many changes since the first version
Modified: trunk/reactos/tools/cabman/cabinet.cxx trunk/reactos/tools/cabman/cabinet.h trunk/reactos/tools/cabman/dfp.cxx trunk/reactos/tools/cabman/main.cxx
Modified: trunk/reactos/tools/cabman/cabinet.cxx URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/cabman/cabinet.cxx?re... ============================================================================== --- trunk/reactos/tools/cabman/cabinet.cxx (original) +++ trunk/reactos/tools/cabman/cabinet.cxx Sat Feb 2 17:32:44 2008 @@ -320,9 +320,9 @@ FileListHead = NULL; FileListTail = NULL;
- Codec = new CRawCodec(); - CodecId = CAB_CODEC_RAW; - CodecSelected = true; + Codec = NULL; + CodecId = -1; + CodecSelected = false;
OutputBuffer = NULL; InputBuffer = NULL; @@ -359,7 +359,7 @@ * ARGUMENTS: * Char = Character to check * RETURNS: - * Wether it is a separator + * Whether it is a separator */ { if ((Char == '\') || (Char == '/')) @@ -511,6 +511,25 @@ NormalizePath(DestPath, MAX_PATH); }
+bool CCabinet::SetCompressionCodec(char* CodecName) +/* + * FUNCTION: Selects the codec to use for compression + * ARGUMENTS: + * CodecName = Pointer to a string with the name of the codec + */ +{ + if( !strcasecmp(CodecName, "raw") ) + SelectCodec(CAB_CODEC_RAW); + else if( !strcasecmp(CodecName, "mszip") ) + SelectCodec(CAB_CODEC_MSZIP); + else + { + printf("Invalid codec specified!\n"); + return false; + } + + return true; +}
char* CCabinet::GetDestinationPath() /* @@ -1300,8 +1319,17 @@ return CAB_STATUS_SUCCESS; }
- -void CCabinet::SelectCodec(ULONG Id) +bool CCabinet::IsCodecSelected() +/* + * FUNCTION: Returns the value of CodecSelected + * RETURNS: + * Whether a codec is selected + */ +{ + return CodecSelected; +} + +void CCabinet::SelectCodec(LONG Id) /* * FUNCTION: Selects codec engine to use * ARGUMENTS: @@ -1320,9 +1348,7 @@ switch (Id) { case CAB_CODEC_RAW: -#if 0 Codec = new CRawCodec(); -#endif break;
case CAB_CODEC_MSZIP: @@ -2080,7 +2106,7 @@ PCFDATA_NODE Node;
DPRINT(MAX_TRACE, ("FileName '%s' FileOffset (0x%lX) FileSize (%lu).\n", - (char*)File->FileName, + File->FileName, (ULONG)File->File.FileOffset, (ULONG)File->File.FileSize));
@@ -2291,7 +2317,7 @@ return Status;
DPRINT(MAX_TRACE, ("Found file '%s' at uncompressed offset (0x%lX). Size (%lu bytes) ControlId (0x%lX).\n", - (char*)File->FileName, + File->FileName, (ULONG)File->File.FileOffset, (ULONG)File->File.FileSize, (ULONG)File->File.FileControlID));
Modified: trunk/reactos/tools/cabman/cabinet.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/cabman/cabinet.h?rev=... ============================================================================== --- trunk/reactos/tools/cabman/cabinet.h (original) +++ trunk/reactos/tools/cabman/cabinet.h Sat Feb 2 17:32:44 2008 @@ -347,8 +347,12 @@ /* Extracts a file from the current cabinet file */ ULONG ExtractFile(char* FileName); /* Select codec engine to use */ - void SelectCodec(ULONG Id); + void SelectCodec(LONG Id); + /* Returns if a codec engine is selected */ + bool IsCodecSelected(); #ifndef CAB_READ_ONLY + /* Sets the codec to use for compression (based on a string value) */ + bool SetCompressionCodec(char* CodecName); /* Creates a new cabinet file */ ULONG NewCabinet(); /* Forces a new disk to be created */ @@ -448,7 +452,7 @@ PCFFILE_NODE FileListHead; PCFFILE_NODE FileListTail; CCABCodec *Codec; - ULONG CodecId; + LONG CodecId; bool CodecSelected; void* InputBuffer; void* CurrentIBuffer; // Current offset in input buffer
Modified: trunk/reactos/tools/cabman/dfp.cxx URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/cabman/dfp.cxx?rev=32... ============================================================================== --- trunk/reactos/tools/cabman/dfp.cxx (original) +++ trunk/reactos/tools/cabman/dfp.cxx Sat Feb 2 17:32:44 2008 @@ -1367,7 +1367,7 @@ if (i > 0) { CurrentString[i] = '\0'; - CurrentInteger = atoi((char*)CurrentString); + CurrentInteger = atoi(CurrentString); CurrentToken = TokenInteger; CurrentChar += i; return;
Modified: trunk/reactos/tools/cabman/main.cxx URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/cabman/main.cxx?rev=3... ============================================================================== --- trunk/reactos/tools/cabman/main.cxx (original) +++ trunk/reactos/tools/cabman/main.cxx Sat Feb 2 17:32:44 2008 @@ -24,9 +24,6 @@ //ULONG DebugTraceLevel = MAX_TRACE;
#endif /* DBG */ - - -#define CM_VERSION "0.9"
char* Pad(char* Str, char PadChar, ULONG Length) @@ -191,7 +188,7 @@ * FUNCTION: Display usage information on screen */ { - printf("ReactOS Cabinet Manager - Version %s\n\n", CM_VERSION); + printf("ReactOS Cabinet Manager\n\n"); printf("CABMAN [-D | -E] [-A] [-L dir] cabinet [filename ...]\n"); printf("CABMAN -C dirfile [-I] [-RC file] [-P dir]\n"); printf("CABMAN -S cabinet filename\n"); @@ -210,6 +207,9 @@ printf(" -I Don't create the cabinet, only the .inf file.\n"); printf(" -L dir Location to place extracted or generated files\n"); printf(" (default is current directory).\n"); + printf(" -M Specify the compression method to use\n"); + printf(" raw - No compression\n"); + printf(" mszip - MsZip compression (default)\n"); printf(" -N Don't create the .inf file, only the cabinet.\n"); printf(" -RC Specify file to put in cabinet reserved area\n"); printf(" (size must be less than 64KB).\n"); @@ -269,10 +269,28 @@ if (argv[i][2] == 0) { i++; - SetDestinationPath((char*)&argv[i][0]); + SetDestinationPath(&argv[i][0]); } else - SetDestinationPath((char*)&argv[i][1]); + SetDestinationPath(&argv[i][2]); + + break; + + case 'm': + case 'M': + // Set the compression codec (only affects compression, not decompression) + if(argv[i][2] == 0) + { + i++; + + if( !SetCompressionCodec(&argv[i][0]) ) + return false; + } + else + { + if( !SetCompressionCodec(&argv[i][2]) ) + return false; + }
break;
@@ -288,7 +306,7 @@ if (argv[i][3] == 0) { i++; - if (!SetCabinetReservedFile((char*)&argv[i][0])) + if (!SetCabinetReservedFile(&argv[i][0])) { printf("Cannot open cabinet reserved area file.\n"); return false; @@ -296,7 +314,7 @@ } else { - if (!SetCabinetReservedFile((char*)&argv[i][3])) + if (!SetCabinetReservedFile(&argv[i][3])) { printf("Cannot open cabinet reserved area file.\n"); return false; @@ -319,10 +337,10 @@ if (argv[i][2] == 0) { i++; - SetFileRelativePath((char*)&argv[i][0]); + SetFileRelativePath(&argv[i][0]); } else - SetFileRelativePath((char*)&argv[i][1]); + SetFileRelativePath(&argv[i][2]);
break;
@@ -336,7 +354,7 @@ if ((FoundCabinet) || (Mode == CM_MODE_CREATE)) { /* FIXME: There may be many of these if Mode != CM_MODE_CREATE */ - strcpy((char*)FileName, argv[i]); + strcpy(FileName, argv[i]); } else { @@ -352,8 +370,9 @@ return false; }
- /* FIXME */ - SelectCodec(CAB_CODEC_MSZIP); + // Select MsZip by default for creating cabinets + if( (Mode == CM_MODE_CREATE || Mode == CM_MODE_CREATE_SIMPLE) && !IsCodecSelected() ) + SelectCodec(CAB_CODEC_MSZIP);
return true; } @@ -366,10 +385,10 @@ { ULONG Status;
- Status = Load((char*)&FileName); + Status = Load(FileName); if (Status != CAB_STATUS_SUCCESS) { - printf("Specified directive file could not be found: %s.\n", (char*)&FileName); + printf("Specified directive file could not be found: %s.\n", FileName); return false; }
@@ -435,9 +454,9 @@ { if (Search.File->FileControlID != CAB_FILE_CONTINUED) { - printf("%s ", Date2Str((char*)&Str, Search.File->FileDate)); - printf("%s ", Time2Str((char*)&Str, Search.File->FileTime)); - printf("%s ", Attr2Str((char*)&Str, Search.File->Attributes)); + printf("%s ", Date2Str(Str, Search.File->FileDate)); + printf("%s ", Time2Str(Str, Search.File->FileTime)); + printf("%s ", Attr2Str(Str, Search.File->Attributes)); sprintf(Str, "%lu", Search.File->FileSize); printf("%s ", Pad(Str, ' ', 13)); printf("%s\n", Search.FileName); @@ -530,7 +549,7 @@ * FUNCTION: Process cabinet */ { - printf("ReactOS Cabinet Manager - Version %s\n\n", CM_VERSION); + printf("ReactOS Cabinet Manager\n\n");
switch (Mode) {