rde@eagle.ukc.ac.uk (R.D.Eager) (06/22/87)
Anyone know the algoritm used by the undocumented CHECKSUM command on VAX/VMS? I'd like to be able to generate/check these on non VAX/VMS systems, to allow some measure of checking on transferred files. I know I could just implement a program, but I want to be able to do the VMS end entirely in DCL (no, I'm not writing my own checksum program in DCL either!). Seriously, if anyone can help.... -- Bob Eager (Captain Nemo) rde@ukc.UUCP ...!mcvax!ukc!rde Phone: +44 227 764000 ext 7589
carl@CITHEX.CALTECH.EDU.UUCP (06/28/87)
> Anyone know the algoritm used by the undocumented CHECKSUM command on > VAX/VMS? I'd like to be able to generate/check these on non VAX/VMS systems, > to allow some measure of checking on transferred files. I assume that you only need the algorithm for CHECKSUM/FILE, and not the stuff for CHECKSUM/IMAGE. If this is the case, then what you need to know (assuming that you've opened the file with RMS, and that your RAB is called "myrab") is: #include rab #include rms unsigned long *longbuffer; unsigned char *charbuffer; long n_longwords, n_bytes, i; checksum = 0; while ((status = SYS$GET(myrab)) != rms$_eof) { if ((status & 7) != 1) { puts("Error during read:"); exit(status); } n_longwords = myrab.rab$w_rsz/4; n_bytes = myrab.rab$w_rsz & 3; longbuffer = (unsigned long *) &(myrab.rab$l_rbf); bytebuffer = (unsigned char *) &(longbuffer[n_longwords]); for (i = 0; i < n_longwords; ++i) checksum = checksum XOR longbuffer[i]; for (i = 0; i < n_bytes; ++i) checksum = checksum + bytebuffer[i]; }