home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / uucp / duucp-1.17 / AU-117b4-src.lha / src / lib / seqname.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-24  |  662 b   |  42 lines

  1. /*
  2.  *  SEQNAME.C
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include "config.h"
  8.  
  9. Prototype char *SeqToName (long);
  10.  
  11. /*
  12.  *  Convert a sequence number into a numeric/character combination.  Names
  13.  *  are unique and case-insensitive.  The sequence number 0-0xFFFFF will be
  14.  *  converted to a 4 character string each position containing 0-9 a-z,
  15.  *  or base 36 (total of 1.6 million combinations)
  16.  */
  17.  
  18. char *
  19. SeqToName (long seqNo)
  20. {
  21.     static char
  22.         Buf [5];
  23.     short
  24.         i;
  25.  
  26.     seqNo &= 0xFFFFF;
  27.  
  28.     for (i = 3; i >= 0; --i) {
  29.         short
  30.             n = seqNo % 36;
  31.  
  32.         if (n < 10)
  33.             Buf [i] = n + '0';
  34.         else
  35.             Buf [i] = n - 10 + 'a';
  36.         seqNo /= 36;
  37.     }
  38.     Buf [4] = 0;
  39.  
  40.     return Buf;
  41. }
  42.