/** @file
Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
Abstract:
Calculate Crc32 value and Verify Crc32 value for input data.
**/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ParseInf.h"
#include "EfiUtilityMsgs.h"
#include "CommonLib.h"
#include "Crc32.h"
#define UTILITY_MAJOR_VERSION 0
#define CRC32_NULL 0
Version (
)
/*++
Routine Description:
Displays the standard utility information to SDTOUT
Arguments:
None
Returns:
None
--*/
{
fprintf (stdout, "%s Version %d.%d %s \n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION, __BUILD_VERSION);
}
Usage (
)
/*++
Routine Description:
Displays the utility usage syntax to STDOUT
Arguments:
None
Returns:
None
--*/
{
//
// Summary usage
//
//
// Copyright declaration
//
//
// Details Option
//
File will be created to store the ouput content.\n");
}
int
main (
int argc,
)
/*++
Routine Description:
Main function.
Arguments:
argc - Number of command line parameters.
argv - Array of pointers to parameter strings.
Returns:
STATUS_SUCCESS - Utility exits successfully.
STATUS_ERROR - Some error occurred during execution.
--*/
{
//
// Init local variables
//
LogLevel = 0;
Crc32Value = 0;
FileBuffer = NULL;
if (argc == 1) {
Usage ();
return STATUS_ERROR;
}
//
// Parse command line
//
argc --;
argv ++;
Version ();
Usage ();
return STATUS_SUCCESS;
}
Version ();
return STATUS_SUCCESS;
}
while (argc > 0) {
goto Finish;
}
argc -= 2;
argv += 2;
continue;
}
argc --;
argv ++;
continue;
}
argc --;
argv ++;
continue;
}
VerboseMsg ("Verbose output Mode Set!");
argc --;
argv ++;
continue;
}
KeyMsg ("Quiet output Mode Set!");
argc --;
argv ++;
continue;
}
goto Finish;
}
if (LogLevel > 9) {
Error (NULL, 0, 1003, "Invalid option value", "Debug Level range is 0-9, current input level is %d", (int) LogLevel);
goto Finish;
}
argc -= 2;
argv += 2;
continue;
}
if (argv[0][0] == '-') {
goto Finish;
}
//
// Get Input file file name.
//
InputFileName = argv[0];
argc --;
argv ++;
}
//
// Check Input paramters
//
if (FileAction == CRC32_NULL) {
Error (NULL, 0, 1001, "Missing option", "either the encode or the decode option must be specified!");
return STATUS_ERROR;
} else if (FileAction == CRC32_ENCODE) {
VerboseMsg ("File will be encoded by Crc32");
} else if (FileAction == CRC32_DECODE) {
VerboseMsg ("File will be decoded by Crc32");
}
if (InputFileName == NULL) {
goto Finish;
} else {
}
if (OutputFileName == NULL) {
goto Finish;
} else {
}
//
// Open Input file and read file data.
//
return STATUS_ERROR;
}
if (FileBuffer == NULL) {
goto Finish;
}
//
// Open output file
//
goto Finish;
}
//
// Calculate Crc32 value
//
if (FileAction == CRC32_ENCODE) {
if (Status != EFI_SUCCESS) {
goto Finish;
}
//
// Done, write output file.
//
} else {
//
// Verify Crc32 Value
//
if (Status != EFI_SUCCESS) {
goto Finish;
}
VerboseMsg ("The calculated CRC32 value is 0x%08x and File Crc32 value is 0x%08x", (unsigned) Crc32Value, (unsigned) (*(UINT32 *)FileBuffer));
goto Finish;
}
//
// Done, write output file.
//
}
if (FileBuffer != NULL) {
free (FileBuffer);
}
}
return GetUtilityStatus ();
}