1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Posix 100.32 compliant %@cksum[] function.

Discussion in 'Suggestions' started by mfarah, Jan 12, 2017.

  1. mfarah

    Joined:
    Nov 2, 2009
    Messages:
    226
    Likes Received:
    5
    For pretty much forever, I've quickly compared files residing on Linux server(s) with copies on my local Windows machine using GNU's crc32 command on the former(s) and %@crc32[] on the latter. All was well and good, until...

    ... my new job, where we use AIX 7.1 servers. Please don't laugh at me. Among several other annoyances, there is no crc32 utility — instead, there's only the Unix standard cksum command, which generates decimal CRC32 values, according to the Posix 100.32 standard, and which differ significantly from the ones generated by GNU's crc32.

    I'd like TCC to have a new %@cksum[] function that outputs the decimal CRC32 value of the contents of a file, according to the Posix 100.32 standard.



    For the sake of clarity:
    - cksum is a standard Unix command; Linux *also* has it, and it performs identically to AIX 7.1 on this regard.
    - I'm aware that %@crc32[d, ...] outputs a decimal value. My problem is that %@crc32[d, testFile] doesn't return the same value as cksum testFile.
    - Don't touch %@crc32[]! It outputs same as all the *zip programs, which is a great feature in and of itself.

    Thanks.
     
  2. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,191
    Likes Received:
    11
    While not a direct answer, can you use md5sum and @md5[] instead?
     
  3. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,191
    Likes Received:
    11
    According to Wikipedia, there are at least 5 different CRC32 algorithms.
    CRC-32
    CRC-32C
    CRC-32K
    CRC-32K2
    CRC-32Q
    They each use a different polynomial, so will produce different results.
     
  4. mfarah

    Joined:
    Nov 2, 2009
    Messages:
    226
    Likes Received:
    5
    md5sum exists in Linux distributions, but is not present on AIX syst Actually, turns out that csum -h MD5 fileName does it.
     
  5. mfarah

    Joined:
    Nov 2, 2009
    Messages:
    226
    Likes Received:
    5
    So I thought about this: use csum, as above, and forget about my initial request, or nevertheless ask that my proposed %@cksum function is added (either as a new feature of TCMD itself, or as a plugin)?

    Considering that cksum is part of the POSIX standard, I think it'd be in everyone's best interest to have it added as a core function. IMHO, of course.
     
  6. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,972
    Likes Received:
    30
    I quickly threw together a CKSUM.EXE after stripping down some code I googled up. It gives the same results as my (2003) Gnu CKSUM.EXE (good/bad?). It's 32-bit and (for now) has ZERO error handling. Syntax "CKSUM filename". If it does what's desired I could make it more robust and put it in a plugin or just send the code to Rex. If anyone wants to try it, anonymous FTP to lucky.syr.edu ... CKSUM.ZIP. Let me know ... does it give the desired result?
     
  7. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,972
    Likes Received:
    30
    Here's another, including 64-bit and a little error checking. It's attached and also on ftp://lucky.syr.edu. It agrees with CKSUM on the only UNIX system I have access to. I'd really like to know if it's the checksum being discussed here.
     

    Attached Files:

  8. mfarah

    Joined:
    Nov 2, 2009
    Messages:
    226
    Likes Received:
    5
    I've been testing your small executable (64-bit version only, though) and so far, everything's working fine.
     
  9. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,972
    Likes Received:
    30
    Thanks. Is it the checksum you wanted?
     
  10. mfarah

    Joined:
    Nov 2, 2009
    Messages:
    226
    Likes Received:
    5
    Yup. Thanks. :-)
     
  11. vefatica

    Joined:
    May 20, 2008
    Messages:
    7,972
    Likes Received:
    30
    Gnu's CKSUM.EXE does the same thing. I don't know if Gnu's coreutils exist in x64 format. I'll send my code to Rex. Maybe he'll include @CKSUM (or something like that) in the next version of TCC.
     
  12. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,870
    Likes Received:
    83
  13. mfarah

    Joined:
    Nov 2, 2009
    Messages:
    226
    Likes Received:
    5
    I've been testing this function. No issues detected. Thanks. :-)
     

Share This Page