+#if EXAMPLE_CODE
+#include <stdio.h>
+#include <string.h>
+#include <m17n.h>
+
+int
+main (int argc, char **argv)
+{
+ MPlist *imlist, *pl;
+
+ M17N_INIT ();
+ imlist = minput_list ((argc > 1) ? msymbol (argv[1]) : Mnil);
+ for (pl = imlist; mplist_key (pl) != Mnil; pl = mplist_next (pl))
+ {
+ MPlist *p = mplist_value (pl);
+ MSymbol lang, name, sane;
+
+ lang = mplist_value (p);
+ p = mplist_next (p);
+ name = mplist_value (p);
+ p = mplist_next (p);
+ sane = mplist_value (p);
+
+ printf ("%s %s %s\n", msymbol_name (lang), msymbol_name (name),
+ sane == Mt ? "ok" : "no");
+ }
+
+ m17n_object_unref (imlist);
+ M17N_FINI ();
+ exit (0);
+}
+#endif
+
+MPlist *
+minput_list (MSymbol language)
+{
+ MPlist *plist, *pl;
+ MPlist *imlist = mplist ();
+
+ MINPUT__INIT ();
+ plist = mdatabase_list (Minput_method, language, Mnil, Mnil);
+ if (! plist)
+ return imlist;
+ MPLIST_DO (pl, plist)
+ {
+ MDatabase *mdb = MPLIST_VAL (pl);
+ MSymbol *tag = mdatabase_tag (mdb);
+ MPlist *imdata, *p, *elm;
+ int num_maps = 0, num_states = 0;
+
+ if (tag[2] == Mnil)
+ continue;
+ imdata = mdatabase_load (mdb);
+ if (! imdata)
+ continue;
+ MPLIST_DO (p, imdata)
+ if (MPLIST_PLIST_P (p))
+ {
+ /* Check these basic functionarity:
+ All external modules (if any) are loadable.
+ All included input method (if any) are loadable.
+ At least one map is defined or included.
+ At least one state is defined or included. */
+ MPlist *elt = MPLIST_PLIST (p);
+ MSymbol key;
+
+ if (MFAILP (MPLIST_SYMBOL_P (elt)))
+ break;
+ key = MPLIST_SYMBOL (elt);
+ if (key == Mmap)
+ num_maps++;
+ else if (key == Mstate)
+ num_states++;
+ else if (key == Mmodule)
+ {
+ MPLIST_DO (elt, MPLIST_NEXT (elt))
+ {
+ MIMExternalModule *external;
+
+ if (MFAILP (MPLIST_PLIST_P (elt)))
+ break;
+ external = load_external_module (MPLIST_PLIST (elt));
+ if (MFAILP (external))
+ break;
+ unload_external_module (external);
+ }
+ if (! MPLIST_TAIL_P (elt))
+ break;
+ }
+ else if (key == Minclude)
+ {
+ MInputMethodInfo *im_info;
+
+ elt = MPLIST_NEXT (elt);
+ if (MFAILP (MPLIST_PLIST_P (elt)))
+ break;
+ im_info = get_im_info_by_tags (MPLIST_PLIST (elt));
+ if (MFAILP (im_info))
+ break;
+ elt = MPLIST_NEXT (elt);
+ if (MFAILP (MPLIST_SYMBOL_P (elt)))
+ break;
+ key = MPLIST_SYMBOL (elt);
+ if (key == Mmap)
+ {
+ if (! im_info->maps)
+ break;
+ num_maps++;
+ }
+ else if (key == Mstate)
+ {
+ if (! im_info->states)
+ break;
+ num_states++;
+ }
+ }
+ }
+ elm = mplist ();
+ mplist_add (elm, Msymbol, tag[1]);
+ mplist_add (elm, Msymbol, tag[2]);
+ if (MPLIST_TAIL_P (p) && num_maps > 0 && num_states > 0)
+ mplist_add (elm, Msymbol, Mt);
+ else
+ mplist_add (elm, Msymbol, Mnil);
+ mplist_push (imlist, Mplist, elm);
+ M17N_OBJECT_UNREF (elm);
+ M17N_OBJECT_UNREF (imdata);
+ }
+ M17N_OBJECT_UNREF (plist);
+ return imlist;
+}
+
+/*=*/
+/*** @} */
+/*=*/