Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / lib / DtSvc / DtUtil2 / MsgP.h
1 #ifndef _DT_MSG_P_H 
2 #define _DT_MSG_P_H
3 /*
4  *  MsgP.h -- Private header file for DT messaging library 
5  *
6  *  $XConsortium: MsgP.h /main/3 1995/10/26 15:24:51 rswiston $
7  *  $XConsortium: MsgP.h /main/3 1995/10/26 15:24:51 rswiston $
8  *
9  * (C) Copyright 1993, Hewlett-Packard, all rights reserved.
10  */
11 #include <Dt/Msg.h>
12
13
14 /*
15  * Definitions
16  */
17
18 /* max property size (bytes) */
19 #define DT_MSG_MAX_PROP_SIZE    (32768)
20
21 /* atom names */
22 #define DT_MSG_XA_REQUEST               "_DT_REQUEST"
23 #define DT_MSG_XA_NOTIFY                "_DT_NOTIFY"
24 #define DT_MSG_XA_BROADCAST_REGISTRY    "_DT_BROADCAST_REGISTRY"
25
26 /*
27  * _DtMessage handle
28  */
29 typedef struct _DtMsgHandle {
30     char *              pchName;        /* handle "name" */
31     Atom                atom;           /* Selection/Broadcast atom  */
32     Widget              widget;         /* Widget registering this handle */
33     char *              pchPropName;    /* property name */
34     Atom                property;       /* atomized property name */
35
36     /* other data */
37     struct _DtMsgServiceContext *
38                         service_data;   /* service data assoc w/ handle */
39     struct _DtMsgBroadcastData *
40                         broadcast_data; /* broadcast data assoc w/ handle */
41 } DtMsgHandle;
42
43 /*
44  * _DtMessage handle accessor "functions" 
45  */
46 #define DtMsgH_Name(h)          ((h)->pchName)
47 #define DtMsgH_Widget(h)        ((h)->widget)
48 #define DtMsgH_Atom(h)          ((h)->atom)
49 #define DtMsgH_SvcData(h)       ((h)->service_data)
50 #define DtMsgH_BcData(h)        ((h)->broadcast_data)
51 #define DtMsgH_PropertyName(h)  ((h)->pchPropName)
52 #define DtMsgH_PropertyAtom(h)  ((h)->property)
53 #define DtMsgH_Shandle(h)       ((h)->service_data->handle)
54 #define DtMsgH_RequestProc(h)   ((h)->service_data->request_proc)
55 #define DtMsgH_ReceiveCD(h)     ((h)->service_data->receive_client_data)
56 #define DtMsgH_LoseProc(h)      ((h)->service_data->lose_proc)
57 #define DtMsgH_LoseCD(h)        ((h)->service_data->lose_client_data)
58 #define DtMsgH_RegistryAtom(h)  ((h)->broadcast_data->aRegistry)
59 #define DtMsgH_SharedWindow(h)  ((h)->broadcast_data->winShared)
60 #define DtMsgH_SharedWidget(h)  ((h)->broadcast_data->wShared)
61 #define DtMsgH_Listener(h)      ((h)->broadcast_data->wListener)
62 #define DtMsgH_BreceiveProc(h)  ((h)->broadcast_data->Breceive_proc)
63 #define DtMsgH_BclientData(h)   ((h)->broadcast_data->Bclient_data)
64 #define DtMsgH_Bprops(h)        ((h)->broadcast_data->props)
65 #define DtMsgH_BnumProps(h)     ((h)->broadcast_data->numProps)
66 #define DtMsgH_BsizeProps(h)    ((h)->broadcast_data->sizeProps)
67 #define DtMsgH_Breceivers(h)    ((h)->broadcast_data->pReceivers)
68 #define DtMsgH_BnumReceivers(h) ((h)->broadcast_data->numReceivers)
69 #define DtMsgH_BsizeReceivers(h)        ((h)->broadcast_data->sizeReceivers)
70 #define DtMsgH_BSenderInit(h) ((h)->broadcast_data->bSenderInitialized)
71
72 /*
73  * Service context data 
74  * (for client that offers a service)
75  */
76 typedef struct _DtMsgServiceContext {
77     DtMsgHandle handle;
78     DtMsgReceiveProc    request_proc;
79     DtMsgStatusProc     lose_proc;
80     Pointer             receive_client_data;
81     Pointer             lose_client_data;
82 } DtMsgServiceContext;
83
84 /*
85  * Request context data
86  * (for client that makes a service request)
87  */
88 typedef struct _DtMsgRequestContext {
89     DtMsgHandle handle;
90     DtMsgReceiveProc    reply_proc;
91     Pointer             client_data;
92 } DtMsgRequestContext;
93
94
95 /*
96  * Reply message context data
97  * (for client replying to a request)
98  */
99 typedef struct _DtMsgReplyMessageContext {
100     DtMsgHandle handle;
101     Window              window;
102     Atom                target;
103     Atom                property;
104 } DtMsgReplyMessageContext;
105
106
107 /*
108  * Broadcast sender data
109  */
110
111 /* number of props to allocate per memory request */
112 #define DT_MSG_PROP_INC_AMT     10
113
114 typedef struct _DtMsgBroadcastPerReceiverData {
115     Widget              widget;                 /* widget of receiver */
116     Atom *              propsUnread;            /* list of props */
117     int                 numPropsUnread;         /* number of props */
118     int                 sizePropsUnread;        /* amt of space allocated */
119 } DtMsgBroadcastPerReceiverData;
120
121 typedef struct _DtMsgBroadcastData {
122     Atom                aRegistry;      /* registry atom name */
123     Window              winShared;      /* shared window */
124     Widget              wShared;        /* shared widget */
125     Widget              wListener;      /* child of shared window */
126     DtMsgReceiveProc    Breceive_proc;  /* broadcast receive proc */
127     Pointer             Bclient_data;   /* broadcast client data */
128
129     Boolean             bSenderInitialized;     /* true if ready for send */
130     Atom *              props;          /* props to use for messages */
131     int                 numProps;       /* number of message props */
132     int                 sizeProps;      /* number of props allocated */
133     DtMsgBroadcastPerReceiverData *     pReceivers;     /* rcvr data */
134     int                 numReceivers;   /* number of receivers */
135     int                 sizeReceivers;  /* amt of rcvr space allocated */
136
137 } DtMsgBroadcastData;
138
139
140 /* 
141  * Broadcast _DtMessage Registry definitions
142  */
143
144 /* registry entry size, in words */
145 #define DT_MSG_REGISTRY_ENTRY_SIZE      2
146
147 /* offsets within each registry entry */
148 #define DT_MSG_REGISTRY_NAME_OFFSET     0
149 #define DT_MSG_REGISTRY_WINDOW_OFFSET   1
150
151 /* Macros to compute offset */
152 #define MSG_GROUP_NAME(R, i) \
153     (R[((i)*DT_MSG_REGISTRY_ENTRY_SIZE)+DT_MSG_REGISTRY_NAME_OFFSET])
154
155 #define MSG_GROUP_WINDOW(R, i) \
156     (R[((i)*DT_MSG_REGISTRY_ENTRY_SIZE)+DT_MSG_REGISTRY_WINDOW_OFFSET])
157
158
159 #endif /* not defined _DT_MSG_P_H */
160 /***** END OF FILE ****/