summaryrefslogtreecommitdiffstats
path: root/src/device.c
diff options
context:
space:
mode:
authorPali Rohár <pali.rohar@gmail.com>2012-08-07 16:57:55 +0200
committerPali Rohár <pali.rohar@gmail.com>2012-08-07 16:57:55 +0200
commit03eeca994daf1cbc78065de75ab182a5f3d17832 (patch)
treee6689f3a46f9ff61c39dd848e7b15947c340579a /src/device.c
parentb596e979266e71223d2e885625f1eee688dbe3d9 (diff)
download0xFFFF-03eeca994daf1cbc78065de75ab182a5f3d17832.tar.bz2
Added new files device.c and device.h
Diffstat (limited to 'src/device.c')
-rw-r--r--src/device.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/device.c b/src/device.c
new file mode 100644
index 0000000..d7b10f9
--- /dev/null
+++ b/src/device.c
@@ -0,0 +1,39 @@
+
+
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+
+#include "device.h"
+
+static const char * devices[] = {
+ [DEVICE_SU_18] = "SU-18",
+ [DEVICE_RX_34] = "RX-34",
+ [DEVICE_RX_44] = "RX-44",
+ [DEVICE_RX_48] = "RX-48",
+ [DEVICE_RX_51] = "RX-51",
+};
+
+enum device device_from_string(const char * device) {
+
+ size_t i;
+
+ if ( ! device )
+ return DEVICE_ANY;
+
+ for ( i = 0; i < sizeof(devices)/sizeof(devices[0]); ++i )
+ if ( devices[i] && strcmp(devices[i], device) == 0 )
+ return i;
+
+ return DEVICE_UNKNOWN;
+
+}
+
+const char * device_to_string(enum device device) {
+
+ if ( device > sizeof(devices) )
+ return NULL;
+
+ return devices[device];
+
+}