1 /* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3 * Copyright (C) 2003 Dom Lachowicz
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02110-1301, USA.
20 * In addition, as a special exception, Dom Lachowicz
21 * gives permission to link the code of this program with
22 * the non-LGPL Spelling Provider libraries (eg: a MSFT Office
23 * spell checker backend) and distribute linked combinations including
24 * the two. You must obey the GNU Lesser General Public License in all
25 * respects for all of the code used other than said providers. If you modify
26 * this file, you may extend this exception to your version of the
27 * file, but you are not obligated to do so. If you do not wish to
28 * do so, delete this exception statement from your version.
37 #include "enchant-provider.h"
40 describe_dict (const char * const lang_tag,
41 const char * const provider_name,
42 const char * const provider_desc,
43 const char * const provider_file,
46 FILE * out = (FILE *)user_data;
47 fprintf (out, "%s (%s)\n", lang_tag, provider_name);
51 enumerate_providers (const char * name,
56 FILE * out = (FILE *)user_data;
57 fprintf (out, "%s (%s)\n", name, desc);
61 enumerate_dicts (const char * const lang_tag,
62 const char * const provider_name,
63 const char * const provider_desc,
64 const char * const provider_file,
67 FILE * out = (FILE *)user_data;
68 fprintf (out, "%s (%s)\n", lang_tag, provider_name);
72 main (int argc, char **argv)
74 EnchantBroker *broker;
76 char * lang_tag = NULL;
80 for (i = 1; i < argc; i++) {
81 if (!strcmp (argv[i], "-lang")) {
83 lang_tag = g_strdup (argv[++i]);
85 lang_tag = enchant_get_user_language();
87 if (!lang_tag || !strcmp (lang_tag, "C")) {
88 if (lang_tag) /* lang might be "C" */
90 lang_tag = g_strdup ("en");
94 } else if (!strcmp (argv[i], "-h") || !strcmp (argv[i], "-?") || !strcmp(argv[i], "-help")) {
95 printf ("%s [-lang [language_tag]] [-list-dicts] [-h] [-v]\n", argv[0]);
99 } else if (!strcmp (argv[i], "-v") || !strcmp (argv[i], "-version")) {
100 printf ("%s %s\n", argv[0], VERSION);
104 } else if (!strcmp (argv[i], "-list-dicts")) {
109 broker = enchant_broker_init ();
112 enchant_broker_describe (broker, enumerate_providers, stdout);
113 } else if (mode == 1) {
116 printf ("Error: language tag not specified and environment variable $LANG not set.\n");
117 enchant_broker_free (broker);
121 dict = enchant_broker_request_dict (broker, lang_tag);
124 printf ("No dictionary available for '%s'.\n", lang_tag);
129 enchant_broker_free (broker);
132 enchant_dict_describe (dict, describe_dict, stdout);
133 enchant_broker_free_dict (broker, dict);
135 } else if (mode == 2) {
136 enchant_broker_list_dicts (broker, enumerate_dicts, stdout);
142 enchant_broker_free (broker);