gooch has asked for the wisdom of the Perl Monks concerning the following question:
#include <stdio.h> /********************************************************************* +***/ /* checksum -- verify checksum */ /********************************************************************* +***/ int checksum (buff, bufflen) char *buff ; int bufflen ; { int ctr ; int retval ; char tmpstr [5] ; long strtol () ; unsigned int chk_sum = (unsigned) 0 ; int twos_comp ; ctr = 0 ; while (ctr < (bufflen - 5)) { chk_sum = chk_sum + (buff [ctr] & 0x7f) ; ctr ++ ; } strncpy (tmpstr, &buff [bufflen - 5], 4) ; tmpstr [4] = '\0' ; twos_comp = (int) strtol (tmpstr, (char **) NULL, 16) ; retval = (((chk_sum + twos_comp) & 0xFFFF) == 0) ? 0 : 1 ; return (retval) ; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Conversion of C code to Perl-ese.
by BrowserUk (Patriarch) on Aug 14, 2003 at 01:31 UTC | |
by gooch (Monk) on Aug 14, 2003 at 15:52 UTC | |
|
Re: Conversion of C code to Perl-ese.
by CombatSquirrel (Hermit) on Aug 13, 2003 at 22:54 UTC | |
by gooch (Monk) on Aug 13, 2003 at 23:50 UTC | |
by esh (Pilgrim) on Aug 14, 2003 at 01:10 UTC | |
|
Re: Conversion of C code to Perl-ese.
by hsmyers (Canon) on Aug 14, 2003 at 04:51 UTC | |
|
Re: Conversion of C code to Perl-ese.
by gooch (Monk) on Aug 13, 2003 at 22:34 UTC |