Initial version of donated sources by Avertec, 3.4p5.
[tas-yagle.git] / distrib / sources / mbk / mbk_fileextract.h
1 /****************************************************************************/
2 /* */
3 /* Chaine de CAO & VLSI AVERTEC */
4 /* */
5 /* Produit : AVERTEC global tools */
6 /* Fichier : mbk_fileextract.h */
7 /* */
8 /* © copyright 2000 AVERTEC */
9 /* Tous droits reserves */
10 /* */
11 /* Auteur(s) : Antony PINTO */
12 /* */
13 /****************************************************************************/
14
15 #ifndef MBK_FILEEXTRACT_H
16 #define MBK_FILEEXTRACT_H
17
18 #include <string.h>
19 #include <ctype.h>
20 #include <stdlib.h>
21 #include <math.h>
22 #include <limits.h>
23
24 #include MUT_H
25
26 typedef struct label_list
27 {
28 char *LABEL;
29 double VALUE;
30 }
31 label_list;
32
33 typedef struct extract_rules
34 {
35 struct extract_rules *NEXT; /* next rule(s) */
36 char *BEGIN; /* mark begin for rule recognition */
37 char *END; /* mark end for rule recognition */
38 int TYPE; /* recognition type : line or array */
39 char **TOKEN; /* list of token to be recognised */
40 int NBTOKEN; /* number of token */
41 int ACTIVATED; /* rule activated or not */
42 int LINE; /* line # in case of table recognition */
43 label_list *LBLLIST; /* list of label recognised */
44 int NBELT; /* nb token found in a line for a table */
45 int NBELT1ST; /* nb token found in the 1st line for a */
46 /* table */
47 }
48 extract_rules;
49
50 typedef struct label_table
51 {
52 struct label_table *NEXT;
53 char *LABEL;
54 union {
55 double NUMBER;
56 struct {
57 double *TABLE;
58 int NBMC;
59 int MAXMC;
60 } MC ;
61 } VALUE ;
62 int FLAG; /* is label found */
63 }
64 label_table;
65
66 typedef struct label_ref
67 {
68 label_table *LABTBL;
69 ht *REFTBL;
70 }
71 label_ref;
72
73 #define RULE_UNACTIVATED ((int) 0)
74 #define RULE_ACTIVATED ((int) 1)
75
76 #define RULE_TYPE_LINE ((int) 4)
77 #define RULE_TYPE_TABLE ((int) 5)
78
79 #define MFE_CHAR_IN_LINE ((int) 3000)
80 #define MFE_LINE_SIZE (sizeof(char)*MFE_CHAR_IN_LINE)
81
82 #define LABL_FOUND ((int) 0)
83 #define LABL_NOTFOUND ((int) 1)
84 /* error code */
85
86 #define RULE_TYPE_ERR ((int) 6) /* rule type */
87 #define RULE_BEGE_ERR ((int) 7) /* begin an end mark */
88 #define RULE_RULE_ERR ((int) 8) /* token */
89 #define RULE_TOOT_ERR ((int) 9) /* too much token */
90 #define RULE_UTOK_ERR ((int) 10) /* unknown token */
91 #define RULE_MATC_ERR ((int) 11) /* match error */
92 #define RULE_FTOK_ERR ((int) 12) /* miss token err */
93 #define LABL_UTBL_ERR ((int) 31) /* unknown table */
94 #define LABL_ULBL_ERR ((int) 32) /* unknown label */
95 #define LABL_LEXI_WAR ((int) 33) /* existant label */
96 #define LABL_PLBL_ERR ((int) 34) /* label probleme */
97 #define MFE_LONGLINE_ERR ((int) 55)
98
99 int mfe_addrule(extract_rules **ruleslist, char *rule);
100 int mfe_delrule(extract_rules **ruleslist, extract_rules *rule);
101 void mfe_freerules(extract_rules **ruleslist);
102 void mfe_duprules(extract_rules **ruleslist, extract_rules *rule);
103 /* be carefull label must be nameallocated */
104 int mfe_addlabel(label_ref **table, char *label, int nbmc);
105 int mfe_dellabel(label_ref **table, char *label);
106 void mfe_freelabels(label_ref **table, int cleanmc);
107 void mfe_duplabels(label_ref **newr, label_ref *ref);
108
109 int mfe_fileextractlabel(char *filename, extract_rules *rules, label_ref *ref, int nbmc);
110
111 int mfe_labelvalue(label_ref *ref, char *label, double *value, int nbmc);
112 void mfe_cleanLabel(label_ref *ref);
113
114 #endif