/* wordfile.c function for wordfile * Copyright (c) 2004 by SmartLu All Rights Reserved * Distributed under the terms of the GNU General Public License (GPL) * See the GNU Library General Public License for more details. */ #include "srecite.h" //word book for word file,limition 10000 gchar wordbook[MAX_WORD][256]; //tag ignore word,1 = ignore,0 = show regularly gchar word_tag[MAX_WORD]; int word_count;//count of word //open wordfile with S_conf.filename gint open_wordfile() { char temp[255]; char old_filename[255]; //strcpy(temp,PRE_DIR); //strcat(temp,S_conf.filename); //if((S_state.wordfile=fopen(temp,"r")) == NULL) if((S_state.wordfile=fopen(S_conf.filename,"r")) == NULL) { strcpy(old_filename,S_conf.filename); strcpy(temp,PRE_DIR); strcat(temp,S_conf.filename); strcpy(S_conf.filename,temp); if((S_state.wordfile=fopen(S_conf.filename,"r")) == NULL) { g_print("Can't open wordfile.wrd (%s)!!\n",old_filename); g_print("Please check /usr/local/share/srecite/wordbooks or your prefix!\n"); //timer_uninstall(); return 0; } } return 1; } //read wordfile to wordbook[][],10000 words limition void init_wordbook() { gchar * strtemp;//temp string gchar str[256];//temp string word_count = 0; S_state.word_index = 0; g_print("init wordbook!\n"); //open word file if(!open_wordfile()) { exit(0); } while( !feof(S_state.wordfile) ) { fgets(str,256,S_state.wordfile); //!strcmp("TRUE",temp) if(str != "") { // change gb to utf8 // setlocale(LC_ALL,"") strtemp = g_locale_to_utf8(str,-1,NULL,NULL,NULL); //strcpy(wordbook[word_count],strtemp); strcpy(wordbook[word_count],str); word_count ++; } // g_print("word count = %d !!\n",word_count); } g_print("finally word_count = %d\n",word_count); //g_print("init wordbook!\n"); fclose(S_state.wordfile); init_word_tag(); } //get S_line from wordfile void read_line() { gchar line[256],EN_word[256],TK_word[256],CH_word[256],*p; gint n;// count for line if(S_state.word_index <= 0 ) gtk_widget_set_sensitive(back_button,0); else gtk_widget_set_sensitive(back_button,1); // '#' is special char defined by me,to show TK_word is end TK_word[0]='#'; strcpy(line,wordbook[S_state.word_index]); for(n=0;n