Skip to content

Commit

Permalink
RLogin-2.23.3
Browse files Browse the repository at this point in the history
  • Loading branch information
kmiya-culti committed Mar 29, 2018
1 parent 07fb48f commit e05e14c
Show file tree
Hide file tree
Showing 44 changed files with 5,294 additions and 652 deletions.
24 changes: 15 additions & 9 deletions RLogin/AlgoDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,34 +78,40 @@ void CAlgoDlg::OnOK()
void CAlgoDlg::OnBnClickedReset()
{
int n, i;
CTextRam TextRam;
CKeyNodeTab KeyTab;
CKeyMacTab KeyMac;
CParamTab ParamTab;
CTextRam *pTextRam = new CTextRam;
CKeyNodeTab *pKeyTab = new CKeyNodeTab;
CKeyMacTab *pKeyMac = new CKeyMacTab;
CParamTab *pParamTab = new CParamTab;
CInitAllDlg dlg;

if ( dlg.DoModal() != IDOK )
return;
goto ENDOF;

switch(dlg.m_InitType) {
case 0: // Init Default Entry
ParamTab.Serialize(FALSE);
pParamTab->Serialize(FALSE);
break;

case 1: // Init Program Default
ParamTab.Init();
pParamTab->Init();
break;

case 2: // Copy Entry option
ASSERT(dlg.m_pInitEntry != NULL);
CRLoginDoc::LoadOption(*(dlg.m_pInitEntry), TextRam, KeyTab, KeyMac, ParamTab);
CRLoginDoc::LoadOption(*(dlg.m_pInitEntry), *pTextRam, *pKeyTab, *pKeyMac, *pParamTab);
break;
}

for ( n = 0 ; n < 12 ; n++ ) {
m_AlgoTab[n] = ParamTab.m_AlgoTab[n];
m_AlgoTab[n] = pParamTab->m_AlgoTab[n];
m_List[n].DeleteAllItems();
for ( i = 0 ; i < m_AlgoTab[n].GetSize() ; i++ )
m_List[n].InsertItem(i, m_AlgoTab[n][i]);
}

ENDOF:
delete pTextRam;
delete pKeyTab;
delete pKeyMac;
delete pParamTab;
}
2 changes: 1 addition & 1 deletion RLogin/ComMoniDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

#define GRAPDATA_MAX 180

typedef struct {
typedef struct _GRAPDATA {
DWORD ByteSec[2];
DWORD ModSts[2];
} GRAPDATA;
Expand Down
35 changes: 28 additions & 7 deletions RLogin/Data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4090,15 +4090,16 @@ void CServerEntryTab::Serialize(int mode)
if ( tmp.GetProfile(_T("ServerEntryTab"), uid) ) {
tmp.m_Uid = ((CRLoginApp *)AfxGetApp())->GetProfileSeqNum(m_pSection, _T("ListMax"));

CTextRam *pTextRam = new CTextRam;
CKeyNodeTab *pKeyTab = new CKeyNodeTab;
CKeyMacTab *pKeyMac = new CKeyMacTab;
CParamTab *pParamTab = new CParamTab;

try {
// Unicodeで再構成
CTextRam TextRam;
CKeyNodeTab KeyTab;
CKeyMacTab KeyMac;
CParamTab ParamTab;

CRLoginDoc::LoadOption(tmp, TextRam, KeyTab, KeyMac, ParamTab);
CRLoginDoc::SaveOption(tmp, TextRam, KeyTab, KeyMac, ParamTab);
CRLoginDoc::LoadOption(tmp, *pTextRam, *pKeyTab, *pKeyMac, *pParamTab);
CRLoginDoc::SaveOption(tmp, *pTextRam, *pKeyTab, *pKeyMac, *pParamTab);

// 新しいSectionに保存
tmp.SetProfile(m_pSection);
Expand All @@ -4114,6 +4115,11 @@ void CServerEntryTab::Serialize(int mode)
errcount++;
continue;
}

delete pTextRam;
delete pKeyTab;
delete pKeyMac;
delete pParamTab;
} else
errcount++;
}
Expand Down Expand Up @@ -5129,7 +5135,7 @@ const CKeyNodeTab & CKeyNodeTab::operator = (CKeyNodeTab &data)
return *this;
}

