Fixed possible buf in proto.c
[yaz-moved-to-github.git] / include / backend.h
1 #ifndef BACKEND_H
2 #define BACKEND_H
3
4 #include <proto.h>
5
6 typedef struct bend_initrequest
7 {
8     char *configname;
9 } bend_initrequest;
10
11 typedef struct bend_initresult
12 {
13     int errcode;               /* 0==OK */
14     char *errstring;           /* system error string or NULL */
15     void *handle;              /* private handle to the backend module */
16 } bend_initresult;
17
18 typedef struct bend_searchrequest
19 {
20     char *setname;             /* name to give to this set */
21     int replace_set;           /* replace set, if it already exists */
22     int num_bases;             /* number of databases in list */
23     char **basenames;          /* databases to search */
24     Z_Query *query;            /* query structure */
25 } bend_searchrequest;
26
27 typedef struct bend_scanrequest
28 {
29     int num_bases;      /* number of elements in databaselist */
30     char **basenames;   /* databases to search */
31     Z_AttributesPlusTerm *term;
32     int term_position;  /* desired index of term in result list */
33     int num_entries;    /* number of entries requested */
34 } bend_scanrequest;
35
36 typedef struct bend_scanresult
37 {
38     int num_entries;
39     struct scan_entry
40     {
41         char *term;
42         int occurrences;
43     } *entries;
44     int term_position;
45     enum
46     {
47         BEND_SCAN_SUCCESS,   /* ok */
48         BEND_SCAN_PARTIAL   /* not all entries could be found */
49     } status;
50     int errcode;
51     char *errstring;
52 } bend_scanresult;
53
54 typedef struct bend_searchresult
55 {
56     int hits;                  /* number of hits */
57     int errcode;               /* 0==OK */
58     char *errstring;           /* system error string or NULL */
59 } bend_searchresult;
60
61 typedef struct bend_fetchrequest
62 {
63     char *setname;             /* set name */
64     int number;                /* record number */
65 } bend_fetchrequest;
66
67 typedef struct bend_fetchresult
68 {
69     char *basename;            /* name of database that provided record */
70     int len;                   /* length of record */
71     char *record;              /* record */
72     int last_in_set;           /* is it?  */
73     int errcode;               /* 0==success */
74     char *errstring;           /* system error string or NULL */
75 } bend_fetchresult;
76
77 typedef struct bend_deleterequest
78 {
79     char *setname;
80 } bend_deleterequest;
81
82 typedef struct bend_deleteresult
83 {
84     int errcode;               /* 0==success */
85     char *errstring;           /* system error string or NULL */
86 } bend_deleteresult;
87
88 bend_initresult *bend_init(bend_initrequest *r);
89
90 bend_searchresult *bend_search(void *handle, bend_searchrequest *r, int *fd);
91 bend_searchresult *bend_searchresponse(void *handle);
92
93 bend_fetchresult *bend_fetch(void *handle, bend_fetchrequest *r, int *fd);
94 bend_fetchresult *bend_fetchresponse(void *handle);
95
96 bend_scanresult *bend_scan(void *handle, bend_scanrequest *r, int *fd);
97 bend_scanresult *bend_scanresponse(void *handle);
98
99 bend_deleteresult *bend_delete(void *handle, bend_deleterequest *r, int *fd);
100 bend_deleteresult *bend_deleteresponse(void *handle);
101
102 void bend_close(void *handle);
103
104 #endif