OSDN Git Service

Fix project files.
[ffftp/ffftp.git] / registry.c
index e85ce74..be28d9c 100644 (file)
@@ -33,6 +33,8 @@
 #endif\r
 \r
 #define        STRICT\r
+// IPv6対応\r
+#include <winsock2.h>\r
 #include <windows.h>\r
 #include <stdio.h>\r
 #include <stdlib.h>\r
@@ -84,6 +86,9 @@ static int ReadMultiStringFromReg(void *Handle, char *Name, char *Str, DWORD Siz
 static int WriteMultiStringToReg(void *Handle, char *Name, char *Str);\r
 static int ReadBinaryFromReg(void *Handle, char *Name, void *Bin, DWORD Size);\r
 static int WriteBinaryToReg(void *Handle, char *Name, void *Bin, int Len);\r
+// 暗号化通信対応\r
+static int StrCatOut(char *Src, int Len, char *Dst);\r
+static int StrReadIn(char *Src, int Max, char *Dst);\r
 \r
 int CheckPasswordValidity( char* Password, int length, const char* HashStr );\r
 void CreatePasswordHash( char* Password, int length, char* HashStr );\r
@@ -187,6 +192,9 @@ extern int FolderAttrNum;
 \r
 // 暗号化通信対応\r
 extern BYTE CertificateCacheHash[MAX_CERT_CACHE_HASH][20];\r
+extern BYTE SSLRootCAFileHash[20];\r
+// ファイルアイコン表示対応\r
+extern int DispFileIcon;\r
 \r
 /*----- マスタパスワードの設定 ----------------------------------------------\r
 *\r
@@ -293,6 +301,7 @@ void SaveRegistory(void)
        // 暗号化通信対応\r
 //     char Str[FMAX_PATH+1];\r
        char Str[PRIVATE_KEY_LEN*4+1];\r
+       char Buf[FMAX_PATH+1];\r
        int i;\r
        int n;\r
        HOSTDATA DefaultHost;\r
@@ -415,7 +424,10 @@ void SaveRegistory(void)
 \r
                                WriteMultiStringToReg(hKey4, "DefAttr", DefAttrList);\r
 \r
-                               GetTempPath(FMAX_PATH, Str);\r
+                               // 環境依存の不具合対策\r
+//                             GetTempPath(FMAX_PATH, Str);\r
+                               GetAppTempPath(Str);\r
+                               SetYenTail(Str);\r
                                SaveStr(hKey4, "Tmp", TmpPath, Str);\r
 \r
                                WriteBinaryToReg(hKey4, "Hdlg", &HostDlgSize, sizeof(SIZE));\r
@@ -483,7 +495,12 @@ void SaveRegistory(void)
                                                        // MLSD対応\r
                                                        SaveIntNum(hKey5, "MLSD", Hist.UseMLSD, DefaultHist.UseMLSD);\r
                                                        // IPv6対応\r
-                                                       SaveIntNum(hKey5, "IPv6", Hist.UseIPv6, DefaultHist.UseIPv6);\r
+                                                       SaveIntNum(hKey5, "NetType", Hist.NetType, DefaultHist.NetType);\r
+                                                       // 自動切断対策\r
+                                                       SaveIntNum(hKey5, "Noop", Hist.NoopInterval, DefaultHist.NoopInterval);\r
+                                                       // 再転送対応\r
+                                                       SaveIntNum(hKey5, "ErrMode", Hist.TransferErrorMode, DefaultHist.TransferErrorMode);\r
+                                                       SaveIntNum(hKey5, "ErrNotify", Hist.TransferErrorNotify, DefaultHist.TransferErrorNotify);\r
 \r
                                                        CloseSubKey(hKey5);\r
                                                        n++;\r
@@ -565,7 +582,12 @@ void SaveRegistory(void)
                                                        // MLSD対応\r
                                                        SaveIntNum(hKey5, "MLSD", Host.UseMLSD, DefaultHost.UseMLSD);\r
                                                        // IPv6対応\r
-                                                       SaveIntNum(hKey5, "IPv6", Host.UseIPv6, DefaultHost.UseIPv6);\r
+                                                       SaveIntNum(hKey5, "NetType", Host.NetType, DefaultHost.NetType);\r
+                                                       // 自動切断対策\r
+                                                       SaveIntNum(hKey5, "Noop", Host.NoopInterval, DefaultHost.NoopInterval);\r
+                                                       // 再転送対応\r
+                                                       SaveIntNum(hKey5, "ErrMode", Host.TransferErrorMode, DefaultHost.TransferErrorMode);\r
+                                                       SaveIntNum(hKey5, "ErrNotify", Host.TransferErrorNotify, DefaultHost.TransferErrorNotify);\r
                                                }\r
                                                CloseSubKey(hKey5);\r
                                        }\r
@@ -587,6 +609,12 @@ void SaveRegistory(void)
 \r
                                // 暗号化通信対応\r
                                WriteBinaryToReg(hKey4, "CertCacheHash", &CertificateCacheHash, sizeof(CertificateCacheHash));\r
+                               strcpy(Buf, "");\r
+                               StrCatOut((char*)&SSLRootCAFileHash, sizeof(SSLRootCAFileHash), Buf);\r
+                               EncodePassword(Buf, Str);\r
+                               WriteStringToReg(hKey4, "RootCertHash", Str);\r
+                               // ファイルアイコン表示対応\r
+                               WriteIntValueToReg(hKey4, "ListIcon", DispFileIcon);\r
                        }\r
                        CloseSubKey(hKey4);\r
                }\r
@@ -617,6 +645,7 @@ int LoadRegistory(void)
        // 暗号化通信対応\r
 //     char Str[256];  /* ASCII_EXT_LENより大きい事 */\r
        char Str[PRIVATE_KEY_LEN*4+1];\r
+       char Buf[FMAX_PATH+1];\r
        char *Pos;\r
        char *Pos2;\r
        HOSTDATA Host;\r
@@ -838,7 +867,12 @@ int LoadRegistory(void)
                                        // MLSD対応\r
                                        ReadIntValueFromReg(hKey5, "MLSD", &Hist.UseMLSD);\r
                                        // IPv6対応\r
-                                       ReadIntValueFromReg(hKey5, "IPv6", &Hist.UseIPv6);\r
+                                       ReadIntValueFromReg(hKey5, "NetType", &Hist.NetType);\r
+                                       // 自動切断対策\r
+                                       ReadIntValueFromReg(hKey5, "Noop", &Hist.NoopInterval);\r
+                                       // 再転送対応\r
+                                       ReadIntValueFromReg(hKey5, "ErrMode", &Hist.TransferErrorMode);\r
+                                       ReadIntValueFromReg(hKey5, "ErrNotify", &Hist.TransferErrorNotify);\r
 \r
                                        CloseSubKey(hKey5);\r
                                        AddHistoryToHistory(&Hist);\r
@@ -926,10 +960,21 @@ int LoadRegistory(void)
                                        // 同時接続対応\r
                                        ReadIntValueFromReg(hKey5, "ThreadCount", &Host.MaxThreadCount);\r
                                        ReadIntValueFromReg(hKey5, "ReuseCmdSkt", &Host.ReuseCmdSkt);\r
+                                       // 1.98d以前で同時接続数が1より大きい場合はソケットの再利用なし\r
+                                       if(Version < 1985)\r
+                                       {\r
+                                               if(Host.MaxThreadCount > 1)\r
+                                                       Host.ReuseCmdSkt = NO;\r
+                                       }\r
                                        // MLSD対応\r
                                        ReadIntValueFromReg(hKey5, "MLSD", &Host.UseMLSD);\r
                                        // IPv6対応\r
-                                       ReadIntValueFromReg(hKey5, "IPv6", &Host.UseIPv6);\r
+                                       ReadIntValueFromReg(hKey5, "NetType", &Host.NetType);\r
+                                       // 自動切断対策\r
+                                       ReadIntValueFromReg(hKey5, "Noop", &Host.NoopInterval);\r
+                                       // 再転送対応\r
+                                       ReadIntValueFromReg(hKey5, "ErrMode", &Host.TransferErrorMode);\r
+                                       ReadIntValueFromReg(hKey5, "ErrNotify", &Host.TransferErrorNotify);\r
 \r
                                        CloseSubKey(hKey5);\r
 \r
@@ -942,6 +987,11 @@ int LoadRegistory(void)
 \r
                        // 暗号化通信対応\r
                        ReadBinaryFromReg(hKey4, "CertCacheHash", &CertificateCacheHash, sizeof(CertificateCacheHash));\r
+                       ReadStringFromReg(hKey4, "RootCertHash", Str, PRIVATE_KEY_LEN*4+1);\r
+                       DecodePassword(Str, Buf);\r
+                       StrReadIn(Buf, sizeof(SSLRootCAFileHash), (char*)&SSLRootCAFileHash);\r
+                       // ファイルアイコン表示対応\r
+                       ReadIntValueFromReg(hKey4, "ListIcon", &DispFileIcon);\r
 \r
                        CloseSubKey(hKey4);\r
                }\r
