5e44a74611d78cc3be219c72bedb8303c6efd360
[yaz-moved-to-github.git] / server / session.h
1 /*
2  * Copyright (C) 1995, 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.8  1995-05-17 08:42:28  quinn
8  * Transfer auth info to backend. Allow backend to reject init gracefully.
9  *
10  * Revision 1.7  1995/05/16  08:51:08  quinn
11  * License, documentation, and memory fixes
12  *
13  * Revision 1.6  1995/05/15  11:56:41  quinn
14  * Asynchronous facilities. Restructuring of seshigh code.
15  *
16  * Revision 1.5  1995/04/20  15:13:01  quinn
17  * Cosmetic
18  *
19  * Revision 1.4  1995/04/10  10:23:39  quinn
20  * Some work to add scan and other things.
21  *
22  * Revision 1.3  1995/03/30  09:09:27  quinn
23  * Added state-handle and some support for asynchronous activities.
24  *
25  * Revision 1.2  1995/03/27  08:34:29  quinn
26  * Added dynamic server functionality.
27  * Released bindings to session.c (is now redundant)
28  *
29  * Revision 1.1  1995/03/14  10:28:02  quinn
30  * More work on demo server.
31  *
32  *
33  */
34
35 #ifndef SESSION_H
36 #define SESSION_H
37
38 #include <comstack.h>
39 #include <odr.h>
40 #include <oid.h>
41 #include <proto.h>
42 #include <eventl.h>
43
44 typedef struct request
45 {
46     int len_refid;          /* length of referenceid */
47     char *refid;            /* referenceid */
48     enum {
49         REQUEST_IDLE,    /* the request is just sitting in the queue */
50         REQUEST_PENDING  /* operation pending (b'end processing or network I/O*/
51         /* this list will have more elements when acc/res control is added */
52     } state;
53
54     Z_APDU *request;        /* Current request */
55     ODR_MEM request_mem;    /* ODR memory handle for request */
56
57     int size_response;     /* size of buffer */
58     int len_response;      /* length of encoded data */
59     char *response;        /* encoded data waiting for transmission */
60
61     struct request *next;
62 } request;
63
64 typedef struct request_q
65 {
66     request *head;
67     request *tail;
68     int num;
69 } request_q;
70
71 /*
72  * association state.
73  */
74 typedef struct association
75 {
76     IOCHAN client_chan;           /* event-loop control */
77     COMSTACK client_link;         /* communication handle */
78     ODR decode;                   /* decoding stream */
79     ODR encode;                   /* encoding stream */
80     ODR print;                    /* printing stream (for -a) */
81     char *encode_buffer;          /* temporary buffer for encoded data */
82     int encoded_len;              /* length of encoded data */
83     char *input_buffer;           /* input buffer (allocated by comstack) */
84     int input_buffer_len;         /* length (size) of buffer */
85     int input_apdu_len;           /* length of current incoming APDU */
86     oid_proto proto;              /* protocol (PROTO_Z3950/PROTO_SR) */
87     void *backend;                /* backend handle */
88     request_q incoming;           /* Q of incoming PDUs */
89     request_q outgoing;           /* Q of outgoing data buffers (enc. PDUs) */
90     int rejected;                 /* session rejected */
91
92     /* session parameters */
93     int preferredMessageSize;
94     int maximumRecordSize;
95 } association;
96
97 association *create_association(IOCHAN channel, COMSTACK link);
98 void destroy_association(association *h);
99 void ir_session(IOCHAN h, int event);
100
101 void request_enq(request_q *q, request *r);
102 request *request_head(request_q *q);
103 request *request_deq(request_q *q);
104 void request_initq(request_q *q);
105 request *request_get(void);
106 void request_release(request *r);
107
108 #endif