Esempio n. 1
0
void LoadAutoEng (void)
{
    FILE	*fp;
    char	strPath[PATH_MAX];

    fp = UserConfigFile("AutoEng.dat", "rt", NULL);
    if (!fp) {
	strcpy (strPath, PKGDATADIR "/data/");
	strcat (strPath, "AutoEng.dat");
	/* add by zxd begin */
        if( access( strPath,0 ) && getenv( "FCITXDIR")) {
            strcpy( strPath, getenv( "FCITXDIR" ) );
    	    strcat (strPath, "/share/fcitx/data/AutoEng.dat");
        }
        /* add by zxd end */

	fp = fopen (strPath, "rt");
	if (!fp)
	    return;
    }

    iAutoEng = CalculateRecordNumber (fp);
    AutoEng = (AUTO_ENG *) malloc (sizeof (AUTO_ENG) * iAutoEng);

    iAutoEng = 0;
    while  (!feof(fp)) {
	fscanf (fp, "%s\n", strPath);
	strcpy (AutoEng[iAutoEng++].str, strPath);
    }

    fclose (fp);
}
Esempio n. 2
0
void LoadAutoEng (void)
{
    FILE           *fp = NULL;
    char            strPath[PY_PATH_MAX];

    strcpy (strPath, respath);
    strcat (strPath, "AutoEng.dat");

    fp = fopen (strPath, "rt");
    if (!fp)
    return;

    iAutoEng = CalculateRecordNumber (fp);
    AutoEng = (AUTO_ENG *) malloc (sizeof (AUTO_ENG) * iAutoEng);

    iAutoEng = 0;
    while  (!feof(fp)) {
    fscanf (fp, "%s\n", strPath);
    strcpy (AutoEng[iAutoEng].str, strPath);
    iAutoEng++;
    }

    fclose (fp);
}