home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / net / crc < prev    next >
Mailbox/MIME Entity  |  1987-04-07  |  6.5 KB

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: Mailbox/MIME Entity (archive/mbox).

ConfidenceProgramDetectionMatch TypeSupport
100% dexvert Mailbox/MIME Entity (archive/mbox) magic Supported
100% dexvert Internet Message Format (text/imf) magic Supported
1% dexvert Text File (text/txt) fallback Supported
100% file Mailbox text, 1st line "From mark@hyper.UUCP Tue Apr 7 13:49:50 1987" default
99% file C source text default
98% file C source, ASCII text default
100% TrID E-Mail message (Var. 2) default
100% checkBytes Printable ASCII default
100% perlTextCheck Likely Text (Perl) default
100% siegfried x-fmt/111 Plain Text File default
100% detectItEasy Format: plain text[LF] default (weak)
100% xdgMime text/x-devicetree-source default (weak)



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 46 72 6f 6d 20 6d 61 72 | 6b 40 68 79 70 65 72 2e |From mar|k@hyper.|
|00000010| 55 55 43 50 20 54 75 65 | 20 41 70 72 20 20 37 20 |UUCP Tue| Apr 7 |
|00000020| 31 33 3a 34 39 3a 35 30 | 20 31 39 38 37 0a 50 61 |13:49:50| 1987.Pa|
|00000030| 74 68 3a 20 73 65 69 73 | 6d 6f 21 72 75 74 67 65 |th: seis|mo!rutge|
|00000040| 72 73 21 64 61 79 74 6f | 6e 21 75 6d 6e 2d 63 73 |rs!dayto|n!umn-cs|
|00000050| 21 68 79 70 65 72 21 6d | 61 72 6b 0a 46 72 6f 6d |!hyper!m|ark.From|
|00000060| 3a 20 6d 61 72 6b 40 68 | 79 70 65 72 2e 55 55 43 |: mark@h|yper.UUC|
|00000070| 50 20 28 4d 61 72 6b 20 | 4d 65 6e 64 65 6c 29 0a |P (Mark |Mendel).|
|00000080| 4e 65 77 73 67 72 6f 75 | 70 73 3a 20 6e 65 74 2e |Newsgrou|ps: net.|
|00000090| 73 6f 75 72 63 65 73 0a | 53 75 62 6a 65 63 74 3a |sources.|Subject:|
|000000a0| 20 67 65 6e 65 72 61 6c | 2c 20 66 61 73 74 20 63 | general|, fast c|
|000000b0| 72 63 20 61 6c 67 6f 72 | 69 74 68 6d 0a 4b 65 79 |rc algor|ithm.Key|
|000000c0| 77 6f 72 64 73 3a 20 63 | 72 63 2c 61 6c 67 6f 72 |words: c|rc,algor|
|000000d0| 69 74 68 6d 2c 74 61 62 | 6c 65 20 64 72 69 76 65 |ithm,tab|le drive|
|000000e0| 6e 0a 4d 65 73 73 61 67 | 65 2d 49 44 3a 20 3c 32 |n.Messag|e-ID: <2|
|000000f0| 33 31 40 68 79 70 65 72 | 2e 55 55 43 50 3e 0a 44 |31@hyper|.UUCP>.D|
|00000100| 61 74 65 3a 20 37 20 41 | 70 72 20 38 37 20 31 37 |ate: 7 A|pr 87 17|
|00000110| 3a 34 39 3a 35 30 20 47 | 4d 54 0a 4f 72 67 61 6e |:49:50 G|MT.Organ|
|00000120| 69 7a 61 74 69 6f 6e 3a | 20 4e 65 74 77 6f 72 6b |ization:| Network|
|00000130| 20 53 79 73 74 65 6d 73 | 20 43 6f 72 70 2e 2c 20 | Systems| Corp., |
|00000140| 4d 70 6c 73 2e 20 4d 4e | 0a 4c 69 6e 65 73 3a 20 |Mpls. MN|.Lines: |
|00000150| 32 30 30 0a 50 6f 73 74 | 65 64 3a 20 54 75 65 20 |200.Post|ed: Tue |
|00000160| 41 70 72 20 20 37 20 31 | 31 3a 34 39 3a 35 30 20 |Apr 7 1|1:49:50 |
|00000170| 31 39 38 37 0a 0a 48 65 | 72 65 20 69 73 20 61 20 |1987..He|re is a |
|00000180| 66 61 73 74 20 28 74 61 | 62 6c 65 20 64 72 69 76 |fast (ta|ble driv|
|00000190| 65 6e 29 2c 20 67 65 6e | 65 72 61 6c 20 63 72 63 |en), gen|eral crc|
|000001a0| 20 70 72 6f 67 72 61 6d | 20 69 6e 20 43 2e 20 20 | program| in C. |
|000001b0| 49 74 20 63 61 6e 20 62 | 65 20 63 6f 6e 66 69 67 |It can b|e config|
|000001c0| 75 72 65 64 0a 74 6f 20 | 67 65 6e 65 72 61 74 65 |ured.to |generate|
|000001d0| 20 74 68 65 20 63 72 63 | 27 73 20 75 73 65 64 20 | the crc|'s used |
|000001e0| 62 79 20 41 52 43 2c 20 | 58 4d 4f 44 45 4d 20 61 |by ARC, |XMODEM a|
|000001f0| 6e 64 20 74 68 65 20 43 | 49 54 54 20 63 72 63 2e |nd the C|ITT crc.|
|00000200| 0a 4e 6f 20 6d 6f 72 65 | 20 65 78 63 75 73 65 73 |.No more| excuses|
|00000210| 20 66 6f 72 20 73 6c 6f | 77 20 63 6f 64 65 21 0a | for slo|w code!.|
|00000220| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--------|--------|
|00000230| 2d 2d 2d 2d 73 6e 69 70 | 2d 2d 2d 2d 2d 2d 2d 2d |----snip|--------|
|00000240| 2d 2d 2d 73 6e 69 70 2d | 2d 2d 2d 2d 2d 2d 2d 2d |---snip-|--------|
|00000250| 2d 2d 73 6e 69 70 2d 2d | 2d 2d 2d 2d 2d 2d 2d 2d |--snip--|--------|
|00000260| 2d 2d 2d 2d 2d 2d 2d 2d | 2d 2d 2d 0a 2f 2a 20 75 |--------|---./* u|
|00000270| 70 64 63 72 63 28 33 29 | 2c 20 63 72 63 28 31 29 |pdcrc(3)|, crc(1)|
|00000280| 20 2d 20 63 61 6c 63 75 | 6c 61 74 65 20 63 72 63 | - calcu|late crc|
|00000290| 20 70 6f 6c 79 6e 6f 6d | 69 61 6c 73 0a 20 2a 0a | polynom|ials. *.|
|000002a0| 20 2a 20 43 61 6c 63 75 | 6c 61 74 65 2c 20 69 6e | * Calcu|late, in|
|000002b0| 74 65 6c 6c 69 67 65 6e | 74 6c 79 2c 20 74 68 65 |telligen|tly, the|
|000002c0| 20 43 52 43 20 6f 66 20 | 61 20 64 61 74 61 73 65 | CRC of |a datase|
|000002d0| 74 20 69 6e 63 72 65 6d | 65 6e 74 61 6c 6c 79 20 |t increm|entally |
|000002e0| 67 69 76 65 6e 20 61 20 | 0a 20 2a 20 62 75 66 66 |given a |. * buff|
|000002f0| 65 72 20 66 75 6c 6c 20 | 61 74 20 61 20 74 69 6d |er full |at a tim|
|00000300| 65 2e 0a 20 2a 20 0a 20 | 2a 20 55 73 61 67 65 3a |e.. * . |* Usage:|
|00000310| 0a 20 2a 20 09 6e 65 77 | 63 72 63 20 3d 20 75 70 |. * .new|crc = up|
|00000320| 64 63 72 63 28 20 6f 6c | 64 63 72 63 2c 20 62 75 |dcrc( ol|dcrc, bu|
|00000330| 66 61 64 72 2c 20 62 75 | 66 6c 65 6e 20 29 0a 20 |fadr, bu|flen ). |
|00000340| 2a 20 09 09 75 6e 73 69 | 67 6e 65 64 20 69 6e 74 |* ..unsi|gned int|
|00000350| 20 6f 6c 64 63 72 63 2c | 20 62 75 66 6c 65 6e 3b | oldcrc,| buflen;|
|00000360| 0a 20 2a 20 09 09 63 68 | 61 72 20 2a 62 75 66 61 |. * ..ch|ar *bufa|
|00000370| 64 72 3b 0a 20 2a 0a 20 | 2a 20 43 6f 6d 70 69 6c |dr;. *. |* Compil|
|00000380| 69 6e 67 20 77 69 74 68 | 20 2d 44 54 45 53 54 20 |ing with| -DTEST |
|00000390| 63 72 65 61 74 65 73 20 | 61 20 70 72 6f 67 72 61 |creates |a progra|
|000003a0| 6d 20 74 6f 20 70 72 69 | 6e 74 20 74 68 65 20 43 |m to pri|nt the C|
|000003b0| 52 43 20 6f 66 20 73 74 | 64 69 6e 20 74 6f 20 73 |RC of st|din to s|
|000003c0| 74 64 6f 75 74 2e 0a 20 | 2a 20 43 6f 6d 70 69 6c |tdout.. |* Compil|
|000003d0| 65 20 77 69 74 68 20 2d | 44 4d 41 4b 45 54 41 42 |e with -|DMAKETAB|
|000003e0| 20 74 6f 20 70 72 69 6e | 74 20 76 61 6c 75 65 73 | to prin|t values|
|000003f0| 20 66 6f 72 20 63 72 63 | 74 61 62 20 74 6f 20 73 | for crc|tab to s|
|00000400| 74 64 6f 75 74 2e 20 20 | 49 66 20 79 6f 75 20 63 |tdout. |If you c|
|00000410| 68 61 6e 67 65 0a 20 2a | 09 74 68 65 20 43 52 43 |hange. *|.the CRC|
|00000420| 20 70 6f 6c 79 6e 6f 6d | 69 61 6c 20 70 61 72 61 | polynom|ial para|
|00000430| 6d 65 74 65 72 73 2c 20 | 62 65 20 73 75 72 65 20 |meters, |be sure |
|00000440| 74 6f 20 64 6f 20 74 68 | 69 73 20 61 6e 64 20 63 |to do th|is and c|
|00000450| 68 61 6e 67 65 0a 20 2a | 09 63 72 63 74 61 62 27 |hange. *|.crctab'|
|00000460| 73 20 69 6e 69 74 69 61 | 6c 20 76 61 6c 75 65 2e |s initia|l value.|
|00000470| 0a 20 2a 0a 20 2a 20 4e | 6f 74 65 73 3a 0a 20 2a |. *. * N|otes:. *|
|00000480| 20 20 52 65 67 61 72 64 | 73 20 74 68 65 20 64 61 | Regard|s the da|
|00000490| 74 61 20 73 74 72 65 61 | 6d 20 61 73 20 61 6e 20 |ta strea|m as an |
|000004a0| 69 6e 74 65 67 65 72 20 | 77 68 6f 73 65 20 4d 53 |integer |whose MS|
|000004b0| 42 20 69 73 20 74 68 65 | 20 4d 53 42 20 6f 66 20 |B is the| MSB of |
|000004c0| 74 68 65 20 66 69 72 73 | 74 0a 20 2a 20 20 62 79 |the firs|t. * by|
|000004d0| 74 65 20 72 65 63 69 65 | 76 65 64 2e 20 20 54 68 |te recie|ved. Th|
|000004e0| 69 73 20 6e 75 6d 62 65 | 72 20 69 73 20 27 64 69 |is numbe|r is 'di|
|000004f0| 76 69 64 65 64 27 20 28 | 75 73 69 6e 67 20 78 6f |vided' (|using xo|
|00000500| 72 20 69 6e 73 74 65 61 | 64 20 6f 66 20 73 75 62 |r instea|d of sub|
|00000510| 74 72 61 63 74 69 6f 6e | 29 0a 20 2a 20 20 62 79 |traction|). * by|
|00000520| 20 74 68 65 20 63 72 63 | 2d 70 6f 6c 79 6e 6f 6d | the crc|-polynom|
|00000530| 69 61 6c 20 50 2e 0a 20 | 2a 20 20 58 4d 4f 44 45 |ial P.. |* XMODE|
|00000540| 4d 20 64 6f 65 73 20 74 | 68 69 6e 67 73 20 61 20 |M does t|hings a |
|00000550| 6c 69 74 74 6c 65 20 64 | 69 66 66 65 72 65 6e 74 |little d|ifferent|
|00000560| 6c 79 2c 20 65 73 73 65 | 6e 74 69 61 6c 6c 79 20 |ly, esse|ntially |
|00000570| 74 72 65 61 74 69 6e 67 | 20 74 68 65 20 4c 53 42 |treating| the LSB|
|00000580| 20 6f 66 0a 20 2a 20 74 | 68 65 20 66 69 72 73 74 | of. * t|he first|
|00000590| 20 64 61 74 61 20 62 79 | 74 65 20 61 73 20 74 68 | data by|te as th|
|000005a0| 65 20 4d 53 42 20 6f 66 | 20 74 68 65 20 69 6e 74 |e MSB of| the int|
|000005b0| 65 67 65 72 2e 20 44 65 | 66 69 6e 65 20 53 57 41 |eger. De|fine SWA|
|000005c0| 50 50 45 44 20 74 6f 20 | 6d 61 6b 65 0a 20 2a 20 |PPED to |make. * |
|000005d0| 74 68 69 6e 67 73 20 62 | 65 68 61 76 65 20 69 6e |things b|ehave in|
|000005e0| 20 74 68 69 73 20 6d 61 | 6e 6e 65 72 2e 0a 20 2a | this ma|nner.. *|
|000005f0| 0a 20 2a 20 41 75 74 68 | 6f 72 3a 09 4d 61 72 6b |. * Auth|or:.Mark|
|00000600| 20 47 2e 20 4d 65 6e 64 | 65 6c 2c 20 37 2f 38 36 | G. Mend|el, 7/86|
|00000610| 0a 20 2a 09 09 55 55 43 | 50 3a 20 69 68 6e 70 34 |. *..UUC|P: ihnp4|
|00000620| 21 75 6d 6e 2d 63 73 21 | 68 79 70 65 72 21 6d 61 |!umn-cs!|hyper!ma|
|00000630| 72 6b 2c 20 47 45 6e 69 | 65 3a 20 6d 67 6d 0a 20 |rk, GEni|e: mgm. |
|00000640| 2a 2f 0a 0a 2f 2a 20 54 | 68 65 20 43 52 43 20 70 |*/../* T|he CRC p|
|00000650| 6f 6c 79 6e 6f 6d 69 61 | 6c 2e 0a 20 2a 20 54 68 |olynomia|l.. * Th|
|00000660| 65 73 65 20 34 20 76 61 | 6c 75 65 73 20 64 65 66 |ese 4 va|lues def|
|00000670| 69 6e 65 20 74 68 65 20 | 63 72 63 2d 70 6f 6c 79 |ine the |crc-poly|
|00000680| 6e 6f 6d 69 61 6c 2e 0a | 20 2a 20 49 66 20 79 6f |nomial..| * If yo|
|00000690| 75 20 63 68 61 6e 67 65 | 20 74 68 65 6d 2c 20 79 |u change| them, y|
|000006a0| 6f 75 20 6d 75 73 74 20 | 63 68 61 6e 67 65 20 63 |ou must |change c|
|000006b0| 72 63 74 61 62 5b 5d 27 | 73 20 69 6e 69 74 69 61 |rctab[]'|s initia|
|000006c0| 6c 20 76 61 6c 75 65 20 | 74 6f 20 77 68 61 74 20 |l value |to what |
|000006d0| 69 73 0a 20 2a 20 70 72 | 69 6e 74 65 64 20 62 79 |is. * pr|inted by|
|000006e0| 20 69 6e 69 74 63 72 63 | 74 61 62 28 29 20 5b 73 | initcrc|tab() [s|
|000006f0| 65 65 20 27 63 6f 6d 70 | 69 6c 65 20 77 69 74 68 |ee 'comp|ile with|
|00000700| 20 2d 44 4d 41 4b 45 54 | 41 42 27 20 61 62 6f 76 | -DMAKET|AB' abov|
|00000710| 65 5d 2e 0a 20 2a 2f 0a | 20 20 20 20 2f 2a 20 56 |e].. */.| /* V|
|00000720| 61 6c 75 65 20 75 73 65 | 64 20 62 79 3a 09 20 20 |alue use|d by:. |
|00000730| 20 20 09 09 43 49 54 54 | 09 58 4d 4f 44 45 4d 09 | ..CITT|.XMODEM.|
|00000740| 41 52 43 20 20 09 2a 2f | 0a 23 64 65 66 69 6e 65 |ARC .*/|.#define|
|00000750| 09 50 09 20 30 78 41 30 | 30 31 09 20 2f 2a 20 74 |.P. 0xA0|01. /* t|
|00000760| 68 65 20 70 6f 6c 79 3a | 09 30 78 31 30 32 31 09 |he poly:|.0x1021.|
|00000770| 30 78 31 30 32 31 09 41 | 30 30 31 09 2a 2f 0a 23 |0x1021.A|001.*/.#|
|00000780| 64 65 66 69 6e 65 20 49 | 4e 49 54 5f 43 52 43 20 |define I|NIT_CRC |
|00000790| 30 4c 09 20 2f 2a 20 69 | 6e 69 74 20 76 61 6c 75 |0L. /* i|nit valu|
|000007a0| 65 3a 09 2d 31 09 30 09 | 30 09 2a 2f 0a 23 64 65 |e:.-1.0.|0.*/.#de|
|000007b0| 66 69 6e 65 20 53 57 41 | 50 50 45 44 09 09 20 2f |fine SWA|PPED.. /|
|000007c0| 2a 20 62 69 74 20 6f 72 | 64 65 72 3a 09 75 6e 64 |* bit or|der:.und|
|000007d0| 65 66 09 64 65 66 69 6e | 65 64 09 64 65 66 69 6e |ef.defin|ed.defin|
|000007e0| 65 64 20 2a 2f 0a 23 64 | 65 66 69 6e 65 20 57 09 |ed */.#d|efine W.|
|000007f0| 31 36 09 20 2f 2a 20 62 | 69 74 73 20 69 6e 20 43 |16. /* b|its in C|
|00000800| 52 43 3a 31 36 09 31 36 | 09 31 36 09 2a 2f 0a 0a |RC:16.16|.16.*/..|
|00000810| 20 20 20 20 2f 2a 20 64 | 61 74 61 20 74 79 70 65 | /* d|ata type|
|00000820| 20 74 68 61 74 20 68 6f | 6c 64 73 20 61 20 57 2d | that ho|lds a W-|
|00000830| 62 69 74 20 75 6e 73 69 | 67 6e 65 64 20 69 6e 74 |bit unsi|gned int|
|00000840| 65 67 65 72 20 2a 2f 0a | 23 69 66 20 57 20 3c 3d |eger */.|#if W <=|
|00000850| 20 31 36 0a 23 20 20 64 | 65 66 69 6e 65 20 57 54 | 16.# d|efine WT|
|00000860| 59 50 45 09 75 6e 73 69 | 67 6e 65 64 20 73 68 6f |YPE.unsi|gned sho|
|00000870| 72 74 0a 23 65 6c 73 65 | 0a 23 20 20 64 65 66 69 |rt.#else|.# defi|
|00000880| 6e 65 20 57 54 59 50 45 | 20 20 20 75 6e 73 69 67 |ne WTYPE| unsig|
|00000890| 6e 65 64 20 6c 6f 6e 67 | 0a 23 65 6e 64 69 66 0a |ned long|.#endif.|
|000008a0| 0a 20 20 20 20 2f 2a 20 | 74 68 65 20 6e 75 6d 62 |. /* |the numb|
|000008b0| 65 72 20 6f 66 20 62 69 | 74 73 20 70 65 72 20 63 |er of bi|ts per c|
|000008c0| 68 61 72 3a 20 64 6f 6e | 27 74 20 63 68 61 6e 67 |har: don|'t chang|
|000008d0| 65 20 69 74 2e 20 2a 2f | 0a 23 64 65 66 69 6e 65 |e it. */|.#define|
|000008e0| 20 42 09 38 0a 0a 73 74 | 61 74 69 63 20 57 54 59 | B.8..st|atic WTY|
|000008f0| 50 45 20 63 72 63 74 61 | 62 5b 31 3c 3c 42 5d 20 |PE crcta|b[1<<B] |
|00000900| 3d 20 2f 2a 20 61 73 20 | 63 61 6c 63 75 6c 61 74 |= /* as |calculat|
|00000910| 65 64 20 62 79 20 69 6e | 69 74 63 72 63 74 61 62 |ed by in|itcrctab|
|00000920| 28 29 20 2a 2f 20 7b 0a | 30 78 30 2c 20 20 30 78 |() */ {.|0x0, 0x|
|00000930| 63 30 63 31 2c 20 20 30 | 78 63 31 38 31 2c 20 20 |c0c1, 0|xc181, |
|00000940| 30 78 31 34 30 2c 20 20 | 30 78 63 33 30 31 2c 20 |0x140, |0xc301, |
|00000950| 20 30 78 33 63 30 2c 20 | 20 30 78 32 38 30 2c 20 | 0x3c0, | 0x280, |
|00000960| 20 30 78 63 32 34 31 2c | 0a 30 78 63 36 30 31 2c | 0xc241,|.0xc601,|
|00000970| 20 20 30 78 36 63 30 2c | 20 20 30 78 37 38 30 2c | 0x6c0,| 0x780,|
|00000980| 20 20 30 78 63 37 34 31 | 2c 20 20 30 78 35 30 30 | 0xc741|, 0x500|
|00000990| 2c 20 20 30 78 63 35 63 | 31 2c 20 20 30 78 63 34 |, 0xc5c|1, 0xc4|
|000009a0| 38 31 2c 20 20 30 78 34 | 34 30 2c 0a 30 78 63 63 |81, 0x4|40,.0xcc|
|000009b0| 30 31 2c 20 20 30 78 63 | 63 30 2c 20 20 30 78 64 |01, 0xc|c0, 0xd|
|000009c0| 38 30 2c 20 20 30 78 63 | 64 34 31 2c 20 20 30 78 |80, 0xc|d41, 0x|
|000009d0| 66 30 30 2c 20 20 30 78 | 63 66 63 31 2c 20 20 30 |f00, 0x|cfc1, 0|
|000009e0| 78 63 65 38 31 2c 20 20 | 30 78 65 34 30 2c 0a 30 |xce81, |0xe40,.0|
|000009f0| 78 61 30 30 2c 20 20 30 | 78 63 61 63 31 2c 20 20 |xa00, 0|xcac1, |
|00000a00| 30 78 63 62 38 31 2c 20 | 20 30 78 62 34 30 2c 20 |0xcb81, | 0xb40, |
|00000a10| 20 30 78 63 39 30 31 2c | 20 20 30 78 39 63 30 2c | 0xc901,| 0x9c0,|
|00000a20| 20 20 30 78 38 38 30 2c | 20 20 30 78 63 38 34 31 | 0x880,| 0xc841|
|00000a30| 2c 0a 30 78 64 38 30 31 | 2c 20 20 30 78 31 38 63 |,.0xd801|, 0x18c|
|00000a40| 30 2c 20 20 30 78 31 39 | 38 30 2c 20 20 30 78 64 |0, 0x19|80, 0xd|
|00000a50| 39 34 31 2c 20 20 30 78 | 31 62 30 30 2c 20 20 30 |941, 0x|1b00, 0|
|00000a60| 78 64 62 63 31 2c 20 20 | 30 78 64 61 38 31 2c 20 |xdbc1, |0xda81, |
|00000a70| 20 30 78 31 61 34 30 2c | 0a 30 78 31 65 30 30 2c | 0x1a40,|.0x1e00,|
|00000a80| 20 20 30 78 64 65 63 31 | 2c 20 20 30 78 64 66 38 | 0xdec1|, 0xdf8|
|00000a90| 31 2c 20 20 30 78 31 66 | 34 30 2c 20 20 30 78 64 |1, 0x1f|40, 0xd|
|00000aa0| 64 30 31 2c 20 20 30 78 | 31 64 63 30 2c 20 20 30 |d01, 0x|1dc0, 0|
|00000ab0| 78 31 63 38 30 2c 20 20 | 30 78 64 63 34 31 2c 0a |x1c80, |0xdc41,.|
|00000ac0| 30 78 31 34 30 30 2c 20 | 20 30 78 64 34 63 31 2c |0x1400, | 0xd4c1,|
|00000ad0| 20 20 30 78 64 35 38 31 | 2c 20 20 30 78 31 35 34 | 0xd581|, 0x154|
|00000ae0| 30 2c 20 20 30 78 64 37 | 30 31 2c 20 20 30 78 31 |0, 0xd7|01, 0x1|
|00000af0| 37 63 30 2c 20 20 30 78 | 31 36 38 30 2c 20 20 30 |7c0, 0x|1680, 0|
|00000b00| 78 64 36 34 31 2c 0a 30 | 78 64 32 30 31 2c 20 20 |xd641,.0|xd201, |
|00000b10| 30 78 31 32 63 30 2c 20 | 20 30 78 31 33 38 30 2c |0x12c0, | 0x1380,|
|00000b20| 20 20 30 78 64 33 34 31 | 2c 20 20 30 78 31 31 30 | 0xd341|, 0x110|
|00000b30| 30 2c 20 20 30 78 64 31 | 63 31 2c 20 20 30 78 64 |0, 0xd1|c1, 0xd|
|00000b40| 30 38 31 2c 20 20 30 78 | 31 30 34 30 2c 0a 30 78 |081, 0x|1040,.0x|
|00000b50| 66 30 30 31 2c 20 20 30 | 78 33 30 63 30 2c 20 20 |f001, 0|x30c0, |
|00000b60| 30 78 33 31 38 30 2c 20 | 20 30 78 66 31 34 31 2c |0x3180, | 0xf141,|
|00000b70| 20 20 30 78 33 33 30 30 | 2c 20 20 30 78 66 33 63 | 0x3300|, 0xf3c|
|00000b80| 31 2c 20 20 30 78 66 32 | 38 31 2c 20 20 30 78 33 |1, 0xf2|81, 0x3|
|00000b90| 32 34 30 2c 0a 30 78 33 | 36 30 30 2c 20 20 30 78 |240,.0x3|600, 0x|
|00000ba0| 66 36 63 31 2c 20 20 30 | 78 66 37 38 31 2c 20 20 |f6c1, 0|xf781, |
|00000bb0| 30 78 33 37 34 30 2c 20 | 20 30 78 66 35 30 31 2c |0x3740, | 0xf501,|
|00000bc0| 20 20 30 78 33 35 63 30 | 2c 20 20 30 78 33 34 38 | 0x35c0|, 0x348|
|00000bd0| 30 2c 20 20 30 78 66 34 | 34 31 2c 0a 30 78 33 63 |0, 0xf4|41,.0x3c|
|00000be0| 30 30 2c 20 20 30 78 66 | 63 63 31 2c 20 20 30 78 |00, 0xf|cc1, 0x|
|00000bf0| 66 64 38 31 2c 20 20 30 | 78 33 64 34 30 2c 20 20 |fd81, 0|x3d40, |
|00000c00| 30 78 66 66 30 31 2c 20 | 20 30 78 33 66 63 30 2c |0xff01, | 0x3fc0,|
|00000c10| 20 20 30 78 33 65 38 30 | 2c 20 20 30 78 66 65 34 | 0x3e80|, 0xfe4|
|00000c20| 31 2c 0a 30 78 66 61 30 | 31 2c 20 20 30 78 33 61 |1,.0xfa0|1, 0x3a|
|00000c30| 63 30 2c 20 20 30 78 33 | 62 38 30 2c 20 20 30 78 |c0, 0x3|b80, 0x|
|00000c40| 66 62 34 31 2c 20 20 30 | 78 33 39 30 30 2c 20 20 |fb41, 0|x3900, |
|00000c50| 30 78 66 39 63 31 2c 20 | 20 30 78 66 38 38 31 2c |0xf9c1, | 0xf881,|
|00000c60| 20 20 30 78 33 38 34 30 | 2c 0a 30 78 32 38 30 30 | 0x3840|,.0x2800|
|00000c70| 2c 20 20 30 78 65 38 63 | 31 2c 20 20 30 78 65 39 |, 0xe8c|1, 0xe9|
|00000c80| 38 31 2c 20 20 30 78 32 | 39 34 30 2c 20 20 30 78 |81, 0x2|940, 0x|
|00000c90| 65 62 30 31 2c 20 20 30 | 78 32 62 63 30 2c 20 20 |eb01, 0|x2bc0, |
|00000ca0| 30 78 32 61 38 30 2c 20 | 20 30 78 65 61 34 31 2c |0x2a80, | 0xea41,|
|00000cb0| 0a 30 78 65 65 30 31 2c | 20 20 30 78 32 65 63 30 |.0xee01,| 0x2ec0|
|00000cc0| 2c 20 20 30 78 32 66 38 | 30 2c 20 20 30 78 65 66 |, 0x2f8|0, 0xef|
|00000cd0| 34 31 2c 20 20 30 78 32 | 64 30 30 2c 20 20 30 78 |41, 0x2|d00, 0x|
|00000ce0| 65 64 63 31 2c 20 20 30 | 78 65 63 38 31 2c 20 20 |edc1, 0|xec81, |
|00000cf0| 30 78 32 63 34 30 2c 0a | 30 78 65 34 30 31 2c 20 |0x2c40,.|0xe401, |
|00000d00| 20 30 78 32 34 63 30 2c | 20 20 30 78 32 35 38 30 | 0x24c0,| 0x2580|
|00000d10| 2c 20 20 30 78 65 35 34 | 31 2c 20 20 30 78 32 37 |, 0xe54|1, 0x27|
|00000d20| 30 30 2c 20 20 30 78 65 | 37 63 31 2c 20 20 30 78 |00, 0xe|7c1, 0x|
|00000d30| 65 36 38 31 2c 20 20 30 | 78 32 36 34 30 2c 0a 30 |e681, 0|x2640,.0|
|00000d40| 78 32 32 30 30 2c 20 20 | 30 78 65 32 63 31 2c 20 |x2200, |0xe2c1, |
|00000d50| 20 30 78 65 33 38 31 2c | 20 20 30 78 32 33 34 30 | 0xe381,| 0x2340|
|00000d60| 2c 20 20 30 78 65 31 30 | 31 2c 20 20 30 78 32 31 |, 0xe10|1, 0x21|
|00000d70| 63 30 2c 20 20 30 78 32 | 30 38 30 2c 20 20 30 78 |c0, 0x2|080, 0x|
|00000d80| 65 30 34 31 2c 0a 30 78 | 61 30 30 31 2c 20 20 30 |e041,.0x|a001, 0|
|00000d90| 78 36 30 63 30 2c 20 20 | 30 78 36 31 38 30 2c 20 |x60c0, |0x6180, |
|00000da0| 20 30 78 61 31 34 31 2c | 20 20 30 78 36 33 30 30 | 0xa141,| 0x6300|
|00000db0| 2c 20 20 30 78 61 33 63 | 31 2c 20 20 30 78 61 32 |, 0xa3c|1, 0xa2|
|00000dc0| 38 31 2c 20 20 30 78 36 | 32 34 30 2c 0a 30 78 36 |81, 0x6|240,.0x6|
|00000dd0| 36 30 30 2c 20 20 30 78 | 61 36 63 31 2c 20 20 30 |600, 0x|a6c1, 0|
|00000de0| 78 61 37 38 31 2c 20 20 | 30 78 36 37 34 30 2c 20 |xa781, |0x6740, |
|00000df0| 20 30 78 61 35 30 31 2c | 20 20 30 78 36 35 63 30 | 0xa501,| 0x65c0|
|00000e00| 2c 20 20 30 78 36 34 38 | 30 2c 20 20 30 78 61 34 |, 0x648|0, 0xa4|
|00000e10| 34 31 2c 0a 30 78 36 63 | 30 30 2c 20 20 30 78 61 |41,.0x6c|00, 0xa|
|00000e20| 63 63 31 2c 20 20 30 78 | 61 64 38 31 2c 20 20 30 |cc1, 0x|ad81, 0|
|00000e30| 78 36 64 34 30 2c 20 20 | 30 78 61 66 30 31 2c 20 |x6d40, |0xaf01, |
|00000e40| 20 30 78 36 66 63 30 2c | 20 20 30 78 36 65 38 30 | 0x6fc0,| 0x6e80|
|00000e50| 2c 20 20 30 78 61 65 34 | 31 2c 0a 30 78 61 61 30 |, 0xae4|1,.0xaa0|
|00000e60| 31 2c 20 20 30 78 36 61 | 63 30 2c 20 20 30 78 36 |1, 0x6a|c0, 0x6|
|00000e70| 62 38 30 2c 20 20 30 78 | 61 62 34 31 2c 20 20 30 |b80, 0x|ab41, 0|
|00000e80| 78 36 39 30 30 2c 20 20 | 30 78 61 39 63 31 2c 20 |x6900, |0xa9c1, |
|00000e90| 20 30 78 61 38 38 31 2c | 20 20 30 78 36 38 34 30 | 0xa881,| 0x6840|
|00000ea0| 2c 0a 30 78 37 38 30 30 | 2c 20 20 30 78 62 38 63 |,.0x7800|, 0xb8c|
|00000eb0| 31 2c 20 20 30 78 62 39 | 38 31 2c 20 20 30 78 37 |1, 0xb9|81, 0x7|
|00000ec0| 39 34 30 2c 20 20 30 78 | 62 62 30 31 2c 20 20 30 |940, 0x|bb01, 0|
|00000ed0| 78 37 62 63 30 2c 20 20 | 30 78 37 61 38 30 2c 20 |x7bc0, |0x7a80, |
|00000ee0| 20 30 78 62 61 34 31 2c | 0a 30 78 62 65 30 31 2c | 0xba41,|.0xbe01,|
|00000ef0| 20 20 30 78 37 65 63 30 | 2c 20 20 30 78 37 66 38 | 0x7ec0|, 0x7f8|
|00000f00| 30 2c 20 20 30 78 62 66 | 34 31 2c 20 20 30 78 37 |0, 0xbf|41, 0x7|
|00000f10| 64 30 30 2c 20 20 30 78 | 62 64 63 31 2c 20 20 30 |d00, 0x|bdc1, 0|
|00000f20| 78 62 63 38 31 2c 20 20 | 30 78 37 63 34 30 2c 0a |xbc81, |0x7c40,.|
|00000f30| 30 78 62 34 30 31 2c 20 | 20 30 78 37 34 63 30 2c |0xb401, | 0x74c0,|
|00000f40| 20 20 30 78 37 35 38 30 | 2c 20 20 30 78 62 35 34 | 0x7580|, 0xb54|
|00000f50| 31 2c 20 20 30 78 37 37 | 30 30 2c 20 20 30 78 62 |1, 0x77|00, 0xb|
|00000f60| 37 63 31 2c 20 20 30 78 | 62 36 38 31 2c 20 20 30 |7c1, 0x|b681, 0|
|00000f70| 78 37 36 34 30 2c 0a 30 | 78 37 32 30 30 2c 20 20 |x7640,.0|x7200, |
|00000f80| 30 78 62 32 63 31 2c 20 | 20 30 78 62 33 38 31 2c |0xb2c1, | 0xb381,|
|00000f90| 20 20 30 78 37 33 34 30 | 2c 20 20 30 78 62 31 30 | 0x7340|, 0xb10|
|00000fa0| 31 2c 20 20 30 78 37 31 | 63 30 2c 20 20 30 78 37 |1, 0x71|c0, 0x7|
|00000fb0| 30 38 30 2c 20 20 30 78 | 62 30 34 31 2c 0a 30 78 |080, 0x|b041,.0x|
|00000fc0| 35 30 30 30 2c 20 20 30 | 78 39 30 63 31 2c 20 20 |5000, 0|x90c1, |
|00000fd0| 30 78 39 31 38 31 2c 20 | 20 30 78 35 31 34 30 2c |0x9181, | 0x5140,|
|00000fe0| 20 20 30 78 39 33 30 31 | 2c 20 20 30 78 35 33 63 | 0x9301|, 0x53c|
|00000ff0| 30 2c 20 20 30 78 35 32 | 38 30 2c 20 20 30 78 39 |0, 0x52|80, 0x9|
|00001000| 32 34 31 2c 0a 30 78 39 | 36 30 31 2c 20 20 30 78 |241,.0x9|601, 0x|
|00001010| 35 36 63 30 2c 20 20 30 | 78 35 37 38 30 2c 20 20 |56c0, 0|x5780, |
|00001020| 30 78 39 37 34 31 2c 20 | 20 30 78 35 35 30 30 2c |0x9741, | 0x5500,|
|00001030| 20 20 30 78 39 35 63 31 | 2c 20 20 30 78 39 34 38 | 0x95c1|, 0x948|
|00001040| 31 2c 20 20 30 78 35 34 | 34 30 2c 0a 30 78 39 63 |1, 0x54|40,.0x9c|
|00001050| 30 31 2c 20 20 30 78 35 | 63 63 30 2c 20 20 30 78 |01, 0x5|cc0, 0x|
|00001060| 35 64 38 30 2c 20 20 30 | 78 39 64 34 31 2c 20 20 |5d80, 0|x9d41, |
|00001070| 30 78 35 66 30 30 2c 20 | 20 30 78 39 66 63 31 2c |0x5f00, | 0x9fc1,|
|00001080| 20 20 30 78 39 65 38 31 | 2c 20 20 30 78 35 65 34 | 0x9e81|, 0x5e4|
|00001090| 30 2c 0a 30 78 35 61 30 | 30 2c 20 20 30 78 39 61 |0,.0x5a0|0, 0x9a|
|000010a0| 63 31 2c 20 20 30 78 39 | 62 38 31 2c 20 20 30 78 |c1, 0x9|b81, 0x|
|000010b0| 35 62 34 30 2c 20 20 30 | 78 39 39 30 31 2c 20 20 |5b40, 0|x9901, |
|000010c0| 30 78 35 39 63 30 2c 20 | 20 30 78 35 38 38 30 2c |0x59c0, | 0x5880,|
|000010d0| 20 20 30 78 39 38 34 31 | 2c 0a 30 78 38 38 30 31 | 0x9841|,.0x8801|
|000010e0| 2c 20 20 30 78 34 38 63 | 30 2c 20 20 30 78 34 39 |, 0x48c|0, 0x49|
|000010f0| 38 30 2c 20 20 30 78 38 | 39 34 31 2c 20 20 30 78 |80, 0x8|941, 0x|
|00001100| 34 62 30 30 2c 20 20 30 | 78 38 62 63 31 2c 20 20 |4b00, 0|x8bc1, |
|00001110| 30 78 38 61 38 31 2c 20 | 20 30 78 34 61 34 30 2c |0x8a81, | 0x4a40,|
|00001120| 0a 30 78 34 65 30 30 2c | 20 20 30 78 38 65 63 31 |.0x4e00,| 0x8ec1|
|00001130| 2c 20 20 30 78 38 66 38 | 31 2c 20 20 30 78 34 66 |, 0x8f8|1, 0x4f|
|00001140| 34 30 2c 20 20 30 78 38 | 64 30 31 2c 20 20 30 78 |40, 0x8|d01, 0x|
|00001150| 34 64 63 30 2c 20 20 30 | 78 34 63 38 30 2c 20 20 |4dc0, 0|x4c80, |
|00001160| 30 78 38 63 34 31 2c 0a | 30 78 34 34 30 30 2c 20 |0x8c41,.|0x4400, |
|00001170| 20 30 78 38 34 63 31 2c | 20 20 30 78 38 35 38 31 | 0x84c1,| 0x8581|
|00001180| 2c 20 20 30 78 34 35 34 | 30 2c 20 20 30 78 38 37 |, 0x454|0, 0x87|
|00001190| 30 31 2c 20 20 30 78 34 | 37 63 30 2c 20 20 30 78 |01, 0x4|7c0, 0x|
|000011a0| 34 36 38 30 2c 20 20 30 | 78 38 36 34 31 2c 0a 30 |4680, 0|x8641,.0|
|000011b0| 78 38 32 30 31 2c 20 20 | 30 78 34 32 63 30 2c 20 |x8201, |0x42c0, |
|000011c0| 20 30 78 34 33 38 30 2c | 20 20 30 78 38 33 34 31 | 0x4380,| 0x8341|
|000011d0| 2c 20 20 30 78 34 31 30 | 30 2c 20 20 30 78 38 31 |, 0x410|0, 0x81|
|000011e0| 63 31 2c 20 20 30 78 38 | 30 38 31 2c 20 20 30 78 |c1, 0x8|081, 0x|
|000011f0| 34 30 34 30 2c 0a 7d 20 | 3b 0a 0a 57 54 59 50 45 |4040,.} |;..WTYPE|
|00001200| 0a 75 70 64 63 72 63 28 | 20 69 63 72 63 2c 20 69 |.updcrc(| icrc, i|
|00001210| 63 70 2c 20 69 63 6e 74 | 20 29 0a 20 20 20 20 57 |cp, icnt| ). W|
|00001220| 54 59 50 45 20 69 63 72 | 63 3b 0a 20 20 20 20 75 |TYPE icr|c;. u|
|00001230| 6e 73 69 67 6e 65 64 20 | 63 68 61 72 20 2a 69 63 |nsigned |char *ic|
|00001240| 70 3b 0a 20 20 20 20 69 | 6e 74 20 69 63 6e 74 3b |p;. i|nt icnt;|
|00001250| 0a 7b 0a 20 20 20 20 72 | 65 67 69 73 74 65 72 20 |.{. r|egister |
|00001260| 57 54 59 50 45 20 63 72 | 63 20 3d 20 69 63 72 63 |WTYPE cr|c = icrc|
|00001270| 3b 0a 20 20 20 20 72 65 | 67 69 73 74 65 72 20 75 |;. re|gister u|
|00001280| 6e 73 69 67 6e 65 64 20 | 63 68 61 72 20 2a 63 70 |nsigned |char *cp|
|00001290| 20 3d 20 69 63 70 3b 0a | 20 20 20 20 72 65 67 69 | = icp;.| regi|
|000012a0| 73 74 65 72 20 69 6e 74 | 20 63 6e 74 20 3d 20 69 |ster int| cnt = i|
|000012b0| 63 6e 74 3b 0a 0a 20 20 | 20 20 77 68 69 6c 65 28 |cnt;.. | while(|
|000012c0| 20 63 6e 74 2d 2d 20 29 | 20 7b 0a 23 69 66 6e 64 | cnt-- )| {.#ifnd|
|000012d0| 65 66 20 53 57 41 50 50 | 45 44 0a 09 63 72 63 20 |ef SWAPP|ED..crc |
|000012e0| 3d 20 28 63 72 63 3c 3c | 42 29 20 5e 20 63 72 63 |= (crc<<|B) ^ crc|
|000012f0| 74 61 62 5b 28 63 72 63 | 3e 3e 28 57 2d 42 29 29 |tab[(crc|>>(W-B))|
|00001300| 20 5e 20 2a 63 70 2b 2b | 5d 3b 0a 23 65 6c 73 65 | ^ *cp++|];.#else|
|00001310| 0a 09 63 72 63 20 3d 20 | 28 63 72 63 3e 3e 42 29 |..crc = |(crc>>B)|
|00001320| 20 5e 20 63 72 63 74 61 | 62 5b 28 63 72 63 20 26 | ^ crcta|b[(crc &|
|00001330| 20 28 28 31 3c 3c 42 29 | 2d 31 29 29 20 5e 20 2a | ((1<<B)|-1)) ^ *|
|00001340| 63 70 2b 2b 5d 3b 20 0a | 23 65 6e 64 69 66 20 53 |cp++]; .|#endif S|
|00001350| 57 41 50 50 45 44 0a 20 | 20 20 20 7d 0a 0a 20 20 |WAPPED. | }.. |
|00001360| 20 20 72 65 74 75 72 6e | 28 20 63 72 63 20 29 3b | return|( crc );|
|00001370| 0a 7d 0a 0a 23 69 66 64 | 65 66 20 4d 41 4b 45 54 |.}..#ifd|ef MAKET|
|00001380| 41 42 0a 0a 23 69 6e 63 | 6c 75 64 65 20 3c 73 74 |AB..#inc|lude <st|
|00001390| 64 69 6f 2e 68 3e 0a 6d | 61 69 6e 28 29 0a 7b 0a |dio.h>.m|ain().{.|
|000013a0| 20 20 20 20 69 6e 69 74 | 63 72 63 74 61 62 28 29 | init|crctab()|
|000013b0| 3b 0a 7d 0a 0a 69 6e 69 | 74 63 72 63 74 61 62 28 |;.}..ini|tcrctab(|
|000013c0| 29 0a 7b 0a 20 20 20 20 | 72 65 67 69 73 74 65 72 |).{. |register|
|000013d0| 20 20 69 6e 74 20 62 2c | 20 69 3b 0a 20 20 20 20 | int b,| i;. |
|000013e0| 57 54 59 50 45 20 76 3b | 0a 0a 20 20 20 20 0a 20 |WTYPE v;|.. . |
|000013f0| 20 20 20 66 6f 72 28 20 | 62 20 3d 20 30 3b 20 62 | for( |b = 0; b|
|00001400| 20 3c 3d 20 28 31 3c 3c | 42 29 2d 31 3b 20 2b 2b | <= (1<<|B)-1; ++|
|00001410| 62 20 29 20 7b 0a 23 69 | 66 6e 64 65 66 20 53 57 |b ) {.#i|fndef SW|
|00001420| 41 50 50 45 44 0a 09 66 | 6f 72 28 20 76 20 3d 20 |APPED..f|or( v = |
|00001430| 62 3c 3c 28 57 2d 42 29 | 2c 20 69 20 3d 20 42 3b |b<<(W-B)|, i = B;|
|00001440| 20 2d 2d 69 20 3e 3d 20 | 30 3b 20 29 0a 09 20 20 | --i >= |0; ).. |
|00001450| 20 20 76 20 3d 20 76 20 | 26 20 28 28 57 54 59 50 | v = v |& ((WTYP|
|00001460| 45 29 31 3c 3c 28 57 2d | 31 29 29 20 3f 20 28 76 |E)1<<(W-|1)) ? (v|
|00001470| 3c 3c 31 29 5e 50 20 3a | 20 76 3c 3c 31 3b 0a 23 |<<1)^P :| v<<1;.#|
|00001480| 65 6c 73 65 0a 09 66 6f | 72 28 20 76 20 3d 20 62 |else..fo|r( v = b|
|00001490| 2c 20 69 20 3d 20 42 3b | 20 2d 2d 69 20 3e 3d 20 |, i = B;| --i >= |
|000014a0| 30 3b 20 29 0a 09 20 20 | 20 20 76 20 3d 20 76 20 |0; ).. | v = v |
|000014b0| 26 20 31 20 3f 20 28 76 | 3e 3e 31 29 5e 50 20 3a |& 1 ? (v|>>1)^P :|
|000014c0| 20 76 3e 3e 31 3b 0a 23 | 65 6e 64 69 66 09 20 20 | v>>1;.#|endif. |
|000014d0| 20 20 0a 09 63 72 63 74 | 61 62 5b 62 5d 20 3d 20 | ..crct|ab[b] = |
|000014e0| 76 3b 0a 0a 09 70 72 69 | 6e 74 66 28 20 22 30 78 |v;...pri|ntf( "0x|
|000014f0| 25 6c 78 2c 22 2c 20 76 | 20 26 20 28 28 31 4c 3c |%lx,", v| & ((1L<|
|00001500| 3c 57 29 2d 31 4c 29 29 | 3b 0a 09 69 66 28 20 28 |<W)-1L))|;..if( (|
|00001510| 62 26 37 29 20 3d 3d 20 | 37 20 29 0a 09 20 20 20 |b&7) == |7 ).. |
|00001520| 20 70 72 69 6e 74 66 28 | 22 5c 6e 22 20 29 3b 0a | printf(|"\n" );.|
|00001530| 09 65 6c 73 65 0a 09 20 | 20 20 20 70 72 69 6e 74 |.else.. | print|
|00001540| 66 28 22 20 20 22 29 3b | 0a 20 20 20 20 7d 0a 7d |f(" ");|. }.}|
|00001550| 0a 23 65 6e 64 69 66 0a | 0a 23 69 66 64 65 66 20 |.#endif.|.#ifdef |
|00001560| 54 45 53 54 0a 0a 23 69 | 6e 63 6c 75 64 65 20 3c |TEST..#i|nclude <|
|00001570| 73 74 64 69 6f 2e 68 3e | 0a 23 69 6e 63 6c 75 64 |stdio.h>|.#includ|
|00001580| 65 20 3c 66 63 6e 74 6c | 2e 68 3e 0a 0a 23 64 65 |e <fcntl|.h>..#de|
|00001590| 66 69 6e 65 20 4d 41 58 | 42 55 46 09 34 30 39 36 |fine MAX|BUF.4096|
|000015a0| 0a 0a 0a 0a 6d 61 69 6e | 28 20 61 63 2c 20 61 76 |....main|( ac, av|
|000015b0| 20 29 0a 20 20 20 20 69 | 6e 74 20 61 63 3b 20 63 | ). i|nt ac; c|
|000015c0| 68 61 72 20 2a 2a 61 76 | 3b 0a 7b 0a 20 20 20 20 |har **av|;.{. |
|000015d0| 69 6e 74 20 66 64 3b 0a | 20 20 20 20 69 6e 74 20 |int fd;.| int |
|000015e0| 6e 72 3b 0a 20 20 20 20 | 69 6e 74 20 69 3b 0a 20 |nr;. |int i;. |
|000015f0| 20 20 20 63 68 61 72 20 | 62 75 66 5b 4d 41 58 42 | char |buf[MAXB|
|00001600| 55 46 5d 3b 0a 20 20 20 | 20 57 54 59 50 45 20 63 |UF];. | WTYPE c|
|00001610| 72 63 2c 20 63 72 63 32 | 3b 0a 0a 20 20 20 20 66 |rc, crc2|;.. f|
|00001620| 64 20 3d 20 30 3b 0a 20 | 20 20 20 69 66 28 20 61 |d = 0;. | if( a|
|00001630| 63 20 3e 20 31 20 29 0a | 09 69 66 28 20 28 66 64 |c > 1 ).|.if( (fd|
|00001640| 20 3d 20 6f 70 65 6e 28 | 20 61 76 5b 31 5d 2c 20 | = open(| av[1], |
|00001650| 4f 5f 52 44 4f 4e 4c 59 | 20 29 29 20 3c 20 30 20 |O_RDONLY| )) < 0 |
|00001660| 29 20 7b 0a 09 20 20 20 | 20 70 65 72 72 6f 72 28 |) {.. | perror(|
|00001670| 20 61 76 5b 31 5d 20 29 | 3b 0a 09 20 20 20 20 65 | av[1] )|;.. e|
|00001680| 78 69 74 28 20 2d 31 20 | 29 3b 0a 09 7d 0a 20 20 |xit( -1 |);..}. |
|00001690| 20 20 63 72 63 20 3d 20 | 63 72 63 32 20 3d 20 49 | crc = |crc2 = I|
|000016a0| 4e 49 54 5f 43 52 43 3b | 0a 0a 20 20 20 20 77 68 |NIT_CRC;|.. wh|
|000016b0| 69 6c 65 28 20 28 6e 72 | 20 3d 20 72 65 61 64 28 |ile( (nr| = read(|
|000016c0| 20 66 64 2c 20 62 75 66 | 2c 20 4d 41 58 42 55 46 | fd, buf|, MAXBUF|
|000016d0| 20 29 29 20 3e 20 30 20 | 29 20 7b 0a 09 63 72 63 | )) > 0 |) {..crc|
|000016e0| 20 3d 20 75 70 64 63 72 | 63 28 20 63 72 63 2c 20 | = updcr|c( crc, |
|000016f0| 62 75 66 2c 20 6e 72 20 | 29 3b 0a 20 20 20 20 7d |buf, nr |);. }|
|00001700| 0a 0a 20 20 20 20 69 66 | 28 20 6e 72 20 21 3d 20 |.. if|( nr != |
|00001710| 30 20 29 0a 09 70 65 72 | 72 6f 72 28 20 22 72 65 |0 )..per|ror( "re|
|00001720| 61 64 69 6e 67 22 20 29 | 3b 0a 20 20 20 20 65 6c |ading" )|;. el|
|00001730| 73 65 20 7b 0a 09 70 72 | 69 6e 74 66 28 20 22 25 |se {..pr|intf( "%|
|00001740| 6c 78 5c 6e 22 2c 20 63 | 72 63 20 29 3b 0a 20 20 |lx\n", c|rc );. |
|00001750| 20 20 7d 0a 0a 23 69 66 | 64 65 66 20 4d 41 47 49 | }..#if|def MAGI|
|00001760| 43 43 48 45 43 4b 0a 20 | 20 20 20 2f 2a 20 74 61 |CCHECK. | /* ta|
|00001770| 63 6b 20 6f 6e 65 27 73 | 20 63 6f 6d 70 6c 65 6d |ck one's| complem|
|00001780| 65 6e 74 20 6f 66 20 63 | 72 63 20 6f 6e 74 6f 20 |ent of c|rc onto |
|00001790| 64 61 74 61 20 73 74 72 | 65 61 6d 2c 20 61 6e 64 |data str|eam, and|
|000017a0| 0a 20 20 20 20 20 20 20 | 63 6f 6e 74 69 6e 75 65 |. |continue|
|000017b0| 20 63 72 63 20 63 61 6c | 63 75 6c 61 74 69 6f 6e | crc cal|culation|
|000017c0| 2e 20 20 53 68 6f 75 6c | 64 20 67 65 74 20 61 20 |. Shoul|d get a |
|000017d0| 63 6f 6e 73 74 61 6e 74 | 20 28 6d 61 67 69 63 20 |constant| (magic |
|000017e0| 6e 75 6d 62 65 72 29 0a | 20 20 20 20 20 20 20 64 |number).| d|
|000017f0| 65 70 65 6e 64 65 6e 74 | 20 6f 6e 6c 79 20 6f 6e |ependent| only on|
|00001800| 20 50 2c 20 6e 6f 74 20 | 74 68 65 20 64 61 74 61 | P, not |the data|
|00001810| 2e 0a 20 20 20 20 20 2a | 2f 0a 20 20 20 20 63 72 |.. *|/. cr|
|00001820| 63 32 20 3d 20 63 72 63 | 20 5e 20 2d 31 4c 3b 0a |c2 = crc| ^ -1L;.|
|00001830| 20 20 20 20 66 6f 72 28 | 20 6e 72 20 3d 20 57 2d | for(| nr = W-|
|00001840| 42 3b 20 6e 72 20 3e 3d | 20 30 3b 20 6e 72 20 2d |B; nr >=| 0; nr -|
|00001850| 3d 20 42 20 29 20 7b 0a | 09 62 75 66 5b 30 5d 20 |= B ) {.|.buf[0] |
|00001860| 3d 20 28 63 72 63 32 20 | 3e 3e 20 6e 72 29 3b 0a |= (crc2 |>> nr);.|
|00001870| 09 63 72 63 20 3d 20 75 | 70 64 63 72 63 28 63 72 |.crc = u|pdcrc(cr|
|00001880| 63 2c 20 62 75 66 2c 20 | 31 29 3b 0a 20 20 20 20 |c, buf, |1);. |
|00001890| 7d 0a 0a 20 20 20 20 2f | 2a 20 63 72 63 20 73 68 |}.. /|* crc sh|
|000018a0| 6f 75 6c 64 20 6e 6f 77 | 20 65 71 75 61 6c 20 6d |ould now| equal m|
|000018b0| 61 67 69 63 20 2a 2f 0a | 20 20 20 20 62 75 66 5b |agic */.| buf[|
|000018c0| 30 5d 20 3d 20 62 75 66 | 5b 31 5d 20 3d 20 62 75 |0] = buf|[1] = bu|
|000018d0| 66 5b 32 5d 20 3d 20 62 | 75 66 5b 33 5d 20 3d 20 |f[2] = b|uf[3] = |
|000018e0| 30 3b 0a 20 20 20 20 70 | 72 69 6e 74 66 28 20 22 |0;. p|rintf( "|
|000018f0| 6d 61 67 69 63 20 74 65 | 73 74 3a 20 25 6c 78 20 |magic te|st: %lx |
|00001900| 3d 3f 3d 20 25 6c 78 5c | 6e 22 2c 20 63 72 63 2c |=?= %lx\|n", crc,|
|00001910| 20 75 70 64 63 72 63 28 | 2d 31 2c 20 62 75 66 2c | updcrc(|-1, buf,|
|00001920| 20 57 2f 42 29 29 3b 0a | 23 65 6e 64 69 66 20 4d | W/B));.|#endif M|
|00001930| 41 47 49 43 43 48 45 43 | 4b 0a 7d 0a 0a 23 65 6e |AGICCHEC|K.}..#en|
|00001940| 64 69 66 0a 2d 2d 20 0a | 4d 61 72 6b 20 47 2e 20 |dif.-- .|Mark G. |
|00001950| 4d 65 6e 64 65 6c 2c 20 | 69 68 6e 70 34 21 75 6d |Mendel, |ihnp4!um|
|00001960| 6e 2d 63 73 21 68 79 70 | 65 72 21 6d 61 72 6b 2c |n-cs!hyp|er!mark,|
|00001970| 20 20 4e 65 74 77 6f 72 | 6b 20 53 79 73 74 65 6d | Networ|k System|
|00001980| 73 20 43 6f 72 70 6f 72 | 61 74 69 6f 6e 0a 0a 41 |s Corpor|ation..A|
|00001990| 6c 6c 20 6f 70 69 6e 69 | 6f 6e 73 20 65 78 70 72 |ll opini|ons expr|
|000019a0| 65 73 73 65 64 20 68 65 | 72 65 69 6e 2c 20 65 76 |essed he|rein, ev|
|000019b0| 65 6e 20 74 68 65 20 6d | 6f 73 74 20 61 72 62 69 |en the m|ost arbi|
|000019c0| 74 72 61 72 79 2c 20 61 | 72 65 20 64 65 66 65 6e |trary, a|re defen|
|000019d0| 64 65 64 20 62 79 20 6d | 79 20 0a 65 6d 70 6c 6f |ded by m|y .emplo|
|000019e0| 79 65 72 20 77 69 74 68 | 20 72 65 6c 69 67 69 6f |yer with| religio|
|000019f0| 75 73 20 66 65 72 76 6f | 72 2e 0a 0a 0a |us fervo|r.... |
+--------+-------------------------+-------------------------+--------+--------+