Files
libultraship/include/ship/utils/StrHash64.h
74776bf112 docs: Add Doxygen documentation to all public headers and bridge APIs (#1065)
* docs: add Doxygen documentation comments to public headers

Agent-Logs-Url: https://github.com/Kenix3/libultraship/sessions/ac57bbd2-5ec9-4b74-a1fb-5a893e4bf5c7

Co-authored-by: Kenix3 <18299654+Kenix3@users.noreply.github.com>

* docs: add Doxygen comments to all remaining classes.h + bridge headers

Agent-Logs-Url: https://github.com/Kenix3/libultraship/sessions/7a4feced-e03b-404a-9f9d-20cbb63b33e1

Co-authored-by: Kenix3 <18299654+Kenix3@users.noreply.github.com>

* docs: complete Doxygen coverage of all public + bridge headers

Agent-Logs-Url: https://github.com/Kenix3/libultraship/sessions/7a4feced-e03b-404a-9f9d-20cbb63b33e1

Co-authored-by: Kenix3 <18299654+Kenix3@users.noreply.github.com>

* style: apply clang-format-14 to fix tidy-format-validation failures

Agent-Logs-Url: https://github.com/Kenix3/libultraship/sessions/db20ac85-c1b1-41ef-a1dc-8c72758c0ca8

Co-authored-by: Kenix3 <18299654+Kenix3@users.noreply.github.com>

* fix: address PR review comments on documentation and Stream::Read signature

Agent-Logs-Url: https://github.com/Kenix3/libultraship/sessions/a77e3bd9-ef1e-43fd-b12f-c73385069307

Co-authored-by: Kenix3 <18299654+Kenix3@users.noreply.github.com>

* refactor: use Seek for BinaryReader::Read skip instead of allocating temp buffer

Agent-Logs-Url: https://github.com/Kenix3/libultraship/sessions/4153ca67-c4f9-4369-aa3b-f60396eb69ea

Co-authored-by: Kenix3 <18299654+Kenix3@users.noreply.github.com>

* docs: add Doxygen documentation to ScriptLoader.h

Agent-Logs-Url: https://github.com/Kenix3/libultraship/sessions/b388c2e1-f44b-4db1-bd32-ff694295e657

Co-authored-by: Kenix3 <18299654+Kenix3@users.noreply.github.com>

* Update include/libultraship/controller/controldeck/ControlDeck.h

* Update include/ship/window/gui/GameOverlay.h

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Kenix3 <18299654+Kenix3@users.noreply.github.com>
Co-authored-by: Kenix3 <kenixwhisperwind@gmail.com>
2026-04-15 20:16:03 -04:00

129 lines
5.7 KiB
C

#pragma once
/*
* Below are the various copyright notices from the original source.
* <http://www.mirrorservice.org/sites/download.sourceforge.net/pub/
* sourceforge/l/li/libcore/libcore_0.22.7.tar.gz/libcore/lib/hash/Crc.cpp>
*
* The source has be substationally modified:
* 1. Unneeded code has been deleted.
* 2. The code was converted from C++ to C.
* 3. Routines optimized for hashing were added.
*/
///////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2006 Anton Samokhvalov
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
///////////////////////////////////////////////////////////////////////////////////
/*
[To some parts of this code]
*/
/*
Copyright (C) 1995-2004 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jean-loup Gailly Mark Adler
jloup@gzip.org madler@alumni.caltech.edu
*/
/*
[To some parts of this code]
*/
/*
Copyright (c) 2003, Dominik Reichl <dominik.reichl@t-online.de>
All rights reserved.
LICENSE TERMS
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of ReichlSoft nor the names of its contributors may be used
to endorse or promote products derived from this software without specific
prior written permission.
DISCLAIMER
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdint.h>
/** @brief Initial CRC64 seed value. Pass to update_crc64() as the starting @p crc. */
#define INITIAL_CRC64 0xffffffffffffffffULL
/**
* @brief Updates a running CRC64 checksum with @p len bytes from @p buf.
*
* Use this function to compute the CRC64 of a multi-part message by chaining calls:
* @code
* uint64_t crc = INITIAL_CRC64;
* crc = update_crc64(part1, len1, crc);
* crc = update_crc64(part2, len2, crc);
* @endcode
*
* @param buf Pointer to the data to hash.
* @param len Number of bytes in @p buf.
* @param crc Running CRC64 value (initialise with INITIAL_CRC64).
* @return Updated CRC64 value.
*/
extern uint64_t update_crc64(const void* buf, uint32_t len, uint64_t crc);
/**
* @brief Computes the CRC64 of @p len bytes starting at @p buf.
*
* Equivalent to calling update_crc64() once with INITIAL_CRC64 as the seed.
*
* @param buf Pointer to the data to hash.
* @param len Number of bytes in @p buf.
* @return 64-bit CRC hash of the input.
*/
extern uint64_t crc64(const void* buf, uint32_t len);
/**
* @brief Computes the CRC64 of a null-terminated string @p t.
*
* This is the primary hashing function used by the resource system to map virtual
* resource paths (char*) to their 64-bit CRC identifiers.
*
* @param t Null-terminated string to hash.
* @return 64-bit CRC hash of @p t (excluding the null terminator).
*/
extern uint64_t CRC64(const char* t);