]> err.no Git - yubikey-personalization/commitdiff
add MODE_ALL instead of letting 0 mean all
authorKlas Lindfors <klas@yubico.com>
Mon, 15 Apr 2013 06:44:21 +0000 (08:44 +0200)
committerKlas Lindfors <klas@yubico.com>
Mon, 15 Apr 2013 06:44:21 +0000 (08:44 +0200)
ykpers-json.c
ykpers.c
ykpers_lcl.c
ykpers_lcl.h

index d114464e09cdeb20775255abe42e803209c65b55..dc5c569d53f21023263c0030139e24c4c9c5a809 100644 (file)
@@ -127,7 +127,7 @@ int ykp_json_export_cfg(const YKP_CONFIG *cfg, char *json, size_t len) {
                        if(!p->json_text) {
                                continue;
                        }
-                       if(!p->mode || (p->mode && (mode & p->mode) == mode)) {
+                       if(p->mode && (mode & p->mode) == mode) {
                                int set = (ycfg.tktFlags & p->flag) == p->flag;
                                json_object *jsetting = json_object_new_boolean(set);
                                json_object_object_add(options_json, p->json_text, jsetting);
@@ -138,7 +138,7 @@ int ykp_json_export_cfg(const YKP_CONFIG *cfg, char *json, size_t len) {
                        if(!p->json_text) {
                                continue;
                        }
-                       if(!p->mode || (p->mode && (mode & p->mode) == mode)) {
+                       if(p->mode && (mode & p->mode) == mode) {
                                int set = (ycfg.cfgFlags & p->flag) == p->flag;
                                json_object *jsetting = json_object_new_boolean(set);
                                json_object_object_add(options_json, p->json_text, jsetting);
@@ -149,7 +149,7 @@ int ykp_json_export_cfg(const YKP_CONFIG *cfg, char *json, size_t len) {
                        if(!p->json_text) {
                                continue;
                        }
-                       if(!p->mode || (p->mode && (mode & p->mode) == mode)) {
+                       if(p->mode && (mode & p->mode) == mode) {
                                int set = (ycfg.extFlags & p->flag) == p->flag;
                                json_object *jsetting = json_object_new_boolean(set);
                                json_object_object_add(options_json, p->json_text, jsetting);
index bd8233df966b2068927056614e25a1b35028c50f..61fc16b61e51f270707df0e112c1465d4bc06f04 100644 (file)
--- a/ykpers.c
+++ b/ykpers.c
@@ -941,7 +941,7 @@ static int ykp_legacy_export_config(const YKP_CONFIG *cfg, char *buf, size_t len
                for (p = _ticket_flags_map; p->flag; p++) {
                        if ((ycfg.tktFlags & p->flag) == p->flag
                            && p->capability(cfg)
-                           && (!p->mode || (mode & p->mode) == mode)) {
+                           && (mode & p->mode) == mode) {
                                if (*buffer) {
                                        strcat(buffer, str_flags_separator);
                                        strcat(buffer, p->flag_text);
@@ -958,7 +958,7 @@ static int ykp_legacy_export_config(const YKP_CONFIG *cfg, char *buf, size_t len
                for (p = _config_flags_map; p->flag; p++) {
                        if ((t_flags & p->flag) == p->flag
                            && p->capability(cfg)
-                           && (!p->mode || (mode & p->mode) == mode)) {
+                           && (mode & p->mode) == mode) {
                                if (*buffer) {
                                        strcat(buffer, str_flags_separator);
                                        strcat(buffer, p->flag_text);
@@ -978,7 +978,7 @@ static int ykp_legacy_export_config(const YKP_CONFIG *cfg, char *buf, size_t len
                for (p = _extended_flags_map; p->flag; p++) {
                        if ((ycfg.extFlags & p->flag) == p->flag
                            && p->capability(cfg)
-                           && (!p->mode || (mode & p->mode) == mode)) {
+                           && (mode & p->mode) == mode) {
                                if (*buffer) {
                                        strcat(buffer, str_flags_separator);
                                        strcat(buffer, p->flag_text);
index 4b2f13a5351308842556ce24027734db9a7d57db..b361d957a308139a12302d3c2638aaeb94d349e6 100644 (file)
@@ -37,7 +37,7 @@ struct map_st _ticket_flags_map[] = {
        { TKTFLAG_APPEND_DELAY1,"APPEND_DELAY1","appendDelay1", capability_has_ticket_mods,     MODE_OUTPUT }, /* XXX: name? */
        { TKTFLAG_APPEND_DELAY2,"APPEND_DELAY2","appendDelay2", capability_has_ticket_mods,     MODE_OUTPUT }, /* XXX: name? */
        { TKTFLAG_APPEND_CR,    "APPEND_CR",    "appendCR",     capability_has_ticket_mods,     MODE_OUTPUT },
-       { TKTFLAG_PROTECT_CFG2, "PROTEXT_CFG2", "protectSecond",capability_has_slot_two,        0 },
+       { TKTFLAG_PROTECT_CFG2, "PROTEXT_CFG2", "protectSecond",capability_has_slot_two,        MODE_ALL },
        { TKTFLAG_OATH_HOTP,    "OATH_HOTP",    0,              capability_has_oath,            MODE_OATH_HOTP },
        { TKTFLAG_CHAL_RESP,    "CHAL_RESP",    0,              capability_has_chal_resp,       MODE_CHAL_RESP },
        { 0, 0, 0, 0, 0 }
@@ -65,14 +65,14 @@ struct map_st _config_flags_map[] = {
 };
 
 struct map_st _extended_flags_map[] = {
-       { EXTFLAG_SERIAL_BTN_VISIBLE,   "SERIAL_BTN_VISIBLE",   "serialBtnVisible",     capability_has_serial,          0 },
-       { EXTFLAG_SERIAL_USB_VISIBLE,   "SERIAL_USB_VISIBLE",   "serialUsbVisible",     capability_has_serial,          0 },
-       { EXTFLAG_SERIAL_API_VISIBLE,   "SERIAL_API_VISIBLE",   "serialApiVisible",     capability_has_serial_api,      0 },
-       { EXTFLAG_USE_NUMERIC_KEYPAD,   "USE_NUMERIC_KEYPAD",   "useNumericKeypad",     capability_has_numeric,         0 },
-       { EXTFLAG_FAST_TRIG,            "FAST_TRIG",            "fastTrig",             capability_has_fast,            0 },
-       { EXTFLAG_ALLOW_UPDATE,         "ALLOW_UPDATE",         "allowUpdate",          capability_has_update,          0 },
-       { EXTFLAG_DORMANT,              "DORMANT",              "dormant",              capability_has_dormant,         0 },
-       { EXTFLAG_LED_INV,              "LED_INV",              "ledInverted",          capability_has_led_inv,         0 },
+       { EXTFLAG_SERIAL_BTN_VISIBLE,   "SERIAL_BTN_VISIBLE",   "serialBtnVisible",     capability_has_serial,          MODE_ALL },
+       { EXTFLAG_SERIAL_USB_VISIBLE,   "SERIAL_USB_VISIBLE",   "serialUsbVisible",     capability_has_serial,          MODE_ALL },
+       { EXTFLAG_SERIAL_API_VISIBLE,   "SERIAL_API_VISIBLE",   "serialApiVisible",     capability_has_serial_api,      MODE_ALL },
+       { EXTFLAG_USE_NUMERIC_KEYPAD,   "USE_NUMERIC_KEYPAD",   "useNumericKeypad",     capability_has_numeric,         MODE_ALL },
+       { EXTFLAG_FAST_TRIG,            "FAST_TRIG",            "fastTrig",             capability_has_fast,            MODE_ALL },
+       { EXTFLAG_ALLOW_UPDATE,         "ALLOW_UPDATE",         "allowUpdate",          capability_has_update,          MODE_ALL },
+       { EXTFLAG_DORMANT,              "DORMANT",              "dormant",              capability_has_dormant,         MODE_ALL },
+       { EXTFLAG_LED_INV,              "LED_INV",              "ledInverted",          capability_has_led_inv,         MODE_ALL },
        { 0, 0, 0, 0, 0 }
 };
 
index d51922cb93edd50dec59a3c3876142d1e7a3ff99..fd531c4ec8f04f50d94eb0cf99fb2b482cbd2d0e 100644 (file)
@@ -85,6 +85,7 @@ extern struct map_st _modes_map[];
 
 #define MODE_CHAL_RESP         MODE_CHAL_YUBICO | MODE_CHAL_HMAC
 #define MODE_OUTPUT            MODE_STATIC_TICKET | MODE_OTP_YUBICO | MODE_OATH_HOTP
+#define MODE_ALL               0xff
 
 # ifdef __cplusplus
 }