#define CMDSKEYTABMAX 133
#define CMDSKEYTABMAX 134
static const struct _CmdsKeyTab {
int code;
LPCWSTR name;
Expand Down Expand Up @@ -5213,6 +5219,7 @@ static const struct _CmdsKeyTab {
{ ID_FILE_PRINT_SETUP, L"$PRINT_SETUP" },
{ ID_PAGE_PRIOR, L"$PRIOR" },
{ IDM_CREATEPROFILE, L"$PROFILE_SAVE" },
{ IDM_REGISTAPP, L"$REGISTRY_HANDLE" },
{ IDM_SAVEREGFILE, L"$REGISTRY_SAVE" },
{ IDM_RESET_ALL, L"$RESET_ALL" },
{ IDM_RESET_ATTR, L"$RESET_ATTR" },
Expand Down Expand Up @@ -6001,6 +6008,8 @@ void CParamTab::Init()

m_bInitPageant = FALSE;
m_StdIoBufSize = 8;

m_TransmitLimit = 1000;
}
void CParamTab::SetArray(CStringArrayExt &stra)
{
Expand Down Expand Up @@ -6048,6 +6057,7 @@ void CParamTab::SetArray(CStringArrayExt &stra)
stra.AddVal(m_x11AuthFlag);
stra.AddVal(m_bInitPageant);
stra.AddVal(m_StdIoBufSize);
stra.AddVal(m_TransmitLimit);
}
void CParamTab::GetArray(CStringArrayExt &stra)
{
Expand Down Expand Up @@ -6175,6 +6185,9 @@ void CParamTab::GetArray(CStringArrayExt &stra)
if ( stra.GetSize() > i )
m_StdIoBufSize = stra.GetVal(i++);

if ( stra.GetSize() > i )
m_TransmitLimit = stra.GetVal(i++);

// Fix IdKeyList
if ( m_IdKeyStr[0].Compare(_T("IdKeyList Entry")) == 0 ) {
m_IdKeyList.GetString(m_IdKeyStr[1]);
Expand Down Expand Up @@ -6253,6 +6266,8 @@ void CParamTab::SetIndex(int mode, CStringIndex &index)
index[_T("InitPageant")] = m_bInitPageant;
index[_T("StdIoBufSize")] = m_StdIoBufSize;

index[_T("TransmitLimit")] = m_TransmitLimit;

} else { // Read
if ( (n = index.Find(_T("Algo"))) >= 0 ) {
for ( int a = 0 ; a < 12 ; a++ ) {
Expand Down Expand Up @@ -6356,6 +6371,9 @@ void CParamTab::SetIndex(int mode, CStringIndex &index)

if ( (n = index.Find(_T("StdIoBufSize"))) >= 0 )
m_StdIoBufSize = index[n];

if ( (n = index.Find(_T("TransmitLimit"))) >= 0 )
m_TransmitLimit = index[n];
}
}
void CParamTab::DiffIndex(CParamTab &orig, CStringIndex &index)
Expand Down Expand Up @@ -6461,6 +6479,9 @@ void CParamTab::DiffIndex(CParamTab &orig, CStringIndex &index)

if ( m_StdIoBufSize != orig.m_StdIoBufSize )
index[_T("StdIoBufSize")] = m_StdIoBufSize;

if ( m_TransmitLimit != orig.m_TransmitLimit )
index[_T("TransmitLimit")] = m_TransmitLimit;
}

static const ScriptCmdsDefs DocSsh[] = {
Expand Down
5 changes: 1 addition & 4 deletions RLogin/Data.h
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,7 @@ class CParamTab : public COptObject
CString m_x11AuthData;
BOOL m_bInitPageant;
int m_StdIoBufSize;
int m_TransmitLimit;

CParamTab();
void Init();
Expand All @@ -882,10 +883,6 @@ class CParamTab : public COptObject
#define FEXT_FLUSH_MAX (512 * 1024)
#define FEXT_MSG_MAX 64 // 512K / 16K = 32 * 2 = 64

#define WM_FILEWRITE (WM_USER + 1)
#define WM_FILEFLUSH (WM_USER + 2)
#define WM_FILESYNC (WM_USER + 3)

class CFileThread : public CWinThread
{
DECLARE_DYNCREATE(CFileThread)
Expand Down
83 changes: 71 additions & 12 deletions RLogin/ExtSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ CExtSocket::CExtSocket(class CRLoginDoc *pDoc)
m_AddrInfoTop = NULL;
m_pSyncEvent = NULL;
m_bUseProc = FALSE;

m_TransmitLimit = 0;
m_SendLimit.clock = m_RecvLimit.clock = clock();
m_SendLimit.size = m_RecvLimit.size = 0;
m_SendLimit.timer = m_RecvLimit.timer = 0;
}

CExtSocket::~CExtSocket()
Expand All @@ -114,6 +119,13 @@ CExtSocket::~CExtSocket()
}
}

void CExtSocket::ResetOption()
{
if ( m_pDocument == NULL )
return;

m_TransmitLimit = m_pDocument->m_TextRam.IsOptEnable(TO_RLTRSLIMIT) ? (m_pDocument->m_ParamTab.m_TransmitLimit * 1024) : 0;
}
void CExtSocket::Destroy()
{
Close();
Expand Down Expand Up @@ -532,6 +544,8 @@ BOOL CExtSocket::Open(LPCTSTR lpszHostAddress, UINT nHostPort, UINT nSocketPort,
while ( m_SendHead != NULL )
m_SendHead = RemoveHead(m_SendHead);

m_TransmitLimit = m_pDocument->m_TextRam.IsOptEnable(TO_RLTRSLIMIT) ? (m_pDocument->m_ParamTab.m_TransmitLimit * 1024) : 0;

m_RecvSize = m_RecvProcSize = 0;
m_SendSize = 0;

Expand Down Expand Up @@ -572,6 +586,8 @@ BOOL CExtSocket::Open(LPCTSTR lpszHostAddress, UINT nHostPort, UINT nSocketPort,
}
void CExtSocket::Close()
{
((CMainFrame *)AfxGetMainWnd())->DelTimerEvent(this);

SSLClose();

if ( m_AddrInfoTop != NULL ) {
Expand Down Expand Up @@ -752,13 +768,37 @@ void CExtSocket::SendFlash(int sec)
Sleep(100);
}
}
void CExtSocket::CheckLimit(int len, struct _LimitData *pLimit)
{
int msec;
clock_t now = clock();

pLimit->size += len;

if ( (msec = now - pLimit->clock) >= (CLOCKS_PER_SEC * 2) ) {
pLimit->size = pLimit->size * CLOCKS_PER_SEC / msec;
pLimit->clock = now - CLOCKS_PER_SEC;
msec = CLOCKS_PER_SEC;
}

if ( msec > 0 && (int)(pLimit->size * CLOCKS_PER_SEC / msec) > m_TransmitLimit ) {
if ( (msec = RECVBUFSIZ * 1000 / m_TransmitLimit) < 10 )
msec = 10;
else if ( msec > 500 )
msec = 500;
pLimit->timer = ((CMainFrame *)::AfxGetMainWnd())->SetTimerEvent(msec, TIMEREVENT_SOCK, this);
}
}
int CExtSocket::Send(const void* lpBuf, int nBufLen, int nFlags)
{
int n;
int len = nBufLen;
CSockBuffer *sp;

while ( m_SendHead == NULL && nBufLen > 0 ) {
if ( nBufLen <= 0 )
return len;

while ( m_SendHead == NULL && m_SendLimit.timer == 0 ) {
if ( m_SSL_mode != 0 )
n = (m_SSL_pSock != NULL ? SSL_write(m_SSL_pSock, lpBuf, nBufLen) : 0);
else
Expand All @@ -769,18 +809,19 @@ int CExtSocket::Send(const void* lpBuf, int nBufLen, int nFlags)
if ( n <= 0 )
break;

if ( m_TransmitLimit > 0 )
CheckLimit(n, &m_SendLimit);

if ( (nBufLen -= n) <= 0 ) {
// Call OnSendEmpty
GetMainWnd()->PostMessage(WM_SOCKSEL, m_Fd, WSAMAKESELECTREPLY(FD_WRITE, 0));
return len;
}

lpBuf = (LPBYTE)lpBuf + n;
}

if ( nBufLen <= 0 )
return len;

if ( m_Fd != (-1) && (m_SocketEvent & FD_WRITE) == 0 ) {
if ( m_Fd != (-1) && (m_SocketEvent & FD_WRITE) == 0 && m_SendLimit.timer == 0 ) {
m_SocketEvent |= FD_WRITE;
WSAAsyncSelect(m_Fd, GetMainWnd()->GetSafeHwnd(), WM_SOCKSEL, m_SocketEvent);
TRACE("Send SocketEvent FD_WRITE On %04x\n", m_SocketEvent);
Expand Down Expand Up @@ -1390,8 +1431,10 @@ void CExtSocket::OnError(int err)
void CExtSocket::OnClose()
{
Close();

if ( m_pDocument == NULL )
return;

m_pDocument->OnSocketClose();
}
void CExtSocket::OnConnect()
Expand Down Expand Up @@ -1423,7 +1466,7 @@ void CExtSocket::OnSend()
{
int n;

while ( m_SendHead != NULL ) {
while ( m_SendHead != NULL && m_SendLimit.timer == 0 ) {
if ( m_SSL_mode != 0 )
n = (m_SSL_pSock != NULL ? SSL_write(m_SSL_pSock, m_SendHead->GetPtr(), m_SendHead->GetSize()): 0);
else
Expand All @@ -1432,16 +1475,20 @@ void CExtSocket::OnSend()
//TRACE("OnSend %s %d\r\n", m_SSL_mode ? "SSL" : "", n);

if ( n <= 0 ) {
m_SocketEvent |= FD_WRITE;
WSAAsyncSelect(m_Fd, GetMainWnd()->GetSafeHwnd(), WM_SOCKSEL, m_SocketEvent);
TRACE("OnSend SocketEvent FD_WRITE On %04x\n", m_SocketEvent);
if ( (m_SocketEvent & FD_WRITE) == 0 ) {
m_SocketEvent |= FD_WRITE;
WSAAsyncSelect(m_Fd, GetMainWnd()->GetSafeHwnd(), WM_SOCKSEL, m_SocketEvent);
}
return;
}

if ( m_SendHead->Consume(n) <= 0 )
m_SendHead = RemoveHead(m_SendHead);

m_SendSize -= n;

if ( m_TransmitLimit > 0 )
CheckLimit(n, &m_SendLimit);
}

if ( m_Fd != (-1) && (m_SocketEvent & FD_WRITE) != 0 ) {
Expand All @@ -1450,21 +1497,22 @@ void CExtSocket::OnSend()
TRACE("OnSend SocketEvent FD_WRITE Off %04x\n", m_SocketEvent);
}

OnSendEmpty();
if ( m_SendHead == NULL )
OnSendEmpty();
}
BOOL CExtSocket::ReceiveFlowCheck()
{
if ( m_Fd == (-1) )
return FALSE;

if ( (m_SocketEvent & (FD_READ | FD_OOB)) == 0 ) {
if ( m_RecvSize <= RECVMINSIZ ) {
if ( m_RecvSize <= RECVMINSIZ && m_RecvLimit.timer == 0 ) {
m_SocketEvent |= (FD_READ | FD_OOB);
WSAAsyncSelect(m_Fd, GetMainWnd()->GetSafeHwnd(), WM_SOCKSEL, m_SocketEvent);
TRACE("OnReceive SocketEvent On %04x (%d:%d)\n", m_SocketEvent, m_RecvSize, m_RecvProcSize);
}
} else {
if ( m_RecvSize >= RECVMAXSIZ ) {
if ( m_RecvSize >= RECVMAXSIZ || m_RecvLimit.timer != 0 ) {
m_SocketEvent &= ~(FD_READ | FD_OOB);
WSAAsyncSelect(m_Fd, GetMainWnd()->GetSafeHwnd(), WM_SOCKSEL, m_SocketEvent);
TRACE("OnReceive SocketEvent Off %04x (%d:%d)\n", m_SocketEvent, m_RecvSize, m_RecvProcSize);
Expand Down Expand Up @@ -1508,6 +1556,9 @@ void CExtSocket::OnReceive(int nFlags)
m_RecvHead = AddTail(sp, m_RecvHead);
m_RecvSize += sp->GetSize();
m_RecvSema.Unlock();

if ( m_TransmitLimit > 0 )
CheckLimit(n, &m_RecvLimit);
}
}
BOOL CExtSocket::ReceiveCall()
Expand Down Expand Up @@ -1673,6 +1724,14 @@ int CExtSocket::OnIdle()
}
void CExtSocket::OnTimer(UINT_PTR nIDEvent)
{
if ( m_SendLimit.timer == (int)nIDEvent ) {
m_SendLimit.timer = 0;
OnSend();
} else if ( m_RecvLimit.timer == (int)nIDEvent ) {
m_RecvLimit.timer = 0;
OnReceive(0);
} else
((CMainFrame *)AfxGetMainWnd())->DelTimerEvent(this, (int)nIDEvent);
}

//////////////////////////////////////////////////////////////////////
Expand Down
Loading

0 comments on commit e05e14c

Please sign in to comment.