2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
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)
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
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
23 /* $XConsortium: xtclient.c /main/1 1996/04/21 19:24:58 drk $ */
25 * (c) Copyright 1993, 1994 Hewlett-Packard Company
26 * (c) Copyright 1993, 1994 International Business Machines Corp.
27 * (c) Copyright 1993, 1994 Novell, Inc.
28 * (c) Copyright 1993, 1994 Sun Microsystems, Inc.
31 #include <EUSCompat.h>
33 #include <X11/Intrinsic.h>
37 typedef struct _appctlist {
39 struct _appctlist *next;
42 static AppCtList *registered_appct = NULL;
44 /*****************************************************************************
45 * forward declaration of static functions
46 *****************************************************************************/
47 static void xtcallback(XtPointer data, int *fid, XtInputId *id);
48 static boolean_t new_appct(XtAppContext apptct);
50 /*****************************************************************************
51 * extern functions used in the library
52 *****************************************************************************/
55 * register callback for all file descriptors that's set
56 * (since we don't know which one is ours).
59 _DtCm_register_xtcallback(XtAppContext appct)
64 fd_set fdset = svc_fdset;
66 DP(("xtclient.c: _DtCm_register_xtcallback()\n"));
68 if (new_appct(appct) == B_FALSE)
71 /* assuming only 1 bit is set */
72 bits = fdset.fds_bits;
73 for (i = 0; i < FD_SETSIZE; i += NFDBITS) {
75 for (j = 0; fmask != 0; j++, fmask >>= 1) {
78 if ((i + j) >= FD_SETSIZE)
81 /* register callback with XtAppAddInput
84 id = XtAppAddInput(appct, ((i *NFDBITS) + j),
85 (XtPointer)XtInputReadMask,
88 DP(("xtclient.c: id %d for input at fd %d\n",
89 id, ((i * NFDBITS) + j)));
96 /*****************************************************************************
97 * static functions used within the file
98 *****************************************************************************/
101 * callback for rpc events
104 xtcallback(XtPointer data, int *fid, XtInputId *id)
108 DP(("xtcallback called\n"));
111 FD_SET(*fid, &rpc_bits);
112 svc_getreqset(&rpc_bits);
116 * need to lock registered_appct
119 new_appct(XtAppContext appct)
122 boolean_t newappct = B_TRUE;
124 for (lptr = registered_appct; lptr != NULL; lptr = lptr->next) {
125 if (lptr->appct == appct) {
131 if (newappct == B_TRUE) {
132 lptr = (AppCtList *)calloc(1, sizeof(AppCtList));
134 lptr->next = registered_appct;
135 registered_appct = lptr;