[PATCH 2/4] dix: Add reverse resource name lookup function to registry.
Rami Ylimäki
rami.ylimaki at vincit.fi
Thu Oct 28 03:23:42 PDT 2010
Currently only some pre-defined resource types can be accessed from
headers. Make it possible to find out types of new resources that
aren't pre-defined but need to be registered separately.
Signed-off-by: Rami Ylimäki <rami.ylimaki at vincit.fi>
---
dix/registry.c | 10 ++++++++++
include/registry.h | 6 ++++++
2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/dix/registry.c b/dix/registry.c
index fc35dbb..15f85cc 100644
--- a/dix/registry.c
+++ b/dix/registry.c
@@ -273,6 +273,16 @@ LookupResourceName(RESTYPE resource)
return resources[resource] ? resources[resource] : XREGISTRY_UNKNOWN;
}
+RESTYPE
+LookupResourceType(const char *name)
+{
+ RESTYPE resource = nresource;
+ while (--resource > 0)
+ if (resources[resource] && !strcmp(resources[resource], name))
+ return resource;
+ return RT_NONE;
+}
+
/*
* Setup and teardown
*/
diff --git a/include/registry.h b/include/registry.h
index 325f765..99a3e65 100644
--- a/include/registry.h
+++ b/include/registry.h
@@ -41,6 +41,11 @@ extern _X_EXPORT const char *LookupErrorName(int error);
extern _X_EXPORT const char *LookupResourceName(RESTYPE rtype);
/*
+ * Reverse lookup functions.
+ */
+extern _X_EXPORT RESTYPE LookupResourceType(const char *name);
+
+/*
* Setup and teardown
*/
extern _X_EXPORT void dixResetRegistry(void);
@@ -57,6 +62,7 @@ extern _X_EXPORT void dixResetRegistry(void);
#define LookupEventName(a) XREGISTRY_UNKNOWN
#define LookupErrorName(a) XREGISTRY_UNKNOWN
#define LookupResourceName(a) XREGISTRY_UNKNOWN
+#define LookupResourceType(a) RT_NONE
#define dixResetRegistry() { ; }
--
1.6.3.3
More information about the xorg-devel
mailing list