Revision: 9436 https://osdn.net/projects/ttssh2/scm/svn/commits/9436 Author: zmatsuo Date: 2021-09-20 00:15:13 +0900 (Mon, 20 Sep 2021) Log Message: ----------- ttermpro コマンドライン Unicode化 Modified Paths: -------------- trunk/TTProxy/TTProxy.h trunk/TTXSamples/TTXAdditionalTitle/TTXAdditionalTitle.c trunk/TTXSamples/TTXCommandLineOpt/TTXCommandLineOpt.c trunk/TTXSamples/TTXRecurringCommand/TTXRecurringCommand.c trunk/TTXSamples/TTXShowCommandLine/TTXShowCommandLine.c trunk/TTXSamples/TTXttyrec/TTXttyplay.c trunk/teraterm/teraterm/ttdde.c trunk/teraterm/teraterm/vtwin.cpp trunk/teraterm/ttpset/ttset.c trunk/ttssh2/ttxssh/ttxssh.c -------------- next part -------------- Modified: trunk/TTProxy/TTProxy.h =================================================================== --- trunk/TTProxy/TTProxy.h 2021-09-19 15:15:00 UTC (rev 9435) +++ trunk/TTProxy/TTProxy.h 2021-09-19 15:15:13 UTC (rev 9436) @@ -99,12 +99,12 @@ write_options(fileName); } - static void PASCAL TTXParseParam(PCHAR param, PTTSet ts, PCHAR DDETopic) { - int param_len=strlen(param); - char option[1024]; + static void PASCAL TTXParseParam(wchar_t *param, PTTSet ts, PCHAR DDETopic) { + size_t param_len = wcslen(param); + wchar_t option[1024]; int opt_len = sizeof(option); int action; - PCHAR start, cur, next; + wchar_t *start, *cur, *next; memset(&option, '\0', opt_len); @@ -118,9 +118,11 @@ if ((option[0] == '-' || option[0] == '/')) { if ((option[1] == 'F' || option[1] == 'f') && option[2] == '=') { - const char *f = get_teraterm_dir_relative_name(option + 3); + char *optA = ToCharW(option + 3); + const char *f = get_teraterm_dir_relative_name(optA); wchar_t *fW = ToWcharA(f); read_options(fW); + free(optA); free(fW); } } @@ -127,11 +129,11 @@ switch (action) { case OPTION_CLEAR: - memset(cur, ' ', next-cur); + wmemset(cur, ' ', next-cur); break; case OPTION_REPLACE: - memset(cur, ' ', next-cur); - memcpy(cur+1, option, strlen(option)); + wmemset(cur, ' ', next-cur); + wmemcpy(cur+1, option, wcslen(option)); break; } @@ -144,22 +146,26 @@ action = OPTION_NONE; if ((option[0] == '-' || option[0] == '/')) { - if (strlen(option + 1) >= 6 && option[6] == '=') { + if (wcslen(option + 1) >= 6 && option[6] == '=') { option[6] = '\0'; - if (_stricmp(option + 1, "proxy") == 0) { - ProxyWSockHook::parseURL(option + 7, TRUE); + if (_wcsicmp(option + 1, L"proxy") == 0) { + char *url = ToCharW(option + 7); + ProxyWSockHook::parseURL(url, TRUE); + free(url); action = OPTION_CLEAR; }else{ option[6] = '='; } } - else if (_stricmp(option+1, "noproxy") == 0) { + else if (_wcsicmp(option+1, L"noproxy") == 0) { // -noproxy \x82\xCD -proxy=none:// \x82̕ʖ\xBC ProxyWSockHook::parseURL("none://", TRUE); action = OPTION_CLEAR; } }else{ - String realhost = ProxyWSockHook::parseURL(option, FALSE); + char *url = ToCharW(option); + String realhost = ProxyWSockHook::parseURL(url, FALSE); + free(url); if (realhost != NULL) { getInstance().realhost = realhost; if (realhost.indexOf("://") == -1) { @@ -175,11 +181,11 @@ switch (action) { case OPTION_CLEAR: - memset(cur, ' ', next-cur); + wmemset(cur, ' ', next-cur); break; case OPTION_REPLACE: - memset(cur, ' ', next-cur); - memcpy(cur+1, option, strlen(option)); + wmemset(cur, ' ', next-cur); + wmemcpy(cur+1, option, wcslen(option)); break; } Modified: trunk/TTXSamples/TTXAdditionalTitle/TTXAdditionalTitle.c =================================================================== --- trunk/TTXSamples/TTXAdditionalTitle/TTXAdditionalTitle.c 2021-09-19 15:15:00 UTC (rev 9435) +++ trunk/TTXSamples/TTXAdditionalTitle/TTXAdditionalTitle.c 2021-09-19 15:15:13 UTC (rev 9436) @@ -287,15 +287,15 @@ } } -static void PASCAL TTXParseParam(PCHAR Param, PTTSet ts, PCHAR DDETopic) { - char buff[1024]; - PCHAR next; +static void PASCAL TTXParseParam(wchar_t *Param, PTTSet ts, PCHAR DDETopic) { + wchar_t buff[1024]; + wchar_t *next; pvar->origParseParam(Param, ts, DDETopic); next = Param; while (next = GetParam(buff, sizeof(buff), next)) { - if (_strnicmp(buff, "/W=", 3) == 0) { + if (_wcsnicmp(buff, L"/W=", 3) == 0) { strncpy_s(pvar->orig_title, sizeof(pvar->orig_title), pvar->ts->Title, _TRUNCATE); SetTitleStr(pvar->orig_title, FALSE); break; Modified: trunk/TTXSamples/TTXCommandLineOpt/TTXCommandLineOpt.c =================================================================== --- trunk/TTXSamples/TTXCommandLineOpt/TTXCommandLineOpt.c 2021-09-19 15:15:00 UTC (rev 9435) +++ trunk/TTXSamples/TTXCommandLineOpt/TTXCommandLineOpt.c 2021-09-19 15:15:13 UTC (rev 9436) @@ -4,6 +4,7 @@ #include "tt_res.h" #include <stdlib.h> #include <stdio.h> +#include <wchar.h> #define ORDER 5800 @@ -23,10 +24,10 @@ pvar->cv = cv; } -BOOL ColorStr2ColorRef(COLORREF *color, PCHAR Str) { +static BOOL ColorStr2ColorRef(COLORREF *color, wchar_t *Str) { int TmpColor[3]; int i, result; - PCHAR cur, next; + wchar_t *cur, *next; cur = Str; @@ -34,10 +35,10 @@ if (!cur) return FALSE; - if ((next = strchr(cur, ',')) != NULL) + if ((next = wcsrchr(cur, L',')) != NULL) *next = 0; - result = sscanf_s(cur, "%d", &TmpColor[i]); + result = swscanf_s(cur, L"%d", &TmpColor[i]); if (next) *next++ = ','; @@ -52,9 +53,9 @@ return TRUE; } -static void PASCAL TTXParseParam(PCHAR Param, PTTSet ts, PCHAR DDETopic) { - char buff[1024]; - PCHAR start, cur, next; +static void PASCAL TTXParseParam(wchar_t *Param, PTTSet ts, PCHAR DDETopic) { + wchar_t buff[1024]; + wchar_t *start, *cur, *next; int x, y; /* the first term shuld be executable filename of Tera Term */ @@ -62,20 +63,20 @@ cur = start; while (next = GetParam(buff, sizeof(buff), cur)) { - if (_strnicmp(buff, "/FG=", 4) == 0) { + if (_wcsnicmp(buff, L"/FG=", 4) == 0) { ColorStr2ColorRef(&(ts->VTColor[0]), &buff[4]); - memset(cur, ' ', next - cur); + wmemset(cur, ' ', next - cur); } - else if (_strnicmp(buff, "/BG=", 4) == 0) { + else if (_wcsnicmp(buff, L"/BG=", 4) == 0) { ColorStr2ColorRef(&(ts->VTColor[1]), &buff[4]); - memset(cur, ' ', next - cur); + wmemset(cur, ' ', next - cur); } - else if (_strnicmp(buff, "/SIZE=", 6) == 0) { - if (sscanf_s(buff+6, "%dx%d", &x, &y) == 2 || sscanf_s(buff+6, "%d,%d", &x, &y) == 2) { - ts->TerminalWidth = x; - ts->TerminalHeight = y; + else if (_wcsnicmp(buff, L"/SIZE=", 6) == 0) { + if (swscanf_s(buff+6, L"%dx%d", &x, &y) == 2 || swscanf_s(buff+6, L"%d,%d", &x, &y) == 2) { + ts->TerminalWidth = x; + ts->TerminalHeight = y; } - memset(cur, ' ', next - cur); + wmemset(cur, ' ', next - cur); } cur = next; } Modified: trunk/TTXSamples/TTXRecurringCommand/TTXRecurringCommand.c =================================================================== --- trunk/TTXSamples/TTXRecurringCommand/TTXRecurringCommand.c 2021-09-19 15:15:00 UTC (rev 9435) +++ trunk/TTXSamples/TTXRecurringCommand/TTXRecurringCommand.c 2021-09-19 15:15:13 UTC (rev 9436) @@ -396,19 +396,16 @@ // /F= \x82ɂ\xE6\x82\xE9\x90ݒ\xE8\x83t\x83@\x83C\x83\x8B\x82̐\xE8\x91ւ\xA6\x82̂ݑΉ\x9E\x81B // -static void PASCAL TTXParseParam(PCHAR Param, PTTSet ts, PCHAR DDETopic) { - char buff[1024]; - PCHAR next; +static void PASCAL TTXParseParam(wchar_t *Param, PTTSet ts, PCHAR DDETopic) { + wchar_t buff[1024]; + wchar_t *next; pvar->origParseParam(Param, ts, DDETopic); next = Param; while (next = GetParam(buff, sizeof(buff), next)) { DequoteParam(buff, sizeof(buff), buff); - if (_strnicmp(buff, "/F=", 3) == 0) { - char *f = buff+3; - wchar_t *fW = ToWcharA(f); - ReadINI(fW, ts); - free(fW); + if (_wcsnicmp(buff, L"/F=", 3) == 0) { + ReadINI(buff+3, ts); } } Modified: trunk/TTXSamples/TTXShowCommandLine/TTXShowCommandLine.c =================================================================== --- trunk/TTXSamples/TTXShowCommandLine/TTXShowCommandLine.c 2021-09-19 15:15:00 UTC (rev 9435) +++ trunk/TTXSamples/TTXShowCommandLine/TTXShowCommandLine.c 2021-09-19 15:15:13 UTC (rev 9436) @@ -16,8 +16,8 @@ static TInstVar *pvar; static TInstVar InstVar; -static void PASCAL TTXParseParam(PCHAR Param, PTTSet ts, PCHAR DDETopic) { - MessageBox(NULL, Param, "TTXShowCommandLine", MB_OK|MB_ICONEXCLAMATION); +static void PASCAL TTXParseParam(wchar_t *Param, PTTSet ts, PCHAR DDETopic) { + MessageBoxW(NULL, Param, L"TTXShowCommandLine", MB_OK|MB_ICONEXCLAMATION); pvar->origParseParam(Param, ts, DDETopic); } Modified: trunk/TTXSamples/TTXttyrec/TTXttyplay.c =================================================================== --- trunk/TTXSamples/TTXttyrec/TTXttyplay.c 2021-09-19 15:15:00 UTC (rev 9435) +++ trunk/TTXSamples/TTXttyrec/TTXttyplay.c 2021-09-19 15:15:13 UTC (rev 9436) @@ -402,17 +402,17 @@ } } -static void PASCAL TTXParseParam(PCHAR Param, PTTSet ts, PCHAR DDETopic) { - char buff[1024]; - PCHAR next; +static void PASCAL TTXParseParam(wchar_t *Param, PTTSet ts, PCHAR DDETopic) { + wchar_t buff[1024]; + wchar_t *next; pvar->origParseParam(Param, ts, DDETopic); next = Param; while (next = GetParam(buff, sizeof(buff), next)) { - if (_strnicmp(buff, "/ttyplay-nowait", 16) == 0 || _strnicmp(buff, "/tpnw", 6) == 0) { + if (_wcsnicmp(buff, L"/ttyplay-nowait", 16) == 0 || _wcsnicmp(buff, L"/tpnw", 6) == 0) { pvar->nowait = TRUE; } - else if (_strnicmp(buff, "/TTYPLAY", 9) == 0 || _strnicmp(buff, "/TP", 4) == 0) { + else if (_wcsnicmp(buff, L"/TTYPLAY", 9) == 0 || _wcsnicmp(buff, L"/TP", 4) == 0) { pvar->enable = TRUE; } } Modified: trunk/teraterm/teraterm/ttdde.c =================================================================== --- trunk/teraterm/teraterm/ttdde.c 2021-09-19 15:15:00 UTC (rev 9435) +++ trunk/teraterm/teraterm/ttdde.c 2021-09-19 15:15:13 UTC (rev 9436) @@ -48,6 +48,7 @@ #include "filesys.h" #include "sendmem.h" +#include "codeconv.h" #define ServiceName "TERATERM" #define ItemName "DATA" @@ -473,8 +474,11 @@ char Temp[MaxStrLen + 2]; strncpy_s(Temp, sizeof(Temp),"a ", _TRUNCATE); // dummy exe name strncat_s(Temp,sizeof(Temp),ParamFileName,_TRUNCATE); - if (LoadTTSET()) - (*ParseParam)(Temp, &ts, NULL); + if (LoadTTSET()) { + wchar_t *commandline = ToWcharA(Temp); + (*ParseParam)(commandline, &ts, NULL); + free(commandline); + } FreeTTSET(); cv.NoMsg = 1; /* suppress error messages */ PostMessage(HVTWin,WM_USER_COMMSTART,0,0); Modified: trunk/teraterm/teraterm/vtwin.cpp =================================================================== --- trunk/teraterm/teraterm/vtwin.cpp 2021-09-19 15:15:00 UTC (rev 9435) +++ trunk/teraterm/teraterm/vtwin.cpp 2021-09-19 15:15:13 UTC (rev 9436) @@ -238,7 +238,6 @@ WNDCLASSW wc; RECT rect; DWORD Style; - char *Param; int CmdShow; int fuLoad = LR_DEFAULTCOLOR; BOOL isFirstInstance; @@ -277,9 +276,9 @@ /* Parse command line parameters*/ // 256\x83o\x83C\x83g\x88ȏ\xE3\x82̃R\x83}\x83\x93\x83h\x83\x89\x83C\x83\x93\x83p\x83\x89\x83\x81\x81[\x83^\x8Ew\x92肪\x82\xA0\x82\xE9\x82ƁABOF(Buffer Over Flow)\x82\xC5 // \x97\x8E\x82\xBF\x82\xE9\x83o\x83O\x82\xF0\x8FC\x90\xB3\x81B(2007.6.12 maya) - Param = GetCommandLine(); if (LoadTTSET()) { - (*ParseParam)(Param, &ts, &(TopicName[0])); + wchar_t *ParamW = GetCommandLineW(); + (*ParseParam)(ParamW, &ts, &(TopicName[0])); } FreeTTSET(); @@ -3516,10 +3515,11 @@ ts.ProtocolFamily = GetHNRec.ProtocolFamily; ts.ComPort = GetHNRec.ComPort; - if ((GetHNRec.PortType==IdTCPIP) && - LoadTTSET()) { - (*ParseParam)(Command, &ts, NULL); + if ((GetHNRec.PortType==IdTCPIP) && LoadTTSET()) { + wchar_t *commandW = ToWcharA(Command); + (*ParseParam)(commandW, &ts, NULL); FreeTTSET(); + free(commandW); } SetKeyMap(); if (ts.MacroFN[0]!=0) { Modified: trunk/teraterm/ttpset/ttset.c =================================================================== --- trunk/teraterm/ttpset/ttset.c 2021-09-19 15:15:00 UTC (rev 9435) +++ trunk/teraterm/ttpset/ttset.c 2021-09-19 15:15:13 UTC (rev 9436) @@ -175,11 +175,12 @@ * TRUE: \x95ϊ\xB7\x90\xAC\x8C\xF7 * FALSE: \x95ϊ\xB7\x8E\xB8\x94s */ -static int SerialPortConfconvertStr2Id(enum serial_port_conf type, PCHAR str, WORD *id) +static int SerialPortConfconvertStr2Id(enum serial_port_conf type, const wchar_t *str, WORD *id) { id_str_pair_t *conf; int ret = FALSE; int i; + char *strA; switch (type) { case COM_DATABIT: @@ -198,25 +199,26 @@ conf = NULL; break; } - if (conf == NULL) - goto error; + if (conf == NULL) { + return FALSE; + } + strA = ToCharW(str); for (i = 0 ; ; i++) { - if (conf[i].id == IDENDMARK) - goto error; - if (_stricmp(conf[i].str, str) == 0) { + if (conf[i].id == IDENDMARK) { + ret = FALSE; + break; + } + if (_stricmp(conf[i].str, strA) == 0) { *id = conf[i].id; + ret = TRUE; break; } } - - ret = TRUE; - -error: - return (ret); + free(strA); + return ret; } - WORD str2id(PCHAR far * List, PCHAR str, WORD DefId) { WORD i; @@ -247,31 +249,32 @@ strncpy_s(str, destlen, List[i], _TRUNCATE); } -int IconName2IconId(const char *name) { +static int IconName2IconId(const wchar_t *name) +{ int id; - if (_stricmp(name, "tterm") == 0) { + if (_wcsicmp(name, L"tterm") == 0) { id = IDI_TTERM; } - else if (_stricmp(name, "vt") == 0) { + else if (_wcsicmp(name, L"vt") == 0) { id = IDI_VT; } - else if (_stricmp(name, "tek") == 0) { + else if (_wcsicmp(name, L"tek") == 0) { id = IDI_TEK; } - else if (_stricmp(name, "tterm_classic") == 0) { + else if (_wcsicmp(name, L"tterm_classic") == 0) { id = IDI_TTERM_CLASSIC; } - else if (_stricmp(name, "vt_classic") == 0) { + else if (_wcsicmp(name, L"vt_classic") == 0) { id = IDI_VT_CLASSIC; } - else if (_stricmp(name, "tterm_3d") == 0) { + else if (_wcsicmp(name, L"tterm_3d") == 0) { id = IDI_TTERM_3D; } - else if (_stricmp(name, "vt_3d") == 0) { + else if (_wcsicmp(name, L"vt_3d") == 0) { id = IDI_VT_3D; } - else if (_stricmp(name, "cygterm") == 0) { + else if (_wcsicmp(name, L"cygterm") == 0) { id = IDI_CYGTERM; } else { @@ -280,6 +283,15 @@ return id; } +static int IconName2IconIdA(const char *name) +{ + wchar_t *nameW = ToWcharA(name); + int id = IconName2IconId(nameW); + free(nameW); + return id; +} + + void IconId2IconName(char *name, int len, int id) { char *icon; switch (id) { @@ -719,6 +731,7 @@ int i; HDC TmpDC; char Temp[MAX_PATH], Temp2[MAX_PATH], *p; + wchar_t TempW[MAX_PATH]; ts->Minimize = 0; ts->HideWindow = 0; @@ -1198,30 +1211,30 @@ ts->Baud = GetPrivateProfileInt(Section, "BaudRate", 9600, FName); /* Parity */ - GetPrivateProfileString(Section, "Parity", "", - Temp, sizeof(Temp), FName); - if (!SerialPortConfconvertStr2Id(COM_PARITY, Temp, &ts->Parity)) { + GetPrivateProfileStringW(SectionW, L"Parity", L"", + TempW, _countof(TempW), FName); + if (!SerialPortConfconvertStr2Id(COM_PARITY, TempW, &ts->Parity)) { ts->Parity = IdParityNone; } /* Data bit */ - GetPrivateProfileString(Section, "DataBit", "", - Temp, sizeof(Temp), FName); - if (!SerialPortConfconvertStr2Id(COM_DATABIT, Temp, &ts->DataBit)) { + GetPrivateProfileStringW(SectionW, L"DataBit", L"", + TempW, _countof(TempW), FName); + if (!SerialPortConfconvertStr2Id(COM_DATABIT, TempW, &ts->DataBit)) { ts->DataBit = IdDataBit8; } /* Stop bit */ - GetPrivateProfileString(Section, "StopBit", "", - Temp, sizeof(Temp), FName); - if (!SerialPortConfconvertStr2Id(COM_STOPBIT, Temp, &ts->StopBit)) { + GetPrivateProfileStringW(SectionW, L"StopBit", L"", + TempW, _countof(TempW), FName); + if (!SerialPortConfconvertStr2Id(COM_STOPBIT, TempW, &ts->StopBit)) { ts->StopBit = IdStopBit1; } /* Flow control */ - GetPrivateProfileString(Section, "FlowCtrl", "", - Temp, sizeof(Temp), FName); - if (!SerialPortConfconvertStr2Id(COM_FLOWCTRL, Temp, &ts->Flow)) { + GetPrivateProfileStringW(SectionW, L"FlowCtrl", L"", + TempW, _countof(TempW), FName); + if (!SerialPortConfconvertStr2Id(COM_FLOWCTRL, TempW, &ts->Flow)) { ts->Flow = IdFlowNone; } @@ -1820,12 +1833,12 @@ // VT Window Icon GetPrivateProfileString(Section, "VTIcon", "Default", Temp, sizeof(Temp), FName); - ts->VTIcon = IconName2IconId(Temp); + ts->VTIcon = IconName2IconIdA(Temp); // Tek Window Icon GetPrivateProfileString(Section, "TEKIcon", "Default", Temp, sizeof(Temp), FName); - ts->TEKIcon = IconName2IconId(Temp); + ts->TEKIcon = IconName2IconIdA(Temp); // Unknown Unicode Character ts->UnknownUnicodeCharaAsWide = @@ -2254,7 +2267,7 @@ if (ts->UnicodeAmbiguousWidth < 1 || 2 < ts->UnicodeAmbiguousWidth) { ts->UnicodeAmbiguousWidth = 1; } - ts->UnicodeEmojiOverride = GetOnOff(Section, "UnicodeEmojiOverride", FName, FALSE); + ts->UnicodeEmojiOverride = (BYTE)GetOnOff(Section, "UnicodeEmojiOverride", FName, FALSE); ts->UnicodeEmojiWidth = GetPrivateProfileInt(Section, "UnicodeEmojiWidth", 1, FName); if (ts->UnicodeEmojiWidth < 1 || 2 < ts->UnicodeEmojiWidth) { ts->UnicodeEmojiWidth = 1; @@ -3725,7 +3738,7 @@ } #endif -static int ParsePortName(char *buff) +static int ParsePortName(const char *buff) { int port = parse_port_from_buf(buff); @@ -3735,6 +3748,14 @@ return 0; } +static int ParsePortNameW(const wchar_t *buff) +{ + char *buffA = ToCharW(buff); + int port = ParsePortName(buffA); + free(buffA); + return port; +} + static void ParseHostName(char *HostStr, WORD * port) { /* @@ -3824,13 +3845,12 @@ } -void PASCAL ParseParam(PCHAR Param, PTTSet ts, PCHAR DDETopic) +void PASCAL ParseParam(wchar_t *Param, PTTSet ts, PCHAR DDETopic) { int i, pos, c; //int param_top; - char Temp[MaxStrLen]; // ttpmacro\x82\xA9\x82\xE7\x8CĂ\xEA\x82邱\x82Ƃ\xF0\x91z\x92肵MaxStrLen\x83T\x83C\x83Y\x82Ƃ\xB7\x82\xE9 - char Temp2[MaxStrLen]; - char TempDir[MAXPATHLEN]; + wchar_t Temp[MaxStrLen]; // ttpmacro\x82\xA9\x82\xE7\x8CĂ\xEA\x82邱\x82Ƃ\xF0\x91z\x92肵MaxStrLen\x83T\x83C\x83Y\x82Ƃ\xB7\x82\xE9 + wchar_t Temp2[MaxStrLen]; WORD ParamPort = 0; WORD ParamCom = 0; WORD ParamTCP = 0; @@ -3839,7 +3859,7 @@ DWORD ParamBaud = BaudNone; BOOL HostNameFlag = FALSE; BOOL JustAfterHost = FALSE; - PCHAR start, cur, next, p; + wchar_t *start, *cur, *next; ts->HostName[0] = 0; //ts->KeyCnfFN[0] = 0; @@ -3855,21 +3875,20 @@ DDETopic[0] = 0; i = 0; /* the first term shuld be executable filename of Tera Term */ - start = GetParam(Temp, sizeof(Temp), Param); + start = GetParam(Temp, _countof(Temp), Param); cur = start; - while (next = GetParam(Temp, sizeof(Temp), cur)) { - DequoteParam(Temp, sizeof(Temp), Temp); - if (_strnicmp(Temp, "/F=", 3) == 0) { /* setup filename */ - strncpy_s(Temp2, sizeof(Temp2), &Temp[3], _TRUNCATE); - if (strlen(Temp2) > 0) { - ConvFName(ts->HomeDir, Temp2, sizeof(Temp2), ".INI", Temp, - sizeof(Temp)); - if (_stricmp(ts->SetupFName, Temp) != 0) { - strncpy_s(ts->SetupFName, sizeof(ts->SetupFName), Temp, - _TRUNCATE); + while (next = GetParam(Temp, _countof(Temp), cur)) { + DequoteParam(Temp, _countof(Temp), Temp); + if (_wcsnicmp(Temp, L"/F=", 3) == 0) { /* setup filename */ + wcsncpy_s(Temp2, _countof(Temp2), &Temp[3], _TRUNCATE); + if (Temp2[0] != 0) { + ConvFNameW(ts->HomeDirW, Temp2, _countof(Temp2), L".INI", Temp, + _countof(Temp)); + if (_wcsicmp(ts->SetupFNameW, Temp) != 0) { free(ts->SetupFNameW); - ts->SetupFNameW = ToWcharA(ts->SetupFName); + ts->SetupFNameW = _wcsdup(Temp); + WideCharToACP_t(ts->SetupFNameW, ts->SetupFName, _countof(ts->SetupFName)); ReadIniFile(ts->SetupFNameW, ts); } } @@ -3878,8 +3897,8 @@ } cur = start; - while (next = GetParam(Temp, sizeof(Temp), cur)) { - DequoteParam(Temp, sizeof(Temp), Temp); + while (next = GetParam(Temp, _countof(Temp), cur)) { + DequoteParam(Temp, _countof(Temp), Temp); if (HostNameFlag) { JustAfterHost = TRUE; @@ -3886,129 +3905,136 @@ HostNameFlag = FALSE; } - if (_strnicmp(Temp, "/AUTOWINCLOSE=", 14) == 0) { /* AutoWinClose=on|off */ - char *s = &Temp[14]; - if (_stricmp(s, "on") == 0) + if (_wcsnicmp(Temp, L"/AUTOWINCLOSE=", 14) == 0) { /* AutoWinClose=on|off */ + wchar_t *s = &Temp[14]; + if (_wcsicmp(s, L"on") == 0) ts->AutoWinClose = 1; else ts->AutoWinClose = 0; } - else if (_strnicmp(Temp, "/SPEED=", 7) == 0) { /* Serial port speed */ + else if (_wcsnicmp(Temp, L"/SPEED=", 7) == 0) { /* Serial port speed */ ParamPort = IdSerial; - ParamBaud = atoi(&Temp[7]); + ParamBaud = _wtoi(&Temp[7]); } - else if (_strnicmp(Temp, "/BAUD=", 6) == 0) { /* for backward compatibility */ + else if (_wcsnicmp(Temp, L"/BAUD=", 6) == 0) { /* for backward compatibility */ ParamPort = IdSerial; - ParamBaud = atoi(&Temp[6]); + ParamBaud = _wtoi(&Temp[6]); } - else if (_stricmp(Temp, "/B") == 0) { /* telnet binary */ + else if (_wcsicmp(Temp, L"/B") == 0) { /* telnet binary */ ParamPort = IdTCPIP; ParamBin = 1; } - else if (_strnicmp(Temp, "/C=", 3) == 0) { /* COM port num */ + else if (_wcsnicmp(Temp, L"/C=", 3) == 0) { /* COM port num */ ParamPort = IdSerial; - ParamCom = atoi(&Temp[3]); + ParamCom = _wtoi(&Temp[3]); if ((ParamCom < 1) || (ParamCom > ts->MaxComPort)) ParamCom = 0; } - else if (_strnicmp(Temp, "/CDATABIT=", 10) == 0) { /* COM data bit */ + else if (_wcsnicmp(Temp, L"/CDATABIT=", 10) == 0) { /* COM data bit */ ParamPort = IdSerial; SerialPortConfconvertStr2Id(COM_DATABIT, &Temp[10], &ts->DataBit); } - else if (_strnicmp(Temp, "/CPARITY=", 9) == 0) { /* COM Parity */ + else if (_wcsnicmp(Temp, L"/CPARITY=", 9) == 0) { /* COM Parity */ ParamPort = IdSerial; SerialPortConfconvertStr2Id(COM_PARITY, &Temp[9], &ts->Parity); } - else if (_strnicmp(Temp, "/CSTOPBIT=", 10) == 0) { /* COM Stop bit */ + else if (_wcsnicmp(Temp, L"/CSTOPBIT=", 10) == 0) { /* COM Stop bit */ ParamPort = IdSerial; SerialPortConfconvertStr2Id(COM_STOPBIT, &Temp[10], &ts->StopBit); } - else if (_strnicmp(Temp, "/CFLOWCTRL=", 11) == 0) { /* COM Flow control */ + else if (_wcsnicmp(Temp, L"/CFLOWCTRL=", 11) == 0) { /* COM Flow control */ ParamPort = IdSerial; SerialPortConfconvertStr2Id(COM_FLOWCTRL, &Temp[11], &ts->Flow); } - else if (_strnicmp(Temp, "/CDELAYPERCHAR=", 15) == 0) { /* COM Transmit delay per character (in msec) */ + else if (_wcsnicmp(Temp, L"/CDELAYPERCHAR=", 15) == 0) { /* COM Transmit delay per character (in msec) */ WORD val = 0; ParamPort = IdSerial; - val = atoi(&Temp[15]); + val = _wtoi(&Temp[15]); ts->DelayPerChar = val; } - else if (_strnicmp(Temp, "/CDELAYPERLINE=", 15) == 0) { /* COM Transmit delay per line (in msec) */ + else if (_wcsnicmp(Temp, L"/CDELAYPERLINE=", 15) == 0) { /* COM Transmit delay per line (in msec) */ WORD val = 0; ParamPort = IdSerial; - val = atoi(&Temp[15]); + val = _wtoi(&Temp[15]); ts->DelayPerLine = val; } - else if (_stricmp(Temp, "/WAITCOM") == 0) { /* wait COM arrival */ + else if (_wcsicmp(Temp, L"/WAITCOM") == 0) { /* wait COM arrival */ ts->WaitCom = 1; } - else if (_strnicmp(Temp, "/D=", 3) == 0) { - if (DDETopic != NULL) - strncpy_s(DDETopic, 21, &Temp[3], _TRUNCATE); // 21 = sizeof(TopicName) + else if (_wcsnicmp(Temp, L"/D=", 3) == 0) { + if (DDETopic != NULL) { + char *DDETopicA = ToCharW(&Temp[3]); + strncpy_s(DDETopic, 21, DDETopicA, _TRUNCATE); // 21 = sizeof(TopicName) + free(DDETopicA); + } } // "New connection" \x83_\x83C\x83A\x83\x8D\x83O\x82\xF0\x95\\x8E\xA6\x82\xB5\x82Ȃ\xA2 (2008.11.14 maya) - else if (_stricmp(Temp, "/DS") == 0) { + else if (_wcsicmp(Temp, L"/DS") == 0) { ts->HostDialogOnStartup = FALSE; } // TCPLocalEcho/TCPCRSend \x82\xF8\x82ɂ\xB7\x82\xE9 (maya 2007.4.25) - else if (_stricmp(Temp, "/E") == 0) { + else if (_wcsicmp(Temp, L"/E") == 0) { ts->DisableTCPEchoCR = TRUE; } // "New connection" \x83_\x83C\x83A\x83\x8D\x83O\x82\xF0\x95\\x8E\xA6\x82\xB7\x82\xE9 (2013.10.08 maya) - else if (_stricmp(Temp, "/ES") == 0) { + else if (_wcsicmp(Temp, L"/ES") == 0) { ts->HostDialogOnStartup = TRUE; } - else if (_strnicmp(Temp, "/FD=", 4) == 0) { /* file transfer directory */ - strncpy_s(Temp2, sizeof(Temp2), &Temp[4], _TRUNCATE); - if (strlen(Temp2) > 0) { - _getcwd(TempDir, sizeof(TempDir)); - if (_chdir(Temp2) == 0) - strncpy_s(ts->FileDir, sizeof(ts->FileDir), Temp2, + else if (_wcsnicmp(Temp, L"/FD=", 4) == 0) { /* file transfer directory */ + wcsncpy_s(Temp2, _countof(Temp2), &Temp[4], _TRUNCATE); + if (wcslen(Temp2) > 0) { + char TempDir[MAXPATHLEN]; + _getcwd(TempDir, _countof(TempDir)); + if (_wchdir(Temp2) == 0) { + char *FileDirA = ToCharW(Temp2); + strncpy_s(ts->FileDir, sizeof(ts->FileDir), FileDirA, _TRUNCATE); + free(FileDirA); + } _chdir(TempDir); } } - else if (_stricmp(Temp, "/H") == 0) /* hide title bar */ + else if (_wcsicmp(Temp, L"/H") == 0) /* hide title bar */ ts->HideTitle = 1; - else if (_stricmp(Temp, "/I") == 0) /* iconize */ + else if (_wcsicmp(Temp, L"/I") == 0) /* iconize */ ts->Minimize = 1; - else if (_strnicmp(Temp, "/K=", 3) == 0) { /* Keyboard setup file */ - strncpy_s(Temp2, sizeof(Temp2), &Temp[3], _TRUNCATE); - ConvFName(ts->HomeDir, Temp2, sizeof(Temp2), ".CNF", - ts->KeyCnfFN, sizeof(ts->KeyCnfFN)); - ts->KeyCnfFNW = ToWcharA(ts->KeyCnfFN); + else if (_wcsnicmp(Temp, L"/K=", 3) == 0) { /* Keyboard setup file */ + wcsncpy_s(Temp2, _countof(Temp2), &Temp[3], _TRUNCATE); + ConvFNameW(ts->HomeDirW, Temp2, _countof(Temp2), L".CNF", Temp, _countof(Temp)); + ts->KeyCnfFNW = _wcsdup(Temp); + WideCharToACP_t(ts->KeyCnfFNW, ts->KeyCnfFN, _countof(ts->KeyCnfFN)); } - else if ((_strnicmp(Temp, "/KR=", 4) == 0) || - (_strnicmp(Temp, "/KT=", 4) == 0)) { /* kanji code */ - if (_stricmp(&Temp[4], "UTF8m") == 0 || - _stricmp(&Temp[4], "UTF-8m") == 0) + else if ((_wcsnicmp(Temp, L"/KR=", 4) == 0) || + (_wcsnicmp(Temp, L"/KT=", 4) == 0)) { /* kanji code */ + if (_wcsicmp(&Temp[4], L"UTF8m") == 0 || + _wcsicmp(&Temp[4], L"UTF-8m") == 0) c = IdUTF8m; - else if (_stricmp(&Temp[4], "UTF8") == 0 || - _stricmp(&Temp[4], "UTF-8") == 0) + else if (_wcsicmp(&Temp[4], L"UTF8") == 0 || + _wcsicmp(&Temp[4], L"UTF-8") == 0) c = IdUTF8; - else if (_stricmp(&Temp[4], "SJIS") == 0 || - _stricmp(&Temp[4], "KS5601") == 0) + else if (_wcsicmp(&Temp[4], L"SJIS") == 0 || + _wcsicmp(&Temp[4], L"KS5601") == 0) c = IdSJIS; - else if (_stricmp(&Temp[4], "EUC") == 0) + else if (_wcsicmp(&Temp[4], L"EUC") == 0) c = IdEUC; - else if (_stricmp(&Temp[4], "JIS") == 0) + else if (_wcsicmp(&Temp[4], L"JIS") == 0) c = IdJIS; else c = -1; if (c != -1) { - if (_strnicmp(Temp, "/KR=", 4) == 0) + if (_wcsnicmp(Temp, L"/KR=", 4) == 0) ts->KanjiCode = c; else ts->KanjiCodeSend = c; } } - else if (_strnicmp(Temp, "/L=", 3) == 0) { /* log file */ - strncpy_s(ts->LogFN, sizeof(ts->LogFN), &Temp[3], _TRUNCATE); - ts->LogFNW = ToWcharA(ts->LogFN); + else if (_wcsnicmp(Temp, L"/L=", 3) == 0) { /* log file */ + ts->LogFNW = _wcsdup(&Temp[3]); + WideCharToACP_t(ts->LogFNW, ts->LogFN, _countof(ts->LogFN)); } - else if (_strnicmp(Temp, "/LA=", 4) == 0) { /* language */ + else if (_wcsnicmp(Temp, L"/LA=", 4) == 0) { /* language */ switch (Temp[4]) { case 'E': case 'e': @@ -4027,112 +4053,115 @@ ts->Language = IdUtf8; break; } } - else if (_strnicmp(Temp, "/MN=", 4) == 0) { /* multicastname */ - strncpy_s(ts->MulticastName, sizeof(ts->MulticastName), &Temp[4], _TRUNCATE); + else if (_wcsnicmp(Temp, L"/MN=", 4) == 0) { /* multicastname */ + WideCharToACP_t(&Temp[4], ts->MulticastName, _countof(ts->MulticastName)); } - else if (_strnicmp(Temp, "/M=", 3) == 0) { /* macro filename */ + else if (_wcsnicmp(Temp, L"/M=", 3) == 0) { /* macro filename */ if ((Temp[3] == 0) || (Temp[3] == '*')) { - strncpy_s(ts->MacroFN, sizeof(ts->MacroFN), "*", - _TRUNCATE); + ts->MacroFNW = _wcsdup(L"*"); } else { - strncpy_s(Temp2, sizeof(Temp2), &Temp[3], _TRUNCATE); - ConvFName(ts->HomeDir, Temp2, sizeof(Temp2), ".TTL", - ts->MacroFN, sizeof(ts->MacroFN)); + wcsncpy_s(Temp2, _countof(Temp2), &Temp[3], _TRUNCATE); + ConvFNameW(ts->HomeDirW, Temp2, _countof(Temp2), L".TTL", Temp, _countof(Temp)); + ts->MacroFNW = _wcsdup(Temp); } + WideCharToACP_t(ts->MacroFNW, ts->MacroFN, _countof(ts->MacroFN)); /* Disable auto connect to serial when macro mode (2006.9.15 maya) */ - ts->MacroFNW = ToWcharA(ts->MacroFN); ts->ComAutoConnect = FALSE; } - else if (_stricmp(Temp, "/M") == 0) { /* macro option without file name */ - strncpy_s(ts->MacroFN, sizeof(ts->MacroFN), "*", _TRUNCATE); - ts->MacroFNW = ToWcharA(ts->MacroFN); + else if (_wcsicmp(Temp, L"/M") == 0) { /* macro option without file name */ + ts->MacroFNW = _wcsdup(L"*"); + WideCharToACP_t(ts->MacroFNW, ts->MacroFN, _countof(ts->MacroFN)); /* Disable auto connect to serial when macro mode (2006.9.15 maya) */ ts->ComAutoConnect = FALSE; } - else if (_stricmp(Temp, "/NOLOG") == 0) { /* disable auto logging */ + else if (_wcsicmp(Temp, L"/NOLOG") == 0) { /* disable auto logging */ ts->LogFN[0] = '\0'; ts->LogAutoStart = 0; } - else if (_strnicmp(Temp, "/OSC52=", 7) == 0) { /* Clipboard access */ + else if (_wcsnicmp(Temp, L"/OSC52=", 7) == 0) { /* Clipboard access */ ts->CtrlFlag &= ~CSF_CBMASK; - if (_stricmp(&Temp[7], "on") == 0 || _stricmp(&Temp[7], "readwrite") == 0) + if (_wcsicmp(&Temp[7], L"on") == 0 || _wcsicmp(&Temp[7], L"readwrite") == 0) ts->CtrlFlag |= CSF_CBRW; - else if (_stricmp(&Temp[7], "read") == 0) + else if (_wcsicmp(&Temp[7], L"read") == 0) ts->CtrlFlag |= CSF_CBREAD; - else if (_stricmp(&Temp[7], "write") == 0) + else if (_wcsicmp(&Temp[7], L"write") == 0) ts->CtrlFlag |= CSF_CBWRITE; - else if (_stricmp(&Temp[7], "off") == 0) + else if (_wcsicmp(&Temp[7], L"off") == 0) ts->CtrlFlag |= CSF_CBNONE; } - else if (_strnicmp(Temp, "/P=", 3) == 0) { /* TCP port num */ + else if (_wcsnicmp(Temp, L"/P=", 3) == 0) { /* TCP port num */ ParamPort = IdTCPIP; - ParamTCP = ParsePortName(&Temp[3]); + ParamTCP = ParsePortNameW(&Temp[3]); } - else if (_stricmp(Temp, "/PIPE") == 0 || - _stricmp(Temp, "/NAMEDPIPE") == 0) { /* \x96\xBC\x91O\x95t\x82\xAB\x83p\x83C\x83v */ + else if (_wcsicmp(Temp, L"/PIPE") == 0 || + _wcsicmp(Temp, L"/NAMEDPIPE") == 0) { /* \x96\xBC\x91O\x95t\x82\xAB\x83p\x83C\x83v */ ParamPort = IdNamedPipe; } - else if (_strnicmp(Temp, "/R=", 3) == 0) { /* Replay filename */ - strncpy_s(Temp2, sizeof(Temp2), &Temp[3], _TRUNCATE); - ConvFName(ts->HomeDir, Temp2, sizeof(Temp2), "", ts->HostName, - sizeof(ts->HostName)); + else if (_wcsnicmp(Temp, L"/R=", 3) == 0) { /* Replay filename */ + wcsncpy_s(Temp2, _countof(Temp2), &Temp[3], _TRUNCATE); + ConvFNameW(ts->HomeDirW, Temp2, _countof(Temp2), L"", Temp, _countof(Temp)); + WideCharToACP_t(Temp, ts->HostName, _countof(ts->HostName)); if (strlen(ts->HostName) > 0) ParamPort = IdFile; } - else if (_stricmp(Temp, "/T=0") == 0) { /* telnet disable */ + else if (_wcsicmp(Temp, L"/T=0") == 0) { /* telnet disable */ ParamPort = IdTCPIP; ParamTel = 0; } - else if (_stricmp(Temp, "/T=1") == 0) { /* telnet enable */ + else if (_wcsicmp(Temp, L"/T=1") == 0) { /* telnet enable */ ParamPort = IdTCPIP; ParamTel = 1; } - else if (_strnicmp(Temp, "/TEKICON=", 9) == 0) { /* Tek window icon */ + else if (_wcsnicmp(Temp, L"/TEKICON=", 9) == 0) { /* Tek window icon */ ts->TEKIcon = IconName2IconId(&Temp[9]); } - else if (_strnicmp(Temp, "/VTICON=", 8) == 0) { /* VT window icon */ + else if (_wcsnicmp(Temp, L"/VTICON=", 8) == 0) { /* VT window icon */ ts->VTIcon = IconName2IconId(&Temp[8]); } - else if (_stricmp(Temp, "/V") == 0) { /* invisible */ + else if (_wcsicmp(Temp, L"/V") == 0) { /* invisible */ ts->HideWindow = 1; } - else if (_strnicmp(Temp, "/W=", 3) == 0) { /* Window title */ - strncpy_s(ts->Title, sizeof(ts->Title), &Temp[3], _TRUNCATE); + else if (_wcsnicmp(Temp, L"/W=", 3) == 0) { /* Window title */ + char* TitleA = ToCharW(&Temp[3]); + strncpy_s(ts->Title, sizeof(ts->Title), TitleA, _TRUNCATE); + free(TitleA); } - else if (_strnicmp(Temp, "/X=", 3) == 0) { /* Window pos (X) */ - if (sscanf(&Temp[3], "%d", &pos) == 1) { + else if (_wcsnicmp(Temp, L"/X=", 3) == 0) { /* Window pos (X) */ + if (swscanf(&Temp[3], L"%d", &pos) == 1) { ts->VTPos.x = pos; if (ts->VTPos.y == CW_USEDEFAULT) ts->VTPos.y = 0; } } - else if (_strnicmp(Temp, "/Y=", 3) == 0) { /* Window pos (Y) */ - if (sscanf(&Temp[3], "%d", &pos) == 1) { + else if (_wcsnicmp(Temp, L"/Y=", 3) == 0) { /* Window pos (Y) */ + if (swscanf(&Temp[3], L"%d", &pos) == 1) { ts->VTPos.y = pos; if (ts->VTPos.x == CW_USEDEFAULT) ts->VTPos.x = 0; } } - else if (_stricmp(Temp, "/4") == 0) /* Protocol Tera Term speaking */ + else if (_wcsicmp(Temp, L"/4") == 0) /* Protocol Tera Term speaking */ ts->ProtocolFamily = AF_INET; - else if (_stricmp(Temp, "/6") == 0) + else if (_wcsicmp(Temp, L"/6") == 0) ts->ProtocolFamily = AF_INET6; - else if (_stricmp(Temp, "/DUPLICATE") == 0) { // duplicate session (2004.12.7. yutaka) + else if (_wcsicmp(Temp, L"/DUPLICATE") == 0) { // duplicate session (2004.12.7. yutaka) ts->DuplicateSession = 1; } - else if (_strnicmp(Temp, "/TIMEOUT=", 9) == 0) { // Connecting Timeout value (2007.1.11. yutaka) - if (sscanf(&Temp[9], "%d", &pos) == 1) { + else if (_wcsnicmp(Temp, L"/TIMEOUT=", 9) == 0) { // Connecting Timeout value (2007.1.11. yutaka) + if (swscanf(&Temp[9], L"%d", &pos) == 1) { if (pos >= 0) ts->ConnectingTimeout = pos; } } - else if ((Temp[0] != '/') && (strlen(Temp) > 0)) { - if (JustAfterHost && ((c=ParsePortName(Temp)) > 0)) + else if ((Temp[0] != '/') && (wcslen(Temp) > 0)) { + if (JustAfterHost && ((c=ParsePortNameW(Temp)) > 0)) ParamTCP = c; else { - strncpy_s(ts->HostName, sizeof(ts->HostName), Temp, _TRUNCATE); /* host name */ + char *HostNameA = ToCharW(Temp); + strncpy_s(ts->HostName, sizeof(ts->HostName), HostNameA, _TRUNCATE); /* host name */ + free(HostNameA); if (ParamPort == IdNamedPipe) { // \x89\xBD\x82\xE0\x82\xB5\x82Ȃ\xA2\x81B @@ -4187,14 +4216,15 @@ break; case IdNamedPipe: if (ts->HostName[0] != 0 && ts->HostName[0] != '\\') { - if (p = strchr(ts->HostName, '\\')) { + char * p = strchr(ts->HostName, '\\'); + if (p == NULL) { *p++ = '\0'; - _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "\\\\%s\\pipe\\%s", ts->HostName, p); + _snwprintf_s(Temp, _countof(Temp), _TRUNCATE, L"\\\\%hs\\pipe\\%hs", ts->HostName, p); } else { - _snprintf_s(Temp, sizeof(Temp), _TRUNCATE, "\\\\.\\pipe\\%s", ts->HostName); + _snwprintf_s(Temp, _countof(Temp), _TRUNCATE, L"\\\\.\\pipe\\%hs", ts->HostName); } - strncpy_s(ts->HostName, sizeof(ts->HostName), Temp, _TRUNCATE); + WideCharToACP_t(Temp, ts->HostName, _countof(ts->HostName)); } ts->PortType = IdNamedPipe; ts->ComPort = 0; Modified: trunk/ttssh2/ttxssh/ttxssh.c =================================================================== --- trunk/ttssh2/ttxssh/ttxssh.c 2021-09-19 15:15:00 UTC (rev 9435) +++ trunk/ttssh2/ttxssh/ttxssh.c 2021-09-19 15:15:13 UTC (rev 9436) @@ -57,6 +57,7 @@ #include <commctrl.h> #include <commdlg.h> #include <winsock2.h> +#include <wchar.h> #include <lmcons.h> @@ -88,6 +89,7 @@ #include "codeconv.h" #include "inifile_com.h" #include "asprintf.h" +#include "win32helper.h" #include "libputty.h" @@ -107,9 +109,6 @@ #define GetPrivateProfileStringA(p1, p2, p3, p4, p5, p6) GetPrivateProfileStringAFileW(p1, p2, p3, p4, p5, p6) #define WritePrivateProfileStringA(p1, p2, p3, p4) WritePrivateProfileStringAFileW(p1, p2, p3, p4) -#define MATCH_STR(s, o) strncmp((s), (o), NUM_ELEM(o) - 1) -#define MATCH_STR_I(s, o) _strnicmp((s), (o), NUM_ELEM(o) - 1) - /* This extension implements SSH, so we choose a load order in the "protocols" range. */ #define ORDER 2500 @@ -1384,7 +1383,7 @@ // Percent-encode\x82\xB3\x82ꂽ\x95\xB6\x8E\x9A\x97\xF1src\x82\xF0\x83f\x83R\x81[\x83h\x82\xB5\x82\xC4dst\x82ɃR\x83s\x81[\x82\xB7\x82\xE9\x81B // dstlen\x82\xCDdst\x82̃T\x83C\x83Y\x81B\x82\xB1\x82\xEA\x82\xE6\x82茋\x89ʂ\xAA\x92\xB7\x82\xA2\x8Fꍇ\x81A\x82\xBB\x82̕\xAA\x82͐\xE8\x8ÊĂ\xE7\x82\xEA\x82\xE9\x81B -static void percent_decode(char *dst, int dstlen, char *src) { +static void percent_decode(char *dst, int dstlen, const wchar_t *src) { if (src == NULL || dst == NULL || dstlen < 1) { return; } @@ -1396,7 +1395,7 @@ src++; dst++; } else { - *dst++ = *src++; + *dst++ = (char)*src++; } dstlen--; } @@ -1404,8 +1403,9 @@ return; } -void add_forward_param(PTInstVar pvar, char *param) +static void add_forward_param(PTInstVar pvar, const wchar_t *paramW) { + char *param = ToCharW(paramW); if (pvar->settings.DefaultForwarding[0] == 0) { strncpy_s(pvar->settings.DefaultForwarding, sizeof(pvar->settings.DefaultForwarding), @@ -1418,15 +1418,17 @@ sizeof(pvar->settings.DefaultForwarding), param, _TRUNCATE); } + free(param); } -static void PASCAL TTXParseParam(PCHAR param, PTTSet ts, PCHAR DDETopic) { - int param_len=strlen(param); +static void PASCAL TTXParseParam(wchar_t *param, PTTSet ts, PCHAR DDETopic) +{ + int param_len = wcslen(param); int opt_len = param_len+1; - char *option = (char *)calloc(opt_len, sizeof(char)); - char *option2 = (char *)calloc(opt_len, sizeof(char)); + wchar_t *option = (wchar_t *)calloc(opt_len, sizeof(wchar_t)); + wchar_t *option2 = (wchar_t *)calloc(opt_len, sizeof(wchar_t)); int action; - PCHAR start, cur, next; + wchar_t *start, *cur, *next; size_t i; if (pvar->hostdlg_activated) { @@ -1442,29 +1444,22 @@ action = OPTION_NONE; if ((option[0] == '-' || option[0] == '/')) { - wchar_t* option2W; - if (MATCH_STR(option + 1, "ssh") == 0) { - if (MATCH_STR(option + 4, "-f=") == 0) { - strncpy_s(option2, opt_len, option + 7, _TRUNCATE); - option2W = ToWcharA(option2); - read_ssh_options_from_user_file(pvar, option2W); - free(option2W); + if (wcsncmp(option + 1, L"ssh", 3) == 0) { + if (wcsncmp(option + 4, L"-f=", 3) == 0) { + const wchar_t *file = option + 7; + read_ssh_options_from_user_file(pvar, file); action = OPTION_CLEAR; - } else if (MATCH_STR(option + 4, "-consume=") == 0) { - strncpy_s(option2, opt_len, option + 13, _TRUNCATE); - option2W = ToWcharA(option2); - read_ssh_options_from_user_file(pvar, option2W); - free(option2W); - DeleteFile(option2); + } else if (wcsncmp(option + 4, L"-consume=", 9) == 0) { + const wchar_t* file = option + 13; + read_ssh_options_from_user_file(pvar, file); + DeleteFileW(file); action = OPTION_CLEAR; } // ttermpro.exe \x82\xCC /F= \x8Ew\x92\xE8\x82ł\xE0 TTSSH \x82̐ݒ\xE8\x82\xF0\x93ǂ\xDE (2006.10.11 maya) - } else if (MATCH_STR_I(option + 1, "f=") == 0) { - strncpy_s(option2, opt_len, option + 3, _TRUNCATE); - option2W = ToWcharA(option2); - read_ssh_options_from_user_file(pvar, option2W); - free(option2W); + } else if (_wcsnicmp(option + 1, L"f=", 2) == 0) { + const wchar_t *file = option + 3; + read_ssh_options_from_user_file(pvar, file); // Tera Term\x91\xA4\x82ł\xE0\x89\xF0\x8E߂\xB7\x82\xE9\x95K\x97v\x82\xAA\x82\xA0\x82\xE9\x82̂ŏ\xC1\x82\xB3\x82Ȃ\xA2 } } @@ -1471,11 +1466,11 @@ switch (action) { case OPTION_CLEAR: - memset(cur, ' ', next-cur); + wmemset(cur, ' ', next-cur); break; case OPTION_REPLACE: - memset(cur, ' ', next-cur); - memcpy(cur+1, option, strlen(option)); + wmemset(cur, ' ', next-cur); + wmemcpy(cur+1, option, wcslen(option)); break; } @@ -1489,13 +1484,13 @@ if ((option[0] == '-' || option[0] == '/')) { action = OPTION_CLEAR; - if (MATCH_STR(option + 1, "ssh") == 0) { + if (wcsncmp(option + 1, L"ssh", 3) == 0) { if (option[4] == 0) { pvar->settings.Enabled = 1; - } else if (MATCH_STR(option + 4, "-L") == 0 || - MATCH_STR(option + 4, "-R") == 0 || - MATCH_STR(option + 4, "-D") == 0) { - char *p = option + 5; + } else if (wcsncmp(option + 4, L"-L", 3) == 0 || + wcsncmp(option + 4, L"-R", 3) == 0 || + wcsncmp(option + 4, L"-D", 3) == 0) { + wchar_t *p = option + 5; option2[0] = *p; i = 1; while (*++p) { @@ -1512,36 +1507,38 @@ option2[i] = 0; add_forward_param(pvar, option2); } - } else if (MATCH_STR(option + 4, "-X") == 0) { - add_forward_param(pvar, "X"); + } else if (wcsncmp(option + 4, L"-X", 2) == 0) { + add_forward_param(pvar, L"X"); if (option+6 != 0) { + char *option6 = ToCharW(option + 6); strncpy_s(pvar->settings.X11Display, sizeof(pvar->settings.X11Display), - option + 6, _TRUNCATE); + option6, _TRUNCATE); + free(option6); } - } else if (strcmp(option + 4, "-v") == 0) { + } else if (wcscmp(option + 4, L"-v") == 0) { pvar->settings.LogLevel = LOG_LEVEL_VERBOSE; - } else if (_stricmp(option + 4, "-autologin") == 0 || - _stricmp(option + 4, "-autologon") == 0) { + } else if (_wcsicmp(option + 4, L"-autologin") == 0 || + _wcsicmp(option + 4, L"-autologon") == 0) { pvar->settings.TryDefaultAuth = TRUE; - } else if (MATCH_STR_I(option + 4, "-agentconfirm=") == 0) { - if ((_stricmp(option+18, "off") == 0) || - (_stricmp(option+18, "no") == 0) || - (_stricmp(option+18, "false") == 0) || - (_stricmp(option+18, "0") == 0) || - (_stricmp(option+18, "n") == 0)) { + } else if (_wcsnicmp(option + 4, L"-agentconfirm=", 14) == 0) { + if ((_wcsicmp(option+18, L"off") == 0) || + (_wcsicmp(option+18, L"no") == 0) || + (_wcsicmp(option+18, L"false") == 0) || + (_wcsicmp(option+18, L"0") == 0) || + (_wcsicmp(option+18, L"n") == 0)) { pvar->settings.ForwardAgentConfirm = 0; } else { pvar->settings.ForwardAgentConfirm = 1; } - } else if (strcmp(option + 4, "-a") == 0) { + } else if (wcscmp(option + 4, L"-a") == 0) { pvar->settings.ForwardAgent = FALSE; - } else if (strcmp(option + 4, "-A") == 0) { + } else if (wcscmp(option + 4, L"-A") == 0) { pvar->settings.ForwardAgent = TRUE; - } else if (MATCH_STR(option + 4, "-C=") == 0) { - pvar->settings.CompressionLevel = atoi(option+7); + } else if (wcsncmp(option + 4, L"-C=", 3) == 0) { + pvar->settings.CompressionLevel = _wtoi(option+7); if (pvar->settings.CompressionLevel < 0) { pvar->settings.CompressionLevel = 0; } @@ -1548,36 +1545,38 @@ else if (pvar->settings.CompressionLevel > 9) { pvar->settings.CompressionLevel = 9; } - } else if (strcmp(option + 4, "-C") == 0) { + } else if (wcscmp(option + 4, L"-C") == 0) { pvar->settings.CompressionLevel = 6; - } else if (strcmp(option + 4, "-c") == 0) { + } else if (wcscmp(option + 4, L"-c") == 0) { pvar->settings.CompressionLevel = 0; - } else if (MATCH_STR_I(option + 4, "-icon=") == 0) { - if ((_stricmp(option+10, "old") == 0) || - (_stricmp(option+10, "yellow") == 0) || - (_stricmp(option+10, "securett_yellow") == 0)) { + } else if (_wcsnicmp(option + 4, L"-icon=", 6) == 0) { + if ((_wcsicmp(option+10, L"old") == 0) || + (_wcsicmp(option+10, L"yellow") == 0) || + (_wcsicmp(option+10, L"securett_yellow") == 0)) { pvar->settings.IconID = IDI_SECURETT_YELLOW; } - else if ((_stricmp(option+10, "green") == 0) || - (_stricmp(option+10, "securett_green") == 0)) { + else if ((_wcsicmp(option+10, L"green") == 0) || + (_wcsicmp(option+10, L"securett_green") == 0)) { pvar->settings.IconID = IDI_SECURETT_GREEN; } else { pvar->settings.IconID = IDI_SECURETT; } - } else if (MATCH_STR(option + 4, "-subsystem=") == 0) { + } else if (wcsncmp(option + 4, L"-subsystem=", 11) == 0) { + char *option15 = ToCharW(option + 15); pvar->use_subsystem = TRUE; strncpy_s(pvar->subsystem_name, sizeof(pvar->subsystem_name), - option + 15, _TRUNCATE); - } else if (strcmp(option + 4, "-N") == 0) { + option15, _TRUNCATE); + free(option15); + } else if (wcscmp(option + 4, L"-N") == 0) { pvar->nosession = TRUE; // /ssh1 \x82\xC6 /ssh2 \x83I\x83v\x83V\x83\x87\x83\x93\x82̐V\x8BK\x92lj\xC1 (2006.9.16 maya) - } else if (strcmp(option + 4, "1") == 0) { + } else if (wcscmp(option + 4, L"1") == 0) { pvar->settings.Enabled = 1; pvar->settings.ssh_protocol_version = 1; - } else if (strcmp(option + 4, "2") == 0) { + } else if (wcscmp(option + 4, L"2") == 0) { pvar->settings.Enabled = 1; pvar->settings.ssh_protocol_version = 2; @@ -1592,8 +1591,8 @@ } // ttermpro.exe \x82\xCC /T= \x8Ew\x92\xE8\x82̗\xAC\x97p\x82Ȃ̂ŁA\x91啶\x8E\x9A\x82\xE0\x8B\x96\x82\xB7 (2006.10.19 maya) - } else if (MATCH_STR_I(option + 1, "t=") == 0) { - if (strcmp(option + 3, "2") == 0) { + } else if (_wcsnicmp(option + 1, L"t=", 2) == 0) { + if (wcscmp(option + 3, L"2") == 0) { pvar->settings.Enabled = 1; // /t=2\x82\xCDttssh\x91\xA4\x82ł̊g\x92\xA3\x82Ȃ̂ŏ\xC1\x82\xB7 } else { @@ -1602,21 +1601,21 @@ } // /1 \x82\xA8\x82\xE6\x82\xD1 /2 \x83I\x83v\x83V\x83\x87\x83\x93\x82̐V\x8BK\x92lj\xC1 (2004.10.3 yutaka) - } else if (strcmp(option + 1, "1") == 0) { + } else if (wcscmp(option + 1, L"1") == 0) { // command line: /ssh /1 is SSH1 only pvar->settings.ssh_protocol_version = 1; - } else if (strcmp(option + 1, "2") == 0) { + } else if (wcscmp(option + 1, L"2") == 0) { // command line: /ssh /2 is SSH2 & SSH1 pvar->settings.ssh_protocol_version = 2; - } else if (strcmp(option + 1, "nossh") == 0) { + } else if (wcscmp(option + 1, L"nossh") == 0) { // '/nossh' \x83I\x83v\x83V\x83\x87\x83\x93\x82̒lj\xC1\x81B // TERATERM.INI \x82\xC5SSH\x82\xAA\x97L\x8C\xF8\x82ɂȂ\xC1\x82Ă\xA2\x82\xE9\x8Fꍇ\x81A\x82\xA4\x82܂\xADCygterm\x82\xAA\x8BN\x93\xAE\x82\xB5\x82Ȃ\xA2\x82\xB1\x82Ƃ\xAA // \x82\xA0\x82邱\x82Ƃւ̑Ώ\x88\x81B(2004.10.11 yutaka) pvar->settings.Enabled = 0; - } else if (strcmp(option + 1, "telnet") == 0) { + } else if (wcscmp(option + 1, L"telnet") == 0) { // '/telnet' \x82\xAA\x8Ew\x92肳\x82\xEA\x82Ă\xA2\x82\xE9\x82Ƃ\xAB\x82ɂ\xCD '/nossh' \x82Ɠ\xAF\x82\xB6\x82\xAD // SSH\x82\xF8\x82ɂ\xB7\x82\xE9 (2006.9.16 maya) pvar->settings.Enabled = 0; @@ -1623,7 +1622,7 @@ // Tera Term \x82\xCC Telnet \x83t\x83\x89\x83O\x82\xE0\x95t\x82\xAF\x82\xE9 pvar->ts->Telnet = 1; - } else if (MATCH_STR(option + 1, "auth=") == 0) { + } else if (wcsncmp(option + 1, L"auth=", 5) == 0) { // SSH2\x8E\xA9\x93\xAE\x83\x8D\x83O\x83C\x83\x93\x83I\x83v\x83V\x83\x87\x83\x93\x82̒lj\xC1 // // SYNOPSIS: /ssh /auth=passowrd /user=\x83\x86\x81[\x83U\x96\xBC /passwd=\x83p\x83X\x83\x8F\x81[\x83h @@ -1635,23 +1634,23 @@ // pvar->ssh2_autologin = 1; // for SSH2 (2004.11.30 yutaka) - if (_stricmp(option + 6, "password") == 0) { // \x83p\x83X\x83\x8F\x81[\x83h + if (_wcsicmp(option + 6, L"password") == 0) { // \x83p\x83X\x83\x8F\x81[\x83h //pvar->auth_state.cur_cred.method = SSH_AUTH_PASSWORD; pvar->ssh2_authmethod = SSH_AUTH_PASSWORD; - } else if (_stricmp(option + 6, "keyboard-interactive") == 0) { // keyboard-interactive\x94F\x8F\xD8 + } else if (_wcsicmp(option + 6, L"keyboard-interactive") == 0) { // keyboard-interactive\x94F\x8F\xD8 //pvar->auth_state.cur_cred.method = SSH_AUTH_TIS; pvar->ssh2_authmethod = SSH_AUTH_TIS; - } else if (_stricmp(option + 6, "challenge") == 0) { // keyboard-interactive\x94F\x8F\xD8 + } else if (_wcsicmp(option + 6, L"challenge") == 0) { // keyboard-interactive\x94F\x8F\xD8 //pvar->auth_state.cur_cred.method = SSH_AUTH_TIS; pvar->ssh2_authmethod = SSH_AUTH_TIS; - } else if (_stricmp(option + 6, "publickey") == 0) { // \x8C\xF6\x8AJ\x8C\xAE\x94F\x8F\xD8 + } else if (_wcsicmp(option + 6, L"publickey") == 0) { // \x8C\xF6\x8AJ\x8C\xAE\x94F\x8F\xD8 //pvar->auth_state.cur_cred.method = SSH_AUTH_RSA; pvar->ssh2_authmethod = SSH_AUTH_RSA; - } else if (_stricmp(option + 6, "pageant") == 0) { // \x8C\xF6\x8AJ\x8C\xAE\x94F\x8F\xD8 by Pageant + } else if (_wcsicmp(option + 6, L"pageant") == 0) { // \x8C\xF6\x8AJ\x8C\xAE\x94F\x8F\xD8 by Pageant //pvar->auth_state.cur_cred.method = SSH_AUTH_RSA; pvar->ssh2_authmethod = SSH_AUTH_PAGEANT; @@ -1659,20 +1658,20 @@ // TODO: } - } else if (MATCH_STR(option + 1, "user=") == 0) { - _snprintf_s(pvar->ssh2_username, sizeof(pvar->ssh2_username), _TRUNCATE, "%s", option+6); + } else if (wcsncmp(option + 1, L"user=", 5) == 0) { + _snprintf_s(pvar->ssh2_username, sizeof(pvar->ssh2_username), _TRUNCATE, "%ls", option+6); - } else if (MATCH_STR(option + 1, "passwd=") == 0) { - _snprintf_s(pvar->ssh2_password, sizeof(pvar->ssh2_password), _TRUNCATE, "%s", option+8); + } else if (wcsncmp(option + 1, L"passwd=", 7) == 0) { + _snprintf_s(pvar->ssh2_password, sizeof(pvar->ssh2_password), _TRUNCATE, "%ls", option+8); - } else if (MATCH_STR(option + 1, "keyfile=") == 0) { - _snprintf_s(pvar->ssh2_keyfile, sizeof(pvar->ssh2_keyfile), _TRUNCATE, "%s", option+9); + } else if (wcsncmp(option + 1, L"keyfile=", 8) == 0) { + _snprintf_s(pvar->ssh2_keyfile, sizeof(pvar->ssh2_keyfile), _TRUNCATE, "%ls", option+9); - } else if (strcmp(option + 1, "ask4passwd") == 0) { + } else if (wcscmp(option + 1, L"ask4passwd") == 0) { // \x83p\x83X\x83\x8F\x81[\x83h\x82\xAD (2006.9.18 maya) pvar->ask4passwd = 1; - } else if (strcmp(option + 1, "nosecuritywarning") == 0) { + } else if (wcscmp(option + 1, L"nosecuritywarning") == 0) { // known_hosts\x83`\x83F\x83b\x83N\x82\xF0\x82\xB5\x82Ȃ\xA2\x81B\x93\x96\x8AY\x83I\x83v\x83V\x83\x87\x83\x93\x82\xF0\x8Eg\x82\xA4\x82ƁA\x83Z\x83L\x83\x85\x83\x8A\x83e\x83B\x90\xAB\x82\xAA\x92ቺ\x82\xB7\x82\xE9 // \x82\xBD\x82߁A\x89B\x82\xB5\x83I\x83v\x83V\x83\x87\x83\x93\x88\xB5\x82\xA2\x82Ƃ\xB7\x82\xE9\x81B // (2009.10.4 yutaka) @@ -1690,12 +1689,12 @@ } } - else if ((MATCH_STR_I(option, "ssh://") == 0) || - (MATCH_STR_I(option, "ssh1://") == 0) || - (MATCH_STR_I(option, "ssh2://") == 0) || - (MATCH_STR_I(option, "slogin://") == 0) || - (MATCH_STR_I(option, "slogin1://") == 0) || - (MATCH_STR_I(option, "slogin2://") == 0)) { + else if ((_wcsnicmp(option, L"ssh://", 6) == 0) || + (_wcsnicmp(option, L"ssh1://", 7) == 0) || + (_wcsnicmp(option, L"ssh2://", 7) == 0) || + (_wcsnicmp(option, L"slogin://", 9) == 0) || + (_wcsnicmp(option, L"slogin1://", 10) == 0) || + (_wcsnicmp(option, L"slogin2://", 10) == 0)) { // // ssh://user@host/ \x93\x99\x82\xCCURL\x8C`\x8E\xAE\x82̃T\x83|\x81[\x83g // \x8A\xEE\x96{\x93I\x82ȏ\x91\x8E\xAE\x82\xCD telnet:// URL\x82ɏ\x87\x82\xB8\x82\xE9 @@ -1704,13 +1703,13 @@ // RFC3986: Uniform Resource Identifier (URI): Generic Syntax // RFC4248: The telnet URI Scheme // - char *p, *p2, *p3; + wchar_t *p, *p2, *p3; int optlen, hostlen; - optlen = strlen(option); + optlen = wcslen(option); // \x8Dŏ\x89\x82\xCC':'\x82̑O\x82̕\xB6\x8E\x9A\x82\xAA\x90\x94\x8E\x9A\x82\xBE\x82\xC1\x82\xBD\x8Fꍇ\x81A\x82\xBB\x82\xEA\x82\xF0ssh\x83v\x83\x8D\x83g\x83R\x83\x8B\x83o\x81[\x83W\x83\x87\x83\x93\x82Ƃ݂Ȃ\xB7 - p = _mbschr(option, ':'); + p = wcschr(option, ':'); switch (*(p-1)) { case '1': pvar->settings.ssh_protocol_version = 1; @@ -1724,15 +1723,15 @@ p += 3; // path part \x82\xF0\x90\xE8\x8ÊĂ\xE9 - if ((p2 = _mbschr(p, '/')) != NULL) { + if ((p2 = wcschr(p, '/')) != NULL) { *p2 = 0; } // '@'\x82\xAA\x82\xA0\x82\xC1\x82\xBD\x8Fꍇ\x81A\x82\xBB\x82\xEA\x82\xE6\x82\xE8\x91O\x82̓\x86\x81[\x83U\x8F\xEE\x95\xF1 - if ((p2 = _mbschr(p, '@')) != NULL) { + if ((p2 = wcschr(p, '@')) != NULL) { *p2 = 0; // ':'\x88ȍ~\x82̓p\x83X\x83\x8F\x81[\x83h - if ((p3 = _mbschr(p, ':')) != NULL) { + if ((p3 = wcschr(p, ':')) != NULL) { *p3 = 0; percent_decode(pvar->ssh2_password, sizeof(pvar->ssh2_password), p3 + 1); } @@ -1743,25 +1742,25 @@ // host part \x82\xF0 option \x82̐擪\x82Ɉړ\xAE\x82\xB5\x82āAscheme part \x82\xF0\x92ׂ\xB7 // port\x8Ew\x92肪\x96\xB3\x82\xA9\x82\xC1\x82\xBD\x8E\x9E\x82\xC9port\x94ԍ\x86\x82𑫂\xB7\x82\xBD\x82߂̗̈\xE6\x8Am\x95ۂ̈Ӗ\xA1\x82\xE0\x82\xA0\x82\xE9 - hostlen = strlen(p); - memmove_s(option, optlen, p, hostlen); + hostlen = wcslen(p); + wmemmove_s(option, optlen, p, hostlen); option[hostlen] = 0; // \x83|\x81[\x83g\x8Ew\x92肪\x96\xB3\x82\xA2\x8E\x9E\x82\xCD":22"\x82𑫂\xB7 if (option[0] == '[' && option[hostlen-1] == ']' || // IPv6 raw address without port - option[0] != '[' && _mbschr(option, ':') == NULL) { // hostname or IPv4 raw address without port - memcpy_s(option+hostlen, optlen-hostlen, ":22", 3); + option[0] != '[' && wcschr(option, ':') == NULL) { // hostname or IPv4 raw address without port + wmemcpy_s(option+hostlen, optlen-hostlen, L":22", 3); hostlen += 3; } // \x83|\x81[\x83g\x8Ew\x92\xE8\x82\xE6\x82\xE8\x8C\xE3\x82\xF0\x82\xB7\x82ׂăX\x83y\x81[\x83X\x82Œׂ\xB7 - memset(option+hostlen, ' ', optlen-hostlen); + wmemset(option+hostlen, ' ', optlen-hostlen); pvar->settings.Enabled = 1; action = OPTION_REPLACE; } - else if (_mbschr(option, '@') != NULL) { + else if (wcschr(option, '@') != NULL) { // // user @ host \x8C`\x8E\xAE\x82̃T\x83|\x81[\x83g // \x8E\xE6\x82荇\x82\xA6\x82\xB8ssh\x82ł̂݃T\x83|\x81[\x83g\x82ׁ̈A\x83\x86\x81[\x83U\x96\xBC\x82\xCDttssh\x93\xE0\x82Œׂ\xB7\x81B @@ -1769,16 +1768,19 @@ // \x8F\xAB\x97\x88\x93I\x82\xC9telnet authentication option\x82\xF0\x83T\x83|\x81[\x83g\x82\xB5\x82\xBD\x8E\x9E\x82\xCD // Tera Term\x96{\x91̂ŏ\x88\x97\x9D\x82\xB7\x82\xE9\x82悤\x82ɂ\xB7\x82\xE9\x97\\x92\xE8\x81B // - char *p; - p = _mbschr(option, '@'); + char *optionA; + wchar_t *p; + p = wcschr(option, '@'); *p = 0; - strncpy_s(pvar->ssh2_username, sizeof(pvar->ssh2_username), option, _TRUNCATE); + optionA = ToCharW(option); + strncpy_s(pvar->ssh2_username, sizeof(pvar->ssh2_username), optionA, _TRUNCATE); + free(optionA); // \x83\x86\x81[\x83U\x96\xBC\x95\x94\x95\xAA\x82\xF0\x83X\x83y\x81[\x83X\x82Œׂ\xB7\x81B // \x8C㑱\x82\xCCTTX\x82\xE2Tera Term\x96{\x91̂ʼn\xF0\x8E߂\xB7\x82鎞\x82ɂ̓X\x83y\x81[\x83X\x82\xF0\x93ǂݔ\xF2\x82\xB7\x82̂ŁA // \x83z\x83X\x83g\x96\xBC\x82\xF0\x90擪\x82ɋl\x82߂\xE9\x95K\x97v\x82͖\xB3\x82\xA2\x81B - memset(option, ' ', p-option+1); + wmemset(option, ' ', p-option+1); action = OPTION_REPLACE; } @@ -1786,11 +1788,11 @@ switch (action) { case OPTION_CLEAR: - memset(cur, ' ', next-cur); + wmemset(cur, ' ', next-cur); break; case OPTION_REPLACE: - memset(cur, ' ', next-cur); - memcpy(cur+1, option, strlen(option)); + wmemset(cur, ' ', next-cur); + wmemcpy(cur+1, option, wcslen(option)); break; }