aboutsummaryrefslogtreecommitdiff
path: root/tinymix.c
diff options
context:
space:
mode:
authorSimon Wilson <ksattic@gmail.com>2014-05-07 06:17:44 -0700
committerSimon Wilson <ksattic@gmail.com>2014-05-07 06:19:53 -0700
commitb5e7b91658baf8f27a1582efd63dd223f79e0e5d (patch)
treeb0623cf84d689e2b9d70bcf2f15b1acd063a32d6 /tinymix.c
parent867920ca46cc8ddc726bc0d406c454c17b7b9262 (diff)
parent8b772cc507f4c3a3b2ce5ca8a2cebbc60d1fa684 (diff)
Merge branch 'master' of git://github.com/charleskeepax/tinyalsa into charleskeepax-master
Conflicts: tinymix.c
Diffstat (limited to 'tinymix.c')
-rw-r--r--tinymix.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/tinymix.c b/tinymix.c
index 68f9495..fa3defc 100644
--- a/tinymix.c
+++ b/tinymix.c
@@ -32,6 +32,8 @@
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
+#include <limits.h>
+#include <errno.h>
static void tinymix_list_controls(struct mixer *mixer);
static void tinymix_detail_control(struct mixer *mixer, const char *control,
@@ -233,6 +235,20 @@ static void tinymix_set_byte_ctl(struct mixer_ctl *ctl, const char *control,
}
}
+static int is_int(char *value)
+{
+ char* end;
+ long int result;
+
+ errno = 0;
+ result = strtol(value, &end, 10);
+
+ if (result == LONG_MIN || result == LONG_MAX)
+ return 0;
+
+ return errno == 0 && *end == '\0';
+}
+
static void tinymix_set_value(struct mixer *mixer, const char *control,
char **values, unsigned int num_values)
{
@@ -259,7 +275,7 @@ static void tinymix_set_value(struct mixer *mixer, const char *control,
return;
}
- if (isdigit(values[0][0])) {
+ if (is_int(values[0])) {
if (num_values == 1) {
/* Set all values the same */
int value = atoi(values[0]);