summaryrefslogtreecommitdiffstats
path: root/input/storage.c
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2007-06-22 17:11:10 +0000
committerClaudio Takahasi <claudio.takahasi@openbossa.org>2007-06-22 17:11:10 +0000
commit0762886602369f99a473dc95cc288def7b6e363c (patch)
tree16420e1e3d6c823d59c1711b547025a89db7155f /input/storage.c
parent51386028973220d84b6a7e59735fa1fce98621b3 (diff)
input: convert hidd to input
Diffstat (limited to 'input/storage.c')
-rw-r--r--input/storage.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/input/storage.c b/input/storage.c
index 3793a275..7da536b3 100644
--- a/input/storage.c
+++ b/input/storage.c
@@ -59,6 +59,48 @@ static inline int create_filename(char *buf, size_t size,
return create_name(buf, size, STORAGEDIR, addr, name);
}
+int parse_stored_hidd(const char *str, struct hidp_connadd_req *req)
+{
+ char tmp[3];
+ char *desc;
+ unsigned int vendor, product, version, subclass, country, parser, pos;
+ int i;
+
+ desc = malloc(4096);
+ if (!desc)
+ return -ENOMEM;
+
+ memset(desc, 0, 4096);
+
+ sscanf(str, "%04X:%04X:%04X %02X %02X %04X %4095s %08X %n",
+ &vendor, &product, &version, &subclass, &country,
+ &parser, desc, &req->flags, &pos);
+
+ req->vendor = vendor;
+ req->product = product;
+ req->version = version;
+ req->subclass = subclass;
+ req->country = country;
+ req->parser = parser;
+
+ req->rd_size = strlen(desc) / 2;
+ req->rd_data = g_try_malloc0(req->rd_size);
+ if (!req->rd_data) {
+ g_free(desc);
+ return -ENOMEM;
+ }
+
+ memset(tmp, 0, sizeof(tmp));
+ for (i = 0; i < req->rd_size; i++) {
+ memcpy(tmp, desc + (i * 2), 2);
+ req->rd_data[i] = (uint8_t) strtol(tmp, NULL, 16);
+ }
+
+ g_free(desc);
+
+ return 0;
+}
+
int parse_stored_device_info(const char *str, struct hidp_connadd_req *req)
{
char tmp[3];