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