1 | /*
|
---|
2 | * Copyright (c) 1995-1999, Index Data.
|
---|
3 | * See the file LICENSE for details.
|
---|
4 | * Sebastian Hammer, Adam Dickmeiss
|
---|
5 | *
|
---|
6 | * $Log$
|
---|
7 | * Revision 1.1 2000/08/03 03:11:32 johnmcp
|
---|
8 | * Added the YAZ toolkit source to the packages directory (for z39.50 stuff)
|
---|
9 | *
|
---|
10 | * Revision 1.6 1999/11/30 13:47:12 adam
|
---|
11 | * Improved installation. Moved header files to include/yaz.
|
---|
12 | *
|
---|
13 | * Revision 1.5 1999/08/27 09:40:32 adam
|
---|
14 | * Renamed logf function to yaz_log. Removed VC++ project files.
|
---|
15 | *
|
---|
16 | * Revision 1.4 1998/05/18 13:07:05 adam
|
---|
17 | * Changed the way attribute sets are handled by the retriaval module.
|
---|
18 | * Extended Explain conversion / schema.
|
---|
19 | * Modified server and client to work with ASN.1 compiled protocol handlers.
|
---|
20 | *
|
---|
21 | * Revision 1.3 1998/02/11 11:53:35 adam
|
---|
22 | * Changed code so that it compiles as C++.
|
---|
23 | *
|
---|
24 | * Revision 1.2 1997/09/30 11:50:04 adam
|
---|
25 | * Added handler data1_get_map_buf that is used by data1_nodetomarc.
|
---|
26 | *
|
---|
27 | * Revision 1.1 1997/09/17 12:28:24 adam
|
---|
28 | * Introduced new 'global' data1 handle.
|
---|
29 | *
|
---|
30 | */
|
---|
31 |
|
---|
32 | #include <stdio.h>
|
---|
33 | #include <stdlib.h>
|
---|
34 |
|
---|
35 | #include <yaz/log.h>
|
---|
36 | #include <yaz/data1.h>
|
---|
37 |
|
---|
38 | struct data1_handle_info {
|
---|
39 | WRBUF wrbuf;
|
---|
40 | char *tab_path;
|
---|
41 |
|
---|
42 | char *read_buf;
|
---|
43 | int read_len;
|
---|
44 |
|
---|
45 | data1_absyn_cache absyn_cache;
|
---|
46 | data1_attset_cache attset_cache;
|
---|
47 |
|
---|
48 | char *map_buf;
|
---|
49 | int map_len;
|
---|
50 |
|
---|
51 | NMEM mem;
|
---|
52 | };
|
---|
53 |
|
---|
54 | data1_handle data1_create (void)
|
---|
55 | {
|
---|
56 | data1_handle p = (data1_handle)xmalloc (sizeof(*p));
|
---|
57 | if (!p)
|
---|
58 | return NULL;
|
---|
59 | p->tab_path = NULL;
|
---|
60 | p->wrbuf = wrbuf_alloc();
|
---|
61 | p->read_buf = NULL;
|
---|
62 | p->read_len = 0;
|
---|
63 | p->map_buf = NULL;
|
---|
64 | p->map_len = 0;
|
---|
65 | p->absyn_cache = NULL;
|
---|
66 | p->attset_cache = NULL;
|
---|
67 | p->mem = nmem_create ();
|
---|
68 | return p;
|
---|
69 | }
|
---|
70 |
|
---|
71 | NMEM data1_nmem_get (data1_handle dh)
|
---|
72 | {
|
---|
73 | return dh->mem;
|
---|
74 | }
|
---|
75 |
|
---|
76 | data1_absyn_cache *data1_absyn_cache_get (data1_handle dh)
|
---|
77 | {
|
---|
78 | return &dh->absyn_cache;
|
---|
79 | }
|
---|
80 |
|
---|
81 | data1_attset_cache *data1_attset_cache_get (data1_handle dh)
|
---|
82 | {
|
---|
83 | return &dh->attset_cache;
|
---|
84 | }
|
---|
85 |
|
---|
86 | void data1_destroy (data1_handle dh)
|
---|
87 | {
|
---|
88 | if (!dh)
|
---|
89 | return;
|
---|
90 | wrbuf_free (dh->wrbuf, 1);
|
---|
91 | if (dh->tab_path)
|
---|
92 | xfree (dh->tab_path);
|
---|
93 | if (dh->read_buf)
|
---|
94 | xfree (dh->read_buf);
|
---|
95 | if (dh->map_buf)
|
---|
96 | xfree (dh->map_buf);
|
---|
97 | nmem_destroy (dh->mem);
|
---|
98 |
|
---|
99 | xfree (dh);
|
---|
100 | }
|
---|
101 |
|
---|
102 | WRBUF data1_get_wrbuf (data1_handle dp)
|
---|
103 | {
|
---|
104 | return dp->wrbuf;
|
---|
105 | }
|
---|
106 |
|
---|
107 | char **data1_get_read_buf (data1_handle dp, int **lenp)
|
---|
108 | {
|
---|
109 | *lenp = &dp->read_len;
|
---|
110 | yaz_log (LOG_DEBUG, "data1_get_read_buf lenp=%u", **lenp);
|
---|
111 | return &dp->read_buf;
|
---|
112 | }
|
---|
113 |
|
---|
114 | char **data1_get_map_buf (data1_handle dp, int **lenp)
|
---|
115 | {
|
---|
116 | *lenp = &dp->map_len;
|
---|
117 | yaz_log (LOG_DEBUG, "data1_get_map_buf lenp=%u", **lenp);
|
---|
118 | return &dp->map_buf;
|
---|
119 | }
|
---|
120 |
|
---|
121 | void data1_set_tabpath (data1_handle dp, const char *p)
|
---|
122 | {
|
---|
123 | if (dp->tab_path)
|
---|
124 | {
|
---|
125 | xfree (dp->tab_path);
|
---|
126 | dp->tab_path = NULL;
|
---|
127 | }
|
---|
128 | if (p)
|
---|
129 | {
|
---|
130 | dp->tab_path = (char *)xmalloc (strlen(p)+1);
|
---|
131 | strcpy (dp->tab_path, p);
|
---|
132 | }
|
---|
133 | }
|
---|
134 |
|
---|
135 | const char *data1_get_tabpath (data1_handle dp)
|
---|
136 | {
|
---|
137 | return dp->tab_path;
|
---|
138 | }
|
---|
139 |
|
---|