[RFC] [PATCH v2 4/12] [xserver] dix: Add reverse resource name lookup function to registry.
Erkki Seppälä
erkki.seppala at vincit.fi
Fri Dec 31 05:32:42 PST 2010
From: Rami Ylimäki <rami.ylimaki at vincit.fi>
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>
Reviewed-by: Mikhail Gusarov <dottedmag at dottedmag.net>
Reviewed-by: Tiago Vignatti <tiago.vignatti at nokia.com>
---
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.7.0.4
More information about the xorg-devel
mailing list