summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile.am2
-rw-r--r--configure.ac1
-rw-r--r--data/Makefile.am29
-rw-r--r--liblangtag/Makefile.am23
-rw-r--r--liblangtag/lt-error.h3
-rw-r--r--liblangtag/lt-extlang-db.c237
-rw-r--r--liblangtag/lt-extlang-db.h41
-rw-r--r--liblangtag/lt-extlang-private.h40
-rw-r--r--liblangtag/lt-extlang.c131
-rw-r--r--liblangtag/lt-extlang.h40
-rw-r--r--tests/Makefile.am10
-rw-r--r--tests/extlang-db.c55
13 files changed, 606 insertions, 7 deletions
diff --git a/.gitignore b/.gitignore
index e0a529d..f97f416 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,6 +31,7 @@ data/*\.in
!data/*\.in\.in
data/*\.sh
data/*\.conf
+data/language-subtag-registry.xml
depcomp
docs/html
docs/tmpl
diff --git a/Makefile.am b/Makefile.am
index 66b1fe6..bbdf068 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,6 @@
NULL =
AUTOMAKE_OPTIONS = dist-bzip2
-SUBDIRS = liblangtag
+SUBDIRS = data liblangtag
if ENABLE_GOBJECT
#SUBDIRS += liblangtag-gobject
diff --git a/configure.ac b/configure.ac
index 4772901..bb7cfc9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -117,6 +117,7 @@ dnl output
dnl ======================================================================
AC_CONFIG_FILES([
Makefile
+ data/Makefile
liblangtag.pc
liblangtag-uninstalled.pc
liblangtag-gobject.pc
diff --git a/data/Makefile.am b/data/Makefile.am
new file mode 100644
index 0000000..8be593d
--- /dev/null
+++ b/data/Makefile.am
@@ -0,0 +1,29 @@
+##
+# Global definitions
+NULL =
+EXTRA_DIST = \
+ $(NULL)
+MAINTAINERCLEANFILES = \
+ language-subtag-registry.xml \
+ $(NULL)
+CLEANFILES = \
+ $(NULL)
+BUILT_FILES = \
+ language-subtag-registry.xml \
+ $(NULL)
+
+##
+# Local definitions
+
+##
+# Local Rules
+language-subtag-registry.xml:
+ wget -O $@ http://langtag.net/registries/language-subtag-registry.xml || \
+ curl -o $@ http://langtag.net/registries/language-subtag-registry.xml
+
+##
+# Target platform
+subtagregistrydir = $(datadir)/liblangtag
+subtagregistry_DATA = \
+ language-subtag-registry.xml \
+ $(NULL)
diff --git a/liblangtag/Makefile.am b/liblangtag/Makefile.am
index 92c96fc..685e06c 100644
--- a/liblangtag/Makefile.am
+++ b/liblangtag/Makefile.am
@@ -1,12 +1,14 @@
##
# Global definitions
NULL =
-INCLUDES = \
- -I$(top_srcdir)/liblangtag/ \
- -I$(top_srcdir) \
- -D__LANGTAG_COMPILATION \
- $(GLIB_CFLAGS) \
- $(LIBXML2_CFLAGS) \
+INCLUDES = \
+ -I$(top_srcdir)/liblangtag/ \
+ -I$(top_srcdir) \
+ -D__LANGTAG_COMPILATION \
+ -DBUILDDIR="\"$(abs_top_builddir)\"" \
+ -DREGDATADIR="\"$(datadir)/liblangtag\"" \
+ $(GLIB_CFLAGS) \
+ $(LIBXML2_CFLAGS) \
$(NULL)
LIBS = \
@LDFLAGS@ \
@@ -36,19 +38,24 @@ BUILT_FILES = \
liblangtag_public_headers = \
lt-division.h \
lt-error.h \
+ lt-extlang.h \
+ lt-extlang-db.h \
lt-lang.h \
lt-lang-db.h \
lt-region.h \
lt-region-db.h \
lt-script.h \
lt-script-db.h \
+ lt-tag.h \
$(NULL)
liblangtag_private_headers = \
+ lt-extlang-private.h \
lt-division-private.h \
lt-lang-private.h \
lt-mem.h \
lt-region-private.h \
lt-script-private.h \
+ lt-utils.h \
$(NULL)
liblangtag_built_public_headers = \
$(NULL)
@@ -61,6 +68,8 @@ liblangtag_sources = \
$(liblangtag_built_sources) \
lt-division.c \
lt-error.c \
+ lt-extlang.c \
+ lt-extlang-db.c \
lt-lang.c \
lt-lang-db.c \
lt-mem.c \
@@ -68,6 +77,8 @@ liblangtag_sources = \
lt-region-db.c \
lt-script.c \
lt-script-db.c \
+ lt-tag.c \
+ lt-utils.c \
$(NULL)
#
stamp_files = \
diff --git a/liblangtag/lt-error.h b/liblangtag/lt-error.h
index 3775ec3..9000c75 100644
--- a/liblangtag/lt-error.h
+++ b/liblangtag/lt-error.h
@@ -33,6 +33,9 @@ enum _lt_error_t {
LT_ERR_SUCCESS = 0,
LT_ERR_OOM,
LT_ERR_FAIL_ON_XML,
+ LT_ERR_EOT,
+ LT_ERR_FAIL_ON_SCANNER,
+ LT_ERR_NO_TAG,
LT_ERR_END
};
diff --git a/liblangtag/lt-extlang-db.c b/liblangtag/lt-extlang-db.c
new file mode 100644
index 0000000..b748c04
--- /dev/null
+++ b/liblangtag/lt-extlang-db.c
@@ -0,0 +1,237 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * lt-extlang-db.c
+ * Copyright (C) 2011-2012 Akira TAGOH
+ *
+ * Authors:
+ * Akira TAGOH <akira@tagoh.org>
+ *
+ * This library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <libxml/parser.h>
+#include <libxml/xpath.h>
+#include "lt-error.h"
+#include "lt-extlang.h"
+#include "lt-extlang-private.h"
+#include "lt-mem.h"
+#include "lt-utils.h"
+#include "lt-extlang-db.h"
+
+
+struct _lt_extlang_db_t {
+ lt_mem_t parent;
+ GHashTable *extlang_entries;
+};
+
+/*< private >*/
+static gboolean
+lt_extlang_db_parse(lt_extlang_db_t *extlangdb,
+ GError **error)
+{
+ gboolean retval = TRUE;
+ gchar *regfile = NULL;
+ xmlParserCtxtPtr xmlparser;
+ xmlDocPtr doc = NULL;
+ xmlXPathContextPtr xctxt = NULL;
+ xmlXPathObjectPtr xobj = NULL;
+ GError *err = NULL;
+ int i, n;
+
+ g_return_val_if_fail (extlangdb != NULL, FALSE);
+
+#ifdef GNOME_ENABLE_DEBUG
+ regfile = g_build_filename(BUILDDIR, "data", "language-subtag-registry.xml", NULL);
+ if (!g_file_test(regfile, G_FILE_TEST_EXISTS)) {
+ g_free(regfile);
+#endif
+ regfile = g_build_filename(REGDATADIR, "language-subtag-registry.xml", NULL);
+#ifdef GNOME_ENABLE_DEBUG
+ }
+#endif
+ xmlparser = xmlNewParserCtxt();
+ if (!xmlparser) {
+ g_set_error(&err, LT_ERROR, LT_ERR_OOM,
+ "Unable to create an instance of xmlParserCtxt.");
+ goto bail;
+ }
+ doc = xmlCtxtReadFile(xmlparser, regfile, "UTF-8", 0);
+ if (!doc) {
+ g_set_error(&err, LT_ERROR, LT_ERR_FAIL_ON_XML,
+ "Unable to read the xml file: %s",
+ regfile);
+ goto bail;
+ }
+ xctxt = xmlXPathNewContext(doc);
+ if (!xctxt) {
+ g_set_error(&err, LT_ERROR, LT_ERR_OOM,
+ "Unable to create an instance of xmlXPathContextPtr.");
+ goto bail;
+ }
+ xobj = xmlXPathEvalExpression((const xmlChar *)"/registry/extlang", xctxt);
+ if (!xobj) {
+ g_set_error(&err, LT_ERROR, LT_ERR_FAIL_ON_XML,
+ "No valid elements for %s",
+ doc->name);
+ goto bail;
+ }
+ n = xmlXPathNodeSetGetLength(xobj->nodesetval);
+
+ for (i = 0; i < n; i++) {
+ xmlNodePtr ent = xmlXPathNodeSetItem(xobj->nodesetval, i);
+ xmlNodePtr cnode;
+ xmlChar *subtag = NULL, *desc = NULL, *macrolang = NULL;
+ lt_extlang_t *le = NULL;
+ gchar *s;
+
+ if (!ent) {
+ g_set_error(&err, LT_ERROR, LT_ERR_FAIL_ON_XML,
+ "Unable to obtain the xml node via XPath.");
+ goto bail;
+ }
+ cnode = ent->children;
+ while (cnode != NULL) {
+ if (xmlStrcmp(cnode->name, (const xmlChar *)"subtag") == 0) {
+ subtag = xmlNodeGetContent(cnode);
+ } else if (xmlStrcmp(cnode->name, (const xmlChar *)"added") == 0) {
+ /* ignore it */
+ } else if (xmlStrcmp(cnode->name, (const xmlChar *)"description") == 0) {
+ desc = xmlNodeGetContent(cnode);
+ } else if (xmlStrcmp(cnode->name, (const xmlChar *)"macrolanguage") == 0) {
+ macrolang = xmlNodeGetContent(cnode);
+ } else {
+ g_warning("Unknown node under /registry/extlang: %s", cnode->name);
+ }
+ cnode = cnode->next;
+ }
+ if (!subtag) {
+ g_warning("No subtag node: description = '%s', macrolanguage = '%s'",
+ desc, macrolang);
+ goto bail1;
+ }
+ if (!desc) {
+ g_warning("No description node: subtag = '%s', macrolanguage = '%s'",
+ subtag, macrolang);
+ goto bail1;
+ }
+ le = lt_extlang_create();
+ if (!le) {
+ g_set_error(&err, LT_ERROR, LT_ERR_OOM,
+ "Unable to create an instance of lt_extlang_t.");
+ goto bail1;
+ }
+ lt_extlang_set_tag(le, (const gchar *)subtag);
+ lt_extlang_set_name(le, (const gchar *)desc);
+ if (macrolang)
+ lt_extlang_set_macro_language(le, (const gchar *)macrolang);
+
+ s = g_strdup(lt_extlang_get_tag(le));
+ g_hash_table_replace(extlangdb->extlang_entries,
+ lt_strlower(s),
+ lt_extlang_ref(le));
+ bail1:
+ if (subtag)
+ xmlFree(subtag);
+ if (desc)
+ xmlFree(desc);
+ if (macrolang)
+ xmlFree(macrolang);
+ lt_extlang_unref(le);
+ }
+ bail:
+ if (err) {
+ if (error)
+ *error = g_error_copy(err);
+ else
+ g_warning(err->message);
+ g_error_free(err);
+ retval = FALSE;
+ }
+ g_free(regfile);
+
+ if (xobj)
+ xmlXPathFreeObject(xobj);
+ if (xctxt)
+ xmlXPathFreeContext(xctxt);
+ if (doc)
+ xmlFreeDoc(doc);
+ if (xmlparser)
+ xmlFreeParserCtxt(xmlparser);
+
+ xmlCleanupParser();
+
+ return retval;
+}
+
+/*< public >*/
+lt_extlang_db_t *
+lt_extlang_db_new(void)
+{
+ lt_extlang_db_t *retval = lt_mem_alloc_object(sizeof (lt_extlang_db_t));
+
+ if (retval) {
+ GError *err = NULL;
+
+ retval->extlang_entries = g_hash_table_new_full(g_str_hash,
+ g_str_equal,
+ g_free,
+ (GDestroyNotify)lt_extlang_unref);
+ lt_mem_add_ref(&retval->parent, retval->extlang_entries,
+ (lt_destroy_func_t)g_hash_table_destroy);
+
+ lt_extlang_db_parse(retval, &err);
+ if (err) {
+ g_printerr(err->message);
+ lt_extlang_db_unref(retval);
+ retval = NULL;
+ g_error_free(err);
+ }
+ }
+
+ return retval;
+}
+
+lt_extlang_db_t *
+lt_extlang_db_ref(lt_extlang_db_t *extlangdb)
+{
+ g_return_val_if_fail (extlangdb != NULL, NULL);
+
+ return lt_mem_ref(&extlangdb->parent);
+}
+
+void
+lt_extlang_db_unref(lt_extlang_db_t *extlangdb)
+{
+ if (extlangdb)
+ lt_mem_unref(&extlangdb->parent);
+}
+
+lt_extlang_t *
+lt_extlang_db_lookup(lt_extlang_db_t *extlangdb,
+ const gchar *subtag)
+{
+ lt_extlang_t *retval;
+
+ g_return_val_if_fail (extlangdb != NULL, NULL);
+ g_return_val_if_fail (subtag != NULL, NULL);
+
+ retval = g_hash_table_lookup(extlangdb->extlang_entries, subtag);
+ if (retval)
+ return lt_extlang_ref(retval);
+
+ return NULL;
+}
diff --git a/liblangtag/lt-extlang-db.h b/liblangtag/lt-extlang-db.h
new file mode 100644
index 0000000..3f84252
--- /dev/null
+++ b/liblangtag/lt-extlang-db.h
@@ -0,0 +1,41 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * lt-extlang-db.h
+ * Copyright (C) 2011-2012 Akira TAGOH
+ *
+ * Authors:
+ * Akira TAGOH <akira@tagoh.org>
+ *
+ * This library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef __LT_EXTLANG_DB_H__
+#define __LT_EXTLANG_DB_H__
+
+#include <glib.h>
+#include <liblangtag/lt-extlang.h>
+
+G_BEGIN_DECLS
+
+typedef struct _lt_extlang_db_t lt_extlang_db_t;
+
+
+lt_extlang_db_t *lt_extlang_db_new (void);
+lt_extlang_db_t *lt_extlang_db_ref (lt_extlang_db_t *extlangdb);
+void lt_extlang_db_unref (lt_extlang_db_t *extlangdb);
+lt_extlang_t *lt_extlang_db_lookup(lt_extlang_db_t *extlangdb,
+ const gchar *subtag);
+
+G_END_DECLS
+
+#endif /* __LT_EXTLANG_DB_H__ */
diff --git a/liblangtag/lt-extlang-private.h b/liblangtag/lt-extlang-private.h
new file mode 100644
index 0000000..522014d
--- /dev/null
+++ b/liblangtag/lt-extlang-private.h
@@ -0,0 +1,40 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * lt-extlang-private.h
+ * Copyright (C) 2011-2012 Akira TAGOH
+ *
+ * Authors:
+ * Akira TAGOH <akira@tagoh.org>
+ *
+ * This library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef __LT_EXTLANG_PRIVATE_H__
+#define __LT_EXTLANG_PRIVATE_H__
+
+#include <glib.h>
+#include "lt-extlang.h"
+
+G_BEGIN_DECLS
+
+lt_extlang_t *lt_extlang_create (void);
+void lt_extlang_set_tag (lt_extlang_t *extlang,
+ const gchar *subtag);
+void lt_extlang_set_name (lt_extlang_t *extlang,
+ const gchar *description);
+void lt_extlang_set_macro_language(lt_extlang_t *extlang,
+ const gchar *macrolanguage);
+
+G_END_DECLS
+
+#endif /* __LT_EXTLANG_PRIVATE_H__ */
diff --git a/liblangtag/lt-extlang.c b/liblangtag/lt-extlang.c
new file mode 100644
index 0000000..ac88806
--- /dev/null
+++ b/liblangtag/lt-extlang.c
@@ -0,0 +1,131 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * lt-extlang.c
+ * Copyright (C) 2011-2012 Akira TAGOH
+ *
+ * Authors:
+ * Akira TAGOH <akira@tagoh.org>
+ *
+ * This library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "lt-mem.h"
+#include "lt-extlang.h"
+#include "lt-extlang-private.h"
+
+
+struct _lt_extlang_t {
+ lt_mem_t parent;
+ gchar *tag;
+ gchar *description;
+ gchar *macrolanguage;
+};
+
+/*< private >*/
+
+/*< protected >*/
+lt_extlang_t *
+lt_extlang_create(void)
+{
+ lt_extlang_t *retval;
+
+ retval = lt_mem_alloc_object(sizeof (lt_extlang_t));
+
+ return retval;
+}
+
+void
+lt_extlang_set_tag(lt_extlang_t *extlang,
+ const gchar *subtag)
+{
+ g_return_if_fail (extlang != NULL);
+ g_return_if_fail (subtag != NULL);
+
+ if (extlang->tag)
+ lt_mem_remove_ref(&extlang->parent, extlang->tag);
+ extlang->tag = g_strdup(subtag);
+ lt_mem_add_ref(&extlang->parent, extlang->tag,
+ (lt_destroy_func_t)g_free);
+}
+
+void
+lt_extlang_set_name(lt_extlang_t *extlang,
+ const gchar *description)
+{
+ g_return_if_fail (extlang != NULL);
+ g_return_if_fail (description != NULL);
+
+ if (extlang->description)
+ lt_mem_remove_ref(&extlang->parent, extlang->description);
+ extlang->description = g_strdup(description);
+ lt_mem_add_ref(&extlang->parent, extlang->description,
+ (lt_destroy_func_t)g_free);
+}
+
+void
+lt_extlang_set_macro_language(lt_extlang_t *extlang,
+ const gchar *macrolanguage)
+{
+ g_return_if_fail (extlang != NULL);
+ g_return_if_fail (macrolanguage != NULL);
+
+ if (extlang->macrolanguage)
+ lt_mem_remove_ref(&extlang->parent, extlang->macrolanguage);
+ extlang->macrolanguage = g_strdup(macrolanguage);
+ lt_mem_add_ref(&extlang->parent, extlang->macrolanguage,
+ (lt_destroy_func_t)g_free);
+}
+
+/*< public >*/
+lt_extlang_t *
+lt_extlang_ref(lt_extlang_t *extlang)
+{
+ g_return_val_if_fail (extlang != NULL, NULL);
+
+ return lt_mem_ref(&extlang->parent);
+}
+
+void
+lt_extlang_unref(lt_extlang_t *extlang)
+{
+ if (extlang)
+ lt_mem_unref(&extlang->parent);
+}
+
+const gchar *
+lt_extlang_get_tag(const lt_extlang_t *extlang)
+{
+ g_return_val_if_fail (extlang != NULL, NULL);
+
+ return extlang->tag;
+}
+
+const gchar *
+lt_extlang_get_name(const lt_extlang_t *extlang)
+{
+ g_return_val_if_fail (extlang != NULL, NULL);
+
+ return extlang->description;
+}
+
+const gchar *
+lt_extlang_get_macro_language(const lt_extlang_t *extlang)
+{
+ g_return_val_if_fail (extlang != NULL, NULL);
+
+ return extlang->macrolanguage;
+}
diff --git a/liblangtag/lt-extlang.h b/liblangtag/lt-extlang.h
new file mode 100644
index 0000000..d2e351e
--- /dev/null
+++ b/liblangtag/lt-extlang.h
@@ -0,0 +1,40 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * lt-extlang.h
+ * Copyright (C) 2011-2012 Akira TAGOH
+ *
+ * Authors:
+ * Akira TAGOH <akira@tagoh.org>
+ *
+ * This library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef __LT_EXTLANG_H__
+#define __LT_EXTLANG_H__
+
+#include <glib.h>
+
+G_BEGIN_DECLS
+
+typedef struct _lt_extlang_t lt_extlang_t;
+
+
+lt_extlang_t *lt_extlang_ref (lt_extlang_t *extlang);
+void lt_extlang_unref (lt_extlang_t *extlang);
+const gchar *lt_extlang_get_tag (const lt_extlang_t *extlang);
+const gchar *lt_extlang_get_name (const lt_extlang_t *extlang);
+const gchar *lt_extlang_get_macro_language(const lt_extlang_t *extlang);
+
+G_END_DECLS
+
+#endif /* __LT_EXTLANG_H__ */
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 505d40d..3af27dc 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -37,9 +37,15 @@ noinst_HEADERS = \
$(common_private_headers) \
$(NULL)
noinst_PROGRAMS = \
+ test-extlang-db \
test-lang-db \
test-region-db \
test-script-db \
+ test-tag \
+ $(NULL)
+#
+test_extlang_db_SOURCES = \
+ extlang-db.c \
$(NULL)
#
test_lang_db_SOURCES = \
@@ -53,3 +59,7 @@ test_region_db_SOURCES = \
test_script_db_SOURCES = \
script-db.c \
$(NULL)
+#
+test_tag_SOURCES = \
+ tag.c \
+ $(NULL)
diff --git a/tests/extlang-db.c b/tests/extlang-db.c
new file mode 100644
index 0000000..ec0f03f
--- /dev/null
+++ b/tests/extlang-db.c
@@ -0,0 +1,55 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * extlang.c
+ * Copyright (C) 2011-2012 Akira TAGOH
+ *
+ * Authors:
+ * Akira TAGOH <akira@tagoh.org>
+ *
+ * This library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation, either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <locale.h>
+#include "lt-extlang-db.h"
+
+int
+main(int argc,
+ char **argv)
+{
+ lt_extlang_db_t *extlangdb;
+
+ setlocale(LC_ALL, "");
+
+ extlangdb = lt_extlang_db_new();
+
+ if (g_strcmp0(argv[1], "list") == 0) {
+ } else if (g_strcmp0(argv[1], "lookup") == 0) {
+ lt_extlang_t *extlang = lt_extlang_db_lookup(extlangdb, argv[2]);
+
+ if (extlang) {
+ g_print("desc: %s\n", lt_extlang_get_name(extlang));
+ g_print("lang: %s\n", lt_extlang_get_macro_language(extlang));
+ lt_extlang_unref(extlang);
+ } else {
+ g_print("no such extlang: %s\n", argv[2]);
+ }
+ }
+
+ lt_extlang_db_unref(extlangdb);
+
+ return 0;
+}