| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
#ifndef TABLE_H |
| 33 |
#define TABLE_H |
| 34 |
|
| 35 |
#include <stdio.h> |
| 36 |
#include <stdint.h> |
| 37 |
|
| 38 |
#include "misc.h" |
| 39 |
#include "list.h" |
| 40 |
|
| 41 |
#include "proba_info.h" |
| 42 |
|
| 43 |
#ifdef WIN32 |
| 44 |
#define fstat _fstati64 |
| 45 |
#define stat _stati64 |
| 46 |
#define fseeko fseeko64 |
| 47 |
#endif |
| 48 |
|
| 49 |
#ifdef __cplusplus |
| 50 |
extern "C" { |
| 51 |
#endif |
| 52 |
|
| 53 |
typedef enum { |
| 54 |
unknown = 0, |
| 55 |
lmalphanum10k, |
| 56 |
lmalphanum5k, |
| 57 |
lmextended, |
| 58 |
ntextended, |
| 59 |
lmgermanv1, |
| 60 |
lmgermanv2, |
| 61 |
ntdict, |
| 62 |
ntnine, |
| 63 |
nteight, |
| 64 |
ntnum, |
| 65 |
ntseven, |
| 66 |
lmflash, |
| 67 |
nteightxl, |
| 68 |
ntspecialxl, |
| 69 |
ntprobafree, |
| 70 |
ntproba10g, |
| 71 |
ntproba60g |
| 72 |
} table_kind_t; |
| 73 |
|
| 74 |
typedef enum { |
| 75 |
preload_none = 0x00, |
| 76 |
preload_init = 0x01, |
| 77 |
preload_idx = 0x02, |
| 78 |
preload_end = 0x04, |
| 79 |
preload_srt = 0x08, |
| 80 |
preload_full = preload_init + preload_idx + preload_end + preload_srt |
| 81 |
} table_preload_t; |
| 82 |
|
| 83 |
typedef struct table_t_ { |
| 84 |
table_kind_t kind; |
| 85 |
uint32_t code; |
| 86 |
|
| 87 |
char *path; |
| 88 |
char *name; |
| 89 |
|
| 90 |
int id; |
| 91 |
int idx; |
| 92 |
int cmin; |
| 93 |
int cmax; |
| 94 |
int ncols; |
| 95 |
int offset; |
| 96 |
int enabled; |
| 97 |
int active; |
| 98 |
|
| 99 |
FILE *idxfile; |
| 100 |
FILE *endfile; |
| 101 |
FILE *srtfile; |
| 102 |
|
| 103 |
uint8_t shared_init; |
| 104 |
|
| 105 |
uint64_t inisize; |
| 106 |
uint64_t idxsize; |
| 107 |
uint64_t endsize; |
| 108 |
uint64_t srtsize; |
| 109 |
|
| 110 |
const uint64_t *sizes; |
| 111 |
|
| 112 |
void *param; |
| 113 |
char *idxmem; |
| 114 |
char *endmem; |
| 115 |
char *srtmem; |
| 116 |
|
| 117 |
void *(*init)(void*); |
| 118 |
void (*cleanup)(void*); |
| 119 |
|
| 120 |
void (*find)(void*, void*, void*); |
| 121 |
int (*lookup_idx)(void*, void*, void*); |
| 122 |
int (*lookup_end)(void*, void*, void*); |
| 123 |
int (*lookup_srt)(void*, void*, void*); |
| 124 |
|
| 125 |
int (*check)(void*, void*, void*); |
| 126 |
int (*isvalid)(void*, void*); |
| 127 |
} table_t; |
| 128 |
|
| 129 |
table_t *table_alloc(uint32_t code, char *path, int idx); |
| 130 |
void table_free(table_t *tbl); |
| 131 |
|
| 132 |
int table_load(table_t *tbl); |
| 133 |
void table_set_size(table_t *tbl); |
| 134 |
int table_verify(table_t *tbl); |
| 135 |
uint64_t table_preload(table_t *tbl, table_preload_t preload); |
| 136 |
uint64_t table_unload(table_t *tbl, table_preload_t preload); |
| 137 |
|
| 138 |
uint64_t table_size(table_t *tbl); |
| 139 |
uint64_t table_preload_size(table_t *tbl, table_preload_t preload); |
| 140 |
int table_open(list_t *tables, const char *dir, const char *tblstr); |
| 141 |
|
| 142 |
table_preload_t table_preload_state(table_t *tbl); |
| 143 |
|
| 144 |
table_kind_t table_kind(uint32_t code); |
| 145 |
const char *table_string(table_kind_t kind); |
| 146 |
|
| 147 |
#ifdef __cplusplus |
| 148 |
} |
| 149 |
#endif |
| 150 |
#endif |