vacman_controller 0.1.2 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/vacman_controller/vacman_controller.c +26 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 718f0e9098056c9546ccd49309c2aef13b8fd1da
|
4
|
+
data.tar.gz: a10a4e19da9752526d224b01440506c3e93244f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f54254895c1d350a44bcbbb2dfd327f20429e51b1bc3cec0b7ae7eadf5e8c9e0c2775bc8f6c5f0c4d1f9b89fea7d53bf6b4737a52e53293efe46a5d8093dc09
|
7
|
+
data.tar.gz: eb7ebc7004676464142abd4220193f1e05de741925918a418c40ff76fb8d53f45a30a84a48f10c46fa88f50b4a098faeecf20658f9421143f6d0c6d26fc9737e
|
@@ -18,12 +18,33 @@ static void vacman_raise_error(const char* method, int error_code) {
|
|
18
18
|
/*
|
19
19
|
* convert a ruby hash to TDigipassBlob structure
|
20
20
|
*/
|
21
|
+
static VALUE rbhash_get_key(VALUE token, const char *property, int type) {
|
22
|
+
VALUE ret = rb_hash_aref(token, rb_str_new2(property));
|
23
|
+
|
24
|
+
if (ret == Qnil) {
|
25
|
+
rb_raise(e_vacmanerror, "invalid token object given: %s property is nil", property);
|
26
|
+
return Qnil;
|
27
|
+
}
|
28
|
+
|
29
|
+
if (!RB_TYPE_P(ret, type)) {
|
30
|
+
rb_raise(e_vacmanerror, "invalid token object given: %s property is not of the correct type", property);
|
31
|
+
return Qnil;
|
32
|
+
}
|
33
|
+
|
34
|
+
return ret;
|
35
|
+
}
|
36
|
+
|
21
37
|
static void rbhash_to_digipass(VALUE token, TDigipassBlob* dpdata) {
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
38
|
+
if (!RB_TYPE_P(token, T_HASH)) {
|
39
|
+
rb_raise(e_vacmanerror, "invalid token object given, requires an hash");
|
40
|
+
return;
|
41
|
+
}
|
42
|
+
|
43
|
+
VALUE blob = rbhash_get_key(token, "blob", T_STRING);
|
44
|
+
VALUE serial = rbhash_get_key(token, "serial", T_STRING);
|
45
|
+
VALUE app_name = rbhash_get_key(token, "app_name", T_STRING);
|
46
|
+
VALUE flag1 = rbhash_get_key(token, "flags1", T_FIXNUM);
|
47
|
+
VALUE flag2 = rbhash_get_key(token, "flags2", T_FIXNUM);
|
27
48
|
|
28
49
|
memset(dpdata, 0, sizeof(*dpdata));
|
29
50
|
|