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