home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 024 / psi110g.zip / FNTEST.C < prev    next >
C/C++ Source or Header  |  1994-04-17  |  818b  |  40 lines

  1. /* A simple File name test program.
  2.  * Prints all 255 ascii values, and shows filename validity .
  3.  */
  4. #include <stdio.h>
  5.   
  6. /* Valid characters in a DOS filename matrix */
  7. static unsigned char doschars[] = {
  8.     0x00, 0x00, 0x00, 0x00, 0xfa, 0x23, 0xff, 0x03,
  9.     0xff, 0xff, 0xff, 0xc7, 0xff, 0xff, 0xff, 0x6f,
  10.     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  11.     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  12. };
  13.   
  14. int dosfnchr(int);
  15.   
  16. int
  17. dosfnchr(ch)
  18. int ch;
  19. {
  20.     int i, j;
  21.   
  22.     i = (ch & 0xf8) >> 3;
  23.     j = doschars[i] & (1 << (ch & 0x07));
  24.     return j;
  25. }
  26.   
  27. void main(void);
  28.   
  29. void main(void) {
  30.     int i,cols;
  31.   
  32.     for(i=0;i<256;i++) {
  33.         printf("%3d: %s   ",i,dosfnchr(i) ? "good" : "BAD!");
  34.         if(i%6 == 0)
  35.             printf("\n");
  36.     }
  37.   
  38. }
  39.   
  40.