diff options
author | Jjgod Jiang <gzjjgod@gmail.com> | 2007-11-23 18:42:18 +0000 |
---|---|---|
committer | Jjgod Jiang <gzjjgod@gmail.com> | 2007-11-23 18:42:18 +0000 |
commit | fb0a76e55e2bbb6ff31506cdb4fd9e3f63b9f665 (patch) | |
tree | 59f0b90e0520dcfae509c1325dd60b8927b23aac /Master/tlpkg/lib/C/tlp-config.c | |
parent | 77f76c0f54c796d4ca72a4b9bcd878b385c6950a (diff) |
Support config.
git-svn-id: svn://tug.org/texlive/trunk@5569 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/lib/C/tlp-config.c')
-rw-r--r-- | Master/tlpkg/lib/C/tlp-config.c | 54 |
1 files changed, 48 insertions, 6 deletions
diff --git a/Master/tlpkg/lib/C/tlp-config.c b/Master/tlpkg/lib/C/tlp-config.c index aa164dfd6d2..5633db611dd 100644 --- a/Master/tlpkg/lib/C/tlp-config.c +++ b/Master/tlpkg/lib/C/tlp-config.c @@ -6,28 +6,70 @@ * This file is licensed under the GNU General Public License version 2 * or any later version. */ +#include <tlp-utils.h> #include <stdlib.h> #define TLP_META_CATEGORIES "Collection", "Scheme" #define TLP_NORMAL_CATEGORIES "Package", "TLCore", "Documentation" +#define TLP_DEFAULT_CATEGORY "Package" const char *_tlp_meta_categories[] = { TLP_META_CATEGORIES, - NULL }; const char *_tlp_normal_categories[] = { TLP_NORMAL_CATEGORIES, - NULL }; const char *_tlp_categories[] = { TLP_META_CATEGORIES, TLP_NORMAL_CATEGORIES, - NULL }; -const char **tlp_meta_categories = _tlp_meta_categories; -const char **tlp_normal_categories = _tlp_normal_categories; -const char **tlp_categories = _tlp_categories; +tlp_str_list *tlp_meta_categories; +tlp_str_list *tlp_normal_categories; +tlp_str_list *tlp_categories; +tlp_str tlp_default_category; + +#define ARR_SIZE(arr) (sizeof(arr) / sizeof(arr[0])) + +/* TODO: we might have more complicated implementation later. */ +tlp_result tlp_config_init() +{ + tlp_meta_categories = tlp_str_list_from_array(_tlp_meta_categories); + if (tlp_meta_categories == NULL) + goto failed1; + + tlp_normal_categories = tlp_str_list_from_array(_tlp_normal_categories); + if (tlp_normal_categories == NULL) + goto failed2; + + tlp_categories = tlp_str_list_from_array(_tlp_categories); + if (tlp_categories == NULL) + goto failed3; + + tlp_default_category = tlp_str_from_bytes(TLP_DEFAULT_CATEGORY); + if (tlp_default_category == NULL) + goto failed4; + + return TLP_OK; + +failed4: + tlp_str_list_free(tlp_categories); +failed3: + tlp_str_list_free(tlp_normal_categories); +failed2: + tlp_str_list_free(tlp_meta_categories); +failed1: + return TLP_FAILED; +} + +void tlp_config_free() +{ + tlp_str_list_free(tlp_meta_categories); + tlp_str_list_free(tlp_normal_categories); + tlp_str_list_free(tlp_categories); + + tlp_str_free(tlp_default_category); +} |