2003-11-14 16:54:54 +01:00
|
|
|
/*
|
|
|
|
|
|
|
|
Copyright 1987, 1998 The Open Group
|
|
|
|
|
|
|
|
Permission to use, copy, modify, distribute, and sell this software and its
|
|
|
|
documentation for any purpose is hereby granted without fee, provided that
|
|
|
|
the above copyright notice appear in all copies and that both that
|
|
|
|
copyright notice and this permission notice appear in supporting
|
|
|
|
documentation.
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included
|
|
|
|
in all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
|
|
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
Except as contained in this notice, the name of The Open Group shall
|
|
|
|
not be used in advertising or otherwise to promote the sale, use or
|
|
|
|
other dealings in this Software without prior written authorization
|
|
|
|
from The Open Group.
|
|
|
|
|
|
|
|
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
|
|
|
|
Copyright 1994 Quarterdeck Office Systems.
|
|
|
|
|
|
|
|
All Rights Reserved
|
|
|
|
|
|
|
|
Permission to use, copy, modify, and distribute this software and its
|
|
|
|
documentation for any purpose and without fee is hereby granted,
|
|
|
|
provided that the above copyright notice appear in all copies and that
|
|
|
|
both that copyright notice and this permission notice appear in
|
|
|
|
supporting documentation, and that the names of Digital and
|
|
|
|
Quarterdeck not be used in advertising or publicity pertaining to
|
|
|
|
distribution of the software without specific, written prior
|
|
|
|
permission.
|
|
|
|
|
|
|
|
DIGITAL AND QUARTERDECK DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|
|
|
|
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
|
|
FITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT
|
|
|
|
OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
|
|
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
|
|
|
|
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
|
|
|
|
OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2005-07-03 09:02:09 +02:00
|
|
|
#ifdef HAVE_DIX_CONFIG_H
|
|
|
|
#include <dix-config.h>
|
|
|
|
#endif
|
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
#ifdef __CYGWIN__
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <signal.h>
|
2008-11-02 21:17:02 +01:00
|
|
|
/*
|
|
|
|
Sigh... We really need a prototype for this to know it is stdcall,
|
|
|
|
but #include-ing <windows.h> here is not a good idea...
|
|
|
|
*/
|
|
|
|
__stdcall unsigned long GetTickCount(void);
|
2003-11-14 17:49:22 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(WIN32) && !defined(__CYGWIN__)
|
2003-11-14 16:54:54 +01:00
|
|
|
#include <X11/Xwinsock.h>
|
|
|
|
#endif
|
2005-04-20 14:25:48 +02:00
|
|
|
#include <X11/Xos.h>
|
2003-11-14 16:54:54 +01:00
|
|
|
#include <stdio.h>
|
2007-01-10 22:10:43 +01:00
|
|
|
#include <time.h>
|
2007-05-24 20:02:28 +02:00
|
|
|
#if !defined(WIN32) || !defined(__MINGW32__)
|
2007-04-09 21:28:53 +02:00
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/resource.h>
|
2007-05-24 20:02:28 +02:00
|
|
|
#endif
|
2005-07-03 10:53:54 +02:00
|
|
|
#include "misc.h"
|
2005-04-20 14:25:48 +02:00
|
|
|
#include <X11/X.h>
|
2006-06-21 23:36:09 +02:00
|
|
|
#define XSERV_t
|
|
|
|
#define TRANS_SERVER
|
|
|
|
#define TRANS_REOPEN
|
2005-04-20 14:25:48 +02:00
|
|
|
#include <X11/Xtrans/Xtrans.h>
|
2003-11-14 16:54:54 +01:00
|
|
|
#include "input.h"
|
2003-11-14 17:49:22 +01:00
|
|
|
#include "dixfont.h"
|
2015-09-02 03:50:55 +02:00
|
|
|
#include <X11/fonts/libxfont2.h>
|
2003-11-14 17:49:22 +01:00
|
|
|
#include "osdep.h"
|
2006-06-08 19:27:28 +02:00
|
|
|
#include "extension.h"
|
2003-11-14 16:54:54 +01:00
|
|
|
#ifdef X_POSIX_C_SOURCE
|
|
|
|
#define _POSIX_C_SOURCE X_POSIX_C_SOURCE
|
|
|
|
#include <signal.h>
|
|
|
|
#undef _POSIX_C_SOURCE
|
|
|
|
#else
|
2008-07-17 20:37:50 +02:00
|
|
|
#if defined(_POSIX_SOURCE)
|
2003-11-14 16:54:54 +01:00
|
|
|
#include <signal.h>
|
|
|
|
#else
|
|
|
|
#define _POSIX_SOURCE
|
|
|
|
#include <signal.h>
|
|
|
|
#undef _POSIX_SOURCE
|
|
|
|
#endif
|
|
|
|
#endif
|
2004-11-15 16:06:51 +01:00
|
|
|
#ifndef WIN32
|
2003-11-14 17:49:22 +01:00
|
|
|
#include <sys/wait.h>
|
2004-11-15 16:06:51 +01:00
|
|
|
#endif
|
2012-03-21 20:55:09 +01:00
|
|
|
#if !defined(SYSV) && !defined(WIN32)
|
2003-11-14 16:54:54 +01:00
|
|
|
#include <sys/resource.h>
|
|
|
|
#endif
|
|
|
|
#include <sys/stat.h>
|
2012-03-21 20:55:09 +01:00
|
|
|
#include <ctype.h> /* for isspace */
|
2003-11-14 16:54:54 +01:00
|
|
|
#include <stdarg.h>
|
2003-11-14 17:49:22 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
#include <stdlib.h> /* for malloc() */
|
2003-11-14 17:49:22 +01:00
|
|
|
|
2016-02-08 23:36:03 +01:00
|
|
|
#if defined(TCPCONN)
|
2012-03-21 20:55:09 +01:00
|
|
|
#ifndef WIN32
|
|
|
|
#include <netdb.h>
|
|
|
|
#endif
|
2003-11-14 16:54:54 +01:00
|
|
|
#endif
|
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
#include "opaque.h"
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
#include "dixstruct.h"
|
|
|
|
|
2008-03-18 09:05:57 +01:00
|
|
|
#include "xkbsrv.h"
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
#include "picture.h"
|
2004-09-14 02:51:25 +02:00
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool noTestExtensions;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2004-09-14 02:51:25 +02:00
|
|
|
#ifdef COMPOSITE
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool noCompositeExtension = FALSE;
|
2004-09-14 02:51:25 +02:00
|
|
|
#endif
|
2006-02-16 08:17:31 +01:00
|
|
|
|
2004-09-14 02:51:25 +02:00
|
|
|
#ifdef DAMAGE
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool noDamageExtension = FALSE;
|
2004-09-14 02:51:25 +02:00
|
|
|
#endif
|
|
|
|
#ifdef DBE
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool noDbeExtension = FALSE;
|
2004-09-14 02:51:25 +02:00
|
|
|
#endif
|
|
|
|
#ifdef DPMSExtension
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool noDPMSExtension = FALSE;
|
2004-09-14 02:51:25 +02:00
|
|
|
#endif
|
|
|
|
#ifdef GLXEXT
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool noGlxExtension = FALSE;
|
2004-09-14 02:51:25 +02:00
|
|
|
#endif
|
|
|
|
#ifdef SCREENSAVER
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool noScreenSaverExtension = FALSE;
|
2004-09-14 02:51:25 +02:00
|
|
|
#endif
|
|
|
|
#ifdef MITSHM
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool noMITShmExtension = FALSE;
|
2004-09-14 02:51:25 +02:00
|
|
|
#endif
|
|
|
|
#ifdef RANDR
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool noRRExtension = FALSE;
|
2004-09-14 02:51:25 +02:00
|
|
|
#endif
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool noRenderExtension = FALSE;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2004-09-14 02:51:25 +02:00
|
|
|
#ifdef XCSECURITY
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool noSecurityExtension = FALSE;
|
2004-09-14 02:51:25 +02:00
|
|
|
#endif
|
|
|
|
#ifdef RES
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool noResExtension = FALSE;
|
2004-09-14 02:51:25 +02:00
|
|
|
#endif
|
|
|
|
#ifdef XF86BIGFONT
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool noXFree86BigfontExtension = FALSE;
|
2004-09-14 02:51:25 +02:00
|
|
|
#endif
|
|
|
|
#ifdef XFreeXDGA
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool noXFree86DGAExtension = FALSE;
|
2004-09-14 02:51:25 +02:00
|
|
|
#endif
|
|
|
|
#ifdef XF86DRI
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool noXFree86DRIExtension = FALSE;
|
2004-09-14 02:51:25 +02:00
|
|
|
#endif
|
|
|
|
#ifdef XF86VIDMODE
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool noXFree86VidModeExtension = FALSE;
|
2004-09-14 02:51:25 +02:00
|
|
|
#endif
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool noXFixesExtension = FALSE;
|
2004-09-14 02:51:25 +02:00
|
|
|
#ifdef PANORAMIX
|
|
|
|
/* Xinerama is disabled by default unless enabled via +xinerama */
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool noPanoramiXExtension = TRUE;
|
2004-09-14 02:51:25 +02:00
|
|
|
#endif
|
2008-03-28 19:01:34 +01:00
|
|
|
#ifdef XSELINUX
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool noSELinuxExtension = FALSE;
|
|
|
|
int selinuxEnforcingState = SELINUX_MODE_DEFAULT;
|
2008-03-28 19:01:34 +01:00
|
|
|
#endif
|
2004-09-14 02:51:25 +02:00
|
|
|
#ifdef XV
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool noXvExtension = FALSE;
|
2004-09-14 02:51:25 +02:00
|
|
|
#endif
|
2008-03-27 00:28:09 +01:00
|
|
|
#ifdef DRI2
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool noDRI2Extension = FALSE;
|
2008-03-27 00:28:09 +01:00
|
|
|
#endif
|
2003-11-14 16:54:54 +01:00
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool noGEExtension = FALSE;
|
2007-04-30 05:27:42 +02:00
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
#define X_INCLUDE_NETDB_H
|
|
|
|
#include <X11/Xos_r.h>
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool CoreDump;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2014-09-04 19:59:40 +02:00
|
|
|
Bool enableIndirectGLX = FALSE;
|
2014-04-23 18:52:17 +02:00
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
#ifdef PANORAMIX
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool PanoramiXExtensionDisabledHack = FALSE;
|
2003-11-14 16:54:54 +01:00
|
|
|
#endif
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
int auditTrailLevel = 1;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2011-07-18 21:19:23 +02:00
|
|
|
char *SeatId = NULL;
|
|
|
|
|
2012-04-06 16:43:57 +02:00
|
|
|
sig_atomic_t inSignalContext = FALSE;
|
|
|
|
|
2003-11-25 20:29:01 +01:00
|
|
|
#if defined(SVR4) || defined(__linux__) || defined(CSRG_BASED)
|
|
|
|
#define HAS_SAVED_IDS_AND_SETEUID
|
|
|
|
#endif
|
|
|
|
|
2016-05-24 12:46:42 +02:00
|
|
|
#ifdef MONOTONIC_CLOCK
|
|
|
|
static clockid_t clockid;
|
|
|
|
#endif
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
OsSigHandlerPtr
|
2009-01-11 08:44:29 +01:00
|
|
|
OsSignal(int sig, OsSigHandlerPtr handler)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2012-04-20 14:46:21 +02:00
|
|
|
#if defined(WIN32) && !defined(__CYGWIN__)
|
|
|
|
return signal(sig, handler);
|
|
|
|
#else
|
2003-11-14 16:54:54 +01:00
|
|
|
struct sigaction act, oact;
|
|
|
|
|
|
|
|
sigemptyset(&act.sa_mask);
|
|
|
|
if (handler != SIG_IGN)
|
2012-03-21 20:55:09 +01:00
|
|
|
sigaddset(&act.sa_mask, sig);
|
2003-11-14 16:54:54 +01:00
|
|
|
act.sa_flags = 0;
|
|
|
|
act.sa_handler = handler;
|
2007-09-22 02:07:36 +02:00
|
|
|
if (sigaction(sig, &act, &oact))
|
2012-03-21 20:55:09 +01:00
|
|
|
perror("sigaction");
|
2003-11-14 16:54:54 +01:00
|
|
|
return oact.sa_handler;
|
2012-04-20 14:46:21 +02:00
|
|
|
#endif
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2008-07-17 20:37:50 +02:00
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
/*
|
|
|
|
* Explicit support for a server lock file like the ones used for UUCP.
|
|
|
|
* For architectures with virtual terminals that can run more than one
|
|
|
|
* server at a time. This keeps the servers from stomping on each other
|
|
|
|
* if the user forgets to give them different display numbers.
|
|
|
|
*/
|
|
|
|
#define LOCK_DIR "/tmp"
|
|
|
|
#define LOCK_TMP_PREFIX "/.tX"
|
|
|
|
#define LOCK_PREFIX "/.X"
|
|
|
|
#define LOCK_SUFFIX "-lock"
|
|
|
|
|
2011-10-21 19:32:49 +02:00
|
|
|
#if !defined(WIN32) || defined(__CYGWIN__)
|
|
|
|
#define LOCK_SERVER
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef LOCK_SERVER
|
|
|
|
void
|
|
|
|
LockServer(void)
|
|
|
|
{}
|
|
|
|
|
|
|
|
void
|
|
|
|
UnlockServer(void)
|
|
|
|
{}
|
|
|
|
#else /* LOCK_SERVER */
|
2003-11-14 17:49:22 +01:00
|
|
|
static Bool StillLocking = FALSE;
|
|
|
|
static char LockFile[PATH_MAX];
|
|
|
|
static Bool nolock = FALSE;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* LockServer --
|
|
|
|
* Check if the server lock file exists. If so, check if the PID
|
|
|
|
* contained inside is valid. If so, then die. Otherwise, create
|
|
|
|
* the lock file containing the PID.
|
|
|
|
*/
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2003-11-25 20:29:01 +01:00
|
|
|
LockServer(void)
|
2003-11-14 17:49:22 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
char tmp[PATH_MAX], pid_str[12];
|
|
|
|
int lfd, i, haslock, l_pid, t;
|
|
|
|
const char *tmppath = LOCK_DIR;
|
|
|
|
int len;
|
|
|
|
char port[20];
|
|
|
|
|
2014-03-19 22:03:13 +01:00
|
|
|
if (nolock || NoListenAll)
|
2012-03-21 20:55:09 +01:00
|
|
|
return;
|
|
|
|
/*
|
|
|
|
* Path names
|
|
|
|
*/
|
|
|
|
snprintf(port, sizeof(port), "%d", atoi(display));
|
|
|
|
len = strlen(LOCK_PREFIX) > strlen(LOCK_TMP_PREFIX) ? strlen(LOCK_PREFIX) :
|
|
|
|
strlen(LOCK_TMP_PREFIX);
|
|
|
|
len += strlen(tmppath) + strlen(port) + strlen(LOCK_SUFFIX) + 1;
|
|
|
|
if (len > sizeof(LockFile))
|
|
|
|
FatalError("Display name `%s' is too long\n", port);
|
|
|
|
(void) sprintf(tmp, "%s" LOCK_TMP_PREFIX "%s" LOCK_SUFFIX, tmppath, port);
|
|
|
|
(void) sprintf(LockFile, "%s" LOCK_PREFIX "%s" LOCK_SUFFIX, tmppath, port);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create a temporary file containing our PID. Attempt three times
|
|
|
|
* to create the file.
|
|
|
|
*/
|
|
|
|
StillLocking = TRUE;
|
2003-11-14 17:49:22 +01:00
|
|
|
i = 0;
|
|
|
|
do {
|
2012-03-21 20:55:09 +01:00
|
|
|
i++;
|
|
|
|
lfd = open(tmp, O_CREAT | O_EXCL | O_WRONLY, 0644);
|
|
|
|
if (lfd < 0)
|
|
|
|
sleep(2);
|
|
|
|
else
|
|
|
|
break;
|
2003-11-14 17:49:22 +01:00
|
|
|
} while (i < 3);
|
2012-03-21 20:55:09 +01:00
|
|
|
if (lfd < 0) {
|
2003-11-14 17:49:22 +01:00
|
|
|
unlink(tmp);
|
2012-03-21 20:55:09 +01:00
|
|
|
i = 0;
|
|
|
|
do {
|
|
|
|
i++;
|
|
|
|
lfd = open(tmp, O_CREAT | O_EXCL | O_WRONLY, 0644);
|
|
|
|
if (lfd < 0)
|
|
|
|
sleep(2);
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
} while (i < 3);
|
|
|
|
}
|
|
|
|
if (lfd < 0)
|
|
|
|
FatalError("Could not create lock file in %s\n", tmp);
|
|
|
|
snprintf(pid_str, sizeof(pid_str), "%10ld\n", (long) getpid());
|
2014-04-19 00:05:00 +02:00
|
|
|
if (write(lfd, pid_str, 11) != 11)
|
|
|
|
FatalError("Could not write pid to lock file in %s\n", tmp);
|
2012-03-21 20:55:09 +01:00
|
|
|
(void) fchmod(lfd, 0444);
|
|
|
|
(void) close(lfd);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* OK. Now the tmp file exists. Try three times to move it in place
|
|
|
|
* for the lock.
|
|
|
|
*/
|
|
|
|
i = 0;
|
|
|
|
haslock = 0;
|
|
|
|
while ((!haslock) && (i++ < 3)) {
|
|
|
|
haslock = (link(tmp, LockFile) == 0);
|
|
|
|
if (haslock) {
|
|
|
|
/*
|
|
|
|
* We're done.
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/*
|
|
|
|
* Read the pid from the existing file
|
|
|
|
*/
|
|
|
|
lfd = open(LockFile, O_RDONLY | O_NOFOLLOW);
|
|
|
|
if (lfd < 0) {
|
|
|
|
unlink(tmp);
|
|
|
|
FatalError("Can't read lock file %s\n", LockFile);
|
|
|
|
}
|
|
|
|
pid_str[0] = '\0';
|
|
|
|
if (read(lfd, pid_str, 11) != 11) {
|
|
|
|
/*
|
|
|
|
* Bogus lock file.
|
|
|
|
*/
|
|
|
|
unlink(LockFile);
|
|
|
|
close(lfd);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
pid_str[11] = '\0';
|
|
|
|
sscanf(pid_str, "%d", &l_pid);
|
|
|
|
close(lfd);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now try to kill the PID to see if it exists.
|
|
|
|
*/
|
|
|
|
errno = 0;
|
|
|
|
t = kill(l_pid, 0);
|
|
|
|
if ((t < 0) && (errno == ESRCH)) {
|
|
|
|
/*
|
|
|
|
* Stale lock file.
|
|
|
|
*/
|
|
|
|
unlink(LockFile);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (((t < 0) && (errno == EPERM)) || (t == 0)) {
|
|
|
|
/*
|
|
|
|
* Process is still active.
|
|
|
|
*/
|
|
|
|
unlink(tmp);
|
|
|
|
FatalError
|
|
|
|
("Server is already active for display %s\n%s %s\n%s\n",
|
|
|
|
port, "\tIf this server is no longer running, remove",
|
|
|
|
LockFile, "\tand start again.");
|
|
|
|
}
|
|
|
|
}
|
2003-11-14 17:49:22 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
unlink(tmp);
|
|
|
|
if (!haslock)
|
|
|
|
FatalError("Could not create server lock file: %s\n", LockFile);
|
|
|
|
StillLocking = FALSE;
|
2003-11-14 17:49:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* UnlockServer --
|
|
|
|
* Remove the server lock file.
|
|
|
|
*/
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2003-11-25 20:29:01 +01:00
|
|
|
UnlockServer(void)
|
2003-11-14 17:49:22 +01:00
|
|
|
{
|
2014-03-19 22:03:13 +01:00
|
|
|
if (nolock || NoListenAll)
|
2012-03-21 20:55:09 +01:00
|
|
|
return;
|
2003-11-14 17:49:22 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!StillLocking) {
|
2003-11-14 17:49:22 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
(void) unlink(LockFile);
|
|
|
|
}
|
2003-11-14 17:49:22 +01:00
|
|
|
}
|
2011-10-21 19:32:49 +02:00
|
|
|
#endif /* LOCK_SERVER */
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
/* Force connections to close on SIGHUP from init */
|
|
|
|
|
2009-04-06 17:05:17 +02:00
|
|
|
void
|
2012-03-21 20:55:09 +01:00
|
|
|
AutoResetServer(int sig)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2003-11-14 17:49:22 +01:00
|
|
|
int olderrno = errno;
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
dispatchException |= DE_RESET;
|
|
|
|
isItTimeToYield = TRUE;
|
2003-11-14 17:49:22 +01:00
|
|
|
errno = olderrno;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Force connections to close and then exit on SIGTERM, SIGINT */
|
|
|
|
|
2009-04-06 17:05:17 +02:00
|
|
|
void
|
2003-11-25 20:29:01 +01:00
|
|
|
GiveUp(int sig)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2003-11-14 17:49:22 +01:00
|
|
|
int olderrno = errno;
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
dispatchException |= DE_TERMINATE;
|
|
|
|
isItTimeToYield = TRUE;
|
2003-11-14 17:49:22 +01:00
|
|
|
errno = olderrno;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
2016-05-24 12:46:42 +02:00
|
|
|
#ifdef MONOTONIC_CLOCK
|
|
|
|
void
|
|
|
|
ForceClockId(clockid_t forced_clockid)
|
|
|
|
{
|
|
|
|
struct timespec tp;
|
|
|
|
|
|
|
|
BUG_RETURN (clockid);
|
|
|
|
|
|
|
|
clockid = forced_clockid;
|
|
|
|
|
|
|
|
if (clock_gettime(clockid, &tp) != 0) {
|
|
|
|
FatalError("Forced clock id failed to retrieve current time: %s\n",
|
|
|
|
strerror(errno));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-11-02 21:17:02 +01:00
|
|
|
#if (defined WIN32 && defined __MINGW32__) || defined(__CYGWIN__)
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
CARD32
|
2012-03-21 20:55:09 +01:00
|
|
|
GetTimeInMillis(void)
|
2007-05-24 20:02:28 +02:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
return GetTickCount();
|
2007-05-24 20:02:28 +02:00
|
|
|
}
|
2013-07-12 01:10:34 +02:00
|
|
|
CARD64
|
|
|
|
GetTimeInMicros(void)
|
|
|
|
{
|
|
|
|
return (CARD64) GetTickCount() * 1000;
|
|
|
|
}
|
2007-05-24 20:02:28 +02:00
|
|
|
#else
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
CARD32
|
2003-11-25 20:29:01 +01:00
|
|
|
GetTimeInMillis(void)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2006-10-25 22:57:00 +02:00
|
|
|
struct timeval tv;
|
2006-10-26 00:10:08 +02:00
|
|
|
|
2006-10-25 22:57:00 +02:00
|
|
|
#ifdef MONOTONIC_CLOCK
|
|
|
|
struct timespec tp;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2010-08-27 12:36:37 +02:00
|
|
|
if (!clockid) {
|
|
|
|
#ifdef CLOCK_MONOTONIC_COARSE
|
|
|
|
if (clock_getres(CLOCK_MONOTONIC_COARSE, &tp) == 0 &&
|
|
|
|
(tp.tv_nsec / 1000) <= 1000 &&
|
|
|
|
clock_gettime(CLOCK_MONOTONIC_COARSE, &tp) == 0)
|
|
|
|
clockid = CLOCK_MONOTONIC_COARSE;
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
|
|
|
|
clockid = CLOCK_MONOTONIC;
|
|
|
|
else
|
|
|
|
clockid = ~0L;
|
|
|
|
}
|
|
|
|
if (clockid != ~0L && clock_gettime(clockid, &tp) == 0)
|
2006-10-29 02:41:34 +02:00
|
|
|
return (tp.tv_sec * 1000) + (tp.tv_nsec / 1000000L);
|
2006-10-25 22:57:00 +02:00
|
|
|
#endif
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2006-10-25 22:57:00 +02:00
|
|
|
X_GETTIMEOFDAY(&tv);
|
2012-03-21 20:55:09 +01:00
|
|
|
return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2013-07-12 01:10:34 +02:00
|
|
|
|
|
|
|
CARD64
|
|
|
|
GetTimeInMicros(void)
|
|
|
|
{
|
|
|
|
struct timeval tv;
|
|
|
|
#ifdef MONOTONIC_CLOCK
|
|
|
|
struct timespec tp;
|
|
|
|
|
|
|
|
if (!clockid) {
|
|
|
|
if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0)
|
|
|
|
clockid = CLOCK_MONOTONIC;
|
|
|
|
else
|
|
|
|
clockid = ~0L;
|
|
|
|
}
|
2013-11-05 16:08:21 +01:00
|
|
|
if (clockid != ~0L && clock_gettime(clockid, &tp) == 0)
|
2013-07-12 01:10:34 +02:00
|
|
|
return (CARD64) tp.tv_sec * (CARD64)1000000 + tp.tv_nsec / 1000;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
X_GETTIMEOFDAY(&tv);
|
|
|
|
return (CARD64) tv.tv_sec * (CARD64)1000000000 + (CARD64) tv.tv_usec * 1000;
|
|
|
|
}
|
2007-05-24 20:02:28 +02:00
|
|
|
#endif
|
2003-11-14 16:54:54 +01:00
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2013-12-15 10:05:51 +01:00
|
|
|
AdjustWaitForDelay(void *waitTime, unsigned long newdelay)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
static struct timeval delay_val;
|
|
|
|
struct timeval **wt = (struct timeval **) waitTime;
|
|
|
|
unsigned long olddelay;
|
|
|
|
|
|
|
|
if (*wt == NULL) {
|
|
|
|
delay_val.tv_sec = newdelay / 1000;
|
|
|
|
delay_val.tv_usec = 1000 * (newdelay % 1000);
|
|
|
|
*wt = &delay_val;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
else {
|
|
|
|
olddelay = (*wt)->tv_sec * 1000 + (*wt)->tv_usec / 1000;
|
|
|
|
if (newdelay < olddelay) {
|
|
|
|
(*wt)->tv_sec = newdelay / 1000;
|
|
|
|
(*wt)->tv_usec = 1000 * (newdelay % 1000);
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
void
|
|
|
|
UseMsg(void)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
ErrorF("use: X [:<display>] [option]\n");
|
2010-01-06 18:13:27 +01:00
|
|
|
ErrorF("-a # default pointer acceleration (factor)\n");
|
2003-11-14 16:54:54 +01:00
|
|
|
ErrorF("-ac disable access control restrictions\n");
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF("-audit int set audit trail level\n");
|
|
|
|
ErrorF("-auth file select authorization file\n");
|
2003-11-14 17:49:22 +01:00
|
|
|
ErrorF("-br create root window with black background\n");
|
|
|
|
ErrorF("+bs enable any backing store support\n");
|
2003-11-14 16:54:54 +01:00
|
|
|
ErrorF("-bs disable any backing store support\n");
|
|
|
|
ErrorF("-c turns off key-click\n");
|
|
|
|
ErrorF("c # key-click volume (0-100)\n");
|
|
|
|
ErrorF("-cc int default color visual class\n");
|
2009-04-23 17:15:01 +02:00
|
|
|
ErrorF("-nocursor disable the cursor\n");
|
2003-11-14 16:54:54 +01:00
|
|
|
ErrorF("-core generate core dump on fatal error\n");
|
2014-04-22 22:19:35 +02:00
|
|
|
ErrorF("-displayfd fd file descriptor to write display number to when ready to connect\n");
|
2003-11-14 16:54:54 +01:00
|
|
|
ErrorF("-dpi int screen resolution in dots per inch\n");
|
|
|
|
#ifdef DPMSExtension
|
|
|
|
ErrorF("-dpms disables VESA DPMS monitor control\n");
|
|
|
|
#endif
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF
|
|
|
|
("-deferglyphs [none|all|16] defer loading of [no|all|16-bit] glyphs\n");
|
2003-11-14 16:54:54 +01:00
|
|
|
ErrorF("-f # bell base (0-100)\n");
|
|
|
|
ErrorF("-fc string cursor font\n");
|
|
|
|
ErrorF("-fn string default font name\n");
|
|
|
|
ErrorF("-fp string default font path\n");
|
|
|
|
ErrorF("-help prints message with these options\n");
|
2014-09-18 00:38:39 +02:00
|
|
|
ErrorF("+iglx Allow creating indirect GLX contexts\n");
|
|
|
|
ErrorF("-iglx Prohibit creating indirect GLX contexts (default)\n");
|
2003-11-14 16:54:54 +01:00
|
|
|
ErrorF("-I ignore all remaining arguments\n");
|
|
|
|
#ifdef RLIMIT_DATA
|
|
|
|
ErrorF("-ld int limit data space to N Kb\n");
|
|
|
|
#endif
|
|
|
|
#ifdef RLIMIT_NOFILE
|
|
|
|
ErrorF("-lf int limit number of open files to N\n");
|
|
|
|
#endif
|
|
|
|
#ifdef RLIMIT_STACK
|
|
|
|
ErrorF("-ls int limit stack space to N Kb\n");
|
|
|
|
#endif
|
2011-10-21 19:32:49 +02:00
|
|
|
#ifdef LOCK_SERVER
|
2003-11-14 17:49:22 +01:00
|
|
|
ErrorF("-nolock disable the locking mechanism\n");
|
2011-10-21 19:32:49 +02:00
|
|
|
#endif
|
2015-07-07 18:19:50 +02:00
|
|
|
ErrorF("-maxclients n set maximum number of clients (power of two)\n");
|
2003-11-14 17:49:22 +01:00
|
|
|
ErrorF("-nolisten string don't listen on protocol\n");
|
2014-09-12 20:33:48 +02:00
|
|
|
ErrorF("-listen string listen on protocol\n");
|
2004-06-19 23:56:01 +02:00
|
|
|
ErrorF("-noreset don't reset after last client exists\n");
|
dix: adds support for none root window background
It lets the driver notify the server whether it can draw a background when
'-background none' option is used by the system platform. Use cases for that
could be video drivers performing mode-setting in kernel time, before X is up,
so a seamless transition would happen until X clients start to show up.
If the driver can copy the framebuffer cleanly then it can set the flag
(canDoBGNoneRoot), otherwise the server will fallback to the normal behaviour.
The system must explicit indicates willingness of doing so through
'-background none'. We could do this option as default; in such case,
malicious users would be able to steal the framebuffer with a bit of tricks.
For instance, I can see the content of my nVidia Quadro FX 580 framebuffer
old X session modifying a bit nv driver:
xf86DPMSInit(pScreen, xf86DPMSSet, 0);
- /* Clear the screen */
- if(pNv->xaa) {
- /* Use the acceleration engine */
- pNv->xaa->SetupForSolidFill(pScrn, 0, GXcopy, ~0);
- pNv->xaa->SubsequentSolidFillRect(pScrn,
- 0, 0, pScrn->displayWidth, pNv->offscreenHeight);
- G80DmaKickoff(pNv);
- } else {
- /* Use a slow software clear path */
- memset(pNv->mem, 0, pitch * pNv->offscreenHeight);
- }
+ pScreen->canDoBGNoneRoot = TRUE;
The commit is originally based on discussions happened on xorg-devel:
http://lists.freedesktop.org/archives/xorg-devel/2010-June/009755.html
Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Reviewed-by: Rami Ylimäki <rami.ylimaki@vincit.fi>
Acked-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2010-11-10 20:48:03 +01:00
|
|
|
ErrorF("-background [none] create root window with no background\n");
|
2004-06-19 23:56:01 +02:00
|
|
|
ErrorF("-reset reset after last client exists\n");
|
2003-11-14 16:54:54 +01:00
|
|
|
ErrorF("-p # screen-saver pattern duration (minutes)\n");
|
|
|
|
ErrorF("-pn accept failure to listen on all ports\n");
|
2003-11-14 17:49:22 +01:00
|
|
|
ErrorF("-nopn reject failure to listen on all ports\n");
|
2003-11-14 16:54:54 +01:00
|
|
|
ErrorF("-r turns off auto-repeat\n");
|
|
|
|
ErrorF("r turns on auto-repeat \n");
|
2003-11-14 17:49:22 +01:00
|
|
|
ErrorF("-render [default|mono|gray|color] set render color alloc policy\n");
|
2008-09-22 16:51:51 +02:00
|
|
|
ErrorF("-retro start with classic stipple and cursor\n");
|
2003-11-14 16:54:54 +01:00
|
|
|
ErrorF("-s # screen-saver timeout (minutes)\n");
|
2011-07-18 21:19:23 +02:00
|
|
|
ErrorF("-seat string seat to run on\n");
|
2010-01-06 18:13:27 +01:00
|
|
|
ErrorF("-t # default pointer threshold (pixels/t)\n");
|
2003-11-14 16:54:54 +01:00
|
|
|
ErrorF("-terminate terminate at server reset\n");
|
|
|
|
ErrorF("-to # connection time out\n");
|
|
|
|
ErrorF("-tst disable testing extensions\n");
|
|
|
|
ErrorF("ttyxx server started from init on /dev/ttyxx\n");
|
|
|
|
ErrorF("v video blanking for screen-saver\n");
|
|
|
|
ErrorF("-v screen-saver without video blanking\n");
|
|
|
|
ErrorF("-wm WhenMapped default backing-store\n");
|
2006-08-18 16:04:48 +02:00
|
|
|
ErrorF("-wr create root window with white background\n");
|
2004-09-24 04:11:14 +02:00
|
|
|
ErrorF("-maxbigreqsize set maximal bigrequest size \n");
|
2003-11-14 16:54:54 +01:00
|
|
|
#ifdef PANORAMIX
|
|
|
|
ErrorF("+xinerama Enable XINERAMA extension\n");
|
|
|
|
ErrorF("-xinerama Disable XINERAMA extension\n");
|
|
|
|
#endif
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF
|
2015-12-08 20:37:51 +01:00
|
|
|
("-dumbSched Disable smart scheduling and threaded input, enable old behavior\n");
|
2003-11-25 20:29:01 +01:00
|
|
|
ErrorF("-schedInterval int Set scheduler interval in msec\n");
|
2010-08-30 20:24:30 +02:00
|
|
|
ErrorF("-sigstop Enable SIGSTOP based startup\n");
|
2004-07-31 06:23:21 +02:00
|
|
|
ErrorF("+extension name Enable extension\n");
|
|
|
|
ErrorF("-extension name Disable extension\n");
|
2003-11-14 16:54:54 +01:00
|
|
|
#ifdef XDMCP
|
|
|
|
XdmcpUseMsg();
|
|
|
|
#endif
|
|
|
|
XkbUseMsg();
|
|
|
|
ddxUseMsg();
|
|
|
|
}
|
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
/* This function performs a rudimentary sanity check
|
|
|
|
* on the display name passed in on the command-line,
|
|
|
|
* since this string is used to generate filenames.
|
|
|
|
* It is especially important that the display name
|
|
|
|
* not contain a "/" and not start with a "-".
|
|
|
|
* --kvajk
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
static int
|
2003-11-25 20:29:01 +01:00
|
|
|
VerifyDisplayName(const char *d)
|
2003-11-14 17:49:22 +01:00
|
|
|
{
|
2014-01-13 08:00:23 +01:00
|
|
|
int i;
|
|
|
|
int period_found = FALSE;
|
|
|
|
int after_period = 0;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (d == (char *) 0)
|
|
|
|
return 0; /* null */
|
|
|
|
if (*d == '\0')
|
|
|
|
return 0; /* empty */
|
|
|
|
if (*d == '-')
|
|
|
|
return 0; /* could be confused for an option */
|
|
|
|
if (*d == '.')
|
|
|
|
return 0; /* must not equal "." or ".." */
|
|
|
|
if (strchr(d, '/') != (char *) 0)
|
|
|
|
return 0; /* very important!!! */
|
2014-01-13 08:00:23 +01:00
|
|
|
|
|
|
|
/* Since we run atoi() on the display later, only allow
|
|
|
|
for digits, or exception of :0.0 and similar (two decimal points max)
|
|
|
|
*/
|
|
|
|
for (i = 0; i < strlen(d); i++) {
|
|
|
|
if (!isdigit(d[i])) {
|
|
|
|
if (d[i] != '.' || period_found)
|
|
|
|
return 0;
|
|
|
|
period_found = TRUE;
|
|
|
|
} else if (period_found)
|
|
|
|
after_period++;
|
|
|
|
|
|
|
|
if (after_period > 2)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* don't allow for :0. */
|
|
|
|
if (period_found && after_period == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (atol(d) > INT_MAX)
|
|
|
|
return 0;
|
|
|
|
|
2010-06-06 16:18:40 +02:00
|
|
|
return 1;
|
2003-11-14 17:49:22 +01:00
|
|
|
}
|
|
|
|
|
2014-09-12 20:33:48 +02:00
|
|
|
static const char *defaultNoListenList[] = {
|
|
|
|
#ifndef LISTEN_TCP
|
|
|
|
"tcp",
|
|
|
|
#endif
|
|
|
|
#ifndef LISTEN_UNIX
|
|
|
|
"unix",
|
|
|
|
#endif
|
|
|
|
#ifndef LISTEN_LOCAL
|
|
|
|
"local",
|
|
|
|
#endif
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
/*
|
|
|
|
* This function parses the command line. Handles device-independent fields
|
|
|
|
* and allows ddx to handle additional fields. It is not allowed to modify
|
|
|
|
* argc or any of the strings pointed to by argv.
|
|
|
|
*/
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2003-11-25 20:29:01 +01:00
|
|
|
ProcessCommandLine(int argc, char *argv[])
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
int i, skip;
|
|
|
|
|
|
|
|
defaultKeyboardControl.autoRepeat = TRUE;
|
|
|
|
|
2004-01-29 09:08:57 +01:00
|
|
|
#ifdef NO_PART_NET
|
|
|
|
PartialNetwork = FALSE;
|
|
|
|
#else
|
|
|
|
PartialNetwork = TRUE;
|
2003-11-14 17:49:22 +01:00
|
|
|
#endif
|
|
|
|
|
2014-09-12 20:33:48 +02:00
|
|
|
for (i = 0; defaultNoListenList[i] != NULL; i++) {
|
|
|
|
if (_XSERVTransNoListen(defaultNoListenList[i]))
|
|
|
|
ErrorF("Failed to disable listen for %s transport",
|
|
|
|
defaultNoListenList[i]);
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
for (i = 1; i < argc; i++) {
|
|
|
|
/* call ddx first, so it can peek/override if it wants */
|
|
|
|
if ((skip = ddxProcessArgument(argc, argv, i))) {
|
|
|
|
i += (skip - 1);
|
|
|
|
}
|
|
|
|
else if (argv[i][0] == ':') {
|
|
|
|
/* initialize display */
|
|
|
|
display = argv[i];
|
2013-03-11 15:34:32 +01:00
|
|
|
explicit_display = TRUE;
|
2012-03-21 20:55:09 +01:00
|
|
|
display++;
|
|
|
|
if (!VerifyDisplayName(display)) {
|
2003-11-14 17:49:22 +01:00
|
|
|
ErrorF("Bad display name: %s\n", display);
|
|
|
|
UseMsg();
|
2012-03-21 20:55:09 +01:00
|
|
|
FatalError("Bad display name, exiting: %s\n", display);
|
2003-11-14 17:49:22 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], "-a") == 0) {
|
|
|
|
if (++i < argc)
|
|
|
|
defaultPointerControl.num = atoi(argv[i]);
|
|
|
|
else
|
|
|
|
UseMsg();
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], "-ac") == 0) {
|
|
|
|
defeatAccessControl = TRUE;
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], "-audit") == 0) {
|
|
|
|
if (++i < argc)
|
|
|
|
auditTrailLevel = atoi(argv[i]);
|
|
|
|
else
|
|
|
|
UseMsg();
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], "-auth") == 0) {
|
|
|
|
if (++i < argc)
|
|
|
|
InitAuthorization(argv[i]);
|
|
|
|
else
|
|
|
|
UseMsg();
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], "-br") == 0); /* default */
|
|
|
|
else if (strcmp(argv[i], "+bs") == 0)
|
|
|
|
enableBackingStore = TRUE;
|
|
|
|
else if (strcmp(argv[i], "-bs") == 0)
|
|
|
|
disableBackingStore = TRUE;
|
|
|
|
else if (strcmp(argv[i], "c") == 0) {
|
|
|
|
if (++i < argc)
|
|
|
|
defaultKeyboardControl.click = atoi(argv[i]);
|
|
|
|
else
|
|
|
|
UseMsg();
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], "-c") == 0) {
|
|
|
|
defaultKeyboardControl.click = 0;
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], "-cc") == 0) {
|
|
|
|
if (++i < argc)
|
|
|
|
defaultColorVisualClass = atoi(argv[i]);
|
|
|
|
else
|
|
|
|
UseMsg();
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], "-core") == 0) {
|
2007-05-24 20:02:28 +02:00
|
|
|
#if !defined(WIN32) || !defined(__MINGW32__)
|
2012-03-21 20:55:09 +01:00
|
|
|
struct rlimit core_limit;
|
|
|
|
|
|
|
|
getrlimit(RLIMIT_CORE, &core_limit);
|
|
|
|
core_limit.rlim_cur = core_limit.rlim_max;
|
|
|
|
setrlimit(RLIMIT_CORE, &core_limit);
|
|
|
|
#endif
|
|
|
|
CoreDump = TRUE;
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], "-nocursor") == 0) {
|
2009-04-23 17:15:01 +02:00
|
|
|
EnableCursor = FALSE;
|
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
else if (strcmp(argv[i], "-dpi") == 0) {
|
|
|
|
if (++i < argc)
|
|
|
|
monitorResolution = atoi(argv[i]);
|
|
|
|
else
|
|
|
|
UseMsg();
|
|
|
|
}
|
2012-04-05 00:29:42 +02:00
|
|
|
else if (strcmp(argv[i], "-displayfd") == 0) {
|
|
|
|
if (++i < argc) {
|
|
|
|
displayfd = atoi(argv[i]);
|
2011-10-21 19:32:49 +02:00
|
|
|
#ifdef LOCK_SERVER
|
2012-04-05 00:29:42 +02:00
|
|
|
nolock = TRUE;
|
2011-10-21 19:32:49 +02:00
|
|
|
#endif
|
2012-04-05 00:29:42 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
UseMsg();
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
#ifdef DPMSExtension
|
2012-03-21 20:55:09 +01:00
|
|
|
else if (strcmp(argv[i], "dpms") == 0)
|
|
|
|
/* ignored for compatibility */ ;
|
|
|
|
else if (strcmp(argv[i], "-dpms") == 0)
|
|
|
|
DPMSDisabledSwitch = TRUE;
|
|
|
|
#endif
|
|
|
|
else if (strcmp(argv[i], "-deferglyphs") == 0) {
|
2015-09-02 03:50:55 +02:00
|
|
|
if (++i >= argc || !xfont2_parse_glyph_caching_mode(argv[i]))
|
2012-03-21 20:55:09 +01:00
|
|
|
UseMsg();
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], "-f") == 0) {
|
|
|
|
if (++i < argc)
|
|
|
|
defaultKeyboardControl.bell = atoi(argv[i]);
|
|
|
|
else
|
|
|
|
UseMsg();
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], "-fc") == 0) {
|
|
|
|
if (++i < argc)
|
|
|
|
defaultCursorFont = argv[i];
|
|
|
|
else
|
|
|
|
UseMsg();
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], "-fn") == 0) {
|
|
|
|
if (++i < argc)
|
|
|
|
defaultTextFont = argv[i];
|
|
|
|
else
|
|
|
|
UseMsg();
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], "-fp") == 0) {
|
|
|
|
if (++i < argc) {
|
|
|
|
defaultFontPath = argv[i];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
UseMsg();
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], "-help") == 0) {
|
|
|
|
UseMsg();
|
|
|
|
exit(0);
|
|
|
|
}
|
2014-04-23 18:52:17 +02:00
|
|
|
else if (strcmp(argv[i], "+iglx") == 0)
|
|
|
|
enableIndirectGLX = TRUE;
|
|
|
|
else if (strcmp(argv[i], "-iglx") == 0)
|
|
|
|
enableIndirectGLX = FALSE;
|
2012-03-21 20:55:09 +01:00
|
|
|
else if ((skip = XkbProcessArguments(argc, argv, i)) != 0) {
|
|
|
|
if (skip > 0)
|
|
|
|
i += skip - 1;
|
|
|
|
else
|
|
|
|
UseMsg();
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
#ifdef RLIMIT_DATA
|
2012-03-21 20:55:09 +01:00
|
|
|
else if (strcmp(argv[i], "-ld") == 0) {
|
|
|
|
if (++i < argc) {
|
|
|
|
limitDataSpace = atoi(argv[i]);
|
|
|
|
if (limitDataSpace > 0)
|
|
|
|
limitDataSpace *= 1024;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
UseMsg();
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
#endif
|
|
|
|
#ifdef RLIMIT_NOFILE
|
2012-03-21 20:55:09 +01:00
|
|
|
else if (strcmp(argv[i], "-lf") == 0) {
|
|
|
|
if (++i < argc)
|
|
|
|
limitNoFile = atoi(argv[i]);
|
|
|
|
else
|
|
|
|
UseMsg();
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
#endif
|
|
|
|
#ifdef RLIMIT_STACK
|
2012-03-21 20:55:09 +01:00
|
|
|
else if (strcmp(argv[i], "-ls") == 0) {
|
|
|
|
if (++i < argc) {
|
|
|
|
limitStackSpace = atoi(argv[i]);
|
|
|
|
if (limitStackSpace > 0)
|
|
|
|
limitStackSpace *= 1024;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
UseMsg();
|
|
|
|
}
|
|
|
|
#endif
|
2011-10-21 19:32:49 +02:00
|
|
|
#ifdef LOCK_SERVER
|
2012-03-21 20:55:09 +01:00
|
|
|
else if (strcmp(argv[i], "-nolock") == 0) {
|
2007-06-29 00:59:05 +02:00
|
|
|
#if !defined(WIN32) && !defined(__CYGWIN__)
|
2012-03-21 20:55:09 +01:00
|
|
|
if (getuid() != 0)
|
|
|
|
ErrorF
|
|
|
|
("Warning: the -nolock option can only be used by root\n");
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
nolock = TRUE;
|
|
|
|
}
|
2011-10-21 19:32:49 +02:00
|
|
|
#endif
|
2015-07-07 18:19:50 +02:00
|
|
|
else if ( strcmp( argv[i], "-maxclients") == 0)
|
|
|
|
{
|
|
|
|
if (++i < argc) {
|
|
|
|
LimitClients = atoi(argv[i]);
|
|
|
|
if (LimitClients != 64 &&
|
|
|
|
LimitClients != 128 &&
|
|
|
|
LimitClients != 256 &&
|
|
|
|
LimitClients != 512) {
|
|
|
|
FatalError("maxclients must be one of 64, 128, 256 or 512\n");
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
UseMsg();
|
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
else if (strcmp(argv[i], "-nolisten") == 0) {
|
|
|
|
if (++i < argc) {
|
|
|
|
if (_XSERVTransNoListen(argv[i]))
|
2012-07-10 03:02:46 +02:00
|
|
|
ErrorF("Failed to disable listen for %s transport",
|
|
|
|
argv[i]);
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
UseMsg();
|
|
|
|
}
|
2014-09-12 20:33:48 +02:00
|
|
|
else if (strcmp(argv[i], "-listen") == 0) {
|
|
|
|
if (++i < argc) {
|
|
|
|
if (_XSERVTransListen(argv[i]))
|
|
|
|
ErrorF("Failed to enable listen for %s transport",
|
|
|
|
argv[i]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
UseMsg();
|
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
else if (strcmp(argv[i], "-noreset") == 0) {
|
|
|
|
dispatchExceptionAtReset = 0;
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], "-reset") == 0) {
|
|
|
|
dispatchExceptionAtReset = DE_RESET;
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], "-p") == 0) {
|
|
|
|
if (++i < argc)
|
|
|
|
defaultScreenSaverInterval = ((CARD32) atoi(argv[i])) *
|
|
|
|
MILLI_PER_MIN;
|
|
|
|
else
|
|
|
|
UseMsg();
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], "-pogo") == 0) {
|
|
|
|
dispatchException = DE_TERMINATE;
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], "-pn") == 0)
|
|
|
|
PartialNetwork = TRUE;
|
|
|
|
else if (strcmp(argv[i], "-nopn") == 0)
|
|
|
|
PartialNetwork = FALSE;
|
|
|
|
else if (strcmp(argv[i], "r") == 0)
|
|
|
|
defaultKeyboardControl.autoRepeat = TRUE;
|
|
|
|
else if (strcmp(argv[i], "-r") == 0)
|
|
|
|
defaultKeyboardControl.autoRepeat = FALSE;
|
|
|
|
else if (strcmp(argv[i], "-retro") == 0)
|
|
|
|
party_like_its_1989 = TRUE;
|
|
|
|
else if (strcmp(argv[i], "-s") == 0) {
|
|
|
|
if (++i < argc)
|
|
|
|
defaultScreenSaverTime = ((CARD32) atoi(argv[i])) *
|
|
|
|
MILLI_PER_MIN;
|
|
|
|
else
|
|
|
|
UseMsg();
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], "-seat") == 0) {
|
|
|
|
if (++i < argc)
|
|
|
|
SeatId = argv[i];
|
|
|
|
else
|
|
|
|
UseMsg();
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], "-t") == 0) {
|
|
|
|
if (++i < argc)
|
|
|
|
defaultPointerControl.threshold = atoi(argv[i]);
|
|
|
|
else
|
|
|
|
UseMsg();
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], "-terminate") == 0) {
|
|
|
|
dispatchExceptionAtReset = DE_TERMINATE;
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], "-to") == 0) {
|
|
|
|
if (++i < argc)
|
|
|
|
TimeOutValue = ((CARD32) atoi(argv[i])) * MILLI_PER_SECOND;
|
|
|
|
else
|
|
|
|
UseMsg();
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], "-tst") == 0) {
|
|
|
|
noTestExtensions = TRUE;
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], "v") == 0)
|
|
|
|
defaultScreenSaverBlanking = PreferBlanking;
|
|
|
|
else if (strcmp(argv[i], "-v") == 0)
|
|
|
|
defaultScreenSaverBlanking = DontPreferBlanking;
|
|
|
|
else if (strcmp(argv[i], "-wm") == 0)
|
|
|
|
defaultBackingStore = WhenMapped;
|
|
|
|
else if (strcmp(argv[i], "-wr") == 0)
|
2006-08-18 16:04:48 +02:00
|
|
|
whiteRoot = TRUE;
|
2012-03-21 20:55:09 +01:00
|
|
|
else if (strcmp(argv[i], "-background") == 0) {
|
|
|
|
if (++i < argc) {
|
|
|
|
if (!strcmp(argv[i], "none"))
|
dix: adds support for none root window background
It lets the driver notify the server whether it can draw a background when
'-background none' option is used by the system platform. Use cases for that
could be video drivers performing mode-setting in kernel time, before X is up,
so a seamless transition would happen until X clients start to show up.
If the driver can copy the framebuffer cleanly then it can set the flag
(canDoBGNoneRoot), otherwise the server will fallback to the normal behaviour.
The system must explicit indicates willingness of doing so through
'-background none'. We could do this option as default; in such case,
malicious users would be able to steal the framebuffer with a bit of tricks.
For instance, I can see the content of my nVidia Quadro FX 580 framebuffer
old X session modifying a bit nv driver:
xf86DPMSInit(pScreen, xf86DPMSSet, 0);
- /* Clear the screen */
- if(pNv->xaa) {
- /* Use the acceleration engine */
- pNv->xaa->SetupForSolidFill(pScrn, 0, GXcopy, ~0);
- pNv->xaa->SubsequentSolidFillRect(pScrn,
- 0, 0, pScrn->displayWidth, pNv->offscreenHeight);
- G80DmaKickoff(pNv);
- } else {
- /* Use a slow software clear path */
- memset(pNv->mem, 0, pitch * pNv->offscreenHeight);
- }
+ pScreen->canDoBGNoneRoot = TRUE;
The commit is originally based on discussions happened on xorg-devel:
http://lists.freedesktop.org/archives/xorg-devel/2010-June/009755.html
Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>
Reviewed-by: Rami Ylimäki <rami.ylimaki@vincit.fi>
Acked-by: Pauli Nieminen <ext-pauli.nieminen@nokia.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2010-11-10 20:48:03 +01:00
|
|
|
bgNoneRoot = TRUE;
|
|
|
|
else
|
|
|
|
UseMsg();
|
|
|
|
}
|
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
else if (strcmp(argv[i], "-maxbigreqsize") == 0) {
|
|
|
|
if (++i < argc) {
|
|
|
|
long reqSizeArg = atol(argv[i]);
|
|
|
|
|
|
|
|
/* Request size > 128MB does not make much sense... */
|
|
|
|
if (reqSizeArg > 0L && reqSizeArg < 128L) {
|
|
|
|
maxBigRequestSize = (reqSizeArg * 1048576L) - 1L;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
UseMsg();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
UseMsg();
|
|
|
|
}
|
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
#ifdef PANORAMIX
|
2012-03-21 20:55:09 +01:00
|
|
|
else if (strcmp(argv[i], "+xinerama") == 0) {
|
|
|
|
noPanoramiXExtension = FALSE;
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], "-xinerama") == 0) {
|
|
|
|
noPanoramiXExtension = TRUE;
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], "-disablexineramaextension") == 0) {
|
|
|
|
PanoramiXExtensionDisabledHack = TRUE;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
else if (strcmp(argv[i], "-I") == 0) {
|
|
|
|
/* ignore all remaining arguments */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (strncmp(argv[i], "tty", 3) == 0) {
|
2010-06-11 20:05:07 +02:00
|
|
|
/* init supplies us with this useless information */
|
2012-03-21 20:55:09 +01:00
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
#ifdef XDMCP
|
2012-03-21 20:55:09 +01:00
|
|
|
else if ((skip = XdmcpOptions(argc, argv, i)) != i) {
|
|
|
|
i = skip - 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
else if (strcmp(argv[i], "-dumbSched") == 0) {
|
2015-12-08 20:37:51 +01:00
|
|
|
InputThreadEnable = FALSE;
|
|
|
|
#if HAVE_SETITIMER
|
2015-11-12 07:02:01 +01:00
|
|
|
SmartScheduleSignalEnable = FALSE;
|
|
|
|
#endif
|
2015-12-08 20:37:51 +01:00
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
else if (strcmp(argv[i], "-schedInterval") == 0) {
|
|
|
|
if (++i < argc) {
|
|
|
|
SmartScheduleInterval = atoi(argv[i]);
|
|
|
|
SmartScheduleSlice = SmartScheduleInterval;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
UseMsg();
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], "-schedMax") == 0) {
|
|
|
|
if (++i < argc) {
|
|
|
|
SmartScheduleMaxSlice = atoi(argv[i]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
UseMsg();
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], "-render") == 0) {
|
|
|
|
if (++i < argc) {
|
|
|
|
int policy = PictureParseCmapPolicy(argv[i]);
|
|
|
|
|
|
|
|
if (policy != PictureCmapPolicyInvalid)
|
|
|
|
PictureCmapPolicy = policy;
|
|
|
|
else
|
|
|
|
UseMsg();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
UseMsg();
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], "-sigstop") == 0) {
|
|
|
|
RunFromSigStopParent = TRUE;
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], "+extension") == 0) {
|
|
|
|
if (++i < argc) {
|
|
|
|
if (!EnableDisableExtension(argv[i], TRUE))
|
|
|
|
EnableDisableExtensionError(argv[i], TRUE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
UseMsg();
|
|
|
|
}
|
|
|
|
else if (strcmp(argv[i], "-extension") == 0) {
|
|
|
|
if (++i < argc) {
|
|
|
|
if (!EnableDisableExtension(argv[i], FALSE))
|
|
|
|
EnableDisableExtensionError(argv[i], FALSE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
UseMsg();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ErrorF("Unrecognized option: %s\n", argv[i]);
|
|
|
|
UseMsg();
|
|
|
|
FatalError("Unrecognized option: %s\n", argv[i]);
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Implement a simple-minded font authorization scheme. The authorization
|
|
|
|
name is "hp-hostname-1", the contents are simply the host name. */
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
int
|
2013-12-15 10:05:51 +01:00
|
|
|
set_font_authorizations(char **authorizations, int *authlen, void *client)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
|
|
|
#define AUTHORIZATION_NAME "hp-hostname-1"
|
2016-02-08 23:36:03 +01:00
|
|
|
#if defined(TCPCONN)
|
2003-11-25 20:29:01 +01:00
|
|
|
static char *result = NULL;
|
2003-11-14 16:54:54 +01:00
|
|
|
static char *p = NULL;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (p == NULL) {
|
|
|
|
char hname[1024], *hnameptr;
|
|
|
|
unsigned int len;
|
|
|
|
|
2003-11-25 20:29:01 +01:00
|
|
|
#if defined(IPv6) && defined(AF_INET6)
|
2012-03-21 20:55:09 +01:00
|
|
|
struct addrinfo hints, *ai = NULL;
|
2003-11-25 20:29:01 +01:00
|
|
|
#else
|
2012-03-21 20:55:09 +01:00
|
|
|
struct hostent *host;
|
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
#ifdef XTHREADS_NEEDS_BYNAMEPARAMS
|
2012-03-21 20:55:09 +01:00
|
|
|
_Xgethostbynameparams hparams;
|
2003-11-25 20:29:01 +01:00
|
|
|
#endif
|
2003-11-14 17:49:22 +01:00
|
|
|
#endif
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
gethostname(hname, 1024);
|
2003-11-25 20:29:01 +01:00
|
|
|
#if defined(IPv6) && defined(AF_INET6)
|
2012-03-21 20:55:09 +01:00
|
|
|
memset(&hints, 0, sizeof(hints));
|
|
|
|
hints.ai_flags = AI_CANONNAME;
|
|
|
|
if (getaddrinfo(hname, NULL, &hints, &ai) == 0) {
|
|
|
|
hnameptr = ai->ai_canonname;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
hnameptr = hname;
|
|
|
|
}
|
2003-11-25 20:29:01 +01:00
|
|
|
#else
|
2012-03-21 20:55:09 +01:00
|
|
|
host = _XGethostbyname(hname, hparams);
|
|
|
|
if (host == NULL)
|
|
|
|
hnameptr = hname;
|
|
|
|
else
|
|
|
|
hnameptr = host->h_name;
|
2003-11-25 20:29:01 +01:00
|
|
|
#endif
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
len = strlen(hnameptr) + 1;
|
|
|
|
result = malloc(len + sizeof(AUTHORIZATION_NAME) + 4);
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
p = result;
|
2003-11-14 16:54:54 +01:00
|
|
|
*p++ = sizeof(AUTHORIZATION_NAME) >> 8;
|
|
|
|
*p++ = sizeof(AUTHORIZATION_NAME) & 0xff;
|
2003-11-25 20:29:01 +01:00
|
|
|
*p++ = (len) >> 8;
|
2003-11-14 16:54:54 +01:00
|
|
|
*p++ = (len & 0xff);
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
memmove(p, AUTHORIZATION_NAME, sizeof(AUTHORIZATION_NAME));
|
|
|
|
p += sizeof(AUTHORIZATION_NAME);
|
|
|
|
memmove(p, hnameptr, len);
|
|
|
|
p += len;
|
2003-11-25 20:29:01 +01:00
|
|
|
#if defined(IPv6) && defined(AF_INET6)
|
2012-03-21 20:55:09 +01:00
|
|
|
if (ai) {
|
|
|
|
freeaddrinfo(ai);
|
|
|
|
}
|
2003-11-25 20:29:01 +01:00
|
|
|
#endif
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
*authlen = p - result;
|
|
|
|
*authorizations = result;
|
|
|
|
return 1;
|
2012-03-21 20:55:09 +01:00
|
|
|
#else /* TCPCONN */
|
2003-11-14 16:54:54 +01:00
|
|
|
return 0;
|
2012-03-21 20:55:09 +01:00
|
|
|
#endif /* TCPCONN */
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void *
|
2003-11-25 20:29:01 +01:00
|
|
|
XNFalloc(unsigned long amount)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2010-05-05 19:16:24 +02:00
|
|
|
void *ptr = malloc(amount);
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
if (!ptr)
|
|
|
|
FatalError("Out of memory");
|
2008-10-03 22:05:19 +02:00
|
|
|
return ptr;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
2015-03-21 23:21:14 +01:00
|
|
|
/* The original XNFcalloc was used with the xnfcalloc macro which multiplied
|
|
|
|
* the arguments at the call site without allowing calloc to check for overflow.
|
|
|
|
* XNFcallocarray was added to fix that without breaking ABI.
|
|
|
|
*/
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void *
|
2003-11-25 20:29:01 +01:00
|
|
|
XNFcalloc(unsigned long amount)
|
2003-11-14 17:49:22 +01:00
|
|
|
{
|
2015-03-21 23:21:14 +01:00
|
|
|
return XNFcallocarray(1, amount);
|
|
|
|
}
|
|
|
|
|
|
|
|
void *
|
|
|
|
XNFcallocarray(size_t nmemb, size_t size)
|
|
|
|
{
|
|
|
|
void *ret = calloc(nmemb, size);
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2010-05-05 19:16:24 +02:00
|
|
|
if (!ret)
|
|
|
|
FatalError("XNFcalloc: Out of memory");
|
2003-11-14 17:49:22 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void *
|
2010-05-05 19:16:24 +02:00
|
|
|
XNFrealloc(void *ptr, unsigned long amount)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2010-05-05 19:16:24 +02:00
|
|
|
void *ret = realloc(ptr, amount);
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2010-05-05 19:16:24 +02:00
|
|
|
if (!ret)
|
2012-03-21 20:55:09 +01:00
|
|
|
FatalError("XNFrealloc: Out of memory");
|
2010-05-05 19:16:24 +02:00
|
|
|
return ret;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
|
2015-03-21 17:28:07 +01:00
|
|
|
void *
|
|
|
|
XNFreallocarray(void *ptr, size_t nmemb, size_t size)
|
|
|
|
{
|
|
|
|
void *ret = reallocarray(ptr, nmemb, size);
|
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
FatalError("XNFreallocarray: Out of memory");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
char *
|
2003-11-14 17:49:22 +01:00
|
|
|
Xstrdup(const char *s)
|
|
|
|
{
|
|
|
|
if (s == NULL)
|
2012-03-21 20:55:09 +01:00
|
|
|
return NULL;
|
2010-05-05 19:16:24 +02:00
|
|
|
return strdup(s);
|
2003-11-14 17:49:22 +01:00
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
char *
|
2003-11-14 17:49:22 +01:00
|
|
|
XNFstrdup(const char *s)
|
|
|
|
{
|
2010-05-05 19:16:24 +02:00
|
|
|
char *ret;
|
2003-11-14 17:49:22 +01:00
|
|
|
|
|
|
|
if (s == NULL)
|
2012-03-21 20:55:09 +01:00
|
|
|
return NULL;
|
2003-11-14 17:49:22 +01:00
|
|
|
|
2010-05-05 19:16:24 +02:00
|
|
|
ret = strdup(s);
|
|
|
|
if (!ret)
|
2012-03-21 20:55:09 +01:00
|
|
|
FatalError("XNFstrdup: Out of memory");
|
2010-05-05 19:16:24 +02:00
|
|
|
return ret;
|
2003-11-14 17:49:22 +01:00
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2012-03-21 20:55:09 +01:00
|
|
|
SmartScheduleStopTimer(void)
|
2003-11-14 17:49:22 +01:00
|
|
|
{
|
2015-11-12 07:02:01 +01:00
|
|
|
#if HAVE_SETITIMER
|
2012-03-21 20:55:09 +01:00
|
|
|
struct itimerval timer;
|
|
|
|
|
2015-11-12 07:02:01 +01:00
|
|
|
if (!SmartScheduleSignalEnable)
|
2012-03-21 20:55:09 +01:00
|
|
|
return;
|
2003-11-14 17:49:22 +01:00
|
|
|
timer.it_interval.tv_sec = 0;
|
|
|
|
timer.it_interval.tv_usec = 0;
|
|
|
|
timer.it_value.tv_sec = 0;
|
|
|
|
timer.it_value.tv_usec = 0;
|
2012-03-21 20:55:09 +01:00
|
|
|
(void) setitimer(ITIMER_REAL, &timer, 0);
|
2012-11-13 14:22:44 +01:00
|
|
|
#endif
|
2003-11-14 17:49:22 +01:00
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2012-03-21 20:55:09 +01:00
|
|
|
SmartScheduleStartTimer(void)
|
2003-11-14 17:49:22 +01:00
|
|
|
{
|
2015-11-12 07:02:01 +01:00
|
|
|
#if HAVE_SETITIMER
|
2012-03-21 20:55:09 +01:00
|
|
|
struct itimerval timer;
|
|
|
|
|
2015-11-12 07:02:01 +01:00
|
|
|
if (!SmartScheduleSignalEnable)
|
2012-03-21 20:55:09 +01:00
|
|
|
return;
|
2003-11-14 17:49:22 +01:00
|
|
|
timer.it_interval.tv_sec = 0;
|
|
|
|
timer.it_interval.tv_usec = SmartScheduleInterval * 1000;
|
|
|
|
timer.it_value.tv_sec = 0;
|
|
|
|
timer.it_value.tv_usec = SmartScheduleInterval * 1000;
|
2012-03-21 20:55:09 +01:00
|
|
|
setitimer(ITIMER_REAL, &timer, 0);
|
2012-11-13 14:22:44 +01:00
|
|
|
#endif
|
2003-11-14 17:49:22 +01:00
|
|
|
}
|
|
|
|
|
2015-11-12 07:02:01 +01:00
|
|
|
#if HAVE_SETITIMER
|
2003-11-25 20:29:01 +01:00
|
|
|
static void
|
2012-03-21 20:55:09 +01:00
|
|
|
SmartScheduleTimer(int sig)
|
2003-11-14 17:49:22 +01:00
|
|
|
{
|
|
|
|
SmartScheduleTime += SmartScheduleInterval;
|
|
|
|
}
|
|
|
|
|
2015-05-20 21:16:12 +02:00
|
|
|
static int
|
|
|
|
SmartScheduleEnable(void)
|
2003-11-14 17:49:22 +01:00
|
|
|
{
|
2015-05-20 21:16:12 +02:00
|
|
|
int ret = 0;
|
2012-03-21 20:55:09 +01:00
|
|
|
struct sigaction act;
|
2003-11-14 17:49:22 +01:00
|
|
|
|
2015-11-12 07:02:01 +01:00
|
|
|
if (!SmartScheduleSignalEnable)
|
2015-05-20 21:16:12 +02:00
|
|
|
return 0;
|
2010-08-04 15:12:59 +02:00
|
|
|
|
2010-06-04 10:35:31 +02:00
|
|
|
memset((char *) &act, 0, sizeof(struct sigaction));
|
2003-11-14 17:49:22 +01:00
|
|
|
|
|
|
|
/* Set up the timer signal function */
|
2015-05-13 00:39:22 +02:00
|
|
|
act.sa_flags = SA_RESTART;
|
2003-11-14 17:49:22 +01:00
|
|
|
act.sa_handler = SmartScheduleTimer;
|
2012-03-21 20:55:09 +01:00
|
|
|
sigemptyset(&act.sa_mask);
|
|
|
|
sigaddset(&act.sa_mask, SIGALRM);
|
2015-05-20 21:16:12 +02:00
|
|
|
ret = sigaction(SIGALRM, &act, 0);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
SmartSchedulePause(void)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
struct sigaction act;
|
|
|
|
|
2015-11-12 07:02:01 +01:00
|
|
|
if (!SmartScheduleSignalEnable)
|
2015-05-20 21:16:12 +02:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
memset((char *) &act, 0, sizeof(struct sigaction));
|
|
|
|
|
|
|
|
act.sa_handler = SIG_IGN;
|
|
|
|
sigemptyset(&act.sa_mask);
|
|
|
|
ret = sigaction(SIGALRM, &act, 0);
|
|
|
|
return ret;
|
|
|
|
}
|
2015-11-12 07:02:01 +01:00
|
|
|
#endif
|
2015-05-20 21:16:12 +02:00
|
|
|
|
|
|
|
void
|
|
|
|
SmartScheduleInit(void)
|
|
|
|
{
|
2015-11-12 07:02:01 +01:00
|
|
|
#if HAVE_SETITIMER
|
2015-05-20 21:16:12 +02:00
|
|
|
if (SmartScheduleEnable() < 0) {
|
2012-03-21 20:55:09 +01:00
|
|
|
perror("sigaction for smart scheduler");
|
2015-11-12 07:02:01 +01:00
|
|
|
SmartScheduleSignalEnable = FALSE;
|
2003-11-14 17:49:22 +01:00
|
|
|
}
|
2015-11-12 07:02:01 +01:00
|
|
|
#endif
|
2003-11-14 17:49:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef SIG_BLOCK
|
2012-03-21 20:55:09 +01:00
|
|
|
static sigset_t PreviousSignalMask;
|
|
|
|
static int BlockedSignalCount;
|
2003-11-14 17:49:22 +01:00
|
|
|
#endif
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2012-03-21 20:55:09 +01:00
|
|
|
OsBlockSignals(void)
|
2003-11-14 17:49:22 +01:00
|
|
|
{
|
|
|
|
#ifdef SIG_BLOCK
|
2012-03-21 20:55:09 +01:00
|
|
|
if (BlockedSignalCount++ == 0) {
|
|
|
|
sigset_t set;
|
|
|
|
|
|
|
|
sigemptyset(&set);
|
|
|
|
sigaddset(&set, SIGALRM);
|
|
|
|
sigaddset(&set, SIGVTALRM);
|
2003-11-14 17:49:22 +01:00
|
|
|
#ifdef SIGWINCH
|
2012-03-21 20:55:09 +01:00
|
|
|
sigaddset(&set, SIGWINCH);
|
2003-11-14 17:49:22 +01:00
|
|
|
#endif
|
2012-03-21 20:55:09 +01:00
|
|
|
sigaddset(&set, SIGTSTP);
|
|
|
|
sigaddset(&set, SIGTTIN);
|
|
|
|
sigaddset(&set, SIGTTOU);
|
|
|
|
sigaddset(&set, SIGCHLD);
|
2015-12-08 20:37:51 +01:00
|
|
|
xthread_sigmask(SIG_BLOCK, &set, &PreviousSignalMask);
|
2003-11-14 17:49:22 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2012-03-21 20:55:09 +01:00
|
|
|
OsReleaseSignals(void)
|
2003-11-14 17:49:22 +01:00
|
|
|
{
|
|
|
|
#ifdef SIG_BLOCK
|
2012-03-21 20:55:09 +01:00
|
|
|
if (--BlockedSignalCount == 0) {
|
2015-12-08 20:37:51 +01:00
|
|
|
xthread_sigmask(SIG_SETMASK, &PreviousSignalMask, 0);
|
2003-11-14 17:49:22 +01:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2012-07-10 01:34:39 +02:00
|
|
|
void
|
|
|
|
OsResetSignals(void)
|
|
|
|
{
|
|
|
|
#ifdef SIG_BLOCK
|
|
|
|
while (BlockedSignalCount > 0)
|
|
|
|
OsReleaseSignals();
|
2015-12-08 23:39:46 +01:00
|
|
|
input_force_unlock();
|
2012-07-10 01:34:39 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-01-28 10:08:33 +01:00
|
|
|
/*
|
|
|
|
* Pending signals may interfere with core dumping. Provide a
|
|
|
|
* mechanism to block signals when aborting.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
2012-03-21 20:55:09 +01:00
|
|
|
OsAbort(void)
|
2010-01-28 10:08:33 +01:00
|
|
|
{
|
2010-03-28 01:35:10 +01:00
|
|
|
#ifndef __APPLE__
|
2010-01-28 10:08:33 +01:00
|
|
|
OsBlockSignals();
|
2010-03-28 01:35:10 +01:00
|
|
|
#endif
|
2010-01-28 10:08:33 +01:00
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
2007-06-29 00:59:05 +02:00
|
|
|
#if !defined(WIN32)
|
2003-11-14 17:49:22 +01:00
|
|
|
/*
|
|
|
|
* "safer" versions of system(3), popen(3) and pclose(3) which give up
|
|
|
|
* all privs before running a command.
|
|
|
|
*
|
|
|
|
* This is based on the code in FreeBSD 2.2 libc.
|
|
|
|
*
|
|
|
|
* XXX It'd be good to redirect stderr so that it ends up in the log file
|
|
|
|
* as well. As it is now, xkbcomp messages don't end up in the log file.
|
|
|
|
*/
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
int
|
2011-11-04 05:10:51 +01:00
|
|
|
System(const char *command)
|
2003-11-14 17:49:22 +01:00
|
|
|
{
|
|
|
|
int pid, p;
|
2012-03-21 20:55:09 +01:00
|
|
|
void (*csig) (int);
|
2003-11-14 17:49:22 +01:00
|
|
|
int status;
|
|
|
|
|
|
|
|
if (!command)
|
2012-03-21 20:55:09 +01:00
|
|
|
return 1;
|
2003-11-14 17:49:22 +01:00
|
|
|
|
2016-06-07 21:52:11 +02:00
|
|
|
csig = OsSignal(SIGCHLD, SIG_DFL);
|
2007-09-22 02:07:36 +02:00
|
|
|
if (csig == SIG_ERR) {
|
2012-03-21 20:55:09 +01:00
|
|
|
perror("signal");
|
|
|
|
return -1;
|
2007-09-22 02:07:36 +02:00
|
|
|
}
|
2011-03-28 18:19:57 +02:00
|
|
|
DebugF("System: `%s'\n", command);
|
2003-11-14 17:49:22 +01:00
|
|
|
|
|
|
|
switch (pid = fork()) {
|
2012-03-21 20:55:09 +01:00
|
|
|
case -1: /* error */
|
|
|
|
p = -1;
|
2014-10-09 14:42:09 +02:00
|
|
|
break;
|
2012-03-21 20:55:09 +01:00
|
|
|
case 0: /* child */
|
|
|
|
if (setgid(getgid()) == -1)
|
|
|
|
_exit(127);
|
|
|
|
if (setuid(getuid()) == -1)
|
|
|
|
_exit(127);
|
|
|
|
execl("/bin/sh", "sh", "-c", command, (char *) NULL);
|
|
|
|
_exit(127);
|
|
|
|
default: /* parent */
|
|
|
|
do {
|
|
|
|
p = waitpid(pid, &status, 0);
|
|
|
|
} while (p == -1 && errno == EINTR);
|
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
}
|
|
|
|
|
2016-06-07 21:52:11 +02:00
|
|
|
if (OsSignal(SIGCHLD, csig) == SIG_ERR) {
|
2012-03-21 20:55:09 +01:00
|
|
|
perror("signal");
|
|
|
|
return -1;
|
2007-09-22 02:07:36 +02:00
|
|
|
}
|
2003-11-14 17:49:22 +01:00
|
|
|
|
|
|
|
return p == -1 ? -1 : status;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct pid {
|
|
|
|
struct pid *next;
|
|
|
|
FILE *fp;
|
|
|
|
int pid;
|
|
|
|
} *pidlist;
|
|
|
|
|
2013-12-15 10:05:51 +01:00
|
|
|
void *
|
2011-11-04 05:10:51 +01:00
|
|
|
Popen(const char *command, const char *type)
|
2003-11-14 17:49:22 +01:00
|
|
|
{
|
|
|
|
struct pid *cur;
|
|
|
|
FILE *iop;
|
|
|
|
int pdes[2], pid;
|
|
|
|
|
|
|
|
if (command == NULL || type == NULL)
|
2012-03-21 20:55:09 +01:00
|
|
|
return NULL;
|
2003-11-14 17:49:22 +01:00
|
|
|
|
|
|
|
if ((*type != 'r' && *type != 'w') || type[1])
|
2012-03-21 20:55:09 +01:00
|
|
|
return NULL;
|
2003-11-14 17:49:22 +01:00
|
|
|
|
2010-05-05 20:44:06 +02:00
|
|
|
if ((cur = malloc(sizeof(struct pid))) == NULL)
|
2012-03-21 20:55:09 +01:00
|
|
|
return NULL;
|
2003-11-14 17:49:22 +01:00
|
|
|
|
|
|
|
if (pipe(pdes) < 0) {
|
2012-03-21 20:55:09 +01:00
|
|
|
free(cur);
|
|
|
|
return NULL;
|
2003-11-14 17:49:22 +01:00
|
|
|
}
|
|
|
|
|
2007-09-11 17:37:06 +02:00
|
|
|
/* Ignore the smart scheduler while this is going on */
|
2015-11-12 07:02:01 +01:00
|
|
|
#if HAVE_SETITIMER
|
2015-05-20 21:16:12 +02:00
|
|
|
if (SmartSchedulePause() < 0) {
|
2012-03-21 20:55:09 +01:00
|
|
|
close(pdes[0]);
|
|
|
|
close(pdes[1]);
|
|
|
|
free(cur);
|
|
|
|
perror("signal");
|
|
|
|
return NULL;
|
2007-09-22 02:07:36 +02:00
|
|
|
}
|
2015-11-12 07:02:01 +01:00
|
|
|
#endif
|
2007-09-11 17:37:06 +02:00
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
switch (pid = fork()) {
|
2012-03-21 20:55:09 +01:00
|
|
|
case -1: /* error */
|
|
|
|
close(pdes[0]);
|
|
|
|
close(pdes[1]);
|
|
|
|
free(cur);
|
2015-11-12 07:02:01 +01:00
|
|
|
#if HAVE_SETITIMER
|
2015-05-20 21:16:12 +02:00
|
|
|
if (SmartScheduleEnable() < 0)
|
2012-03-21 20:55:09 +01:00
|
|
|
perror("signal");
|
2015-11-12 07:02:01 +01:00
|
|
|
#endif
|
2012-03-21 20:55:09 +01:00
|
|
|
return NULL;
|
|
|
|
case 0: /* child */
|
|
|
|
if (setgid(getgid()) == -1)
|
|
|
|
_exit(127);
|
|
|
|
if (setuid(getuid()) == -1)
|
|
|
|
_exit(127);
|
|
|
|
if (*type == 'r') {
|
|
|
|
if (pdes[1] != 1) {
|
|
|
|
/* stdout */
|
|
|
|
dup2(pdes[1], 1);
|
|
|
|
close(pdes[1]);
|
|
|
|
}
|
|
|
|
close(pdes[0]);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (pdes[0] != 0) {
|
|
|
|
/* stdin */
|
|
|
|
dup2(pdes[0], 0);
|
|
|
|
close(pdes[0]);
|
|
|
|
}
|
|
|
|
close(pdes[1]);
|
|
|
|
}
|
|
|
|
execl("/bin/sh", "sh", "-c", command, (char *) NULL);
|
|
|
|
_exit(127);
|
2003-11-14 17:49:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Avoid EINTR during stdio calls */
|
2012-03-21 20:55:09 +01:00
|
|
|
OsBlockSignals();
|
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
/* parent */
|
|
|
|
if (*type == 'r') {
|
2012-03-21 20:55:09 +01:00
|
|
|
iop = fdopen(pdes[0], type);
|
|
|
|
close(pdes[1]);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
iop = fdopen(pdes[1], type);
|
|
|
|
close(pdes[0]);
|
2003-11-14 17:49:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cur->fp = iop;
|
|
|
|
cur->pid = pid;
|
|
|
|
cur->next = pidlist;
|
|
|
|
pidlist = cur;
|
|
|
|
|
2011-03-28 18:19:57 +02:00
|
|
|
DebugF("Popen: `%s', fp = %p\n", command, iop);
|
2003-11-14 17:49:22 +01:00
|
|
|
|
|
|
|
return iop;
|
|
|
|
}
|
|
|
|
|
2003-11-25 20:29:01 +01:00
|
|
|
/* fopen that drops privileges */
|
2013-12-15 10:05:51 +01:00
|
|
|
void *
|
2011-11-04 05:10:51 +01:00
|
|
|
Fopen(const char *file, const char *type)
|
2003-11-25 20:29:01 +01:00
|
|
|
{
|
|
|
|
FILE *iop;
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2003-11-25 20:29:01 +01:00
|
|
|
#ifndef HAS_SAVED_IDS_AND_SETEUID
|
|
|
|
struct pid *cur;
|
|
|
|
int pdes[2], pid;
|
|
|
|
|
|
|
|
if (file == NULL || type == NULL)
|
2012-03-21 20:55:09 +01:00
|
|
|
return NULL;
|
2003-11-25 20:29:01 +01:00
|
|
|
|
|
|
|
if ((*type != 'r' && *type != 'w') || type[1])
|
2012-03-21 20:55:09 +01:00
|
|
|
return NULL;
|
2003-11-25 20:29:01 +01:00
|
|
|
|
2010-05-05 20:44:06 +02:00
|
|
|
if ((cur = malloc(sizeof(struct pid))) == NULL)
|
2012-03-21 20:55:09 +01:00
|
|
|
return NULL;
|
2003-11-25 20:29:01 +01:00
|
|
|
|
|
|
|
if (pipe(pdes) < 0) {
|
2012-03-21 20:55:09 +01:00
|
|
|
free(cur);
|
|
|
|
return NULL;
|
2003-11-25 20:29:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (pid = fork()) {
|
2012-03-21 20:55:09 +01:00
|
|
|
case -1: /* error */
|
|
|
|
close(pdes[0]);
|
|
|
|
close(pdes[1]);
|
|
|
|
free(cur);
|
|
|
|
return NULL;
|
|
|
|
case 0: /* child */
|
|
|
|
if (setgid(getgid()) == -1)
|
|
|
|
_exit(127);
|
|
|
|
if (setuid(getuid()) == -1)
|
|
|
|
_exit(127);
|
|
|
|
if (*type == 'r') {
|
|
|
|
if (pdes[1] != 1) {
|
|
|
|
/* stdout */
|
|
|
|
dup2(pdes[1], 1);
|
|
|
|
close(pdes[1]);
|
|
|
|
}
|
|
|
|
close(pdes[0]);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (pdes[0] != 0) {
|
|
|
|
/* stdin */
|
|
|
|
dup2(pdes[0], 0);
|
|
|
|
close(pdes[0]);
|
|
|
|
}
|
|
|
|
close(pdes[1]);
|
|
|
|
}
|
|
|
|
execl("/bin/cat", "cat", file, (char *) NULL);
|
|
|
|
_exit(127);
|
2003-11-25 20:29:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Avoid EINTR during stdio calls */
|
2012-03-21 20:55:09 +01:00
|
|
|
OsBlockSignals();
|
|
|
|
|
2003-11-25 20:29:01 +01:00
|
|
|
/* parent */
|
|
|
|
if (*type == 'r') {
|
2012-03-21 20:55:09 +01:00
|
|
|
iop = fdopen(pdes[0], type);
|
|
|
|
close(pdes[1]);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
iop = fdopen(pdes[1], type);
|
|
|
|
close(pdes[0]);
|
2003-11-25 20:29:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
cur->fp = iop;
|
|
|
|
cur->pid = pid;
|
|
|
|
cur->next = pidlist;
|
|
|
|
pidlist = cur;
|
|
|
|
|
2011-03-28 18:19:57 +02:00
|
|
|
DebugF("Fopen(%s), fp = %p\n", file, iop);
|
2003-11-25 20:29:01 +01:00
|
|
|
|
|
|
|
return iop;
|
|
|
|
#else
|
|
|
|
int ruid, euid;
|
|
|
|
|
|
|
|
ruid = getuid();
|
|
|
|
euid = geteuid();
|
2012-03-21 20:55:09 +01:00
|
|
|
|
2003-11-25 20:29:01 +01:00
|
|
|
if (seteuid(ruid) == -1) {
|
2012-03-21 20:55:09 +01:00
|
|
|
return NULL;
|
2003-11-25 20:29:01 +01:00
|
|
|
}
|
|
|
|
iop = fopen(file, type);
|
|
|
|
|
|
|
|
if (seteuid(euid) == -1) {
|
2012-03-21 20:55:09 +01:00
|
|
|
fclose(iop);
|
|
|
|
return NULL;
|
2003-11-25 20:29:01 +01:00
|
|
|
}
|
|
|
|
return iop;
|
2012-03-21 20:55:09 +01:00
|
|
|
#endif /* HAS_SAVED_IDS_AND_SETEUID */
|
2003-11-25 20:29:01 +01:00
|
|
|
}
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
int
|
2013-12-15 10:05:51 +01:00
|
|
|
Pclose(void *iop)
|
2003-11-14 17:49:22 +01:00
|
|
|
{
|
|
|
|
struct pid *cur, *last;
|
|
|
|
int pstat;
|
|
|
|
int pid;
|
|
|
|
|
2011-03-28 18:19:57 +02:00
|
|
|
DebugF("Pclose: fp = %p\n", iop);
|
2003-11-14 17:49:22 +01:00
|
|
|
fclose(iop);
|
|
|
|
|
|
|
|
for (last = NULL, cur = pidlist; cur; last = cur, cur = cur->next)
|
2012-03-21 20:55:09 +01:00
|
|
|
if (cur->fp == iop)
|
|
|
|
break;
|
2003-11-14 17:49:22 +01:00
|
|
|
if (cur == NULL)
|
2012-03-21 20:55:09 +01:00
|
|
|
return -1;
|
2003-11-14 17:49:22 +01:00
|
|
|
|
|
|
|
do {
|
2012-03-21 20:55:09 +01:00
|
|
|
pid = waitpid(cur->pid, &pstat, 0);
|
2003-11-14 17:49:22 +01:00
|
|
|
} while (pid == -1 && errno == EINTR);
|
|
|
|
|
|
|
|
if (last == NULL)
|
2012-03-21 20:55:09 +01:00
|
|
|
pidlist = cur->next;
|
2003-11-14 17:49:22 +01:00
|
|
|
else
|
2012-03-21 20:55:09 +01:00
|
|
|
last->next = cur->next;
|
2010-05-05 20:44:06 +02:00
|
|
|
free(cur);
|
2003-11-14 17:49:22 +01:00
|
|
|
|
|
|
|
/* allow EINTR again */
|
2012-03-21 20:55:09 +01:00
|
|
|
OsReleaseSignals();
|
|
|
|
|
2015-11-12 07:02:01 +01:00
|
|
|
#if HAVE_SETITIMER
|
2015-05-20 21:16:12 +02:00
|
|
|
if (SmartScheduleEnable() < 0) {
|
2012-03-21 20:55:09 +01:00
|
|
|
perror("signal");
|
|
|
|
return -1;
|
2007-09-22 02:07:36 +02:00
|
|
|
}
|
2015-11-12 07:02:01 +01:00
|
|
|
#endif
|
2007-09-11 17:37:06 +02:00
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
return pid == -1 ? -1 : pstat;
|
|
|
|
}
|
2003-11-25 20:29:01 +01:00
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
int
|
2013-12-15 10:05:51 +01:00
|
|
|
Fclose(void *iop)
|
2003-11-25 20:29:01 +01:00
|
|
|
{
|
|
|
|
#ifdef HAS_SAVED_IDS_AND_SETEUID
|
|
|
|
return fclose(iop);
|
|
|
|
#else
|
|
|
|
return Pclose(iop);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
#endif /* !WIN32 */
|
2003-11-14 17:49:22 +01:00
|
|
|
|
2012-07-13 23:36:25 +02:00
|
|
|
#ifdef WIN32
|
|
|
|
|
|
|
|
#include <X11/Xwindows.h>
|
|
|
|
|
|
|
|
const char *
|
2015-03-20 15:25:17 +01:00
|
|
|
Win32TempDir(void)
|
2012-07-13 23:36:25 +02:00
|
|
|
{
|
|
|
|
static char buffer[PATH_MAX];
|
|
|
|
|
|
|
|
if (GetTempPath(sizeof(buffer), buffer)) {
|
|
|
|
int len;
|
|
|
|
|
|
|
|
buffer[sizeof(buffer) - 1] = 0;
|
|
|
|
len = strlen(buffer);
|
|
|
|
if (len > 0)
|
|
|
|
if (buffer[len - 1] == '\\')
|
|
|
|
buffer[len - 1] = 0;
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
if (getenv("TEMP") != NULL)
|
|
|
|
return getenv("TEMP");
|
|
|
|
else if (getenv("TMP") != NULL)
|
2012-07-22 14:15:02 +02:00
|
|
|
return getenv("TMP");
|
2012-07-13 23:36:25 +02:00
|
|
|
else
|
|
|
|
return "/tmp";
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
System(const char *cmdline)
|
|
|
|
{
|
|
|
|
STARTUPINFO si;
|
|
|
|
PROCESS_INFORMATION pi;
|
|
|
|
DWORD dwExitCode;
|
|
|
|
char *cmd = strdup(cmdline);
|
|
|
|
|
|
|
|
ZeroMemory(&si, sizeof(si));
|
|
|
|
si.cb = sizeof(si);
|
|
|
|
ZeroMemory(&pi, sizeof(pi));
|
|
|
|
|
|
|
|
if (!CreateProcess(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi)) {
|
|
|
|
LPVOID buffer;
|
|
|
|
|
|
|
|
if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
|
|
|
FORMAT_MESSAGE_FROM_SYSTEM |
|
|
|
|
FORMAT_MESSAGE_IGNORE_INSERTS,
|
|
|
|
NULL,
|
|
|
|
GetLastError(),
|
|
|
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
2012-11-06 06:50:58 +01:00
|
|
|
(LPTSTR) &buffer, 0, NULL)) {
|
2012-07-13 23:36:25 +02:00
|
|
|
ErrorF("[xkb] Starting '%s' failed!\n", cmdline);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ErrorF("[xkb] Starting '%s' failed: %s", cmdline, (char *) buffer);
|
|
|
|
LocalFree(buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
free(cmd);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
/* Wait until child process exits. */
|
|
|
|
WaitForSingleObject(pi.hProcess, INFINITE);
|
|
|
|
|
|
|
|
GetExitCodeProcess(pi.hProcess, &dwExitCode);
|
|
|
|
|
|
|
|
/* Close process and thread handles. */
|
|
|
|
CloseHandle(pi.hProcess);
|
|
|
|
CloseHandle(pi.hThread);
|
|
|
|
free(cmd);
|
|
|
|
|
|
|
|
return dwExitCode;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
/*
|
|
|
|
* CheckUserParameters: check for long command line arguments and long
|
|
|
|
* environment variables. By default, these checks are only done when
|
|
|
|
* the server's euid != ruid. In 3.3.x, these checks were done in an
|
|
|
|
* external wrapper utility.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Consider LD* variables insecure? */
|
|
|
|
#ifndef REMOVE_ENV_LD
|
|
|
|
#define REMOVE_ENV_LD 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Remove long environment variables? */
|
|
|
|
#ifndef REMOVE_LONG_ENV
|
|
|
|
#define REMOVE_LONG_ENV 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Disallow stdout or stderr as pipes? It's possible to block the X server
|
|
|
|
* when piping stdout+stderr to a pipe.
|
|
|
|
*
|
|
|
|
* Don't enable this because it looks like it's going to cause problems.
|
|
|
|
*/
|
|
|
|
#ifndef NO_OUTPUT_PIPES
|
|
|
|
#define NO_OUTPUT_PIPES 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Check args and env only if running setuid (euid == 0 && euid != uid) ? */
|
|
|
|
#ifndef CHECK_EUID
|
2004-11-15 16:06:51 +01:00
|
|
|
#ifndef WIN32
|
2003-11-14 17:49:22 +01:00
|
|
|
#define CHECK_EUID 1
|
2004-11-15 16:06:51 +01:00
|
|
|
#else
|
|
|
|
#define CHECK_EUID 0
|
|
|
|
#endif
|
2003-11-14 17:49:22 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Maybe the locale can be faked to make isprint(3) report that everything
|
|
|
|
* is printable? Avoid it by default.
|
|
|
|
*/
|
|
|
|
#ifndef USE_ISPRINT
|
|
|
|
#define USE_ISPRINT 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define MAX_ARG_LENGTH 128
|
|
|
|
#define MAX_ENV_LENGTH 256
|
2012-03-21 20:55:09 +01:00
|
|
|
#define MAX_ENV_PATH_LENGTH 2048 /* Limit for *PATH and TERMCAP */
|
2003-11-14 17:49:22 +01:00
|
|
|
|
|
|
|
#if USE_ISPRINT
|
|
|
|
#include <ctype.h>
|
|
|
|
#define checkPrintable(c) isprint(c)
|
|
|
|
#else
|
|
|
|
#define checkPrintable(c) (((c) & 0x7f) >= 0x20 && ((c) & 0x7f) != 0x7f)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
enum BadCode {
|
|
|
|
NotBad = 0,
|
|
|
|
UnsafeArg,
|
|
|
|
ArgTooLong,
|
|
|
|
UnprintableArg,
|
|
|
|
EnvTooLong,
|
|
|
|
OutputIsPipe,
|
|
|
|
InternalError
|
|
|
|
};
|
|
|
|
|
2004-08-12 00:27:50 +02:00
|
|
|
#if defined(VENDORSUPPORT)
|
|
|
|
#define BUGADDRESS VENDORSUPPORT
|
|
|
|
#elif defined(BUILDERADDR)
|
|
|
|
#define BUGADDRESS BUILDERADDR
|
|
|
|
#else
|
|
|
|
#define BUGADDRESS "xorg@freedesktop.org"
|
|
|
|
#endif
|
|
|
|
|
2003-11-14 17:49:22 +01:00
|
|
|
void
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
CheckUserParameters(int argc, char **argv, char **envp)
|
2003-11-14 17:49:22 +01:00
|
|
|
{
|
|
|
|
enum BadCode bad = NotBad;
|
|
|
|
int i = 0, j;
|
|
|
|
char *a, *e = NULL;
|
|
|
|
|
|
|
|
#if CHECK_EUID
|
|
|
|
if (geteuid() == 0 && getuid() != geteuid())
|
|
|
|
#endif
|
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
/* Check each argv[] */
|
|
|
|
for (i = 1; i < argc; i++) {
|
|
|
|
if (strcmp(argv[i], "-fp") == 0) {
|
|
|
|
i++; /* continue with next argument. skip the length check */
|
|
|
|
if (i >= argc)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (strlen(argv[i]) > MAX_ARG_LENGTH) {
|
|
|
|
bad = ArgTooLong;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
a = argv[i];
|
|
|
|
while (*a) {
|
|
|
|
if (checkPrintable(*a) == 0) {
|
|
|
|
bad = UnprintableArg;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
a++;
|
|
|
|
}
|
|
|
|
if (bad)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!bad) {
|
|
|
|
/* Check each envp[] */
|
|
|
|
for (i = 0; envp[i]; i++) {
|
|
|
|
|
|
|
|
/* Check for bad environment variables and values */
|
2003-11-14 17:49:22 +01:00
|
|
|
#if REMOVE_ENV_LD
|
2012-03-21 20:55:09 +01:00
|
|
|
while (envp[i] && (strncmp(envp[i], "LD", 2) == 0)) {
|
|
|
|
for (j = i; envp[j]; j++) {
|
|
|
|
envp[j] = envp[j + 1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (envp[i] && (strlen(envp[i]) > MAX_ENV_LENGTH)) {
|
2003-11-14 17:49:22 +01:00
|
|
|
#if REMOVE_LONG_ENV
|
2012-03-21 20:55:09 +01:00
|
|
|
for (j = i; envp[j]; j++) {
|
|
|
|
envp[j] = envp[j + 1];
|
|
|
|
}
|
|
|
|
i--;
|
2003-11-14 17:49:22 +01:00
|
|
|
#else
|
2012-03-21 20:55:09 +01:00
|
|
|
char *eq;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
eq = strchr(envp[i], '=');
|
|
|
|
if (!eq)
|
|
|
|
continue;
|
|
|
|
len = eq - envp[i];
|
|
|
|
e = strndup(envp[i], len);
|
|
|
|
if (!e) {
|
|
|
|
bad = InternalError;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (len >= 4 &&
|
|
|
|
(strcmp(e + len - 4, "PATH") == 0 ||
|
|
|
|
strcmp(e, "TERMCAP") == 0)) {
|
|
|
|
if (strlen(envp[i]) > MAX_ENV_PATH_LENGTH) {
|
|
|
|
bad = EnvTooLong;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
free(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
bad = EnvTooLong;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-11-14 17:49:22 +01:00
|
|
|
#if NO_OUTPUT_PIPES
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!bad) {
|
|
|
|
struct stat buf;
|
2003-11-14 17:49:22 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (fstat(fileno(stdout), &buf) == 0 && S_ISFIFO(buf.st_mode))
|
|
|
|
bad = OutputIsPipe;
|
|
|
|
if (fstat(fileno(stderr), &buf) == 0 && S_ISFIFO(buf.st_mode))
|
|
|
|
bad = OutputIsPipe;
|
|
|
|
}
|
2003-11-14 17:49:22 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
switch (bad) {
|
|
|
|
case NotBad:
|
2012-03-21 20:55:09 +01:00
|
|
|
return;
|
2003-11-14 17:49:22 +01:00
|
|
|
case UnsafeArg:
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF("Command line argument number %d is unsafe\n", i);
|
|
|
|
break;
|
2003-11-14 17:49:22 +01:00
|
|
|
case ArgTooLong:
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF("Command line argument number %d is too long\n", i);
|
|
|
|
break;
|
2003-11-14 17:49:22 +01:00
|
|
|
case UnprintableArg:
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF("Command line argument number %d contains unprintable"
|
|
|
|
" characters\n", i);
|
|
|
|
break;
|
2003-11-14 17:49:22 +01:00
|
|
|
case EnvTooLong:
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF("Environment variable `%s' is too long\n", e);
|
|
|
|
break;
|
2003-11-14 17:49:22 +01:00
|
|
|
case OutputIsPipe:
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF("Stdout and/or stderr is a pipe\n");
|
|
|
|
break;
|
2003-11-14 17:49:22 +01:00
|
|
|
case InternalError:
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF("Internal Error\n");
|
|
|
|
break;
|
2003-11-14 17:49:22 +01:00
|
|
|
default:
|
2012-03-21 20:55:09 +01:00
|
|
|
ErrorF("Unknown error\n");
|
|
|
|
break;
|
2003-11-14 17:49:22 +01:00
|
|
|
}
|
|
|
|
FatalError("X server aborted because of unsafe environment\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* CheckUserAuthorization: check if the user is allowed to start the
|
|
|
|
* X server. This usually means some sort of PAM checking, and it is
|
|
|
|
* usually only done for setuid servers (uid != euid).
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef USE_PAM
|
|
|
|
#include <security/pam_appl.h>
|
|
|
|
#include <security/pam_misc.h>
|
|
|
|
#include <pwd.h>
|
2012-03-21 20:55:09 +01:00
|
|
|
#endif /* USE_PAM */
|
2003-11-14 17:49:22 +01:00
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
void
|
2003-11-25 20:29:01 +01:00
|
|
|
CheckUserAuthorization(void)
|
2003-11-14 17:49:22 +01:00
|
|
|
{
|
|
|
|
#ifdef USE_PAM
|
|
|
|
static struct pam_conv conv = {
|
2012-03-21 20:55:09 +01:00
|
|
|
misc_conv,
|
|
|
|
NULL
|
2003-11-14 17:49:22 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
pam_handle_t *pamh = NULL;
|
|
|
|
struct passwd *pw;
|
|
|
|
int retval;
|
|
|
|
|
|
|
|
if (getuid() != geteuid()) {
|
2012-03-21 20:55:09 +01:00
|
|
|
pw = getpwuid(getuid());
|
|
|
|
if (pw == NULL)
|
|
|
|
FatalError("getpwuid() failed for uid %d\n", getuid());
|
|
|
|
|
|
|
|
retval = pam_start("xserver", pw->pw_name, &conv, &pamh);
|
|
|
|
if (retval != PAM_SUCCESS)
|
|
|
|
FatalError("pam_start() failed.\n"
|
|
|
|
"\tMissing or mangled PAM config file or module?\n");
|
|
|
|
|
|
|
|
retval = pam_authenticate(pamh, 0);
|
|
|
|
if (retval != PAM_SUCCESS) {
|
|
|
|
pam_end(pamh, retval);
|
|
|
|
FatalError("PAM authentication failed, cannot start X server.\n"
|
|
|
|
"\tPerhaps you do not have console ownership?\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
retval = pam_acct_mgmt(pamh, 0);
|
|
|
|
if (retval != PAM_SUCCESS) {
|
|
|
|
pam_end(pamh, retval);
|
|
|
|
FatalError("PAM authentication failed, cannot start X server.\n"
|
|
|
|
"\tPerhaps you do not have console ownership?\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* this is not a session, so do not do session management */
|
|
|
|
pam_end(pamh, PAM_SUCCESS);
|
2003-11-14 17:49:22 +01:00
|
|
|
}
|
2003-11-14 16:54:54 +01:00
|
|
|
#endif
|
|
|
|
}
|
2005-11-08 07:33:30 +01:00
|
|
|
|
2010-02-10 06:36:49 +01:00
|
|
|
/*
|
|
|
|
* Tokenize a string into a NULL terminated array of strings. Always returns
|
|
|
|
* an allocated array unless an error occurs.
|
|
|
|
*/
|
2014-01-29 23:52:32 +01:00
|
|
|
char **
|
2010-02-10 06:36:49 +01:00
|
|
|
xstrtokenize(const char *str, const char *separators)
|
|
|
|
{
|
2014-01-29 23:52:32 +01:00
|
|
|
char **list, **nlist;
|
2010-02-10 06:36:49 +01:00
|
|
|
char *tok, *tmp;
|
|
|
|
unsigned num = 0, n;
|
|
|
|
|
|
|
|
if (!str)
|
|
|
|
return NULL;
|
|
|
|
list = calloc(1, sizeof(*list));
|
|
|
|
if (!list)
|
|
|
|
return NULL;
|
|
|
|
tmp = strdup(str);
|
|
|
|
if (!tmp)
|
|
|
|
goto error;
|
|
|
|
for (tok = strtok(tmp, separators); tok; tok = strtok(NULL, separators)) {
|
2015-03-21 18:08:25 +01:00
|
|
|
nlist = reallocarray(list, num + 2, sizeof(*list));
|
2010-02-10 06:36:49 +01:00
|
|
|
if (!nlist)
|
|
|
|
goto error;
|
|
|
|
list = nlist;
|
|
|
|
list[num] = strdup(tok);
|
|
|
|
if (!list[num])
|
|
|
|
goto error;
|
|
|
|
list[++num] = NULL;
|
|
|
|
}
|
|
|
|
free(tmp);
|
|
|
|
return list;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
error:
|
2010-02-10 06:36:49 +01:00
|
|
|
free(tmp);
|
|
|
|
for (n = 0; n < num; n++)
|
2014-01-29 23:52:32 +01:00
|
|
|
free(list[n]);
|
2010-02-10 06:36:49 +01:00
|
|
|
free(list);
|
|
|
|
return NULL;
|
|
|
|
}
|
2012-04-06 19:13:45 +02:00
|
|
|
|
2012-08-13 06:24:36 +02:00
|
|
|
/* Format a signed number into a string in a signal safe manner. The string
|
|
|
|
* should be at least 21 characters in order to handle all int64_t values.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
FormatInt64(int64_t num, char *string)
|
|
|
|
{
|
|
|
|
if (num < 0) {
|
|
|
|
string[0] = '-';
|
|
|
|
num *= -1;
|
|
|
|
string++;
|
|
|
|
}
|
|
|
|
FormatUInt64(num, string);
|
|
|
|
}
|
|
|
|
|
2012-04-06 19:13:45 +02:00
|
|
|
/* Format a number into a string in a signal safe manner. The string should be
|
|
|
|
* at least 21 characters in order to handle all uint64_t values. */
|
|
|
|
void
|
|
|
|
FormatUInt64(uint64_t num, char *string)
|
|
|
|
{
|
|
|
|
uint64_t divisor;
|
|
|
|
int len;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (len = 1, divisor = 10;
|
|
|
|
len < 20 && num / divisor;
|
|
|
|
len++, divisor *= 10);
|
|
|
|
|
|
|
|
for (i = len, divisor = 1; i > 0; i--, divisor *= 10)
|
|
|
|
string[i - 1] = '0' + ((num / divisor) % 10);
|
|
|
|
|
|
|
|
string[len] = '\0';
|
|
|
|
}
|
|
|
|
|
2013-01-10 04:20:12 +01:00
|
|
|
/**
|
|
|
|
* Format a double number as %.2f.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
FormatDouble(double dbl, char *string)
|
|
|
|
{
|
|
|
|
int slen = 0;
|
|
|
|
uint64_t frac;
|
|
|
|
|
2013-02-08 17:57:43 +01:00
|
|
|
frac = (dbl > 0 ? dbl : -dbl) * 100.0 + 0.5;
|
2013-01-10 04:20:12 +01:00
|
|
|
frac %= 100;
|
|
|
|
|
|
|
|
/* write decimal part to string */
|
|
|
|
if (dbl < 0 && dbl > -1)
|
|
|
|
string[slen++] = '-';
|
|
|
|
FormatInt64((int64_t)dbl, &string[slen]);
|
|
|
|
|
|
|
|
while(string[slen] != '\0')
|
|
|
|
slen++;
|
|
|
|
|
|
|
|
/* append fractional part, but only if we have enough characters. We
|
|
|
|
* expect string to be 21 chars (incl trailing \0) */
|
|
|
|
if (slen <= 17) {
|
|
|
|
string[slen++] = '.';
|
|
|
|
if (frac < 10)
|
|
|
|
string[slen++] = '0';
|
|
|
|
|
|
|
|
FormatUInt64(frac, &string[slen]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-04-06 19:13:45 +02:00
|
|
|
/* Format a number into a hexadecimal string in a signal safe manner. The string
|
|
|
|
* should be at least 17 characters in order to handle all uint64_t values. */
|
|
|
|
void
|
|
|
|
FormatUInt64Hex(uint64_t num, char *string)
|
|
|
|
{
|
|
|
|
uint64_t divisor;
|
|
|
|
int len;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (len = 1, divisor = 0x10;
|
|
|
|
len < 16 && num / divisor;
|
|
|
|
len++, divisor *= 0x10);
|
|
|
|
|
|
|
|
for (i = len, divisor = 1; i > 0; i--, divisor *= 0x10) {
|
|
|
|
int val = (num / divisor) % 0x10;
|
|
|
|
|
|
|
|
if (val < 10)
|
|
|
|
string[i - 1] = '0' + val;
|
|
|
|
else
|
|
|
|
string[i - 1] = 'a' + val - 10;
|
|
|
|
}
|
|
|
|
|
|
|
|
string[len] = '\0';
|
|
|
|
}
|
2013-11-22 07:12:34 +01:00
|
|
|
|
2015-03-20 15:25:53 +01:00
|
|
|
#if !defined(WIN32) || defined(__CYGWIN__)
|
2013-11-22 07:12:34 +01:00
|
|
|
/* Move a file descriptor out of the way of our select mask; this
|
|
|
|
* is useful for file descriptors which will never appear in the
|
|
|
|
* select mask to avoid reducing the number of clients that can
|
|
|
|
* connect to the server
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
os_move_fd(int fd)
|
|
|
|
{
|
|
|
|
int newfd;
|
|
|
|
|
|
|
|
#ifdef F_DUPFD_CLOEXEC
|
|
|
|
newfd = fcntl(fd, F_DUPFD_CLOEXEC, MAXCLIENTS);
|
|
|
|
#else
|
|
|
|
newfd = fcntl(fd, F_DUPFD, MAXCLIENTS);
|
|
|
|
#endif
|
|
|
|
if (newfd < 0)
|
|
|
|
return fd;
|
|
|
|
#ifndef F_DUPFD_CLOEXEC
|
|
|
|
fcntl(newfd, F_SETFD, FD_CLOEXEC);
|
|
|
|
#endif
|
|
|
|
close(fd);
|
|
|
|
return newfd;
|
|
|
|
}
|
2015-03-20 15:25:53 +01:00
|
|
|
#endif
|