| 1 |
------------------------------------------------------------------------------ |
| 2 |
-- -- |
| 3 |
-- GNAT LIBRARY COMPONENTS -- |
| 4 |
-- -- |
| 5 |
-- G N A T . C R C 3 2 -- |
| 6 |
-- -- |
| 7 |
-- B o d y -- |
| 8 |
-- -- |
| 9 |
-- Copyright (C) 2001-2025, AdaCore -- |
| 10 |
-- -- |
| 11 |
-- GNAT is free software; you can redistribute it and/or modify it under -- |
| 12 |
-- terms of the GNU General Public License as published by the Free Soft- -- |
| 13 |
-- ware Foundation; either version 3, or (at your option) any later ver- -- |
| 14 |
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- |
| 15 |
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- |
| 16 |
-- or FITNESS FOR A PARTICULAR PURPOSE. -- |
| 17 |
-- -- |
| 18 |
-- As a special exception under Section 7 of GPL version 3, you are granted -- |
| 19 |
-- additional permissions described in the GCC Runtime Library Exception, -- |
| 20 |
-- version 3.1, as published by the Free Software Foundation. -- |
| 21 |
-- -- |
| 22 |
-- You should have received a copy of the GNU General Public License and -- |
| 23 |
-- a copy of the GCC Runtime Library Exception along with this program; -- |
| 24 |
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- |
| 25 |
-- <http://www.gnu.org/licenses/>. -- |
| 26 |
-- -- |
| 27 |
-- GNAT was originally developed by the GNAT team at New York University. -- |
| 28 |
-- Extensive contributions were provided by Ada Core Technologies Inc. -- |
| 29 |
-- -- |
| 30 |
------------------------------------------------------------------------------ |
| 31 |
|
| 32 |
with Ada.Unchecked_Conversion; |
| 33 |
|
| 34 |
package body GNAT.CRC32 is |
| 35 |
|
| 36 |
------------ |
| 37 |
-- Update -- |
| 38 |
------------ |
| 39 |
|
| 40 |
procedure Update (C : in out CRC32; Value : String) is |
| 41 |
begin |
| 42 |
for K in Value'Range loop |
| 43 |
Update (C, Value (K)); |
| 44 |
end loop; |
| 45 |
end Update; |
| 46 |
|
| 47 |
procedure Update (C : in out CRC32; Value : Ada.Streams.Stream_Element) is |
| 48 |
function To_Char is new Ada.Unchecked_Conversion |
| 49 |
(Ada.Streams.Stream_Element, Character); |
| 50 |
V : constant Character := To_Char (Value); |
| 51 |
begin |
| 52 |
Update (C, V); |
| 53 |
end Update; |
| 54 |
|
| 55 |
procedure Update |
| 56 |
(C : in out CRC32; |
| 57 |
Value : Ada.Streams.Stream_Element_Array) |
| 58 |
is |
| 59 |
begin |
| 60 |
for K in Value'Range loop |
| 61 |
Update (C, Value (K)); |
| 62 |
end loop; |
| 63 |
end Update; |
| 64 |
|
| 65 |
----------------- |
| 66 |
-- Wide_Update -- |
| 67 |
----------------- |
| 68 |
|
| 69 |
procedure Wide_Update (C : in out CRC32; Value : Wide_Character) is |
| 70 |
subtype S2 is String (1 .. 2); |
| 71 |
function To_S2 is new Ada.Unchecked_Conversion (Wide_Character, S2); |
| 72 |
VS : constant S2 := To_S2 (Value); |
| 73 |
begin |
| 74 |
Update (C, VS (1)); |
| 75 |
Update (C, VS (2)); |
| 76 |
end Wide_Update; |
| 77 |
|
| 78 |
procedure Wide_Update (C : in out CRC32; Value : Wide_String) is |
| 79 |
begin |
| 80 |
for K in Value'Range loop |
| 81 |
Wide_Update (C, Value (K)); |
| 82 |
end loop; |
| 83 |
end Wide_Update; |
| 84 |
|
| 85 |
end GNAT.CRC32; |