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:
Keith Packard 2014-09-10 15:21:32 -07:00
commit 69d8572ae4
5 changed files with 74 additions and 65 deletions

View file

@ -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 */