diff options
author | marha <marha@users.sourceforge.net> | 2010-05-26 08:58:03 +0000 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2010-05-26 08:58:03 +0000 |
commit | e60ed91097aa7511581b6c53b9e4b14aaf1027b5 (patch) | |
tree | c8ce06db36103141858e95febad857ca989e7ad0 /xorg-server/dix/inpututils.c | |
parent | fb91c8589937f1a9aba5d5a4e0de98c381dfe9b8 (diff) | |
parent | fade1b113f18f3fd26c3c01ca4543effa80b9b62 (diff) | |
download | vcxsrv-e60ed91097aa7511581b6c53b9e4b14aaf1027b5.tar.gz vcxsrv-e60ed91097aa7511581b6c53b9e4b14aaf1027b5.tar.bz2 vcxsrv-e60ed91097aa7511581b6c53b9e4b14aaf1027b5.zip |
svn merge ^/branches/released .
Diffstat (limited to 'xorg-server/dix/inpututils.c')
-rw-r--r-- | xorg-server/dix/inpututils.c | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/xorg-server/dix/inpututils.c b/xorg-server/dix/inpututils.c index d2d36bd95..0ad709a16 100644 --- a/xorg-server/dix/inpututils.c +++ b/xorg-server/dix/inpututils.c @@ -35,6 +35,9 @@ #include "xace.h"
#include "xkbsrv.h"
#include "xkbstr.h"
+#ifdef _MSC_VER
+#define strdup _strdup
+#endif
/* Check if a button map change is okay with the device.
* Returns -1 for BadValue, as it collides with MappingBusy. */
@@ -331,3 +334,82 @@ int generate_modkeymap(ClientPtr client, DeviceIntPtr dev, return Success;
}
+
+/**
+ * Duplicate the InputAttributes in the most obvious way.
+ * No special memory handling is used to give drivers the maximum
+ * flexibility with the data. Drivers should be able to call realloc on the
+ * product string if needed and perform similar operations.
+ */
+InputAttributes*
+DuplicateInputAttributes(InputAttributes *attrs)
+{
+ InputAttributes *new_attr;
+ int ntags = 0;
+ char **tags, **new_tags;
+
+ if (!attrs)
+ return NULL;
+
+ if (!(new_attr = calloc(1, sizeof(InputAttributes))))
+ goto unwind;
+
+ if (attrs->product && !(new_attr->product = strdup(attrs->product)))
+ goto unwind;
+ if (attrs->vendor && !(new_attr->vendor = strdup(attrs->vendor)))
+ goto unwind;
+ if (attrs->device && !(new_attr->device = strdup(attrs->device)))
+ goto unwind;
+
+ new_attr->flags = attrs->flags;
+
+ if ((tags = attrs->tags))
+ {
+ while(*tags++)
+ ntags++;
+
+ new_attr->tags = calloc(ntags + 1, sizeof(char*));
+ if (!new_attr->tags)
+ goto unwind;
+
+ tags = attrs->tags;
+ new_tags = new_attr->tags;
+
+ while(*tags)
+ {
+ *new_tags = strdup(*tags);
+ if (!*new_tags)
+ goto unwind;
+
+ tags++;
+ new_tags++;
+ }
+ }
+
+ return new_attr;
+
+unwind:
+ FreeInputAttributes(new_attr);
+ return NULL;
+}
+
+void
+FreeInputAttributes(InputAttributes *attrs)
+{
+ char **tags;
+
+ if (!attrs)
+ return;
+
+ free(attrs->product);
+ free(attrs->vendor);
+ free(attrs->device);
+
+ if ((tags = attrs->tags))
+ while(*tags)
+ free(*tags++);
+
+ free(attrs->tags);
+ free(attrs);
+}
+
|