00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef HAVE_DBSPECDATA_H
00032 #define HAVE_DBSPECDATA_H 1
00033 #include <fakedbfs/types.h>
00034 #define MAXLINE 2048
00035 #define ALLSUBSTART 6500
00036
00037
00038 typedef struct {
00039 struct CatalogueHead *cathead;
00040 struct EnumHead *enumhead;
00041 struct CatalogueHead *lastcath;
00042 struct EnumHead *lastenumh;
00043 struct CatalogueHead *curcath;
00044 struct EnumHead *curenumh;
00045
00046 struct CatalogueHead *db_cath;
00047 struct EnumHead *db_enumh;
00048
00049 struct CatElem *catelemhead;
00050 struct EnumElem *enumelemhead;
00051 struct CatElem *lastcatel;
00052 struct EnumElem *lastenumel;
00053 struct CatElem *curcatel;
00054 struct EnumElem *curenumel;
00055
00056 struct EnumSubElem *subelhead;
00057 struct EnumSubElem *lastsubel;
00058
00059 struct EnumSubElem *allsubelhead;
00060 struct EnumSubElem *lastallsubel;
00061
00062 unsigned int lastevalue;
00063 unsigned int lastsubval;
00064 unsigned int lastallsubval;
00065 int err;
00066 void *instance;
00067 } Heads;
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078 #if 0
00079 this isn't really necessary...
00080 struct EnumSubHead {
00081 struct EnumElem *father;
00082 struct EnumSubElem *headsub;
00083 short int hasSelf;
00084 };
00085 #endif
00086
00087
00088
00089
00090 #define SUBE_IS_SELF 0x1
00091 #define SUBE_IS_SAMEAS 0x2
00092 #define SUBE_IS_ALLSUB 0x4
00093 struct EnumSubElem {
00094 char *name;
00095
00096 unsigned int value;
00097 struct EnumElem *father;
00098 int flags;
00099 struct EnumSubElem *next;
00100 };
00101
00102 struct EnumElem {
00103 char *name;
00104 char *fmtname;
00105 unsigned int value;
00106 short int other;
00107 enum DataType othertype;
00108 struct EnumSubElem *subhead;
00109 struct EnumElem *next;
00110 };
00111 #define ENUMH_FROM_DB 0x1
00112
00113 struct EnumHead {
00114 char *name;
00115 int flags;
00116 struct EnumSubElem *allsubs;
00117 struct EnumElem *headelem;
00118 struct EnumElem *otherelem;
00119 struct EnumHead *next;
00120 };
00121
00122
00123 #define CATE_USES_FC 0x1
00124 struct CatElem {
00125 char *name;
00126 char *alias;
00127 enum DataType type;
00128 struct EnumHead *enumptr;
00129 struct CatElem *subcatel;
00130 int flags;
00131 struct CatElem *next;
00132 };
00133 #define CATH_USES_FC 0x1
00134 #define CATH_FROM_DB 0x2
00135
00136 struct CatalogueHead {
00137 char *name;
00138 char *fmtname;
00139 int flags;
00140 struct CatElem *headelem;
00141 struct CatalogueHead *next;
00142 };
00143
00151 struct EnumElem* fdbfs_find_elem_by_name(struct EnumElem *h, const char *name);
00152
00160 struct CatElem* fdbfs_find_catelem_enum(struct CatElem *h, struct EnumHead *en);
00161
00170 char* fdbfs_get_enum_string_by_value(struct EnumElem *h, unsigned int val, short int fmted);
00171
00179 struct EnumSubElem* fdbfs_get_subhead_by_enval(struct EnumElem *h, unsigned int val);
00180
00188 char* fdbfs_get_enum_sub_string_by_value(struct EnumSubElem *h, unsigned int val);
00189
00197 struct CatalogueHead* fdbfs_find_cathead_by_name(struct CatalogueHead *h, const char *name);
00198
00206 struct CatElem* fdbfs_find_catelem_by_name(struct CatElem *h, const char *name);
00207
00215 struct EnumHead* fdbfs_find_enumhead_by_name(struct EnumHead *h, const char *name);
00216
00227 struct EnumSubElem* fdbfs_copy_sub_list(
00228 struct EnumSubElem *from,
00229 struct EnumSubElem *to,
00230 struct EnumElem *fajah,
00231 int *lastval
00232 );
00233
00243 struct EnumElem* fdbfs_enumelems_from_dbtab(fdbfs_t *f, const char *table, struct EnumHead *e);
00244
00251 struct EnumHead* fdbfs_enums_from_db(fdbfs_t *f);
00252
00261 struct CatElem* fdbfs_catelems_from_dbtab(fdbfs_t *f, const char *table, struct EnumHead *enumhead);
00262
00270 struct CatalogueHead* fdbfs_cats_from_db(fdbfs_t *f, struct EnumHead *enumhead);
00271
00279 struct EnumSubElem* fdbfs_free_enum_sub_elem(struct EnumSubElem *e, short int allsub);
00280
00287 void fdbfs_free_enum_sub_elem_list(struct EnumSubElem *head, short int allsub);
00288
00295 struct EnumElem* fdbfs_free_enum_elem(struct EnumElem *e);
00296
00302 void fdbfs_free_enum_elem_list(struct EnumElem *head);
00303
00310 struct EnumHead* fdbfs_free_enum_head(struct EnumHead *e);
00311
00317 void fdbfs_free_enum_head_list(struct EnumHead *head);
00318
00325 struct CatElem* fdbfs_free_cat_elem(struct CatElem *e);
00326
00332 void fdbfs_free_cat_elem_list(struct CatElem *head);
00333
00340 struct CatalogueHead* fdbfs_free_cat_head(struct CatalogueHead *e);
00341
00347 void fdbfs_free_cat_head_list(struct CatalogueHead *head);
00348
00355 void fdbfs_free_head_members(Heads *hd);
00356
00366 int fdbfs_dbspec_parse(fdbfs_t *f, const char *filename);
00367
00373 void fdbfs_actcats_free(actcat_t *h);
00374
00382 actcat_t* fdbfs_catalogues_from_db(fdbfs_t *f, struct CatalogueHead *cathead);
00383
00384 #define CAT_TABLE_PREFIX "c_"
00385 #define CAT_FIELD_TABLE_PREFIX "cft_"
00386 #define ENUM_TABLE_PREFIX "endef_"
00387 #define OTHER_ELEM_PREFIX "oth_"
00388 #endif