• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Loweynet


コミットメタ情報

リビジョンc7302e73116a393e9a99f940d26b4c2bbe944f3e (tree)
日時2011-10-04 19:37:48
作者s_kawamoto <s_kawamoto@user...>
コミッターs_kawamoto

ログメッセージ

Update to c30cc851b60a7c4006cd02b4718d9738a6c4049a about bug fixes.
Fix bugs of UTF-8 to UTF-16 API bridge.
Fix bugs of simultaneous connection.
Add support for additional features of hosts.
Fix inconsistent WINVER, _WIN32_WINNT and _WIN32_IE.

変更サマリ

差分

--- a/FFFTP.vc90.vcproj
+++ b/FFFTP.vc90.vcproj
@@ -47,7 +47,7 @@
4747 Name="VCCLCompilerTool"
4848 Optimization="0"
4949 AdditionalIncludeDirectories="Resource"
50- PreprocessorDefinitions="WIN32,_DEBUG,_WINDOWS,_WIN32_IE=0x300,_CRT_SECURE_NO_WARNINGS"
50+ PreprocessorDefinitions="WIN32,_DEBUG,_WINDOWS,WINVER=0x0500,_WIN32_WINNT=0x0500,_WIN32_IE=0x0400,_CRT_SECURE_NO_WARNINGS"
5151 RuntimeLibrary="1"
5252 PrecompiledHeaderFile=".\Debug\FFFTP.pch"
5353 AssemblerListingLocation=".\Debug\"
@@ -71,7 +71,7 @@
7171 <Tool
7272 Name="VCLinkerTool"
7373 AdditionalOptions="/MACHINE:I386"
74- AdditionalDependencies="wsock32.lib comctl32.lib winmm.lib htmlhelp.lib"
74+ AdditionalDependencies="comctl32.lib htmlhelp.lib rasapi32.lib winmm.lib wsock32.lib"
7575 OutputFile=".\Debug\FFFTP.exe"
7676 LinkIncremental="2"
7777 SuppressStartupBanner="true"
@@ -137,7 +137,7 @@
137137 Name="VCCLCompilerTool"
138138 InlineFunctionExpansion="1"
139139 AdditionalIncludeDirectories="Resource"
140- PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS,_WIN32_IE=0x300,_CRT_SECURE_NO_WARNINGS"
140+ PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS,WINVER=0x0500,_WIN32_WINNT=0x0500,_WIN32_IE=0x0400,_CRT_SECURE_NO_WARNINGS"
141141 StringPooling="true"
142142 RuntimeLibrary="0"
143143 EnableFunctionLevelLinking="true"
@@ -163,7 +163,7 @@
163163 <Tool
164164 Name="VCLinkerTool"
165165 AdditionalOptions="/MACHINE:I386"
166- AdditionalDependencies="wsock32.lib comctl32.lib winmm.lib RASAPI32.LIB htmlhelp.lib"
166+ AdditionalDependencies="comctl32.lib htmlhelp.lib rasapi32.lib winmm.lib wsock32.lib"
167167 OutputFile=".\Release\FFFTP.exe"
168168 LinkIncremental="1"
169169 SuppressStartupBanner="true"
--- a/FFFTP.vcproj
+++ b/FFFTP.vcproj
@@ -46,7 +46,7 @@
4646 Name="VCCLCompilerTool"
4747 Optimization="0"
4848 AdditionalIncludeDirectories="Resource"
49- PreprocessorDefinitions="WIN32,_DEBUG,_WINDOWS,_WIN32_IE=0x300,_CRT_SECURE_NO_WARNINGS"
49+ PreprocessorDefinitions="WIN32,_DEBUG,_WINDOWS,WINVER=0x0500,_WIN32_WINNT=0x0500,_WIN32_IE=0x0400,_CRT_SECURE_NO_WARNINGS"
5050 RuntimeLibrary="1"
5151 PrecompiledHeaderFile=".\Debug\FFFTP.pch"
5252 AssemblerListingLocation=".\Debug\"
@@ -70,7 +70,7 @@
7070 <Tool
7171 Name="VCLinkerTool"
7272 AdditionalOptions="/MACHINE:I386"
73- AdditionalDependencies="wsock32.lib comctl32.lib winmm.lib htmlhelp.lib"
73+ AdditionalDependencies="comctl32.lib htmlhelp.lib rasapi32.lib winmm.lib wsock32.lib"
7474 OutputFile=".\Debug\FFFTP.exe"
7575 LinkIncremental="2"
7676 SuppressStartupBanner="true"
@@ -137,7 +137,7 @@
137137 Name="VCCLCompilerTool"
138138 InlineFunctionExpansion="1"
139139 AdditionalIncludeDirectories="Resource"
140- PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS,_WIN32_IE=0x300,_CRT_SECURE_NO_WARNINGS"
140+ PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS,WINVER=0x0500,_WIN32_WINNT=0x0500,_WIN32_IE=0x0400,_CRT_SECURE_NO_WARNINGS"
141141 StringPooling="true"
142142 RuntimeLibrary="0"
143143 EnableFunctionLevelLinking="true"
@@ -163,7 +163,7 @@
163163 <Tool
164164 Name="VCLinkerTool"
165165 AdditionalOptions="/MACHINE:I386"
166- AdditionalDependencies="wsock32.lib comctl32.lib winmm.lib RASAPI32.LIB htmlhelp.lib"
166+ AdditionalDependencies="comctl32.lib htmlhelp.lib rasapi32.lib winmm.lib wsock32.lib"
167167 OutputFile=".\Release\FFFTP.exe"
168168 LinkIncremental="1"
169169 SuppressStartupBanner="true"
Binary files a/FFFTP_Eng_Release/FFFTP.exe and b/FFFTP_Eng_Release/FFFTP.exe differ
--- a/FFFTP_English.vc90.vcproj
+++ b/FFFTP_English.vc90.vcproj
@@ -48,7 +48,7 @@
4848 Name="VCCLCompilerTool"
4949 Optimization="0"
5050 AdditionalIncludeDirectories="Resource_eng"
51- PreprocessorDefinitions="WIN32,_DEBUG,_WINDOWS,_WIN32_IE=0x300,_CRT_SECURE_NO_WARNINGS,ENGLISH"
51+ PreprocessorDefinitions="WIN32,_DEBUG,_WINDOWS,WINVER=0x0500,_WIN32_WINNT=0x0500,_WIN32_IE=0x0400,_CRT_SECURE_NO_WARNINGS,ENGLISH"
5252 BasicRuntimeChecks="3"
5353 RuntimeLibrary="1"
5454 PrecompiledHeaderFile=".\FFFTP_Eng_Debug\FFFTP_English.pch"
@@ -73,7 +73,7 @@
7373 <Tool
7474 Name="VCLinkerTool"
7575 AdditionalOptions="/MACHINE:I386"
76- AdditionalDependencies="wsock32.lib comctl32.lib winmm.lib htmlhelp.lib"
76+ AdditionalDependencies="comctl32.lib htmlhelp.lib rasapi32.lib winmm.lib wsock32.lib"
7777 OutputFile=".\FFFTP_Eng_Debug\FFFTP.exe"
7878 LinkIncremental="2"
7979 SuppressStartupBanner="true"
@@ -139,7 +139,7 @@
139139 Name="VCCLCompilerTool"
140140 InlineFunctionExpansion="1"
141141 AdditionalIncludeDirectories="Resource_eng"
142- PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS,_WIN32_IE=0x300,_CRT_SECURE_NO_WARNINGS,ENGLISH"
142+ PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS,WINVER=0x0500,_WIN32_WINNT=0x0500,_WIN32_IE=0x0400,_CRT_SECURE_NO_WARNINGS,ENGLISH"
143143 StringPooling="true"
144144 RuntimeLibrary="0"
145145 EnableFunctionLevelLinking="true"
@@ -164,7 +164,7 @@
164164 <Tool
165165 Name="VCLinkerTool"
166166 AdditionalOptions="/MACHINE:I386"
167- AdditionalDependencies="wsock32.lib comctl32.lib winmm.lib htmlhelp.lib"
167+ AdditionalDependencies="comctl32.lib htmlhelp.lib rasapi32.lib winmm.lib wsock32.lib"
168168 OutputFile=".\FFFTP_Eng_Release\FFFTP.exe"
169169 LinkIncremental="1"
170170 SuppressStartupBanner="true"
--- a/FFFTP_English.vcproj
+++ b/FFFTP_English.vcproj
@@ -47,7 +47,7 @@
4747 Name="VCCLCompilerTool"
4848 Optimization="0"
4949 AdditionalIncludeDirectories="Resource_eng"
50- PreprocessorDefinitions="WIN32,_DEBUG,_WINDOWS,_WIN32_IE=0x300,_CRT_SECURE_NO_WARNINGS,ENGLISH"
50+ PreprocessorDefinitions="WIN32,_DEBUG,_WINDOWS,WINVER=0x0500,_WIN32_WINNT=0x0500,_WIN32_IE=0x0400,_CRT_SECURE_NO_WARNINGS,ENGLISH"
5151 BasicRuntimeChecks="3"
5252 RuntimeLibrary="1"
5353 PrecompiledHeaderFile=".\FFFTP_Eng_Debug\FFFTP_English.pch"
@@ -72,7 +72,7 @@
7272 <Tool
7373 Name="VCLinkerTool"
7474 AdditionalOptions="/MACHINE:I386"
75- AdditionalDependencies="wsock32.lib comctl32.lib winmm.lib htmlhelp.lib"
75+ AdditionalDependencies="comctl32.lib htmlhelp.lib rasapi32.lib winmm.lib wsock32.lib"
7676 OutputFile=".\FFFTP_Eng_Debug\FFFTP.exe"
7777 LinkIncremental="2"
7878 SuppressStartupBanner="true"
@@ -139,7 +139,7 @@
139139 Name="VCCLCompilerTool"
140140 InlineFunctionExpansion="1"
141141 AdditionalIncludeDirectories="Resource_eng"
142- PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS,_WIN32_IE=0x300,_CRT_SECURE_NO_WARNINGS,ENGLISH"
142+ PreprocessorDefinitions="WIN32,NDEBUG,_WINDOWS,WINVER=0x0500,_WIN32_WINNT=0x0500,_WIN32_IE=0x0400,_CRT_SECURE_NO_WARNINGS,ENGLISH"
143143 StringPooling="true"
144144 RuntimeLibrary="0"
145145 EnableFunctionLevelLinking="true"
@@ -164,7 +164,7 @@
164164 <Tool
165165 Name="VCLinkerTool"
166166 AdditionalOptions="/MACHINE:I386"
167- AdditionalDependencies="wsock32.lib comctl32.lib winmm.lib htmlhelp.lib"
167+ AdditionalDependencies="comctl32.lib htmlhelp.lib rasapi32.lib winmm.lib wsock32.lib"
168168 OutputFile=".\FFFTP_Eng_Release\FFFTP.exe"
169169 LinkIncremental="1"
170170 SuppressStartupBanner="true"
Binary files a/Release/FFFTP.exe and b/Release/FFFTP.exe differ
--- a/bookmark.c
+++ b/bookmark.c
@@ -27,7 +27,8 @@
2727 / THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2828 /============================================================================*/
2929
30-#define WINVER 0x400
30+// UTF-8対応
31+//#define WINVER 0x400
3132
3233 #define STRICT
3334 #include <windows.h>
--- a/common.h
+++ b/common.h
@@ -868,6 +868,10 @@ LIST_UNIX_70
868868 #define CRYPT_FTPIS 2
869869 #define CRYPT_SFTP 3
870870
871+// FEAT対応
872+// UTF-8対応
873+#define FEATURE_UTF8 0x00000001
874+
871875
872876 /*=================================================
873877 * ストラクチャ
@@ -918,6 +922,8 @@ typedef struct {
918922 int UseSFTP; /* SFTPで接続する (YES/NO) */
919923 // 同時接続対応
920924 int MaxThreadCount; /* 同時接続数 */
925+ // FEAT対応
926+ int Feature; /* 利用可能な機能のフラグ (FEATURE_xxx) */
921927 } HOSTDATA;
922928
923929
@@ -1383,6 +1389,8 @@ int AskUseFTPIS(void);
13831389 int AskUseSFTP(void);
13841390 // 同時接続対応
13851391 int AskMaxThreadCount(void);
1392+// FEAT対応
1393+int AskHostFeature(void);
13861394
13871395 /*===== cache.c =====*/
13881396
--- a/connect.c
+++ b/connect.c
@@ -957,7 +957,7 @@ int ReConnectCmdSkt(void)
957957 // 同時接続対応
958958 int ReConnectTrnSkt(SOCKET *Skt)
959959 {
960- char Path[FMAX_PATH+1];
960+// char Path[FMAX_PATH+1];
961961 int Sts;
962962
963963 Sts = FFFTP_FAIL;
@@ -1092,8 +1092,8 @@ int AskShareProh(void)
10921092 int Sts;
10931093
10941094 Sts = YES;
1095- if(CmdCtrlSocket == TrnCtrlSocket)
1096- Sts = NO;
1095+// if(CmdCtrlSocket == TrnCtrlSocket)
1096+// Sts = NO;
10971097
10981098 return(Sts);
10991099 }
@@ -1476,6 +1476,26 @@ static SOCKET DoConnect(char *Host, char *User, char *Pass, char *Acct, int Port
14761476 #endif
14771477 TryConnect = NO;
14781478
1479+ // FEAT対応
1480+ // ホストの機能を確認
1481+ if(ContSock != INVALID_SOCKET)
1482+ {
1483+ if((Sts = command(ContSock, Reply, &CancelFlg, "FEAT")) == 211)
1484+ {
1485+ // 改行文字はReadReplyMessageで消去されるため区切り文字に空白を使用
1486+ // UTF-8対応
1487+ if(strstr(Reply, " UTF8 "))
1488+ CurHost.Feature |= FEATURE_UTF8;
1489+ }
1490+ // UTF-8対応
1491+ if(CurHost.NameKanjiCode == KANJI_AUTO && (CurHost.Feature & FEATURE_UTF8))
1492+ {
1493+ if((Sts = command(ContSock, Reply, &CancelFlg, "OPTS UTF8 ON")) == 200)
1494+ {
1495+ }
1496+ }
1497+ }
1498+
14791499 return(ContSock);
14801500 }
14811501
@@ -2238,3 +2258,9 @@ int AskMaxThreadCount(void)
22382258 return(CurHost.MaxThreadCount);
22392259 }
22402260
2261+// FEAT対応
2262+int AskHostFeature(void)
2263+{
2264+ return(CurHost.Feature);
2265+}
2266+
--- a/filelist.c
+++ b/filelist.c
@@ -27,7 +27,8 @@
2727 / THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2828 /============================================================================*/
2929
30-#define _WIN32_WINNT 0x400
30+// UTF-8対応
31+//#define _WIN32_WINNT 0x400
3132
3233 #define STRICT
3334 #include <windows.h>
@@ -3593,7 +3594,6 @@ static int AnalizeFileInfo(char *Str)
35933594 }
35943595 }
35953596 }
3596-
35973597 }
35983598
35993599 DoPrintf("ListType=%d", Ret);
--- a/getput.c
+++ b/getput.c
@@ -120,6 +120,8 @@ static HANDLE hListAccMutex; /* 転送ファイルアクセス用ミューテ
120120
121121 static int TransFiles = 0; /* 転送待ちファイル数 */
122122 static TRANSPACKET *TransPacketBase = NULL; /* 転送ファイルリスト */
123+// 同時接続対応
124+static TRANSPACKET *NextTransPacketBase = NULL;
123125
124126 // 同時接続対応
125127 //static int Canceled; /* 中止フラグ YES/NO */
@@ -373,6 +375,9 @@ void AddTransFileList(TRANSPACKET *Pkt)
373375 PostMessage(GetMainHwnd(), WM_CHANGE_COND, 0, 0);
374376 }
375377 }
378+ // 同時接続対応
379+ if(NextTransPacketBase == NULL)
380+ NextTransPacketBase = TransPacketBase;
376381 ReleaseMutex(hListAccMutex);
377382
378383 return;
@@ -413,6 +418,9 @@ void AppendTransFileList(TRANSPACKET *Pkt)
413418 Pos = Pos->Next;
414419 Pos->Next = Pkt;
415420 }
421+ // 同時接続対応
422+ if(NextTransPacketBase == NULL)
423+ NextTransPacketBase = TransPacketBase;
416424
417425 while(Pkt != NULL)
418426 {
@@ -494,19 +502,26 @@ static void EraseTransFileList(void)
494502 if(strcmp(New->Cmd, "BACKCUR") == 0)
495503 {
496504 if(NotDel != NULL)
497- free(NotDel);
505+ // 同時接続対応
506+// free(NotDel);
507+ strcpy(NotDel->Cmd, "");
498508 NotDel = New;
499509 New = New->Next;
500- NotDel->Next = NULL;
510+ // 同時接続対応
511+// NotDel->Next = NULL;
501512 }
502513 else
503514 {
504515 Next = New->Next;
505- free(New);
516+ // 同時接続対応
517+// free(New);
518+ strcpy(New->Cmd, "");
506519 New = Next;
507520 }
508521 }
509522 TransPacketBase = NotDel;
523+ // 同時接続対応
524+ NextTransPacketBase = TransPacketBase;
510525 TransFiles = 0;
511526 PostMessage(GetMainHwnd(), WM_CHANGE_COND, 0, 0);
512527 ReleaseMutex(hListAccMutex);
@@ -611,8 +626,10 @@ static ULONG WINAPI TransferThread(void *Dummy)
611626 char Tmp[FMAX_PATH+1];
612627 int CwdSts;
613628 int GoExit;
614- int Down;
615- int Up;
629+// int Down;
630+// int Up;
631+ static int Down;
632+ static int Up;
616633 int DelNotify;
617634 int ThreadCount;
618635 SOCKET CmdSkt;
@@ -650,6 +667,12 @@ static ULONG WINAPI TransferThread(void *Dummy)
650667 // Canceled = NO;
651668 Canceled[ThreadCount] = NO;
652669
670+ while(TransPacketBase != NULL && strcmp(TransPacketBase->Cmd, "") == 0)
671+ {
672+ Pos = TransPacketBase;
673+ TransPacketBase = TransPacketBase->Next;
674+ free(Pos);
675+ }
653676 NewCmdSkt = AskCmdCtrlSkt();
654677 if(TransPacketBase && NewCmdSkt != INVALID_SOCKET && ThreadCount < AskMaxThreadCount())
655678 {
@@ -682,10 +705,10 @@ static ULONG WINAPI TransferThread(void *Dummy)
682705 }
683706 CmdSkt = NewCmdSkt;
684707 // if(TransPacketBase != NULL)
685- if(TrnSkt != INVALID_SOCKET && TransPacketBase != NULL)
708+ if(TrnSkt != INVALID_SOCKET && NextTransPacketBase != NULL)
686709 {
687- Pos = TransPacketBase;
688- TransPacketBase = TransPacketBase->Next;
710+ Pos = NextTransPacketBase;
711+ NextTransPacketBase = NextTransPacketBase->Next;
689712 // ディレクトリ操作は非同期で行わない
690713 // ReleaseMutex(hListAccMutex);
691714 if(hWndTrans == NULL)
@@ -1003,6 +1026,7 @@ static ULONG WINAPI TransferThread(void *Dummy)
10031026 for(i = 0; i < MAX_DATA_CONNECTION; i++)
10041027 Canceled[i] = YES;
10051028 EraseTransFileList();
1029+ Pos = NULL;
10061030 }
10071031 else
10081032 {
@@ -1032,7 +1056,8 @@ static ULONG WINAPI TransferThread(void *Dummy)
10321056 }
10331057 if(hWndTrans != NULL)
10341058 SendMessage(hWndTrans, WM_SET_PACKET, 0, 0);
1035- free(Pos);
1059+ if(Pos != NULL)
1060+ strcpy(Pos->Cmd, "");
10361061 }
10371062 // else
10381063 else if(TransPacketBase == NULL)
@@ -1047,20 +1072,20 @@ static ULONG WINAPI TransferThread(void *Dummy)
10471072 DestroyWindow(hWndTrans);
10481073 hWndTrans = NULL;
10491074
1050- if(GoExit == YES)
1051- {
1052- SoundPlay(SND_TRANS);
1053-
1054- if(AskAutoExit() == NO)
1055- {
1056- if(Down == YES)
1057- PostMessage(GetMainHwnd(), WM_REFRESH_LOCAL_FLG, 0, 0);
1058- if(Up == YES)
1059- PostMessage(GetMainHwnd(), WM_REFRESH_REMOTE_FLG, 0, 0);
1060- }
1061- Down = NO;
1062- Up = NO;
1063- }
1075+// if(GoExit == YES)
1076+// {
1077+// SoundPlay(SND_TRANS);
1078+//
1079+// if(AskAutoExit() == NO)
1080+// {
1081+// if(Down == YES)
1082+// PostMessage(GetMainHwnd(), WM_REFRESH_LOCAL_FLG, 0, 0);
1083+// if(Up == YES)
1084+// PostMessage(GetMainHwnd(), WM_REFRESH_REMOTE_FLG, 0, 0);
1085+// }
1086+// Down = NO;
1087+// Up = NO;
1088+// }
10641089 }
10651090 }
10661091 BackgrndMessageProc();
@@ -1068,6 +1093,16 @@ static ULONG WINAPI TransferThread(void *Dummy)
10681093
10691094 if(GoExit == YES)
10701095 {
1096+ SoundPlay(SND_TRANS);
1097+ if(AskAutoExit() == NO)
1098+ {
1099+ if(Down == YES)
1100+ PostMessage(GetMainHwnd(), WM_REFRESH_LOCAL_FLG, 0, 0);
1101+ if(Up == YES)
1102+ PostMessage(GetMainHwnd(), WM_REFRESH_REMOTE_FLG, 0, 0);
1103+ }
1104+ Down = NO;
1105+ Up = NO;
10711106 PostMessage(GetMainHwnd(), WM_COMMAND, MAKEWPARAM(MENU_AUTO_EXIT, 0), 0);
10721107 GoExit = NO;
10731108 }
--- a/hostman.c
+++ b/hostman.c
@@ -1309,6 +1309,7 @@ void CopyDefaultHost(HOSTDATA *Set)
13091309 Set->UseSFTP = YES;
13101310 // 同時接続対応
13111311 Set->MaxThreadCount = 1;
1312+ Set->Feature = 0;
13121313 return;
13131314 }
13141315
@@ -1526,6 +1527,10 @@ static int DispHostSetDlg(HWND hDlg)
15261527 PROPSHEETPAGE psp[7];
15271528 PROPSHEETHEADER psh;
15281529
1530+ // 変数が未初期化のバグ修正
1531+ memset(&psp, 0, sizeof(psp));
1532+ memset(&psh, 0, sizeof(psh));
1533+
15291534 psp[0].dwSize = sizeof(PROPSHEETPAGE);
15301535 psp[0].dwFlags = PSP_USETITLE | PSP_HASHELP;
15311536 psp[0].hInstance = GetFtpInst();
--- a/main.c
+++ b/main.c
@@ -244,6 +244,7 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLi
244244
245245 InitCommonControls();
246246
247+ // FTPS対応
247248 #ifdef USE_OPENSSL
248249 LoadOpenSSL();
249250 #endif
@@ -277,6 +278,7 @@ int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLi
277278 Ret = Msg.wParam;
278279 }
279280 UnregisterClass(FtpClassStr, hInstFtp);
281+ // FTPS対応
280282 #ifdef USE_OPENSSL
281283 FreeOpenSSL();
282284 #endif
--- a/mbswrapper.c
+++ b/mbswrapper.c
@@ -1,4 +1,4 @@
1-// mbswrapper.cpp
1+// mbswrapper.c
22 // Copyright (C) 2011 Suguru Kawamoto
33 // マルチバイト文字ワイド文字APIラッパー
44 // マルチバイト文字はUTF-8、ワイド文字はUTF-16であるものとする
@@ -6,9 +6,6 @@
66
77 #define UNICODE
88 #define _UNICODE
9-#define _WIN32_WINNT 0x0600
10-#undef _WIN32_IE
11-#define _WIN32_IE 0x0400
129
1310 #include <tchar.h>
1411 #include <direct.h>
@@ -40,6 +37,16 @@ int WtoM(LPSTR pDst, int size, LPCWSTR pSrc, int count)
4037 return WideCharToMultiByte(CP_UTF8, 0, pSrc, count, NULL, 0, NULL, NULL);
4138 }
4239
40+// Shift_JIS文字列からワイド文字列へ変換
41+int AtoW(LPWSTR pDst, int size, LPCSTR pSrc, int count)
42+{
43+ if(pSrc < (LPCSTR)0x00010000 || pSrc == (LPCSTR)~0)
44+ return 0;
45+ if(pDst)
46+ return MultiByteToWideChar(CP_ACP, 0, pSrc, count, pDst, size);
47+ return MultiByteToWideChar(CP_ACP, 0, pSrc, count, NULL, 0);
48+}
49+
4350 // ワイド文字列からShift_JIS文字列へ変換
4451 int WtoA(LPSTR pDst, int size, LPCWSTR pSrc, int count)
4552 {
@@ -179,6 +186,24 @@ int WtoMMultiString(LPSTR pDst, int size, LPCWSTR pSrc)
179186 return i;
180187 }
181188
189+// NULL区切りShift_JIS文字列からワイド文字列へ変換
190+int AtoWMultiString(LPWSTR pDst, int size, LPCSTR pSrc)
191+{
192+ int i;
193+ if(pSrc < (LPCSTR)0x00010000 || pSrc == (LPCSTR)~0)
194+ return 0;
195+ if(!pDst)
196+ return GetMultiStringLengthA(pSrc);
197+ i = 0;
198+ while(*pSrc != '\0')
199+ {
200+ i += MultiByteToWideChar(CP_ACP, 0, pSrc, -1, pDst + i, size - i - 1);
201+ pSrc += strlen(pSrc) + 1;
202+ }
203+ pDst[i] = L'\0';
204+ return i;
205+}
206+
182207 // NULL区切りワイド文字列からShift_JIS文字列へ変換
183208 int WtoAMultiString(LPSTR pDst, int size, LPCWSTR pSrc)
184209 {
@@ -234,6 +259,7 @@ char* AllocateStringA(int size)
234259 }
235260
236261 // メモリを確保してマルチバイト文字列からワイド文字列へ変換
262+// リソースIDならば元の値を返す
237263 wchar_t* DuplicateMtoW(LPCSTR lpString, int c)
238264 {
239265 wchar_t* p;
@@ -252,6 +278,7 @@ wchar_t* DuplicateMtoW(LPCSTR lpString, int c)
252278 }
253279
254280 // 指定したサイズのメモリを確保してマルチバイト文字列からワイド文字列へ変換
281+// リソースIDならば元の値を返す
255282 wchar_t* DuplicateMtoWBuffer(LPCSTR lpString, int c, int size)
256283 {
257284 wchar_t* p;
@@ -270,6 +297,7 @@ wchar_t* DuplicateMtoWBuffer(LPCSTR lpString, int c, int size)
270297 }
271298
272299 // メモリを確保してNULL区切りマルチバイト文字列からワイド文字列へ変換
300+// リソースIDならば元の値を返す
273301 wchar_t* DuplicateMtoWMultiString(LPCSTR lpString)
274302 {
275303 int count;
@@ -284,6 +312,7 @@ wchar_t* DuplicateMtoWMultiString(LPCSTR lpString)
284312 }
285313
286314 // 指定したサイズのメモリを確保してNULL区切りマルチバイト文字列からワイド文字列へ変換
315+// リソースIDならば元の値を返す
287316 wchar_t* DuplicateMtoWMultiStringBuffer(LPCSTR lpString, int size)
288317 {
289318 int count;
@@ -302,6 +331,7 @@ wchar_t* DuplicateMtoWMultiStringBuffer(LPCSTR lpString, int size)
302331 }
303332
304333 // メモリを確保してワイド文字列からマルチバイト文字列へ変換
334+// リソースIDならば元の値を返す
305335 char* DuplicateWtoM(LPCWSTR lpString, int c)
306336 {
307337 char* p;
@@ -319,7 +349,27 @@ char* DuplicateWtoM(LPCWSTR lpString, int c)
319349 return p;
320350 }
321351
352+// メモリを確保してShift_JIS文字列からワイド文字列へ変換
353+// リソースIDならば元の値を返す
354+wchar_t* DuplicateAtoW(LPCSTR lpString, int c)
355+{
356+ wchar_t* p;
357+ int i;
358+ if(lpString < (LPCSTR)0x00010000 || lpString == (LPCSTR)~0)
359+ return (wchar_t*)lpString;
360+ if(c < 0)
361+ c = strlen(lpString);
362+ p = AllocateStringW(AtoW(NULL, 0, lpString, c) + 1);
363+ if(p)
364+ {
365+ i = AtoW(p, 65535, lpString, c);
366+ p[i] = L'\0';
367+ }
368+ return p;
369+}
370+
322371 // メモリを確保してワイド文字列からShift_JIS文字列へ変換
372+// リソースIDならば元の値を返す
323373 char* DuplicateWtoA(LPCWSTR lpString, int c)
324374 {
325375 char* p;
@@ -338,6 +388,7 @@ char* DuplicateWtoA(LPCWSTR lpString, int c)
338388 }
339389
340390 // 文字列用に確保したメモリを開放
391+// リソースIDならば何もしない
341392 void FreeDuplicatedString(void* p)
342393 {
343394 if(p < (void*)0x00010000 || p == (void*)~0)
@@ -351,10 +402,35 @@ void FreeDuplicatedString(void* p)
351402 // マルチバイト文字バッファ pm%d
352403 // 引数バッファ a%d
353404
405+#pragma warning(disable:4102)
354406 #define START_ROUTINE do{
355407 #define END_ROUTINE }while(0);end_of_routine:
356408 #define QUIT_ROUTINE goto end_of_routine;
357409
410+int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow)
411+{
412+ int r = 0;
413+ char* pm0 = NULL;
414+START_ROUTINE
415+ pm0 = DuplicateWtoM(lpCmdLine, -1);
416+ r = WinMainM(hInstance, hPrevInstance, pm0, nCmdShow);
417+END_ROUTINE
418+ FreeDuplicatedString(pm0);
419+ return r;
420+}
421+
422+HMODULE LoadLibraryM(LPCSTR lpLibFileName)
423+{
424+ HMODULE r = NULL;
425+ wchar_t* pw0 = NULL;
426+START_ROUTINE
427+ pw0 = DuplicateMtoW(lpLibFileName, -1);
428+ r = LoadLibraryW(pw0);
429+END_ROUTINE
430+ FreeDuplicatedString(pw0);
431+ return r;
432+}
433+
358434 HANDLE CreateFileM(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile)
359435 {
360436 HANDLE r = INVALID_HANDLE_VALUE;
@@ -874,11 +950,24 @@ END_ROUTINE
874950 return r;
875951 }
876952
953+LPSTR GetCommandLineM()
954+{
955+ LPSTR r = 0;
956+ static char* pm0 = NULL;
957+START_ROUTINE
958+ if(!pm0)
959+ pm0 = DuplicateWtoM(GetCommandLineW(), -1);
960+ r = pm0;
961+END_ROUTINE
962+ return r;
963+}
964+
877965 DWORD GetCurrentDirectoryM(DWORD nBufferLength, LPSTR lpBuffer)
878966 {
879967 DWORD r = 0;
880968 wchar_t* pw0 = NULL;
881969 START_ROUTINE
970+ // TODO: バッファが不十分な場合に必要なサイズを返す
882971 pw0 = AllocateStringW(nBufferLength * 4);
883972 GetCurrentDirectoryW(nBufferLength * 4, pw0);
884973 WtoM(lpBuffer, nBufferLength, pw0, -1);
@@ -900,18 +989,6 @@ END_ROUTINE
900989 return r;
901990 }
902991
903-BOOL SetDllDirectoryM(LPCSTR lpPathName)
904-{
905- BOOL r = FALSE;
906- wchar_t* pw0 = NULL;
907-START_ROUTINE
908- pw0 = DuplicateMtoW(lpPathName, -1);
909- r = SetDllDirectoryW(pw0);
910-END_ROUTINE
911- FreeDuplicatedString(pw0);
912- return r;
913-}
914-
915992 DWORD GetTempPathM(DWORD nBufferLength, LPSTR lpBuffer)
916993 {
917994 DWORD r = 0;
@@ -1100,56 +1177,79 @@ START_ROUTINE
11001177 a0.hIcon = v0->hIcon;
11011178 a0.pszCaption = DuplicateMtoW(v0->pszCaption, -1);
11021179 a0.nPages = v0->nPages;
1103- a0.pStartPage = DuplicateMtoW(v0->pStartPage, -1);
1104- if(v0->ppsp && (pwPage = (PROPSHEETPAGEW*)malloc(sizeof(PROPSHEETPAGEW) * v0->nPages)))
1180+ if(v0->dwFlags & PSH_USEPSTARTPAGE)
1181+ a0.pStartPage = DuplicateMtoW(v0->pStartPage, -1);
1182+ else
1183+ a0.nStartPage = v0->nStartPage;
1184+ if(v0->dwFlags & PSH_PROPSHEETPAGE)
11051185 {
1106- for(i = 0; i < v0->nPages; i++)
1186+ if(v0->ppsp && (pwPage = (PROPSHEETPAGEW*)malloc(sizeof(PROPSHEETPAGEW) * v0->nPages)))
11071187 {
1108- pwPage[i].dwSize = sizeof(PROPSHEETPAGEW);
1109- pwPage[i].dwFlags = v0->ppsp[i].dwFlags;
1110- pwPage[i].hInstance = v0->ppsp[i].hInstance;
1111- pwPage[i].pszTemplate = DuplicateMtoW(v0->ppsp[i].pszTemplate, -1);
1112- if(v0->ppsp[i].dwFlags & PSP_USEICONID)
1113- pwPage[i].pszIcon = DuplicateMtoW(v0->ppsp[i].pszIcon, -1);
1114- else
1115- pwPage[i].hIcon = v0->ppsp[i].hIcon;
1116- if(v0->ppsp[i].dwFlags & PSP_USETITLE)
1117- pwPage[i].pszTitle = DuplicateMtoW(v0->ppsp[i].pszTitle, -1);
1118- pwPage[i].pfnDlgProc = v0->ppsp[i].pfnDlgProc;
1119- pwPage[i].lParam = v0->ppsp[i].lParam;
1120- // TODO: pfnCallback
1121- pwPage[i].pfnCallback = v0->ppsp[i].pfnCallback;
1122- pwPage[i].pcRefParent = v0->ppsp[i].pcRefParent;
1123-// pwPage[i].pszHeaderTitle = DuplicateMtoW(v0->ppsp[i].pszHeaderTitle, -1);
1124-// pwPage[i].pszHeaderSubTitle = DuplicateMtoW(v0->ppsp[i].pszHeaderSubTitle, -1);
1125- pwPage[i].hActCtx = v0->ppsp[i].hActCtx;
1126-// pwPage[i].pszbmHeader = DuplicateMtoW(v0->ppsp[i].pszbmHeader, -1);
1188+ for(i = 0; i < v0->nPages; i++)
1189+ {
1190+ pwPage[i].dwSize = sizeof(PROPSHEETPAGEW);
1191+ pwPage[i].dwFlags = v0->ppsp[i].dwFlags;
1192+ pwPage[i].hInstance = v0->ppsp[i].hInstance;
1193+ if(v0->ppsp[i].dwFlags & PSP_DLGINDIRECT)
1194+ pwPage[i].pResource = v0->ppsp[i].pResource;
1195+ else
1196+ pwPage[i].pszTemplate = DuplicateMtoW(v0->ppsp[i].pszTemplate, -1);
1197+ if(v0->ppsp[i].dwFlags & PSP_USEICONID)
1198+ pwPage[i].pszIcon = DuplicateMtoW(v0->ppsp[i].pszIcon, -1);
1199+ else
1200+ pwPage[i].hIcon = v0->ppsp[i].hIcon;
1201+ if(v0->ppsp[i].dwFlags & PSP_USETITLE)
1202+ pwPage[i].pszTitle = DuplicateMtoW(v0->ppsp[i].pszTitle, -1);
1203+ pwPage[i].pfnDlgProc = v0->ppsp[i].pfnDlgProc;
1204+ pwPage[i].lParam = v0->ppsp[i].lParam;
1205+ // TODO: pfnCallback
1206+ pwPage[i].pfnCallback = (LPFNPSPCALLBACKW)v0->ppsp[i].pfnCallback;
1207+ pwPage[i].pcRefParent = v0->ppsp[i].pcRefParent;
1208+ if(v0->ppsp[i].dwFlags & PSP_USEHEADERTITLE)
1209+ pwPage[i].pszHeaderTitle = DuplicateMtoW(v0->ppsp[i].pszHeaderTitle, -1);
1210+ if(v0->ppsp[i].dwFlags & PSP_USEHEADERSUBTITLE)
1211+ pwPage[i].pszHeaderSubTitle = DuplicateMtoW(v0->ppsp[i].pszHeaderSubTitle, -1);
1212+ }
11271213 }
1214+ else
1215+ pwPage = NULL;
1216+ a0.ppsp = pwPage;
11281217 }
11291218 else
1130- pwPage = NULL;
1131- a0.ppsp = pwPage;
1219+ a0.phpage = v0->phpage;
11321220 a0.pfnCallback = v0->pfnCallback;
1221+ if(v0->dwFlags & PSH_USEHBMWATERMARK)
1222+ a0.hbmWatermark = v0->hbmWatermark;
1223+ else
1224+ a0.pszbmWatermark = DuplicateMtoW(v0->pszbmWatermark, -1);
11331225 r = PropertySheetW(&a0);
11341226 if(a0.dwFlags & PSH_USEICONID)
1135- FreeDuplicatedString(a0.pszIcon);
1136- FreeDuplicatedString(a0.pszCaption);
1137- FreeDuplicatedString(a0.pStartPage);
1138- if(pwPage)
1227+ FreeDuplicatedString((void*)a0.pszIcon);
1228+ FreeDuplicatedString((void*)a0.pszCaption);
1229+ if(v0->dwFlags & PSH_USEPSTARTPAGE)
1230+ FreeDuplicatedString((void*)a0.pStartPage);
1231+ if(v0->dwFlags & PSH_PROPSHEETPAGE)
11391232 {
1140- for(i = 0; i < v0->nPages; i++)
1233+ if(pwPage)
11411234 {
1142- FreeDuplicatedString(pwPage[i].pszTemplate);
1143- if(pwPage[i].dwFlags & PSP_USEICONID)
1144- FreeDuplicatedString(pwPage[i].pszIcon);
1145- if(pwPage[i].dwFlags & PSP_USETITLE)
1146- FreeDuplicatedString(pwPage[i].pszTitle);
1147-// FreeDuplicatedString(pwPage[i].pszHeaderTitle);
1148-// FreeDuplicatedString(pwPage[i].pszHeaderSubTitle);
1149-// FreeDuplicatedString(pwPage[i].pszbmHeader);
1235+ for(i = 0; i < v0->nPages; i++)
1236+ {
1237+ if(!(v0->ppsp[i].dwFlags & PSP_DLGINDIRECT))
1238+ FreeDuplicatedString((void*)pwPage[i].pszTemplate);
1239+ if(v0->ppsp[i].dwFlags & PSP_USEICONID)
1240+ FreeDuplicatedString((void*)pwPage[i].pszIcon);
1241+ if(v0->ppsp[i].dwFlags & PSP_USETITLE)
1242+ FreeDuplicatedString((void*)pwPage[i].pszTitle);
1243+ if(v0->ppsp[i].dwFlags & PSP_USEHEADERTITLE)
1244+ FreeDuplicatedString((void*)pwPage[i].pszHeaderTitle);
1245+ if(v0->ppsp[i].dwFlags & PSP_USEHEADERSUBTITLE)
1246+ FreeDuplicatedString((void*)pwPage[i].pszHeaderSubTitle);
1247+ }
1248+ free(pwPage);
11501249 }
1151- free(pwPage);
11521250 }
1251+ if(!(v0->dwFlags & PSH_USEHBMWATERMARK))
1252+ FreeDuplicatedString((void*)a0.pszbmWatermark);
11531253 END_ROUTINE
11541254 return r;
11551255 }
@@ -1437,7 +1537,8 @@ START_ROUTINE
14371537 wFileOp.fFlags = lpFileOp->fFlags;
14381538 wFileOp.fAnyOperationsAborted = lpFileOp->fAnyOperationsAborted;
14391539 wFileOp.hNameMappings = lpFileOp->hNameMappings;
1440- pw2 = DuplicateMtoW(lpFileOp->lpszProgressTitle, -1);
1540+ if(lpFileOp->fFlags & FOF_SIMPLEPROGRESS)
1541+ pw2 = DuplicateMtoW(lpFileOp->lpszProgressTitle, -1);
14411542 r = SHFileOperationW(&wFileOp);
14421543 lpFileOp->fAnyOperationsAborted = wFileOp.fAnyOperationsAborted;
14431544 END_ROUTINE
@@ -1479,9 +1580,13 @@ START_ROUTINE
14791580 wmii.hbmpChecked = lpmii->hbmpChecked;
14801581 wmii.hbmpUnchecked = lpmii->hbmpUnchecked;
14811582 wmii.dwItemData = lpmii->dwItemData;
1482- pw0 = DuplicateMtoWBuffer(lpmii->dwTypeData, -1, lpmii->cch * 4);
1483- wmii.dwTypeData = pw0;
1484- wmii.cch = lpmii->cch * 4;
1583+ if(lpmii->fMask & MIIM_TYPE)
1584+ {
1585+ pw0 = DuplicateMtoWBuffer(lpmii->dwTypeData, -1, lpmii->cch * 4);
1586+ wmii.dwTypeData = pw0;
1587+ wmii.cch = lpmii->cch * 4;
1588+ }
1589+ wmii.hbmpItem = lpmii->hbmpItem;
14851590 r = GetMenuItemInfoW(hmenu, item, fByPosition, &wmii);
14861591 lpmii->fType = wmii.fType;
14871592 lpmii->fState = wmii.fState;
@@ -1589,7 +1694,7 @@ START_ROUTINE
15891694 v0->nFontType = a0.nFontType;
15901695 if(pwlf)
15911696 free(pwlf);
1592- FreeDuplicatedString(a0.lpTemplateName);
1697+ FreeDuplicatedString((void*)a0.lpTemplateName);
15931698 FreeDuplicatedString(a0.lpszStyle);
15941699 END_ROUTINE
15951700 FreeDuplicatedString(pw0);
@@ -1692,7 +1797,7 @@ START_ROUTINE
16921797 if(wr)
16931798 {
16941799 *wr = L'\0';
1695- r = _Str + WtoM(NULL, 0, pw0, -1) - 1;
1800+ r = (unsigned char*)_Str + WtoM(NULL, 0, pw0, -1) - 1;
16961801 }
16971802 END_ROUTINE
16981803 FreeDuplicatedString(pw0);
@@ -1711,7 +1816,7 @@ START_ROUTINE
17111816 if(wr)
17121817 {
17131818 *wr = L'\0';
1714- r = _Str + WtoM(NULL, 0, pw0, -1) - 1;
1819+ r = (unsigned char*)_Str + WtoM(NULL, 0, pw0, -1) - 1;
17151820 }
17161821 END_ROUTINE
17171822 FreeDuplicatedString(pw0);
@@ -1731,7 +1836,7 @@ START_ROUTINE
17311836 if(wr)
17321837 {
17331838 *wr = L'\0';
1734- r = _Str + WtoM(NULL, 0, pw0, -1) - 1;
1839+ r = (unsigned char*)_Str + WtoM(NULL, 0, pw0, -1) - 1;
17351840 }
17361841 END_ROUTINE
17371842 FreeDuplicatedString(pw0);
@@ -1823,7 +1928,7 @@ START_ROUTINE
18231928 if(wr)
18241929 {
18251930 *wr = L'\0';
1826- r = _Str + WtoM(NULL, 0, pw0, -1) - 1;
1931+ r = (unsigned char*)_Str + WtoM(NULL, 0, pw0, -1) - 1;
18271932 }
18281933 END_ROUTINE
18291934 FreeDuplicatedString(pw0);
--- a/mbswrapper.h
+++ b/mbswrapper.h
@@ -11,6 +11,12 @@
1111
1212 #ifndef DO_NOT_REPLACE
1313
14+#undef WinMain
15+#define WinMain WinMainM
16+int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow);
17+#undef LoadLibrary
18+#define LoadLibrary LoadLibraryM
19+HMODULE LoadLibraryM(LPCSTR lpLibFileName);
1420 #undef CreateFile
1521 #define CreateFile CreateFileM
1622 HANDLE CreateFileM(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
@@ -59,15 +65,15 @@ BOOL SetWindowTextM(HWND hWnd, LPCSTR lpString);
5965 #undef DragQueryFile
6066 #define DragQueryFile DragQueryFileM
6167 UINT DragQueryFileM(HDROP hDrop, UINT iFile, LPSTR lpszFile, UINT cch);
68+#undef GetCommandLine
69+#define GetCommandLine GetCommandLineM
70+LPSTR GetCommandLineM();
6271 #undef GetCurrentDirectory
6372 #define GetCurrentDirectory GetCurrentDirectoryM
6473 DWORD GetCurrentDirectoryM(DWORD nBufferLength, LPSTR lpBuffer);
6574 #undef SetCurrentDirectory
6675 #define SetCurrentDirectory SetCurrentDirectoryM
6776 BOOL SetCurrentDirectoryM(LPCSTR lpPathName);
68-#undef SetDllDirectory
69-#define SetDllDirectory SetDllDirectoryM
70-BOOL SetDllDirectoryM(LPCSTR lpPathName);
7177 #undef GetTempPath
7278 #define GetTempPath GetTempPathM
7379 DWORD GetTempPathM(DWORD nBufferLength, LPSTR lpBuffer);
@@ -201,15 +207,17 @@ FILE * fopenM(const char * _Filename, const char * _Mode);
201207
202208 int MtoW(LPWSTR pDst, int size, LPCSTR pSrc, int count);
203209 int WtoM(LPSTR pDst, int size, LPCWSTR pSrc, int count);
210+int AtoW(LPWSTR pDst, int size, LPCSTR pSrc, int count);
204211 int WtoA(LPSTR pDst, int size, LPCWSTR pSrc, int count);
205212 int TerminateStringM(LPSTR lpString, int size);
206213 int TerminateStringW(LPWSTR lpString, int size);
207-int TerminateStringA(LPWSTR lpString, int size);
214+int TerminateStringA(LPSTR lpString, int size);
208215 size_t GetMultiStringLengthM(LPCSTR lpString);
209216 size_t GetMultiStringLengthW(LPCWSTR lpString);
210-size_t GetMultiStringLengthA(LPCWSTR lpString);
217+size_t GetMultiStringLengthA(LPCSTR lpString);
211218 int MtoWMultiString(LPWSTR pDst, int size, LPCSTR pSrc);
212219 int WtoMMultiString(LPSTR pDst, int size, LPCWSTR pSrc);
220+int AtoWMultiString(LPWSTR pDst, int size, LPCSTR pSrc);
213221 int WtoAMultiString(LPSTR pDst, int size, LPCWSTR pSrc);
214222 char* AllocateStringM(int size);
215223 wchar_t* AllocateStringW(int size);
@@ -219,8 +227,11 @@ wchar_t* DuplicateMtoWBuffer(LPCSTR lpString, int c, int size);
219227 wchar_t* DuplicateMtoWMultiString(LPCSTR lpString);
220228 wchar_t* DuplicateMtoWMultiStringBuffer(LPCSTR lpString, int size);
221229 char* DuplicateWtoM(LPCWSTR lpString, int c);
230+wchar_t* DuplicateAtoW(LPCSTR lpString, int c);
222231 char* DuplicateWtoA(LPCWSTR lpString, int c);
223232 void FreeDuplicatedString(void* p);
224233
234+int WINAPI WinMainM(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow);
235+
225236 #endif
226237
--- a/option.c
+++ b/option.c
@@ -163,6 +163,10 @@ void SetOption(int Start)
163163 PROPSHEETPAGE psp[12];
164164 PROPSHEETHEADER psh;
165165
166+ // 変数が未初期化のバグ修正
167+ memset(&psp, 0, sizeof(psp));
168+ memset(&psh, 0, sizeof(psh));
169+
166170 psp[0].dwSize = sizeof(PROPSHEETPAGE);
167171 psp[0].dwFlags = PSP_USETITLE | PSP_HASHELP;
168172 psp[0].hInstance = GetFtpInst();
--- a/ras.c
+++ b/ras.c
@@ -29,7 +29,8 @@
2929
3030 #define STRICT
3131
32-#define WINVER 0x400
32+// UTF-8対応
33+//#define WINVER 0x400
3334
3435 #include <windows.h>
3536 #include <stdio.h>
--- a/socketwrapper.c
+++ b/socketwrapper.c
@@ -1,4 +1,4 @@
1-// socketwrapper.cpp
1+// socketwrapper.c
22 // Copyright (C) 2011 Suguru Kawamoto
33 // ソケットラッパー
44 // socket関連関数をOpenSSL用に置換