summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorJjgod Jiang <gzjjgod@gmail.com>2007-11-23 11:27:45 +0000
committerJjgod Jiang <gzjjgod@gmail.com>2007-11-23 11:27:45 +0000
commit261ef52df7e5dfb6b21bedda05dbe72286b21771 (patch)
tree8f132c73b6413f934b5824ce37327d39ee9445fd /Master
parent0673dd83462f9f799b99fcf67671c0e3dce3074d (diff)
Use tlp-config to encapsulate config implementations.
git-svn-id: svn://tug.org/texlive/trunk@5565 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/tlpkg/lib/C/tlp-config.c33
-rw-r--r--Master/tlpkg/lib/C/tlp-config.h12
-rw-r--r--Master/tlpkg/lib/C/tlp-src.c43
-rw-r--r--Master/tlpkg/lib/C/tlp-utils.c17
-rw-r--r--Master/tlpkg/lib/C/tlp-utils.h2
5 files changed, 88 insertions, 19 deletions
diff --git a/Master/tlpkg/lib/C/tlp-config.c b/Master/tlpkg/lib/C/tlp-config.c
new file mode 100644
index 00000000000..aa164dfd6d2
--- /dev/null
+++ b/Master/tlpkg/lib/C/tlp-config.c
@@ -0,0 +1,33 @@
+/* tlp-config.c - module exporting configuration stuff
+ *
+ * Copyright 2007 Jjgod Jiang
+ * Derived from the Perl implementation by Norbert Preining
+ *
+ * This file is licensed under the GNU General Public License version 2
+ * or any later version. */
+
+#include <stdlib.h>
+
+#define TLP_META_CATEGORIES "Collection", "Scheme"
+#define TLP_NORMAL_CATEGORIES "Package", "TLCore", "Documentation"
+
+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;
+
diff --git a/Master/tlpkg/lib/C/tlp-config.h b/Master/tlpkg/lib/C/tlp-config.h
new file mode 100644
index 00000000000..6b02f88bf33
--- /dev/null
+++ b/Master/tlpkg/lib/C/tlp-config.h
@@ -0,0 +1,12 @@
+/* tlp-config.c - header exporting configuration stuff
+ *
+ * Copyright 2007 Jjgod Jiang
+ * Derived from the Perl implementation by Norbert Preining
+ *
+ * This file is licensed under the GNU General Public License version 2
+ * or any later version. */
+
+extern const char **tlp_meta_categories;
+extern const char **tlp_normal_categories;
+extern const char **tlp_categories;
+
diff --git a/Master/tlpkg/lib/C/tlp-src.c b/Master/tlpkg/lib/C/tlp-src.c
index 13d33df823f..457709c0076 100644
--- a/Master/tlpkg/lib/C/tlp-src.c
+++ b/Master/tlpkg/lib/C/tlp-src.c
@@ -22,12 +22,17 @@ tlp_result tlp_src_get_name(tlp_str line,
int *started,
const char *file);
+tlp_result tlp_src_get_category(tlp_str line,
+ tlp_src *src,
+ int *started,
+ const char *file);
+
/* }}} */
/* internal data structures {{{ */
struct tlp_src_field {
- tlp_str key;
+ const char *key;
tlp_result (*func)(tlp_str line,
tlp_src *src,
int *started,
@@ -38,19 +43,19 @@ struct tlp_src_field {
* process it, and feed it with the current tlp_src instance. */
struct tlp_src_field tlp_src_fields[] = {
- { TLP_STR("name"), tlp_src_get_name }, /*
- { TLP_STR("category"), tlp_src_get_category },
- { TLP_STR("shortdesc"), tlp_src_get_shortdesc },
- { TLP_STR("longdesc"), tlp_src_get_longdesc },
- { TLP_STR("catalogue"), tlp_src_get_catalogue },
-
- { TLP_STR("runpatterns"), tlp_src_get_runpatterns },
- { TLP_STR("srcpatterns"), tlp_src_get_srcpatterns },
- { TLP_STR("docpatterns"), tlp_src_get_docpatterns },
- { TLP_STR("binpatterns"), tlp_src_get_binpatterns },
-
- { TLP_STR("execute"), tlp_src_get_execute },
- { TLP_STR("depend"), tlp_src_get_depend }, */
+ { "name", tlp_src_get_name },
+ { "category", tlp_src_get_category }, /*
+ { "shortdesc", tlp_src_get_shortdesc },
+ { "longdesc", tlp_src_get_longdesc },
+ { "catalogue", tlp_src_get_catalogue },
+
+ { "runpatterns", tlp_src_get_runpatterns },
+ { "srcpatterns", tlp_src_get_srcpatterns },
+ { "docpatterns", tlp_src_get_docpatterns },
+ { "binpatterns", tlp_src_get_binpatterns },
+
+ { "execute", tlp_src_get_execute },
+ { "depend", tlp_src_get_depend }, */
};
#define TLP_SRC_TOTAL_FIELDS (sizeof(tlp_src_fields) / sizeof(tlp_src_fields[0]))
@@ -186,7 +191,7 @@ tlp_result tlp_src_process_line(tlp_src *src, tlp_str line,
}
for (i = 0; i < TLP_SRC_TOTAL_FIELDS; i++)
- if (tlp_str_start_with(line, tlp_src_fields[i].key))
+ if (tlp_str_start_with_bytes(line, tlp_src_fields[i].key))
return tlp_src_fields[i].func(line, src, started, file);
return TLP_FAILED;
@@ -217,10 +222,10 @@ tlp_result tlp_src_get_name(tlp_str line,
return TLP_FAILED;
}
-tlp_result tlp_src_get_catalogue(tlp_str line,
- tlp_src *src,
- int *started,
- const char *file)
+tlp_result tlp_src_get_category(tlp_str line,
+ tlp_src *src,
+ int *started,
+ const char *file)
{
if (! *started)
{
diff --git a/Master/tlpkg/lib/C/tlp-utils.c b/Master/tlpkg/lib/C/tlp-utils.c
index 5d24cfa42c9..eda65103584 100644
--- a/Master/tlpkg/lib/C/tlp-utils.c
+++ b/Master/tlpkg/lib/C/tlp-utils.c
@@ -11,6 +11,11 @@
#include <stdio.h>
#include <ctype.h>
+tlp_str tlp_str_from_bytes(const char *bytes)
+{
+ return (tlp_str) strdup(bytes);
+}
+
tlp_str tlp_str_copy(tlp_str str)
{
if (str == NULL)
@@ -67,6 +72,18 @@ int tlp_str_start_with(tlp_str str, tlp_str prefix)
(const char *) prefix, len);
}
+int tlp_str_start_with_bytes(tlp_str str, const char *prefix)
+{
+ tlp_str prefix_str;
+ int ret;
+
+ prefix_str = tlp_str_from_bytes(prefix);
+ ret = tlp_str_start_with(str, prefix_str);
+
+ tlp_str_free(prefix_str);
+ return ret;
+}
+
int tlp_char_is_space(tlp_char ch)
{
return isspace((int) ch);
diff --git a/Master/tlpkg/lib/C/tlp-utils.h b/Master/tlpkg/lib/C/tlp-utils.h
index 9a05bb03086..60e74848fc5 100644
--- a/Master/tlpkg/lib/C/tlp-utils.h
+++ b/Master/tlpkg/lib/C/tlp-utils.h
@@ -41,6 +41,7 @@ typedef enum tlp_result {
#define tlp_new(x) ((x *) malloc(sizeof(x)))
+tlp_str tlp_str_from_bytes(const char *bytes);
tlp_str tlp_str_copy(tlp_str str);
void tlp_str_free(tlp_str str);
void tlp_str_list_free(tlp_str_list *list);
@@ -49,6 +50,7 @@ tlp_str tlp_fgets(tlp_str s, int n, FILE *fp);
size_t tlp_str_len(tlp_str str);
void tlp_str_output(FILE *fp, tlp_str str);
int tlp_str_start_with(tlp_str str, tlp_str prefix);
+int tlp_str_start_with_bytes(tlp_str str, const char *prefix);
int tlp_char_is_space(tlp_char ch);
int tlp_char_is_eol(tlp_char ch);