diff options
Diffstat (limited to 'linden/indra/llmath/llcrc.h')
-rw-r--r-- | linden/indra/llmath/llcrc.h | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/linden/indra/llmath/llcrc.h b/linden/indra/llmath/llcrc.h new file mode 100644 index 0000000..7c267d6 --- /dev/null +++ b/linden/indra/llmath/llcrc.h | |||
@@ -0,0 +1,69 @@ | |||
1 | /** | ||
2 | * @file llcrc.h | ||
3 | * @brief LLCRC class header file. | ||
4 | * | ||
5 | * Copyright (c) 2002-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | #ifndef LL_LLCRC_H | ||
29 | #define LL_LLCRC_H | ||
30 | |||
31 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
32 | // Class llcrc | ||
33 | // | ||
34 | // Simple 32 bit crc. To use, instantiate an LLCRC instance and feed | ||
35 | // it the bytes you want to check. It will update the internal crc as | ||
36 | // you go, and you can qery it at the end. As a horribly inefficient | ||
37 | // example (don't try this at work kids): | ||
38 | // | ||
39 | // LLCRC crc; | ||
40 | // FILE* fp = LLFile::fopen(filename,"rb"); | ||
41 | // while(!feof(fp)) { | ||
42 | // crc.update(fgetc(fp)); | ||
43 | // } | ||
44 | // fclose(fp); | ||
45 | // llinfos << "File crc: " << crc.getCRC() << llendl; | ||
46 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
47 | |||
48 | class LLCRC | ||
49 | { | ||
50 | protected: | ||
51 | U32 mCurrent; | ||
52 | |||
53 | public: | ||
54 | LLCRC(); | ||
55 | |||
56 | U32 getCRC() const; | ||
57 | void update(U8 next_byte); | ||
58 | void update(const U8* buffer, U32 buffer_size); | ||
59 | void update(const char *filename); | ||
60 | |||
61 | #ifdef _DEBUG | ||
62 | // This function runs tests to make sure the crc is | ||
63 | // working. Returns TRUE if it is. | ||
64 | static BOOL testHarness(); | ||
65 | #endif | ||
66 | }; | ||
67 | |||
68 | |||
69 | #endif // LL_LLCRC_H | ||