mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-21 05:03:36 +01:00
b0581433a7
fix: remove executable flag and change back to 100644 (was 100755) Signed-off-by: Roger Meier <r.meier@siemens.com>
61 lines
926 B
C++
61 lines
926 B
C++
//
|
|
// Checksum.cpp
|
|
//
|
|
// $Id: //poco/1.4/Foundation/src/Checksum.cpp#1 $
|
|
//
|
|
// Library: Foundation
|
|
// Package: Core
|
|
// Module: Checksum
|
|
//
|
|
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
|
// and Contributors.
|
|
//
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
//
|
|
|
|
|
|
#include "Poco/Checksum.h"
|
|
#if defined(POCO_UNBUNDLED)
|
|
#include <zlib.h>
|
|
#else
|
|
#include "Poco/zlib.h"
|
|
#endif
|
|
|
|
|
|
namespace Poco {
|
|
|
|
|
|
Checksum::Checksum():
|
|
_type(TYPE_CRC32),
|
|
_value(crc32(0L, Z_NULL, 0))
|
|
{
|
|
}
|
|
|
|
|
|
Checksum::Checksum(Type t):
|
|
_type(t),
|
|
_value(0)
|
|
{
|
|
if (t == TYPE_CRC32)
|
|
_value = crc32(0L, Z_NULL, 0);
|
|
else
|
|
_value = adler32(0L, Z_NULL, 0);
|
|
}
|
|
|
|
|
|
Checksum::~Checksum()
|
|
{
|
|
}
|
|
|
|
|
|
void Checksum::update(const char* data, unsigned length)
|
|
{
|
|
if (_type == TYPE_ADLER32)
|
|
_value = adler32(_value, reinterpret_cast<const Bytef*>(data), length);
|
|
else
|
|
_value = crc32(_value, reinterpret_cast<const Bytef*>(data), length);
|
|
}
|
|
|
|
|
|
} // namespace Poco
|