xref: /OK3568_Linux_fs/external/xserver/include/client.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). All
3*4882a593Smuzhiyun  * rights reserved.
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * Permission is hereby granted, free of charge, to any person obtaining a copy
6*4882a593Smuzhiyun  * of this software and associated documentation files (the "Software"), to deal
7*4882a593Smuzhiyun  * in the Software without restriction, including without limitation the rights
8*4882a593Smuzhiyun  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9*4882a593Smuzhiyun  * copies of the Software, and to permit persons to whom the Software is
10*4882a593Smuzhiyun  * furnished to do so, subject to the following conditions:
11*4882a593Smuzhiyun  *
12*4882a593Smuzhiyun  * The above copyright notice and this permission notice shall be included in
13*4882a593Smuzhiyun  * all copies or substantial portions of the Software.
14*4882a593Smuzhiyun  *
15*4882a593Smuzhiyun  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16*4882a593Smuzhiyun  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17*4882a593Smuzhiyun  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18*4882a593Smuzhiyun  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19*4882a593Smuzhiyun  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20*4882a593Smuzhiyun  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21*4882a593Smuzhiyun  * THE SOFTWARE.
22*4882a593Smuzhiyun  */
23*4882a593Smuzhiyun 
24*4882a593Smuzhiyun /* Author: Rami Ylimäki <rami.ylimaki@vincit.fi> */
25*4882a593Smuzhiyun 
26*4882a593Smuzhiyun #ifndef CLIENT_H
27*4882a593Smuzhiyun #define CLIENT_H
28*4882a593Smuzhiyun 
29*4882a593Smuzhiyun #ifdef HAVE_DIX_CONFIG_H
30*4882a593Smuzhiyun #include <dix-config.h>
31*4882a593Smuzhiyun #endif                          /* HAVE_DIX_CONFIG_H */
32*4882a593Smuzhiyun #include <X11/Xfuncproto.h>
33*4882a593Smuzhiyun #include <sys/types.h>
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun /* Client IDs. Use GetClientPid, GetClientCmdName and GetClientCmdArgs
36*4882a593Smuzhiyun  * instead of accessing the fields directly. */
37*4882a593Smuzhiyun typedef struct {
38*4882a593Smuzhiyun     pid_t pid;                  /* process ID, -1 if not available */
39*4882a593Smuzhiyun     const char *cmdname;        /* process name, NULL if not available */
40*4882a593Smuzhiyun     const char *cmdargs;        /* process arguments, NULL if not available */
41*4882a593Smuzhiyun } ClientIdRec, *ClientIdPtr;
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun struct _Client;
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun /* Initialize and clean up. */
46*4882a593Smuzhiyun void ReserveClientIds(struct _Client *client);
47*4882a593Smuzhiyun void ReleaseClientIds(struct _Client *client);
48*4882a593Smuzhiyun 
49*4882a593Smuzhiyun /* Determine client IDs for caching. Exported on purpose for
50*4882a593Smuzhiyun  * extensions such as SELinux. */
51*4882a593Smuzhiyun extern _X_EXPORT pid_t DetermineClientPid(struct _Client *client);
52*4882a593Smuzhiyun extern _X_EXPORT void DetermineClientCmd(pid_t, const char **cmdname,
53*4882a593Smuzhiyun                                          const char **cmdargs);
54*4882a593Smuzhiyun 
55*4882a593Smuzhiyun /* Query cached client IDs. Exported on purpose for drivers. */
56*4882a593Smuzhiyun extern _X_EXPORT pid_t GetClientPid(struct _Client *client);
57*4882a593Smuzhiyun extern _X_EXPORT const char *GetClientCmdName(struct _Client *client);
58*4882a593Smuzhiyun extern _X_EXPORT const char *GetClientCmdArgs(struct _Client *client);
59*4882a593Smuzhiyun 
60*4882a593Smuzhiyun #endif                          /* CLIENT_H */
61