#include <string.h>
#include <ctype.h>
Go to the source code of this file.
void chartoname | ( | register char * | name, | |
char | c, | |||
const char * | dir | |||
) |
converts c into a useful filename
Definition at line 21 of file chartoname.cpp.
Referenced by LearnBlob().
00023 { /*directory to use */ 00024 char file[3]; /*filename */ 00025 int index; /*index of namelist */ 00026 static const char *namelist[] = { 00027 "!bang", 00028 "\"doubleq", 00029 "#hash", 00030 "$dollar", 00031 "%percent", 00032 "&and", 00033 "'quote", 00034 "(lround", 00035 ")rround", 00036 "*asterisk", 00037 "+plus", 00038 ",comma", 00039 "-minus", 00040 ".dot", 00041 "/slash", 00042 ":colon", 00043 ";semic", 00044 "<less", 00045 "=equal", 00046 ">greater", 00047 "?question", 00048 "@at", 00049 "[lsquare", 00050 "\\backsl", 00051 "]rsquare", 00052 "^uparr", 00053 "_unders", 00054 "`grave", 00055 "{lbrace", 00056 "|bar", 00057 "}rbrace", 00058 "~tilde" 00059 }; 00060 00061 strcpy(name, dir); /*add specific directory */ 00062 for (index = 0; index < sizeof namelist / sizeof (char *) 00063 && c != namelist[index][0]; index++); 00064 if (index < sizeof namelist / sizeof (char *)) 00065 /*add text name */ 00066 strcat (name, &namelist[index][1]); 00067 else { 00068 if (isupper (c)) { 00069 file[0] = 'c'; /*direct a-z or A-Z */ 00070 file[1] = c; /*direct a-z or A-Z */ 00071 file[2] = '\0'; 00072 } 00073 else { 00074 file[0] = c; /*direct a-z or A-Z */ 00075 file[1] = '\0'; 00076 } 00077 strcat(name, file); /*append filename */ 00078 } 00079 }