home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / netds / winsock / nwlink / testlib / memory.c < prev    next >
C/C++ Source or Header  |  1997-10-05  |  1KB  |  44 lines

  1. /****************************************************************************\
  2. *  memory.c -- sample program demonstrating NWLink.
  3. *
  4. *       Microsoft Developer Support
  5. *       Copyright (c) 1992-1997 Microsoft Corporation
  6. *
  7. *  Demonstrates basic sockets programming with the Windows Sockets API
  8. *  using the NWLink transport.
  9. ****************************************************************************/
  10. #include <stdio.h>
  11. #include <windows.h>
  12. #include "externs.h"
  13.  
  14. /****************************************************************************
  15. *
  16. *    FUNCTION:  mem_check( LPSTR p, UCHAR ch, int len)
  17. *
  18. *    PURPOSE:   Makes sure that a buffer is filled with only the character
  19. *               specified.
  20. *
  21. *    ARGUMENTS:    LPSTR    => buffer to scan
  22. *               char    character to check for
  23. *               int     length of buffer to check 
  24. *
  25. *     RETURNS:   0 if buffer has only the specified character
  26. *                offset to non-matching character if found 
  27. *
  28. *\***************************************************************************/
  29. int mem_check(LPSTR p, UCHAR ch, int len)
  30. {
  31.     int buflen;
  32.  
  33.     buflen = len;
  34.  
  35.     while (len--) {
  36.         if ((UCHAR)*p++ != ch) {
  37.             return (buflen - len);
  38.         }
  39.     }
  40.   
  41.     return 0;
  42. }
  43.