summaryrefslogtreecommitdiff
path: root/apps/misc.c
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2010-07-29 12:37:48 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2010-07-29 12:37:48 +0000
commit2d31d77a8ba231cb03ec35863c4c4ce2024f6509 (patch)
treeb85ca1bede3e83695619064ee9a323f0a8da1865 /apps/misc.c
parente436483b66a931fef6436e9cd3e69eb2b3ff1f7b (diff)
downloadrockbox-2d31d77a8ba231cb03ec35863c4c4ce2024f6509.zip
rockbox-2d31d77a8ba231cb03ec35863c4c4ce2024f6509.tar.gz
rockbox-2d31d77a8ba231cb03ec35863c4c4ce2024f6509.tar.bz2
rockbox-2d31d77a8ba231cb03ec35863c4c4ce2024f6509.tar.xz
FS#11470 - new skin code, finally svn uses the new parser from the theme editor. This means that a skin that passes the editor WILL pass svn and checkwps (unless the target runs out of skin buffer or something.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27613 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/misc.c')
-rw-r--r--apps/misc.c135
1 files changed, 8 insertions, 127 deletions
diff --git a/apps/misc.c b/apps/misc.c
index bae8dfb..c378133 100644
--- a/apps/misc.c
+++ b/apps/misc.c
@@ -937,142 +937,23 @@ int hex_to_rgb(const char* hex, int* color)
#endif /* HAVE_LCD_COLOR */
#ifdef HAVE_LCD_BITMAP
-/* A simplified scanf - used (at time of writing) by wps parsing functions.
-
- fmt - char array specifying the format of each list option. Valid values
- are: d - int
- s - string (sets pointer to string, without copying)
- c - hex colour (RGB888 - e.g. ff00ff)
- g - greyscale "colour" (0-3)
- set_vals - if not NULL 1 is set in the bitplace if the item was read OK
- 0 if not read.
- first item is LSB, (max 32 items! )
- Stops parseing if an item is invalid unless the item == '-'
- sep - list separator (e.g. ',' or '|')
- str - string to parse, must be terminated by 0 or sep
- ... - pointers to store the parsed values
-
- return value - pointer to char after parsed data, 0 if there was an error.
-
-*/
-
/* '0'-'3' are ASCII 0x30 to 0x33 */
#define is0123(x) (((x) & 0xfc) == 0x30)
-const char* parse_list(const char *fmt, uint32_t *set_vals,
- const char sep, const char* str, ...)
+bool parse_color(char *text, int *value)
{
- va_list ap;
- const char* p = str, *f = fmt;
- const char** s;
- int* d;
- bool set, is_negative;
- int i=0;
-
- va_start(ap, str);
- if (set_vals)
- *set_vals = 0;
- while (*fmt)
- {
- /* Check for separator, if we're not at the start */
- if (f != fmt)
- {
- if (*p != sep)
- goto err;
- p++;
- }
- set = false;
- switch (*fmt++)
- {
- case 's': /* string - return a pointer to it (not a copy) */
- s = va_arg(ap, const char **);
-
- *s = p;
- while (*p && *p != sep && *p != ')')
- p++;
- set = (s[0][0]!='-') && (s[0][1]!=sep && s[0][1]!=')') ;
- break;
-
- case 'd': /* int */
- is_negative = false;
- d = va_arg(ap, int*);
-
- if (*p == '-' && isdigit(*(p+1)))
- {
- is_negative = true;
- p++;
- }
- if (!isdigit(*p))
- {
- if (!set_vals || *p != '-')
- goto err;
- p++;
- }
- else
- {
- *d = *p++ - '0';
- while (isdigit(*p))
- *d = (*d * 10) + (*p++ - '0');
- set = true;
- if (is_negative)
- *d *= -1;
- }
-
- break;
-
+ (void)text; (void)value; /* silence warnings on mono bitmap */
#ifdef HAVE_LCD_COLOR
- case 'c': /* colour (rrggbb - e.g. f3c1a8) */
- d = va_arg(ap, int*);
-
- if (hex_to_rgb(p, d) < 0)
- {
- if (!set_vals || *p != '-')
- goto err;
- p++;
- }
- else
- {
- p += 6;
- set = true;
- }
-
- break;
+ if (hex_to_rgb(text, value) < 0)
+ return false;
#endif
#if LCD_DEPTH == 2 || (defined(HAVE_REMOTE_LCD) && LCD_REMOTE_DEPTH == 2)
- case 'g': /* greyscale colour (0-3) */
- d = va_arg(ap, int*);
-
- if (!is0123(*p))
- {
- if (!set_vals || *p != '-')
- goto err;
- p++;
- }
- else
- {
- *d = *p++ - '0';
- set = true;
- }
-
- break;
+ if (!is0123(*text))
+ return false;
+ *value = *text - '0';
#endif
-
- default: /* Unknown format type */
- goto err;
- break;
- }
- if (set_vals && set)
- *set_vals |= BIT_N(i);
- i++;
- }
-
- va_end(ap);
- return p;
-
-err:
- va_end(ap);
- return NULL;
+ return true;
}
/* only used in USB HID and set_time screen */