Tesseract
3.02
|
00001 /************************************************************************** 00002 ** Licensed under the Apache License, Version 2.0 (the "License"); 00003 ** you may not use this file except in compliance with the License. 00004 ** You may obtain a copy of the License at 00005 ** http://www.apache.org/licenses/LICENSE-2.0 00006 ** Unless required by applicable law or agreed to in writing, software 00007 ** distributed under the License is distributed on an "AS IS" BASIS, 00008 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00009 ** See the License for the specific language governing permissions and 00010 ** limitations under the License. 00011 **************************************************************************/ 00012 #include <string.h> 00013 #include <ctype.h> 00014 00015 /*chartoname(name,c,dir) converts c into a useful filename*/ 00016 void chartoname(register char *name, /*result */ 00017 char c, /*char to convert */ 00018 const char *dir) { /*directory to use */ 00019 char file[3]; /*filename */ 00020 int index; /*index of namelist */ 00021 static const char *namelist[] = { 00022 "!bang", 00023 "\"doubleq", 00024 "#hash", 00025 "$dollar", 00026 "%percent", 00027 "&and", 00028 "'quote", 00029 "(lround", 00030 ")rround", 00031 "*asterisk", 00032 "+plus", 00033 ",comma", 00034 "-minus", 00035 ".dot", 00036 "/slash", 00037 ":colon", 00038 ";semic", 00039 "<less", 00040 "=equal", 00041 ">greater", 00042 "?question", 00043 "@at", 00044 "[lsquare", 00045 "\\backsl", 00046 "]rsquare", 00047 "^uparr", 00048 "_unders", 00049 "`grave", 00050 "{lbrace", 00051 "|bar", 00052 "}rbrace", 00053 "~tilde" 00054 }; 00055 00056 strcpy(name, dir); /*add specific directory */ 00057 for (index = 0; index < sizeof namelist / sizeof (char *) 00058 && c != namelist[index][0]; index++); 00059 if (index < sizeof namelist / sizeof (char *)) 00060 /*add text name */ 00061 strcat (name, &namelist[index][1]); 00062 else { 00063 if (isupper (c)) { 00064 file[0] = 'c'; /*direct a-z or A-Z */ 00065 file[1] = c; /*direct a-z or A-Z */ 00066 file[2] = '\0'; 00067 } 00068 else { 00069 file[0] = c; /*direct a-z or A-Z */ 00070 file[1] = '\0'; 00071 } 00072 strcat(name, file); /*append filename */ 00073 } 00074 }