#include "dkcOSIndependent.h"
dkcCRC.hのインクルード依存関係図

このグラフは、どのファイルから直接、間接的にインクルードされているかを示しています。

構成 | |
| struct | dkc_CRC |
型定義 | |
| typedef dkc_CRC | DKC_CRC |
関数 | |
| DKC_EXTERN DKC_CRC *WINAPI | dkcAllocCRC (size_t Bits, ULONG TruncPoly, ULONG InitRem, ULONG FinalXor, dkctBOOL ReflectIn, dkctBOOL ReflectRem) |
| DKC_EXTERN DKC_CRC *WINAPI | dkcAllocCRC_32left () |
| DKC_EXTERN DKC_CRC *WINAPI | dkcAllocCRC_32right () |
| DKC_EXTERN DKC_CRC *WINAPI | dkcAllocCRC_ansi16left () |
| DKC_EXTERN DKC_CRC *WINAPI | dkcAllocCRC_ansi16right () |
| DKC_EXTERN DKC_CRC *WINAPI | dkcAllocCRC_ccitt_left () |
| DKC_EXTERN DKC_CRC *WINAPI | dkcAllocCRC_ccitt_right () |
| DKC_EXTERN DKC_CRC *WINAPI | dkcAllocCRC_xmodem () |
| DKC_EXTERN int WINAPI | dkcFreeCRC (DKC_CRC **pp) |
| DKC_EXTERN int WINAPI | dkcCRCInit (DKC_CRC *p, void *buffer, size_t Bits, ULONG TruncPoly, ULONG InitRem, ULONG FinalXor, dkctBOOL ReflectIn, dkctBOOL ReflectRem) |
| DKC_EXTERN size_t WINAPI | dkcCRCGetUseTableSize (size_t Bits) |
| dkcCRCInit()のbufferに渡すバッファサイズを求める。 | |
| DKC_EXTERN void WINAPI | dkcCRCLoad (DKC_CRC *p, const BYTE *pBuffer, size_t size) |
| DKC_EXTERN void WINAPI | dkcCRCLoadBlock (DKC_CRC *p, const void *Begin, const void *End) |
| DKC_EXTERN ULONG WINAPI | dkcCRCFinal (DKC_CRC *p) |
| DKC_EXTERN ULONG WINAPI | dkcCRCResult (const DKC_CRC *p) |
サポートしていそうなCRC
boost::crcのC言語版を目指していると考えていただくと分かりやすいかと・・・。 それにしてもboost::crcの実装はかなりE感じ。 ULONGとしている所がE感じのテクだと思った。 (MinGW等ではtemplate<class T,class C=std::vector<T> >みたいな事が出来ない。)
dkcCRC.h で定義されています。
|
|
||||||||||||||||||||||||||||
|
参照先 DKC_CRC, dkcAllocate(), dkcCRCGetUseTableSize(), dkcCRCInit(), dkcFree(), dkctBOOL, と NULL. 参照元 dkcAllocCRC_32left(), dkcAllocCRC_32right(), dkcAllocCRC_7left(), dkcAllocCRC_7right(), dkcAllocCRC_ansi16left(), dkcAllocCRC_ansi16right(), dkcAllocCRC_ccitt_left(), dkcAllocCRC_ccitt_right(), と dkcAllocCRC_xmodem().
00230 {
00231 DKC_CRC *p = (DKC_CRC *)dkcAllocate(sizeof(DKC_CRC));
00232 void *pt;
00233
00234 if(NULL==p){
00235 return NULL;
00236 }
00237 pt = dkcAllocate(dkcCRCGetUseTableSize(Bits));
00238 if(NULL==pt){
00239 goto Error;
00240 }
00241 dkcCRCInit(p,pt,Bits,TruncPoly,InitRem,FinalXor,ReflectIn,ReflectRem);
00242
00243 return p;
00244
00245 Error:
00246 dkcFree((void **)&p);
00247 return NULL;
00248 }
|
|
|
参照先 DKC_CRC, dkcAllocCRC(), と FALSE.
00250 {
00251 return dkcAllocCRC(32, 0xEDB88320, 0xFFFFFFFF, 0xFFFFFFFF, FALSE, FALSE);
00252
00253 }
|
|
|
参照先 DKC_CRC, dkcAllocCRC(), と TRUE.
00255 {
00256 //バグ ... 値を治す
00257 return dkcAllocCRC(32, 0x04C11DB7, 0xFFFFFFFF, 0xFFFFFFFF, TRUE, TRUE);
00258 }
|
|
|
参照先 DKC_CRC, dkcAllocCRC(), と TRUE.
00259 {
00260 return dkcAllocCRC(16, 0x8005, 0, 0, TRUE,TRUE);
00261 }
|
|
|
参照先 DKC_CRC, dkcAllocCRC(), と FALSE.
00263 {
00264 return dkcAllocCRC(16, 0xa001, 0, 0, FALSE,FALSE);
00265 }
|
|
|
参照先 DKC_CRC, dkcAllocCRC(), と FALSE.
00267 {
00268 return dkcAllocCRC(16, 0x1021, 0xFFFF, 0, FALSE,FALSE);
00269 }
|
|
|
参照先 DKC_CRC, dkcAllocCRC(), と TRUE.
00270 {
00271 return dkcAllocCRC(16, 0x8005, 0xFFFF, 0, TRUE,TRUE);
00272 }
|
|
|
参照先 DKC_CRC, dkcAllocCRC(), と TRUE.
00280 {
00281 return dkcAllocCRC(16, 0x8408, 0, 0, TRUE,TRUE);
00282 }
|
|
|
参照先 BOOL, DKC_CRC, mask_value(), dkc_CRC::mBits, dkc_CRC::mFinalXor, dkc_CRC::mR, dkc_CRC::mReflectIn, dkc_CRC::mReflectRem, dkc_CRC::mResult, と reflection().
00490 {
00491 BOOL b = (p->mReflectRem != p->mReflectIn);
00492 size_t Bits = p->mBits;
00493 ULONG ult = mask_value(Bits);
00494 //~(0x80000000 >> (Bits ));//( ( 1u ) << ( get_sigbit(Bits) - 1u ) );
00495 //変数の再利用・・・。本当はしたくないのだが・・・。
00496 Bits = ( reflection(b,Bits,p->mR) ^ p->mFinalXor ) & ult;
00497
00498 p->mResult = Bits;
00499
00500 return Bits;
00501
00502
00503 //reflect_out_type::reflect(rem_) ^ get_final_xor_value() )
00504 // & masking_type::sig_bits_fast;
00505 }
|
|
|
dkcCRCInit()のbufferに渡すバッファサイズを求める。
参照元 dkcAllocCRC().
00214 {
00215 //手抜き演算〜〜
00216 size_t t;
00217 if(Bits <= 16){
00218 t = sizeof(USHORT) * 0x100;
00219 }else if(Bits <= 32){
00220 t = sizeof(ULONG) * 0x100;
00221 }else{
00222 t = 0;
00223 }
00224 return t;
00225 }
|
|
||||||||||||||||||||||||||||||||||||
|
参照先 DKC_CRC, dkctBOOL, makecrctable16(), makecrctable32(), dkc_CRC::mBits, dkc_CRC::mFinalXor, dkc_CRC::mInitRem, dkc_CRC::mR, dkc_CRC::mReflectIn, dkc_CRC::mReflectRem, dkc_CRC::mResult, dkc_CRC::mTable, dkc_CRC::mTruncPoly, と reflection(). 参照元 dkcAllocCRC().
00334 {
00335 int r;
00336
00337 //初期値
00338 p->mR = reflection(ReflectIn,Bits,InitRem);
00339 //処理結果
00340 p->mResult = 0;
00341 //テーブルへのポインタ
00342 p->mTable = buffer;
00343
00344 p->mBits = Bits;
00345 p->mTruncPoly = TruncPoly;
00346 p->mInitRem = InitRem;
00347 p->mFinalXor = FinalXor;
00348 p->mReflectIn = ReflectIn;
00349 p->mReflectRem = ReflectRem;
00350
00351
00352
00353 if(Bits <= 16){
00354 r = makecrctable16((USHORT *)buffer,Bits,TruncPoly,ReflectIn);
00355 //p->mLoader = Loader16;
00356 }else if(Bits <= 32){
00357 r = makecrctable32((ULONG *)buffer,Bits,TruncPoly,ReflectIn);
00358 //p->mLoader = Loader32;
00359 }else{
00360 r = edk_FAILED;
00361 }
00362 return r;
00363
00364 }
|
|
||||||||||||||||
|
参照先 BYTE, DKC_CRC, と dkcCRCLoadBlock().
00367 {
00368 unsigned char const * const b = (unsigned char const *)pBuffer;
00369 dkcCRCLoadBlock(p, b, b + size );
00370
00371 }
|
|
||||||||||||||||
|
参照先 BOOL, BYTE, DKC_CRC, dkcmFORCE_NOT_ASSERT, index(), mask_value(), dkc_CRC::mBits, dkc_CRC::mR, dkc_CRC::mReflectIn, dkc_CRC::mTable, と shift(). 参照元 dkcCRCLoad().
00385 {
00386 unsigned char const * p = (unsigned char const *)bytes_begin;
00387
00388 unsigned char byte_index;
00389 //for 32bit
00390 //ULONG *pTable32 = (ULONG *)pobj->mTable;
00391 //for 16bit
00392 //USHORT *pTable16 = (ULONG *)pobj->mTable;
00393
00394
00395
00396 //general purpose
00397 size_t Bits = pobj->mBits;
00398 BOOL DoReflect = pobj->mReflectIn;
00399
00400 USHORT *usp;
00401 ULONG *ulp;
00402 ULONG rem;
00403
00404 ulp = (ULONG *)pobj->mTable;
00405 usp = (USHORT *)ulp;
00406
00407 //もし、おかしな値になったらエンディアン系を疑ってネ^^;
00408 rem = pobj->mR;
00409
00410
00411 if(Bits <= 16)
00412 {//16bit filter
00413 // Recompute the CRC for each byte passed
00414 for (; p < (const BYTE *)bytes_end ; ++p )
00415 {
00416 // Compare the new byte with the remainder's higher bits to
00417 // get the new bits, shift out the remainder's current higher
00418 // bits, and update the remainder with the polynominal division
00419 // of the new bits.
00420 byte_index = index( rem, *p ,Bits,DoReflect);
00421 rem = (USHORT)shift( rem , DoReflect);
00422 rem ^= usp[ byte_index ];
00423 }
00424
00425 pobj->mR = rem & mask_value(Bits);
00426
00427 }else if(Bits <= 32)
00428 {//32bit filter
00429 for (; p < (const BYTE *)bytes_end ; ++p )
00430 {
00431
00432 byte_index = index( rem, *p ,Bits,DoReflect);
00433 rem = shift( rem ,DoReflect);
00434 rem ^= ulp[ byte_index ];
00435 }
00436 pobj->mR = rem;
00437 }else{
00438 dkcmFORCE_NOT_ASSERT("dkcCRCLoadBlock中に32ビット以上の計算を要求された");
00439 }
00440 /*
00441 OFFSET_PTR_UNION uni;
00442 OFFSET_UNION rem;
00443
00444 uni.pt32 = (ULONG *)pobj->mTable;
00445 //もし、おかしな値になったらエンディアン系を疑ってネ^^;
00446 rem.t32 = pobj->mR;
00447
00448
00449 if(Bits <= 16)
00450 {//16bit filter
00451 // Recompute the CRC for each byte passed
00452 for (; p < (const BYTE *)bytes_end ; ++p )
00453 {
00454 // Compare the new byte with the remainder's higher bits to
00455 // get the new bits, shift out the remainder's current higher
00456 // bits, and update the remainder with the polynominal division
00457 // of the new bits.
00458 byte_index = index( rem.t16, *p ,Bits,DoReflect);
00459 rem.t16 = (USHORT)shift( rem.t16 , DoReflect);
00460 rem.t16 ^= uni.pt16[ byte_index ];
00461 }
00462
00463 pobj->mR = rem.t16;
00464
00465 }else if(Bits <= 32)
00466 {//32bit filter
00467 for (; p < (const BYTE *)bytes_end ; ++p )
00468 {
00469
00470 byte_index = index( rem.t32, *p ,Bits,DoReflect);
00471 rem.t32 = shift( rem.t32 ,DoReflect);
00472 rem.t32 ^= uni.pt32[ byte_index ];
00473 }
00474 pobj->mR = rem.t32;
00475 }else{
00476 dkcmFORCE_NOT_ASSERT("dkcCRCLoadBlock中に32ビット以上の計算を要求された");
00477 }
00478 */
00479
00480
00481 // rem.t32 & mask_value(Bits);
00482 }
|
|
|
参照先 DKC_CRC, と dkc_CRC::mResult.
00507 {
00508 return p->mResult;
00509 }
|
|
|
|
1.3.6