1 /* -*- c-file-style: "java"; indent-tabs-mode: nil; tab-width: 4; fill-column: 78 -*- 2 * 3 * Copyright 2005 Google Inc. 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License 7 * as published by the Free Software Foundation; either version 2 8 * of the License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 18 * USA. 19 */ 20 21 #ifndef STRINGMAP_H 22 #define STRINGMAP_H 23 24 typedef struct { 25 /* the strings, and what they map to */ 26 struct { 27 char *key; 28 char *value; 29 } *map; 30 31 /* number of elements in map */ 32 int n; 33 34 /* if nonzero, ignore all but this many trailing words, 35 * where words are separated by the '/' char 36 * Example: 37 * comparison num=1 num=2 num=3 38 * a/b/z =? 1/y/z match no no 39 * a/b/z =? 1/b/z match match no 40 */ 41 int numFinalWordsToMatch; 42 } stringmap_t; 43 44 stringmap_t *stringmap_load(const char *filename, int numFinalWordsToMatch); 45 const char *stringmap_lookup(const stringmap_t *map, const char *string); 46 47 #endif 48