/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 1996-2011 AT&T Intellectual Property *4* and is licensed under the *5* Eclipse Public License, Version 1.0 *6* by AT&T Intellectual Property *7* *8* A copy of the License is available at *9* http://www.eclipse.org/org/documents/epl-v10.html *10* (with md5 checksum b35adb5213ca9657e911e9befb180842) *11* *12* Information and Software Systems Research *13* AT&T Research *14* Florham Park NJ *15* *16* Glenn Fowler <[email protected]> *17* *18***********************************************************************/19#pragma prototyped2021/*22* bsd23*/2425#define bsd_description \26"The BSD checksum."27#define bsd_options 028#define bsd_match "bsd|ucb"29#define bsd_open long_open30#define bsd_init long_init31#define bsd_done short_done32#define bsd_print long_print33#define bsd_data long_data34#define bsd_scale 10243536static int37bsd_block(register Sum_t* p, const void* s, size_t n)38{39register uint32_t c = ((Integral_t*)p)->sum;40register unsigned char* b = (unsigned char*)s;41register unsigned char* e = b + n;4243while (b < e)44c = ((c >> 1) + *b++ + ((c & 01) ? 0x8000 : 0)) & 0xffff;45((Integral_t*)p)->sum = c;46return 0;47}484950