.include "../../i18n_module/Makefile.shlib"
CFLAGS+= -DI18NMODULE_MAJOR=${MODULE_SHLIB_MAJOR} -D_I18N_DYNAMIC
+STATIC_LOCALES?=
SRCS+= citrus_bcs.c citrus_csmapper.c citrus_ctype.c citrus_ctype_fallback.c
SRCS+= citrus_db.c citrus_db_hash.c citrus_esdb.c citrus_hash.c
SRCS+= citrus_iconv.c citrus_lookup.c citrus_mapper.c citrus_memstream.c
SRCS+= citrus_mmap.c citrus_module.c citrus_none.c citrus_stdenc.c
+SRCS+= citrus_prop.c
+
+# Add the locale modules to compile-in in the static libc.a (and libc_p.a)
+# If a new locale module is added, the includes and the table in
+# citrus_module.c must be updated.
+# A new module must have the file name citrus_xxx.c where xxx is the lower
+# case name of the module.
+# Currently the modules specified by STATIC_LOCALES are included in the
+# shared libc (but never used). This is a bug.
+.if ${STATIC_LOCALES} != ""
+.PATH: ${.CURDIR}/../libc/citrus/modules
+CFLAGS+=-I${.CURDIR}/citrus
+CFLAGS+=-D_I18N_STATIC
+.for var in ${STATIC_LOCALES}
+SRCS+= citrus_${var:L}.c
+CFLAGS+=-D_I18N_STATIC_${var}
+.endfor
+.endif # STATIC_LOCALES
#include <locale.h>
#include <stddef.h>
#include <paths.h>
+#include <wchar.h>
#include "citrus_module.h"
#include <sys/types.h>
if (handle)
dlclose((void *)handle);
}
-#else
-/* !_I18N_DYNAMIC */
+#elif defined(_I18N_STATIC)
+/*
+ * Compiled-in multibyte locale support for statically linked programs.
+ */
-SET_DECLARE(citrus_set, struct citrus_metadata);
+#include "citrus_ctype.h"
+#ifdef _I18N_STATIC_BIG5
+#include "modules/citrus_big5.h"
+#endif
+#ifdef _I18N_STATIC_EUC
+#include "modules/citrus_euc.h"
+#endif
+#ifdef _I18N_STATIC_EUCTW
+#include "modules/citrus_euctw.h"
+#endif
+#ifdef _I18N_STATIC_ISO2022
+#include "modules/citrus_iso2022.h"
+#endif
+#ifdef _I18N_STATIC_MSKanji
+#include "modules/citrus_mskanji.h"
+#endif
+#ifdef _I18N_STATIC_UTF8
+#include "modules/citrus_utf8.h"
+#endif
-struct citrus_metadata empty = {
- NULL, NULL, NULL
+#define _CITRUS_GETOPS_FUNC(_m_, _if_) _citrus_##_m_##_##_if_##_getops
+/* only ctype is supported */
+#define _CITRUS_LOCALE_TABLE_ENTRY(_n_) \
+{ #_n_, "ctype", _CITRUS_GETOPS_FUNC(_n_, ctype) }
+
+/*
+ * Table of compiled-in locales.
+ */
+struct citrus_metadata locale_table[] = {
+#ifdef _I18N_STATIC_BIG5
+ _CITRUS_LOCALE_TABLE_ENTRY(BIG5),
+#endif
+#ifdef _I18N_STATIC_EUC
+ _CITRUS_LOCALE_TABLE_ENTRY(EUC),
+#endif
+#ifdef _I18N_STATIC_EUCTW
+ _CITRUS_LOCALE_TABLE_ENTRY(EUCTW),
+#endif
+#ifdef _I18N_STATIC_ISO2022
+ _CITRUS_LOCALE_TABLE_ENTRY(ISO2022),
+#endif
+#ifdef _I18N_STATIC_MSKanji
+ _CITRUS_LOCALE_TABLE_ENTRY(MSKanji),
+#endif
+#ifdef _I18N_STATIC_UTF8
+ _CITRUS_LOCALE_TABLE_ENTRY(UTF8),
+#endif
+ { NULL, NULL, NULL },
};
-DATA_SET(citrus_set, empty);
+SET_DECLARE(citrus_set, struct citrus_metadata);
+
+DATA_SET(citrus_set, locale_table);
#define MAGIC_HANDLE (void *)(0xC178C178)
{
struct citrus_metadata **mdp, *mod;
- _DIAGASSERT(handle == MAGIC_HANDLE);
-
SET_FOREACH(mdp, citrus_set) {
mod = *mdp;
if (mod == NULL || mod->module_name == NULL || mod->interface_name == NULL)
continue;
if (strcmp(mod->module_name, modname) != 0)
continue;
- *rhandle = MAGIC_HANDLE;
+ *rhandle = (_citrus_module_t)mod;
return(0);
}
return (EINVAL);
_citrus_unload_module(_citrus_module_t handle __unused)
{
}
+#else
+SET_DECLARE(citrus_set, struct citrus_metadata);
+
+struct citrus_metadata empty = {
+ NULL, NULL, NULL
+};
+
+DATA_SET(citrus_set, empty);
+
+#define MAGIC_HANDLE (void *)(0xC178C178)
+
+void *
+/*ARGSUSED*/
+_citrus_find_getops(_citrus_module_t handle __unused, const char *modname,
+ const char *ifname)
+{
+ struct citrus_metadata **mdp, *mod;
+
+ _DIAGASSERT(handle == MAGIC_HANDLE);
+
+ SET_FOREACH(mdp, citrus_set) {
+ mod = *mdp;
+ if (mod == NULL || mod->module_name == NULL || mod->interface_name == NULL)
+ continue;
+ if (strcmp(mod->module_name, modname) != 0)
+ continue;
+ if (strcmp(mod->interface_name, ifname) != 0)
+ continue;
+ return(mod->module_ops);
+ }
+ return (NULL);
+}
+
+int
+/*ARGSUSED*/
+_citrus_load_module(_citrus_module_t *rhandle, char const *modname)
+{
+ struct citrus_metadata **mdp, *mod;
+
+ SET_FOREACH(mdp, citrus_set) {
+ mod = *mdp;
+ if (mod == NULL || mod->module_name == NULL)
+ continue;
+ if (strcmp(mod->module_name, modname) != 0)
+ continue;
+ *rhandle = MAGIC_HANDLE;
+ return(0);
+ }
+ return (EINVAL);
+}
+
+void
+/*ARGSUSED*/
+_citrus_unload_module(_citrus_module_t handle __unused)
+{
+}
#endif