Browse Subversion Repository
Diff of /trunk/teraterm/ttpset/ttset.c
Parent Directory
| Revision Log
| Patch
| 47 |
#include "servicenames.h" |
#include "servicenames.h" |
| 48 |
#include "codeconv.h" |
#include "codeconv.h" |
| 49 |
#include "win32helper.h" |
#include "win32helper.h" |
| 50 |
|
#include "inifile_com.h" |
| 51 |
|
|
| 52 |
#define DllExport __declspec(dllexport) |
#define DllExport __declspec(dllexport) |
| 53 |
#include "ttset.h" |
#include "ttset.h" |
| 161 |
return (ret); |
return (ret); |
| 162 |
} |
} |
| 163 |
|
|
|
/** |
|
|
* GetPrivateProfileStringA() のファイル名だけが wchar_t 版 |
|
|
*/ |
|
|
DWORD GetPrivateProfileStringAFileW(const char *appA, const char *keyA, const char* defA, char *strA, DWORD size, const wchar_t *filenameW) |
|
|
{ |
|
|
DWORD lenA; |
|
|
wchar_t *appW = ToWcharA(appA); |
|
|
wchar_t *keyW = ToWcharA(keyA); |
|
|
wchar_t *defW = ToWcharA(defA); |
|
|
DWORD lenW_max = size; |
|
|
wchar_t *strW = malloc(sizeof(wchar_t) * lenW_max); |
|
|
DWORD lenW = GetPrivateProfileStringW(appW, keyW, defW, strW, lenW_max, filenameW); |
|
|
free(appW); |
|
|
free(keyW); |
|
|
free(defW); |
|
|
if (lenW == 0) { |
|
|
free(strW); |
|
|
*strA = '\0'; |
|
|
return 0; |
|
|
} |
|
|
if (lenW < lenW_max) { |
|
|
lenW++; // for L'\0' |
|
|
} |
|
|
lenA = WideCharToMultiByte(CP_ACP, 0, strW, lenW, strA, size, NULL, NULL); |
|
|
// GetPrivateProfileStringW() の戻り値は '\0' を含まない文字列長 |
|
|
// WideCharToMultiByte() の戻り値は '\0' を含む文字列長 |
|
|
if (lenW != 0 && strA[lenA-1] == 0) { |
|
|
lenA--; |
|
|
} |
|
|
free(strW); |
|
|
return lenA; |
|
|
} |
|
|
|
|
|
/** |
|
|
* WritePrivateProfileStringA() のファイル名だけが wchar_t 版 |
|
|
*/ |
|
|
BOOL WritePrivateProfileStringAFileW(const char *appA, const char *keyA, const char *strA, const wchar_t *filenameW) |
|
|
{ |
|
|
wchar_t *appW = ToWcharA(appA); |
|
|
wchar_t *keyW = ToWcharA(keyA); |
|
|
wchar_t *strW = ToWcharA(strA); |
|
|
BOOL r = WritePrivateProfileStringW(appW, keyW, strW, filenameW); |
|
|
free(appW); |
|
|
free(keyW); |
|
|
free(strW); |
|
|
return r; |
|
|
} |
|
|
|
|
|
/** |
|
|
* GetPrivateProfileIntFileA() のファイル名だけが wchar_t 版 |
|
|
*/ |
|
|
UINT GetPrivateProfileIntFileW(const char *appA, const char *keyA, int def, const wchar_t *filenameW) |
|
|
{ |
|
|
wchar_t *appW = ToWcharA(appA); |
|
|
wchar_t *keyW = ToWcharA(keyA); |
|
|
UINT r = GetPrivateProfileIntW(appW, keyW, def, filenameW); |
|
|
free(appW); |
|
|
free(keyW); |
|
|
return r; |
|
|
} |
|
|
|
|
|
/** |
|
|
* WritePrivateProfileInt() のファイル名だけが wchar_t 版 |
|
|
*/ |
|
|
BOOL WritePrivateProfileIntFileW(const char *appA, const char *keyA, int val, const wchar_t *filenameW) |
|
|
{ |
|
|
wchar_t strW[MAX_PATH]; |
|
|
wchar_t *appW = ToWcharA(appA); |
|
|
wchar_t *keyW = ToWcharA(keyA); |
|
|
BOOL r; |
|
|
_snwprintf_s(strW, _countof(strW), _TRUNCATE, L"%d", val); |
|
|
r = WritePrivateProfileStringW(appW, keyW, strW, filenameW); |
|
|
free(appW); |
|
|
free(keyW); |
|
|
return r; |
|
|
} |
|
|
|
|
| 164 |
#if INI_FILE_IS_UNICODE |
#if INI_FILE_IS_UNICODE |
| 165 |
#undef GetPrivateProfileInt |
#undef GetPrivateProfileInt |
| 166 |
#undef GetPrivateProfileString |
#undef GetPrivateProfileString |
| 167 |
#define GetPrivateProfileInt(p1, p2, p3, p4) GetPrivateProfileIntFileW(p1, p2, p3, p4) |
#define GetPrivateProfileInt(p1, p2, p3, p4) GetPrivateProfileIntAFileW(p1, p2, p3, p4) |
| 168 |
#define GetPrivateProfileString(p1, p2, p3, p4, p5, p6) GetPrivateProfileStringAFileW(p1, p2, p3, p4, p5, p6) |
#define GetPrivateProfileString(p1, p2, p3, p4, p5, p6) GetPrivateProfileStringAFileW(p1, p2, p3, p4, p5, p6) |
| 169 |
#define GetPrivateProfileStringA(p1, p2, p3, p4, p5, p6) GetPrivateProfileStringAFileW(p1, p2, p3, p4, p5, p6) |
#define GetPrivateProfileStringA(p1, p2, p3, p4, p5, p6) GetPrivateProfileStringAFileW(p1, p2, p3, p4, p5, p6) |
| 170 |
#define WritePrivateProfileStringA(p1, p2, p3, p4) WritePrivateProfileStringAFileW(p1, p2, p3, p4) |
#define WritePrivateProfileStringA(p1, p2, p3, p4) WritePrivateProfileStringAFileW(p1, p2, p3, p4) |
| 316 |
strncpy_s(name, len, icon, _TRUNCATE); |
strncpy_s(name, len, icon, _TRUNCATE); |
| 317 |
} |
} |
| 318 |
|
|
|
#if INI_FILE_IS_UNICODE |
|
| 319 |
static WORD GetOnOff(PCHAR Sect, PCHAR Key, const wchar_t *FName, BOOL Default) |
static WORD GetOnOff(PCHAR Sect, PCHAR Key, const wchar_t *FName, BOOL Default) |
|
#else |
|
|
static WORD GetOnOff(PCHAR Sect, PCHAR Key, const char *FName, BOOL Default) |
|
|
#endif |
|
| 320 |
{ |
{ |
| 321 |
char Temp[4]; |
char Temp[4]; |
| 322 |
GetPrivateProfileString(Sect, Key, "", Temp, sizeof(Temp), FName); |
GetPrivateProfileString(Sect, Key, "", Temp, sizeof(Temp), FName); |
| 334 |
} |
} |
| 335 |
} |
} |
| 336 |
|
|
|
#if INI_FILE_IS_UNICODE |
|
| 337 |
void WriteOnOff(PCHAR Sect, PCHAR Key, const wchar_t *FName, WORD Flag) |
void WriteOnOff(PCHAR Sect, PCHAR Key, const wchar_t *FName, WORD Flag) |
|
#else |
|
|
void WriteOnOff(PCHAR Sect, PCHAR Key, const char *FName, WORD Flag) |
|
|
#endif |
|
| 338 |
{ |
{ |
| 339 |
const char *on_off = (Flag != 0) ? "on" : "off"; |
const char *on_off = (Flag != 0) ? "on" : "off"; |
| 340 |
WritePrivateProfileStringA(Sect, Key, on_off, FName); |
WritePrivateProfileStringA(Sect, Key, on_off, FName); |
| 341 |
} |
} |
| 342 |
|
|
|
#if INI_FILE_IS_UNICODE |
|
| 343 |
void WriteInt(PCHAR Sect, PCHAR Key, const wchar_t *FName, int i) |
void WriteInt(PCHAR Sect, PCHAR Key, const wchar_t *FName, int i) |
|
#else |
|
|
void WriteInt(PCHAR Sect, PCHAR Key, const char *FName, int i) |
|
|
#endif |
|
| 344 |
{ |
{ |
| 345 |
char Temp[15]; |
char Temp[15]; |
| 346 |
_snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", i); |
_snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d", i); |
| 347 |
WritePrivateProfileStringA(Sect, Key, Temp, FName); |
WritePrivateProfileStringA(Sect, Key, Temp, FName); |
| 348 |
} |
} |
| 349 |
|
|
|
#if INI_FILE_IS_UNICODE |
|
| 350 |
void WriteUint(PCHAR Sect, PCHAR Key, const wchar_t *FName, UINT i) |
void WriteUint(PCHAR Sect, PCHAR Key, const wchar_t *FName, UINT i) |
|
#else |
|
|
void WriteUint(PCHAR Sect, PCHAR Key, const char *FName, UINT i) |
|
|
#endif |
|
| 351 |
{ |
{ |
| 352 |
char Temp[15]; |
char Temp[15]; |
| 353 |
_snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%u", i); |
_snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%u", i); |
| 354 |
WritePrivateProfileStringA(Sect, Key, Temp, FName); |
WritePrivateProfileStringA(Sect, Key, Temp, FName); |
| 355 |
} |
} |
| 356 |
|
|
|
#if INI_FILE_IS_UNICODE |
|
| 357 |
void WriteInt2(PCHAR Sect, PCHAR Key, const wchar_t *FName, int i1, int i2) |
void WriteInt2(PCHAR Sect, PCHAR Key, const wchar_t *FName, int i1, int i2) |
|
#else |
|
|
void WriteInt2(PCHAR Sect, PCHAR Key, const char *FName, int i1, int i2) |
|
|
#endif |
|
| 358 |
{ |
{ |
| 359 |
char Temp[32]; |
char Temp[32]; |
| 360 |
_snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d,%d", i1, i2); |
_snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d,%d", i1, i2); |
| 361 |
WritePrivateProfileStringA(Sect, Key, Temp, FName); |
WritePrivateProfileStringA(Sect, Key, Temp, FName); |
| 362 |
} |
} |
| 363 |
|
|
|
#if INI_FILE_IS_UNICODE |
|
| 364 |
void WriteInt4(PCHAR Sect, PCHAR Key, const wchar_t *FName, |
void WriteInt4(PCHAR Sect, PCHAR Key, const wchar_t *FName, |
| 365 |
int i1, int i2, int i3, int i4) |
int i1, int i2, int i3, int i4) |
|
#else |
|
|
void WriteInt4(PCHAR Sect, PCHAR Key, const char *FName, |
|
|
int i1, int i2, int i3, int i4) |
|
|
#endif |
|
| 366 |
{ |
{ |
| 367 |
char Temp[64]; |
char Temp[64]; |
| 368 |
_snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d,%d,%d,%d", |
_snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d,%d,%d,%d", |
| 370 |
WritePrivateProfileStringA(Sect, Key, Temp, FName); |
WritePrivateProfileStringA(Sect, Key, Temp, FName); |
| 371 |
} |
} |
| 372 |
|
|
|
#if INI_FILE_IS_UNICODE |
|
| 373 |
void WriteInt6(PCHAR Sect, PCHAR Key, const wchar_t *FName, |
void WriteInt6(PCHAR Sect, PCHAR Key, const wchar_t *FName, |
| 374 |
int i1, int i2, int i3, int i4, int i5, int i6) |
int i1, int i2, int i3, int i4, int i5, int i6) |
|
#else |
|
|
void WriteInt6(PCHAR Sect, PCHAR Key, const char *FName, |
|
|
int i1, int i2, int i3, int i4, int i5, int i6) |
|
|
#endif |
|
| 375 |
{ |
{ |
| 376 |
char Temp[96]; |
char Temp[96]; |
| 377 |
_snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d,%d,%d,%d,%d,%d", |
_snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "%d,%d,%d,%d,%d,%d", |
| 380 |
} |
} |
| 381 |
|
|
| 382 |
// フォント情報書き込み、4パラメータ版 |
// フォント情報書き込み、4パラメータ版 |
|
#if INI_FILE_IS_UNICODE |
|
| 383 |
static void WriteFont(PCHAR Sect, PCHAR Key, const wchar_t *FName, |
static void WriteFont(PCHAR Sect, PCHAR Key, const wchar_t *FName, |
| 384 |
PCHAR Name, int x, int y, int charset) |
PCHAR Name, int x, int y, int charset) |
|
#else |
|
|
static void WriteFont(PCHAR Sect, PCHAR Key, const char *FName, |
|
|
PCHAR Name, int x, int y, int charset) |
|
|
#endif |
|
| 385 |
{ |
{ |
| 386 |
char Temp[80]; |
char Temp[80]; |
| 387 |
if (Name[0] != 0) |
if (Name[0] != 0) |
| 393 |
} |
} |
| 394 |
|
|
| 395 |
// フォント情報読み込み、4パラメータ版 |
// フォント情報読み込み、4パラメータ版 |
|
#if INI_FILE_IS_UNICODE |
|
| 396 |
static void ReadFont( |
static void ReadFont( |
| 397 |
const char *Sect, const char *Key, const char *Default, const wchar_t *FName, |
const char *Sect, const char *Key, const char *Default, const wchar_t *FName, |
| 398 |
char *FontName, size_t FontNameLen, POINT *FontSize, int *FontCharSet) |
char *FontName, size_t FontNameLen, POINT *FontSize, int *FontCharSet) |
|
#else |
|
|
static void ReadFont( |
|
|
const char *Sect, const char *Key, const char *Default, const char *FName, |
|
|
char *FontName, size_t FontNameLen, POINT *FontSize, int *FontCharSet) |
|
|
#endif |
|
| 399 |
{ |
{ |
| 400 |
char Temp[MAX_PATH]; |
char Temp[MAX_PATH]; |
| 401 |
GetPrivateProfileString(Sect, Key, Default, |
GetPrivateProfileString(Sect, Key, Default, |
| 416 |
} |
} |
| 417 |
|
|
| 418 |
// フォント情報読み込み、3パラメータ版 |
// フォント情報読み込み、3パラメータ版 |
|
#if INI_FILE_IS_UNICODE |
|
| 419 |
static void ReadFont3( |
static void ReadFont3( |
| 420 |
const char *Sect, const char *Key, const char *Default, const wchar_t *FName, |
const char *Sect, const char *Key, const char *Default, const wchar_t *FName, |
| 421 |
char *FontName, size_t FontNameLen, int *FontPoint, int *FontCharSet) |
char *FontName, size_t FontNameLen, int *FontPoint, int *FontCharSet) |
|
#else |
|
|
static void ReadFont3( |
|
|
const char *Sect, const char *Key, const char *Default, const char *FName, |
|
|
char *FontName, size_t FontNameLen, int *FontPoint, int *FontCharSet) |
|
|
#endif |
|
| 422 |
{ |
{ |
| 423 |
char Temp[MAX_PATH]; |
char Temp[MAX_PATH]; |
| 424 |
GetPrivateProfileString(Sect, Key, Default, |
GetPrivateProfileString(Sect, Key, Default, |
| 717 |
|
|
| 718 |
} |
} |
| 719 |
|
|
| 720 |
void PASCAL ReadIniFile(PCHAR FNameA, PTTSet ts) |
void PASCAL ReadIniFile(const wchar_t *FName, PTTSet ts) |
| 721 |
{ |
{ |
| 722 |
int i; |
int i; |
| 723 |
HDC TmpDC; |
HDC TmpDC; |
| 724 |
char Temp[MAX_PATH], Temp2[MAX_PATH], *p; |
char Temp[MAX_PATH], Temp2[MAX_PATH], *p; |
|
#if INI_FILE_IS_UNICODE |
|
|
const wchar_t *FName = ToWcharA(FNameA); |
|
|
#else |
|
|
const char *FName = FNameA; |
|
|
#endif |
|
| 725 |
|
|
| 726 |
ts->Minimize = 0; |
ts->Minimize = 0; |
| 727 |
ts->HideWindow = 0; |
ts->HideWindow = 0; |
| 2262 |
if (ts->UnicodeEmojiWidth < 1 || 2 < ts->UnicodeEmojiWidth) { |
if (ts->UnicodeEmojiWidth < 1 || 2 < ts->UnicodeEmojiWidth) { |
| 2263 |
ts->UnicodeEmojiWidth = 1; |
ts->UnicodeEmojiWidth = 1; |
| 2264 |
} |
} |
|
|
|
|
#if INI_FILE_IS_UNICODE |
|
|
free((void *)FName); |
|
|
#endif |
|
| 2265 |
} |
} |
| 2266 |
|
|
| 2267 |
void PASCAL WriteIniFile(PCHAR FNameA, PTTSet ts) |
void PASCAL WriteIniFile(const wchar_t *FName, PTTSet ts) |
| 2268 |
{ |
{ |
| 2269 |
int i; |
int i; |
| 2270 |
char Temp[MAX_PATH]; |
char Temp[MAX_PATH]; |
| 2271 |
char buf[20]; |
char buf[20]; |
| 2272 |
int ret; |
int ret; |
| 2273 |
char uimsg[MAX_UIMSG], uimsg2[MAX_UIMSG], msg[MAX_UIMSG]; |
char uimsg[MAX_UIMSG], uimsg2[MAX_UIMSG], msg[MAX_UIMSG]; |
|
#if INI_FILE_IS_UNICODE |
|
|
const wchar_t *FName = ToWcharA(FNameA); |
|
|
#else |
|
|
const char *FName = FNameA; |
|
|
#endif |
|
| 2274 |
|
|
| 2275 |
/* version */ |
/* version */ |
| 2276 |
ret = WritePrivateProfileString(Section, "Version", TT_VERSION_STR("."), FName); |
ret = WritePrivateProfileString(Section, "Version", TT_VERSION_STR("."), FName); |
| 3186 |
WritePrivateProfileString(ETERM_SECTION, "BGThemeFile", |
WritePrivateProfileString(ETERM_SECTION, "BGThemeFile", |
| 3187 |
ts->EtermLookfeel.BGThemeFile, FName); |
ts->EtermLookfeel.BGThemeFile, FName); |
| 3188 |
{ |
{ |
|
#if INI_FILE_IS_UNICODE |
|
| 3189 |
wchar_t TempW[MAX_PATH]; |
wchar_t TempW[MAX_PATH]; |
| 3190 |
_snwprintf_s(TempW, _countof(TempW), _TRUNCATE, L"%hs\\%hs", ts->HomeDir, BG_THEME_IMAGEFILE); |
_snwprintf_s(TempW, _countof(TempW), _TRUNCATE, L"%hs\\%hs", ts->HomeDir, BG_THEME_IMAGEFILE); |
|
#else |
|
|
char TempW[MAX_PATH]; |
|
|
_snprintf_s(TempW, _countof(TempW), _TRUNCATE, "%s\\%s", ts->HomeDir, BG_THEME_IMAGEFILE); |
|
|
#endif |
|
| 3191 |
WritePrivateProfileStringA(BG_SECTION, BG_DESTFILE, ts->BGImageFilePath, TempW); |
WritePrivateProfileStringA(BG_SECTION, BG_DESTFILE, ts->BGImageFilePath, TempW); |
| 3192 |
WriteInt(BG_SECTION, BG_THEME_IMAGE_BRIGHTNESS1, TempW, ts->BGImgBrightness); |
WriteInt(BG_SECTION, BG_THEME_IMAGE_BRIGHTNESS1, TempW, ts->BGImgBrightness); |
| 3193 |
WriteInt(BG_SECTION, BG_THEME_IMAGE_BRIGHTNESS2, TempW, ts->BGImgBrightness); |
WriteInt(BG_SECTION, BG_THEME_IMAGE_BRIGHTNESS2, TempW, ts->BGImgBrightness); |
| 3591 |
WriteInt(Section, "UnicodeAmbiguousWidth", FName, ts->UnicodeAmbiguousWidth); |
WriteInt(Section, "UnicodeAmbiguousWidth", FName, ts->UnicodeAmbiguousWidth); |
| 3592 |
WriteOnOff(Section, "UnicodeEmojiOverride", FName, ts->UnicodeEmojiOverride); |
WriteOnOff(Section, "UnicodeEmojiOverride", FName, ts->UnicodeEmojiOverride); |
| 3593 |
WriteInt(Section, "UnicodeEmojiWidth", FName, ts->UnicodeEmojiWidth); |
WriteInt(Section, "UnicodeEmojiWidth", FName, ts->UnicodeEmojiWidth); |
|
|
|
|
#if INI_FILE_IS_UNICODE |
|
|
free((void *)FName); |
|
|
#endif |
|
| 3594 |
} |
} |
| 3595 |
|
|
| 3596 |
void PASCAL CopySerialList(PCHAR IniSrcA, PCHAR IniDestA, PCHAR section, |
void PASCAL CopySerialList(PCHAR IniSrcA, PCHAR IniDestA, PCHAR section, |
| 3893 |
if (_stricmp(ts->SetupFName, Temp) != 0) { |
if (_stricmp(ts->SetupFName, Temp) != 0) { |
| 3894 |
strncpy_s(ts->SetupFName, sizeof(ts->SetupFName), Temp, |
strncpy_s(ts->SetupFName, sizeof(ts->SetupFName), Temp, |
| 3895 |
_TRUNCATE); |
_TRUNCATE); |
| 3896 |
|
free(ts->SetupFNameW); |
| 3897 |
ts->SetupFNameW = ToWcharA(ts->SetupFName); |
ts->SetupFNameW = ToWcharA(ts->SetupFName); |
| 3898 |
ReadIniFile(ts->SetupFName, ts); |
ReadIniFile(ts->SetupFNameW, ts); |
| 3899 |
} |
} |
| 3900 |
} |
} |
| 3901 |
} |
} |
|
|
Legend:
| Removed from v.9381 |
|
| changed lines |
| |
Added in v.9429 |
|
|
| |