1 /* database.h -- header file for the database module. 2 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 3 National Institute of Advanced Industrial Science and Technology (AIST) 4 Registration Number H15PRO112 5 6 This file is part of the m17n library. 7 8 The m17n library is free software; you can redistribute it and/or 9 modify it under the terms of the GNU Lesser General Public License 10 as published by the Free Software Foundation; either version 2.1 of 11 the License, or (at your option) any later version. 12 13 The m17n library is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 Lesser General Public License for more details. 17 18 You should have received a copy of the GNU Lesser General Public 19 License along with the m17n library; if not, write to the Free 20 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 21 Boston, MA 02110-1301 USA. */ 22 23 #ifndef _M17N_DATABASE_H_ 24 #define _M17N_DATABASE_H_ 25 26 #ifndef M17NDIR 27 #define M17NDIR "/usr/local/share/m17n" 28 #endif 29 30 #ifndef PATH_MAX 31 #define PATH_MAX 1024 32 #endif 33 34 #ifndef PATH_SEPARATOR 35 #define PATH_SEPARATOR '/' 36 #endif 37 38 enum MDatabaseStatus 39 { 40 /* The database was defined automatically (from mdb.dir file(s)) 41 with no wildcard tag. */ 42 MDB_STATUS_AUTO, 43 /* The database was defined automatically (from mdb.dir file(s)). 44 with a wildcard tag. */ 45 MDB_STATUS_AUTO_WILDCARD, 46 /* The database was defined explicitely (by mdatabase_define ()). */ 47 MDB_STATUS_EXPLICIT, 48 /* The databse is currently disabled. (usually because it is 49 deleted from mdb.dir file(s)). */ 50 MDB_STATUS_DISABLED, 51 MDB_STATUS_UPDATED, 52 MDB_STATUS_OUTDATED 53 }; 54 55 typedef struct 56 { 57 /* Name of the file containing the database. */ 58 char *filename; 59 /* Length of FILENAME. */ 60 int len; 61 /* Absolute path of filename. */ 62 char *absolute_filename; 63 /* The current status of the database. */ 64 enum MDatabaseStatus status; 65 /* When the database was loaded last. 0 if it has never been 66 loaded. */ 67 time_t time; 68 char *lock_file, *uniq_file; 69 70 MPlist *properties; 71 } MDatabaseInfo; 72 73 extern MPlist *mdatabase__dir_list; 74 75 extern void mdatabase__update (void); 76 77 extern MPlist *mdatabase__load_for_keys (MDatabase *mdb, MPlist *keys); 78 79 extern int mdatabase__check (MDatabase *mdb); 80 81 extern char *mdatabase__find_file (char *filename); 82 83 extern char *mdatabase__file (MDatabase *mdb); 84 85 extern int mdatabase__lock (MDatabase *mdb); 86 87 extern int mdatabase__save (MDatabase *mdb, MPlist *data); 88 89 extern int mdatabase__unlock (MDatabase *mdb); 90 91 extern MPlist *mdatabase__props (MDatabase *mdb); 92 93 extern void *(*mdatabase__load_charset_func) (FILE *fp, MSymbol charset_name); 94 95 #endif /* not _M17N_DATABASE_H_ */ 96