From: Richard Levitte Date: Thu, 16 Oct 2008 14:46:45 +0000 (+0000) Subject: Add functions to set more fields in the configuration structure. Implement the simpl... X-Git-Tag: yubikey-personalisation_1.3.5-1~4^2~192 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3ea3d9a712ba7a3caed3d2cca23e306aa7218084;p=yubikey-personalization.old Add functions to set more fields in the configuration structure. Implement the simple ones for now --- diff --git a/ykpers.c b/ykpers.c index 1e56e15..8716c75 100644 --- 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) { diff --git a/ykpers.h b/ykpers.h index 6f90571..ff8e1df 100644 --- 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__