]> err.no Git - yubikey-personalization.old/commitdiff
Add functions to set more fields in the configuration structure. Implement the simpl...
authorRichard Levitte <levitte@lp.se>
Thu, 16 Oct 2008 14:46:45 +0000 (14:46 +0000)
committerRichard Levitte <levitte@lp.se>
Thu, 16 Oct 2008 14:46:45 +0000 (14:46 +0000)
ykpers.c
ykpers.h

index 1e56e15f99fcd2e8a2a4655c5c0e5397632ab185..8716c7539235b91027893f00eb8a9a26c20f4107 100644 (file)
--- a/ykpers.c
+++ b/ykpers.c
@@ -151,6 +151,49 @@ int ykp_set_access_code(CONFIG *cfg, unsigned char *access_code)
        return 0;
 }
 
+#define def_set_tktflag(type)                                  \
+int ykp_set_tktflag_ ## type(CONFIG *cfg, bool state)          \
+{                                                              \
+       if (cfg) {                                              \
+               if (state)                                      \
+                       cfg->tktFlags |= TKTFLAG_ ## type;      \
+               else                                            \
+                       cfg->tktFlags &= ~TKTFLAG_ ## type;     \
+               return 1;                                       \
+       }                                                       \
+       ykp_errno = YKP_ENOCFG;                                 \
+       return 0;                                               \
+}
+
+#define def_set_cfgflag(type)                                  \
+int ykp_set_cfgflag_ ## type(CONFIG *cfg, bool state)          \
+{                                                              \
+       if (cfg) {                                              \
+               if (state)                                      \
+                       cfg->cfgFlags |= CFGFLAG_ ## type;      \
+               else                                            \
+                       cfg->cfgFlags &= ~CFGFLAG_ ## type;     \
+               return 1;                                       \
+       }                                                       \
+       ykp_errno = YKP_ENOCFG;                                 \
+       return 0;                                               \
+}
+
+def_set_tktflag(TAB_FIRST)
+def_set_tktflag(APPEND_TAB1)
+def_set_tktflag(APPEND_TAB2)
+def_set_tktflag(APPEND_DELAY1)
+def_set_tktflag(APPEND_DELAY2)
+def_set_tktflag(APPEND_CR)
+
+def_set_cfgflag(SEND_REF)
+def_set_cfgflag(TICKET_FIRST)
+def_set_cfgflag(PACING_10MS)
+def_set_cfgflag(PACING_20MS)
+def_set_cfgflag(ALLOW_HIDTRIG)
+def_set_cfgflag(STATIC_TICKET)
+
+
 const char str_key_value_separator[] = ":";
 const char str_fixed[] = "fixed";
 const char str_uid[] = "uid";
@@ -288,7 +331,8 @@ int * const _ykp_errno_location(void)
 
 static const char *errtext[] = {
        "",
-       "not yet implemented"
+       "not yet implemented",
+       "no configuration structure given"
 };
 const char *ykp_strerror(int errnum)
 {
index 6f90571816c8eea9283232c42ac43893f1d87d3b..ff8e1df0405acb75593514e12d62e416df5695a9 100644 (file)
--- a/ykpers.h
+++ b/ykpers.h
@@ -39,6 +39,22 @@ int ykp_free_config(CONFIG *cfg);
 int ykp_AES_key_from_passphrase(CONFIG *cfg, const char *passphrase,
                                const char *salt);
 int ykp_set_access_code(CONFIG *cfg, unsigned char *access_code);
+int ykp_set_fixed(CONFIG *cfg, unsigned char *fixed);
+int ykp_set_uid(CONFIG *cfg, unsigned char *uid);
+
+int ykp_set_tktflag_TAB_FIRST(CONFIG *cfg, bool state);
+int ykp_set_tktflag_APPEND_TAB1(CONFIG *cfg, bool state);
+int ykp_set_tktflag_APPEND_TAB2(CONFIG *cfg, bool state);
+int ykp_set_tktflag_APPEND_DELAY1(CONFIG *cfg, bool state);
+int ykp_set_tktflag_APPEND_DELAY2(CONFIG *cfg, bool state);
+int ykp_set_tktflag_APPEND_CR(CONFIG *cfg, bool state);
+
+int ykp_set_cfgflag_SEND_REF(CONFIG *cfg, bool state);
+int ykp_set_cfgflag_TICKET_FIRST(CONFIG *cfg, bool state);
+int ykp_set_cfgflag_PACING_10MS(CONFIG *cfg, bool state);
+int ykp_set_cfgflag_PACING_20MS(CONFIG *cfg, bool state);
+int ykp_set_cfgflag_ALLOW_HIDTRIG(CONFIG *cfg, bool state);
+int ykp_set_cfgflag_STATIC_TICKET(CONFIG *cfg, bool state);
 
 int ykp_write_config(const CONFIG *cfg,
                     int (*writer)(const char *buf, size_t count,
@@ -54,5 +70,6 @@ extern int * const _ykp_errno_location(void);
 const char *ykp_strerror(int errnum);
 
 #define YKP_ENOTYETIMPL        0x01
+#define YKP_ENOCFG     0x02
 
 #endif // __YKPERS_H_INCLUDED__