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