home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff225.lzh / AmigaTCP / src / misc.c < prev    next >
C/C++ Source or Header  |  1989-06-24  |  671b  |  46 lines

  1. /* Miscellaneous machine independent utilities */
  2.  
  3. #include "machdep.h"
  4.  
  5. bcmp(a,b,n)
  6. register char *a,*b;
  7. register int16 n;
  8. {
  9.     while(n-- != 0){
  10.         if(*a++ != *b++)
  11.             return 1;
  12.     }
  13.     return 0;
  14. }
  15.  
  16. bzero(buf,cnt)
  17. register char *buf;
  18. register int16 cnt;
  19. {
  20.     while(cnt-- != 0)
  21.         *buf++ = '\0';
  22. }
  23.  
  24. /* Convert hex-ascii to integer */
  25. int
  26. htoi(s)
  27. char *s;
  28. {
  29.     int i = 0;
  30.     char c;
  31.  
  32.     while((c = *s++) != '\0'){
  33.         if(c == 'x')
  34.             continue;    /* allow 0x notation */
  35.         if('0' <= c && c <= '9')
  36.             i = (i * 16) + (c - '0');
  37.         else if('a' <= c && c <= 'f')
  38.             i = (i * 16) + (c - 'a' + 10);
  39.         else if('A' <= c && c <= 'F')
  40.             i = (i * 16) + (c - 'A' + 10);
  41.         else
  42.             break;
  43.     }
  44.     return i;
  45. }
  46.