Build required portions of registry.c automatically [v2]
Instead of making the inclusion of the registry code a global conditional, split the registry into two pieces; the bits required by the X-Resource extension (the resource names) and the bits required by the XCSECURITY extension (the protocol names). Build each set of code if the related extension is being built. v2: Check for both XCSECURITY and XSELINUX. Signed-off-by: Keith Packard <keithp@keithp.com> Reviewed-by: Adam Jackson <ajax@redhat.com>
This commit is contained in:
parent
a11fc2493e
commit
69d8572ae4
|
@ -564,7 +564,6 @@ AC_ARG_WITH(khronos-spec-dir, AS_HELP_STRING([--with-khronos-spec-dir=PATH], [Pa
|
|||
[KHRONOS_SPEC_DIR=auto])
|
||||
|
||||
dnl Extensions.
|
||||
AC_ARG_ENABLE(registry, AS_HELP_STRING([--disable-registry], [Build string registry module (default: enabled)]), [XREGISTRY=$enableval], [XREGISTRY=yes])
|
||||
AC_ARG_ENABLE(composite, AS_HELP_STRING([--disable-composite], [Build Composite extension (default: enabled)]), [COMPOSITE=$enableval], [COMPOSITE=yes])
|
||||
AC_ARG_ENABLE(mitshm, AS_HELP_STRING([--disable-mitshm], [Build SHM extension (default: auto)]), [MITSHM=$enableval], [MITSHM=auto])
|
||||
AC_ARG_ENABLE(xres, AS_HELP_STRING([--disable-xres], [Build XRes extension (default: enabled)]), [RES=$enableval], [RES=yes])
|
||||
|
@ -1016,11 +1015,6 @@ if test "x$XVMC" = xyes; then
|
|||
AC_DEFINE(XvMCExtension, 1, [Build XvMC extension])
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(XREGISTRY, [test "x$XREGISTRY" = xyes])
|
||||
if test "x$XREGISTRY" = xyes; then
|
||||
AC_DEFINE(XREGISTRY, 1, [Build registry module])
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(COMPOSITE, [test "x$COMPOSITE" = xyes])
|
||||
if test "x$COMPOSITE" = xyes; then
|
||||
AC_DEFINE(COMPOSITE, 1, [Support Composite Extension])
|
||||
|
|
|
@ -139,7 +139,9 @@ AddExtension(const char *name, int NumEvents, int NumErrors,
|
|||
ext->errorLast = 0;
|
||||
}
|
||||
|
||||
#ifdef X_REGISTRY_REQUEST
|
||||
RegisterExtensionNames(ext);
|
||||
#endif
|
||||
return ext;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,8 +21,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#ifdef XREGISTRY
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <X11/X.h>
|
||||
|
@ -31,6 +29,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#include "registry.h"
|
||||
|
||||
#define BASE_SIZE 16
|
||||
|
||||
#ifdef X_REGISTRY_REQUEST
|
||||
#define CORE "X11"
|
||||
#define FILENAME SERVER_MISC_CONFIG_PATH "/protocol.txt"
|
||||
|
||||
|
@ -42,9 +42,15 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
static FILE *fh;
|
||||
|
||||
static char ***requests, **events, **errors;
|
||||
static const char **resources;
|
||||
static unsigned nmajor, *nminor, nevent, nerror, nresource;
|
||||
static unsigned nmajor, *nminor, nevent, nerror;
|
||||
#endif
|
||||
|
||||
#ifdef X_REGISTRY_RESOURCE
|
||||
static const char **resources;
|
||||
static unsigned nresource;
|
||||
#endif
|
||||
|
||||
#if defined(X_REGISTRY_RESOURCE) || defined(X_REGISTRY_REQUEST)
|
||||
/*
|
||||
* File parsing routines
|
||||
*/
|
||||
|
@ -72,7 +78,12 @@ double_size(void *p, unsigned n, unsigned size)
|
|||
memset(*ptr + s, 0, f - s);
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef X_REGISTRY_REQUEST
|
||||
/*
|
||||
* Request/event/error registry functions
|
||||
*/
|
||||
static void
|
||||
RegisterRequestName(unsigned major, unsigned minor, char *name)
|
||||
{
|
||||
|
@ -197,28 +208,6 @@ RegisterExtensionNames(ExtensionEntry * extEntry)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Registration functions
|
||||
*/
|
||||
|
||||
void
|
||||
RegisterResourceName(RESTYPE resource, const char *name)
|
||||
{
|
||||
resource &= TypeMask;
|
||||
|
||||
while (resource >= nresource) {
|
||||
if (!double_size(&resources, nresource, sizeof(char *)))
|
||||
return;
|
||||
nresource = nresource ? nresource * 2 : BASE_SIZE;
|
||||
}
|
||||
|
||||
resources[resource] = name;
|
||||
}
|
||||
|
||||
/*
|
||||
* Lookup functions
|
||||
*/
|
||||
|
||||
const char *
|
||||
LookupRequestName(int major, int minor)
|
||||
{
|
||||
|
@ -269,6 +258,26 @@ LookupErrorName(int error)
|
|||
|
||||
return errors[error] ? errors[error] : XREGISTRY_UNKNOWN;
|
||||
}
|
||||
#endif /* X_REGISTRY_REQUEST */
|
||||
|
||||
#ifdef X_REGISTRY_RESOURCE
|
||||
/*
|
||||
* Resource registry functions
|
||||
*/
|
||||
|
||||
void
|
||||
RegisterResourceName(RESTYPE resource, const char *name)
|
||||
{
|
||||
resource &= TypeMask;
|
||||
|
||||
while (resource >= nresource) {
|
||||
if (!double_size(&resources, nresource, sizeof(char *)))
|
||||
return;
|
||||
nresource = nresource ? nresource * 2 : BASE_SIZE;
|
||||
}
|
||||
|
||||
resources[resource] = name;
|
||||
}
|
||||
|
||||
const char *
|
||||
LookupResourceName(RESTYPE resource)
|
||||
|
@ -279,10 +288,12 @@ LookupResourceName(RESTYPE resource)
|
|||
|
||||
return resources[resource] ? resources[resource] : XREGISTRY_UNKNOWN;
|
||||
}
|
||||
#endif /* X_REGISTRY_RESOURCE */
|
||||
|
||||
void
|
||||
dixFreeRegistry(void)
|
||||
{
|
||||
#ifdef X_REGISTRY_REQUEST
|
||||
/* Free all memory */
|
||||
while (nmajor--) {
|
||||
while (nminor[nmajor])
|
||||
|
@ -299,25 +310,30 @@ dixFreeRegistry(void)
|
|||
while (nerror--)
|
||||
free(errors[nerror]);
|
||||
free(errors);
|
||||
|
||||
free(resources);
|
||||
|
||||
requests = NULL;
|
||||
nminor = NULL;
|
||||
events = NULL;
|
||||
errors = NULL;
|
||||
resources = NULL;
|
||||
nmajor = nevent = nerror = 0;
|
||||
#endif
|
||||
|
||||
nmajor = nevent = nerror = nresource = 0;
|
||||
#ifdef X_REGISTRY_RESOURCE
|
||||
free(resources);
|
||||
|
||||
resources = NULL;
|
||||
nresource = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
dixCloseRegistry(void)
|
||||
{
|
||||
#ifdef X_REGISTRY_REQUEST
|
||||
if (fh) {
|
||||
fclose(fh);
|
||||
fh = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -326,16 +342,24 @@ dixCloseRegistry(void)
|
|||
void
|
||||
dixResetRegistry(void)
|
||||
{
|
||||
#ifdef X_REGISTRY_REQUEST
|
||||
ExtensionEntry extEntry = { .name = CORE };
|
||||
#endif
|
||||
|
||||
dixFreeRegistry();
|
||||
|
||||
#ifdef X_REGISTRY_REQUEST
|
||||
/* Open the protocol file */
|
||||
fh = fopen(FILENAME, "r");
|
||||
if (!fh)
|
||||
LogMessage(X_WARNING,
|
||||
"Failed to open protocol names file " FILENAME "\n");
|
||||
|
||||
/* Add the core protocol */
|
||||
RegisterExtensionNames(&extEntry);
|
||||
#endif
|
||||
|
||||
#ifdef X_REGISTRY_RESOURCE
|
||||
/* Add built-in resources */
|
||||
RegisterResourceName(RT_NONE, "NONE");
|
||||
RegisterResourceName(RT_WINDOW, "WINDOW");
|
||||
|
@ -347,9 +371,5 @@ dixResetRegistry(void)
|
|||
RegisterResourceName(RT_CMAPENTRY, "COLORMAP ENTRY");
|
||||
RegisterResourceName(RT_OTHERCLIENT, "OTHER CLIENT");
|
||||
RegisterResourceName(RT_PASSIVEGRAB, "PASSIVE GRAB");
|
||||
|
||||
/* Add the core protocol */
|
||||
RegisterExtensionNames(&extEntry);
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* XREGISTRY */
|
||||
|
|
|
@ -524,8 +524,10 @@ CreateNewResourceType(DeleteType deleteFunc, const char *name)
|
|||
resourceTypes[next].findSubResFunc = DefaultFindSubRes;
|
||||
resourceTypes[next].errorValue = BadValue;
|
||||
|
||||
#if X_REGISTRY_RESOURCE
|
||||
/* Called even if name is NULL, to remove any previous entry */
|
||||
RegisterResourceName(next, name);
|
||||
#endif
|
||||
|
||||
return next;
|
||||
}
|
||||
|
|
|
@ -17,18 +17,26 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
*/
|
||||
#define XREGISTRY_UNKNOWN "<unknown>"
|
||||
|
||||
#ifdef XREGISTRY
|
||||
|
||||
#include "resource.h"
|
||||
#include "extnsionst.h"
|
||||
|
||||
#if defined(XSELINUX) || defined(RES)
|
||||
#define X_REGISTRY_RESOURCE 1
|
||||
#endif
|
||||
|
||||
#if defined(XSELINUX) || defined(XCSECURITY)
|
||||
#define X_REGISTRY_REQUEST 1
|
||||
#endif
|
||||
|
||||
/* Internal string registry - for auditing, debugging, security, etc. */
|
||||
|
||||
/*
|
||||
* Registration functions. The name string is not copied, so it must
|
||||
* not be a stack variable.
|
||||
*/
|
||||
#ifdef X_REGISTRY_RESOURCE
|
||||
/* Functions used by the X-Resource extension */
|
||||
extern _X_EXPORT void RegisterResourceName(RESTYPE type, const char *name);
|
||||
extern _X_EXPORT const char *LookupResourceName(RESTYPE rtype);
|
||||
#endif
|
||||
|
||||
#ifdef X_REGISTRY_REQUEST
|
||||
extern _X_EXPORT void RegisterExtensionNames(ExtensionEntry * ext);
|
||||
|
||||
/*
|
||||
|
@ -38,7 +46,7 @@ extern _X_EXPORT const char *LookupMajorName(int major);
|
|||
extern _X_EXPORT const char *LookupRequestName(int major, int minor);
|
||||
extern _X_EXPORT const char *LookupEventName(int event);
|
||||
extern _X_EXPORT const char *LookupErrorName(int error);
|
||||
extern _X_EXPORT const char *LookupResourceName(RESTYPE rtype);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Setup and teardown
|
||||
|
@ -47,21 +55,4 @@ extern _X_EXPORT void dixResetRegistry(void);
|
|||
extern _X_EXPORT void dixFreeRegistry(void);
|
||||
extern _X_EXPORT void dixCloseRegistry(void);
|
||||
|
||||
#else /* XREGISTRY */
|
||||
|
||||
/* Define calls away when the registry is not being built. */
|
||||
|
||||
#define RegisterResourceName(a, b) { ; }
|
||||
#define RegisterExtensionNames(a) { ; }
|
||||
|
||||
#define LookupMajorName(a) XREGISTRY_UNKNOWN
|
||||
#define LookupRequestName(a, b) XREGISTRY_UNKNOWN
|
||||
#define LookupEventName(a) XREGISTRY_UNKNOWN
|
||||
#define LookupErrorName(a) XREGISTRY_UNKNOWN
|
||||
#define LookupResourceName(a) XREGISTRY_UNKNOWN
|
||||
|
||||
#define dixResetRegistry() { ; }
|
||||
#define dixFreeRegistry() { ; }
|
||||
|
||||
#endif /* XREGISTRY */
|
||||
#endif /* DIX_REGISTRY_H */
|
||||
|
|
Loading…
Reference in New Issue