IDZEBRA  2.1.2
marcomp.h
Go to the documentation of this file.
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;
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,
78 } mc_token;
79 
80 typedef enum
81 {
82  EMCOK = 0, /* first always, mondatory */
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);
107 
109 void mc_destroy_field(mc_field *p);
110 void mc_pr_field(mc_field *p, int offset);
111 
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 
struct mc_subfield * list
Definition: marcomp.h:62
struct mc_field * in_line
Definition: marcomp.h:40
int start
Definition: marcomp.h:32
void mc_pr_field(mc_field *p, int offset)
struct mc_field mc_field
mc_errcode errcode
Definition: marcomp.h:99
void mc_pr_subfields(mc_subfield *p, int offset)
struct mc_subfield * next
Definition: marcomp.h:43
Definition: marcomp.h:67
int offset
Definition: marcomp.h:94
char * name
Definition: marcomp.h:28
Definition: marcomp.h:85
int crrval
Definition: marcomp.h:96
mc_token
Definition: marcomp.h:65
char * prefix
Definition: marcomp.h:29
mc_field * mc_getfield(mc_context *c)
Definition: marcomp.c:214
Definition: marcomp.h:84
Definition: marcomp.h:71
const char * mc_error(mc_errcode no)
Definition: marcomp.c:59
const char * data
Definition: marcomp.h:102
Definition: marcomp.h:72
mc_token crrtok
Definition: marcomp.h:97
void mc_destroy_subfield(mc_subfield *p)
Definition: marcomp.c:275
void mc_destroy_context(mc_context *c)
Definition: marcomp.c:86
Definition: marcomp.h:82
mc_errcode
Definition: marcomp.h:80
union mc_subfield::@16 u
int end
Definition: marcomp.h:33
void mc_destroy_subfields_recursive(mc_subfield *p)
Definition: marcomp.c:296
mc_errcode mc_errno(mc_context *c)
Definition: marcomp.c:55
int len
Definition: marcomp.h:101
struct mc_subfield mc_subfield
void mc_destroy_field(mc_field *p)
Definition: marcomp.c:204
char * name
Definition: marcomp.h:55
struct mc_context mc_context
Definition: marcomp.h:89
char * ind1
Definition: marcomp.h:56
char * ind2
Definition: marcomp.h:57
mc_context * mc_mk_context(const char *s)
Definition: marcomp.c:66
int start
Definition: marcomp.h:59
char * suffix
Definition: marcomp.h:30
struct mc_subfield::@15 interval
int end
Definition: marcomp.h:60
struct mc_subfield * child
Definition: marcomp.h:41
struct mc_subfield * parent
Definition: marcomp.h:44
int which
Definition: marcomp.h:35
mc_subfield * mc_getsubfields(mc_context *c, mc_subfield *parent)
Definition: marcomp.c:320