1 /*************************************************************************** 2 $RCSfile$ 3 ------------------- 4 cvs : $Id: idlist_p.h 1048 2006-05-17 17:15:35Z martin $ 5 begin : Mon Mar 01 2004 6 copyright : (C) 2004 by Martin Preuss 7 email : martin@libchipcard.de 8 9 *************************************************************************** 10 * * 11 * This library is free software; you can redistribute it and/or * 12 * modify it under the terms of the GNU Lesser General Public * 13 * License as published by the Free Software Foundation; either * 14 * version 2.1 of the License, or (at your option) any later version. * 15 * * 16 * This library is distributed in the hope that it will be useful, * 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 19 * Lesser General Public License for more details. * 20 * * 21 * You should have received a copy of the GNU Lesser General Public * 22 * License along with this library; if not, write to the Free Software * 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * 24 * MA 02111-1307 USA * 25 * * 26 ***************************************************************************/ 27 28 #ifndef GWENHYWFAR_IDMAP_P_H 29 #define GWENHYWFAR_IDMAP_P_H 30 31 #include "idmap.h" 32 33 34 typedef GWEN_IDMAP_RESULT(*GWEN_IDMAP_SETPAIR_FN)(GWEN_IDMAP *map, 35 uint32_t id, 36 void *ptr); 37 typedef void *(*GWEN_IDMAP_GETPAIR_FN)(GWEN_IDMAP *map, 38 uint32_t id); 39 40 typedef GWEN_IDMAP_RESULT(*GWEN_IDMAP_FINDFIRST_FN)(const GWEN_IDMAP *map, 41 uint32_t *pid); 42 typedef GWEN_IDMAP_RESULT(*GWEN_IDMAP_FINDNEXT_FN)(const GWEN_IDMAP *map, 43 uint32_t *pid); 44 45 typedef void (*GWEN_IDMAP_DUMP_FN)(GWEN_IDMAP *map, FILE *f, int indent); 46 47 48 typedef void (*GWEN_IDMAP_FREEDATA_FN)(GWEN_IDMAP *map); 49 50 51 struct GWEN_IDMAP { 52 GWEN_IDMAP_SETPAIR_FN setPairFn; 53 GWEN_IDMAP_GETPAIR_FN getPairFn; 54 GWEN_IDMAP_FINDFIRST_FN findFirstFn; 55 GWEN_IDMAP_FINDNEXT_FN findNextFn; 56 GWEN_IDMAP_FREEDATA_FN freeDataFn; 57 GWEN_IDMAP_DUMP_FN dumpFn; 58 59 GWEN_IDMAP_ALGO algo; 60 void *algoData; 61 uint32_t count; 62 }; 63 64 65 66 67 typedef struct GWEN_IDMAP_HEX4_TABLE GWEN_IDMAP_HEX4_TABLE; 68 struct GWEN_IDMAP_HEX4_TABLE { 69 GWEN_IDMAP_HEX4_TABLE *parent; 70 int isPtrTable; 71 void *ptrs[16]; 72 }; 73 static GWEN_IDMAP_HEX4_TABLE *GWEN_IdMapHex4Map_new(GWEN_IDMAP_HEX4_TABLE *p, 74 int isPtrTable); 75 static void GWEN_IdMapHex4Map_free(GWEN_IDMAP_HEX4_TABLE *t); 76 77 78 typedef struct GWEN_IDMAP_HEX4 GWEN_IDMAP_HEX4; 79 struct GWEN_IDMAP_HEX4 { 80 GWEN_IDMAP_HEX4_TABLE *table; 81 uint32_t lastId; 82 }; 83 84 static void GWEN_IdMapHex4_Extend(GWEN_IDMAP *map); 85 static void GWEN_IdMapHex4_free(GWEN_IDMAP *map); 86 static GWEN_IDMAP_RESULT GWEN_IdMapHex4_Insert(GWEN_IDMAP *map, 87 uint32_t id, 88 void *ptr); 89 static void *GWEN_IdMapHex4_Find(GWEN_IDMAP *map, uint32_t id); 90 91 static GWEN_IDMAP_RESULT GWEN_IdMapHex4_FindFirst(const GWEN_IDMAP *map, 92 uint32_t *pid); 93 static GWEN_IDMAP_RESULT GWEN_IdMapHex4_FindNext(const GWEN_IDMAP *map, 94 uint32_t *pid); 95 96 97 98 static 99 GWEN_IDMAP_HEX4_TABLE *GWEN_IdMapHex4__GetTable(GWEN_IDMAP_HEX4_TABLE *t, 100 uint32_t id); 101 102 static 103 GWEN_IDMAP_HEX4_TABLE *GWEN_IdMapHex4__GetFirstTable(GWEN_IDMAP_HEX4_TABLE *t, 104 uint32_t *pid); 105 106 static 107 GWEN_IDMAP_HEX4_TABLE *GWEN_IdMapHex4__GetNextTable(GWEN_IDMAP_HEX4_TABLE *t, 108 uint32_t *pid, 109 int incr); 110 111 static void GWEN_IdMapHex4__Dump(GWEN_IDMAP_HEX4_TABLE *table, 112 FILE *f, int indent); 113 114 static void GWEN_IdMapHex4_Dump(GWEN_IDMAP *map, FILE *f, int indent); 115 116 117 #endif 118 119