3 Copyright 1996, 1998 The Open Group
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in this Software without prior written authorization from The Open Group.
28 /* Author: Ralph Mor, X Consortium */
33 #include <X11/ICE/ICElib.h>
34 #include "ICElibint.h"
35 #include <X11/Xtrans/Xtrans.h>
40 IceListenForWellKnownConnections (
43 IceListenObj **listenObjsRet,
48 struct _IceListenObj *listenObjs;
50 int transCount, partial, i, j;
52 XtransConnInfo *transConns = NULL;
55 if ((_IceTransMakeAllCOTSServerListeners (port, &partial,
56 &transCount, &transConns) < 0) || (transCount < 1))
58 *listenObjsRet = NULL;
61 strncpy (errorStringRet,
62 "Cannot establish any listening sockets", errorLength);
67 if ((listenObjs = (struct _IceListenObj *) malloc (
68 transCount * sizeof (struct _IceListenObj))) == NULL)
70 for (i = 0; i < transCount; i++)
71 _IceTransClose (transConns[i]);
72 free ((char *) transConns);
78 for (i = 0; i < transCount; i++)
80 networkId = (char *)_IceTransGetMyNetworkId (transConns[i]);
84 listenObjs[*countRet].trans_conn = transConns[i];
85 listenObjs[*countRet].network_id = networkId;
93 *listenObjsRet = NULL;
95 strncpy (errorStringRet,
96 "Cannot establish any listening sockets", errorLength);
102 *listenObjsRet = (IceListenObj *) malloc (
103 *countRet * sizeof (IceListenObj));
105 if (*listenObjsRet == NULL)
107 strncpy (errorStringRet, "Malloc failed", errorLength);
113 for (i = 0; i < *countRet; i++)
115 (*listenObjsRet)[i] = (IceListenObj) malloc (
116 sizeof (struct _IceListenObj));
118 if ((*listenObjsRet)[i] == NULL)
120 strncpy (errorStringRet, "Malloc failed", errorLength);
122 for (j = 0; j < i; j++)
123 free ((char *) (*listenObjsRet)[j]);
125 free ((char *) *listenObjsRet);
126 *listenObjsRet = NULL;
133 *((*listenObjsRet)[i]) = listenObjs[i];
141 if (errorStringRet && errorLength > 0)
142 *errorStringRet = '\0';
144 for (i = 0; i < *countRet; i++)
146 (*listenObjsRet)[i]->host_based_auth_proc = NULL;
151 for (i = 0; i < transCount; i++)
152 _IceTransClose (transConns[i]);
155 free ((char *) listenObjs);
156 free ((char *) transConns);