1 2 /*************************************************************************** 3 * __ __ _ ___________ * 4 * \ \ / /| |____ ____| * 5 * \ \ / / | | | | * 6 * \ \ /\ / / | | | | * 7 * \ \/ \/ / | | | | * 8 * \ /\ / | | | | * 9 * \/ \/ |_| |_| * 10 * * 11 * Wiimms ISO Tools * 12 * http://wit.wiimm.de/ * 13 * * 14 *************************************************************************** 15 * * 16 * This file is part of the WIT project. * 17 * Visit http://wit.wiimm.de/ for project details and sources. * 18 * * 19 * Copyright (c) 2009-2013 by Dirk Clemens <wiimm@wiimm.de> * 20 * * 21 *************************************************************************** 22 * * 23 * This program is free software; you can redistribute it and/or modify * 24 * it under the terms of the GNU General Public License as published by * 25 * the Free Software Foundation; either version 2 of the License, or * 26 * (at your option) any later version. * 27 * * 28 * This program is distributed in the hope that it will be useful, * 29 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 31 * GNU General Public License for more details. * 32 * * 33 * See file gpl-2.0.txt or http://www.gnu.org/licenses/gpl-2.0.txt * 34 * * 35 ***************************************************************************/ 36 37 #ifndef WIT_TITELS_H 38 #define WIT_TITELS_H 1 39 40 #include "types.h" 41 42 // 43 /////////////////////////////////////////////////////////////////////////////// 44 /////////////// docu /////////////// 45 /////////////////////////////////////////////////////////////////////////////// 46 #if 0 47 48 //--------------------------------------------------------------------------- 49 // 50 // The title data base is a list of pointers. Each pointer points to a 51 // dynamic allocated memory location structured by this: 52 // 53 // 6 bytes : For the ID. The ID have 1 to 6 characters padded with NULL. 54 // 1 byte : A NULL character (needed by strcmp()) 55 // >=1 byte : The title, NULL terminated. 56 // 57 // The list is orderd by the ID which is unique in the data base. 58 // 59 // While inserting an ID an existing entry will be removed. Additional all 60 // entries that begins with the new ID are removed. 61 // 62 // While looking up for an ID, the ID itself is searched. If not found an 63 // abbreviaton for that ID is searched. Binary searching is used. 64 // 65 //--------------------------------------------------------------------------- 66 67 #endif 68 // 69 /////////////////////////////////////////////////////////////////////////////// 70 /////////////// declarations /////////////// 71 /////////////////////////////////////////////////////////////////////////////// 72 73 extern int title_mode; 74 75 extern struct StringList_t * first_title_fname; 76 extern struct StringList_t ** append_title_fname; 77 78 79 /////////////////////////////////////////////////////////////////////////////// 80 81 typedef struct ID_t 82 { 83 char id[7]; // the ID padded with at least 1 NULL 84 char title[2]; // the title 85 86 } ID_t; 87 88 /////////////////////////////////////////////////////////////////////////////// 89 90 typedef struct ID_DB_t 91 { 92 ID_t ** list; // pointer to the title field 93 int used; // number of used titles in the title field 94 int size; // number of allocated pointer in 'title' 95 96 } ID_DB_t; 97 98 // 99 /////////////////////////////////////////////////////////////////////////////// 100 /////////////// titles interface /////////////// 101 /////////////////////////////////////////////////////////////////////////////// 102 103 extern ID_DB_t title_db; // title database 104 105 // file support 106 void InitializeTDB(); 107 int AddTitleFile ( ccp arg, int unused ); 108 109 // title lookup 110 ccp GetTitle ( ccp id6, ccp default_if_failed ); 111 112 // 113 /////////////////////////////////////////////////////////////////////////////// 114 /////////////// select id interface /////////////// 115 /////////////////////////////////////////////////////////////////////////////// 116 117 typedef enum enumSelectID 118 { 119 SEL_F_FILE = 1, // flag: source is file 120 SEL_F_PARAM = 2, // flag: '=param' allowed 121 122 SEL_ID = 0, 123 SEL_FILE = SEL_F_FILE, 124 SEL_ID_P = SEL_F_PARAM, 125 SEL_FILE_P = SEL_F_FILE | SEL_F_PARAM, 126 127 } enumSelectID; 128 129 /////////////////////////////////////////////////////////////////////////////// 130 131 typedef enum enumSelectUsed 132 { 133 SEL_UNUSED = 1, 134 SEL_USED = 2, 135 SEL_ALL = SEL_UNUSED | SEL_USED 136 137 } enumSelectUsed; 138 139 /////////////////////////////////////////////////////////////////////////////// 140 141 142 extern int disable_exclude_db; // disable exclude db at all if > 0 143 extern bool include_first; // use include rules before exclude 144 145 int AddIncludeID ( ccp arg, int select_mode ); 146 int AddIncludePath ( ccp arg, int unused ); 147 148 int AddExcludeID ( ccp arg, int select_mode ); 149 int AddExcludePath ( ccp arg, int unused ); 150 151 void SetupExcludeDB(); 152 void DefineExcludePath ( ccp path, int max_dir_depth ); 153 154 bool IsExcludeActive(); 155 bool IsExcluded ( ccp id6 ); 156 void DumpExcludeDB(); 157 158 // 159 /////////////////////////////////////////////////////////////////////////////// 160 /////////////// param id6 interface /////////////// 161 /////////////////////////////////////////////////////////////////////////////// 162 163 extern StringField_t param_id6; // param id6 (without wildcard '.') 164 extern StringField_t param_pat; // param pattern (with wildcard '.') 165 166 void ClearParamDB(); 167 int AddParamID ( ccp arg, int select_mode ); 168 int CountParamID (); 169 IdItem_t * FindParamID ( ccp id6 ); 170 int DumpParamDB ( enumSelectUsed mask, bool warn ); 171 172 int SetupParamDB 173 ( 174 // return the number of valid parameters or NULL on error 175 176 ccp default_param, // not NULL: use this if no param is defined 177 bool warn, // print a warning if no param is defined 178 bool allow_arg // allow arguments '=arg' 179 ); 180 181 struct WBFS_t; 182 183 IdItem_t * CheckParamSlot 184 ( 185 // return NULL if no disc at slot found or disc not match or disabled 186 // or a pointer to the string item 187 188 struct WBFS_t * wbfs, // valid and opened WBFS 189 int slot, // valid slot index 190 bool open_disc, // true: open the disc 191 ccp * ret_id6, // not NULL: store pointer to ID6 of disc 192 // The ID6 is valid until the WBFS is closed 193 ccp * ret_title // not NULL: store pointer to title of disc 194 // The title is searched in the title db first 195 // The title may be stored in a static buffer 196 ); 197 198 // 199 /////////////////////////////////////////////////////////////////////////////// 200 /////////////// low level interface /////////////// 201 /////////////////////////////////////////////////////////////////////////////// 202 203 typedef enum { // all values are well orders 204 205 IDB_NOT_FOUND, // id not found 206 IDB_ABBREV_FOUND, // id not found but an abbreviation 207 IDB_ID_FOUND, // if found 208 IDB_EXTENSION_FOUND, // id not found but an extended version 209 210 } TDBfind_t; 211 212 int FindID ( ID_DB_t * db, ccp id, TDBfind_t * stat, int * num_of_matching ); 213 int InsertID ( ID_DB_t * db, ccp id, ccp title ); 214 int RemoveID ( ID_DB_t * db, ccp id, bool remove_extended ); 215 216 void DumpIDDB ( ID_DB_t * db, FILE * f ); 217 218 // 219 /////////////////////////////////////////////////////////////////////////////// 220 /////////////// system menu interface /////////////// 221 /////////////////////////////////////////////////////////////////////////////// 222 223 ccp GetSystemMenu 224 ( 225 u32 version, // system version number 226 ccp return_if_not_found // return value if not found 227 ); 228 229 // 230 /////////////////////////////////////////////////////////////////////////////// 231 /////////////// END /////////////// 232 /////////////////////////////////////////////////////////////////////////////// 233 234 #endif // WIT_TITELS_H 235 236