diff options
Diffstat (limited to 'xorg-server/dix/registry.c')
-rwxr-xr-x[-rw-r--r--] | xorg-server/dix/registry.c | 98 |
1 files changed, 61 insertions, 37 deletions
diff --git a/xorg-server/dix/registry.c b/xorg-server/dix/registry.c index ce741c28e..aaccfbd09 100644..100755 --- a/xorg-server/dix/registry.c +++ b/xorg-server/dix/registry.c @@ -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 <unistd.h> @@ -32,6 +30,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" @@ -43,9 +43,15 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. static FILE *fh; static char ***requests, **events, **errors; +static unsigned nmajor, *nminor, nevent, nerror; +#endif + +#ifdef X_REGISTRY_RESOURCE static const char **resources; -static unsigned nmajor, *nminor, nevent, nerror, nresource; +static unsigned nresource; +#endif +#if defined(X_REGISTRY_RESOURCE) || defined(X_REGISTRY_REQUEST) /* * File parsing routines */ @@ -73,7 +79,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) { @@ -198,28 +209,6 @@ RegisterExtensionNames(ExtensionEntry * extEntry) } } -/* - * Registration functions - */ - -void -RegisterResourceName(RESTYPE resource, const char *name) -{ - resource &= TypeMask; - - while (resource >= nresource) { - if (!double_size((void*)&resources, nresource, sizeof(char *))) - return; - nresource = nresource ? nresource * 2 : BASE_SIZE; - } - - resources[resource] = name; -} - -/* - * Lookup functions - */ - const char * LookupRequestName(int major, int minor) { @@ -270,6 +259,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((void*)&resources, nresource, sizeof(char *))) + return; + nresource = nresource ? nresource * 2 : BASE_SIZE; + } + + resources[resource] = name; +} const char * LookupResourceName(RESTYPE resource) @@ -280,10 +289,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]) @@ -300,21 +311,30 @@ dixFreeRegistry(void) while (nerror--) free(errors[nerror]); free(errors); - - free((void*)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((void*)resources); + + resources = NULL; + nresource = 0; +#endif +} +void +dixCloseRegistry(void) +{ +#ifdef X_REGISTRY_REQUEST if (fh) { fclose(fh); fh = NULL; } +#endif } /* @@ -323,16 +343,26 @@ dixFreeRegistry(void) void dixResetRegistry(void) { +#ifdef X_REGISTRY_REQUEST ExtensionEntry extEntry; +#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 */ + memset(&extEntry, 0, sizeof(extEntry)); + extEntry.name = CORE; + RegisterExtensionNames(&extEntry); +#endif + +#ifdef X_REGISTRY_RESOURCE /* Add built-in resources */ RegisterResourceName(RT_NONE, "NONE"); RegisterResourceName(RT_WINDOW, "WINDOW"); @@ -344,11 +374,5 @@ dixResetRegistry(void) RegisterResourceName(RT_CMAPENTRY, "COLORMAP ENTRY"); RegisterResourceName(RT_OTHERCLIENT, "OTHER CLIENT"); RegisterResourceName(RT_PASSIVEGRAB, "PASSIVE GRAB"); - - /* Add the core protocol */ - memset(&extEntry, 0, sizeof(extEntry)); - extEntry.name = CORE; - RegisterExtensionNames(&extEntry); +#endif } - -#endif /* XREGISTRY */ |