Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / lib / DtSvc / DtUtil2 / MsgP.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 #ifndef _DT_MSG_P_H 
24 #define _DT_MSG_P_H
25 /*
26  *  MsgP.h -- Private header file for DT messaging library 
27  *
28  *  $XConsortium: MsgP.h /main/3 1995/10/26 15:24:51 rswiston $
29  *  $XConsortium: MsgP.h /main/3 1995/10/26 15:24:51 rswiston $
30  *
31  * (C) Copyright 1993, Hewlett-Packard, all rights reserved.
32  */
33 #include <Dt/Msg.h>
34
35
36 /*
37  * Definitions
38  */
39
40 /* max property size (bytes) */
41 #define DT_MSG_MAX_PROP_SIZE    (32768)
42
43 /* atom names */
44 #define DT_MSG_XA_REQUEST               "_DT_REQUEST"
45 #define DT_MSG_XA_NOTIFY                "_DT_NOTIFY"
46 #define DT_MSG_XA_BROADCAST_REGISTRY    "_DT_BROADCAST_REGISTRY"
47
48 /*
49  * _DtMessage handle
50  */
51 typedef struct _DtMsgHandle {
52     char *              pchName;        /* handle "name" */
53     Atom                atom;           /* Selection/Broadcast atom  */
54     Widget              widget;         /* Widget registering this handle */
55     char *              pchPropName;    /* property name */
56     Atom                property;       /* atomized property name */
57
58     /* other data */
59     struct _DtMsgServiceContext *
60                         service_data;   /* service data assoc w/ handle */
61     struct _DtMsgBroadcastData *
62                         broadcast_data; /* broadcast data assoc w/ handle */
63 } DtMsgHandle;
64
65 /*
66  * _DtMessage handle accessor "functions" 
67  */
68 #define DtMsgH_Name(h)          ((h)->pchName)
69 #define DtMsgH_Widget(h)        ((h)->widget)
70 #define DtMsgH_Atom(h)          ((h)->atom)
71 #define DtMsgH_SvcData(h)       ((h)->service_data)
72 #define DtMsgH_BcData(h)        ((h)->broadcast_data)
73 #define DtMsgH_PropertyName(h)  ((h)->pchPropName)
74 #define DtMsgH_PropertyAtom(h)  ((h)->property)
75 #define DtMsgH_Shandle(h)       ((h)->service_data->handle)
76 #define DtMsgH_RequestProc(h)   ((h)->service_data->request_proc)
77 #define DtMsgH_ReceiveCD(h)     ((h)->service_data->receive_client_data)
78 #define DtMsgH_LoseProc(h)      ((h)->service_data->lose_proc)
79 #define DtMsgH_LoseCD(h)        ((h)->service_data->lose_client_data)
80 #define DtMsgH_RegistryAtom(h)  ((h)->broadcast_data->aRegistry)
81 #define DtMsgH_SharedWindow(h)  ((h)->broadcast_data->winShared)
82 #define DtMsgH_SharedWidget(h)  ((h)->broadcast_data->wShared)
83 #define DtMsgH_Listener(h)      ((h)->broadcast_data->wListener)
84 #define DtMsgH_BreceiveProc(h)  ((h)->broadcast_data->Breceive_proc)
85 #define DtMsgH_BclientData(h)   ((h)->broadcast_data->Bclient_data)
86 #define DtMsgH_Bprops(h)        ((h)->broadcast_data->props)
87 #define DtMsgH_BnumProps(h)     ((h)->broadcast_data->numProps)
88 #define DtMsgH_BsizeProps(h)    ((h)->broadcast_data->sizeProps)
89 #define DtMsgH_Breceivers(h)    ((h)->broadcast_data->pReceivers)
90 #define DtMsgH_BnumReceivers(h) ((h)->broadcast_data->numReceivers)
91 #define DtMsgH_BsizeReceivers(h)        ((h)->broadcast_data->sizeReceivers)
92 #define DtMsgH_BSenderInit(h) ((h)->broadcast_data->bSenderInitialized)
93
94 /*
95  * Service context data 
96  * (for client that offers a service)
97  */
98 typedef struct _DtMsgServiceContext {
99     DtMsgHandle handle;
100     DtMsgReceiveProc    request_proc;
101     DtMsgStatusProc     lose_proc;
102     Pointer             receive_client_data;
103     Pointer             lose_client_data;
104 } DtMsgServiceContext;
105
106 /*
107  * Request context data
108  * (for client that makes a service request)
109  */
110 typedef struct _DtMsgRequestContext {
111     DtMsgHandle handle;
112     DtMsgReceiveProc    reply_proc;
113     Pointer             client_data;
114 } DtMsgRequestContext;
115
116
117 /*
118  * Reply message context data
119  * (for client replying to a request)
120  */
121 typedef struct _DtMsgReplyMessageContext {
122     DtMsgHandle handle;
123     Window              window;
124     Atom                target;
125     Atom                property;
126 } DtMsgReplyMessageContext;
127
128
129 /*
130  * Broadcast sender data
131  */
132
133 /* number of props to allocate per memory request */
134 #define DT_MSG_PROP_INC_AMT     10
135
136 typedef struct _DtMsgBroadcastPerReceiverData {
137     Widget              widget;                 /* widget of receiver */
138     Atom *              propsUnread;            /* list of props */
139     int                 numPropsUnread;         /* number of props */
140     int                 sizePropsUnread;        /* amt of space allocated */
141 } DtMsgBroadcastPerReceiverData;
142
143 typedef struct _DtMsgBroadcastData {
144     Atom                aRegistry;      /* registry atom name */
145     Window              winShared;      /* shared window */
146     Widget              wShared;        /* shared widget */
147     Widget              wListener;      /* child of shared window */
148     DtMsgReceiveProc    Breceive_proc;  /* broadcast receive proc */
149     Pointer             Bclient_data;   /* broadcast client data */
150
151     Boolean             bSenderInitialized;     /* true if ready for send */
152     Atom *              props;          /* props to use for messages */
153     int                 numProps;       /* number of message props */
154     int                 sizeProps;      /* number of props allocated */
155     DtMsgBroadcastPerReceiverData *     pReceivers;     /* rcvr data */
156     int                 numReceivers;   /* number of receivers */
157     int                 sizeReceivers;  /* amt of rcvr space allocated */
158
159 } DtMsgBroadcastData;
160
161
162 /* 
163  * Broadcast _DtMessage Registry definitions
164  */
165
166 /* registry entry size, in words */
167 #define DT_MSG_REGISTRY_ENTRY_SIZE      2
168
169 /* offsets within each registry entry */
170 #define DT_MSG_REGISTRY_NAME_OFFSET     0
171 #define DT_MSG_REGISTRY_WINDOW_OFFSET   1
172
173 /* Macros to compute offset */
174 #define MSG_GROUP_NAME(R, i) \
175     (R[((i)*DT_MSG_REGISTRY_ENTRY_SIZE)+DT_MSG_REGISTRY_NAME_OFFSET])
176
177 #define MSG_GROUP_WINDOW(R, i) \
178     (R[((i)*DT_MSG_REGISTRY_ENTRY_SIZE)+DT_MSG_REGISTRY_WINDOW_OFFSET])
179
180
181 #endif /* not defined _DT_MSG_P_H */
182 /***** END OF FILE ****/