Jonathan Gordon | e7ef935 | 2010-05-27 15:35:22 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id: tag_table.c 26297 2010-05-26 03:53:06Z jdgordon $ |
| 9 | * |
| 10 | * Copyright (C) 2010 Robert Bieber |
| 11 | * |
| 12 | * This program is free software; you can redistribute it and/or |
| 13 | * modify it under the terms of the GNU General Public License |
| 14 | * as published by the Free Software Foundation; either version 2 |
| 15 | * of the License, or (at your option) any later version. |
| 16 | * |
| 17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 18 | * KIND, either express or implied. |
| 19 | * |
| 20 | ****************************************************************************/ |
| 21 | |
| 22 | #include "tag_table.h" |
| 23 | |
| 24 | #include <string.h> |
| 25 | |
| 26 | /* The tag definition table */ |
| 27 | struct tag_info legal_tags[] = |
| 28 | { |
| 29 | { "ac", "" }, |
| 30 | { "al", "" }, |
| 31 | { "aL", "" }, |
| 32 | { "ar", "" }, |
| 33 | { "aR", "" }, |
Jonathan Gordon | 20dcf0b | 2010-05-28 02:30:27 +0000 | [diff] [blame] | 34 | { "ax", "" }, |
Jonathan Gordon | e7ef935 | 2010-05-27 15:35:22 +0000 | [diff] [blame] | 35 | |
| 36 | { "bl" , "*fIIII" }, |
| 37 | { "bv", "" }, |
| 38 | { "bt", "" }, |
| 39 | { "bs", "" }, |
| 40 | { "bc", "" }, |
| 41 | { "bp", "" }, |
| 42 | { "bu", "" }, |
| 43 | |
| 44 | |
| 45 | { "cc", "" }, |
| 46 | { "cd", "" }, |
| 47 | { "ce", "" }, |
| 48 | { "cf", "" }, |
| 49 | { "cH", "" }, |
| 50 | { "ck", "" }, |
| 51 | { "cI", "" }, |
| 52 | { "cl", "" }, |
| 53 | { "cm", "" }, |
| 54 | { "cM", "" }, |
| 55 | { "cS", "" }, |
| 56 | { "cy", "" }, |
| 57 | { "cY", "" }, |
| 58 | { "cP", "" }, |
| 59 | { "cp", "" }, |
| 60 | { "ca", "" }, |
| 61 | { "cb", "" }, |
| 62 | { "cu", "" }, |
| 63 | { "cw", "" }, |
| 64 | |
| 65 | { "fb", "" }, |
| 66 | { "fc", "" }, |
| 67 | { "ff", "" }, |
| 68 | { "fk", "" }, |
| 69 | { "fm", "" }, |
| 70 | { "fn", "" }, |
| 71 | { "fp", "" }, |
| 72 | { "fs", "" }, |
| 73 | { "fv", "" }, |
| 74 | { "d" , "I" }, |
| 75 | |
| 76 | { "Fb", "" }, |
| 77 | { "Fc", "" }, |
| 78 | { "Ff", "" }, |
| 79 | { "Fk", "" }, |
| 80 | { "Fm", "" }, |
| 81 | { "Fn", "" }, |
| 82 | { "Fp", "" }, |
| 83 | { "Fs", "" }, |
| 84 | { "Fv", "" }, |
| 85 | { "D" , "I" }, |
| 86 | |
| 87 | |
| 88 | { "ia", "" }, |
| 89 | { "ic", "" }, |
| 90 | { "id", "" }, |
| 91 | { "iA", "" }, |
| 92 | { "iG", "" }, |
| 93 | { "ig", "" }, |
| 94 | { "ik", "" }, |
| 95 | { "in", "" }, |
| 96 | { "it", "" }, |
| 97 | { "iv", "" }, |
| 98 | { "iy", "" }, |
| 99 | { "iC", "" }, |
| 100 | |
| 101 | { "Ia", "" }, |
| 102 | { "Ic", "" }, |
| 103 | { "Id", "" }, |
| 104 | { "IA", "" }, |
| 105 | { "IG", "" }, |
| 106 | { "Ig", "" }, |
| 107 | { "Ik", "" }, |
| 108 | { "In", "" }, |
| 109 | { "It", "" }, |
| 110 | { "Iv", "" }, |
| 111 | { "Iy", "" }, |
| 112 | { "IC", "" }, |
| 113 | |
| 114 | { "Sp", "" }, |
| 115 | { "Ss", "" }, |
| 116 | |
| 117 | { "lh", "" }, |
| 118 | |
| 119 | { "mh", "" }, |
| 120 | { "mr", "" }, |
| 121 | { "mm", "" }, |
| 122 | { "mp", "" }, |
| 123 | { "mv", "|I" }, |
| 124 | |
| 125 | { "pm", "" }, |
| 126 | { "pf", "" }, |
| 127 | { "pb" , "*fIIII" }, |
| 128 | { "pv" , "*fIIII" }, |
| 129 | |
| 130 | { "px", "" }, |
| 131 | { "pc", "" }, |
| 132 | { "pr", "" }, |
| 133 | { "pt", "" }, |
| 134 | { "pS" , "|I"}, |
| 135 | { "pE" , "|I"}, |
| 136 | { "pp", "" }, |
| 137 | { "pe", "" }, |
| 138 | { "pn", "" }, |
| 139 | { "ps", "" }, |
| 140 | |
| 141 | { "rp", "" }, |
| 142 | { "rr", "" }, |
| 143 | { "ra", "" }, |
| 144 | |
| 145 | { "rg", "" }, |
| 146 | { "xf", "" }, |
| 147 | |
| 148 | { "tp", "" }, |
| 149 | { "tt", "" }, |
| 150 | { "tm", "" }, |
| 151 | { "ts", "" }, |
| 152 | { "ta", "" }, |
| 153 | { "tb", "" }, |
| 154 | { "tf", "" }, |
| 155 | { "Ti", "" }, |
| 156 | { "Tn", "" }, |
| 157 | { "Tf", "" }, |
| 158 | { "Tc", "" }, |
| 159 | { "tx", "" }, |
| 160 | { "ty", "" }, |
| 161 | { "tz", "" }, |
| 162 | |
| 163 | { "s", "" }, |
| 164 | { "t" , "I" }, |
| 165 | |
| 166 | { "we", "" }, |
| 167 | { "wd", "" }, |
| 168 | { "wi", "" }, |
| 169 | |
| 170 | { "xl", "SFIIi" }, |
| 171 | { "xd", "S" }, |
| 172 | { "x", "SFII" }, |
| 173 | |
| 174 | { "Fl" , "IF"}, |
| 175 | { "Cl" , "IISS"}, |
| 176 | { "C" , ""}, |
| 177 | |
| 178 | { "Vd" , "S"}, |
| 179 | { "VI" , "S"}, |
| 180 | |
| 181 | { "Vp" , "ICC"}, |
| 182 | { "Lt" , ""}, |
| 183 | { "Li" , ""}, |
| 184 | |
| 185 | { "Vl" , "SIIiii|ii"}, |
| 186 | { "Vi" , "sIIiii|ii"}, |
| 187 | { "V" , "IIiii|ii"}, |
| 188 | |
| 189 | { "X" , "f"}, |
| 190 | |
| 191 | { "St" , "S"}, |
| 192 | { "Sx" , "S"}, |
| 193 | { "Sr" , ""}, |
| 194 | |
| 195 | { "Tl" , "|I"}, |
| 196 | { "cs", "" }, |
| 197 | { "T" , "IIiiI"}, |
| 198 | |
| 199 | { "Rp" , ""}, |
| 200 | { "Rr" , ""}, |
| 201 | { "Rf" , ""}, |
| 202 | { "Re" , ""}, |
| 203 | { "Rb" , ""}, |
| 204 | { "Rm" , ""}, |
| 205 | { "Rs" , ""}, |
| 206 | { "Rn" , ""}, |
| 207 | { "Rh" , ""}, |
| 208 | { "s",""}, |
| 209 | |
| 210 | { "" , ""} /* Keep this here to mark the end of the table */ |
| 211 | }; |
| 212 | |
| 213 | /* A table of legal escapable characters */ |
| 214 | char legal_escape_characters[] = "%(,);#<|>"; |
| 215 | |
| 216 | /* |
| 217 | * Just does a straight search through the tag table to find one by |
| 218 | * the given name |
| 219 | */ |
| 220 | char* find_tag(char* name) |
| 221 | { |
| 222 | |
| 223 | struct tag_info* current = legal_tags; |
| 224 | |
| 225 | /* |
| 226 | * Continue searching so long as we have a non-empty name string |
| 227 | * and the name of the current element doesn't match the name |
| 228 | * we're searching for |
| 229 | */ |
| 230 | |
| 231 | while(strcmp(current->name, name) && current->name[0] != '\0') |
| 232 | current++; |
| 233 | |
| 234 | if(current->name[0] == '\0') |
| 235 | return NULL; |
| 236 | else |
| 237 | return current->params; |
| 238 | |
| 239 | } |
| 240 | |
| 241 | /* Searches through the legal escape characters string */ |
| 242 | int find_escape_character(char lookup) |
| 243 | { |
| 244 | char* current = legal_escape_characters; |
| 245 | while(*current != lookup && *current != '\0') |
| 246 | current++; |
| 247 | |
| 248 | if(*current == lookup) |
| 249 | return 1; |
| 250 | else |
| 251 | return 0; |
| 252 | } |