libaacs | branch: master | npzacs <[email protected]> | Tue May 1 21:51:17 2012 +0300| [fdef27fb3ce9186b4b5b50de6a4751788bfc65ac] | committer: npzacs
Moved _load_config() to keydbcfg.c > http://git.videolan.org/gitweb.cgi/libaacs.git/?a=commit;h=fdef27fb3ce9186b4b5b50de6a4751788bfc65ac --- src/file/keydbcfg.c | 40 +++++++++++++++++++++++++++++++++++++--- src/file/keydbcfg.h | 4 +--- src/libaacs/aacs.c | 38 +++----------------------------------- 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/file/keydbcfg.c b/src/file/keydbcfg.c index 08d9162..115a241 100644 --- a/src/file/keydbcfg.c +++ b/src/file/keydbcfg.c @@ -244,7 +244,7 @@ static int _parse_cert_file(config_file *cf, FILE *fp) return result; } -int keydbcfg_load_pk_file(config_file *cf) +static int _load_pk_file(config_file *cf) { static const char pk_file_name[] = PK_FILE_NAME; FILE *fp; @@ -265,7 +265,7 @@ int keydbcfg_load_pk_file(config_file *cf) return result; } -int keydbcfg_load_cert_file(config_file *cf) +static int _load_cert_file(config_file *cf) { static const char cert_file_name[] = CERT_FILE_NAME; FILE *fp; @@ -402,7 +402,7 @@ int keycache_find(const char *type, const uint8_t *disc_id, uint8_t *key, unsign return result; } -char *keydbcfg_find_config_file(void) +static char *_find_config_file(void) { static const char cfg_file_name[] = CFG_FILE_NAME; @@ -422,3 +422,37 @@ char *keydbcfg_find_config_file(void) return cfg_file; } +config_file *keydbcfg_config_load(const char *configfile_path) +{ + int config_ok = 0; + + config_file *cf = keydbcfg_new_config_file(); + + /* try to load KEYDB.cfg */ + + if (configfile_path) { + config_ok = keydbcfg_parse_config(cf, configfile_path); + + } else { + /* If no configfile path given, check for config files in user's home or + * under /etc. + */ + char *cfgfile = _find_config_file(); + config_ok = keydbcfg_parse_config(cf, cfgfile); + X_FREE(cfgfile); + } + + /* Try to load simple (aacskeys) config files */ + + config_ok = _load_pk_file(cf) || config_ok; + config_ok = _load_cert_file(cf) || config_ok; + + if (!config_ok) { + DEBUG(DBG_AACS | DBG_CRIT, "No valid AACS configuration files found\n"); + keydbcfg_config_file_close(cf); + return NULL; + } + + return cf; +} + diff --git a/src/file/keydbcfg.h b/src/file/keydbcfg.h index b71a2fa..249186c 100644 --- a/src/file/keydbcfg.h +++ b/src/file/keydbcfg.h @@ -118,9 +118,7 @@ AACS_PRIVATE int keydbcfg_config_file_close(config_file *cfgfile); /* */ -AACS_PRIVATE char *keydbcfg_find_config_file(void); -AACS_PRIVATE int keydbcfg_load_cert_file(config_file *cf); -AACS_PRIVATE int keydbcfg_load_pk_file(config_file *cf); +AACS_PRIVATE config_file *keydbcfg_config_load(const char *configfile_path); AACS_PRIVATE int keycache_save(const char *type, const uint8_t *disc_id, const uint8_t *key, unsigned int len); diff --git a/src/libaacs/aacs.c b/src/libaacs/aacs.c index fc0a688..e9ee7ac 100644 --- a/src/libaacs/aacs.c +++ b/src/libaacs/aacs.c @@ -596,39 +596,6 @@ static int _decrypt_unit(AACS *aacs, uint8_t *out_buf, const uint8_t *in_buf, ui return 0; } -static int _load_config(AACS *aacs, const char *configfile_path) -{ - int config_ok = 0; - - aacs->cf = keydbcfg_new_config_file(); - - /* try to load KEYDB.cfg */ - - if (configfile_path) { - config_ok = keydbcfg_parse_config(aacs->cf, configfile_path); - - } else { - /* If no configfile path given, check for config files in user's home or - * under /etc. - */ - char *cfgfile = keydbcfg_find_config_file(); - config_ok = keydbcfg_parse_config(aacs->cf, cfgfile); - X_FREE(cfgfile); - } - - /* Try to load simple (aacskeys) config files */ - - config_ok = keydbcfg_load_pk_file(aacs->cf) || config_ok; - config_ok = keydbcfg_load_cert_file(aacs->cf) || config_ok; - - if (!config_ok) { - DEBUG(DBG_AACS | DBG_CRIT, "No valid AACS configuration files found\n"); - return AACS_ERROR_NO_CONFIG; - } - - return AACS_SUCCESS; -} - void aacs_get_version(int *major, int *minor, int *micro) { *major = AACS_VERSION_MAJOR; @@ -663,9 +630,10 @@ AACS *aacs_open2(const char *path, const char *configfile_path, int *error_code) AACS *aacs = calloc(1, sizeof(AACS)); - *error_code = _load_config(aacs, configfile_path); - if (*error_code != AACS_SUCCESS) { + aacs->cf = keydbcfg_config_load(configfile_path); + if (!aacs->cf) { aacs_close(aacs); + *error_code = AACS_ERROR_NO_CONFIG; return NULL; } _______________________________________________ libaacs-devel mailing list [email protected] http://mailman.videolan.org/listinfo/libaacs-devel
