48a90f8c560f25333c85bcd7df5b0a45ba309fe6
[idzebra-moved-to-github.git] / recctrl / marcomp.h
1 /*
2     $Id: marcomp.h,v 1.1 2003-02-28 12:33:39 oleg Exp $
3 */
4 #ifndef MARCOMP_H
5 #define MARCOMP_H
6
7 #ifdef __cplusplus
8 extern "C" {
9 #endif
10
11 typedef struct mc_subfield
12 {
13     char *name;
14     char *prefix;
15     char *suffix;
16     struct {
17         int start;
18         int end;
19     } interval;
20     int which;
21     union {
22 #define MC_SF           1
23 #define MC_SFGROUP      2
24 #define MC_SFVARIANT    3
25         struct mc_field *in_line;
26         struct mc_subfield *child;
27     } u;
28     struct mc_subfield *next;
29     struct mc_subfield *parent;
30 } mc_subfield;
31
32 #define SZ_FNAME        3
33 #define SZ_IND          1
34 #define SZ_SFNAME       1
35 #define SZ_PREFIX       1
36 #define SZ_SUFFIX       1
37
38 typedef struct mc_field
39 {
40     char *name;
41     char *ind1;
42     char *ind2;
43     struct {
44         int start;
45         int end;
46     } interval;
47     struct mc_subfield *list;
48 } mc_field;
49
50 typedef enum
51 {
52     NOP,
53     REGULAR,
54     LVARIANT,
55     RVARIANT,
56     LGROUP,
57     RGROUP,
58     LINLINE,
59     RINLINE,
60     SUBFIELD,
61     LINTERVAL,
62     RINTERVAL,
63 } mc_token;
64
65 typedef enum
66 {
67     EMCOK = 0,  /* first always, mondatory */
68     EMCNOMEM,
69     EMCF,
70     EMCSF,
71     EMCSFGROUP,
72     EMCSFVAR,
73     EMCSFINLINE,
74     EMCEND      /* last always, mondatory */
75 } mc_errcode;
76
77 typedef struct mc_context
78 {
79     int offset;
80     
81     int crrval;
82     mc_token crrtok;
83     
84     mc_errcode errcode;
85     
86     int len;
87     const char *data;
88 } mc_context;
89
90 mc_context *mc_mk_context(const char *s);
91 void mc_destroy_context(mc_context *c);
92
93 mc_field *mc_getfield(mc_context *c);
94 void mc_destroy_field(mc_field *p);
95 void mc_pr_field(mc_field *p, int offset);
96
97 mc_subfield *mc_getsubfields(mc_context *c, mc_subfield *parent);
98 void mc_destroy_subfield(mc_subfield *p);
99 void mc_destroy_subfields_recursive(mc_subfield *p);
100 void mc_pr_subfields(mc_subfield *p, int offset);
101
102 mc_errcode mc_errno(mc_context *c);
103 const char *mc_error(mc_errcode no);
104
105 #ifdef __cplusplus
106 }
107 #endif
108
109 #endif