svnno****@sourc*****
svnno****@sourc*****
2015年 5月 17日 (日) 01:47:54 JST
Revision: 5876 http://sourceforge.jp/projects/ttssh2/scm/svn/commits/5876 Author: maya Date: 2015-05-17 01:47:54 +0900 (Sun, 17 May 2015) Log Message: ----------- ttpmacro の NextParam を ttpset の NextParam と同じ動きにした Dequote を DequoteParam として ttlib.c に移動した GetParam を ttcmn.c から ttlib.c に移動した Modified Paths: -------------- trunk/TTProxy/ProxyWSockHook.h trunk/TTXSamples/TTXCommandLineOpt/TTXCommandLineOpt.c trunk/teraterm/common/ttcommon.h trunk/teraterm/common/ttlib.c trunk/teraterm/common/ttlib.h trunk/teraterm/ttpcmn/ttcmn.c trunk/teraterm/ttpcmn/ttpcmn.def trunk/teraterm/ttpmacro/ttmdlg.cpp trunk/teraterm/ttpset/ttset.c -------------- next part -------------- Modified: trunk/TTProxy/ProxyWSockHook.h =================================================================== --- trunk/TTProxy/ProxyWSockHook.h 2015-05-16 16:04:29 UTC (rev 5875) +++ trunk/TTProxy/ProxyWSockHook.h 2015-05-16 16:47:54 UTC (rev 5876) @@ -15,7 +15,6 @@ #include "Logger.h" #include "SSLSocket.h" -#include "ttcommon.h" #include "ttlib.h" #include "i18n.h" Modified: trunk/TTXSamples/TTXCommandLineOpt/TTXCommandLineOpt.c =================================================================== --- trunk/TTXSamples/TTXCommandLineOpt/TTXCommandLineOpt.c 2015-05-16 16:04:29 UTC (rev 5875) +++ trunk/TTXSamples/TTXCommandLineOpt/TTXCommandLineOpt.c 2015-05-16 16:47:54 UTC (rev 5876) @@ -1,7 +1,6 @@ #include "teraterm.h" #include "tttypes.h" #include "ttplugin.h" -#include "ttcommon.h" #include "tt_res.h" #include <stdlib.h> #include <stdio.h> Modified: trunk/teraterm/common/ttcommon.h =================================================================== --- trunk/teraterm/common/ttcommon.h 2015-05-16 16:04:29 UTC (rev 5875) +++ trunk/teraterm/common/ttcommon.h 2015-05-16 16:47:54 UTC (rev 5876) @@ -41,7 +41,6 @@ void FAR PASCAL BroadcastClosingMessage(HWND myhwnd); void FAR PASCAL UndoAllWin(); void FAR PASCAL OpenHelp(UINT Command, DWORD Data, char *UILanguageFile); -PCHAR FAR PASCAL GetParam(PCHAR buff, int size, PCHAR param); int FAR PASCAL CommReadRawByte(PComVar cv, LPBYTE b); int FAR PASCAL CommRead1Byte(PComVar cv, LPBYTE b); Modified: trunk/teraterm/common/ttlib.c =================================================================== --- trunk/teraterm/common/ttlib.c 2015-05-16 16:04:29 UTC (rev 5875) +++ trunk/teraterm/common/ttlib.c 2015-05-16 16:47:54 UTC (rev 5876) @@ -1056,3 +1056,75 @@ return strtime; } + +PCHAR FAR PASCAL GetParam(PCHAR buff, int size, PCHAR param) +{ + int i = 0; + BOOL quoted = FALSE; + + while (*param == ' ' || *param == '\t') { + param++; + } + + if (*param == '\0' || *param == ';') { + return NULL; + } + + while (*param != '\0' && (quoted || (*param != ';' && *param != ' ' && *param != '\t'))) { + if (*param == '"' && (*++param != '"' || !quoted)) { + quoted = !quoted; + continue; + } + else if (i < size - 1) { + buff[i++] = *param; + } + param++; + } + + buff[i] = '\0'; + return (param); +} + +void FAR PASCAL DequoteParam(PCHAR dest, int dest_len, PCHAR src) +{ + int i, j; + char q, c; + + dest[0] = 0; + if (src[0] == 0) + return; + i = 0; + /* quoting char */ + q = src[i]; + /* only '"' is used as quoting char */ + if (q == '"') + i++; + + c = src[i]; + i++; + j = 0; + while ((c != 0 && j<dest_len)) { + if (c != '"') { + dest[j] = c; + j++; + } + else { + if (q == '"' && src[i] == '"') { + dest[j] = c; + j++; + i++; + } + else if (q == '"' && src[i] == '\0') { + break; + } + else { + dest[j] = c; + j++; + } + } + c = src[i]; + i++; + } + + dest[j] = 0; +} Modified: trunk/teraterm/common/ttlib.h =================================================================== --- trunk/teraterm/common/ttlib.h 2015-05-16 16:04:29 UTC (rev 5875) +++ trunk/teraterm/common/ttlib.h 2015-05-16 16:47:54 UTC (rev 5876) @@ -54,6 +54,9 @@ void b64encode(PCHAR dst, int dsize, PCHAR src, int len); int b64decode(PCHAR dst, int dsize, PCHAR src); +PCHAR FAR PASCAL GetParam(PCHAR buff, int size, PCHAR param); +void FAR PASCAL DequoteParam(PCHAR dest, int dest_len, PCHAR src); + #ifdef __cplusplus } #endif Modified: trunk/teraterm/ttpcmn/ttcmn.c =================================================================== --- trunk/teraterm/ttpcmn/ttcmn.c 2015-05-16 16:04:29 UTC (rev 5875) +++ trunk/teraterm/ttpcmn/ttcmn.c 2015-05-16 16:47:54 UTC (rev 5876) @@ -1155,34 +1155,6 @@ } } -PCHAR FAR PASCAL GetParam(PCHAR buff, int size, PCHAR param) -{ - int i = 0; - BOOL quoted = FALSE; - - while (*param == ' ' || *param == '\t') { - param++; - } - - if (*param == '\0' || *param == ';') { - return NULL; - } - - while (*param != '\0' && (quoted || (*param != ';' && *param != ' ' && *param != '\t'))) { - if (*param == '"' && (*++param != '"' || !quoted)) { - quoted = !quoted; - continue; - } - else if (i < size - 1) { - buff[i++] = *param; - } - param++; - } - - buff[i] = '\0'; - return (param); -} - HWND FAR PASCAL GetNthWin(int n) { if (n<pm->NWin) { Modified: trunk/teraterm/ttpcmn/ttpcmn.def =================================================================== --- trunk/teraterm/ttpcmn/ttpcmn.def 2015-05-16 16:04:29 UTC (rev 5875) +++ trunk/teraterm/ttpcmn/ttpcmn.def 2015-05-16 16:47:54 UTC (rev 5876) @@ -56,3 +56,4 @@ OpenHelp @61 GetParam @62 + DequoteParam @63 Modified: trunk/teraterm/ttpmacro/ttmdlg.cpp =================================================================== --- trunk/teraterm/ttpmacro/ttmdlg.cpp 2015-05-16 16:04:29 UTC (rev 5875) +++ trunk/teraterm/ttpmacro/ttmdlg.cpp 2015-05-16 16:47:54 UTC (rev 5876) @@ -43,43 +43,39 @@ static PStatDlg StatDlg = NULL; extern "C" { -BOOL NextParam(PCHAR Param, int *i, PCHAR Buff, int BuffSize) +BOOL NextParam(PCHAR Param, int *i, PCHAR Temp, int Size) { int j; - char c, q; + char c; BOOL Quoted; - if ( *i >= (int)strlen(Param)) { + if ((unsigned int) (*i) >= strlen(Param)) { return FALSE; } j = 0; - while (Param[*i]==' ') { + while (Param[*i] == ' ' || Param[*i] == '\t') { (*i)++; } + Quoted = FALSE; c = Param[*i]; - Quoted = ((c=='"') || (c=='\'')); - q = 0; - if (Quoted) { - q = c; - (*i)++; - c = Param[*i]; - } (*i)++; - while ((c!=0) && (c!=q) && (Quoted || (c!=' ')) && - (Quoted || (c!=';')) && (j<BuffSize-1)) { - Buff[j] = c; + while ((c != 0) && (j < Size - 1) && + (Quoted || ((c != ' ') && (c != ';') && (c != '\t')))) { + if (c == '"') + Quoted = !Quoted; + Temp[j] = c; j++; c = Param[*i]; (*i)++; } - if (! Quoted && (c==';')) { + if (!Quoted && (c == ';')) { (*i)--; } - Buff[j] = 0; - return (strlen(Buff)>0); + Temp[j] = 0; + return (strlen(Temp) > 0); } } @@ -135,31 +131,31 @@ else { j++; if (j==1) { - strncpy_s(FileName, sizeof(FileName),Temp, _TRUNCATE); + DequoteParam(FileName, sizeof(FileName), Temp); } else if (j==2) { - strncpy_s(Param2, sizeof(Param2),Temp, _TRUNCATE); + DequoteParam(Param2, sizeof(Param2), Temp); } else if (j==3) { - strncpy_s(Param3, sizeof(Param3),Temp, _TRUNCATE); + DequoteParam(Param3, sizeof(Param3), Temp); } else if (j==4) { - strncpy_s(Param4, sizeof(Param4),Temp, _TRUNCATE); + DequoteParam(Param4, sizeof(Param4), Temp); } else if (j==5) { - strncpy_s(Param5, sizeof(Param5),Temp, _TRUNCATE); + DequoteParam(Param5, sizeof(Param5), Temp); } else if (j==6) { - strncpy_s(Param6, sizeof(Param6),Temp, _TRUNCATE); + DequoteParam(Param6, sizeof(Param6), Temp); } else if (j==7) { - strncpy_s(Param7, sizeof(Param7),Temp, _TRUNCATE); + DequoteParam(Param7, sizeof(Param7), Temp); } else if (j==8) { - strncpy_s(Param8, sizeof(Param8),Temp, _TRUNCATE); + DequoteParam(Param8, sizeof(Param8), Temp); } else if (j==9) { - strncpy_s(Param9, sizeof(Param9),Temp, _TRUNCATE); + DequoteParam(Param9, sizeof(Param9), Temp); } } } Modified: trunk/teraterm/ttpset/ttset.c =================================================================== --- trunk/teraterm/ttpset/ttset.c 2015-05-16 16:04:29 UTC (rev 5875) +++ trunk/teraterm/ttpset/ttset.c 2015-05-16 16:47:54 UTC (rev 5876) @@ -3156,12 +3156,14 @@ char c; BOOL Quoted; - if ((unsigned int) (*i) >= strlen(Param)) + if ((unsigned int) (*i) >= strlen(Param)) { return FALSE; + } j = 0; - while (Param[*i] == ' ' || Param[*i] == '\t') + while (Param[*i] == ' ' || Param[*i] == '\t') { (*i)++; + } Quoted = FALSE; c = Param[*i]; @@ -3175,58 +3177,14 @@ c = Param[*i]; (*i)++; } - if (!Quoted && (c == ';')) + if (!Quoted && (c == ';')) { (*i)--; + } Temp[j] = 0; return (strlen(Temp) > 0); } -void Dequote(PCHAR Source, PCHAR Dest) -{ - int i, j; - char q, c; - - Dest[0] = 0; - if (Source[0] == 0) - return; - i = 0; - /* quoting char */ - q = Source[i]; - /* only '"' is used as quoting char */ - if (q == '"') - i++; - - c = Source[i]; - i++; - j = 0; - while ((c != 0)) { - if (c != '"') { - Dest[j] = c; - j++; - } - else { - if (q == '"' && Source[i] == '"') { - Dest[j] = c; - j++; - i++; - } - else if (q == '"' && Source[i] == '\0') { - break; - } - else { - Dest[j] = c; - j++; - } - } - c = Source[i]; - i++; - } - - Dest[j] = 0; -} - - #ifndef NO_INET6 static void ParseHostName(char *HostStr, WORD * port) { @@ -3353,7 +3311,7 @@ while (NextParam(Param, &i, Temp, sizeof(Temp))) { if (_strnicmp(Temp, "/F=", 3) == 0) { /* setup filename */ - Dequote(&Temp[3], Temp2); + DequoteParam(Temp2, sizeof(Temp2), &Temp[3]); if (strlen(Temp2) > 0) { ConvFName(ts->HomeDir, Temp2, sizeof(Temp2), ".INI", Temp, sizeof(Temp)); @@ -3414,7 +3372,7 @@ ts->HostDialogOnStartup = TRUE; } else if (_strnicmp(Temp, "/FD=", 4) == 0) { /* file transfer directory */ - Dequote(&Temp[4], Temp2); + DequoteParam(Temp2, sizeof(Temp2), &Temp[4]); if (strlen(Temp2) > 0) { _getcwd(TempDir, sizeof(TempDir)); if (_chdir(Temp2) == 0) @@ -3428,7 +3386,7 @@ else if (_stricmp(Temp, "/I") == 0) /* iconize */ ts->Minimize = 1; else if (_strnicmp(Temp, "/K=", 3) == 0) { /* Keyboard setup file */ - Dequote(&Temp[3], Temp2); + DequoteParam(Temp2, sizeof(Temp2), &Temp[3]); ConvFName(ts->HomeDir, Temp2, sizeof(Temp2), ".CNF", ts->KeyCnfFN, sizeof(ts->KeyCnfFN)); } @@ -3457,7 +3415,7 @@ } } else if (_strnicmp(Temp, "/L=", 3) == 0) { /* log file */ - Dequote(&Temp[3], Temp2); + DequoteParam(Temp2, sizeof(Temp2), &Temp[3]); strncpy_s(ts->LogFN, sizeof(ts->LogFN), Temp2, _TRUNCATE); } else if (_strnicmp(Temp, "/LA=", 4) == 0) { /* language */ @@ -3480,14 +3438,14 @@ } } else if (_strnicmp(Temp, "/MN=", 4) == 0) { /* multicastname */ - Dequote(&Temp[4], ts->MulticastName); + DequoteParam(ts->MulticastName, sizeof(ts->MulticastName), &Temp[4]); } else if (_strnicmp(Temp, "/M=", 3) == 0) { /* macro filename */ if ((Temp[3] == 0) || (Temp[3] == '*')) strncpy_s(ts->MacroFN, sizeof(ts->MacroFN), "*", _TRUNCATE); else { - Dequote(&Temp[3], Temp2); + DequoteParam(Temp2, sizeof(Temp2), &Temp[3]); ConvFName(ts->HomeDir, Temp2, sizeof(Temp2), ".TTL", ts->MacroFN, sizeof(ts->MacroFN)); } @@ -3509,7 +3467,7 @@ ParamTCP = 65535; } else if (_strnicmp(Temp, "/R=", 3) == 0) { /* Replay filename */ - Dequote(&Temp[3], Temp2); + DequoteParam(Temp2, sizeof(Temp2), &Temp[3]); ConvFName(ts->HomeDir, Temp2, sizeof(Temp2), "", ts->HostName, sizeof(ts->HostName)); if (strlen(ts->HostName) > 0) @@ -3533,7 +3491,7 @@ ts->HideWindow = 1; } else if (_strnicmp(Temp, "/W=", 3) == 0) { /* Window title */ - Dequote(&Temp[3], ts->Title); + DequoteParam(ts->Title, sizeof(ts->Title), &Temp[3]); } else if (_strnicmp(Temp, "/X=", 3) == 0) { /* Window pos (X) */ if (sscanf(&Temp[3], "%d", &pos) == 1) {