Added --with-yc option to configure. For the data1_node in data1.h:
[yaz-moved-to-github.git] / server / session.h
1 /*
2  * Copyright (C) 1995-1998, Index Data I/S 
3  * See the file LICENSE for details.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: session.h,v $
7  * Revision 1.18  1998-08-03 10:23:57  adam
8  * Fixed bug regarding Options for Sort.
9  *
10  * Revision 1.17  1998/07/20 12:38:43  adam
11  * Implemented delete result set service to server API.
12  *
13  * Revision 1.16  1998/03/31 11:07:45  adam
14  * Furhter work on UNIverse resource report.
15  * Added Extended Services handling in frontend server.
16  *
17  * Revision 1.15  1998/02/11 11:53:36  adam
18  * Changed code so that it compiles as C++.
19  *
20  * Revision 1.14  1998/02/10 11:03:57  adam
21  * Added support for extended handlers in backend server interface.
22  *
23  * Revision 1.13  1998/01/29 13:30:23  adam
24  * Better event handle system for NT/Unix.
25  *
26  * Revision 1.12  1997/09/01 08:53:01  adam
27  * New windows NT/95 port using MSV5.0. The test server 'ztest' was
28  * moved a separate directory. MSV5.0 project server.dsp created.
29  * As an option, the server can now operate as an NT service.
30  *
31  * Revision 1.11  1995/11/08 17:41:40  quinn
32  * Smallish.
33  *
34  * Revision 1.10  1995/08/29  11:18:01  quinn
35  * Added code to receive close
36  *
37  * Revision 1.9  1995/06/16  10:31:38  quinn
38  * Added session timeout.
39  *
40  * Revision 1.8  1995/05/17  08:42:28  quinn
41  * Transfer auth info to backend. Allow backend to reject init gracefully.
42  *
43  * Revision 1.7  1995/05/16  08:51:08  quinn
44  * License, documentation, and memory fixes
45  *
46  * Revision 1.6  1995/05/15  11:56:41  quinn
47  * Asynchronous facilities. Restructuring of seshigh code.
48  *
49  * Revision 1.5  1995/04/20  15:13:01  quinn
50  * Cosmetic
51  *
52  * Revision 1.4  1995/04/10  10:23:39  quinn
53  * Some work to add scan and other things.
54  *
55  * Revision 1.3  1995/03/30  09:09:27  quinn
56  * Added state-handle and some support for asynchronous activities.
57  *
58  * Revision 1.2  1995/03/27  08:34:29  quinn
59  * Added dynamic server functionality.
60  * Released bindings to session.c (is now redundant)
61  *
62  * Revision 1.1  1995/03/14  10:28:02  quinn
63  * More work on demo server.
64  *
65  *
66  */
67
68 #ifndef SESSION_H
69 #define SESSION_H
70
71 #include <comstack.h>
72 #include <odr.h>
73 #include <oid.h>
74 #include <proto.h>
75 #include <sys/types.h>
76 #include "eventl.h"
77
78 typedef enum {
79         REQUEST_IDLE,    /* the request is just sitting in the queue */
80         REQUEST_PENDING  /* operation pending (b'end processing or network I/O*/
81         /* this list will have more elements when acc/res control is added */
82 } request_state;
83
84 typedef struct request
85 {
86     int len_refid;          /* length of referenceid */
87     char *refid;            /* referenceid */
88     request_state state;
89
90     Z_APDU *request;        /* Current request */
91     NMEM request_mem;    /* memory handle for request */
92
93     int size_response;     /* size of buffer */
94     int len_response;      /* length of encoded data */
95     char *response;        /* encoded data waiting for transmission */
96
97     void *clientData;
98     struct request *next;
99     struct request_q *q; 
100 } request;
101
102 typedef struct request_q
103 {
104     request *head;
105     request *tail;
106     request *list;
107     int num;
108 } request_q;
109
110 /*
111  * association state.
112  */
113 typedef enum
114 {
115     ASSOC_NEW,                /* not initialized yet */
116     ASSOC_UP,                 /* normal operation */
117     ASSOC_DEAD                /* dead. Close if input arrives */
118 } association_state;
119
120 typedef struct association
121 {
122     IOCHAN client_chan;           /* event-loop control */
123     COMSTACK client_link;         /* communication handle */
124     ODR decode;                   /* decoding stream */
125     ODR encode;                   /* encoding stream */
126     ODR print;                    /* printing stream (for -a) */
127     char *encode_buffer;          /* temporary buffer for encoded data */
128     int encoded_len;              /* length of encoded data */
129     char *input_buffer;           /* input buffer (allocated by comstack) */
130     int input_buffer_len;         /* length (size) of buffer */
131     int input_apdu_len;           /* length of current incoming APDU */
132     oid_proto proto;              /* protocol (PROTO_Z3950/PROTO_SR) */
133     void *backend;                /* backend handle */
134     request_q incoming;           /* Q of incoming PDUs */
135     request_q outgoing;           /* Q of outgoing data buffers (enc. PDUs) */
136     association_state state;
137
138     /* session parameters */
139     int preferredMessageSize;
140     int maximumRecordSize;
141     int version;                  /* highest version-bit set (2 or 3) */
142
143     int (*bend_sort) ();
144     int (*bend_search) ();
145     int (*bend_present) ();
146     int (*bend_esrequest) ();
147     int (*bend_delete) ();
148 } association;
149
150 association *create_association(IOCHAN channel, COMSTACK link);
151 void destroy_association(association *h);
152 void ir_session(IOCHAN h, int event);
153
154 void request_enq(request_q *q, request *r);
155 request *request_head(request_q *q);
156 request *request_deq(request_q *q);
157 request *request_deq_x(request_q *q, request *r);
158 void request_initq(request_q *q);
159 void request_delq(request_q *q);
160 request *request_get(request_q *q);
161 void request_release(request *r);
162
163 #endif