fdchecksum32.c.html 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?xml version='1.0' encoding='iso-8859-1'?>
  2. <!doctype html public '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
  3. <html xmlns='http://www.w3c.org/1999/xhtml' lang='en-us'>
  4. <head>
  5. <title>
  6. fdchecksum32.c
  7. </title>
  8. <meta http-equiv='content-type' content='text/html;iso-8859-1'/>
  9. <meta name='generator' content='motley-tools 1.9.4 13:40:33 Feb 18 2015'/>
  10. <meta name='author' content='cmaier@cmassoc.net'/>
  11. <meta name='robots' content='noindex,nofollow'/>
  12. <link href='toolkit.css' rel='stylesheet' type='text/css'/>
  13. </head>
  14. <body>
  15. <div class='headerlink'>
  16. [<a href='fcs.c.html' title=' fcs.c '>PREV</a>]
  17. [<a href='toolkit.html' title=' Index '>HOME</a>]
  18. [<a href='fdmanifest.c.html' title=' fdmanifest.c '>NEXT</a>]
  19. </div>
  20. <pre>
  21. /*====================================================================*
  22. *
  23. * uint32_t fdchecksum32 (int fd, size_t extent, uint32_t checksum);
  24. *
  25. * memory.h
  26. *
  27. * return the 32-bit checksum of a file region starting from the
  28. * current file position; extent is specified in bytes but will be
  29. * rounded to a multiple of four bytes;
  30. *
  31. * Motley Tools by Charles Maier &lt;cmaier@cmassoc.net&gt;;
  32. * Copyright (c) 2001-2006 by Charles Maier Associates;
  33. * Licensed under the Internet Software Consortium License;
  34. *
  35. *--------------------------------------------------------------------*/
  36. #ifndef FDCHECKSUM32_SOURCE
  37. #define FDCHECKSUM32_SOURCE
  38. #include &lt;stdio.h&gt;
  39. #include &lt;unistd.h&gt;
  40. #include &lt;errno.h&gt;
  41. #include &quot;../tools/memory.h&quot;
  42. uint32_t fdchecksum32 (int fd, register size_t extent, register uint32_t checksum)
  43. {
  44. uint32_t memory;
  45. while (extent &gt;= sizeof (memory))
  46. {
  47. if (read (fd, &amp;memory, sizeof (memory)) != sizeof (memory))
  48. {
  49. return (-1);
  50. }
  51. extent -= sizeof (memory);
  52. checksum ^= memory;
  53. }
  54. return (~checksum);
  55. }
  56. #endif
  57. </pre>
  58. <div class='footerlink'>
  59. [<a href='fcs.c.html' title=' fcs.c '>PREV</a>]
  60. [<a href='toolkit.html' title=' Index '>HOME</a>]
  61. [<a href='fdmanifest.c.html' title=' fdmanifest.c '>NEXT</a>]
  62. </div>
  63. </body>
  64. </html>