2 * Copyright (C) 1995-2006, Index Data ApS
3 * See the file LICENSE for details.
5 * $Id: session.h,v 1.12 2006-12-04 14:56:55 adam Exp $
9 * \brief Internal Header for GFS.
14 #include <yaz/comstack.h>
18 #include <yaz/proto.h>
19 #include <yaz/backend.h>
20 #include <yaz/retrieval.h>
24 statserv_options_block cb;
27 cql_transform_t cql_transform;
28 void *server_node_ptr;
32 yaz_retrieval_t retrieval;
33 struct gfs_server *next;
39 struct gfs_listen *next;
43 REQUEST_IDLE, /* the request is just sitting in the queue */
44 REQUEST_PENDING /* operation pending (b'end processing or network I/O*/
45 /* this list will have more elements when acc/res control is added */
48 typedef struct request
50 int len_refid; /* length of referenceid */
51 char *refid; /* referenceid */
54 Z_GDU *gdu_request; /* Current request */
55 Z_APDU *apdu_request; /* Current Z39.50 request */
56 NMEM request_mem; /* memory handle for request */
58 int size_response; /* size of buffer */
59 int len_response; /* length of encoded data */
60 char *response; /* encoded data waiting for transmission */
67 typedef struct request_q
80 ASSOC_NEW, /* not initialized yet */
81 ASSOC_UP, /* normal operation */
82 ASSOC_DEAD /* dead. Close if input arrives */
85 typedef struct association
87 IOCHAN client_chan; /* event-loop control */
88 COMSTACK client_link; /* communication handle */
89 ODR decode; /* decoding stream */
90 ODR encode; /* encoding stream */
91 ODR print; /* printing stream (for -a) */
92 char *encode_buffer; /* temporary buffer for encoded data */
93 int encoded_len; /* length of encoded data */
94 char *input_buffer; /* input buffer (allocated by comstack) */
95 int input_buffer_len; /* length (size) of buffer */
96 int input_apdu_len; /* length of current incoming APDU */
97 oid_proto proto; /* protocol (PROTO_Z3950/PROTO_SR) */
98 void *backend; /* backend handle */
99 request_q incoming; /* Q of incoming PDUs */
100 request_q outgoing; /* Q of outgoing data buffers (enc. PDUs) */
101 association_state state;
103 /* session parameters */
104 int preferredMessageSize;
105 int maximumRecordSize;
106 int version; /* highest version-bit set (2 or 3) */
108 unsigned cs_get_mask;
109 unsigned cs_put_mask;
110 unsigned cs_accept_mask;
112 struct bend_initrequest *init;
113 statserv_options_block *last_control;
115 struct gfs_server *server;
118 association *create_association(IOCHAN channel, COMSTACK link,
119 const char *apdufile);
120 void destroy_association(association *h);
121 void ir_session(IOCHAN h, int event);
123 void request_enq(request_q *q, request *r);
124 request *request_head(request_q *q);
125 request *request_deq(request_q *q);
126 request *request_deq_x(request_q *q, request *r);
127 void request_initq(request_q *q);
128 void request_delq(request_q *q);
129 request *request_get(request_q *q);
130 void request_release(request *r);
132 int statserv_must_terminate(void);
134 int control_association(association *assoc, const char *host, int force);
136 int ir_read(IOCHAN h, int event);
142 * indent-tabs-mode: nil
144 * vim: shiftwidth=4 tabstop=8 expandtab