2015-03-13 14:48:53 +08:00
|
|
|
/* utility.h
|
|
|
|
|
2016-02-02 09:08:08 +08:00
|
|
|
Copyright (c) 2016, Nikolaj Schlej. All rights reserved.
|
2015-03-13 14:48:53 +08:00
|
|
|
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
|
|
|
|
http://opensource.org/licenses/bsd-license.php
|
|
|
|
|
|
|
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
|
|
|
|
|
|
*/
|
2015-04-02 16:04:37 +08:00
|
|
|
|
2016-04-09 18:47:19 +08:00
|
|
|
#ifndef UTILITY_H
|
|
|
|
#define UTILITY_H
|
2015-04-02 16:04:37 +08:00
|
|
|
|
2016-10-10 14:05:04 +08:00
|
|
|
#include "basetypes.h"
|
2016-06-26 11:54:21 +08:00
|
|
|
#include "ustring.h"
|
2016-07-07 13:57:45 +08:00
|
|
|
#include "treemodel.h"
|
2015-04-02 16:04:37 +08:00
|
|
|
#include "parsingdata.h"
|
|
|
|
|
2017-10-12 13:59:23 +08:00
|
|
|
// Returns unique name for tree item
|
2016-07-09 14:31:08 +08:00
|
|
|
UString uniqueItemName(const UModelIndex & index);
|
|
|
|
|
2016-06-26 11:54:21 +08:00
|
|
|
// Converts error code to UString
|
2016-07-09 14:31:08 +08:00
|
|
|
UString errorCodeToUString(UINT8 errorCode);
|
2015-03-13 14:48:53 +08:00
|
|
|
|
|
|
|
// Decompression routine
|
2016-10-28 00:31:15 +08:00
|
|
|
USTATUS decompress(const UByteArray & compressed, const UINT8 compressionType, UINT8 & algorithm, UByteArray & decompressed, UByteArray & efiDecompressed);
|
2015-03-13 14:48:53 +08:00
|
|
|
|
|
|
|
// Compression routine
|
2016-06-26 11:54:21 +08:00
|
|
|
//USTATUS compress(const UByteArray & decompressed, UByteArray & compressed, const UINT8 & algorithm);
|
2015-03-13 14:48:53 +08:00
|
|
|
|
2015-07-07 21:57:41 +08:00
|
|
|
// CRC32 calculation routine
|
2016-07-09 14:31:08 +08:00
|
|
|
UINT32 crc32(UINT32 initial, const UINT8* buffer, const UINT32 length);
|
2015-04-02 16:04:37 +08:00
|
|
|
|
2017-12-11 09:56:00 +08:00
|
|
|
// 8bit sum calculation routine
|
|
|
|
UINT8 calculateSum8(const UINT8* buffer, UINT32 bufferSize);
|
|
|
|
|
2015-07-07 21:57:41 +08:00
|
|
|
// 8bit checksum calculation routine
|
2016-07-09 14:31:08 +08:00
|
|
|
UINT8 calculateChecksum8(const UINT8* buffer, UINT32 bufferSize);
|
2015-07-07 21:57:41 +08:00
|
|
|
|
|
|
|
// 16bit checksum calculation routine
|
2016-07-09 14:31:08 +08:00
|
|
|
UINT16 calculateChecksum16(const UINT16* buffer, UINT32 bufferSize);
|
2015-07-07 21:57:41 +08:00
|
|
|
|
2016-10-10 14:05:04 +08:00
|
|
|
// Return padding type from it's contents
|
|
|
|
UINT8 getPaddingType(const UByteArray & padding);
|
|
|
|
|
2016-04-09 18:47:19 +08:00
|
|
|
#endif // UTILITY_H
|