YAZ  5.23.1
session.h
Go to the documentation of this file.
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) Index Data.
3  * All rights reserved.
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of Index Data nor the names of its contributors
13  * may be used to endorse or promote products derived from this
14  * software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
31 #ifndef SESSION_H
32 #define SESSION_H
33 
34 #include <yaz/comstack.h>
35 #include <yaz/cql.h>
36 #include <yaz/ccl.h>
37 #include <yaz/odr.h>
38 #include <yaz/proto.h>
39 #include <yaz/backend.h>
40 #include <yaz/retrieval.h>
41 #include "eventl.h"
42 
43 struct gfs_server {
45  char *host;
46  char *id;
47  int *listen_ref;
51  char *directory;
52  char *docpath;
53  char *stylesheet;
56  struct gfs_server *next;
57 };
58 
59 struct gfs_listen {
60  char *id;
61  char *address;
62  struct gfs_listen *next;
63 };
64 
65 typedef enum {
66  REQUEST_IDLE, /* the request is just sitting in the queue */
67  REQUEST_PENDING /* operation pending (b'end processing or network I/O*/
68  /* this list will have more elements when acc/res control is added */
70 
71 typedef struct request
72 {
74 
75  Z_GDU *gdu_request; /* Current request */
76  Z_APDU *apdu_request; /* Current Z39.50 request */
77  NMEM request_mem; /* memory handle for request */
78 
79  int size_response; /* size of buffer */
80  int len_response; /* length of encoded data */
81  char *response; /* encoded data waiting for transmission */
82 
83  void *clientData;
84  struct request *next;
85  struct request_q *q;
86 } request;
87 
88 typedef struct request_q
89 {
93  int num;
94 } request_q;
95 
96 /*
97  * association state.
98  */
99 typedef enum
100 {
101  ASSOC_NEW, /* not initialized yet or HTTP session */
102  ASSOC_UP, /* Z39.50 session is UP */
103  ASSOC_DEAD /* dead. Close if input arrives */
105 
106 typedef struct association
107 {
108  IOCHAN client_chan; /* event-loop control */
109  COMSTACK client_link; /* communication handle */
110  ODR decode; /* decoding stream */
111  ODR encode; /* encoding stream */
112  ODR print; /* printing stream (for -a) */
113  char *encode_buffer; /* temporary buffer for encoded data */
114  int encoded_len; /* length of encoded data */
115  char *input_buffer; /* input buffer (allocated by comstack) */
116  int input_buffer_len; /* length (size) of buffer */
117  int input_apdu_len; /* length of current incoming APDU */
118  oid_proto proto; /* protocol (PROTO_Z3950/PROTO_SR) */
119  void *backend; /* backend handle */
120  request_q incoming; /* Q of incoming PDUs */
121  request_q outgoing; /* Q of outgoing data buffers (enc. PDUs) */
123 
124  /* session parameters */
127  int version; /* highest version-bit set (2 or 3) */
128 
132 
135 
137 } association;
138 
140  const char *apdufile);
142 void ir_session(IOCHAN h, int event);
143 
144 void request_enq(request_q *q, request *r);
148 void request_initq(request_q *q);
149 void request_delq(request_q *q);
151 void request_release(request *r);
152 
153 int control_association(association *assoc, const char *host, int force);
154 
155 int ir_read(IOCHAN h, int event);
156 
157 #endif
158 /*
159  * Local variables:
160  * c-basic-offset: 4
161  * c-file-style: "Stroustrup"
162  * indent-tabs-mode: nil
163  * End:
164  * vim: shiftwidth=4 tabstop=8 expandtab
165  */
166 
request * request_get(request_q *q)
Definition: requestq.c:67
Z_APDU * apdu_request
Definition: session.h:76
Header for ODR (Open Data Representation)
int num
Definition: session.h:93
IOCHAN client_chan
Definition: session.h:108
void ir_session(IOCHAN h, int event)
Definition: seshigh.c:365
struct request_q * q
Definition: session.h:85
request * tail
Definition: session.h:91
char * input_buffer
Definition: session.h:115
yaz_retrieval_t retrieval
Definition: session.h:55
int cs_get_mask
Definition: session.h:129
int encoded_len
Definition: session.h:114
request * request_deq_x(request_q *q, request *r)
request_state
Definition: session.h:65
request_q incoming
Definition: session.h:120
request_state state
Definition: session.h:73
void request_enq(request_q *q, request *r)
Definition: requestq.c:21
struct gfs_server * next
Definition: session.h:56
void * backend
Definition: session.h:119
ODR decode
Definition: session.h:110
char * encode_buffer
Definition: session.h:113
int input_buffer_len
Definition: session.h:116
oid_proto proto
Definition: session.h:118
Information for the Init handler.
Definition: backend.h:251
oid_proto
Definition: oid_util.h:44
void * server_node_ptr
Definition: session.h:50
void destroy_association(association *h)
Definition: seshigh.c:207
struct request * next
Definition: session.h:84
struct bend_initrequest * init
Definition: session.h:133
Definitions for event loop handling for GFS.
char * host
Definition: session.h:45
int control_association(association *assoc, const char *host, int force)
Definition: statserv.c:267
Header with public definitions about CQL.
struct gfs_server * server
Definition: session.h:136
ODR encode
Definition: session.h:111
struct request request
char * address
Definition: session.h:61
request_q outgoing
Definition: session.h:121
int len_response
Definition: session.h:80
The internal structure for yaz_retrieval_t.
Definition: retrieval.c:30
Z_GDU * gdu_request
Definition: session.h:75
int * listen_ref
Definition: session.h:47
int maximumRecordSize
Definition: session.h:126
struct association association
statserv_options_block cb
Definition: session.h:44
char * id
Definition: session.h:46
Header for COMSTACK.
Header for Z39.50 Protocol.
request * list
Definition: session.h:92
void * clientData
Definition: session.h:83
int version
Definition: session.h:127
int ir_read(IOCHAN h, int event)
Definition: seshigh.c:266
int preferredMessageSize
Definition: session.h:125
request * head
Definition: session.h:90
char * directory
Definition: session.h:51
association * create_association(IOCHAN channel, COMSTACK link, const char *apdufile)
Definition: seshigh.c:148
int input_apdu_len
Definition: session.h:117
Definition: odr.h:124
NMEM request_mem
Definition: session.h:77
void request_delq(request_q *q)
Definition: requestq.c:55
struct request_q request_q
int size_response
Definition: session.h:79
association_state state
Definition: session.h:122
control block for server
Definition: backend.h:330
char * stylesheet
Definition: session.h:53
int cs_put_mask
Definition: session.h:130
char * id
Definition: session.h:60
Definition: eventl.h:45
char * docpath
Definition: session.h:52
cql_transform_t cql_transform
Definition: session.h:48
Definition: z-core.h:321
Definition: zgdu.h:68
request * request_head(request_q *q)
Definition: requestq.c:31
char * response
Definition: session.h:81
CCL_bibset ccl_transform
Definition: session.h:49
struct gfs_listen * next
Definition: session.h:62
void request_release(request *r)
Definition: requestq.c:91
int cs_accept_mask
Definition: session.h:131
request * request_deq(request_q *q)
Definition: requestq.c:36
Retrieval utility.
COMSTACK client_link
Definition: session.h:109
Header for GFS.
char * client_query_charset
Definition: session.h:54
association_state
Definition: session.h:99
Header with public definitions for CCL.
ODR print
Definition: session.h:112
void request_initq(request_q *q)
Definition: requestq.c:49
statserv_options_block * last_control
Definition: session.h:134