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