diff options
author | Pali Rohár <pali.rohar@gmail.com> | 2012-08-08 18:10:53 +0200 |
---|---|---|
committer | Pali Rohár <pali.rohar@gmail.com> | 2012-08-08 18:10:53 +0200 |
commit | b5828692080d87255f5b12424cc205654f0240b2 (patch) | |
tree | 27af833aaad9d9d675247d8c35bb8c1549e8fc64 /src | |
parent | dd2c6b7f18fc4a26c950e09c47af76eeb894cd68 (diff) | |
download | 0xFFFF-b5828692080d87255f5b12424cc205654f0240b2.tar.bz2 |
Added enum DEVICE_COUNT and IMAGE_COUNT, Added function device_to_long_string
Diffstat (limited to 'src')
-rw-r--r-- | src/device.c | 19 | ||||
-rw-r--r-- | src/device.h | 2 | ||||
-rw-r--r-- | src/image.c | 2 | ||||
-rw-r--r-- | src/image.h | 1 | ||||
-rw-r--r-- | src/usb_device.h | 2 |
5 files changed, 23 insertions, 3 deletions
diff --git a/src/device.c b/src/device.c index 20b491e..bc319c6 100644 --- a/src/device.c +++ b/src/device.c @@ -48,9 +48,26 @@ enum device device_from_string(const char * device) { const char * device_to_string(enum device device) { - if ( device > sizeof(devices) ) + if ( device > sizeof(devices)/sizeof(devices[0]) ) return NULL; return devices[device]; } + +static const char * long_devices[] = { + [DEVICE_SU_18] = "Nokia 770", + [DEVICE_RX_34] = "Nokia N800", + [DEVICE_RX_44] = "Nokia N810", + [DEVICE_RX_48] = "Nokia N810 Wimax", + [DEVICE_RX_51] = "Nokia N900", +}; + +const char * device_to_long_string(enum device device) { + + if ( device > sizeof(long_devices)/sizeof(long_devices[0]) ) + return NULL; + + return long_devices[device]; + +} diff --git a/src/device.h b/src/device.h index 4b69f1e..0410494 100644 --- a/src/device.h +++ b/src/device.h @@ -28,9 +28,11 @@ enum device { DEVICE_RX_44, /* Nokia N810 */ DEVICE_RX_48, /* Nokia N810 WiMax */ DEVICE_RX_51, /* Nokia N900 */ + DEVICE_COUNT, }; enum device device_from_string(const char * device); const char * device_to_string(enum device device); +const char * device_to_long_string(enum device device); #endif diff --git a/src/image.c b/src/image.c index a26a172..b5a7576 100644 --- a/src/image.c +++ b/src/image.c @@ -467,7 +467,7 @@ enum image_type image_type_from_string(const char * type) { const char * image_type_to_string(enum image_type type) { - if ( type > sizeof(image_types) ) + if ( type > sizeof(image_types)/sizeof(image_types[0]) ) return NULL; return image_types[type]; diff --git a/src/image.h b/src/image.h index 054e2bc..a16852e 100644 --- a/src/image.h +++ b/src/image.h @@ -38,6 +38,7 @@ enum image_type { IMAGE_CMT_2ND, IMAGE_CMT_ALGO, IMAGE_CMT_MCUSW, + IMAGE_COUNT, }; struct image { diff --git a/src/usb_device.h b/src/usb_device.h index 078ff52..ec4f967 100644 --- a/src/usb_device.h +++ b/src/usb_device.h @@ -36,7 +36,7 @@ struct usb_flash_device { int alternate; int configuration; enum usb_flash_protocol protocol; - enum device devices[10]; + enum device devices[DEVICE_COUNT]; }; struct usb_device_info { |