/* statefile.c function for statefile * load_state and save_state * 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" #include #include /* save_state to saveN file,now only 1.sav */ void save_state(gchar * savefile) { FILE *fp=NULL; int i; gchar strPath[1024]; gchar home_savefile[1024]; strcpy(home_savefile,home_path); strcat(home_savefile,savefile); strcpy(strPath, home_path); // remove timer show_stop(); show_banner("Saving ..."); // check home path dir if (access (strPath, 0)) { mkdir (strPath, S_IRWXU); g_print("mkdir (%s) !!\n",strPath); } // check ~/.srecite/sav/ strcat (strPath, "sav/"); if (access (strPath, 0)) { mkdir (strPath, S_IRWXU); g_print("mkdir (%s) !!\n",strPath); } if ((fp=fopen(home_savefile,"w")) == NULL) { g_print("Can't open *.sav (%s)!!\n",home_savefile); g_print("Please check ~/.srecite/sav !\n"); exit(0); } // save S_conf fprintf(fp,"%s\n",S_conf.filename); //fprintf(fp,"%d\n",S_conf.filename); // save S_state fprintf(fp,"%d\n",S_state.word_index); // save word_tag[] for(i=0;i