aboutsummaryrefslogtreecommitdiff
path: root/osc.lv2
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2017-05-10 22:58:09 +0200
committerHanspeter Portner <dev@open-music-kontrollers.ch>2017-05-10 22:58:09 +0200
commite9316bc2e11b88365aabf478c546f53b8af458ee (patch)
treea978cd6dbaeaf0f5245f5bc843791e1344862f7e /osc.lv2
parentbff22accc7b733fba3902454d6982c57b4fed802 (diff)
downloadsherlock.lv2-e9316bc2e11b88365aabf478c546f53b8af458ee.tar.xz
get rid of sscanf.
Diffstat (limited to 'osc.lv2')
-rw-r--r--osc.lv2/util.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/osc.lv2/util.h b/osc.lv2/util.h
index 12a1af1..a026e21 100644
--- a/osc.lv2/util.h
+++ b/osc.lv2/util.h
@@ -22,6 +22,7 @@
#include <ctype.h>
#include <inttypes.h>
#include <stdio.h>
+#include <stdlib.h>
#include <osc.lv2/osc.h>
@@ -347,7 +348,20 @@ lv2_osc_rgba_get(LV2_OSC_URID *osc_urid, const LV2_Atom *atom,
{
assert(r && g && b && a);
const char *str = LV2_ATOM_CONTENTS_CONST(LV2_Atom_Literal, atom);
- sscanf(str, "%02"SCNx8"%02"SCNx8"%02"SCNx8"%02"SCNx8, r, g, b, a);
+
+ uint8_t *key [4] = {
+ r, g, b, a
+ };
+
+ const char *pos = str;
+ char *endptr;
+
+ for(unsigned count = 0; count < 4; count++, pos += 2)
+ {
+ char buf [5] = {'0', 'x', pos[0], pos[1], '\0'};
+
+ *key[count] = strtol(buf, &endptr, 16);
+ }
return lv2_atom_tuple_next(atom);
}