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
|
|
|
|
|
|
|
#ifndef __UTILITY_H__
|
|
|
|
#define __UTILITY_H__
|
|
|
|
|
2015-03-13 14:48:53 +08:00
|
|
|
#include <QString>
|
2015-04-02 16:04:37 +08:00
|
|
|
#include <QModelIndex>
|
2015-03-13 14:48:53 +08:00
|
|
|
#include "basetypes.h"
|
2015-04-02 16:04:37 +08:00
|
|
|
#include "parsingdata.h"
|
|
|
|
|
|
|
|
// Returns either new parsing data instance or obtains it from index
|
2015-07-07 21:57:41 +08:00
|
|
|
PARSING_DATA parsingDataFromQModelIndex(const QModelIndex & index);
|
2015-04-02 16:04:37 +08:00
|
|
|
|
|
|
|
// Converts parsing data to byte array
|
2015-05-15 01:15:19 +08:00
|
|
|
QByteArray parsingDataToQByteArray(const PARSING_DATA & pdata);
|
2015-03-13 14:48:53 +08:00
|
|
|
|
|
|
|
// Converts error code to QString
|
|
|
|
extern QString errorCodeToQString(UINT8 errorCode);
|
|
|
|
|
|
|
|
// Decompression routine
|
2016-02-02 09:08:08 +08:00
|
|
|
extern STATUS decompress(const QByteArray & compressed, UINT8 & algorithm, QByteArray & decompressed, QByteArray & efiDecompressed = QByteArray());
|
2015-03-13 14:48:53 +08:00
|
|
|
|
|
|
|
// Compression routine
|
|
|
|
//STATUS compress(const QByteArray & decompressed, QByteArray & compressed, const UINT8 & algorithm);
|
|
|
|
|
2015-07-07 21:57:41 +08:00
|
|
|
// CRC32 calculation routine
|
2015-03-13 14:48:53 +08:00
|
|
|
extern UINT32 crc32(UINT32 initial, const UINT8* buffer, UINT32 length);
|
2015-04-02 16:04:37 +08:00
|
|
|
|
2015-07-07 21:57:41 +08:00
|
|
|
// 8bit checksum calculation routine
|
|
|
|
extern UINT8 calculateChecksum8(const UINT8* buffer, UINT32 bufferSize);
|
|
|
|
|
|
|
|
// 16bit checksum calculation routine
|
|
|
|
extern UINT16 calculateChecksum16(const UINT16* buffer, UINT32 bufferSize);
|
|
|
|
|
2015-04-02 16:04:37 +08:00
|
|
|
#endif
|