nmake: align with pazpar2 WRT icu/libxslt
[idzebra-moved-to-github.git] / index / marcomp.h
1 /* This file is part of the Zebra server.
2    Copyright (C) Index Data
3
4 Zebra is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8
9 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12 for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
18 */
19 #ifndef MARCOMP_H
20 #define MARCOMP_H
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26 typedef struct mc_subfield
27 {
28     char *name;
29     char *prefix;
30     char *suffix;
31     struct {
32         int start;
33         int end;
34     } interval;
35     int which;
36     union {
37 #define MC_SF           1
38 #define MC_SFGROUP      2
39 #define MC_SFVARIANT    3
40         struct mc_field *in_line;
41         struct mc_subfield *child;
42     } u;
43     struct mc_subfield *next;
44     struct mc_subfield *parent;
45 } mc_subfield;
46
47 #define SZ_FNAME        3
48 #define SZ_IND          1
49 #define SZ_SFNAME       1
50 #define SZ_PREFIX       1
51 #define SZ_SUFFIX       1
52
53 typedef struct mc_field
54 {
55     char *name;
56     char *ind1;
57     char *ind2;
58     struct {
59         int start;
60         int end;
61     } interval;
62     struct mc_subfield *list;
63 } mc_field;
64
65 typedef enum
66 {
67     NOP,
68     REGULAR,
69     LVARIANT,
70     RVARIANT,
71     LGROUP,
72     RGROUP,
73     LINLINE,
74     RINLINE,
75     SUBFIELD,
76     LINTERVAL,
77     RINTERVAL,
78 } mc_token;
79
80 typedef enum
81 {
82     EMCOK = 0,  /* first always, mondatory */
83     EMCNOMEM,
84     EMCF,
85     EMCSF,
86     EMCSFGROUP,
87     EMCSFVAR,
88     EMCSFINLINE,
89     EMCEND      /* last always, mondatory */
90 } mc_errcode;
91
92 typedef struct mc_context
93 {
94     int offset;
95
96     int crrval;
97     mc_token crrtok;
98
99     mc_errcode errcode;
100
101     int len;
102     const char *data;
103 } mc_context;
104
105 mc_context *mc_mk_context(const char *s);
106 void mc_destroy_context(mc_context *c);
107
108 mc_field *mc_getfield(mc_context *c);
109 void mc_destroy_field(mc_field *p);
110 void mc_pr_field(mc_field *p, int offset);
111
112 mc_subfield *mc_getsubfields(mc_context *c, mc_subfield *parent);
113 void mc_destroy_subfield(mc_subfield *p);
114 void mc_destroy_subfields_recursive(mc_subfield *p);
115 void mc_pr_subfields(mc_subfield *p, int offset);
116
117 mc_errcode mc_errno(mc_context *c);
118 const char *mc_error(mc_errcode no);
119
120 #ifdef __cplusplus
121 }
122 #endif
123
124 #endif
125 /*
126  * Local variables:
127  * c-basic-offset: 4
128  * c-file-style: "Stroustrup"
129  * indent-tabs-mode: nil
130  * End:
131  * vim: shiftwidth=4 tabstop=8 expandtab
132  */
133