2 * Copyright (C) 1995-2003, Index Data
3 * See the file LICENSE for details.
4 * Sebastian Hammer, Adam Dickmeiss
6 * $Id: session.h,v 1.27 2003-01-06 08:20:28 adam Exp $
12 #include <sys/types.h>
13 #include <yaz/comstack.h>
16 #include <yaz/proto.h>
20 REQUEST_IDLE, /* the request is just sitting in the queue */
21 REQUEST_PENDING /* operation pending (b'end processing or network I/O*/
22 /* this list will have more elements when acc/res control is added */
25 typedef struct request
27 int len_refid; /* length of referenceid */
28 char *refid; /* referenceid */
31 Z_APDU *apdu_request; /* Current request */
32 NMEM request_mem; /* memory handle for request */
34 int size_response; /* size of buffer */
35 int len_response; /* length of encoded data */
36 char *response; /* encoded data waiting for transmission */
43 typedef struct request_q
56 ASSOC_NEW, /* not initialized yet */
57 ASSOC_UP, /* normal operation */
58 ASSOC_DEAD /* dead. Close if input arrives */
61 typedef struct association
63 IOCHAN client_chan; /* event-loop control */
64 COMSTACK client_link; /* communication handle */
65 ODR decode; /* decoding stream */
66 ODR encode; /* encoding stream */
67 ODR print; /* printing stream (for -a) */
68 char *encode_buffer; /* temporary buffer for encoded data */
69 int encoded_len; /* length of encoded data */
70 char *input_buffer; /* input buffer (allocated by comstack) */
71 int input_buffer_len; /* length (size) of buffer */
72 int input_apdu_len; /* length of current incoming APDU */
73 oid_proto proto; /* protocol (PROTO_Z3950/PROTO_SR) */
74 void *backend; /* backend handle */
75 request_q incoming; /* Q of incoming PDUs */
76 request_q outgoing; /* Q of outgoing data buffers (enc. PDUs) */
77 association_state state;
79 /* session parameters */
80 int preferredMessageSize;
81 int maximumRecordSize;
82 int version; /* highest version-bit set (2 or 3) */
86 unsigned cs_accept_mask;
88 struct bend_initrequest *init;
91 int (*bend_search) ();
92 int (*bend_present) ();
93 int (*bend_esrequest) ();
94 int (*bend_delete) ();
96 int (*bend_segment) ();
100 association *create_association(IOCHAN channel, COMSTACK link);
101 void destroy_association(association *h);
102 void ir_session(IOCHAN h, int event);
104 void request_enq(request_q *q, request *r);
105 request *request_head(request_q *q);
106 request *request_deq(request_q *q);
107 request *request_deq_x(request_q *q, request *r);
108 void request_initq(request_q *q);
109 void request_delq(request_q *q);
110 request *request_get(request_q *q);
111 void request_release(request *r);
113 int statserv_must_terminate(void);