home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / k95source / ckctox.c < prev    next >
C/C++ Source or Header  |  2020-01-01  |  830b  |  42 lines

  1. #define CHAR unsigned char
  2.  
  3. static char rxdigits[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  4.  
  5. char *
  6. #ifdef CK_ANSIC
  7. ckctox(CHAR c, int flag)
  8. #else
  9. ckctox(c, flag) CHAR c; int flag;
  10. #endif
  11. /* ckctox */ {
  12.     static char buf[48];
  13.     static int current = 0;
  14.     int x;
  15.     char h;
  16.     if (current > 45)
  17.       current = 0;
  18.     x = (c >> 4) & 0x0f;
  19.     h = rxdigits[x];
  20.     if (!flag && isupper(rxdigits[x]))
  21.       h = tolower(rxdigits[x]);
  22.     buf[current++] = h;
  23.     x = c & 0x0f;
  24.     h = rxdigits[x];
  25.     if (!flag && isupper(rxdigits[x]))
  26.       h = tolower(rxdigits[x]);
  27.     buf[current++] = h;
  28.     buf[current++] = '\0';
  29.     return((char *)(buf + current - 3));
  30. }
  31.  
  32.  
  33. main() {
  34.     int i;
  35.     CHAR c;
  36.     for (i = 0; i < 256; i++) {
  37.         c = i & 0xff;
  38.         printf("%s",ckctox(c,0));
  39.         printf("%s",ckctox(c,1));
  40.     }
  41. }
  42.