home *** CD-ROM | disk | FTP | other *** search
/ Encyclopedia of Graphics File Formats Companion / GFF_CD.ISO / software / unix / saoimage / sao1_07.tar / vms / bcopy.c next >
Text File  |  1989-11-14  |  1KB  |  67 lines

  1. /** 
  2.  **  BCOPY.C -- Emulation of the Unix BSTRING(3) library routines for VMS.
  3.  **/
  4.  
  5. #define MOVC_MAX 65535
  6.  
  7.  
  8. /* BCOPY -- Copies length bytes from string b1 to string b2.
  9.  * Overlapping strings are handled correctly.
  10.  */
  11. bcopy (b1, b2, length)
  12.     char    *b1, *b2;
  13.     int    length;
  14. {
  15.     unsigned short    len;
  16.  
  17.     while (length > 0) {
  18.         len = (length < MOVC_MAX) ? length : MOVC_MAX;
  19.  
  20.         lib$movc3 (&len, b1, b2);
  21.  
  22.         length -= len;
  23.         b1     += len;
  24.         b2     += len;
  25.     }
  26. }
  27.  
  28.  
  29. /* BCMP -- Compares byte string b1 against byte string b2, returning
  30.  * zero if they are identical, non-zero otherwise.  Both strings are 
  31.  * assumed to be length bytes long.
  32.  */
  33. bcmp (b1, b2, length)
  34.     register char    *b1, *b2;
  35.     int    length;
  36. {
  37.     register int    i;
  38.  
  39.     for (i = 0; i < length; i++)
  40.         if (*b1++ != *b2++)
  41.         return (-1);
  42.     return (0);
  43. }
  44.  
  45.  
  46. /* BZERO -- Zero fill a buffer.
  47.  */
  48. bzero (b, length)
  49.     char    *b;
  50.     int    length;
  51. {
  52.     unsigned short    src_len = 0;
  53.     unsigned short    dst_len;
  54.     char    null = '\000';
  55.  
  56.  
  57.     while (length > 0) {
  58.         dst_len = (length < MOVC_MAX) ? length : MOVC_MAX;
  59.  
  60.         lib$movc5 (&src_len, 0, &null, &dst_len, b);
  61.  
  62.         length -= dst_len;
  63.         b      += dst_len;
  64.     }
  65. }
  66.                                                            
  67.