1 /******************************************************************************
4 Copyright 1993, 1998 The Open Group
6 Permission to use, copy, modify, distribute, and sell this software and its
7 documentation for any purpose is hereby granted without fee, provided that
8 the above copyright notice appear in all copies and that both that
9 copyright notice and this permission notice appear in supporting
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 Except as contained in this notice, the name of The Open Group shall not be
23 used in advertising or otherwise to promote the sale, use or other dealings
24 in this Software without prior written authorization from The Open Group.
26 Author: Ralph Mor, X Consortium
27 ******************************************************************************/
32 #include <X11/ICE/ICElib.h>
33 #include "ICElibint.h"
36 IceRegisterForProtocolSetup (
37 const char *protocolName,
41 IcePoVersionRec *versionRecs,
43 const char **authNames,
44 IcePoAuthProc *authProcs,
45 IceIOErrorProc IOErrorProc
51 for (i = 1; i <= _IceLastMajorOpcode; i++)
52 if (strcmp (protocolName, _IceProtocols[i - 1].protocol_name) == 0)
54 if (_IceProtocols[i - 1].orig_client != NULL)
57 * We've already registered this protocol.
68 if (i <= _IceLastMajorOpcode)
70 p = _IceProtocols[i - 1].orig_client =
71 (_IcePoProtocol *) malloc (sizeof (_IcePoProtocol));
74 else if (_IceLastMajorOpcode == 255 ||
76 strlen (protocolName) == 0)
84 _IceProtocols[_IceLastMajorOpcode].protocol_name = name =
87 p = _IceProtocols[_IceLastMajorOpcode].orig_client =
88 (_IcePoProtocol *) malloc (sizeof (_IcePoProtocol));
90 _IceProtocols[_IceLastMajorOpcode].accept_client = NULL;
92 opcodeRet = ++_IceLastMajorOpcode;
95 p->vendor = strdup(vendor);
96 p->release = strdup(release);
98 p->version_count = versionCount;
100 p->version_recs = (IcePoVersionRec *) malloc (
101 versionCount * sizeof (IcePoVersionRec));
102 memcpy (p->version_recs, versionRecs,
103 versionCount * sizeof (IcePoVersionRec));
105 if ((p->auth_count = authCount) > 0)
107 p->auth_names = (char **) malloc (
108 authCount * sizeof (char *));
110 p->auth_procs = (IcePoAuthProc *) malloc (
111 authCount * sizeof (IcePoAuthProc));
113 for (i = 0; i < authCount; i++)
115 p->auth_names[i] = strdup(authNames[i]);
116 p->auth_procs[i] = authProcs[i];
121 p->auth_names = NULL;
122 p->auth_procs = NULL;
125 p->io_error_proc = IOErrorProc;
133 IceRegisterForProtocolReply (
134 const char *protocolName,
138 IcePaVersionRec *versionRecs,
140 const char **authNames,
141 IcePaAuthProc *authProcs,
142 IceHostBasedAuthProc hostBasedAuthProc,
143 IceProtocolSetupProc protocolSetupProc,
144 IceProtocolActivateProc protocolActivateProc,
145 IceIOErrorProc IOErrorProc
151 for (i = 1; i <= _IceLastMajorOpcode; i++)
152 if (strcmp (protocolName, _IceProtocols[i - 1].protocol_name) == 0)
154 if (_IceProtocols[i - 1].accept_client != NULL)
157 * We've already registered this protocol.
169 if (i <= _IceLastMajorOpcode)
171 p = _IceProtocols[i - 1].accept_client =
172 (_IcePaProtocol *) malloc (sizeof (_IcePaProtocol));
175 else if (_IceLastMajorOpcode == 255 ||
177 strlen (protocolName) == 0)
185 _IceProtocols[_IceLastMajorOpcode].protocol_name = name =
186 strdup(protocolName);
188 _IceProtocols[_IceLastMajorOpcode].orig_client = NULL;
190 p = _IceProtocols[_IceLastMajorOpcode].accept_client =
191 (_IcePaProtocol *) malloc (sizeof (_IcePaProtocol));
193 opcodeRet = ++_IceLastMajorOpcode;
196 p->vendor = strdup(vendor);
197 p->release = strdup(release);
199 p->version_count = versionCount;
201 p->version_recs = (IcePaVersionRec *) malloc (
202 versionCount * sizeof (IcePaVersionRec));
203 memcpy (p->version_recs, versionRecs,
204 versionCount * sizeof (IcePaVersionRec));
206 p->protocol_setup_proc = protocolSetupProc;
207 p->protocol_activate_proc = protocolActivateProc;
209 if ((p->auth_count = authCount) > 0)
211 p->auth_names = (char **) malloc (
212 authCount * sizeof (char *));
214 p->auth_procs = (IcePaAuthProc *) malloc (
215 authCount * sizeof (IcePaAuthProc));
217 for (i = 0; i < authCount; i++)
219 p->auth_names[i] = strdup(authNames[i]);
220 p->auth_procs[i] = authProcs[i];
225 p->auth_names = NULL;
226 p->auth_procs = NULL;
229 p->host_based_auth_proc = hostBasedAuthProc;
231 p->io_error_proc = IOErrorProc;