@@ -1794,8 +1844,9 @@ typedef struct regdatatbl {
 \r
 static BOOL WriteOutRegToFile(REGDATATBL *Pos);\r
 static int ReadInReg(char *Name, REGDATATBL **Handle);\r
-static int StrCatOut(char *Src, int Len, char *Dst);\r
-static int StrReadIn(char *Src, int Max, char *Dst);\r
+// 暗号化通信対応\r
+//static int StrCatOut(char *Src, int Len, char *Dst);\r
+//static int StrReadIn(char *Src, int Max, char *Dst);\r
 static char *ScanValue(void *Handle, char *Name);\r
 \r
 \r
@@ -2351,7 +2402,6 @@ static int ReadStringFromReg(void *Handle, char *Name, char *Str, DWORD Size)
                                Sts = FFFTP_SUCCESS;\r
                                if(!CheckStringM(Str))\r
                                        break;\r
-                               Str = Str;\r
                                // UTF-8ではない可能性がある\r
                                // Shift_JISとみなす\r
                        case KANJI_SJIS:\r
@@ -2455,9 +2505,10 @@ static int ReadMultiStringFromReg(void *Handle, char *Name, char *Str, DWORD Siz
                        switch(IniKanjiCode)\r
                        {\r
                        case KANJI_NOCNV:\r
-                               TempSize = min1(Size-1, strlen(Pos));\r
+                               TempSize = min1(Size - 2, strlen(Pos));\r
                                TempSize = StrReadIn(Pos, TempSize, Str);\r
                                *(Str + TempSize) = NUL;\r
+                               *(Str + TempSize + 1) = NUL;\r
                                Sts = FFFTP_SUCCESS;\r
                                if(!CheckMultiStringM(Str))\r
                                        break;\r