/* This file is part of The New Aspell * Copyright (C) 2000-2001 by Kevin Atkinson under the GNU LGPL * license version 2.0 or 2.1. You should have received a copy of the * LGPL license along with this library if you did not you can find it * at http://www.gnu.org/. */ #include #include #include #include "aspell.h" static void print_word_list(AspellSpeller * speller, const AspellWordList *wl, char delem) { if (wl == 0) { printf("Error: %s\n", aspell_speller_error_message(speller)); } else { AspellStringEnumeration * els = aspell_word_list_elements(wl); const char * word; while ( (word = aspell_string_enumeration_next(els)) != 0) { fputs(word, stdout); putc(delem, stdout); } delete_aspell_string_enumeration(els); } } #define check_for_error(speller) \ if (aspell_speller_error(speller) != 0) { \ printf("Error: %s\n", aspell_speller_error_message(speller)); \ break; \ } #define check_for_config_error(config) \ if (aspell_config_error(config) != 0) { \ printf("Error: %s\n", aspell_config_error_message(config)); \ break; \ } static void check_document(AspellSpeller * speller, const char * file); int main(int argc, const char *argv[]) { AspellCanHaveError * ret; AspellSpeller * speller; int have; char word[81]; char * p; char * word_end; AspellConfig * config; /* if (argc < 2) { printf("Usage: %s [|- [[|- []]]\n", argv[0]); return 1; } */ config = new_aspell_config(); aspell_config_replace(config, "lang", "en"); aspell_config_replace(config, "mode", "tex"); /* if (argc >= 4 && argv[3][0] != '-') aspell_config_replace(config, "jargon", argv[3]); if (argc >= 5 && argv[4][0] != '-') aspell_config_replace(config, "encoding", argv[4]); */ ret = new_aspell_speller(config); delete_aspell_config(config); if (aspell_error(ret) != 0) { printf("Error: %s\n",aspell_error_message(ret)); delete_aspell_can_have_error(ret); return 2; } speller = to_aspell_speller(ret); config = aspell_speller_config(speller); fputs("Using: ", stdout); fputs(aspell_config_retrieve(config, "lang"), stdout); fputs("-", stdout); fputs(aspell_config_retrieve(config, "jargon"), stdout); fputs("-", stdout); fputs(aspell_config_retrieve(config, "size"), stdout); fputs("-", stdout); fputs(aspell_config_retrieve(config, "module"), stdout); fputs("-", stdout); fputs(aspell_config_retrieve(config, "mode"), stdout); fputs("\n\n", stdout); puts("Type \"h\" for help.\n"); while (fgets(word, 80, stdin) != 0) { /* remove trailing spaces */ word_end = strchr(word, '\0') - 1; while (word_end != word && (*word_end == '\n' || *word_end == ' ')) --word_end; ++word_end; *word_end = '\0'; putchar('\n'); switch (word[0]) { case '\0': break; case 'h': puts( "Usage: \n" " h(elp) help\n" " c check if a word is the correct spelling\n" " s print out a list of suggestions for a word\n" " a add a word to the personal word list\n" " i ignore a word for the rest of the session\n" " d spell checks a document\n" " p dumps the personal word list\n" " P dumps the session word list\n" " m dumps the main word list\n" " o