|
楼主 |
发表于 2003-3-8 13:22:11
|
显示全部楼层
void LoadProfile (void)
{
FILE *fp;
char str[PATH_MAX], *pstr;
char strPath[PATH_MAX];
int i;
strcpy (strFontName, "*");
#ifndef _USE_XFT
strcpy (strFontLocale, "zh_CN.GBK");
#endif
strcpy (strPath, (char *) getenv ("HOME"));
strcat (strPath, "/.gWuBi/profile");
fp = fopen (strPath, "rt");
if (!fp)
SaveProfile ();
else {
for (;; ) {
if (!fgets (str, PATH_MAX, fp))
break;
if (str[0] == '#')//如果行头为#,略过此行
continue;
i = strlen (str) - 1;
while (str == ' ' || str == '\n')//除去行尾空格回车,并加字符串结束标志
str[i--] = '\0';
pstr = str;
if (!strncmp (str, "区域设置=", 9)) { //比较行首9个字符是否是"区域设置="
pstr += 9;
if (pstr[0] != '\0')//如果在"区域设置="没有内容,pstr[0]为刚才所加字符串结束标志
strcpy (strUserLocale, pstr);
}
else if (strstr (str, "字体=")) {
pstr += 5;
if (pstr[0] != '\0')
strcpy (strFontName, pstr);
}
#ifndef _USE_XFT
else if (strstr (str, "字体区域设置=")) {
pstr += 13;
if (pstr[0] != '\0')
strcpy (strFontLocale, pstr);
}
#endif
else if (strstr (str, "是否自动隐藏输入条=")) {
pstr += 19;
bAutoHide = atoi (pstr);
}
else if (strstr (str, "是否隐藏主图标=")) {
pstr += 15;
bHideMainLogo = atoi (pstr);
}
else if (strstr (str, "是否光标跟随=")) {
pstr += 13;
bTrackCursor = atoi (pstr);
}
else if (strstr (str, "是否使用Z输入拼音=")) {
pstr += 18;
bUseZPinYin = atoi (pstr);
}
else if (strstr (str, "出错时是否响铃=")) {
pstr += 15;
bBell = atoi (pstr);
}
else if (strstr (str, "是否切换区位输入法=")) {
pstr += 19;
bSwitchQW = atoi (pstr);
}
else if (strstr (str, "拼音单字重码调整方式=")) {
pstr += 21;
baseOrder = (ADJUSTORDER) atoi (pstr);
}
else if (strstr (str, "拼音词组重码调整方式=")) {
pstr += 21;
phraseOrder = (ADJUSTORDER) atoi (pstr);
}
else if (strstr (str, "拼音常用词重码调整方式=")) {
pstr += 23;
freqOrder = (ADJUSTORDER) atoi (pstr);
}
else if (strstr (str, "是否模糊an和ang=")) {
pstr += 16;
MHPY_C[0].bMode = atoi (pstr);
}
else if (strstr (str, "是否模糊en和eng=")) {
pstr += 16;
MHPY_C[1].bMode = atoi (pstr);
}
else if (strstr (str, "是否模糊ian和iang=")) {
pstr += 18;
MHPY_C[2].bMode = atoi (pstr);
}
else if (strstr (str, "是否模糊in和ing=")) {
pstr += 16;
MHPY_C[3].bMode = atoi (pstr);
}
else if (strstr (str, "是否模糊ou和u=")) {
pstr += 14;
MHPY_C[4].bMode = atoi (pstr);
}
else if (strstr (str, "是否模糊uan和uang=")) {
pstr += 18;
MHPY_C[5].bMode = atoi (pstr);
}
else if (strstr (str, "是否模糊c和ch=")) {
pstr += 14;
MHPY_S[0].bMode = atoi (pstr);
}
else if (strstr (str, "是否模糊f和h=")) {
pstr += 13;
MHPY_S[1].bMode = atoi (pstr);
}
else if (strstr (str, "是否模糊l和n=")) {
pstr += 13;
MHPY_S[2].bMode = atoi (pstr);
}
else if (strstr (str, "是否模糊s和sh=")) {
pstr += 14;
MHPY_S[3].bMode = atoi (pstr);
}
else if (strstr (str, "是否模糊z和zh=")) {
pstr += 14;
MHPY_S[4].bMode = atoi (pstr);
}
}
fclose (fp);
}
} |
|