summaryrefslogtreecommitdiffabout
authorMichael Krelin <hacker@klever.net>2004-07-05 01:53:09 (UTC)
committer Michael Krelin <hacker@klever.net>2004-07-05 01:53:09 (UTC)
commit9938ea772d372ba955b7bc1f1c48a062c3a36f8a (patch) (side-by-side diff)
treea98185df944e3a763f9557aa74bc2837b343f048
downloadpumpkin-9938ea772d372ba955b7bc1f1c48a062c3a36f8a.zip
pumpkin-9938ea772d372ba955b7bc1f1c48a062c3a36f8a.tar.gz
pumpkin-9938ea772d372ba955b7bc1f1c48a062c3a36f8a.tar.bz2
initial commit into svn repository
git-svn-id: http://svn.klever.net/kin/pumpkin/trunk@1 fe716a7a-6dde-0310-88d9-d003556173a8
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--.gitignore37
-rw-r--r--COPYING19
-rw-r--r--ConfirmRRQDlg.cpp67
-rw-r--r--ConfirmRRQDlg.h39
-rw-r--r--ConfirmWRQDlg.cpp89
-rw-r--r--ConfirmWRQDlg.h44
-rw-r--r--KTAGS12
-rw-r--r--PropsNetwork.cpp71
-rw-r--r--PropsNetwork.h45
-rw-r--r--PropsServer.cpp79
-rw-r--r--PropsServer.h45
-rw-r--r--PropsSounds.cpp146
-rw-r--r--PropsSounds.h58
-rw-r--r--PumpKINDlg.cpp1973
-rw-r--r--PumpKINDlg.h327
-rw-r--r--README33
-rw-r--r--RequestDlg.cpp299
-rw-r--r--RequestDlg.h63
-rw-r--r--Resolver.cpp71
-rw-r--r--Resolver.h42
-rw-r--r--Retrier.cpp46
-rw-r--r--Retrier.h38
-rw-r--r--Trayer.cpp118
-rw-r--r--Trayer.h48
-rw-r--r--help/pumpkin.bmpbin0 -> 1318 bytes
-rw-r--r--help/pumpkin.cnt14
-rw-r--r--help/pumpkin.hpj19
-rw-r--r--help/pumpkin.rtf117
-rw-r--r--help/pumpkin.xml86
-rw-r--r--install/custom.rch10
-rw-r--r--install/install.cpp67
-rw-r--r--install/install.rc182
-rw-r--r--install/resource.h24
-rw-r--r--makehelp.bat32
-rw-r--r--pumpkin.clw283
-rw-r--r--pumpkin.cpp69
-rw-r--r--pumpkin.h36
-rw-r--r--pumpkin.mak1429
-rw-r--r--pumpkin.rc605
-rw-r--r--res/failed.wavbin0 -> 6746 bytes
-rw-r--r--res/finished.wavbin0 -> 8978 bytes
-rw-r--r--res/pumpkin.icobin0 -> 4710 bytes
-rw-r--r--res/pumpkin.rc213
-rw-r--r--res/ring.wavbin0 -> 3364 bytes
-rw-r--r--res/rrq.icobin0 -> 4710 bytes
-rw-r--r--res/wrq.icobin0 -> 4710 bytes
-rw-r--r--resource.h147
-rw-r--r--shared-code/BTreendex.h595
-rw-r--r--shared-code/BellsNWhistles.h146
-rw-r--r--shared-code/BitSet.h105
-rw-r--r--shared-code/Dynamide.h443
-rw-r--r--shared-code/FindIFace.h125
-rw-r--r--shared-code/LRUCache.h113
-rw-r--r--shared-code/RegEx.cpp1697
-rw-r--r--shared-code/RegEx.h158
-rw-r--r--shared-code/SNMPExtDll.h252
-rw-r--r--shared-code/SNMPOIDs.h221
-rw-r--r--shared-code/SNMPeer.h286
-rw-r--r--shared-code/install.h370
-rw-r--r--shared-code/ip_icmp.h91
-rw-r--r--shared-code/kHelpers.h159
-rw-r--r--shared-code/kICMP.cpp300
-rw-r--r--shared-code/kICMP.h80
-rw-r--r--shared-code/kinhelp.xsl250
-rw-r--r--shared-code/ms_icmp.h77
-rw-r--r--shared-data/browse-icon.icobin0 -> 1078 bytes
-rw-r--r--shared-data/install-icon.icobin0 -> 2998 bytes
-rw-r--r--shared-data/klever-background.bmpbin0 -> 2578 bytes
-rw-r--r--shared-data/play-icon.icobin0 -> 1078 bytes
-rw-r--r--stdafx.cpp6
-rw-r--r--stdafx.h27
71 files changed, 12443 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..fd020f1
--- a/dev/null
+++ b/.gitignore
@@ -0,0 +1,37 @@
+
+# /
+/Debug
+/Release
+/Releast
+/debug
+/release
+/releast
+/DEBUG
+/RELEASE
+/RELEAST
+/*.mdp
+/*.ncb
+/*.aps
+/redist
+
+# /help/
+/help/PUMPKIN.HLP
+/help/pumpkin.LOG
+/help/pumpkin.hm
+/help/pumpkin.GID
+/help/PumpKIN.FTS
+
+# /install/
+/install/debug
+/install/pure
+/install/canned
+/install/static
+/install/Debug
+/install/Pure
+/install/Canned
+/install/Static
+/install/DEBUG
+/install/PURE
+/install/CANNED
+/install/STATIC
+/install/*.aps
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..98e8827
--- a/dev/null
+++ b/COPYING
@@ -0,0 +1,19 @@
+Copyright (c) 1997, 1998, 2002 Klever Group (http://www.klever.net/)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/ConfirmRRQDlg.cpp b/ConfirmRRQDlg.cpp
new file mode 100644
index 0000000..361ad14
--- a/dev/null
+++ b/ConfirmRRQDlg.cpp
@@ -0,0 +1,67 @@
+// ConfirmRRQDlg.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "PumpKIN.h"
+#include "ConfirmRRQDlg.h"
+#include "PumpKINDlg.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CConfirmRRQDlg dialog
+
+
+CConfirmRRQDlg::CConfirmRRQDlg(CWnd* pParent /*=NULL*/)
+ : CDialog(CConfirmRRQDlg::IDD, pParent)
+{
+ m_Daddy=NULL;
+ //{{AFX_DATA_INIT(CConfirmRRQDlg)
+ m_File = _T("");
+ m_Host = _T("");
+ //}}AFX_DATA_INIT
+}
+
+
+void CConfirmRRQDlg::DoDataExchange(CDataExchange* pDX)
+{
+ CDialog::DoDataExchange(pDX);
+ //{{AFX_DATA_MAP(CConfirmRRQDlg)
+ DDX_Text(pDX, IDC_FILE, m_File);
+ DDX_Text(pDX, IDC_HOST, m_Host);
+ //}}AFX_DATA_MAP
+}
+
+
+BEGIN_MESSAGE_MAP(CConfirmRRQDlg, CDialog)
+ //{{AFX_MSG_MAP(CConfirmRRQDlg)
+ ON_WM_TIMER()
+ //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CConfirmRRQDlg message handlers
+
+BOOL CConfirmRRQDlg::OnInitDialog()
+{
+ CDialog::OnInitDialog();
+
+ m_Daddy->m_Daddy->m_bnw.StartSound(m_Daddy->m_Daddy->m_bnwRequest);
+ if(m_Daddy->m_Daddy->m_PromptTimeOut)
+ SetTimer(1,m_Daddy->m_Daddy->m_PromptTimeOut*1000,NULL);
+ SetWindowPos(&CWnd::wndTopMost,0,0,0,0,SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE);
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
+}
+
+void CConfirmRRQDlg::OnTimer(UINT nIDEvent)
+{
+ if(nIDEvent==1)
+ EndDialog(IDCANCEL);
+ CDialog::OnTimer(nIDEvent);
+}
diff --git a/ConfirmRRQDlg.h b/ConfirmRRQDlg.h
new file mode 100644
index 0000000..465d438
--- a/dev/null
+++ b/ConfirmRRQDlg.h
@@ -0,0 +1,39 @@
+// ConfirmRRQDlg.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CConfirmRRQDlg dialog
+
+class CRRQSocket;
+class CConfirmRRQDlg : public CDialog
+{
+// Construction
+public:
+ CRRQSocket * m_Daddy;
+ CConfirmRRQDlg(CWnd* pParent = NULL); // standard constructor
+
+// Dialog Data
+ //{{AFX_DATA(CConfirmRRQDlg)
+ enum { IDD = IDD_CONFIRM_RRQ };
+ CString m_File;
+ CString m_Host;
+ //}}AFX_DATA
+
+
+// Overrides
+ // ClassWizard generated virtual function overrides
+ //{{AFX_VIRTUAL(CConfirmRRQDlg)
+ protected:
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+
+ // Generated message map functions
+ //{{AFX_MSG(CConfirmRRQDlg)
+ virtual BOOL OnInitDialog();
+ afx_msg void OnTimer(UINT nIDEvent);
+ //}}AFX_MSG
+ DECLARE_MESSAGE_MAP()
+};
diff --git a/ConfirmWRQDlg.cpp b/ConfirmWRQDlg.cpp
new file mode 100644
index 0000000..c0380e3
--- a/dev/null
+++ b/ConfirmWRQDlg.cpp
@@ -0,0 +1,89 @@
+// ConfirmWRQDlg.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "PumpKIN.h"
+#include "ConfirmWRQDlg.h"
+
+#include "PumpKINDlg.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CConfirmWRQDlg dialog
+
+
+CConfirmWRQDlg::CConfirmWRQDlg(CWnd* pParent /*=NULL*/)
+ : CDialog(CConfirmWRQDlg::IDD, pParent)
+{
+ //{{AFX_DATA_INIT(CConfirmWRQDlg)
+ m_File = _T("");
+ m_Host = _T("");
+ //}}AFX_DATA_INIT
+}
+
+
+void CConfirmWRQDlg::DoDataExchange(CDataExchange* pDX)
+{
+ CDialog::DoDataExchange(pDX);
+ //{{AFX_DATA_MAP(CConfirmWRQDlg)
+ DDX_Control(pDX, IDC_RESUME, m_ResumeCtl);
+ DDX_Control(pDX, IDOK, m_OkCtl);
+ DDX_Control(pDX, IDC_RENAME, m_RenameCtl);
+ DDX_Text(pDX, IDC_FILE, m_File);
+ DDX_Text(pDX, IDC_HOST, m_Host);
+ //}}AFX_DATA_MAP
+}
+
+
+BEGIN_MESSAGE_MAP(CConfirmWRQDlg, CDialog)
+ //{{AFX_MSG_MAP(CConfirmWRQDlg)
+ ON_BN_CLICKED(IDC_RENAME, OnRename)
+ ON_WM_TIMER()
+ ON_BN_CLICKED(IDC_RESUME, OnResume)
+ //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CConfirmWRQDlg message handlers
+
+void CConfirmWRQDlg::OnRename()
+{
+ EndDialog(IDC_RENAME);
+}
+
+BOOL CConfirmWRQDlg::OnInitDialog()
+{
+ CDialog::OnInitDialog();
+
+ m_Daddy->m_Daddy->m_bnw.StartSound(m_Daddy->m_Daddy->m_bnwRequest);
+ if(m_Daddy->m_Daddy->m_PromptTimeOut)
+ SetTimer(1,m_Daddy->m_Daddy->m_PromptTimeOut*1000,NULL);
+ SetWindowPos(&CWnd::wndTopMost,0,0,0,0,SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE);
+ m_ResumeCtl.EnableWindow(m_Daddy->m_bResume);
+ if(m_Daddy->m_Rename){
+ m_OkCtl.SetButtonStyle(m_OkCtl.GetButtonStyle()&~BS_DEFPUSHBUTTON);
+ m_RenameCtl.SetButtonStyle(m_RenameCtl.GetButtonStyle()|BS_DEFPUSHBUTTON);
+ m_RenameCtl.SetFocus();
+ return FALSE;
+ }
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
+}
+
+void CConfirmWRQDlg::OnTimer(UINT nIDEvent)
+{
+ if(nIDEvent==1)
+ EndDialog(IDCANCEL);
+ CDialog::OnTimer(nIDEvent);
+}
+
+void CConfirmWRQDlg::OnResume()
+{
+ EndDialog(IDC_RESUME);
+}
diff --git a/ConfirmWRQDlg.h b/ConfirmWRQDlg.h
new file mode 100644
index 0000000..c14848d
--- a/dev/null
+++ b/ConfirmWRQDlg.h
@@ -0,0 +1,44 @@
+// ConfirmWRQDlg.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CConfirmWRQDlg dialog
+
+class CWRQSocket;
+class CConfirmWRQDlg : public CDialog
+{
+// Construction
+public:
+ CWRQSocket *m_Daddy;
+ CConfirmWRQDlg(CWnd* pParent = NULL); // standard constructor
+
+// Dialog Data
+ //{{AFX_DATA(CConfirmWRQDlg)
+ enum { IDD = IDD_CONFIRM_WRQ };
+ CButton m_ResumeCtl;
+ CButton m_OkCtl;
+ CButton m_RenameCtl;
+ CString m_File;
+ CString m_Host;
+ //}}AFX_DATA
+
+
+// Overrides
+ // ClassWizard generated virtual function overrides
+ //{{AFX_VIRTUAL(CConfirmWRQDlg)
+ protected:
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+
+ // Generated message map functions
+ //{{AFX_MSG(CConfirmWRQDlg)
+ afx_msg void OnRename();
+ virtual BOOL OnInitDialog();
+ afx_msg void OnTimer(UINT nIDEvent);
+ afx_msg void OnResume();
+ //}}AFX_MSG
+ DECLARE_MESSAGE_MAP()
+};
diff --git a/KTAGS b/KTAGS
new file mode 100644
index 0000000..36d22e5
--- a/dev/null
+++ b/KTAGS
@@ -0,0 +1,12 @@
+about-date pumpkin.rc /LTEXT\s\+"Copyright /;" kind:d
+about-version pumpkin.rc /LTEXT\s\+"PumpKIN, Version /;" kind:v
+help-license-date ./help/pumpkin.xml /<license\s/;" kind:d
+help-news ./help/pumpkin.xml /<newsfor\s/
+install-version ./install/install.cpp /^#define\s\+KINAME\s\+"/;" kind:v
+install-vsinfo-date install/install.rc /^\s\+VALUE\s\+"LegalCopyright",/;" kind:d
+install-vsinfo-numeric-version install/install.rc /^\s\+FILEVERSION\s\+/;" kind:v
+install-vsinfo-string-version install/install.rc /^\s\+VALUE\s\+"FileVersion",/;" kind:v
+license-date COPYING :1;" kind:d
+vsinfo-date pumpkin.rc /VALUE\s\+"LegalCopyright",/;" kind:d
+vsinfo-numeric-version pumpkin.rc /^\s\+FILEVERSION\s\+/;" kind:v
+vsinfo-string-version pumpkin.rc /^\s\+VALUE\s\+"FileVersion",/;" kind:v
diff --git a/PropsNetwork.cpp b/PropsNetwork.cpp
new file mode 100644
index 0000000..b5585d7
--- a/dev/null
+++ b/PropsNetwork.cpp
@@ -0,0 +1,71 @@
+// PropsNetwork.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "PumpKIN.h"
+#include "PropsNetwork.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CPropsNetwork property page
+
+IMPLEMENT_DYNCREATE(CPropsNetwork, CPropertyPage)
+
+CPropsNetwork::CPropsNetwork() : CPropertyPage(CPropsNetwork::IDD)
+{
+ //{{AFX_DATA_INIT(CPropsNetwork)
+ m_ListenPort = 0;
+ m_SpeakPort = 0;
+ m_TimeOut = 0;
+ m_BlockSize = 0;
+ //}}AFX_DATA_INIT
+}
+
+CPropsNetwork::~CPropsNetwork()
+{
+}
+
+void CPropsNetwork::DoDataExchange(CDataExchange* pDX)
+{
+ CPropertyPage::DoDataExchange(pDX);
+ //{{AFX_DATA_MAP(CPropsNetwork)
+ DDX_Control(pDX, IDC_BSIZESPIN, m_BSizeSpinCtl);
+ DDX_Control(pDX, IDC_TIMESPIN, m_TimeSpinCtl);
+ DDX_Control(pDX, IDC_SPEAKSPIN, m_SpeakSpinCtl);
+ DDX_Control(pDX, IDC_LISTENSPIN, m_ListenSpinCtl);
+ DDX_Text(pDX, IDC_LISTENPORT, m_ListenPort);
+ DDX_Text(pDX, IDC_SPEAKPORT, m_SpeakPort);
+ DDX_Text(pDX, IDC_TIMEOUT, m_TimeOut);
+ DDV_MinMaxUInt(pDX, m_TimeOut, 5, 60);
+ DDX_Text(pDX, IDC_BLOCKSIZE, m_BlockSize);
+ //}}AFX_DATA_MAP
+}
+
+
+BEGIN_MESSAGE_MAP(CPropsNetwork, CPropertyPage)
+ //{{AFX_MSG_MAP(CPropsNetwork)
+ //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CPropsNetwork message handlers
+
+BOOL CPropsNetwork::OnInitDialog()
+{
+ CPropertyPage::OnInitDialog();
+
+ m_ListenSpinCtl.SetRange(0,32767);
+ m_SpeakSpinCtl.SetRange(0,32767);
+ m_TimeSpinCtl.SetRange(5,60);
+ m_BSizeSpinCtl.SetRange(512,16384);
+UDACCEL uda = {0,512};
+ m_BSizeSpinCtl.SetAccel(1,&uda);
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
+}
diff --git a/PropsNetwork.h b/PropsNetwork.h
new file mode 100644
index 0000000..67d0b53
--- a/dev/null
+++ b/PropsNetwork.h
@@ -0,0 +1,45 @@
+// PropsNetwork.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CPropsNetwork dialog
+
+class CPropsNetwork : public CPropertyPage
+{
+ DECLARE_DYNCREATE(CPropsNetwork)
+
+// Construction
+public:
+ CPropsNetwork();
+ ~CPropsNetwork();
+
+// Dialog Data
+ //{{AFX_DATA(CPropsNetwork)
+ enum { IDD = IDD_PROPS_NETWORK };
+ CSpinButtonCtrl m_BSizeSpinCtl;
+ CSpinButtonCtrl m_TimeSpinCtl;
+ CSpinButtonCtrl m_SpeakSpinCtl;
+ CSpinButtonCtrl m_ListenSpinCtl;
+ UINT m_ListenPort;
+ UINT m_SpeakPort;
+ UINT m_TimeOut;
+ UINT m_BlockSize;
+ //}}AFX_DATA
+
+
+// Overrides
+ // ClassWizard generate virtual function overrides
+ //{{AFX_VIRTUAL(CPropsNetwork)
+ protected:
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+ // Generated message map functions
+ //{{AFX_MSG(CPropsNetwork)
+ virtual BOOL OnInitDialog();
+ //}}AFX_MSG
+ DECLARE_MESSAGE_MAP()
+
+};
diff --git a/PropsServer.cpp b/PropsServer.cpp
new file mode 100644
index 0000000..6f1e08c
--- a/dev/null
+++ b/PropsServer.cpp
@@ -0,0 +1,79 @@
+// PropsServer.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "PumpKIN.h"
+#include "PropsServer.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CPropsServer property page
+
+IMPLEMENT_DYNCREATE(CPropsServer, CPropertyPage)
+
+CPropsServer::CPropsServer() : CPropertyPage(CPropsServer::IDD)
+{
+ //{{AFX_DATA_INIT(CPropsServer)
+ m_RRQMode = -1;
+ m_TFTPRoot = _T("");
+ m_TFTPSubdirs = FALSE;
+ m_WRQMode = -1;
+ //}}AFX_DATA_INIT
+}
+
+CPropsServer::~CPropsServer()
+{
+}
+
+void CPropsServer::DoDataExchange(CDataExchange* pDX)
+{
+ CPropertyPage::DoDataExchange(pDX);
+ //{{AFX_DATA_MAP(CPropsServer)
+ DDX_Control(pDX, IDC_BROWSE, m_BrowseCtl);
+ DDX_Control(pDX, IDC_PROMPTTIMEOUT, m_PromptTimeoutCtl);
+ DDX_Radio(pDX, IDC_RRQ_GIVEALL, m_RRQMode);
+ DDX_Text(pDX, IDC_TFTPROOT, m_TFTPRoot);
+ DDX_Check(pDX, IDC_TFTPSUBDIRS, m_TFTPSubdirs);
+ DDX_Radio(pDX, IDC_WRQ_TAKEALL, m_WRQMode);
+ //}}AFX_DATA_MAP
+ if(pDX->m_bSaveAndValidate)
+ m_PromptTimeOut=m_PromptTimeoutCtl.GetPos();
+ else
+ m_PromptTimeoutCtl.SetPos(m_PromptTimeOut);
+}
+
+
+BEGIN_MESSAGE_MAP(CPropsServer, CPropertyPage)
+ //{{AFX_MSG_MAP(CPropsServer)
+ ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
+ //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CPropsServer message handlers
+
+BOOL CPropsServer::OnInitDialog()
+{
+ CPropertyPage::OnInitDialog();
+
+ m_PromptTimeoutCtl.SetRange(5,60);
+ m_BrowseCtl.SetIcon(AfxGetApp()->LoadIcon(IDI_BROWSE));
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
+}
+
+void CPropsServer::OnBrowse()
+{
+CString nr = m_TFTPRoot;
+ if(Klever::BrowseForFolder(nr,IDS_SELECT_TFTPROOT,this)){
+ UpdateData(TRUE);
+ m_TFTPRoot=nr;
+ UpdateData(FALSE);
+ }
+}
diff --git a/PropsServer.h b/PropsServer.h
new file mode 100644
index 0000000..29d85bd
--- a/dev/null
+++ b/PropsServer.h
@@ -0,0 +1,45 @@
+// PropsServer.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CPropsServer dialog
+
+class CPropsServer : public CPropertyPage
+{
+ DECLARE_DYNCREATE(CPropsServer)
+
+// Construction
+public:
+ UINT m_PromptTimeOut;
+ CPropsServer();
+ ~CPropsServer();
+
+// Dialog Data
+ //{{AFX_DATA(CPropsServer)
+ enum { IDD = IDD_PROPS_SERVER };
+ CButton m_BrowseCtl;
+ CSliderCtrl m_PromptTimeoutCtl;
+ int m_RRQMode;
+ CString m_TFTPRoot;
+ BOOL m_TFTPSubdirs;
+ int m_WRQMode;
+ //}}AFX_DATA
+
+
+// Overrides
+ // ClassWizard generate virtual function overrides
+ //{{AFX_VIRTUAL(CPropsServer)
+ protected:
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+ // Generated message map functions
+ //{{AFX_MSG(CPropsServer)
+ virtual BOOL OnInitDialog();
+ afx_msg void OnBrowse();
+ //}}AFX_MSG
+ DECLARE_MESSAGE_MAP()
+
+};
diff --git a/PropsSounds.cpp b/PropsSounds.cpp
new file mode 100644
index 0000000..a6f68d7
--- a/dev/null
+++ b/PropsSounds.cpp
@@ -0,0 +1,146 @@
+// PropsSounds.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "PumpKIN.h"
+#include "PropsSounds.h"
+#include "PumpKINDlg.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CPropsSounds property page
+
+IMPLEMENT_DYNCREATE(CPropsSounds, CPropertyPage)
+
+CPropsSounds::CPropsSounds() : CPropertyPage(CPropsSounds::IDD)
+{
+ //{{AFX_DATA_INIT(CPropsSounds)
+ m_Abort = _T("");
+ m_Success = _T("");
+ m_Request = _T("");
+ //}}AFX_DATA_INIT
+}
+
+CPropsSounds::~CPropsSounds()
+{
+}
+
+void CPropsSounds::DoDataExchange(CDataExchange* pDX)
+{
+ CPropertyPage::DoDataExchange(pDX);
+ //{{AFX_DATA_MAP(CPropsSounds)
+ DDX_Control(pDX, IDC_RING_PLAY, m_RequestPlayCtl);
+ DDX_Control(pDX, IDC_RING_BROWSE, m_RequestBrowseCtl);
+ DDX_Control(pDX, IDC_RING, m_RequestCtl);
+ DDX_Control(pDX, IDC_FINISHED_PLAY, m_SuccessPlayCtl);
+ DDX_Control(pDX, IDC_FINISHED_BROWSE, m_SuccessBrowseCtl);
+ DDX_Control(pDX, IDC_FINISHED, m_SuccessCtl);
+ DDX_Control(pDX, IDC_ABORTED_PLAY, m_AbortPlayCtl);
+ DDX_Control(pDX, IDC_ABORTED_BROWSE, m_AbortBrowseCtl);
+ DDX_Control(pDX, IDC_ABORTED, m_AbortCtl);
+ DDX_CBString(pDX, IDC_ABORTED, m_Abort);
+ DDX_CBString(pDX, IDC_FINISHED, m_Success);
+ DDX_CBString(pDX, IDC_RING, m_Request);
+ //}}AFX_DATA_MAP
+}
+
+
+BEGIN_MESSAGE_MAP(CPropsSounds, CPropertyPage)
+ //{{AFX_MSG_MAP(CPropsSounds)
+ ON_BN_CLICKED(IDC_ABORTED_BROWSE, OnAbortedBrowse)
+ ON_BN_CLICKED(IDC_FINISHED_BROWSE, OnFinishedBrowse)
+ ON_BN_CLICKED(IDC_RING_BROWSE, OnRingBrowse)
+ ON_BN_CLICKED(IDC_ABORTED_PLAY, OnAbortedPlay)
+ ON_BN_CLICKED(IDC_FINISHED_PLAY, OnFinishedPlay)
+ ON_BN_CLICKED(IDC_RING_PLAY, OnRingPlay)
+ //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CPropsSounds message handlers
+
+BOOL CPropsSounds::OnInitDialog()
+{
+ CPropertyPage::OnInitDialog();
+
+HICON hP = AfxGetApp()->LoadIcon(IDI_PLAY);
+HICON hB = AfxGetApp()->LoadIcon(IDI_BROWSE);
+ m_RequestPlayCtl.SetIcon(hP);
+ m_SuccessPlayCtl.SetIcon(hP);
+ m_AbortPlayCtl.SetIcon(hP);
+ m_RequestBrowseCtl.SetIcon(hB);
+ m_SuccessBrowseCtl.SetIcon(hB);
+ m_AbortBrowseCtl.SetIcon(hB);
+
+CPumpKINDlg* pd = (CPumpKINDlg*)AfxGetMainWnd();
+// ASSERT_KINDOF(CPumpKINDlg,pd);
+ m_bnw=&pd->m_bnw;
+
+ m_bnw->FillInCombo(&m_RequestCtl);
+ m_bnw->FillInCombo(&m_SuccessCtl);
+ m_bnw->FillInCombo(&m_AbortCtl);
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
+}
+
+void CPropsSounds::OnAbortedBrowse()
+{
+ Browse(m_AbortCtl);
+}
+void CPropsSounds::OnFinishedBrowse()
+{
+ Browse(m_SuccessCtl);
+}
+void CPropsSounds::OnRingBrowse()
+{
+ Browse(m_RequestCtl);
+}
+
+void CPropsSounds::OnAbortedPlay()
+{
+ Play(m_AbortCtl);
+}
+
+void CPropsSounds::OnFinishedPlay()
+{
+ Play(m_SuccessCtl);
+}
+
+void CPropsSounds::OnRingPlay()
+{
+ Play(m_RequestCtl);
+}
+
+void CPropsSounds::Browse(CComboBox& ctl)
+{
+CString f;
+ ctl.GetWindowText(f);
+CString filter;
+ filter.LoadString(IDS_FILTER_WAV);
+CFileDialog fd(TRUE,NULL,(LPCTSTR)f,
+ OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY
+ |OFN_LONGNAMES|OFN_NOCHANGEDIR|OFN_PATHMUSTEXIST,
+ filter,this);
+CString title;
+ title.LoadString(IDS_TITLE_WAV);
+ fd.m_ofn.lpstrTitle=(LPCTSTR)title;
+ if(fd.DoModal()==IDOK)
+ ctl.SetWindowText(fd.GetPathName());
+}
+
+void CPropsSounds::Play(CComboBox& ctl)
+{
+CString s;
+ ctl.GetWindowText(s);
+CBellsNWhistles::Whistling w = m_bnw->StartSound(s);
+ if(w){
+ Sleep(5000);
+ m_bnw->StopSound(w);
+ }
+}
diff --git a/PropsSounds.h b/PropsSounds.h
new file mode 100644
index 0000000..05aea4c
--- a/dev/null
+++ b/PropsSounds.h
@@ -0,0 +1,58 @@
+// PropsSounds.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CPropsSounds dialog
+
+class CPropsSounds : public CPropertyPage
+{
+ DECLARE_DYNCREATE(CPropsSounds)
+
+// Construction
+public:
+ void Play(CComboBox& ctl);
+ void Browse(CComboBox& ctl);
+ CBellsNWhistles* m_bnw;
+ CPropsSounds();
+ ~CPropsSounds();
+
+// Dialog Data
+ //{{AFX_DATA(CPropsSounds)
+ enum { IDD = IDD_PROPS_SOUNDS };
+ CButton m_RequestPlayCtl;
+ CButton m_RequestBrowseCtl;
+ CComboBox m_RequestCtl;
+ CButton m_SuccessPlayCtl;
+ CButton m_SuccessBrowseCtl;
+ CComboBox m_SuccessCtl;
+ CButton m_AbortPlayCtl;
+ CButton m_AbortBrowseCtl;
+ CComboBox m_AbortCtl;
+ CString m_Abort;
+ CString m_Success;
+ CString m_Request;
+ //}}AFX_DATA
+
+
+// Overrides
+ // ClassWizard generate virtual function overrides
+ //{{AFX_VIRTUAL(CPropsSounds)
+ protected:
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+ // Generated message map functions
+ //{{AFX_MSG(CPropsSounds)
+ virtual BOOL OnInitDialog();
+ afx_msg void OnAbortedBrowse();
+ afx_msg void OnFinishedBrowse();
+ afx_msg void OnRingBrowse();
+ afx_msg void OnAbortedPlay();
+ afx_msg void OnFinishedPlay();
+ afx_msg void OnRingPlay();
+ //}}AFX_MSG
+ DECLARE_MESSAGE_MAP()
+
+};
diff --git a/PumpKINDlg.cpp b/PumpKINDlg.cpp
new file mode 100644
index 0000000..1e6d03f
--- a/dev/null
+++ b/PumpKINDlg.cpp
@@ -0,0 +1,1973 @@
+// PumpKINDlg.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "PumpKIN.h"
+#include "PumpKINDlg.h"
+
+#include "PropsServer.h"
+#include "PropsNetwork.h"
+#include "PropsSounds.h"
+#include "ConfirmRRQDlg.h"
+#include "ConfirmWRQDlg.h"
+#include "RequestDlg.h"
+#include "Resolver.h"
+#include "Retrier.h"
+#include "Trayer.h"
+
+#include <io.h>
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+IMPLEMENT_DYNAMIC(CXferSocket, CAsyncSocket)
+IMPLEMENT_DYNAMIC(CWRQSocket, CXferSocket)
+IMPLEMENT_DYNAMIC(CRRQSocket, CXferSocket)
+
+/////////////////////////////////////////////////////////////////////////////
+// CAboutDlg dialog used for App About
+
+class CAboutDlg : public CDialog
+{
+public:
+ CAboutDlg();
+
+// Dialog Data
+ //{{AFX_DATA(CAboutDlg)
+ enum { IDD = IDD_ABOUTBOX };
+ //}}AFX_DATA
+
+ // ClassWizard generated virtual function overrides
+ //{{AFX_VIRTUAL(CAboutDlg)
+ protected:
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+ //{{AFX_MSG(CAboutDlg)
+ afx_msg void OnKlevernet();
+ //}}AFX_MSG
+ DECLARE_MESSAGE_MAP()
+};
+
+CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
+{
+ //{{AFX_DATA_INIT(CAboutDlg)
+ //}}AFX_DATA_INIT
+}
+
+void CAboutDlg::DoDataExchange(CDataExchange* pDX)
+{
+ CDialog::DoDataExchange(pDX);
+ //{{AFX_DATA_MAP(CAboutDlg)
+ //}}AFX_DATA_MAP
+}
+
+BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
+ //{{AFX_MSG_MAP(CAboutDlg)
+ ON_BN_CLICKED(IDC_KLEVERNET, OnKlevernet)
+ //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CPumpKINDlg dialog
+
+CPumpKINDlg::CPumpKINDlg(CWnd* pParent /*=NULL*/)
+ : CDialog(CPumpKINDlg::IDD, pParent)
+{
+ m_ListenPort = 69;
+ m_bTFTPSubdirs = TRUE;
+ m_RRQMode = rrqAlwaysConfirm;
+ m_WRQMode = wrqAlwaysConfirm;
+ m_TFTPTimeOut = CTimeSpan(0,0,0,30);
+ m_RetryTimeOut = CTimeSpan(0,0,0,10);
+ m_LogLength = 100;
+ m_SpeakPort = 69;
+ m_PromptTimeOut=30;
+ m_bShown=TRUE;
+ m_bExiting=FALSE;
+ m_BlockSize=1024;
+ m_bnw.AssignSound("(bang)",IDR_WAVE_RING,CBellsNWhistles::CBang::bangResource);
+ m_bnw.AssignSound("(done)",IDR_WAVE_FINISHED,CBellsNWhistles::CBang::bangResource);
+ m_bnw.AssignSound("(oops)",IDR_WAVE_ABORTED,CBellsNWhistles::CBang::bangResource);
+ m_bnw.AssignSound("(none)",(int)0,CBellsNWhistles::CBang::bangNone);
+ m_bnwRequest="(bang)"; m_bnwSuccess="(done)";
+ m_bnwAbort="(oops)";
+ //{{AFX_DATA_INIT(CPumpKINDlg)
+ //}}AFX_DATA_INIT
+ // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
+ m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
+ m_bmpBack.LoadBitmap(IDB_BACKGROUND);
+ m_bmpBack.GetBitmap(&m_bitmapBack);
+ m_Retrier = new CRetrier(this);
+ ASSERT(m_Retrier);
+ m_Trayer = new CTrayer(this);
+ ASSERT(m_Trayer);
+ LoadSettings();
+}
+
+void CPumpKINDlg::DoDataExchange(CDataExchange* pDX)
+{
+ CDialog::DoDataExchange(pDX);
+ //{{AFX_DATA_MAP(CPumpKINDlg)
+ DDX_Control(pDX, IDC_ABORT, m_AbortCtl);
+ DDX_Control(pDX, IDC_OPTIONS, m_OptionsCtl);
+ DDX_Control(pDX, IDC_LOG, m_Log);
+ DDX_Control(pDX, IDC_CONNECTIONS, m_List);
+ //}}AFX_DATA_MAP
+}
+
+BEGIN_MESSAGE_MAP(CPumpKINDlg, CDialog)
+ //{{AFX_MSG_MAP(CPumpKINDlg)
+ ON_WM_SYSCOMMAND()
+ ON_WM_DESTROY()
+ ON_WM_PAINT()
+ ON_WM_QUERYDRAGICON()
+ ON_WM_CREATE()
+ ON_BN_CLICKED(IDC_OPTIONS, OnOptions)
+ ON_WM_TIMER()
+ ON_BN_CLICKED(IDC_EXIT, OnExit)
+ ON_BN_CLICKED(IDC_PUT, OnPut)
+ ON_BN_CLICKED(IDC_GET, OnGet)
+ ON_NOTIFY(LVN_DELETEALLITEMS, IDC_CONNECTIONS, OnDeleteallitemsConnections)
+ ON_NOTIFY(LVN_DELETEITEM, IDC_CONNECTIONS, OnDeleteitemConnections)
+ ON_NOTIFY(LVN_INSERTITEM, IDC_CONNECTIONS, OnInsertitemConnections)
+ ON_NOTIFY(LVN_ITEMCHANGED, IDC_CONNECTIONS, OnItemchangedConnections)
+ ON_BN_CLICKED(IDC_ABORT, OnAbort)
+ ON_WM_CLOSE()
+ ON_COMMAND(ID_TRAY_SHOWPUMPKINWINDOW, OnTrayShowpumpkinwindow)
+ ON_COMMAND(ID_TRAY_EXIT, OnTrayExit)
+ ON_COMMAND(ID_TRAY_ABOUTPUMPKIN, OnTrayAboutpumpkin)
+ ON_COMMAND(ID_TRAY_FETCHFILE, OnTrayFetchfile)
+ ON_COMMAND(ID_TRAY_HELP, OnTrayHelp)
+ ON_COMMAND(ID_TRAY_OPTIONS, OnTrayOptions)
+ ON_COMMAND(ID_TRAY_SENDFILE, OnTraySendfile)
+ ON_WM_WINDOWPOSCHANGING()
+ ON_LBN_SELCHANGE(IDC_LOG, OnSelchangeLog)
+ ON_COMMAND(ID_TRAY_OPENFILESFOLDER, OnTrayOpenfilesfolder)
+ ON_WM_DROPFILES()
+ ON_BN_CLICKED(ID_HELP, OnHelp)
+ //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CPumpKINDlg message handlers
+
+BOOL CPumpKINDlg::OnInitDialog()
+{
+ CDialog::OnInitDialog();
+
+ // Add "About..." menu item to system menu.
+
+ // IDM_ABOUTBOX must be in the system command range.
+ ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
+ ASSERT(IDM_ABOUTBOX < 0xF000);
+
+ CMenu* pSysMenu = GetSystemMenu(FALSE);
+ CString strAboutMenu;
+ strAboutMenu.LoadString(IDS_ABOUTBOX);
+ if (!strAboutMenu.IsEmpty())
+ {
+ pSysMenu->AppendMenu(MF_SEPARATOR);
+ pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
+ }
+
+ // Set the icon for this dialog. The framework does this automatically
+ // when the application's main window is not a dialog
+ SetIcon(m_hIcon, TRUE); // Set big icon
+ SetIcon(m_hIcon, FALSE); // Set small icon
+
+ VERIFY(m_Retrier->Create(NULL,"PumpKIN-Retrier",WS_CHILD,CRect(0,0,0,0),this,0));
+
+
+ m_Images.Create(16,16,TRUE,2,1);
+ m_iRRQ = m_Images.Add(AfxGetApp()->LoadIcon(IDI_RRQ));
+ m_iWRQ = m_Images.Add(AfxGetApp()->LoadIcon(IDI_WRQ));
+ ASSERT(m_iRRQ>=0);
+ ASSERT(m_iWRQ>=0);
+ m_List.SetImageList(&m_Images,LVSIL_NORMAL);
+ m_List.SetImageList(&m_Images,LVSIL_SMALL);
+ m_List.SetImageList(&m_Images,LVSIL_STATE);
+ m_List.SetTextColor(RGB(255,255,0)); // Yellow
+ m_List.SetTextBkColor(RGB(12,167,0)); // Green
+ m_List.SetBkColor(RGB(12,167,0)); // Green
+CRect listrc;
+ m_List.GetClientRect(&listrc);
+ m_List.InsertColumn(0,"File",LVCFMT_LEFT,listrc.Width()-((listrc.Width()/7)*3+listrc.Width()*2/7),subitemFile);
+ m_List.InsertColumn(1,"type",LVCFMT_CENTER,listrc.Width()/7,subitemType);
+ m_List.InsertColumn(2,"peer",LVCFMT_LEFT,listrc.Width()*2/7,subitemPeer);
+ m_List.InsertColumn(3,"ACK",LVCFMT_RIGHT,listrc.Width()/7,subitemBytes);
+ m_List.InsertColumn(4,"tsize",LVCFMT_RIGHT,listrc.Width()/7,subitemTSize);
+
+ LogLine(IDS_LOG_START);
+
+ SetupButtons();
+
+CRect rc, drc;
+ GetWindowRect(rc);
+ GetDesktopWindow()->GetWindowRect(drc);
+ SetWindowPos(NULL,drc.right-6-rc.Width(),6,0,0,SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER);
+
+ if(m_bShown)
+ ShowWindow(SW_SHOW);
+ else
+ ShowWindow(SW_HIDE);
+
+ // CG: The following block was added by the ToolTips component.
+ {
+ // Create the ToolTip control.
+ m_tooltip.Create(this);
+ m_tooltip.Activate(TRUE);
+
+ m_tooltip.AddTool(&m_List,IDC_CONNECTIONS);
+ m_tooltip.AddTool(GetDlgItem(IDC_PUT),IDC_PUT);
+ m_tooltip.AddTool(GetDlgItem(IDC_GET),IDC_GET);
+ m_tooltip.AddTool(&m_AbortCtl,IDC_ABORT);
+ m_tooltip.AddTool(GetDlgItem(IDC_OPTIONS),IDC_OPTIONS);
+ m_tooltip.AddTool(GetDlgItem(IDC_EXIT),IDC_EXIT);
+ m_tooltip.AddTool(GetDlgItem(ID_HELP),ID_HELP);
+ m_tooltip.AddTool(GetDlgItem(IDC_LOG),IDC_LOG);
+ }
+ return TRUE; // return TRUE unless you set the focus to a control
+}
+
+void CPumpKINDlg::OnSysCommand(UINT nID, LPARAM lParam)
+{
+ if ((nID & 0xFFF0) == IDM_ABOUTBOX)
+ {
+ CAboutDlg dlgAbout;
+ dlgAbout.DoModal();
+ }
+ else
+ {
+ CDialog::OnSysCommand(nID, lParam);
+ }
+}
+
+void CPumpKINDlg::OnDestroy()
+{
+ SaveSettings();
+
+NOTIFYICONDATA nid;
+ memset(&nid,0,sizeof(nid));
+ nid.cbSize=sizeof(nid);
+ nid.hWnd=m_Trayer->m_hWnd;
+ nid.uID=IDC_TRAYICON;
+ nid.uFlags=0;
+ VERIFY(Shell_NotifyIcon(NIM_DELETE,&nid));
+
+ WinHelp(0L, HELP_QUIT);
+ CDialog::OnDestroy();
+POSITION p = m_LogTimes.GetStartPosition();
+ while(p){
+ CTime *t,*tt;
+ m_LogTimes.GetNextAssoc(p,t,tt);
+ ASSERT(t && tt && t==tt);
+ delete t;
+ }
+ // *** Abort and cleanup transfers
+ m_LogTimes.RemoveAll();
+}
+
+// If you add a minimize button to your dialog, you will need the code below
+// to draw the icon. For MFC applications using the document/view model,
+// this is automatically done for you by the framework.
+
+void CPumpKINDlg::OnPaint()
+{
+ if (IsIconic())
+ {
+ CPaintDC dc(this); // device context for painting
+
+ SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
+
+ // Center icon in client rectangle
+ int cxIcon = GetSystemMetrics(SM_CXICON);
+ int cyIcon = GetSystemMetrics(SM_CYICON);
+ CRect rect;
+ GetClientRect(&rect);
+ int x = (rect.Width() - cxIcon + 1) / 2;
+ int y = (rect.Height() - cyIcon + 1) / 2;
+
+ // Draw the icon
+ dc.DrawIcon(x, y, m_hIcon);
+ }
+ else
+ {
+ CPaintDC pDC(this);
+ CDC bmpDC;
+ bmpDC.CreateCompatibleDC(&pDC);
+ bmpDC.SelectObject(&m_bmpBack);
+ CRect rc;
+ GetClientRect(&rc);
+ for(int x=-m_bitmapBack.bmWidth*2/4;x<rc.Width();x+=m_bitmapBack.bmWidth)
+ for(int y=-m_bitmapBack.bmHeight*2/4;y<rc.Height();y+=m_bitmapBack.bmHeight)
+ pDC.BitBlt(x,y,m_bitmapBack.bmWidth,m_bitmapBack.bmHeight,&bmpDC,0,0,SRCCOPY);
+ bmpDC.DeleteDC();
+ CDialog::OnPaint();
+ }
+}
+
+// The system calls this to obtain the cursor to display while the user drags
+// the minimized window.
+HCURSOR CPumpKINDlg::OnQueryDragIcon()
+{
+ return (HCURSOR) m_hIcon;
+}
+
+int CPumpKINDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
+{
+ if (CDialog::OnCreate(lpCreateStruct) == -1)
+ return -1;
+
+ m_Listener.m_Daddy=this;
+ if(!m_Listener.Create(m_ListenPort,SOCK_DGRAM)){
+ TRACE0("Failed to create socket\n");
+ return -1;
+ }
+
+ if(!m_Trayer->Create(NULL,"PumpKIN TrayIcon",WS_CHILD,CRect(0,0,0,0),this,0)){
+ TRACE0("Failed to create trayer\n");
+ return -1;
+ }
+
+NOTIFYICONDATA nid;
+ memset(&nid,0,sizeof(nid));
+ nid.cbSize=sizeof(nid);
+ nid.hWnd=m_Trayer->m_hWnd;
+ nid.uID=IDC_TRAYICON;
+ nid.uFlags=NIF_MESSAGE|NIF_ICON|NIF_TIP;
+ nid.uCallbackMessage=WM_TRAYICON;
+ nid.hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME);
+ // *** Load from resource
+ strcpy(nid.szTip,"PumpKIN");
+ VERIFY(Shell_NotifyIcon(NIM_ADD,&nid));
+
+ return 0;
+}
+
+void CListenSocket::OnReceive(int nErrorCode)
+{
+ ASSERT(m_Daddy);
+ if(nErrorCode){
+ m_Daddy->LogLine(IDS_LOG_LISTENRECEIVEERROR);
+ return;
+ }
+DWORD fionread = 0;
+ VERIFY(IOCtl(FIONREAD,&fionread)); // *** Do some checking on the value acquired
+tftp *tftpRQ = tftp::Allocate(fionread);
+ ASSERT(tftpRQ);
+SOCKADDR_IN sin;
+ if(!tftpRQ->Receive(this,fionread,&sin)){
+ m_Daddy->LogLine(IDS_LOG_LISTENACCEPTERROR);
+ delete tftpRQ;
+ return;
+ }
+#ifndef NDEBUG
+CString tmp;
+ tmp.Format("%u - %s - %u\n",tftpRQ->Opcode(),inet_ntoa(sin.sin_addr),sin.sin_port);
+ TRACE0(tmp);
+#endif
+POSITION p = m_Daddy->m_Xfers.GetStartPosition();
+ while(p){
+ SOCKET key;
+ CXferSocket *sock;
+ m_Daddy->m_Xfers.GetNextAssoc(p,key,sock);
+ ASSERT(sock);
+ if(sock->m_Peer.sin_addr.s_addr==sin.sin_addr.s_addr && sock->m_Peer.sin_port==sin.sin_port){
+ TRACE0("Ignoring request which we are already processing\n");
+ delete tftpRQ;
+ return;
+ }
+ }
+ switch(tftpRQ->Opcode()){
+ case tftp::opRRQ:
+ // Read Request
+ {
+ CString tmp;
+ tmp.Format(IDS_LOG_RRQSERVE,tftpRQ->rqFileName(),tftpRQ->rqType(),inet_ntoa(sin.sin_addr));
+ m_Daddy->LogLine(tmp);
+ CRRQSocket *s = new CRRQSocket(m_Daddy,tftpRQ->rqFileName(),tftpRQ->rqType(),&sin);
+ ASSERT(s);
+ tftpRQ->GetOptions(&s->m_Options);
+ if(!s->Create())
+ s->Destroy(FALSE);
+ }
+ break;
+ case tftp::opWRQ:
+ // Write Request
+ {
+ CString tmp;
+ tmp.Format(IDS_LOG_WRQSERVE,tftpRQ->rqFileName(),tftpRQ->rqType(),inet_ntoa(sin.sin_addr));
+ m_Daddy->LogLine(tmp);
+ CWRQSocket *s = new CWRQSocket(m_Daddy,tftpRQ->rqFileName(),tftpRQ->rqType(),&sin);
+ ASSERT(s);
+ tftpRQ->GetOptions(&s->m_Options);
+ if(!s->Create(NULL,NULL))
+ s->Destroy(FALSE);
+ }
+ break;
+ default:
+ m_Daddy->LogLine(IDS_LOG_LISTENOPCODE);
+ delete tftpRQ;
+ return;
+ }
+ delete tftpRQ;
+}
+
+BOOL tftp::Receive(CAsyncSocket* socket,UINT maxLength,SOCKADDR_IN *sin)
+{
+ ASSERT(socket);
+int saddrLen = sizeof(SOCKADDR_IN);
+ length = sin ?
+ socket->ReceiveFrom(udpBase(),maxLength,(SOCKADDR*)sin,&saddrLen)
+ :
+ socket->Receive(udpBase(),maxLength)
+ ;
+ if(!length)
+ return FALSE;
+ if(length==(tftpLength)SOCKET_ERROR)
+ return FALSE;
+ return TRUE;
+}
+
+UINT tftp::Opcode()
+{
+ return REVERSEBYTES(opcode);
+}
+
+CString tftp::rqFileName()
+{
+ ASSERT(length);
+ ASSERT(Opcode()==opRRQ || Opcode()==opWRQ);
+CString rv;
+ if(memchr(&data.m_RQ.data,0,length-sizeof(opcode)))
+ rv = (LPCTSTR)data.m_RQ.data;
+ return rv;
+}
+
+CString tftp::rqType()
+{
+ ASSERT(length);
+ ASSERT(Opcode()==opRRQ || Opcode()==opWRQ);
+CString rv;
+char *tmp = (char*)memchr(&data.m_RQ.data,0,length-sizeof(opcode));
+ if(tmp++)
+ rv = (LPCTSTR)tmp;
+ return rv;
+}
+
+UINT tftp::GetOptions(tftp::tftpOptions* ops)
+{
+ ASSERT(length);
+ ASSERT(Opcode()==opRRQ || Opcode()==opWRQ || Opcode()==opOACK);
+ ASSERT(ops);
+tftpOptions& o = *ops;
+LPSTR base = (LPSTR)&data.m_RQ.data;
+UINT basePtr = 0;
+ if(Opcode()==opRRQ || Opcode()==opWRQ){
+ base = (LPSTR)memchr(&data.m_RQ.data,0,length-sizeof(opcode));
+ if(!base)
+ return 0;
+ base++;
+ basePtr = (base-(LPSTR)&data.m_RQ.data);
+ base = (LPSTR)memchr(base,0,length-basePtr);
+ if(!base)
+ return 0;
+ base++;
+ basePtr = (base-(LPSTR)&data.m_RQ.data);
+ }
+ ops->RemoveAll();
+UINT rv = 0;
+ while(basePtr<(length-sizeof(opcode))){
+ CString onam = (LPSTR)&data.m_RQ.data[basePtr];
+ basePtr+=onam.GetLength()+1;
+ CString oval = (LPSTR)&data.m_RQ.data[basePtr];
+ basePtr+=oval.GetLength()+1;
+ onam.MakeLower();
+ o[onam]=oval;
+ rv++;
+ }
+ return rv;
+}
+
+tftp::tftp()
+{
+ length=0;
+}
+
+
+void CXferSocket::OnSend(int nErrorCode)
+{
+ if(nErrorCode){
+ ASSERT(m_Daddy);
+ m_Daddy->LogLine(IDS_LOG_XFERSEND);
+ return;
+ }
+ if(!m_Queue.IsEmpty()){
+ tftp *p = m_Queue.GetHead();
+ ASSERT(p);
+ m_Queue.RemoveHead();
+ if(!p->Send(this,&m_Peer)){
+ ASSERT(m_Daddy);
+ m_Daddy->LogLine(IDS_LOG_XFERUDPSEND);
+ }
+ delete p;
+ }
+ DoSelect();
+ if(m_Queue.IsEmpty()){
+ switch(state){
+ case stateDeny:
+ Destroy(FALSE);
+ break;
+ case stateFinish:
+ Destroy(TRUE);
+ break;
+ }
+ }
+}
+
+BOOL tftp::Send(CAsyncSocket *socket,SOCKADDR_IN* saddr)
+{
+ ASSERT(socket);
+int rv = socket->SendTo(udpBase(),length,(SOCKADDR*)saddr,sizeof(SOCKADDR_IN));
+ if(rv!=length)
+ return FALSE;
+ return TRUE;
+}
+
+void CXferSocket::DoSelect()
+{
+ if(m_Peer.sin_addr.s_addr!=INADDR_NONE)
+ AsyncSelect(FD_CLOSE|FD_READ|(m_Queue.IsEmpty()?0:FD_WRITE));
+}
+
+void CXferSocket::OnReceive(int nErrorCode)
+{
+ if(nErrorCode){
+ ASSERT(m_Daddy);
+ m_Daddy->LogLine(IDS_LOG_XFERRECEIVE);
+ return;
+ }
+ ASSERT(m_Daddy);
+DWORD fionread = 0;
+ VERIFY(IOCtl(FIONREAD,&fionread));
+tftp *p = tftp::Allocate(fionread);
+ ASSERT(p);
+SOCKADDR_IN sin;
+ if(!p->Receive(this,fionread,&sin)){
+ m_Daddy->LogLine(IDS_LOG_XFERUDPRECEIVE);
+ delete p;
+ }else
+ if(m_Peer.sin_addr.s_addr==INADDR_NONE){
+ m_Peer.sin_addr=sin.sin_addr;
+ m_Peer.sin_port=sin.sin_port;
+ }
+BOOL alive = TRUE;
+ if(state==stateInit){
+ state=stateXfer;
+ m_Peer.sin_port=sin.sin_port;
+ UpdateList();
+ }
+ if(sin.sin_addr.s_addr!=m_Peer.sin_addr.s_addr || sin.sin_port!=m_Peer.sin_port){
+ m_Daddy->LogLine(IDS_LOG_XFERSOURCETID);
+ // *** Bounce it!
+ }else{
+ alive = OnTFTP(p);
+ }
+ delete p;
+ if(alive){
+ DoSelect();
+ ResetTimeout();
+ }
+}
+
+void CXferSocket::SetPeer(SOCKADDR_IN *sin)
+{
+ ASSERT(sin);
+ memmove(&m_Peer,sin,sizeof(m_Peer));
+}
+
+void CXferSocket::UpdateList()
+{
+ ASSERT(m_Daddy);
+LV_FINDINFO lvf;
+ memset(&lvf,0,sizeof(lvf));
+ lvf.flags=LVFI_PARAM;
+ lvf.lParam=(LPARAM)this;
+int i = m_Daddy->m_List.FindItem(&lvf);
+ if(i<0){
+ ASSERT(IsKindOf(RUNTIME_CLASS(CRRQSocket)) || IsKindOf(RUNTIME_CLASS(CWRQSocket)));
+ i=m_Daddy->m_List.InsertItem(0,m_FileName,IsKindOf(RUNTIME_CLASS(CRRQSocket))?m_Daddy->m_iRRQ:m_Daddy->m_iWRQ);
+ ASSERT(!(i<0));
+ m_Daddy->m_List.SetItemData(i,(DWORD)this);
+ }
+ m_Daddy->m_List.SetItemText(i,CPumpKINDlg::subitemFile,m_FileName);
+ m_Daddy->m_List.SetItemText(i,CPumpKINDlg::subitemType,m_Type);
+ m_Daddy->m_List.SetItemText(i,CPumpKINDlg::subitemPeer,inet_ntoa(m_Peer.sin_addr));
+CString tmp;
+ tmp.Format(IDS_FMT_BYTES,GetACK());
+ m_Daddy->m_List.SetItemText(i,CPumpKINDlg::subitemBytes,tmp);
+ if(m_xferSize>=0){
+ tmp.Format(IDS_FMT_BYTES,m_xferSize);
+ m_Daddy->m_List.SetItemText(i,CPumpKINDlg::subitemTSize,tmp);
+ }
+}
+
+CXferSocket::CXferSocket()
+ : m_wndResolver(NULL), m_Retry(NULL), m_bRetry(FALSE),
+ m_blkSize(512), m_timeOut(30), m_xferSize(-1),
+ m__blkSize(512), m__timeOut(30)
+{
+ m_Daddy=NULL;
+ m_Peer.sin_addr.s_addr=INADDR_NONE;
+ m_Peer.sin_family=AF_INET;
+ state=stateNone;
+}
+
+ULONG CXferSocket::GetACK()
+{
+ return 0;
+}
+
+CXferSocket::CXferSocket(CPumpKINDlg *daddy,LPCTSTR fileName,LPCTSTR type,SOCKADDR_IN* sin)
+ : m_wndResolver(NULL), m_Retry(NULL), m_bRetry(FALSE),
+ m_blkSize(512), m_timeOut(30), m_xferSize(-1),
+ m__blkSize(512), m__timeOut(30)
+{
+ m_Peer.sin_family=AF_INET;
+ state=stateNone;
+ ASSERT(daddy);
+ m_Daddy=daddy;
+ m_timeOut=m__timeOut=m_Daddy->m_TFTPTimeOut.GetTotalSeconds();
+ if(sin){
+ m_Peer.sin_addr.s_addr=sin->sin_addr.s_addr;
+ m_Peer.sin_port=sin->sin_port;
+ }else
+ m_Peer.sin_addr.s_addr=INADDR_NONE;
+ m_FileName=fileName;
+ m_Type=type;
+}
+
+BOOL CRRQSocket::Create(LPCTSTR localFile,LPCTSTR hostName)
+{
+ if(!CAsyncSocket::Create(0,SOCK_DGRAM))
+ return FALSE;
+ ASSERT(m_Daddy);
+ ASSERT(m_Peer.sin_addr.s_addr!=INADDR_NONE || hostName);
+ m_Daddy->m_Xfers[m_hSocket]=this;
+CString lFile = localFile?localFile:m_FileName;
+ TurnSlashes(lFile,TRUE);
+ UpdateList();
+ if(!localFile){ // Check only if server
+ if(CheckBadRelativeness(m_FileName)){
+ Deny(tftp::errAccessViolation,IDS_TFTP_ERROR_ACCESS);
+ return TRUE;
+ }
+ switch(m_Daddy->m_RRQMode){
+ case CPumpKINDlg::rrqGiveAll:
+ break;
+ case CPumpKINDlg::rrqAlwaysConfirm:
+ if(ConfirmRequest())
+ break;
+ case CPumpKINDlg::rrqDenyAll:
+ Deny(tftp::errAccessViolation,IDS_TFTP_ERROR_ACCESS);
+ return TRUE;
+ }
+ }
+CString fn = localFile?ApplyRootGently(lFile):ApplyRoot(lFile);
+CFileException e;
+ if(!m_File.Open(fn,CFile::modeRead|CFile::shareDenyWrite,&e)){
+ if(localFile){
+ CString tmp;
+ tmp.Format(IDS_LOG_FAILEDLOCALFILE,fn);
+ m_Daddy->LogLine(tmp);
+ return FALSE;
+ }
+ Deny(&e);
+ return TRUE;
+ }
+ m_xferSize=m_File.GetLength(); // *** HANDLE EXCEPTION
+ if(hostName){
+ m_HostName=hostName;
+
+ CString tmp;
+ tmp.Format(IDS_LOG_SENDING,m_FileName,m_HostName);
+ m_Daddy->LogLine(tmp);
+
+ CString inAddr = hostName;
+ int at = inAddr.Find('@');
+ if(at>=0)
+ inAddr=inAddr.Mid(at+1);
+ if((m_Peer.sin_addr.s_addr=inet_addr((LPCTSTR)inAddr))==INADDR_NONE){
+ ASSERT(!m_wndResolver);
+ m_wndResolver = new CResolver(this);
+ ASSERT(m_wndResolver);
+ return m_wndResolver->Resolve();
+ }
+ else
+ OnHostKnown();
+ }else{
+ tftp::tftpOptions o;
+ CString v;
+ if(m_Options.Lookup(tftpoBSize,v)){
+ m__blkSize=atoi(v);
+ if(m__blkSize){
+ m_blkSize=m__blkSize;
+ v.Format("%u",m_blkSize);
+ o[tftpoBSize]=v;
+ }
+ }
+ if(m_Options.Lookup(tftpoTSize,v)){
+ v.Format("%lu",m_xferSize);
+ o[tftpoTSize]=v;
+ }
+ if(m_Options.Lookup(tftpoTOut,v)){
+ m__timeOut=atoi(v);
+ if(m__timeOut){
+ m_timeOut=m__timeOut;
+ v.Format("%u",m_timeOut);
+ o[tftpoTOut]=v;
+ }
+ }
+ state = stateXfer;
+ m_ACK=0;
+ if(o.GetCount()){
+ tftp *p = tftp::Allocate(tftp::tftpOACK::tftpSize(&o));
+ ASSERT(p);
+ p->SetOpcode(tftp::opOACK);
+ p->data.m_OACK.Set(&o);
+ PostTFTP(p,TRUE);
+ }else
+ DoXfer();
+ }
+ return TRUE;
+}
+
+CRRQSocket::CRRQSocket(CPumpKINDlg *daddy,LPCTSTR fileName,LPCTSTR type,SOCKADDR_IN *sin)
+ : CXferSocket(daddy,fileName,type,sin)
+{
+ m_ACK=0;
+ m_LastSlack=0;
+}
+
+UINT tftp::tftpERROR::tftpSize(LPCTSTR msg)
+{
+ return tftpHdrSize-tftpSlackSize+sizeof(tftp::tftpERROR::tftpErrorCode)+strlen(msg)+1;
+}
+
+tftp* tftp::Allocate(UINT tftpSize)
+{
+ ASSERT(tftpSize);
+tftp* rv = (tftp*) new BYTE[tftpSlackSize+tftpSize];
+ ASSERT(rv);
+ rv->length=tftpSize;
+ return rv;
+}
+
+void tftp::errSet(UINT code,LPCTSTR msg)
+{
+ ASSERT(this);
+ ASSERT(length>=data.m_ERROR.tftpSize(msg));
+ strcpy((char*)data.m_ERROR.data,msg);
+ data.m_ERROR.SetCode(code);
+}
+
+void CXferSocket::PostTFTP(tftp* p,BOOL retryable)
+{
+ ASSERT(p);
+ m_Queue.AddTail(p);
+ DoSelect();
+ if(!m_bRetry){
+ if(retryable)
+ SetTry(p);
+ else
+ SetTry();
+ }
+ ResetTimeout();
+}
+
+void CXferSocket::Deny(UINT errCode,UINT errID)
+{
+ PostError(errCode,errID);
+ state=stateDeny;
+}
+
+void CRRQSocket::DoXfer()
+{
+tftp *p = tftp::Allocate(tftp::tftpDATA::tftpSize(m_blkSize));
+ ASSERT(p);
+ p->SetOpcode(tftp::opDATA);
+ TRY{
+ m_File.Seek(m_ACK*m_blkSize,CFile::begin);
+ int bytes = m_File.Read(p->data.m_DATA.data,m_blkSize);
+ p->data.m_DATA.SetBlock(m_ACK+1);
+ p->length=p->length-m_blkSize+bytes;
+ m_LastSlack = m_blkSize-bytes;
+ PostTFTP(p);
+ if(bytes<m_blkSize){
+ state=stateFinish;
+ ASSERT(m_Daddy);
+ CString tmp;
+ tmp.Format(IDS_LOG_XFERRRQFINISHED,(LPCTSTR)m_FileName);
+ m_Daddy->LogLine(tmp);
+ }
+ }CATCH(CFileException,e){
+ Deny(e);
+ }END_CATCH
+}
+
+UINT tftp::tftpDATA::tftpSize(UINT blkSize)
+{
+ return tftpHdrSize-tftpSlackSize+sizeof(tftp::tftpDATA)
+ -sizeof(BYTE)+blkSize;
+}
+
+void CXferSocket::Deny(CFileException* e)
+{
+ PostError(e);
+ state=stateDeny;
+}
+
+void CXferSocket::PostError(UINT errCode,UINT errID)
+{
+CString msg;
+ msg.LoadString(errID);
+ ASSERT(m_Daddy);
+/* // ***
+CString tmp;
+ tmp.Format(IDS_LOG_SENTTFTPERROR,errCode,(LPCTSTR)msg);
+ m_Daddy->LogLine(tmp);
+ */
+tftp* err = tftp::Allocate(tftp::tftpERROR::tftpSize(msg));
+err->SetOpcode(tftp::opERROR);
+ err->errSet(errCode,msg);
+ PostTFTP(err);
+}
+
+void CXferSocket::PostError(CFileException* e)
+{
+UINT eCode;
+UINT eMsgID;
+ switch(e->m_cause){
+ case CFileException::fileNotFound:
+ eCode=tftp::errNotFound;
+ eMsgID=IDS_TFTP_ERROR_NOTFOUND;
+ break;
+ case CFileException::accessDenied:
+ eCode=tftp::errAccessViolation;
+ eMsgID=IDS_TFTP_ERROR_ACCESS;
+ break;
+ case CFileException::directoryFull:
+ eCode=tftp::errDiskFull;
+ eMsgID=IDS_TFTP_ERROR_DIRFULL;
+ break;
+ case CFileException::sharingViolation:
+ eCode=tftp::errAccessViolation;
+ eMsgID=IDS_TFTP_ERROR_SHARING;
+ break;
+ case CFileException::diskFull:
+ eCode=tftp::errDiskFull;
+ eMsgID=IDS_TFTP_ERROR_DISKFULL;
+ break;
+ default:
+ eCode=tftp::errUndefined;
+ eMsgID=IDS_TFTP_ERROR_UNDEFINED;
+ break;
+ }
+ PostError(eCode,eMsgID);
+}
+
+ULONG CRRQSocket::GetACK(void)
+{
+ return (m_ACK*m_blkSize)-m_LastSlack;
+}
+
+BOOL CRRQSocket::OnTFTP(tftp* p)
+{
+BOOL rv = TRUE;
+ switch(p->Opcode()){
+ case tftp::opOACK:
+ m_ACK=0;
+ ASSERT(state!=stateFinish);
+ {
+ tftp::tftpOptions o;
+ if(p->GetOptions(&o)){
+ CString v;
+ if(o.Lookup(tftpoBSize,v)){
+ m_blkSize=atoi(v);
+ if(!m_blkSize){ // *** More sanity checks
+ Deny(tftp::errOption,IDS_TFTP_ERROR_BSIZE);
+ rv = TRUE;
+ break;
+ }
+ }
+ if(o.Lookup(tftpoTOut,v)){
+ m_timeOut=atoi(v);
+ if(!m_timeOut){ // *** More sanity checks
+ Deny(tftp::errOption,IDS_TFTP_ERROR_TOUT);
+ rv = TRUE;
+ break;
+ }
+ }
+ if(o.Lookup(tftpoXResume,v)){
+ m_ACK=atoi(v);
+ }
+ }
+ UpdateList();
+ DoXfer();
+ }
+ break;
+ case tftp::opACK:
+ m_ACK=p->data.m_ACK.Block();
+ if(state!=stateFinish){
+ UpdateList();
+ DoXfer();
+ }
+ break;
+ case tftp::opERROR:
+ {
+ ASSERT(m_Daddy);
+ CString tmp;
+ tmp.Format(IDS_LOG_GOTTFTPERROR,p->data.m_ERROR.Code(),(LPCTSTR)p->errMessage());
+ m_Daddy->LogLine(tmp);
+ }
+ Destroy(FALSE);
+ rv = FALSE;
+ break;
+ default:
+ ASSERT(m_Daddy);
+ m_Daddy->LogLine(IDS_LOG_XFEROPCODE);
+ // *** Self destruct maybe??
+ break;
+ }
+ return rv;
+}
+
+BOOL CWRQSocket::OnTFTP(tftp* p)
+{
+ switch(p->Opcode()){
+ case tftp::opOACK:
+ ASSERT(state!=stateFinish);
+ {
+ if(m_bResume)
+ m_ACK=m_File.GetLength()/m_blkSize;
+ else
+ m_ACK=0;
+ tftp::tftpOptions o;
+ if(p->GetOptions(&o)){
+ CString v;
+ if(o.Lookup(tftpoBSize,v)){
+ m_blkSize=atoi(v);
+ if(!m_blkSize){ // *** More sanity checks
+ Deny(tftp::errOption,IDS_TFTP_ERROR_BSIZE);
+ return TRUE;
+ }
+ }
+ if(o.Lookup(tftpoTOut,v)){
+ m_timeOut=atoi(v);
+ if(!m_timeOut){ // *** More sanity checks
+ Deny(tftp::errOption,IDS_TFTP_ERROR_TOUT);
+ return TRUE;
+ }
+ }
+ if(o.Lookup(tftpoTSize,v)){
+ m_xferSize=atoi(v);
+ }
+ }
+ UpdateList();
+ DoXfer();
+ }
+ break;
+ case tftp::opDATA:
+ {
+ UINT block = p->data.m_DATA.Block();
+ TRY{
+ m_File.Seek((block-1)*m_blkSize,CFile::begin);
+ int bytes = p->length-sizeof(p->data.m_DATA.block)-(tftpHdrSize-tftpSlackSize);
+ if(bytes){
+ m_File.Write(p->data.m_DATA.data,bytes);
+ // *** Move to the other place where we can do it not that often
+ m_File.SetLength(m_File.GetPosition());
+ }
+ if(bytes<m_blkSize){
+ state=stateFinish;
+ ASSERT(m_Daddy);
+ CString tmp;
+ tmp.Format(IDS_LOG_XFERWRQFINISHED,(LPCTSTR)m_FileName);
+ m_Daddy->LogLine(tmp);
+ }
+ m_ACK=block;
+ m_LastSlack=m_blkSize-bytes;
+ UpdateList();
+ DoXfer();
+ }CATCH(CFileException,e){
+ Deny(e);
+ }END_CATCH
+ }
+ break;
+ case tftp::opERROR:
+ {
+ ASSERT(m_Daddy);
+ CString tmp;
+ tmp.Format(IDS_LOG_GOTTFTPERROR,p->data.m_ERROR.Code(),(LPCTSTR)p->errMessage());
+ m_Daddy->LogLine(tmp);
+ }
+ Destroy(FALSE);
+ return FALSE;
+ default:
+ ASSERT(m_Daddy);
+ m_Daddy->LogLine(IDS_LOG_XFEROPCODE);
+ // *** Self destruct maybe??
+ break;
+ }
+ return TRUE;
+}
+
+void tftp::SetOpcode(WORD op)
+{
+ opcode = REVERSEBYTES(op);
+}
+void tftp::tftpDATA::SetBlock(WORD b)
+{
+ block=REVERSEBYTES(b);
+}
+WORD tftp::tftpDATA::Block()
+{
+ return REVERSEBYTES(block);
+}
+WORD tftp::tftpACK::Block()
+{
+ return REVERSEBYTES(block);
+}
+void tftp::tftpACK::SetBlock(WORD b)
+{
+ block = REVERSEBYTES(b);
+}
+WORD tftp::tftpERROR::Code()
+{
+ return REVERSEBYTES(code);
+}
+void tftp::tftpERROR::SetCode(WORD c)
+{
+ code = REVERSEBYTES(c);
+}
+
+
+CString tftp::errMessage()
+{
+CString rv;
+ if(memchr(data.m_ERROR.data,0,length-(tftpHdrSize-tftpSlackSize)-sizeof(data.m_ERROR.code)))
+ rv = (LPCTSTR)data.m_ERROR.data;
+ return rv;
+}
+
+void CXferSocket::Destroy(BOOL success)
+{
+ if(m_wndResolver){
+ delete m_wndResolver;
+ m_wndResolver=NULL;
+ }
+ SetTry();
+ m_Daddy->m_bnw.StartSound(
+ success
+ ? m_Daddy->m_bnwSuccess
+ : m_Daddy->m_bnwAbort
+ );
+ if(m_File.m_hFile!=CFile::hFileNull){
+ TRY{
+ m_File.Close();
+ }CATCH(CFileException,e){
+ TRACE0("Error closing file\n");
+ }END_CATCH
+ }
+ ASSERT(m_Daddy);
+ m_Daddy->KillTimer(m_hSocket);
+ m_Daddy->m_Xfers.RemoveKey(m_hSocket);
+LV_FINDINFO lvf;
+ memset(&lvf,0,sizeof(lvf));
+ lvf.flags=LVFI_PARAM;
+ lvf.lParam=(LPARAM)this;
+int i = m_Daddy->m_List.FindItem(&lvf);
+ if(i>=0)
+ m_Daddy->m_List.DeleteItem(i);
+ delete this;
+}
+
+void CPumpKINDlg::LogLine(LPCTSTR str)
+{
+ ASSERT(m_LogLength);
+ while(m_Log.GetCount()>m_LogLength && m_Log.GetCount()!=LB_ERR){
+ CTime *t = (CTime*)m_Log.GetItemData(0);
+ if(((DWORD)t)!=LB_ERR){
+ ASSERT(t);
+ m_LogTimes.RemoveKey(t);
+ delete t;
+ }
+ m_Log.DeleteString(0);
+ }
+int i = m_Log.AddString(str);
+ ASSERT(i!=LB_ERR);
+CTime *t = new CTime(CTime::GetCurrentTime());
+ m_Log.SetItemData(i,(DWORD)(m_LogTimes[t]=t));
+ m_Log.SetCurSel(i);
+}
+
+void CPumpKINDlg::LogLine(UINT msgID)
+{
+CString tmp;
+ tmp.Format(msgID);
+ LogLine(tmp);
+}
+
+void CXferSocket::TurnSlashes(CString& fn,BOOL bBack)
+{
+int s = fn.Find(bBack?'/':'\\');
+ while(s>=0){
+ fn.SetAt(s,bBack?'\\':'/');
+ s = fn.Find(bBack?'/':'\\');
+ }
+}
+
+CString CXferSocket::ApplyRoot(LPCTSTR fileName)
+{
+ ASSERT(m_Daddy);
+CString fn = fileName;
+CString rv = m_Daddy->m_TFTPRoot;
+ if(rv.IsEmpty())
+ rv = ".";
+ if(rv[rv.GetLength()-1]!='\\')
+ rv+="\\";
+ while((!fn.IsEmpty()) && fn[0]=='\\')
+ fn=fn.Mid(1);
+ rv+=fn;
+ return rv;
+}
+
+void CPumpKINDlg::OnOptions()
+{
+CPropertySheet cps(IDS_TITLE_OPTIONS,this);
+CPropsServer server;
+CPropsNetwork network;
+CPropsSounds sounds;
+
+ server.m_RRQMode=m_RRQMode;
+ server.m_TFTPRoot=m_TFTPRoot;
+ server.m_TFTPSubdirs=m_bTFTPSubdirs;
+ server.m_WRQMode=m_WRQMode;
+ server.m_PromptTimeOut=m_PromptTimeOut;
+
+ network.m_ListenPort=m_ListenPort;
+ network.m_SpeakPort=m_SpeakPort;
+ network.m_TimeOut=m_TFTPTimeOut.GetTotalSeconds();
+ network.m_BlockSize=m_BlockSize;
+
+ sounds.m_Request = m_bnwRequest;
+ sounds.m_Success = m_bnwSuccess;
+ sounds.m_Abort = m_bnwAbort;
+
+ cps.AddPage(&server);
+ cps.AddPage(&network);
+ cps.AddPage(&sounds);
+ if(cps.DoModal()==IDOK){
+ m_RRQMode=server.m_RRQMode;
+ m_TFTPRoot=server.m_TFTPRoot;
+ m_bTFTPSubdirs=server.m_TFTPSubdirs;
+ m_WRQMode=server.m_WRQMode;
+ m_PromptTimeOut=server.m_PromptTimeOut;
+
+ m_ListenPort=network.m_ListenPort;
+ m_SpeakPort=network.m_SpeakPort;
+ m_TFTPTimeOut=CTimeSpan(network.m_TimeOut);
+ m_BlockSize=network.m_BlockSize;
+
+ m_bnwRequest = sounds.m_Request;
+ m_bnwSuccess = sounds.m_Success;
+ m_bnwAbort = sounds.m_Abort;
+ }
+}
+
+BOOL CRRQSocket::ConfirmRequest()
+{
+CConfirmRRQDlg cd(NULL);
+ cd.m_Daddy=this;
+ cd.m_File=m_FileName;
+ cd.m_Host=inet_ntoa(m_Peer.sin_addr);
+ if(cd.DoModal()==IDOK)
+ return TRUE;
+ return FALSE;
+}
+
+CWRQSocket::CWRQSocket(CPumpKINDlg* daddy,LPCTSTR fileName,LPCTSTR type,SOCKADDR_IN *sin)
+ : CXferSocket(daddy,fileName,type,sin)
+{
+ state=stateNone;
+ m_ACK=0;
+ m_LastSlack=0;
+ m_bResume=FALSE;
+}
+
+BOOL CWRQSocket::Create(LPCTSTR localFile,LPCTSTR hostName)
+{
+ if(!CAsyncSocket::Create(0,SOCK_DGRAM))
+ return FALSE;
+ ASSERT(m_Daddy);
+ ASSERT(m_Peer.sin_addr.s_addr!=INADDR_NONE || hostName);
+ m_Daddy->m_Xfers[m_hSocket]=this;
+ TurnSlashes(m_FileName,TRUE);
+ UpdateList();
+CString fn = localFile?ApplyRootGently(localFile):ApplyRoot(m_FileName);
+ if(!localFile){ // This is an incoming request..
+ if(CheckBadRelativeness(m_FileName)){
+ Deny(tftp::errAccessViolation,IDS_TFTP_ERROR_ACCESS);
+ return TRUE;
+ }
+ BOOL exists;
+ if(!_access((LPCTSTR)fn,0))
+ m_Rename=exists=TRUE;
+ else
+ m_Rename=exists=FALSE;
+ // *** m_WRQMode only if server transfer
+ switch(m_Daddy->m_WRQMode){
+ case CPumpKINDlg::wrqTakeAll:
+ if(exists){
+ if(!RenameFile(fn)){
+ Deny(tftp::errDiskFull,IDS_TFTP_ERROR_FAILEDTORENAME);
+ return TRUE;
+ }
+ }
+ break;
+ case CPumpKINDlg::wrqConfirmIfExists:
+ if(!exists)
+ break;
+ case CPumpKINDlg::wrqAlwaysConfirm:
+ if(exists)
+ m_bResume=TRUE;
+ if(ConfirmRequest()){
+ if(m_Rename){
+ RenameFile(fn);
+ if(SaveAs(fn))
+ break;
+ }else
+ break;
+ }
+ case CPumpKINDlg::wrqDenyAll:
+ Deny(tftp::errAccessViolation,IDS_TFTP_ERROR_ACCESS);
+ return TRUE;
+ }
+ }
+CFileException e;
+ if(!m_File.Open(
+ fn,
+ m_bResume
+ ?(CFile::modeWrite|CFile::shareDenyWrite)
+ :(CFile::modeCreate|CFile::modeWrite|CFile::shareDenyWrite),
+ &e
+ )){
+ if(localFile){ // Outgoing request
+ CString tmp;
+ tmp.Format(IDS_LOG_FAILEDTOOPEN,fn);
+ m_Daddy->LogLine(tmp);
+ return FALSE;
+ }else{
+ Deny(&e);
+ return TRUE;
+ }
+ }
+ if(hostName){
+ m_HostName=hostName;
+
+ CString tmp;
+ tmp.Format(IDS_LOG_REQUESTING,m_FileName,m_HostName);
+ m_Daddy->LogLine(tmp);
+
+ CString inAddr = hostName;
+ int at = inAddr.Find('@');
+ if(at>=0)
+ inAddr=inAddr.Mid(at+1);
+ if((m_Peer.sin_addr.s_addr=inet_addr((LPCTSTR)inAddr))==INADDR_NONE){
+ ASSERT(!m_wndResolver);
+ m_wndResolver = new CResolver(this);
+ ASSERT(m_wndResolver);
+ return m_wndResolver->Resolve();
+ }else{
+ OnHostKnown();
+ return TRUE;
+ }
+ }
+CString v;
+tftp::tftpOptions oack;
+ if(m_Options.Lookup(tftpoTSize,v)){
+ m_xferSize=atol(v);
+ if(!m_xferSize){
+ Deny(tftp::errOption,IDS_TFTP_ERROR_TSIZE);
+ return TRUE;
+ }
+ }
+ if(m_Options.Lookup(tftpoBSize,v)){
+ m_blkSize=atoi(v);
+ if(!m_blkSize){ // *** Do more about sanity check
+ Deny(tftp::errOption,IDS_TFTP_ERROR_BSIZE);
+ return TRUE;
+ }
+ v.Format("%u",m_blkSize);
+ oack[tftpoBSize]=v;
+ }
+ if(m_Options.Lookup(tftpoTOut,v)){
+ m_timeOut=atoi(v);
+ if(!m_timeOut){ // *** Do more about sanity check
+ Deny(tftp::errOption,IDS_TFTP_ERROR_TOUT);
+ return TRUE;
+ }
+ v.Format("%u",m_timeOut);
+ oack[tftpoTOut]=v;
+ }
+ if(m_Options.Lookup(tftpoXResume,v) && m_bResume){
+ m_ACK=m_File.GetLength()/m_blkSize;
+ v.Format("%u",m_ACK);
+ oack[tftpoXResume]=v;
+ }else
+ m_ACK=0;
+ state=stateXfer;
+ if(oack.GetCount()){
+ tftp *p = tftp::Allocate(tftp::tftpOACK::tftpSize(&oack));
+ ASSERT(p);
+ p->SetOpcode(tftp::opOACK);
+ p->data.m_OACK.Set(&oack);
+ PostTFTP(p,TRUE);
+ }else
+ DoXfer();
+ return TRUE;
+}
+
+BOOL CWRQSocket::ConfirmRequest()
+{
+CConfirmWRQDlg cd(NULL);
+ cd.m_Daddy=this;
+ cd.m_File=m_FileName;
+ cd.m_Host=inet_ntoa(m_Peer.sin_addr);
+ switch(cd.DoModal()){
+ case IDOK:
+ m_Rename=FALSE;
+ m_bResume=FALSE;
+ return TRUE;
+ case IDC_RENAME:
+ m_bResume=FALSE;
+ m_Rename=TRUE;
+ return TRUE;
+ case IDC_RESUME:
+ m_Rename=FALSE;
+ m_bResume=TRUE;
+ return TRUE;
+ case IDCANCEL:
+ return FALSE;
+ }
+ return FALSE;
+}
+
+BOOL CWRQSocket::RenameFile(CString& fn)
+{
+CString renamed = fn;
+ if(fn.IsEmpty())
+ return FALSE;
+ if(fn[fn.GetLength()-1]==')'){
+ int op = fn.ReverseFind('(');
+ if(op>0 && fn[op-1]==' '){
+ if(fn.Mid(op+1,fn.GetLength()-op-2).SpanExcluding("0123456789").IsEmpty())
+ renamed = renamed.Left(op-1);
+ }
+ }
+CString testFN;
+ for(UINT tmp=0;tmp<32768;tmp++){
+ testFN.Format("%s (%u)",(LPCTSTR)renamed,tmp);
+ if(!_access((LPCTSTR)testFN,0))
+ continue;
+ fn=testFN;
+ return TRUE;
+ }
+ return FALSE;
+}
+
+BOOL CWRQSocket::SaveAs(CString& fn)
+{
+CFileDialog cfd(FALSE,NULL,fn,OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_PATHMUSTEXIST,NULL,m_Daddy);
+CString title;
+ title.LoadString(IDS_RENAME_TITLE);
+ cfd.m_ofn.lpstrTitle=(LPCTSTR)title;
+ if(cfd.DoModal()!=IDOK)
+ return FALSE;
+ fn = cfd.GetPathName();
+ return TRUE;
+}
+
+void CWRQSocket::DoXfer()
+{
+tftp *p = tftp::Allocate(tftp::tftpACK::tftpSize());
+ ASSERT(p);
+ p->SetOpcode(tftp::opACK);
+ p->data.m_ACK.SetBlock(m_ACK);
+ TRACE1("WRQ-ACK-%u\n",m_ACK);
+ PostTFTP(p,TRUE); // *** ??? Hope this is right
+}
+
+UINT tftp::tftpACK::tftpSize()
+{
+ return tftpHdrSize-tftpSlackSize+sizeof(tftp::tftpACK);
+}
+
+ULONG CWRQSocket::GetACK()
+{
+ return (m_ACK*m_blkSize)-m_LastSlack;
+}
+
+void CXferSocket::ResetTimeout()
+{
+ ASSERT(m_Daddy);
+ m_Daddy->m_Retrier->KillTimer(m_hSocket);
+ if(m_Retry)
+ m_Daddy->m_Retrier->SetTimer(m_hSocket,min(60,m_Daddy->m_RetryTimeOut.GetTotalSeconds())*1000,NULL);
+ if(!m_bRetry){
+ m_Daddy->KillTimer(m_hSocket);
+ m_Daddy->SetTimer(m_hSocket,min(60,m_timeOut)*1000,NULL);
+ }
+}
+
+void CXferSocket::Abort()
+{
+ ASSERT(m_Daddy);
+CString tmp;
+ tmp.Format(IDS_LOG_XFERABORTED,(LPCTSTR)m_FileName);
+ m_Daddy->LogLine(tmp);
+ Destroy(FALSE);
+}
+
+void CPumpKINDlg::OnTimer(UINT nIDEvent)
+{
+CXferSocket *socket;
+ if(m_Xfers.Lookup(nIDEvent,socket)){
+ CString tmp;
+ tmp.Format(IDS_LOG_TIMEDOUT,socket->m_FileName);
+ LogLine(tmp);
+ socket->Abort();
+ }else{
+ TRACE0("Failed to find timed out socket!\n");
+ }
+ CDialog::OnTimer(nIDEvent);
+}
+
+void CPumpKINDlg::OnExit()
+{
+ if(!m_Xfers.IsEmpty()){
+ CString title,text;
+ title.LoadString(IDS_CONFIRMEXIT_TITLE);
+ text.LoadString(IDS_CONFIRMEXIT_TEXT);
+ if(MessageBox(text,title,MB_ICONQUESTION|MB_YESNO)!=IDYES)
+ return;
+ }
+ m_bExiting=TRUE;
+ EndDialog(IDOK);
+}
+
+void CPumpKINDlg::OnPut()
+{
+CRequestDlg crd(NULL);
+ crd.m_Put=TRUE;
+ crd.m_BSize=m_BlockSize;
+ if(crd.DoModal()==IDOK){
+ CRRQSocket *socket = new CRRQSocket(this,crd.m_RemoteFile,crd.m_Type,NULL);
+ if(crd.m_BSize)
+ socket->m__blkSize=crd.m_BSize;
+ if(!socket->Create(crd.m_LocalFile,crd.m_Host))
+ socket->Destroy();
+ }
+}
+
+void CPumpKINDlg::OnGet()
+{
+CRequestDlg crd(NULL);
+ crd.m_Put=FALSE;
+ crd.m_BSize=m_BlockSize;
+ if(crd.DoModal()==IDOK){
+ CWRQSocket *socket = new CWRQSocket(this,crd.m_RemoteFile,crd.m_Type,NULL);
+ if(crd.m_BSize)
+ socket->m__blkSize=crd.m_BSize;
+ if(!socket->Create(crd.m_LocalFile,crd.m_Host))
+ socket->Destroy();
+ }
+}
+
+void CPumpKINDlg::SetupButtons()
+{
+ m_AbortCtl.EnableWindow(m_List.GetSelectedCount()>0);
+}
+
+void CPumpKINDlg::OnDeleteallitemsConnections(NMHDR* pNMHDR, LRESULT* pResult)
+{
+ NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
+ SetupButtons();
+ *pResult = 0;
+}
+
+void CPumpKINDlg::OnDeleteitemConnections(NMHDR* pNMHDR, LRESULT* pResult)
+{
+ NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
+ SetupButtons();
+ *pResult = 0;
+}
+
+void CPumpKINDlg::OnInsertitemConnections(NMHDR* pNMHDR, LRESULT* pResult)
+{
+ NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
+ SetupButtons();
+ *pResult = 0;
+}
+
+void CPumpKINDlg::OnItemchangedConnections(NMHDR* pNMHDR, LRESULT* pResult)
+{
+ NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
+ SetupButtons();
+ *pResult = 0;
+}
+
+void CPumpKINDlg::OnAbort()
+{
+ if(!m_List.GetSelectedCount())
+ return;
+int items = m_List.GetItemCount();
+ for(int tmp=0;tmp<items;tmp++){
+ if(!(m_List.GetItemState(tmp,LVIS_SELECTED)&LVIS_SELECTED))
+ continue;
+ CXferSocket *xfer = (CXferSocket*) m_List.GetItemData(tmp);
+ ASSERT(xfer);
+ xfer->Abort();
+ }
+}
+
+void CXferSocket::OnFailedToResolve()
+{
+ TRACE0("Resolve failed\n");
+ delete m_wndResolver;
+ m_wndResolver=NULL;
+ ASSERT(m_Daddy);
+CString tmp;
+ tmp.Format(IDS_LOG_RESOLVEFAILED,m_HostName);
+ m_Daddy->LogLine(tmp);
+ Abort();
+}
+
+void CXferSocket::OnResolved()
+{
+ delete m_wndResolver;
+ m_wndResolver=NULL;
+ TRACE0("Resolved\n");
+ m_Peer.sin_addr.s_addr = *(DWORD*)(((hostent*)m_ResolveBuff)->h_addr);
+}
+
+void CRRQSocket::OnResolved()
+{
+ CXferSocket::OnResolved();
+ OnHostKnown();
+}
+
+void CRRQSocket::OnHostKnown()
+{
+ ASSERT(m_Daddy);
+ m_Peer.sin_port=htons(m_Daddy->m_SpeakPort);
+tftp::tftpOptions o;
+CString v;
+ ASSERT(m_xferSize>=0);
+ v.Format("%lu",m_xferSize);
+ o[tftpoTSize] = v;
+ ASSERT(m__blkSize);
+ v.Format("%u",m__blkSize);
+ o[tftpoBSize] = v;
+ ASSERT(m__timeOut);
+ v.Format("%u",m__timeOut);
+ o[tftpoTOut] = v;
+ o[tftpoXResume] = "0";
+tftp *p = tftp::Allocate(tftp::tftpWRQ::tftpSize(m_FileName,m_Type,&o));
+ ASSERT(p);
+ p->SetOpcode(tftp::opWRQ);
+ p->data.m_WRQ.Set(m_FileName,m_Type,&o);
+ PostTFTP(p,TRUE);
+ state=stateInit;
+ UpdateList();
+}
+
+UINT tftp::tftpRQ::tftpSize(LPCTSTR file,LPCTSTR type,tftp::tftpOptions* ops)
+{
+UINT rv = tftpHdrSize-tftpSlackSize+strlen(file)+1+strlen(type)+1;
+ if(ops){
+ tftpOptions& o = *ops;
+ POSITION p = o.GetStartPosition();
+ while(p){
+ CString n,v;
+ o.GetNextAssoc(p,n,v);
+ rv+=n.GetLength()+1+v.GetLength()+1;
+ }
+ }
+ return rv;
+}
+UINT tftp::tftpRRQ::tftpSize(LPCTSTR file,LPCTSTR type,tftp::tftpOptions* ops)
+{
+ return tftp::tftpRQ::tftpSize(file,type,ops);
+}
+UINT tftp::tftpWRQ::tftpSize(LPCTSTR file,LPCTSTR type,tftp::tftpOptions* ops)
+{
+ return tftp::tftpRQ::tftpSize(file,type,ops);
+}
+UINT tftp::tftpOACK::tftpSize(tftp::tftpOptions* ops)
+{
+UINT rv = tftpHdrSize-tftpSlackSize;
+ if(ops){
+ tftpOptions& o = *ops;
+ POSITION p = o.GetStartPosition();
+ while(p){
+ CString n,v;
+ o.GetNextAssoc(p,n,v);
+ rv+=n.GetLength()+1+v.GetLength()+1;
+ }
+ }
+ return rv;
+}
+void tftp::tftpRQ::Set(LPCTSTR file,LPCTSTR type,tftp::tftpOptions* ops)
+{
+ // MAY BE DANGEROUS!
+UINT ptr = 0;
+ strcpy((LPTSTR)&data[ptr],file); ptr+=strlen(file)+1;
+ strcpy((LPTSTR)&data[ptr],type); ptr+=strlen(type)+1;
+ if(ops){
+ tftpOptions& o = *ops;
+ POSITION p = o.GetStartPosition();
+ while(p){
+ CString n,v;
+ o.GetNextAssoc(p,n,v);
+ strcpy((LPTSTR)&data[ptr],(LPCTSTR)n); ptr+=n.GetLength()+1;
+ strcpy((LPTSTR)&data[ptr],(LPCTSTR)v); ptr+=v.GetLength()+1;
+ }
+ }
+}
+void tftp::tftpRRQ::Set(LPCTSTR file,LPCTSTR type,tftp::tftpOptions* ops)
+{
+ // MAY BE DANGEROUS!
+UINT ptr = 0;
+ strcpy((LPTSTR)&data[ptr],file); ptr+=strlen(file)+1;
+ strcpy((LPTSTR)&data[ptr],type); ptr+=strlen(type)+1;
+ if(ops){
+ tftpOptions& o = *ops;
+ POSITION p = o.GetStartPosition();
+ while(p){
+ CString n,v;
+ o.GetNextAssoc(p,n,v);
+ strcpy((LPTSTR)&data[ptr],(LPCTSTR)n); ptr+=n.GetLength()+1;
+ strcpy((LPTSTR)&data[ptr],(LPCTSTR)v); ptr+=v.GetLength()+1;
+ }
+ }
+}
+void tftp::tftpWRQ::Set(LPCTSTR file,LPCTSTR type,tftp::tftpOptions* ops)
+{
+ // MAY BE DANGEROUS!
+UINT ptr = 0;
+ strcpy((LPTSTR)&data[ptr],file); ptr+=strlen(file)+1;
+ strcpy((LPTSTR)&data[ptr],type); ptr+=strlen(type)+1;
+ if(ops){
+ tftpOptions& o = *ops;
+ POSITION p = o.GetStartPosition();
+ while(p){
+ CString n,v;
+ o.GetNextAssoc(p,n,v);
+ strcpy((LPTSTR)&data[ptr],(LPCTSTR)n); ptr+=n.GetLength()+1;
+ strcpy((LPTSTR)&data[ptr],(LPCTSTR)v); ptr+=v.GetLength()+1;
+ }
+ }
+}
+void tftp::tftpOACK::Set(tftpOptions* ops)
+{
+ ASSERT(ops);
+UINT ptr = 0;
+tftpOptions& o = *ops;
+POSITION p = o.GetStartPosition();
+ while(p){
+ CString n,v;
+ o.GetNextAssoc(p,n,v);
+ strcpy((LPTSTR)&data[ptr],(LPCTSTR)n); ptr+=n.GetLength()+1;
+ strcpy((LPTSTR)&data[ptr],(LPCTSTR)v); ptr+=v.GetLength()+1;
+ }
+}
+
+void CWRQSocket::OnResolved()
+{
+ CXferSocket::OnResolved();
+ OnHostKnown();
+}
+
+void CWRQSocket::OnHostKnown()
+{
+ ASSERT(m_Daddy);
+ m_Peer.sin_port=htons(m_Daddy->m_SpeakPort);
+tftp::tftpOptions o;
+CString v;
+ o[tftpoTSize]="0";
+ if(m__blkSize){
+ v.Format("%u",m__blkSize);
+ o[tftpoBSize]=v;
+ }
+ if(m__timeOut){
+ v.Format("%u",m__timeOut);
+ o[tftpoTOut]=v;
+ }
+tftp *p = tftp::Allocate(tftp::tftpRRQ::tftpSize(m_FileName,m_Type,&o));
+ ASSERT(p);
+ p->SetOpcode(tftp::opRRQ);
+ p->data.m_RRQ.Set(m_FileName,m_Type,&o);
+ PostTFTP(p,TRUE);
+ state=stateInit;
+ UpdateList();
+}
+
+void CPumpKINDlg::OnClose()
+{
+ OnTrayShowpumpkinwindow();
+}
+
+void CPumpKINDlg::OnTrayShowpumpkinwindow()
+{
+ if(IsWindowVisible()){
+ m_bShown=FALSE;
+ ShowWindow(SW_HIDE);
+ }else{
+ m_bShown=TRUE;
+ ShowWindow(SW_SHOW);
+ SetForegroundWindow();
+ SetFocus();
+ }
+}
+
+void CPumpKINDlg::OnTrayExit()
+{
+ OnExit();
+}
+
+void CPumpKINDlg::OnTrayAboutpumpkin()
+{
+CAboutDlg dlgAbout;
+ dlgAbout.DoModal();
+}
+
+void CPumpKINDlg::OnTrayFetchfile()
+{
+ OnGet();
+}
+
+void CPumpKINDlg::OnTrayHelp()
+{
+ OnHelp();
+}
+
+void CPumpKINDlg::OnTrayOptions()
+{
+ OnOptions();
+}
+
+void CPumpKINDlg::OnTraySendfile()
+{
+ OnPut();
+}
+
+void CPumpKINDlg::LoadSettings()
+{
+CWinApp *app = AfxGetApp();
+ ASSERT(app);
+ m_bnwRequest=app->GetProfileString("BellsNWhistles","Request",m_bnwRequest);
+ m_bnwSuccess=app->GetProfileString("BellsNWhistles","Success",m_bnwSuccess);
+ m_bnwAbort=app->GetProfileString("BellsNWhistles","Abort",m_bnwAbort);
+ m_bTFTPSubdirs=app->GetProfileInt("TFTPSettings","Subdirs",m_bTFTPSubdirs);
+ m_ListenPort=app->GetProfileInt("TFTPSettings","ListenPort",m_ListenPort);
+ m_LogLength=app->GetProfileInt("UISettings","LogLength",m_LogLength);
+ m_PromptTimeOut=app->GetProfileInt("UISettings","PromptTimeout",m_PromptTimeOut);
+ m_RRQMode=app->GetProfileInt("TFTPSettings","RRQMode",m_RRQMode);
+ m_SpeakPort=app->GetProfileInt("TFTPSettings","SpeakPort",m_SpeakPort);
+ m_TFTPRoot=app->GetProfileString("TFTPSettings","TFTPRoot",m_TFTPRoot);
+ m_TFTPTimeOut=CTimeSpan(app->GetProfileInt("TFTPSettings","TFTPTimeout",m_TFTPTimeOut.GetTotalSeconds()));
+ m_BlockSize=app->GetProfileInt("TFTPSettings","TFTPBlockSize",m_BlockSize);
+ m_RetryTimeOut=CTimeSpan(app->GetProfileInt("TFTPSettings","RetryTimeout",m_RetryTimeOut.GetTotalSeconds()));
+ m_WRQMode=app->GetProfileInt("TFTPSettings","WRQMode",m_WRQMode);
+ m_bShown=app->GetProfileInt("UISettings","Visble",m_bShown);
+ if(m_TFTPRoot.IsEmpty()){
+ DWORD dL = ::GetCurrentDirectory(0,NULL);
+ VERIFY(::GetCurrentDirectory(dL,m_TFTPRoot.GetBuffer(dL)));
+ m_TFTPRoot.ReleaseBuffer();
+ }
+ ::SetCurrentDirectory(m_TFTPRoot);
+}
+
+void CPumpKINDlg::SaveSettings()
+{
+CWinApp *app = AfxGetApp();
+ ASSERT(app);
+ app->WriteProfileString("BellsNWhistles","Request",m_bnwRequest);
+ app->WriteProfileString("BellsNWhistles","Success",m_bnwSuccess);
+ app->WriteProfileString("BellsNWhistles","Abort",m_bnwAbort);
+ app->WriteProfileInt("TFTPSettings","Subdirs",m_bTFTPSubdirs);
+ app->WriteProfileInt("TFTPSettings","ListenPort",m_ListenPort);
+ app->WriteProfileInt("UISettings","LogLength",m_LogLength);
+ app->WriteProfileInt("UISettings","PromptTimeout",m_PromptTimeOut);
+ app->WriteProfileInt("TFTPSettings","RRQMode",m_RRQMode);
+ app->WriteProfileInt("TFTPSettings","SpeakPort",m_SpeakPort);
+ app->WriteProfileString("TFTPSettings","TFTPRoot",m_TFTPRoot);
+ app->WriteProfileInt("TFTPSettings","TFTPTimeout",m_TFTPTimeOut.GetTotalSeconds());
+ app->WriteProfileInt("TFTPSettings","TFTPBlockSize",m_BlockSize);
+ app->WriteProfileInt("TFTPSettings","RetryTimeout",m_RetryTimeOut.GetTotalSeconds());
+ app->WriteProfileInt("TFTPSettings","WRQMode",m_WRQMode);
+ app->WriteProfileInt("UISettings","Visble",m_bShown);
+}
+
+void CPumpKINDlg::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos)
+{
+ CDialog::OnWindowPosChanging(lpwndpos);
+ if(!m_bExiting){
+ if(m_bShown){
+ lpwndpos->flags&=~SWP_HIDEWINDOW;
+ lpwndpos->flags|=SWP_SHOWWINDOW;
+ }else{
+ lpwndpos->flags&=~SWP_SHOWWINDOW;
+ lpwndpos->flags|=SWP_HIDEWINDOW;
+ if(::GetForegroundWindow()==m_hWnd && (m_Trayer && !m_Trayer->m_inMenu))
+ GetDesktopWindow()->SetForegroundWindow();
+ }
+ }
+}
+
+CString CXferSocket::ApplyRootGently(LPCTSTR fn)
+{
+CString f = fn;
+CString rv = f;
+ if((!f.IsEmpty()) && f[0]!='\\' && f.Find(":")<0 && f.Find("\\")<0)
+ rv = ApplyRoot(f);
+ return rv;
+}
+
+BOOL CXferSocket::CheckBadRelativeness(LPCTSTR file)
+{
+CString tmp = file;
+ if(tmp.IsEmpty())
+ return FALSE;
+ if(tmp.Find("..")>=0)
+ return TRUE;
+ if(tmp.Find(":")>=0)
+ return TRUE;
+ if((!m_Daddy->m_bTFTPSubdirs) && m_FileName.Find('\\')>=0)
+ return TRUE;
+ return FALSE;
+}
+
+void CAboutDlg::OnKlevernet()
+{
+CString url;
+ url.LoadString(IDS_KLEVERNET_URL);
+ ShellExecute(::GetDesktopWindow(),"open",url,NULL,NULL,SW_SHOWMAXIMIZED);
+}
+
+BOOL CPumpKINDlg::PreTranslateMessage(MSG* pMsg)
+{
+ // CG: The following block was added by the ToolTips component.
+ {
+ // Let the ToolTip process this message.
+ m_tooltip.RelayEvent(pMsg);
+
+ return CDialog::PreTranslateMessage(pMsg);
+ }
+}
+
+void CPumpKINDlg::OnSelchangeLog()
+{
+int sel = m_Log.GetCurSel();
+ if(sel==LB_ERR){
+ TRACE0("Error retrieving selection\n");
+ }else{
+ CTime *t = (CTime*)m_Log.GetItemData(sel);
+ ASSERT(t);
+ m_tooltip.UpdateTipText(t->Format(IDS_LOGTIMEFORMAT),&m_Log);
+ }
+}
+
+void CPumpKINDlg::OnTrayOpenfilesfolder()
+{
+ ShellExecute(::GetDesktopWindow(),NULL,m_TFTPRoot,NULL,NULL,SW_SHOWDEFAULT);
+}
+
+void CPumpKINDlg::OnDropFiles(HDROP hDropInfo)
+{
+UINT files = ::DragQueryFile(hDropInfo,0xFFFFFFFF,NULL,0);
+ ASSERT(files);
+ for(UINT file=0;file<files;file++){
+ CString theFile;
+ UINT fileNameLength = ::DragQueryFile(hDropInfo,file,NULL,0);
+ ASSERT(fileNameLength);
+ VERIFY(::DragQueryFile(hDropInfo,file,theFile.GetBuffer(fileNameLength+5),fileNameLength+4)<=fileNameLength);
+ theFile.ReleaseBuffer();
+ // Send it over!
+ CRequestDlg crd(NULL);
+ crd.m_Drop=TRUE;
+ crd.m_Put=TRUE;
+ crd.m_BSize=m_BlockSize;
+ crd.m_LocalFile=theFile;
+ if(crd.DoModal()==IDOK){
+ CRRQSocket *socket = new CRRQSocket(this,crd.m_RemoteFile,crd.m_Type,NULL);
+ if(crd.m_BSize)
+ socket->m__blkSize=crd.m_BSize;
+ if(!socket->Create(crd.m_LocalFile,crd.m_Host))
+ socket->Destroy();
+ }
+ }
+ ::DragFinish(hDropInfo);
+}
+
+void CPumpKINDlg::OnCancel()
+{
+ OnClose();
+}
+
+CPumpKINDlg::~CPumpKINDlg()
+{
+ delete m_Trayer;
+ delete m_Retrier;
+}
+
+void CXferSocket::OnRetry()
+{
+ if(!m_Retry){
+ TRACE("Retrying unretriable..\n");
+ return;
+ }
+ TRACE0("Retrying..\n");
+ m_bRetry=TRUE;
+ PostTFTP(tftp::Copy(m_Retry));
+ m_bRetry=FALSE;
+}
+
+tftp* tftp::Copy(tftp *src)
+{
+ ASSERT(src);
+ ASSERT(src->length);
+tftp* rv = Allocate(src->length);
+ ASSERT(rv);
+ memmove(rv,src,tftpSlackSize+src->length);
+ return rv;
+}
+
+void CXferSocket::SetTry(tftp *p)
+{
+ if(m_Retry)
+ delete m_Retry;
+ m_Retry=p?tftp::Copy(p):NULL;
+}
+
+void CPumpKINDlg::OnHelp()
+{
+ AfxGetApp()->WinHelp(0,HELP_FINDER);
+}
diff --git a/PumpKINDlg.h b/PumpKINDlg.h
new file mode 100644
index 0000000..42ae62d
--- a/dev/null
+++ b/PumpKINDlg.h
@@ -0,0 +1,327 @@
+// PumpKINDlg.h : header file
+//
+
+//#define REVERSEBYTES(w) MAKEWORD(HIBYTE(w),LOBYTE(w));
+#define REVERSEBYTES(w) (htons((WORD)w))
+#define tftpoBSize "blksize"
+#define tftpoTSize "tsize"
+#define tftpoTOut "timeout"
+
+#define tftpoXResume "x-resume"
+
+struct tftp {
+ typedef CMapStringToString tftpOptions;
+ typedef WORD tftpLength;
+ typedef WORD tftpOpcode;
+ tftpLength length;
+ tftpOpcode opcode;
+ enum {
+ opRRQ = 1,
+ opWRQ = 2,
+ opDATA = 3,
+ opACK = 4,
+ opERROR = 5,
+ opOACK = 6,
+
+ errUndefined = 0,
+ errNotFound = 1,
+ errAccessViolation = 2,
+ errDiskFull = 3,
+ errIllegalOp = 4,
+ errUnknownTID = 5,
+ errFileExists = 6,
+ errNoUser = 7,
+ errOption = 8
+ };
+ struct tftpUNKNOWN {
+ BYTE data[1];
+ };
+ struct tftpRQ {
+ BYTE data[1];
+public:
+ void Set(LPCTSTR file,LPCTSTR type,tftpOptions* ops=NULL);
+ static UINT tftpSize(LPCTSTR file,LPCTSTR type,tftpOptions* ops=NULL);
+ };
+ struct tftpRRQ {
+ BYTE data[1];
+public:
+ void Set(LPCTSTR file,LPCTSTR type,tftpOptions* ops=NULL);
+ static UINT tftpSize(LPCTSTR file,LPCTSTR type,tftpOptions* ops=NULL);
+ };
+ struct tftpWRQ {
+ BYTE data[1];
+public:
+ void Set(LPCTSTR file,LPCTSTR type,tftpOptions* ops=NULL);
+ static UINT tftpSize(LPCTSTR file,LPCTSTR type,tftpOptions* ops=NULL);
+ };
+ struct tftpDATA {
+ WORD block;
+ BYTE data[1];
+ public:
+ WORD Block();
+ void SetBlock(WORD b);
+ static UINT tftpSize(UINT blkSize=512);
+ };
+ struct tftpACK {
+ WORD block;
+ public:
+ static UINT tftpSize();
+ void SetBlock(WORD b);
+ WORD Block();
+ };
+ struct tftpERROR {
+ typedef WORD tftpErrorCode;
+ tftpErrorCode code;
+ BYTE data[1];
+ public:
+ void SetCode(WORD c);
+ WORD Code();
+ static UINT tftpSize(LPCTSTR msg);
+ };
+ struct tftpOACK {
+ BYTE data[1];
+ public:
+ void Set(tftpOptions* ops);
+ static UINT tftpSize(tftpOptions* ops);
+ };
+ union tftpPacket {
+ tftpUNKNOWN m_UNKNOWN;
+ tftpRQ m_RQ;
+ tftpRRQ m_RRQ;
+ tftpWRQ m_WRQ;
+ tftpDATA m_DATA;
+ tftpACK m_ACK;
+ tftpERROR m_ERROR;
+ tftpOACK m_OACK;
+ } data;
+
+ void *udpBase(void) { return &opcode; }
+public:
+ static tftp* Copy(tftp *src);
+ CString errMessage();
+ void SetOpcode(WORD op);
+ void errSet(UINT code,LPCTSTR msg);
+ static tftp* Allocate(UINT tftpSize=0);
+ BOOL Send(CAsyncSocket *socket,SOCKADDR_IN* saddr);
+ CString rqType();
+ CString rqFileName();
+ UINT GetOptions(tftpOptions* ops);
+ tftp();
+ UINT Opcode();
+ BOOL Receive(CAsyncSocket* socket,UINT maxLength,SOCKADDR_IN *sin=NULL);
+};
+#define tftpHdrSize (sizeof(tftp)-sizeof(tftp::tftpPacket))
+#define tftpSlackSize sizeof(tftp::tftpLength)
+
+class CPumpKINDlg;
+class CListenSocket : public CAsyncSocket {
+public:
+ virtual void OnReceive(int nErrorCode);
+ CPumpKINDlg* m_Daddy;
+};
+
+typedef CList<tftp*,tftp*> CTFTPList;
+class CResolver;
+class CXferSocket : public CAsyncSocket {
+public:
+ UINT m__timeOut;
+ UINT m__blkSize;
+ tftp::tftpOptions m_Options;
+ LONG m_xferSize;
+ UINT m_timeOut;
+ UINT m_blkSize;
+ BOOL m_bRetry;
+ void SetTry(tftp *p=NULL);
+ tftp* m_Retry;
+ void OnRetry();
+ BOOL CheckBadRelativeness(LPCTSTR file);
+ CString ApplyRootGently(LPCTSTR fn);
+ CString m_HostName;
+ virtual void OnResolved();
+ virtual void OnFailedToResolve();
+ CResolver *m_wndResolver;
+ BYTE m_ResolveBuff[MAXGETHOSTSTRUCT];
+ virtual void Abort();
+ void ResetTimeout();
+ enum {
+ stateNone, stateDeny, stateInit, stateOACK, stateXfer, stateFinish, stateClosing
+ };
+ int state;
+ void Deny(UINT errCode,UINT errID);
+ void Deny(CFileException* e);
+ CString ApplyRoot(LPCTSTR fileName);
+ void TurnSlashes(CString& fn,BOOL bBack=TRUE);
+ virtual void Destroy(BOOL success=TRUE);
+ void PostError(CFileException* e);
+ void PostError(UINT errCode,UINT errID);
+ void PostTFTP(tftp* p,BOOL retryable=FALSE);
+ CXferSocket(CPumpKINDlg *daddy,LPCTSTR fileName,LPCTSTR type,SOCKADDR_IN* sin);
+ CFile m_File;
+ virtual ULONG GetACK();
+ CString m_Type;
+ CString m_FileName;
+ CXferSocket();
+ void UpdateList();
+ void SetPeer(SOCKADDR_IN *sin);
+ virtual BOOL OnTFTP(tftp* p) = 0;
+ virtual void OnReceive(int nErrorCode);
+ void DoSelect();
+ SOCKADDR_IN m_Peer;
+ virtual void OnSend(int nErrorCode);
+ CPumpKINDlg* m_Daddy;
+ CTFTPList m_Queue;
+
+ DECLARE_DYNAMIC(CXferSocket)
+};
+class CWRQSocket : public CXferSocket {
+public:
+ BOOL m_bResume;
+ void OnHostKnown();
+ virtual void OnResolved();
+ UINT m_LastSlack;
+ ULONG GetACK();
+ void DoXfer();
+ UINT m_ACK;
+ BOOL SaveAs(CString& fn);
+ BOOL RenameFile(CString& fn);
+ BOOL m_Rename;
+ BOOL ConfirmRequest();
+ BOOL Create(LPCTSTR localFile=NULL,LPCTSTR hostName=NULL);
+ CWRQSocket(CPumpKINDlg* daddy,LPCTSTR fileName,LPCTSTR type,SOCKADDR_IN *sin);
+ BOOL OnTFTP(tftp* p);
+
+ DECLARE_DYNAMIC(CWRQSocket)
+};
+class CRRQSocket : public CXferSocket {
+public:
+ void OnHostKnown();
+ virtual void OnResolved();
+ BOOL ConfirmRequest();
+ WORD m_LastSlack;
+ UINT m_ACK;
+ BOOL OnTFTP(tftp* p);
+ ULONG GetACK(void);
+ void DoXfer();
+ CRRQSocket(CPumpKINDlg *daddy,LPCTSTR fileName,LPCTSTR type,SOCKADDR_IN *sin);
+ BOOL Create(LPCTSTR localFile=NULL,LPCTSTR hostName=NULL);
+
+ DECLARE_DYNAMIC(CRRQSocket)
+};
+
+typedef CMap<SOCKET,SOCKET,CXferSocket*,CXferSocket*> CTIDMap;
+typedef CMap<CTime*,CTime*,CTime*,CTime*> CTimeMap;
+
+/////////////////////////////////////////////////////////////////////////////
+// CPumpKINDlg dialog
+
+class CTrayer;
+class CRetrier;
+class CPumpKINDlg : public CDialog
+{
+// Construction
+public:
+ CString m_bnwRequest;
+ CString m_bnwSuccess;
+ CString m_bnwAbort;
+ CBellsNWhistles m_bnw;
+ CTrayer *m_Trayer;
+ CTimeSpan m_RetryTimeOut;
+ virtual ~CPumpKINDlg();
+ CRetrier* m_Retrier;
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
+ BOOL m_bShown;
+ BOOL m_bExiting;
+ void SaveSettings();
+ void LoadSettings();
+ void SetupButtons();
+ BITMAP m_bitmapBack;
+ CBitmap m_bmpBack;
+ UINT m_PromptTimeOut;
+ UINT m_SpeakPort;
+ void LogLine(UINT msgID);
+ CTimeMap m_LogTimes;
+ void LogLine(LPCTSTR str);
+ int m_LogLength;
+ enum {
+ subitemFile=0, subitemType, subitemPeer, subitemBytes, subitemTSize
+ };
+ int m_iWRQ;
+ int m_iRRQ;
+ CImageList m_Images;
+ CTIDMap m_Xfers;
+ CTimeSpan m_TFTPTimeOut;
+ enum {
+ rrqGiveAll=0,
+ rrqAlwaysConfirm,
+ rrqDenyAll
+ };
+ enum {
+ wrqTakeAll=0,
+ wrqConfirmIfExists,
+ wrqAlwaysConfirm,
+ wrqDenyAll
+ };
+ UINT m_RRQMode;
+ UINT m_WRQMode;
+ BOOL m_bTFTPSubdirs;
+ CString m_TFTPRoot;
+ UINT m_ListenPort;
+ UINT m_BlockSize;
+ CListenSocket m_Listener;
+ CPumpKINDlg(CWnd* pParent = NULL); // standard constructor
+
+// Dialog Data
+ //{{AFX_DATA(CPumpKINDlg)
+ enum { IDD = IDD_PUMPKIN_DIALOG };
+ CButton m_AbortCtl;
+ CButton m_OptionsCtl;
+ CListBox m_Log;
+ CListCtrl m_List;
+ //}}AFX_DATA
+
+ // ClassWizard generated virtual function overrides
+ //{{AFX_VIRTUAL(CPumpKINDlg)
+ protected:
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+ CToolTipCtrl m_tooltip;
+ HICON m_hIcon;
+
+ // Generated message map functions
+ //{{AFX_MSG(CPumpKINDlg)
+ virtual BOOL OnInitDialog();
+ afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
+ afx_msg void OnDestroy();
+ afx_msg void OnPaint();
+ afx_msg HCURSOR OnQueryDragIcon();
+ afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
+ afx_msg void OnOptions();
+ afx_msg void OnTimer(UINT nIDEvent);
+ afx_msg void OnExit();
+ afx_msg void OnPut();
+ afx_msg void OnGet();
+ afx_msg void OnDeleteallitemsConnections(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnDeleteitemConnections(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnInsertitemConnections(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnItemchangedConnections(NMHDR* pNMHDR, LRESULT* pResult);
+ afx_msg void OnAbort();
+ afx_msg void OnClose();
+ afx_msg void OnTrayShowpumpkinwindow();
+ afx_msg void OnTrayExit();
+ afx_msg void OnTrayAboutpumpkin();
+ afx_msg void OnTrayFetchfile();
+ afx_msg void OnTrayHelp();
+ afx_msg void OnTrayOptions();
+ afx_msg void OnTraySendfile();
+ afx_msg void OnWindowPosChanging(WINDOWPOS FAR* lpwndpos);
+ afx_msg void OnSelchangeLog();
+ afx_msg void OnTrayOpenfilesfolder();
+ afx_msg void OnDropFiles(HDROP hDropInfo);
+ virtual void OnCancel();
+ afx_msg void OnHelp();
+ //}}AFX_MSG
+ DECLARE_MESSAGE_MAP()
+};
diff --git a/README b/README
new file mode 100644
index 0000000..fbdfd9c
--- a/dev/null
+++ b/README
@@ -0,0 +1,33 @@
+
+Before compiling canned install executable the following files should be placed
+in the build tree:
+
+redist/mfc42.dl_
+
+Release checklist:
+ (These are tags stored in KTAGS file. please, keep in sync. Use vim to
+ jump to these tags. I haven't tried it on windows, though).
+
+|help-news| - Release notes in help file
+
+Version number in the following places:
+
+|about-version| - About box
+|vsinfo-numeric-version| - VERSIONINFO numerical File&Prod V
+|vsinfo-string-version| - VERSIONINFO string File&Prod V
+|install-version| - Version used in install
+|install-vsinfo-numeric-version| - install's VERSIONINFO block
+|install-vsinfo-string-version| - install's VERSIONINFO block
+
+If the year flips check these:
+
+|about-date| - About box
+|help-license-date| - license in help file
+|license-date| - license in COPYING file
+|vsinfo-date| - Copyright in VERSIONINFO block
+|install-vsinfo-date| - Copyright in install's VERSIONINFO
+ block
+
+
+This is for vim (don't remove):
+ vim:set tags=KTAGS isk=!-~,^*,^\|,^\" ft=help:
diff --git a/RequestDlg.cpp b/RequestDlg.cpp
new file mode 100644
index 0000000..94a8a98
--- a/dev/null
+++ b/RequestDlg.cpp
@@ -0,0 +1,299 @@
+// RequestDlg.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "PumpKIN.h"
+#include "RequestDlg.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CRequestDlg dialog
+
+
+CRequestDlg::CRequestDlg(CWnd* pParent /*=NULL*/)
+ : CDialog(CRequestDlg::IDD, pParent)
+{
+ m_Put=TRUE;
+ m_Drop=FALSE;
+ //{{AFX_DATA_INIT(CRequestDlg)
+ m_Host = m_MRUHost;
+ m_LocalFile = _T("");
+ m_RemoteFile = _T("");
+ m_Type = _T("octet");
+ m_strBSize = _T("");
+ //}}AFX_DATA_INIT
+}
+
+
+void CRequestDlg::DoDataExchange(CDataExchange* pDX)
+{
+ CDialog::DoDataExchange(pDX);
+ if(!pDX->m_bSaveAndValidate)
+ m_strBSize.Format("%u",m_BSize);
+ //{{AFX_DATA_MAP(CRequestDlg)
+ DDX_Control(pDX, IDC_REMOTEFILE, m_RemoteFileCtl);
+ DDX_Control(pDX, IDC_LOCALFILE, m_LocalFileCtl);
+ DDX_Control(pDX, IDC_REFRESH, m_RefreshCtl);
+ DDX_Control(pDX, IDOK, m_OKCtl);
+ DDX_Control(pDX, IDC_TALKS, m_TalksCtl);
+ DDX_Control(pDX, IDC_BROWSE, m_BrowseCtl);
+ DDX_CBString(pDX, IDC_TALKS, m_Host);
+ DDX_Text(pDX, IDC_LOCALFILE, m_LocalFile);
+ DDX_Text(pDX, IDC_REMOTEFILE, m_RemoteFile);
+ DDX_CBString(pDX, IDC_TYPE, m_Type);
+ DDX_CBString(pDX, IDC_BSIZE, m_strBSize);
+ //}}AFX_DATA_MAP
+ if(pDX->m_bSaveAndValidate)
+ m_BSize=atoi(m_strBSize);
+}
+
+CString CRequestDlg::m_MRUHost;
+
+BEGIN_MESSAGE_MAP(CRequestDlg, CDialog)
+ //{{AFX_MSG_MAP(CRequestDlg)
+ ON_BN_CLICKED(IDC_REFRESH, OnRefresh)
+ ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
+ ON_EN_CHANGE(IDC_LOCALFILE, OnChangeLocalfile)
+ ON_EN_CHANGE(IDC_REMOTEFILE, OnChangeRemotefile)
+ ON_CBN_EDITCHANGE(IDC_TALKS, OnEditchangeTalks)
+ ON_CBN_SELCHANGE(IDC_TALKS, OnSelchangeTalks)
+ ON_WM_CTLCOLOR()
+ ON_WM_DROPFILES()
+ //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CRequestDlg message handlers
+
+BOOL CRequestDlg::OnInitDialog()
+{
+ CDialog::OnInitDialog();
+
+ m_RefreshCtl.SendMessage(WM_SETFONT,(WPARAM)::GetStockObject(ANSI_FIXED_FONT),0);
+ m_BrowseCtl.SetIcon(AfxGetApp()->LoadIcon(IDI_BROWSE));
+
+CString title;
+ title.LoadString(m_Put?IDS_TITLE_PUTREQUEST:IDS_TITLE_GETREQUEST);
+ SetWindowText(title);
+ UpdateOK();
+ SyncNames();
+ BringWindowToTop();
+ SetForegroundWindow();
+ OnRefresh();
+ if(!m_MRUHost.IsEmpty())
+ m_TalksCtl.SetWindowText(m_MRUHost);
+ else{
+ if(m_TalksCtl.GetCount()==1){
+ CString tmp;
+ m_TalksCtl.GetLBText(0,tmp);
+ m_TalksCtl.SetWindowText(tmp);
+ }
+ }
+
+ // CG: The following block was added by the ToolTips component.
+ {
+ // Create the ToolTip control.
+ m_tooltip.Create(this);
+ m_tooltip.Activate(TRUE);
+
+ m_tooltip.AddTool(&m_BrowseCtl,IDC_BROWSE);
+ m_tooltip.AddTool(&m_RefreshCtl,IDC_REFRESH);
+ }
+
+ if(m_Put)
+ DragAcceptFiles();
+
+ if(m_Drop || !m_Put){
+ m_RemoteFileCtl.SetFocus();
+ return FALSE;
+ }
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // EXCEPTION: OCX Property Pages should return FALSE
+}
+
+void CRequestDlg::OnRefresh()
+{
+ m_TalksCtl.ResetContent();
+CWnd *wnd = CWnd::FindWindow(NULL,NULL);
+CString wtalkHead,wtalkAt;
+ wtalkHead.LoadString(IDS_WTALKHEADING);wtalkAt.LoadString(IDS_WTALKAT);
+CString otalxHead,otalxAt;
+ otalxHead.LoadString(IDS_OTALXHEADING);otalxAt.LoadString(IDS_OTALXAT);
+ while(wnd){
+ CString text;
+ wnd->GetWindowText(text);
+ int tw = text.Find(wtalkHead);
+ if(tw==0){
+ text=text.Mid(wtalkHead.GetLength());
+ int at = text.Find(wtalkAt);
+ if(at>=0){
+ if(text.GetLength()>(at+wtalkAt.GetLength())){
+ text=text.Left(at)+'@'+text.Mid(at+wtalkAt.GetLength());
+ text.TrimLeft();
+ text.TrimRight();
+ VERIFY(m_TalksCtl.AddString(text)>=0);
+ }
+ }
+ }else{
+ tw = text.Find(otalxHead);
+ if(tw==0){
+ text=text.Mid(otalxHead.GetLength());
+ int at = text.Find(otalxAt);
+ if(at>=0){
+ if(text.GetLength()>(at+otalxAt.GetLength())){
+ text=text.Left(at)+'@'+text.Mid(at+otalxAt.GetLength());
+ text.TrimLeft();
+ text.TrimRight();
+ VERIFY(m_TalksCtl.AddString(text)>=0);
+ }
+ }
+ }
+ }
+ wnd = wnd->GetNextWindow();
+ }
+ UpdateOK();
+}
+
+void CRequestDlg::OnBrowse()
+{
+ UpdateData(TRUE);
+CFileDialog cfd(m_Put,NULL,m_LocalFile.IsEmpty()?NULL:m_LocalFile,OFN_EXPLORER|OFN_HIDEREADONLY|OFN_PATHMUSTEXIST|(m_Put?OFN_FILEMUSTEXIST:OFN_OVERWRITEPROMPT),NULL,this);
+CString title;
+ title.LoadString(IDS_TITLE_BROWSEFILE);
+ cfd.m_ofn.lpstrTitle=(LPCTSTR)title;
+ if(cfd.DoModal()==IDOK){
+ m_LocalFile=cfd.GetPathName();
+ UpdateData(FALSE);
+ SyncNames();
+ UpdateOK();
+ }
+}
+
+void CRequestDlg::SyncNames()
+{
+ if(m_Put){
+ CString tmp;
+ m_LocalFileCtl.GetWindowText(tmp);
+ int s=tmp.ReverseFind('\\');
+ if(s>=0)
+ tmp=tmp.Mid(s+1);
+ else{
+ s = tmp.ReverseFind('/');
+ if(s>=0)
+ tmp=tmp.Mid(s+1);
+ }
+ if(!tmp.IsEmpty())
+ m_RemoteFileCtl.SetWindowText(tmp);
+ }else{
+ CString tmp;
+ m_RemoteFileCtl.GetWindowText(tmp);
+ int s=tmp.ReverseFind('\\');
+ if(s>=0)
+ tmp=tmp.Mid(s+1);
+ else{
+ s = tmp.ReverseFind('/');
+ if(s>=0)
+ tmp=tmp.Mid(s+1);
+ }
+ if(!tmp.IsEmpty())
+ m_LocalFileCtl.SetWindowText(tmp);
+ }
+}
+
+void CRequestDlg::OnChangeLocalfile()
+{
+ if(m_Put)
+ SyncNames();
+ UpdateOK();
+}
+
+void CRequestDlg::OnChangeRemotefile()
+{
+ if(!m_Put)
+ SyncNames();
+ UpdateOK();
+}
+
+void CRequestDlg::UpdateOK()
+{
+CString t;
+ m_LocalFileCtl.GetWindowText(t);
+ if(t.IsEmpty())
+ goto dAble;
+ m_RemoteFileCtl.GetWindowText(t);
+ if(t.IsEmpty())
+ goto dAble;
+ m_TalksCtl.GetWindowText(t);
+ if(t.IsEmpty())
+ goto dAble;
+ m_OKCtl.EnableWindow(TRUE);
+ return;
+dAble:
+ m_OKCtl.EnableWindow(FALSE);
+}
+
+void CRequestDlg::OnEditchangeTalks()
+{
+ UpdateOK();
+}
+
+void CRequestDlg::OnSelchangeTalks()
+{
+ UpdateOK();
+}
+
+HBRUSH CRequestDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
+{
+ HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
+ UpdateOK();
+ return hbr;
+}
+
+BOOL CRequestDlg::PreTranslateMessage(MSG* pMsg)
+{
+ // CG: The following block was added by the ToolTips component.
+ {
+ // Let the ToolTip process this message.
+ if(::IsWindow(m_tooltip.m_hWnd))
+ m_tooltip.RelayEvent(pMsg);
+
+ return CDialog::PreTranslateMessage(pMsg);
+ }
+}
+
+int CRequestDlg::DoModal()
+{
+int rv = CDialog::DoModal();
+ if(rv==IDOK)
+ m_MRUHost=m_Host;
+ return rv;
+}
+
+void CRequestDlg::OnDropFiles(HDROP hDropInfo)
+{
+UINT files = ::DragQueryFile(hDropInfo,0xFFFFFFFF,NULL,0);
+ if(files!=1){
+ CString title,text;
+ title.LoadString(IDS_DROPFILES_TITLE);
+ text.LoadString(IDS_NOMULTIPLEDROP_TEXT);
+ if(MessageBox(text,title,MB_ICONSTOP|MB_OKCANCEL)!=IDOK){
+ ::DragFinish(hDropInfo);
+ return;
+ }
+ }
+ ASSERT(files);
+CString theFile;
+UINT fileNameLength = ::DragQueryFile(hDropInfo,0,NULL,0);
+ ASSERT(fileNameLength);
+ VERIFY(::DragQueryFile(hDropInfo,0,theFile.GetBuffer(fileNameLength+5),fileNameLength+4)<=fileNameLength);
+ theFile.ReleaseBuffer();
+ m_LocalFileCtl.SetWindowText(theFile);
+ SyncNames();
+ ::DragFinish(hDropInfo);
+}
diff --git a/RequestDlg.h b/RequestDlg.h
new file mode 100644
index 0000000..fcd2d20
--- a/dev/null
+++ b/RequestDlg.h
@@ -0,0 +1,63 @@
+// RequestDlg.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CRequestDlg dialog
+
+class CRequestDlg : public CDialog
+{
+// Construction
+public:
+ UINT m_BSize;
+ static CString m_MRUHost;
+ BOOL m_Drop;
+ virtual BOOL PreTranslateMessage(MSG* pMsg);
+ void UpdateOK();
+ void SyncNames();
+ BOOL m_Put;
+ CRequestDlg(CWnd* pParent = NULL); // standard constructor
+
+// Dialog Data
+ //{{AFX_DATA(CRequestDlg)
+ enum { IDD = IDD_REQUEST };
+ CEdit m_RemoteFileCtl;
+ CEdit m_LocalFileCtl;
+ CButton m_RefreshCtl;
+ CButton m_OKCtl;
+ CComboBox m_TalksCtl;
+ CButton m_BrowseCtl;
+ CString m_Host;
+ CString m_LocalFile;
+ CString m_RemoteFile;
+ CString m_Type;
+ CString m_strBSize;
+ //}}AFX_DATA
+
+
+// Overrides
+ // ClassWizard generated virtual function overrides
+ //{{AFX_VIRTUAL(CRequestDlg)
+ public:
+ virtual int DoModal();
+ protected:
+ virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
+ //}}AFX_VIRTUAL
+
+// Implementation
+protected:
+ CToolTipCtrl m_tooltip;
+
+ // Generated message map functions
+ //{{AFX_MSG(CRequestDlg)
+ virtual BOOL OnInitDialog();
+ afx_msg void OnRefresh();
+ afx_msg void OnBrowse();
+ afx_msg void OnChangeLocalfile();
+ afx_msg void OnChangeRemotefile();
+ afx_msg void OnEditchangeTalks();
+ afx_msg void OnSelchangeTalks();
+ afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
+ afx_msg void OnDropFiles(HDROP hDropInfo);
+ //}}AFX_MSG
+ DECLARE_MESSAGE_MAP()
+};
diff --git a/Resolver.cpp b/Resolver.cpp
new file mode 100644
index 0000000..0ec66d3
--- a/dev/null
+++ b/Resolver.cpp
@@ -0,0 +1,71 @@
+// Resolver.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "PumpKIN.h"
+#include "Resolver.h"
+#include "PumpKINDlg.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CResolver
+
+CResolver::CResolver()
+{
+ ASSERT(NULL);
+}
+
+CResolver::~CResolver()
+{
+}
+
+
+BEGIN_MESSAGE_MAP(CResolver, CWnd)
+ //{{AFX_MSG_MAP(CResolver)
+ ON_WM_CREATE()
+ ON_MESSAGE(WM_RESOLVED, OnResolved)
+ //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+
+/////////////////////////////////////////////////////////////////////////////
+// CResolver message handlers
+
+CResolver::CResolver(CXferSocket *socket)
+ : socket(socket)
+{
+}
+
+int CResolver::OnCreate(LPCREATESTRUCT lpCreateStruct)
+{
+ if (CWnd::OnCreate(lpCreateStruct) == -1)
+ return -1;
+
+ ASSERT(socket);
+CString hostName = socket->m_HostName;
+int at = hostName.Find('@');
+ if(at>=0)
+ hostName=hostName.Mid(at+1);
+ m_hAsync=WSAAsyncGetHostByName(m_hWnd,WM_RESOLVED,(LPCTSTR)hostName,(char*)socket->m_ResolveBuff,sizeof(socket->m_ResolveBuff));
+ ASSERT(m_hAsync);
+ return 0;
+}
+
+LRESULT CResolver::OnResolved(WPARAM wP,LPARAM lP)
+{
+ if(WSAGETASYNCERROR(lP))
+ socket->OnFailedToResolve();
+ else
+ socket->OnResolved();
+ return 0;
+}
+
+BOOL CResolver::Resolve()
+{
+ return Create(NULL,"PumpKIN-Resolver",WS_CHILD,CRect(0,0,0,0),socket->m_Daddy,0);
+}
diff --git a/Resolver.h b/Resolver.h
new file mode 100644
index 0000000..a97b23e
--- a/dev/null
+++ b/Resolver.h
@@ -0,0 +1,42 @@
+// Resolver.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CResolver window
+
+class CXferSocket;
+class CResolver : public CWnd
+{
+// Construction
+public:
+ BOOL Resolve();
+ HANDLE m_hAsync;
+ CResolver(CXferSocket *socket);
+ CXferSocket* socket;
+ CResolver();
+
+// Attributes
+public:
+
+// Operations
+public:
+
+// Overrides
+ // ClassWizard generated virtual function overrides
+ //{{AFX_VIRTUAL(CResolver)
+ //}}AFX_VIRTUAL
+
+// Implementation
+public:
+ virtual ~CResolver();
+
+ // Generated message map functions
+protected:
+ //{{AFX_MSG(CResolver)
+ afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
+ afx_msg LRESULT OnResolved(WPARAM wP,LPARAM lP);
+ //}}AFX_MSG
+ DECLARE_MESSAGE_MAP()
+};
+
+/////////////////////////////////////////////////////////////////////////////
diff --git a/Retrier.cpp b/Retrier.cpp
new file mode 100644
index 0000000..15b9fc3
--- a/dev/null
+++ b/Retrier.cpp
@@ -0,0 +1,46 @@
+// Retrier.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "PumpKIN.h"
+#include "Retrier.h"
+
+#include "PumpKINDlg.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CRetrier
+
+CRetrier::CRetrier(CPumpKINDlg *daddy)
+ : m_Daddy(daddy)
+{
+}
+
+CRetrier::~CRetrier()
+{
+}
+
+
+BEGIN_MESSAGE_MAP(CRetrier, CWnd)
+ //{{AFX_MSG_MAP(CRetrier)
+ ON_WM_TIMER()
+ //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+
+/////////////////////////////////////////////////////////////////////////////
+// CRetrier message handlers
+
+void CRetrier::OnTimer(UINT nIDEvent)
+{
+ ASSERT(m_Daddy);
+CXferSocket *socket;
+ if(m_Daddy->m_Xfers.Lookup(nIDEvent,socket))
+ socket->OnRetry();
+ CWnd::OnTimer(nIDEvent);
+}
diff --git a/Retrier.h b/Retrier.h
new file mode 100644
index 0000000..1a50ce2
--- a/dev/null
+++ b/Retrier.h
@@ -0,0 +1,38 @@
+// Retrier.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CRetrier window
+
+class CPumpKINDlg;
+class CRetrier : public CWnd
+{
+// Construction
+public:
+ CPumpKINDlg* m_Daddy;
+ CRetrier(CPumpKINDlg *daddy);
+
+// Attributes
+public:
+
+// Operations
+public:
+
+// Overrides
+ // ClassWizard generated virtual function overrides
+ //{{AFX_VIRTUAL(CRetrier)
+ //}}AFX_VIRTUAL
+
+// Implementation
+public:
+ virtual ~CRetrier();
+
+ // Generated message map functions
+protected:
+ //{{AFX_MSG(CRetrier)
+ afx_msg void OnTimer(UINT nIDEvent);
+ //}}AFX_MSG
+ DECLARE_MESSAGE_MAP()
+};
+
+/////////////////////////////////////////////////////////////////////////////
diff --git a/Trayer.cpp b/Trayer.cpp
new file mode 100644
index 0000000..6e8c100
--- a/dev/null
+++ b/Trayer.cpp
@@ -0,0 +1,118 @@
+// Trayer.cpp : implementation file
+//
+
+#include "stdafx.h"
+#include "PumpKIN.h"
+#include "Trayer.h"
+
+#include "PumpKINDlg.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CTrayer
+
+CTrayer::CTrayer()
+{
+ m_inMenu=0;
+}
+
+CTrayer::~CTrayer()
+{
+}
+
+
+BEGIN_MESSAGE_MAP(CTrayer, CWnd)
+ //{{AFX_MSG_MAP(CTrayer)
+ ON_MESSAGE(WM_TRAYICON, OnTray)
+ ON_COMMAND(ID_TRAY_ABOUTPUMPKIN, OnTrayAboutpumpkin)
+ ON_COMMAND(ID_TRAY_EXIT, OnTrayExit)
+ ON_COMMAND(ID_TRAY_FETCHFILE, OnTrayFetchfile)
+ ON_COMMAND(ID_TRAY_HELP, OnTrayHelp)
+ ON_COMMAND(ID_TRAY_OPENFILESFOLDER, OnTrayOpenfilesfolder)
+ ON_COMMAND(ID_TRAY_OPTIONS, OnTrayOptions)
+ ON_COMMAND(ID_TRAY_SENDFILE, OnTraySendfile)
+ ON_COMMAND(ID_TRAY_SHOWPUMPKINWINDOW, OnTrayShowpumpkinwindow)
+ //}}AFX_MSG_MAP
+END_MESSAGE_MAP()
+
+
+/////////////////////////////////////////////////////////////////////////////
+// CTrayer message handlers
+
+CTrayer::CTrayer(CPumpKINDlg* daddy)
+ : m_Daddy(daddy)
+{
+ m_inMenu=0;
+}
+
+LRESULT CTrayer::OnTray(WPARAM wP,LPARAM lP)
+{
+ ASSERT(wP==IDC_TRAYICON);
+ switch(lP){
+ case WM_RBUTTONDOWN:
+ {
+ CMenu menu;
+ VERIFY(menu.LoadMenu(IDM_POPUPS));
+ CMenu *popUp = menu.GetSubMenu(0);
+ ASSERT(popUp);
+ CPoint pt;
+ VERIFY(::GetCursorPos(&pt));
+ m_inMenu++;
+ SetForegroundWindow();
+ popUp->CheckMenuItem(ID_TRAY_SHOWPUMPKINWINDOW,MF_BYCOMMAND|(IsWindowVisible()?MF_CHECKED:MF_UNCHECKED));
+ popUp->TrackPopupMenu(TPM_RIGHTALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON,pt.x,pt.y,this);
+ m_inMenu--;
+ SendMessage(WM_NULL);
+ }
+ break;
+ case WM_LBUTTONDOWN:
+ m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_SHOWPUMPKINWINDOW);
+ break;
+ }
+ return 0;
+}
+
+void CTrayer::OnTrayAboutpumpkin()
+{
+ m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_ABOUTPUMPKIN);
+}
+
+void CTrayer::OnTrayExit()
+{
+ m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_EXIT);
+}
+
+void CTrayer::OnTrayFetchfile()
+{
+ m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_FETCHFILE);
+}
+
+void CTrayer::OnTrayHelp()
+{
+ m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_HELP);
+}
+
+void CTrayer::OnTrayOpenfilesfolder()
+{
+ m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_OPENFILESFOLDER);
+}
+
+void CTrayer::OnTrayOptions()
+{
+ m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_OPTIONS);
+}
+
+void CTrayer::OnTraySendfile()
+{
+ m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_SENDFILE);
+}
+
+void CTrayer::OnTrayShowpumpkinwindow()
+{
+ m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_SHOWPUMPKINWINDOW);
+}
diff --git a/Trayer.h b/Trayer.h
new file mode 100644
index 0000000..061a53a
--- a/dev/null
+++ b/Trayer.h
@@ -0,0 +1,48 @@
+// Trayer.h : header file
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// CTrayer window
+
+class CPumpKINDlg;
+class CTrayer : public CWnd
+{
+// Construction
+public:
+ int m_inMenu;
+ CPumpKINDlg* m_Daddy;
+ CTrayer(CPumpKINDlg* daddy);
+ CTrayer();
+
+// Attributes
+public:
+
+// Operations
+public:
+
+// Overrides
+ // ClassWizard generated virtual function overrides
+ //{{AFX_VIRTUAL(CTrayer)
+ //}}AFX_VIRTUAL
+
+// Implementation
+public:
+ virtual ~CTrayer();
+
+ // Generated message map functions
+protected:
+ //{{AFX_MSG(CTrayer)
+ afx_msg LRESULT OnTray(WPARAM,LPARAM);
+ afx_msg void OnTrayAboutpumpkin();
+ afx_msg void OnTrayExit();
+ afx_msg void OnTrayFetchfile();
+ afx_msg void OnTrayHelp();
+ afx_msg void OnTrayOpenfilesfolder();
+ afx_msg void OnTrayOptions();
+ afx_msg void OnTraySendfile();
+ afx_msg void OnTrayShowpumpkinwindow();
+ //}}AFX_MSG
+ DECLARE_MESSAGE_MAP()
+};
+
+/////////////////////////////////////////////////////////////////////////////
diff --git a/help/pumpkin.bmp b/help/pumpkin.bmp
new file mode 100644
index 0000000..9c09c21
--- a/dev/null
+++ b/help/pumpkin.bmp
Binary files differ
diff --git a/help/pumpkin.cnt b/help/pumpkin.cnt
new file mode 100644
index 0000000..0e09da3
--- a/dev/null
+++ b/help/pumpkin.cnt
@@ -0,0 +1,14 @@
+:Base PumpKIN.hlp>Standard
+:Title PumpKIN
+1 PumpKIN
+2 About PumpKIN=About
+2 What's New=News
+2 Using PumpKIN=Using
+1 PumpKIN Dialogs
+2 Confirm Read Request Dialog=ConfirmRRQ
+2 Confirm Write Request Dialog=ConfirmWRQ
+2 Request Dialog=Request
+1 PumpKIN Options
+2 Server Options=ServerOptions
+2 Network Options=NetworkOptions
+2 Sounds Options=SoundsOptions
diff --git a/help/pumpkin.hpj b/help/pumpkin.hpj
new file mode 100644
index 0000000..d4a2efe
--- a/dev/null
+++ b/help/pumpkin.hpj
@@ -0,0 +1,19 @@
+; This file is maintained by HCW. Do not modify this file directly.
+
+[OPTIONS]
+COMPRESS=12 Hall Zeck
+LCID=0x409 0x0 0x0 ; English (United States)
+REPORT=Yes
+CONTENTS=Using
+TITLE=PumpKIN
+CNT=pumpkin.cnt
+HLP=PUMPKIN.HLP
+
+[FILES]
+pumpkin.rtf
+
+[MAP]
+#include pumpkin.hm
+
+[WINDOWS]
+Standard="",(2,6,732,884),20740,(r14876671),(r12632256),f2
diff --git a/help/pumpkin.rtf b/help/pumpkin.rtf
new file mode 100644
index 0000000..b78a159
--- a/dev/null
+++ b/help/pumpkin.rtf
@@ -0,0 +1,117 @@
+{\rtf1\ansi
+@{\footnote
+THIS FILE WAS AUTOMATICALLY GENERATED FROM XML DOCUMENT.
+DO NOT MODIFY THIS FILE DIRECTLY. EDIT XML DOCUMENT INSTEAD
+}
+{\fonttbl{\f0\froman Times New Roman;}{\f1\fswiss Arial;}{\f3\froman Symbol;}}{\colortbl;
+ \red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;
+ \red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;
+ \red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;
+ \red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;}
+
+\pard\plain\keepn
+#{\footnote About}
+${\footnote About PumpKIN}
+K{\footnote about}
+{ \f1\fs18\b\sb120 About {\b PumpKIN}}
+\par\sa120\sb120\qj\pard \f1\fs18\sb120 {\b PumpKIN} is a program designed to send and receive files over the net while having {\uldb {\b T42}}{\v %!ExecFile("http://www.klever.net/kin/t42.html")} or {\uldb {\b\cf6 Wintalk}}{\v %!ExecFile("http://www.elf.com/elf/wintalk.html")} session running using {\i TFTP} ({\uldb {\b RFC1350}}{\v %!ExecFile("http://www.rfc-editor.org/rfc/rfc1350.txt")}) protocol. It includes full-functional {\i TFTP} server/client so it may be useful for maintaining {\uldb CISCO}{\v %!ExecFile("http://www.cisco.com/")} routers and other network equipment.
+\par\sa120\sb120\qj\pard \f1\fs18\sb120
+\par\sa120\sb120\qj\pard \f1\fs18\sb120 {\b {\i Enjoy!}}
+{
+\par\pard\plain\sb360\sa120 \f1\fs16 Copyright (c) 1997, 1998, 2002 {\uldb\cf0 Klever Group (http://www.klever.net/)}{\v %!ExecFile("http://www.klever.net/")}
+\par\qj\sb120\sa120Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+\par The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+\par \sa360 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+}
+\page
+
+\pard\plain
+#{\footnote News}
+${\footnote What's New}
+\par\pard\plain\f1\fs24\qc\cf2\b 2.5 - August 19st, 2002
+\par\pard\plain\fi0\li0\f1\fs18 \bullet Change of {\uldb license}{\v About} and opening the source.
+\par\pard\plain\fi0\li0\f1\fs18 \bullet Minor cosmetic changes, mostly in build process
+\par\pard\plain\f1\fs24\qc\cf2\b 2.0 - June 13th, 1998
+\par\pard\plain\fi0\li0\f1\fs18 \bullet Sounds customization. Now you can customize {\b PumpKIN} bells and whistles or turn them off completely.
+\par\pard\plain\fi0\li0\f1\fs18 \bullet Previous version of {\b PumpKIN} had a bug causing it to misbehave when you're requesting file from remote {\i tftp} server using {\b IP Address} (as opposed to {\b hostname}).
+\par\pard\plain\fi0\li0\f1\fs18 \bullet Typo causing {\b PumpKIN} to log outgoing request in reverse (i.e. {\i Requesting 'hostname' from 'filename'}) fixed.
+\par\pard\plain\fi0\li0\f1\fs18 \bullet Something else that you may not notice and I can not remember.
+\par\pard\plain\f1\fs24\qc\cf2\b 1.5 - February 12th, 1998
+\par\pard\plain\fi0\li0\f1\fs18 \bullet Transfer resumes. No checking on file contents is done, so it's up to you to decide whether you want to start transmission from the beginning or resume unfinished transfer.
+\par\pard\plain\fi0\li0\f1\fs18 \bullet Support for {\b block size}, {\b trasnfer size} and {\b transfer timeout} options as described in {\uldb {\b RFC1782}}{\v %!ExecFile("http://www.rfc-editor.org/rfc/rfc1782.txt")}, {\uldb {\b RFC1783}}{\v %!ExecFile("http://www.rfc-editor.org/rfc/rfc1783.txt")} and {\uldb {\b RFC1784}}{\v %!ExecFile("http://www.rfc-editor.org/rfc/rfc1784.txt")}. I'm not sure if there are any other {\i TFTP} implementations supporting this, but at least it makes sense if you use {\b PumpKIN} on both ends.
+\par\pard\plain\fi0\li0\f1\fs18 \bullet New Install program
+\page
+
+\pard\plain\keepn
+#{\footnote Using}
+${\footnote Using PumpKIN}
+{ \f1\fs18\b\sb120 Using {\b PumpKIN}}
+\par\sa120\sb120\qj\pard \f1\fs18\sb120 This is a simple program for file exchange between two parties. It allows you to send files over the network to your party while having a {\uldb {\b T42}}{\v %!ExecFile("http://www.klever.net/kin/t42.html")} or {\uldb {\b\cf6 Wintalk}}{\v %!ExecFile("http://elf.com/elf/wintalk.html")} conversation. It uses open sessions to determine IP address of your party. Also you may use it as a {\i TFTP} client/server by itself. To get/put files from/to {\i TFTP} server you need to enter host name/IP address manually in the {\uldb Request Dialog}{\v Request}.
+\par\sa120\sb120\qj\pard \f1\fs18\sb120 To Abort transfer(s) currently in progress - select transfer(s) you want to terminate in the list and click {\b Abort xfer} button.
+\par\sa120\sb120\qj\pard \f1\fs18\sb120 You may want to hide {\b PumpKIN} window and leave it as a tray icon only. Just click the \{bmct pumpkin.bmp\} icon in the tray or simply close the window.
+\par\sa120\sb120\qj\pard \f1\fs18\sb120 Use {\uldb Options}{\v Options} button to set {\b PumpKIN} options.
+\page
+
+\pard\plain\keepn
+#{\footnote ConfirmRRQ}
+${\footnote Confirm Read Request Dialog}
+{ \f1\fs18\b\sb120 Confirm Read Request Dialog}
+\par\sa120\sb120\qj\pard \f1\fs18\sb120 When the file is requested from your {\i TFTP} server you may choose to {\b Grant Access} to this file or to {\b Deny Access}. If you hesitate to answer for {\uldb {\b Confirmation timeout}}{\v ConfirmationTimeout} ({\i default - 30 seconds}) {\b PumpKIN} defaults to denial of all requests.
+\page
+
+\pard\plain\keepn
+#{\footnote ConfirmWRQ}
+${\footnote Confirm Write Request Dialog}
+{ \f1\fs18\b\sb120 Confirm Write Request Dialog}
+\par\sa120\sb120\qj\pard \f1\fs18\sb120 Whenever your party sends you a file you have always a choice to accept it or not. You can also save the file under a different name by choosing the {\b Rename} option. If you already have file with such name you may chose to {\b resume} transfer. No checking on file contents is done. This option may or may not work depending on remote implementation of protocol. It does work if you use {\b PumpKIN} on both ends. If you are still unsure for {\uldb {\b Confirmation timeout}}{\v ConfirmationTimeOut} ({\i default - 30 seconds}) {\b PumpKIN} will make safe decision for you (deny).
+\page
+
+\pard\plain\keepn
+#{\footnote Request}
+${\footnote Request Dialog}
+{ \f1\fs18\b\sb120 Request Dialog}
+\par\sa120\sb120\qj\pard \f1\fs18\sb120 Request dialog is aimed to let you form read or write request. You may set the following options:\pard
+\par \fi0\li0 \bullet {\b Local File} - You can change the name of the file you're sending (or destination in case you're receiving) right here. You may also use {\b Browse} button to select the file.
+\par \fi0\li0 \bullet {\b Remote File} Specifies the name of file on the remote host you're requesting (in case of read request) or the name of file you want your file to appear as (in case of write request).
+\par \fi0\li0 \bullet {\b Remote Host} is your party's host or {\i TFTP} server you're requesting file from/sending file to. To refresh the list of your talk windows use {\b REFRESH} button.
+\par \fi0\li0 \bullet {\b Type} is the type of transfer as defined in {\uldb {\b RFC1350}}{\v %!ExecFile("http://www.rfc-editor.org/rfc/rfc1350.txt")}. Doesn't mean much, really. Defined types are '{\i octet}' or '{\i netascii}'. Default is '{\i octet}'.
+\par \fi0\li0 \bullet {\b Block Size} - Use this block size if remote is {\uldb {\b RFC1783}}{\v %!ExecFile("http://www.rfc-editor.org/rfc/rfc1783.txt")}-compliant. If remote doesn't support this option {\b PumpKIN} will fallback to 512 bytes per block.\pard
+\page
+
+\pard\plain\keepn
+#{\footnote Options}
+${\footnote Options}
+{ \f1\fs18\b\sb120 Options}
+\par\sa120\sb120\qj\pard \f1\fs18\sb120 {\b PumpKIN} options property sheet consists of two tabs. For more information see {\uldb {\b Network}}{\v NetworkOptions} and {\b Server} options.
+\page
+
+\pard\plain\keepn
+#{\footnote NetworkOptions}
+${\footnote Network Options}
+{ \f1\fs18\b\sb120 Network Options}\pard
+\par \fi0\li0 \bullet {\b UDP Ports}\pard
+\par \fi0\li0 \bullet {\b Listen for incoming connections on port} - specifies the port we're listening to. The default as defined in {\uldb {\b RFC1350}}{\v %!ExecFile("http://www.rfc-editor.org/rfc/rfc1350.txt")} is 69.
+\par \fi0\li0 \bullet {\b Send outgoing requests to port} - specifies the port we're going to send all requests to.\pard
+\par \fi0\li0 \bullet {\b Default Connection timeout} - if there's no activity for specified time, transfer is considered to be dead and terminated. {\b PumpKIN} tries to propagate this value to remote as described in {\uldb {\b RFC1782}}{\v %!ExecFile("http://www.rfc-editor.org/rfc/rfc1782.txt")} and {\uldb {\b RFC1784}}{\v %!ExecFile("http://www.rfc-editor.org/rfc/rfc1784.txt")} if possible.
+\par \fi0\li0 \bullet {\b Default Block Size} - {\b PumpKIN} tries to negotiate block size with remote using this value unless specified explicitly in request. If remote doesn't support {\uldb {\b RFC1782}}{\v %!ExecFile("http://www.rfc-editor.org/rfc/rfc1782.txt")} and {\uldb {\b RFC1783}}{\v %!ExecFile("http://www.rfc-editor.org/rfc/rfc1783.txt")}{\b PumpKIN} falls back to 512 bytes per block.\pard
+\page
+
+\pard\plain\keepn
+#{\footnote ServerOptions}
+${\footnote Server Options}
+{ \f1\fs18\b\sb120 Server Options}\pard
+\par \fi0\li0 \bullet {\b TFTP Filesystem root} - Specifies the location of files you're transmitting or where to start looking for them from. Defaults to the directory you start {\b PumpKIN} for the first time from.
+\par \fi0\li0 \bullet {\b Allow access to subdirectories} - specifies whether you want allow access to the whole subtree of {\b TFTP Root} or only to the directory itself.
+\par \fi0\li0 \bullet {\b Read Request Behavior} - You may choose to automatically agree to give all files requested, to be prompted to confirm these operations, or to deny all requests as if you're not even here.
+\par \fi0\li0 \bullet {\b Write Request Behavior} - You may chose to {\b take all files} ({\i not recommended}), to {\b prompt only if file exists already}, {\b Always prompt} or {\b Deny all requests}.
+\par \fi0\li0 \bullet {#{\footnote ConfirmationTimeOut}}{\b Confirmation timeout} - this is the time {\b PumpKIN} will wait for you to accept or deny request before it will give up and take default action which is always deny.\pard
+\page
+
+\pard\plain\keepn
+#{\footnote SoundsOptoins}
+${\footnote Sounds Options}
+{ \f1\fs18\b\sb120 Sounds}
+\par\sa120\sb120\qj\pard \f1\fs18\sb120 You can customize {\b PumpKIN} sounds notifications here. There are three customizable sounds defined - {\b Incoming request}, which notifies you about incoming request prompt if you're set to be prompted whenever incoming request occurs. {\b xfer Aborted} - which happens to sound every time transfer is interrupted for whatever reason - time out, explicit kill, denied access, etc. {\b xfer Finished} means that your file was successfully transmitted.
+\par\sa120\sb120\qj\pard \f1\fs18\sb120 You can select any {\b .wav} file or one of the predefined sounds from the dropdown list.
+\page
+} \ No newline at end of file
diff --git a/help/pumpkin.xml b/help/pumpkin.xml
new file mode 100644
index 0000000..bac9950
--- a/dev/null
+++ b/help/pumpkin.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0"?>
+<winhelp>
+ <topic id="About" title="About PumpKIN" keywords="about">
+ <heading scroll="no">About <kin>PumpKIN</kin></heading>
+ <p><kin>PumpKIN</kin> is a program designed to send and receive files over the net while having <kin href="http://www.klever.net/kin/t42.html">T42</kin> or <product href="http://www.elf.com/elf/wintalk.html">Wintalk</product> session running using <term>TFTP</term> (<rfc num="1350"/>) protocol. It includes full-functional <term>TFTP</term> server/client so it may be useful for maintaining <a href="http://www.cisco.com/">CISCO</a> routers and other network equipment.</p>
+ <p/>
+ <p><b><i>Enjoy!</i></b></p>
+ <license years="1997, 1998, 2002"/>
+ <credist/>
+ </topic>
+ <topic id="News" title="What's New">
+ <newsfor version="2.5" date="August 19st, 2002">
+ <ni>Change of <a href="#About">license</a> and opening the source.</ni>
+ <ni>Minor cosmetic changes, mostly in build process</ni>
+ </newsfor>
+ <newsfor version="2.0" date="June 13th, 1998">
+ <ni>Sounds customization. Now you can customize <kin>PumpKIN</kin> bells and whistles or turn them off completely.</ni>
+ <ni>Previous version of <kin>PumpKIN</kin> had a bug causing it to misbehave when you're requesting file from remote <term>tftp</term> server using <b>IP Address</b> (as opposed to <b>hostname</b>).</ni>
+ <ni>Typo causing <kin>PumpKIN</kin> to log outgoing request in reverse (i.e. <i>Requesting 'hostname' from 'filename'</i>) fixed.</ni>
+ <ni>Something else that you may not notice and I can not remember.</ni>
+ </newsfor>
+ <newsfor version="1.5" date="February 12th, 1998">
+ <ni>Transfer resumes. No checking on file contents is done, so it's up to you to decide whether you want to start transmission from the beginning or resume unfinished transfer.</ni>
+ <ni>Support for <b>block size</b>, <b>trasnfer size</b> and <b>transfer timeout</b> options as described in <rfc num="1782"/>, <rfc num="1783"/> and <rfc num="1784"/>. I'm not sure if there are any other <term>TFTP</term> implementations supporting this, but at least it makes sense if you use <kin>PumpKIN</kin> on both ends.</ni>
+ <ni>New Install program</ni>
+ </newsfor>
+ </topic>
+ <topic id="Using" title="Using PumpKIN">
+ <heading scroll="no">Using <kin>PumpKIN</kin></heading>
+ <p>This is a simple program for file exchange between two parties. It allows you to send files over the network to your party while having a <kin href="http://www.klever.net/kin/t42.html">T42</kin> or <product href="http://elf.com/elf/wintalk.html">Wintalk</product> conversation. It uses open sessions to determine IP address of your party. Also you may use it as a <term>TFTP</term> client/server by itself. To get/put files from/to <term>TFTP</term> server you need to enter host name/IP address manually in the <a href="#Request">Request Dialog</a>.</p>
+ <p>To Abort transfer(s) currently in progress - select transfer(s) you want to terminate in the list and click <b>Abort xfer</b> button.</p>
+ <p>You may want to hide <kin>PumpKIN</kin> window and leave it as a tray icon only. Just click the <image source="pumpkin.bmp"/> icon in the tray or simply close the window.</p>
+ <p>Use <a href="#Options">Options</a> button to set <kin>PumpKIN</kin> options.</p>
+ </topic>
+ <topic id="ConfirmRRQ" title="Confirm Read Request Dialog">
+ <heading scroll="no">Confirm Read Request Dialog</heading>
+ <p>When the file is requested from your <term>TFTP</term> server you may choose to <b>Grant Access</b> to this file or to <b>Deny Access</b>. If you hesitate to answer for <a href="#ConfirmationTimeout"><b>Confirmation timeout</b></a> (<i>default - 30 seconds</i>) <kin>PumpKIN</kin> defaults to denial of all requests.</p>
+ </topic>
+ <topic id="ConfirmWRQ" title="Confirm Write Request Dialog">
+ <heading scroll="no">Confirm Write Request Dialog</heading>
+ <p>Whenever your party sends you a file you have always a choice to accept it or not. You can also save the file under a different name by choosing the <b>Rename</b> option. If you already have file with such name you may chose to <b>resume</b> transfer. No checking on file contents is done. This option may or may not work depending on remote implementation of protocol. It does work if you use <kin>PumpKIN</kin> on both ends. If you are still unsure for <a href="#ConfirmationTimeOut"><b>Confirmation timeout</b></a> (<i>default - 30 seconds</i>) <kin>PumpKIN</kin> will make safe decision for you (deny).</p>
+ </topic>
+ <topic id="Request" title="Request Dialog">
+ <heading scroll="no">Request Dialog</heading>
+ <p>Request dialog is aimed to let you form read or write request. You may set the following options:</p>
+ <ul>
+ <li><b>Local File</b> - You can change the name of the file you're sending (or destination in case you're receiving) right here. You may also use <b>Browse</b> button to select the file.</li>
+ <li><b>Remote File</b> Specifies the name of file on the remote host you're requesting (in case of read request) or the name of file you want your file to appear as (in case of write request).</li>
+ <li><b>Remote Host</b> is your party's host or <term>TFTP</term> server you're requesting file from/sending file to. To refresh the list of your talk windows use <b>REFRESH</b> button.</li>
+ <li><b>Type</b> is the type of transfer as defined in <rfc num="1350"/>. Doesn't mean much, really. Defined types are '<i>octet</i>' or '<i>netascii</i>'. Default is '<i>octet</i>'.</li>
+ <li><b>Block Size</b> - Use this block size if remote is <rfc num="1783"/>-compliant. If remote doesn't support this option <kin>PumpKIN</kin> will fallback to 512 bytes per block.</li>
+ </ul>
+ </topic>
+ <topic id="Options" title="Options">
+ <heading scroll="no">Options</heading>
+ <p><kin>PumpKIN</kin> options property sheet consists of two tabs. For more information see <a href="#NetworkOptions"><b>Network</b></a> and <a herf="#ServerOptions"><b>Server</b></a> options.</p>
+ </topic>
+ <topic id="NetworkOptions" title="Network Options">
+ <heading scroll="no">Network Options</heading>
+ <ul>
+ <li><b>UDP Ports</b>
+ <ul>
+ <li><b>Listen for incoming connections on port</b> - specifies the port we're listening to. The default as defined in <rfc num="1350"/> is 69.</li>
+ <li><b>Send outgoing requests to port</b> - specifies the port we're going to send all requests to.</li>
+ </ul>
+ </li>
+ <li><b>Default Connection timeout</b> - if there's no activity for specified time, transfer is considered to be dead and terminated. <kin>PumpKIN</kin> tries to propagate this value to remote as described in <rfc num="1782"/> and <rfc num="1784"/> if possible.</li>
+ <li><b>Default Block Size</b> - <kin>PumpKIN</kin> tries to negotiate block size with remote using this value unless specified explicitly in request. If remote doesn't support <rfc num="1782"/> and <rfc num="1783"/> <kin>PumpKIN</kin> falls back to 512 bytes per block.</li>
+ </ul>
+ </topic>
+ <topic id="ServerOptions" title="Server Options">
+ <heading scroll="no">Server Options</heading>
+ <ul>
+ <li><b>TFTP Filesystem root</b> - Specifies the location of files you're transmitting or where to start looking for them from. Defaults to the directory you start <kin>PumpKIN</kin> for the first time from.</li>
+ <li><b>Allow access to subdirectories</b> - specifies whether you want allow access to the whole subtree of <b>TFTP Root</b> or only to the directory itself.</li>
+ <li><b>Read Request Behavior</b> - You may choose to automatically agree to give all files requested, to be prompted to confirm these operations, or to deny all requests as if you're not even here.</li>
+ <li><b>Write Request Behavior</b> - You may chose to <b>take all files</b> (<i>not recommended</i>), to <b>prompt only if file exists already</b>, <b>Always prompt</b> or <b>Deny all requests</b>.</li>
+ <li><a name="ConfirmationTimeOut"/><b>Confirmation timeout</b> - this is the time <kin>PumpKIN</kin> will wait for you to accept or deny request before it will give up and take default action which is always deny.</li>
+ </ul>
+ </topic>
+ <topic id="SoundsOptoins" title="Sounds Options">
+ <heading scroll="no">Sounds</heading>
+ <p>You can customize <kin>PumpKIN</kin> sounds notifications here. There are three customizable sounds defined - <b>Incoming request</b>, which notifies you about incoming request prompt if you're set to be prompted whenever incoming request occurs. <b>xfer Aborted</b> - which happens to sound every time transfer is interrupted for whatever reason - time out, explicit kill, denied access, etc. <b>xfer Finished</b> means that your file was successfully transmitted.</p>
+ <p>You can select any <b>.wav</b> file or one of the predefined sounds from the dropdown list.</p>
+ </topic>
+</winhelp>
diff --git a/install/custom.rch b/install/custom.rch
new file mode 100644
index 0000000..d37b074
--- a/dev/null
+++ b/install/custom.rch
@@ -0,0 +1,10 @@
+#ifdef STATI_K
+PumpKIN.ex_ rcdata discardable "../releast/pumpkin.ex_"
+#else
+PumpKIN.ex_ rcdata discardable "../release/pumpkin.ex_"
+#endif
+PumpKIN.cn_ rcdata discardable "../release/pumpkin.cn_"
+PumpKIN.hl_ rcdata discardable "../release/pumpkin.hl_"
+#ifdef K_ANNED
+mfc42.dl_ rcdata discardable "../redist/mfc42.dl_"
+#endif
diff --git a/install/install.cpp b/install/install.cpp
new file mode 100644
index 0000000..4e518d5
--- a/dev/null
+++ b/install/install.cpp
@@ -0,0 +1,67 @@
+#include "resource.h"
+#include "../shared-code/install.h"
+
+#define KINAME "PumpKIN 2.5"
+#define SKINAME "PumpKIN"
+
+BOOL Install(void)
+{
+STRING dPath = strFETCH_REG_KEY(HKEY_LOCAL_MACHINE,"Software\\Klever Group, Inc.",SKINAME "Path");
+STRING kPath = strFETCH_REG_KEY(HKEY_LOCAL_MACHINE,"Software\\Klever Group, Inc.","KINPath");
+LPCSTR qPath = ((LPCSTR)dPath)?(LPCSTR)dPath:(((LPCSTR)kPath)?(LPSTR)kPath:"C:\\Program Files\\Klever\\Nothings");
+STRING path = REQUESTPATH(" " KINAME,"\nEnter destination path:",qPath);
+ if(!path)
+ return NULL;
+
+#ifdef K_ANNED
+STRING sysDir(_MAX_PATH);
+ GetSystemDirectory(sysDir,_MAX_PATH);
+ INSTALLFILE("mfc42.dl_",sysDir,"mfc42.dll");
+#endif
+
+ MAKE_PATH(path);
+STRING shortPath = GET_SHORT_PATH(path);
+ if(!shortPath){
+ MessageBox(NULL,"Failed to install " KINAME " in specified directory",NULL,MB_ICONERROR|MB_OK);
+ return FALSE;
+ }
+
+ if(!(
+ INSTALLFILE(SKINAME ".ex_",path,SKINAME ".exe") &&
+ INSTALLFILE(SKINAME ".hl_",path,SKINAME ".hlp") &&
+ INSTALLFILE(SKINAME ".cn_",path,SKINAME ".cnt")
+ )){
+ MessageBox(NULL,"Failed to install " KINAME " in specified directory",NULL,MB_ICONERROR|MB_OK);
+ return FALSE;
+ }
+ ADDMENU("Accessories\\Klever Co.",SKINAME,path, SKINAME ".exe");
+
+ strSET_REG_KEY(HKEY_LOCAL_MACHINE,"Software\\Klever Group, Inc.",SKINAME "Path",path);
+ strSET_REG_KEY(HKEY_LOCAL_MACHINE,"Software\\Klever Group, Inc.","KINPath",path);
+
+FILE* inf=CREATE_INF_FILE(path,SKINAME ".INF");
+ if(!inf){
+ MessageBox(NULL,"Failed to install " KINAME,NULL,MB_ICONERROR|MB_OK);
+ return FALSE;
+ }
+ INF_FILE_HEADER(inf);
+ INF_FILE_SECTION(inf,"Uninstall");
+ fprintf(inf,"AddReg=kFiles\nDelReg=kReg\nUpdateInis=kMenu\n");
+ INF_FILE_SECTION(inf,"kFiles");
+ INF_REMOVE_ROOT(inf,SKINAME "Files",shortPath);
+ INF_REMOVE_FILE(inf,SKINAME "Files",SKINAME ".exe");
+ INF_REMOVE_HELP_FILE(inf,SKINAME "Files",SKINAME);
+ INF_REMOVE_FILE(inf,SKINAME "Files",SKINAME ".inf");
+ INF_FILE_SECTION(inf,"kReg");
+ INF_UNINSTALL_REG(inf,SKINAME);
+ INF_FILE_SECTION(inf,"kMenu");
+ INF_MENU_GROUP(inf,1,"Accessories\\Klever Co.");
+ INF_MENU_ITEM(inf,1,SKINAME);
+ fclose(inf);
+
+ REG_UNINSTALL_COMMAND(SKINAME,"Klever " KINAME,shortPath,SKINAME ".INF","Uninstall");
+
+ MessageBox(NULL,KINAME " installed successfully, you may now run it from Programs/Accessories/Klever Co. menu or remove it using Control Panel Add/Remove Programs applet."," Rejoice!",MB_ICONINFORMATION|MB_OK);
+
+ return TRUE;
+}
diff --git a/install/install.rc b/install/install.rc
new file mode 100644
index 0000000..b4eeb01
--- a/dev/null
+++ b/install/install.rc
@@ -0,0 +1,182 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+#if defined(APSTUDIO_INVOKED) || defined(FALSE)
+#if defined(APSTUDIO_INVOKED)
+IDD_INSTALLING$(FALSE) DIALOGEX 0, 0, 200, 74
+#else
+IDD_INSTALLING DIALOGEX 0, 0, 200, 74
+#endif
+STYLE DS_MODALFRAME | DS_3DLOOK | WS_POPUP
+FONT 8, "MS Sans Serif", 0, 0, 0x1
+BEGIN
+ PUSHBUTTON "Cancel",IDCANCEL,143,53,50,14,BS_CENTER | BS_VCENTER |
+ BS_NOTIFY | BS_FLAT,WS_EX_DLGMODALFRAME
+ CONTROL "Animate1",IDC_DISKS,"SysAnimate32",ACS_TRANSPARENT |
+ ACS_AUTOPLAY | WS_TABSTOP,161,7,32,32
+ LTEXT "",IDC_STATE,7,7,150,32,SS_NOPREFIX | SS_NOTIFY
+ CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",0x0,7,45,
+ 186,7,WS_EX_DLGMODALFRAME
+END
+#endif
+
+IDD_PATH DIALOGEX 0, 0, 255, 73
+STYLE DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_CENTER | WS_POPUP |
+ WS_VISIBLE | WS_CAPTION
+EXSTYLE WS_EX_TOOLWINDOW | WS_EX_CLIENTEDGE
+FONT 8, "MS Sans Serif", 0, 0, 0x1
+BEGIN
+ LTEXT "",IDC_PROMPT,7,7,241,30
+ EDITTEXT IDC_PATH,7,37,195,12,ES_AUTOHSCROLL
+ PUSHBUTTON "B&rowse..",IDC_BROWSE,208,37,40,12
+ DEFPUSHBUTTON "OK",IDOK,69,52,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,135,52,50,14
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO DISCARDABLE
+BEGIN
+ "IDD_INSTALLING$(FALSE)", DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 193
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 67
+ HORZGUIDE, 39
+ END
+
+ IDD_PATH, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 248
+ VERTGUIDE, 202
+ VERTGUIDE, 208
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 66
+ HORZGUIDE, 37
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#include ""afxres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#include ""custom.rch""\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_ICON ICON DISCARDABLE "../shared-data/install-icon.ico"
+
+#ifndef _MAC
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 2,5,0,0
+ PRODUCTVERSION 2,5,0,0
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x40004L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "CompanyName", "Klever Group (http://www.klever.net/)\0"
+ VALUE "FileDescription", "INSTALL: PumpKIN, tftp client/daemon\0"
+ VALUE "FileVersion", "2, 5, 0, 0\0"
+ VALUE "InternalName", "INSTALL\0"
+ VALUE "LegalCopyright", "Copyright © 1997, 1998, 2002 Klever Group (http://www.klever.net/)\0"
+ VALUE "LegalTrademarks", "Klever Group (http://www.klever.net/)\0"
+ VALUE "OriginalFilename", "INSTALL.EXE\0"
+ VALUE "ProductName", "PumpKIN\0"
+ VALUE "ProductVersion", "2, 5, 0, 0\0"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
+
+#endif // !_MAC
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+#include "custom.rch"
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/install/resource.h b/install/resource.h
new file mode 100644
index 0000000..ebf7991
--- a/dev/null
+++ b/install/resource.h
@@ -0,0 +1,24 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by Install.rc
+//
+#define IDD_INSTALLING 101
+#define IDD_PATH 102
+#define IDI_ICON 105
+#define IDC_DISKS 1000
+#define IDC_STATE 1001
+#define IDC_PROGRESS 1002
+#define IDC_PROMPT 1003
+#define IDC_PATH 1004
+#define IDC_BROWSE 1005
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 107
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1006
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/makehelp.bat b/makehelp.bat
new file mode 100644
index 0000000..4132ec8
--- a/dev/null
+++ b/makehelp.bat
@@ -0,0 +1,32 @@
+@echo off
+REM -- First make map file from Microsoft Visual C++ generated resource.h
+echo // MAKEHELP.BAT generated Help Map file. Used by PUMPKIN.HPJ. >"help\pumpkin.hm"
+echo. >>"help\pumpkin.hm"
+echo // Commands (ID_* and IDM_*) >>"help\pumpkin.hm"
+makehm ID_,HID_,0x10000 IDM_,HIDM_,0x10000 resource.h >>"help\pumpkin.hm"
+echo. >>"help\pumpkin.hm"
+echo // Prompts (IDP_*) >>"help\pumpkin.hm"
+makehm IDP_,HIDP_,0x30000 resource.h >>"help\pumpkin.hm"
+echo. >>"help\pumpkin.hm"
+echo // Resources (IDR_*) >>"help\pumpkin.hm"
+makehm IDR_,HIDR_,0x20000 resource.h >>"help\pumpkin.hm"
+echo. >>"help\pumpkin.hm"
+echo // Dialogs (IDD_*) >>"help\pumpkin.hm"
+makehm IDD_,HIDD_,0x20000 resource.h >>"help\pumpkin.hm"
+echo. >>"help\pumpkin.hm"
+echo // Frame Controls (IDW_*) >>"help\pumpkin.hm"
+makehm IDW_,HIDW_,0x50000 resource.h >>"help\pumpkin.hm"
+REM -- Make help for Project PUMPKIN
+
+echo Building RTF file
+xsltproc -o help/pumpkin.rtf shared-code/kinhelp.xsl help/pumpkin.xml
+echo Building Win32 Help files
+start /wait hcrtf -x "help\pumpkin.hpj"
+echo.
+if exist Debug\nul copy "help\pumpkin.hlp" Debug
+if exist Debug\nul copy "help\pumpkin.cnt" Debug
+if exist Release\nul copy "help\pumpkin.hlp" Release
+if exist Release\nul copy "help\pumpkin.cnt" Release
+if exist Releast\nul copy "help\pumpkin.hlp" Releast
+if exist Releast\nul copy "help\pumpkin.cnt" Releast
+echo.
diff --git a/pumpkin.clw b/pumpkin.clw
new file mode 100644
index 0000000..4ae747b
--- a/dev/null
+++ b/pumpkin.clw
@@ -0,0 +1,283 @@
+; CLW file contains information for the MFC ClassWizard
+
+[General Info]
+Version=1
+LastClass=CPropsSounds
+LastTemplate=CPropertyPage
+NewFileInclude1=#include "stdafx.h"
+NewFileInclude2=#include "PumpKIN.h"
+
+ClassCount=12
+Class1=CPumpKINApp
+Class2=CPumpKINDlg
+Class3=CAboutDlg
+
+ResourceCount=9
+Resource1=IDD_REQUEST
+Resource2=IDD_PROPS_SERVER
+Resource3=IDD_CONFIRM_RRQ
+Resource4=IDD_ABOUTBOX
+Class4=CPropsServer
+Class5=CPropsNetwork
+Resource5=IDD_CONFIRM_WRQ
+Resource6=IDD_PROPS_NETWORK
+Class6=CConfirmRRQDlg
+Class7=CConfirmWRQDlg
+Resource7=IDD_PUMPKIN_DIALOG
+Class8=CRequestDlg
+Class9=CResolver
+Class10=CRetrier
+Class11=CTrayer
+Resource8=IDD_PROPS_SOUNDS
+Class12=CPropsSounds
+Resource9=IDM_POPUPS
+
+[CLS:CPumpKINApp]
+Type=0
+HeaderFile=PumpKIN.h
+ImplementationFile=PumpKIN.cpp
+Filter=N
+
+[CLS:CPumpKINDlg]
+Type=0
+HeaderFile=PumpKINDlg.h
+ImplementationFile=PumpKINDlg.cpp
+Filter=W
+BaseClass=CDialog
+VirtualFilter=dWC
+LastObject=ID_HELP
+
+[CLS:CAboutDlg]
+Type=0
+HeaderFile=PumpKINDlg.h
+ImplementationFile=PumpKINDlg.cpp
+Filter=D
+BaseClass=CDialog
+VirtualFilter=dWC
+LastObject=CAboutDlg
+
+[DLG:IDD_ABOUTBOX]
+Type=1
+Class=CAboutDlg
+ControlCount=5
+Control1=IDC_STATIC,static,1342177283
+Control2=IDC_STATIC,static,1342308480
+Control3=IDC_STATIC,static,1342308352
+Control4=IDOK,button,1342373889
+Control5=IDC_KLEVERNET,button,1342242816
+
+[DLG:IDD_PUMPKIN_DIALOG]
+Type=1
+Class=CPumpKINDlg
+ControlCount=9
+Control1=IDC_CONNECTIONS,SysListView32,1350631681
+Control2=IDC_GET,button,1342259200
+Control3=IDC_PUT,button,1342259200
+Control4=IDC_ABORT,button,1342259200
+Control5=IDC_OPTIONS,button,1342259200
+Control6=IDC_EXIT,button,1342259200
+Control7=ID_HELP,button,1342259200
+Control8=IDC_LOG,listbox,1353728129
+Control9=IDCANCEL,button,1073741824
+
+[DLG:IDD_PROPS_SERVER]
+Type=1
+Class=CPropsServer
+ControlCount=15
+Control1=IDC_STATIC,button,1342177287
+Control2=IDC_TFTPROOT,edit,1350631552
+Control3=IDC_BROWSE,button,1342242880
+Control4=IDC_TFTPSUBDIRS,button,1342242819
+Control5=IDC_STATIC,button,1342177287
+Control6=IDC_RRQ_GIVEALL,button,1342324745
+Control7=IDC_RRQ_ALWAYSCONFIRM,button,1342193673
+Control8=IDC_RRQ_DENYALL,button,1342193673
+Control9=IDC_STATIC,button,1342308359
+Control10=IDC_WRQ_TAKEALL,button,1342308361
+Control11=IDC_WRQ_PROMPTEXISTING,button,1342177289
+Control12=IDC_WRQ_ALWAYSCONFIRM,button,1342177289
+Control13=IDC_WRQ_DENYALL,button,1342177289
+Control14=IDC_STATIC,static,1342308609
+Control15=IDC_PROMPTTIMEOUT,msctls_trackbar32,1342242823
+
+[DLG:IDD_PROPS_NETWORK]
+Type=1
+Class=CPropsNetwork
+ControlCount=15
+Control1=IDC_STATIC,button,1342177287
+Control2=IDC_STATIC,static,1342308354
+Control3=IDC_LISTENPORT,edit,1350631552
+Control4=IDC_LISTENSPIN,msctls_updown32,1342177463
+Control5=IDC_STATIC,static,1342308354
+Control6=IDC_SPEAKPORT,edit,1350631552
+Control7=IDC_SPEAKSPIN,msctls_updown32,1342177463
+Control8=IDC_STATIC,static,1342308352
+Control9=IDC_TIMEOUT,edit,1350639744
+Control10=IDC_TIMESPIN,msctls_updown32,1342177463
+Control11=IDC_STATIC,static,1342308352
+Control12=IDC_STATIC,static,1342308352
+Control13=IDC_STATIC,static,1342308352
+Control14=IDC_BLOCKSIZE,edit,1350639744
+Control15=IDC_BSIZESPIN,msctls_updown32,1342177463
+
+[CLS:CPropsServer]
+Type=0
+HeaderFile=PropsServer.h
+ImplementationFile=PropsServer.cpp
+BaseClass=CPropertyPage
+Filter=D
+VirtualFilter=idWC
+LastObject=CPropsServer
+
+[CLS:CPropsNetwork]
+Type=0
+HeaderFile=PropsNetwork.h
+ImplementationFile=PropsNetwork.cpp
+BaseClass=CPropertyPage
+Filter=D
+VirtualFilter=idWC
+LastObject=CPropsNetwork
+
+[DLG:IDD_CONFIRM_RRQ]
+Type=1
+Class=CConfirmRRQDlg
+ControlCount=9
+Control1=IDOK,button,1342242817
+Control2=IDCANCEL,button,1342242816
+Control3=IDC_STATIC,static,1342308352
+Control4=IDC_HOST,static,1350701313
+Control5=IDC_STATIC,static,1342308353
+Control6=IDC_FILE,static,1350701313
+Control7=IDC_STATIC,static,1342177296
+Control8=IDC_STATIC,static,1342177283
+Control9=IDC_STATIC,static,1342177283
+
+[DLG:IDD_CONFIRM_WRQ]
+Type=1
+Class=CConfirmWRQDlg
+ControlCount=11
+Control1=IDOK,button,1342242817
+Control2=IDC_RENAME,button,1342242816
+Control3=IDCANCEL,button,1342242816
+Control4=IDC_STATIC,static,1342308352
+Control5=IDC_HOST,static,1350701313
+Control6=IDC_STATIC,static,1342308353
+Control7=IDC_FILE,static,1350701313
+Control8=IDC_STATIC,static,1342177296
+Control9=IDC_STATIC,static,1342177283
+Control10=IDC_STATIC,static,1342177283
+Control11=IDC_RESUME,button,1342242816
+
+[CLS:CConfirmRRQDlg]
+Type=0
+HeaderFile=ConfirmRRQDlg.h
+ImplementationFile=ConfirmRRQDlg.cpp
+BaseClass=CDialog
+Filter=D
+VirtualFilter=dWC
+LastObject=CConfirmRRQDlg
+
+[CLS:CConfirmWRQDlg]
+Type=0
+HeaderFile=ConfirmWRQDlg.h
+ImplementationFile=ConfirmWRQDlg.cpp
+BaseClass=CDialog
+Filter=D
+VirtualFilter=dWC
+LastObject=IDC_RESUME
+
+[DLG:IDD_REQUEST]
+Type=1
+Class=CRequestDlg
+ControlCount=15
+Control1=IDC_STATIC,static,1342308608
+Control2=IDC_LOCALFILE,edit,1350631552
+Control3=IDC_BROWSE,button,1342242880
+Control4=IDC_STATIC,static,1342308608
+Control5=IDC_REMOTEFILE,edit,1350631552
+Control6=IDC_STATIC,static,1342308608
+Control7=IDC_TALKS,combobox,1344341313
+Control8=IDC_REFRESH,button,1342271232
+Control9=IDC_STATIC,static,1342308352
+Control10=IDC_TYPE,combobox,1344356418
+Control11=IDC_STATIC,static,1342308352
+Control12=IDC_BSIZE,combobox,1344339970
+Control13=IDOK,button,1342242817
+Control14=IDCANCEL,button,1342242816
+Control15=IDC_STATIC,static,1342177297
+
+[CLS:CRequestDlg]
+Type=0
+HeaderFile=RequestDlg.h
+ImplementationFile=RequestDlg.cpp
+BaseClass=CDialog
+Filter=W
+VirtualFilter=dWC
+LastObject=CRequestDlg
+
+[CLS:CResolver]
+Type=0
+HeaderFile=Resolver.h
+ImplementationFile=Resolver.cpp
+BaseClass=CWnd
+Filter=W
+LastObject=CResolver
+VirtualFilter=WC
+
+[MNU:IDM_POPUPS]
+Type=1
+Class=CPumpKINDlg
+Command1=ID_TRAY_SENDFILE
+Command2=ID_TRAY_FETCHFILE
+Command3=ID_TRAY_OPTIONS
+Command4=ID_TRAY_SHOWPUMPKINWINDOW
+Command5=ID_TRAY_OPENFILESFOLDER
+Command6=ID_TRAY_HELP
+Command7=ID_TRAY_ABOUTPUMPKIN
+Command8=ID_TRAY_EXIT
+CommandCount=8
+
+[CLS:CRetrier]
+Type=0
+HeaderFile=Retrier.h
+ImplementationFile=Retrier.cpp
+BaseClass=CWnd
+Filter=W
+LastObject=CRetrier
+VirtualFilter=WC
+
+[CLS:CTrayer]
+Type=0
+HeaderFile=Trayer.h
+ImplementationFile=Trayer.cpp
+BaseClass=CWnd
+Filter=W
+LastObject=CTrayer
+VirtualFilter=WC
+
+[DLG:IDD_PROPS_SOUNDS]
+Type=1
+Class=CPropsSounds
+ControlCount=12
+Control1=IDC_STATIC,static,1342308352
+Control2=IDC_RING,combobox,1344340290
+Control3=IDC_RING_BROWSE,button,1342242880
+Control4=IDC_RING_PLAY,button,1342242880
+Control5=IDC_STATIC,static,1342308352
+Control6=IDC_FINISHED,combobox,1344340290
+Control7=IDC_FINISHED_BROWSE,button,1342242880
+Control8=IDC_FINISHED_PLAY,button,1342242880
+Control9=IDC_STATIC,static,1342308352
+Control10=IDC_ABORTED,combobox,1344340290
+Control11=IDC_ABORTED_BROWSE,button,1342242880
+Control12=IDC_ABORTED_PLAY,button,1342242880
+
+[CLS:CPropsSounds]
+Type=0
+HeaderFile=PropsSounds.h
+ImplementationFile=PropsSounds.cpp
+BaseClass=CPropertyPage
+Filter=D
+LastObject=CPropsSounds
+VirtualFilter=idWC
+
diff --git a/pumpkin.cpp b/pumpkin.cpp
new file mode 100644
index 0000000..c086fb3
--- a/dev/null
+++ b/pumpkin.cpp
@@ -0,0 +1,69 @@
+// PumpKIN.cpp : Defines the class behaviors for the application.
+//
+
+#include "stdafx.h"
+#include "PumpKIN.h"
+#include "PumpKINDlg.h"
+
+#ifdef _DEBUG
+#define new DEBUG_NEW
+#undef THIS_FILE
+static char THIS_FILE[] = __FILE__;
+#endif
+
+/////////////////////////////////////////////////////////////////////////////
+// CPumpKINApp
+
+BEGIN_MESSAGE_MAP(CPumpKINApp, CWinApp)
+ //{{AFX_MSG_MAP(CPumpKINApp)
+ //}}AFX_MSG
+ ON_COMMAND(ID_HELP, CWinApp::OnHelp)
+END_MESSAGE_MAP()
+
+/////////////////////////////////////////////////////////////////////////////
+// CPumpKINApp construction
+
+CPumpKINApp::CPumpKINApp()
+{
+}
+
+/////////////////////////////////////////////////////////////////////////////
+// The one and only CPumpKINApp object
+
+CPumpKINApp theApp;
+
+/////////////////////////////////////////////////////////////////////////////
+// CPumpKINApp initialization
+
+BOOL CPumpKINApp::InitInstance()
+{
+ if (!AfxSocketInit())
+ {
+ AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
+ return FALSE;
+ }
+
+ // Standard initialization
+ // If you are not using these features and wish to reduce the size
+ // of your final executable, you should remove from the following
+ // the specific initialization routines you do not need.
+
+#ifdef _AFXDLL
+ Enable3dControls(); // Call this when using MFC in a shared DLL
+#else
+ Enable3dControlsStatic(); // Call this when linking to MFC statically
+#endif
+
+ SetRegistryKey(IDS_REGISTRYKEY);
+ m_HelpFile = m_pszHelpFilePath;
+ m_HelpFile+=">Standard";
+ m_pszHelpFilePath=(LPCTSTR)m_HelpFile;
+
+ CPumpKINDlg dlg;
+ m_pMainWnd = &dlg;
+ int nResponse = dlg.DoModal();
+
+ // Since the dialog has been closed, return FALSE so that we exit the
+ // application, rather than start the application's message pump.
+ return FALSE;
+}
diff --git a/pumpkin.h b/pumpkin.h
new file mode 100644
index 0000000..71c720e
--- a/dev/null
+++ b/pumpkin.h
@@ -0,0 +1,36 @@
+// PumpKIN.h : main header file for the PUMPKIN application
+//
+
+#ifndef __AFXWIN_H__
+ #error include 'stdafx.h' before including this file for PCH
+#endif
+
+#include "resource.h" // main symbols
+
+/////////////////////////////////////////////////////////////////////////////
+// CPumpKINApp:
+// See PumpKIN.cpp for the implementation of this class
+//
+
+class CPumpKINApp : public CWinApp
+{
+public:
+ CString m_HelpFile;
+ CPumpKINApp();
+
+// Overrides
+ // ClassWizard generated virtual function overrides
+ //{{AFX_VIRTUAL(CPumpKINApp)
+ public:
+ virtual BOOL InitInstance();
+ //}}AFX_VIRTUAL
+
+// Implementation
+
+ //{{AFX_MSG(CPumpKINApp)
+ //}}AFX_MSG
+ DECLARE_MESSAGE_MAP()
+};
+
+
+/////////////////////////////////////////////////////////////////////////////
diff --git a/pumpkin.mak b/pumpkin.mak
new file mode 100644
index 0000000..9a40fa2
--- a/dev/null
+++ b/pumpkin.mak
@@ -0,0 +1,1429 @@
+# Microsoft Developer Studio Generated NMAKE File, Format Version 4.20
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Application" 0x0101
+
+!IF "$(CFG)" == ""
+CFG=Install - Win32 Debug
+!MESSAGE No configuration specified. Defaulting to Install - Win32 Debug.
+!ENDIF
+
+!IF "$(CFG)" != "PumpKIN - Win32 Release" && "$(CFG)" !=\
+ "PumpKIN - Win32 Debug" && "$(CFG)" != "PumpKIN - Win32 Static" && "$(CFG)" !=\
+ "Install - Win32 Debug" && "$(CFG)" != "Install - Win32 Pure" && "$(CFG)" !=\
+ "Install - Win32 Static" && "$(CFG)" != "Install - Win32 Canned"
+!MESSAGE Invalid configuration "$(CFG)" specified.
+!MESSAGE You can specify a configuration when running NMAKE on this makefile
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "pumpkin.mak" CFG="Install - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "PumpKIN - Win32 Release" (based on "Win32 (x86) Application")
+!MESSAGE "PumpKIN - Win32 Debug" (based on "Win32 (x86) Application")
+!MESSAGE "PumpKIN - Win32 Static" (based on "Win32 (x86) Application")
+!MESSAGE "Install - Win32 Debug" (based on "Win32 (x86) Application")
+!MESSAGE "Install - Win32 Pure" (based on "Win32 (x86) Application")
+!MESSAGE "Install - Win32 Static" (based on "Win32 (x86) Application")
+!MESSAGE "Install - Win32 Canned" (based on "Win32 (x86) Application")
+!MESSAGE
+!ERROR An invalid configuration is specified.
+!ENDIF
+
+!IF "$(OS)" == "Windows_NT"
+NULL=
+!ELSE
+NULL=nul
+!ENDIF
+################################################################################
+# Begin Project
+# PROP Target_Last_Scanned "Install - Win32 Canned"
+RSC=rc.exe
+MTL=mktyplib.exe
+CPP=cl.exe
+
+!IF "$(CFG)" == "PumpKIN - Win32 Release"
+
+# PROP BASE Use_MFC 6
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 6
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+OUTDIR=.\Release
+INTDIR=.\Release
+# Begin Custom Macros
+OutDir=.\Release
+TargetName=pumpkin
+# End Custom Macros
+
+ALL : "$(OUTDIR)\pumpkin.exe" "$(OUTDIR)\pumpkin.ex_" "$(OUTDIR)\pumpkin.hlp"\
+ "$(OUTDIR)\pumpkin.cnt" "$(OUTDIR)\pumpkin.hl_" "$(OUTDIR)\pumpkin.cn_"
+
+CLEAN :
+ -@erase "$(INTDIR)\ConfirmRRQDlg.obj"
+ -@erase "$(INTDIR)\ConfirmWRQDlg.obj"
+ -@erase "$(INTDIR)\PropsNetwork.obj"
+ -@erase "$(INTDIR)\PropsServer.obj"
+ -@erase "$(INTDIR)\PropsSounds.obj"
+ -@erase "$(INTDIR)\pumpkin.cn_"
+ -@erase "$(INTDIR)\pumpkin.cnt"
+ -@erase "$(INTDIR)\pumpkin.hl_"
+ -@erase "$(INTDIR)\pumpkin.hlp"
+ -@erase "$(INTDIR)\PumpKIN.obj"
+ -@erase "$(INTDIR)\pumpkin.pch"
+ -@erase "$(INTDIR)\PumpKIN.res"
+ -@erase "$(INTDIR)\PumpKINDlg.obj"
+ -@erase "$(INTDIR)\RequestDlg.obj"
+ -@erase "$(INTDIR)\Resolver.obj"
+ -@erase "$(INTDIR)\Retrier.obj"
+ -@erase "$(INTDIR)\StdAfx.obj"
+ -@erase "$(INTDIR)\Trayer.obj"
+ -@erase "$(OUTDIR)\pumpkin.ex_"
+ -@erase "$(OUTDIR)\pumpkin.exe"
+
+"$(OUTDIR)" :
+ if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /c
+# ADD CPP /nologo /Zp1 /MD /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /c
+CPP_PROJ=/nologo /Zp1 /MD /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D\
+ "_AFXDLL" /D "_MBCS" /Fp"$(INTDIR)/pumpkin.pch" /Yu"stdafx.h" /Fo"$(INTDIR)/"\
+ /c
+CPP_OBJS=.\Release/
+CPP_SBRS=.\.
+# ADD BASE MTL /nologo /D "NDEBUG" /win32
+# ADD MTL /nologo /D "NDEBUG" /win32
+MTL_PROJ=/nologo /D "NDEBUG" /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
+# ADD RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
+RSC_PROJ=/l 0x409 /fo"$(INTDIR)/PumpKIN.res" /d "NDEBUG" /d "_AFXDLL"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+BSC32_FLAGS=/nologo /o"$(OUTDIR)/pumpkin.bsc"
+BSC32_SBRS= \
+
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
+# ADD LINK32 /nologo /subsystem:windows /machine:I386
+LINK32_FLAGS=/nologo /subsystem:windows /incremental:no\
+ /pdb:"$(OUTDIR)/pumpkin.pdb" /machine:I386 /out:"$(OUTDIR)/pumpkin.exe"
+LINK32_OBJS= \
+ "$(INTDIR)\ConfirmRRQDlg.obj" \
+ "$(INTDIR)\ConfirmWRQDlg.obj" \
+ "$(INTDIR)\PropsNetwork.obj" \
+ "$(INTDIR)\PropsServer.obj" \
+ "$(INTDIR)\PropsSounds.obj" \
+ "$(INTDIR)\PumpKIN.obj" \
+ "$(INTDIR)\PumpKIN.res" \
+ "$(INTDIR)\PumpKINDlg.obj" \
+ "$(INTDIR)\RequestDlg.obj" \
+ "$(INTDIR)\Resolver.obj" \
+ "$(INTDIR)\Retrier.obj" \
+ "$(INTDIR)\StdAfx.obj" \
+ "$(INTDIR)\Trayer.obj"
+
+"$(OUTDIR)\pumpkin.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+# Begin Custom Build
+OutDir=.\Release
+TargetName=pumpkin
+InputPath=.\Release\pumpkin.exe
+SOURCE=$(InputPath)
+
+"$(OutDir)\$(TargetName).ex_" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ compress $(OutDir)\$(TargetName).exe $(OutDir)\$(TargetName).ex_
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug"
+
+# PROP BASE Use_MFC 6
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 6
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Target_Dir ""
+OUTDIR=.\Debug
+INTDIR=.\Debug
+# Begin Custom Macros
+OutDir=.\Debug
+TargetName=pumpkin
+# End Custom Macros
+
+ALL : "$(OUTDIR)\pumpkin.exe" "$(OUTDIR)\pumpkin.bsc" "$(OUTDIR)\pumpkin.ex_"\
+ "$(OUTDIR)\pumpkin.hlp" "$(OUTDIR)\pumpkin.cnt" "$(OUTDIR)\pumpkin.hl_"\
+ "$(OUTDIR)\pumpkin.cn_"
+
+CLEAN :
+ -@erase "$(INTDIR)\ConfirmRRQDlg.obj"
+ -@erase "$(INTDIR)\ConfirmRRQDlg.sbr"
+ -@erase "$(INTDIR)\ConfirmWRQDlg.obj"
+ -@erase "$(INTDIR)\ConfirmWRQDlg.sbr"
+ -@erase "$(INTDIR)\PropsNetwork.obj"
+ -@erase "$(INTDIR)\PropsNetwork.sbr"
+ -@erase "$(INTDIR)\PropsServer.obj"
+ -@erase "$(INTDIR)\PropsServer.sbr"
+ -@erase "$(INTDIR)\PropsSounds.obj"
+ -@erase "$(INTDIR)\PropsSounds.sbr"
+ -@erase "$(INTDIR)\pumpkin.cn_"
+ -@erase "$(INTDIR)\pumpkin.cnt"
+ -@erase "$(INTDIR)\pumpkin.hl_"
+ -@erase "$(INTDIR)\pumpkin.hlp"
+ -@erase "$(INTDIR)\PumpKIN.obj"
+ -@erase "$(INTDIR)\pumpkin.pch"
+ -@erase "$(INTDIR)\PumpKIN.res"
+ -@erase "$(INTDIR)\PumpKIN.sbr"
+ -@erase "$(INTDIR)\PumpKINDlg.obj"
+ -@erase "$(INTDIR)\PumpKINDlg.sbr"
+ -@erase "$(INTDIR)\RequestDlg.obj"
+ -@erase "$(INTDIR)\RequestDlg.sbr"
+ -@erase "$(INTDIR)\Resolver.obj"
+ -@erase "$(INTDIR)\Resolver.sbr"
+ -@erase "$(INTDIR)\Retrier.obj"
+ -@erase "$(INTDIR)\Retrier.sbr"
+ -@erase "$(INTDIR)\StdAfx.obj"
+ -@erase "$(INTDIR)\StdAfx.sbr"
+ -@erase "$(INTDIR)\Trayer.obj"
+ -@erase "$(INTDIR)\Trayer.sbr"
+ -@erase "$(INTDIR)\vc40.idb"
+ -@erase "$(INTDIR)\vc40.pdb"
+ -@erase "$(OUTDIR)\pumpkin.bsc"
+ -@erase "$(OUTDIR)\pumpkin.ex_"
+ -@erase "$(OUTDIR)\pumpkin.exe"
+ -@erase "$(OUTDIR)\pumpkin.ilk"
+ -@erase "$(OUTDIR)\pumpkin.pdb"
+
+"$(OUTDIR)" :
+ if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /c
+# ADD CPP /nologo /Zp1 /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR /Yu"stdafx.h" /c
+CPP_PROJ=/nologo /Zp1 /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D\
+ "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR"$(INTDIR)/" /Fp"$(INTDIR)/pumpkin.pch"\
+ /Yu"stdafx.h" /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c
+CPP_OBJS=.\Debug/
+CPP_SBRS=.\Debug/
+# ADD BASE MTL /nologo /D "_DEBUG" /win32
+# ADD MTL /nologo /D "_DEBUG" /win32
+MTL_PROJ=/nologo /D "_DEBUG" /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
+# ADD RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
+RSC_PROJ=/l 0x409 /fo"$(INTDIR)/PumpKIN.res" /d "_DEBUG" /d "_AFXDLL"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+BSC32_FLAGS=/nologo /o"$(OUTDIR)/pumpkin.bsc"
+BSC32_SBRS= \
+ "$(INTDIR)\ConfirmRRQDlg.sbr" \
+ "$(INTDIR)\ConfirmWRQDlg.sbr" \
+ "$(INTDIR)\PropsNetwork.sbr" \
+ "$(INTDIR)\PropsServer.sbr" \
+ "$(INTDIR)\PropsSounds.sbr" \
+ "$(INTDIR)\PumpKIN.sbr" \
+ "$(INTDIR)\PumpKINDlg.sbr" \
+ "$(INTDIR)\RequestDlg.sbr" \
+ "$(INTDIR)\Resolver.sbr" \
+ "$(INTDIR)\Retrier.sbr" \
+ "$(INTDIR)\StdAfx.sbr" \
+ "$(INTDIR)\Trayer.sbr"
+
+"$(OUTDIR)\pumpkin.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
+ $(BSC32) @<<
+ $(BSC32_FLAGS) $(BSC32_SBRS)
+<<
+
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386
+# ADD LINK32 /nologo /subsystem:windows /debug /machine:I386
+LINK32_FLAGS=/nologo /subsystem:windows /incremental:yes\
+ /pdb:"$(OUTDIR)/pumpkin.pdb" /debug /machine:I386 /out:"$(OUTDIR)/pumpkin.exe"
+LINK32_OBJS= \
+ "$(INTDIR)\ConfirmRRQDlg.obj" \
+ "$(INTDIR)\ConfirmWRQDlg.obj" \
+ "$(INTDIR)\PropsNetwork.obj" \
+ "$(INTDIR)\PropsServer.obj" \
+ "$(INTDIR)\PropsSounds.obj" \
+ "$(INTDIR)\PumpKIN.obj" \
+ "$(INTDIR)\PumpKIN.res" \
+ "$(INTDIR)\PumpKINDlg.obj" \
+ "$(INTDIR)\RequestDlg.obj" \
+ "$(INTDIR)\Resolver.obj" \
+ "$(INTDIR)\Retrier.obj" \
+ "$(INTDIR)\StdAfx.obj" \
+ "$(INTDIR)\Trayer.obj"
+
+"$(OUTDIR)\pumpkin.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+# Begin Custom Build
+OutDir=.\Debug
+TargetName=pumpkin
+InputPath=.\Debug\pumpkin.exe
+SOURCE=$(InputPath)
+
+"$(OutDir)\$(TargetName).ex_" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ compress $(OutDir)\$(TargetName).exe $(OutDir)\$(TargetName).ex_
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "PumpKIN - Win32 Static"
+
+# PROP BASE Use_MFC 6
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "PumpKIN_"
+# PROP BASE Intermediate_Dir "PumpKIN_"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 5
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Releast"
+# PROP Intermediate_Dir "Releast"
+# PROP Target_Dir ""
+OUTDIR=.\Releast
+INTDIR=.\Releast
+# Begin Custom Macros
+OutDir=.\Releast
+TargetName=pumpkin
+# End Custom Macros
+
+ALL : "$(OUTDIR)\pumpkin.exe" "$(OUTDIR)\pumpkin.ex_" "$(OUTDIR)\pumpkin.hlp"\
+ "$(OUTDIR)\pumpkin.cnt" "$(OUTDIR)\pumpkin.hl_" "$(OUTDIR)\pumpkin.cn_"
+
+CLEAN :
+ -@erase "$(INTDIR)\ConfirmRRQDlg.obj"
+ -@erase "$(INTDIR)\ConfirmWRQDlg.obj"
+ -@erase "$(INTDIR)\PropsNetwork.obj"
+ -@erase "$(INTDIR)\PropsServer.obj"
+ -@erase "$(INTDIR)\PropsSounds.obj"
+ -@erase "$(INTDIR)\pumpkin.cn_"
+ -@erase "$(INTDIR)\pumpkin.cnt"
+ -@erase "$(INTDIR)\pumpkin.hl_"
+ -@erase "$(INTDIR)\pumpkin.hlp"
+ -@erase "$(INTDIR)\PumpKIN.obj"
+ -@erase "$(INTDIR)\pumpkin.pch"
+ -@erase "$(INTDIR)\PumpKIN.res"
+ -@erase "$(INTDIR)\PumpKINDlg.obj"
+ -@erase "$(INTDIR)\RequestDlg.obj"
+ -@erase "$(INTDIR)\Resolver.obj"
+ -@erase "$(INTDIR)\Retrier.obj"
+ -@erase "$(INTDIR)\StdAfx.obj"
+ -@erase "$(INTDIR)\Trayer.obj"
+ -@erase "$(OUTDIR)\pumpkin.ex_"
+ -@erase "$(OUTDIR)\pumpkin.exe"
+
+"$(OUTDIR)" :
+ if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+# ADD BASE CPP /nologo /Zp1 /MD /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /c
+# ADD CPP /nologo /Zp1 /MT /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /c
+CPP_PROJ=/nologo /Zp1 /MT /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D\
+ "_MBCS" /Fp"$(INTDIR)/pumpkin.pch" /Yu"stdafx.h" /Fo"$(INTDIR)/" /c
+CPP_OBJS=.\Releast/
+CPP_SBRS=.\.
+# ADD BASE MTL /nologo /D "NDEBUG" /win32
+# ADD MTL /nologo /D "NDEBUG" /win32
+MTL_PROJ=/nologo /D "NDEBUG" /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
+# ADD RSC /l 0x409 /d "NDEBUG"
+RSC_PROJ=/l 0x409 /fo"$(INTDIR)/PumpKIN.res" /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+BSC32_FLAGS=/nologo /o"$(OUTDIR)/pumpkin.bsc"
+BSC32_SBRS= \
+
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
+# ADD LINK32 /nologo /subsystem:windows /machine:I386
+LINK32_FLAGS=/nologo /subsystem:windows /incremental:no\
+ /pdb:"$(OUTDIR)/pumpkin.pdb" /machine:I386 /out:"$(OUTDIR)/pumpkin.exe"
+LINK32_OBJS= \
+ "$(INTDIR)\ConfirmRRQDlg.obj" \
+ "$(INTDIR)\ConfirmWRQDlg.obj" \
+ "$(INTDIR)\PropsNetwork.obj" \
+ "$(INTDIR)\PropsServer.obj" \
+ "$(INTDIR)\PropsSounds.obj" \
+ "$(INTDIR)\PumpKIN.obj" \
+ "$(INTDIR)\PumpKIN.res" \
+ "$(INTDIR)\PumpKINDlg.obj" \
+ "$(INTDIR)\RequestDlg.obj" \
+ "$(INTDIR)\Resolver.obj" \
+ "$(INTDIR)\Retrier.obj" \
+ "$(INTDIR)\StdAfx.obj" \
+ "$(INTDIR)\Trayer.obj"
+
+"$(OUTDIR)\pumpkin.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+# Begin Custom Build
+OutDir=.\Releast
+TargetName=pumpkin
+InputPath=.\Releast\pumpkin.exe
+SOURCE=$(InputPath)
+
+"$(OutDir)\$(TargetName).ex_" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ compress $(OutDir)\$(TargetName).exe $(OutDir)\$(TargetName).ex_
+
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "Install - Win32 Debug"
+
+# PROP BASE Use_MFC 2
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Install\Debug"
+# PROP BASE Intermediate_Dir "Install\Debug"
+# PROP BASE Target_Dir "Install"
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Install\Debug"
+# PROP Intermediate_Dir "Install\Debug"
+# PROP Target_Dir "Install"
+OUTDIR=.\Install\Debug
+INTDIR=.\Install\Debug
+
+ALL : "$(OUTDIR)\Install.exe"
+
+CLEAN :
+ -@erase "$(INTDIR)\install.obj"
+ -@erase "$(INTDIR)\Install.res"
+ -@erase "$(INTDIR)\vc40.idb"
+ -@erase "$(INTDIR)\vc40.pdb"
+ -@erase "$(OUTDIR)\Install.exe"
+ -@erase "$(OUTDIR)\Install.ilk"
+ -@erase "$(OUTDIR)\Install.pdb"
+
+"$(OUTDIR)" :
+ if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /YX /c
+# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /c
+CPP_PROJ=/nologo /MLd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS"\
+ /D "_MBCS" /Fp"$(INTDIR)/Install.pch" /YX /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c
+CPP_OBJS=.\Install\Debug/
+CPP_SBRS=.\.
+# ADD BASE MTL /nologo /D "_DEBUG" /win32
+# ADD MTL /nologo /D "_DEBUG" /win32
+MTL_PROJ=/nologo /D "_DEBUG" /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
+# ADD RSC /l 0x409 /d "_DEBUG"
+RSC_PROJ=/l 0x409 /fo"$(INTDIR)/Install.res" /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+BSC32_FLAGS=/nologo /o"$(OUTDIR)/Install.bsc"
+BSC32_SBRS= \
+
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib version.lib /nologo /subsystem:windows /debug /machine:I386
+LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
+ advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
+ odbccp32.lib version.lib /nologo /subsystem:windows /incremental:yes\
+ /pdb:"$(OUTDIR)/Install.pdb" /debug /machine:I386 /out:"$(OUTDIR)/Install.exe"
+LINK32_OBJS= \
+ "$(INTDIR)\install.obj" \
+ "$(INTDIR)\Install.res"
+
+"$(OUTDIR)\Install.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ELSEIF "$(CFG)" == "Install - Win32 Pure"
+
+# PROP BASE Use_MFC 2
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Install\Pure"
+# PROP BASE Intermediate_Dir "Install\Pure"
+# PROP BASE Target_Dir "Install"
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Install\Pure"
+# PROP Intermediate_Dir "Install\Pure"
+# PROP Target_Dir "Install"
+OUTDIR=.\Install\Pure
+INTDIR=.\Install\Pure
+
+ALL : "$(OUTDIR)\Install.exe"
+
+CLEAN :
+ -@erase "$(INTDIR)\install.obj"
+ -@erase "$(INTDIR)\Install.res"
+ -@erase "$(OUTDIR)\Install.exe"
+
+"$(OUTDIR)" :
+ if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /YX /c
+# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /c
+CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D\
+ "_MBCS" /Fp"$(INTDIR)/Install.pch" /YX /Fo"$(INTDIR)/" /c
+CPP_OBJS=.\Install\Pure/
+CPP_SBRS=.\.
+# ADD BASE MTL /nologo /D "NDEBUG" /win32
+# ADD MTL /nologo /D "NDEBUG" /win32
+MTL_PROJ=/nologo /D "NDEBUG" /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
+# ADD RSC /l 0x409 /d "NDEBUG"
+RSC_PROJ=/l 0x409 /fo"$(INTDIR)/Install.res" /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+BSC32_FLAGS=/nologo /o"$(OUTDIR)/Install.bsc"
+BSC32_SBRS= \
+
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib version.lib /nologo /subsystem:windows /machine:I386
+LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
+ advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
+ odbccp32.lib version.lib /nologo /subsystem:windows /incremental:no\
+ /pdb:"$(OUTDIR)/Install.pdb" /machine:I386 /out:"$(OUTDIR)/Install.exe"
+LINK32_OBJS= \
+ "$(INTDIR)\install.obj" \
+ "$(INTDIR)\Install.res"
+
+"$(OUTDIR)\Install.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ELSEIF "$(CFG)" == "Install - Win32 Static"
+
+# PROP BASE Use_MFC 2
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Install\Static"
+# PROP BASE Intermediate_Dir "Install\Static"
+# PROP BASE Target_Dir "Install"
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Install\Static"
+# PROP Intermediate_Dir "Install\Static"
+# PROP Target_Dir "Install"
+OUTDIR=.\Install\Static
+INTDIR=.\Install\Static
+
+ALL : "$(OUTDIR)\Install.exe"
+
+CLEAN :
+ -@erase "$(INTDIR)\install.obj"
+ -@erase "$(INTDIR)\Install.res"
+ -@erase "$(OUTDIR)\Install.exe"
+
+"$(OUTDIR)" :
+ if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /YX /c
+# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "STATI_K" /YX /c
+CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D\
+ "_MBCS" /D "STATI_K" /Fp"$(INTDIR)/Install.pch" /YX /Fo"$(INTDIR)/" /c
+CPP_OBJS=.\Install\Static/
+CPP_SBRS=.\.
+# ADD BASE MTL /nologo /D "NDEBUG" /win32
+# ADD MTL /nologo /D "NDEBUG" /win32
+MTL_PROJ=/nologo /D "NDEBUG" /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
+# ADD RSC /l 0x409 /d "NDEBUG" /d "STATI_K"
+RSC_PROJ=/l 0x409 /fo"$(INTDIR)/Install.res" /d "NDEBUG" /d "STATI_K"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+BSC32_FLAGS=/nologo /o"$(OUTDIR)/Install.bsc"
+BSC32_SBRS= \
+
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib version.lib /nologo /subsystem:windows /machine:I386
+LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
+ advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
+ odbccp32.lib version.lib /nologo /subsystem:windows /incremental:no\
+ /pdb:"$(OUTDIR)/Install.pdb" /machine:I386 /out:"$(OUTDIR)/Install.exe"
+LINK32_OBJS= \
+ "$(INTDIR)\install.obj" \
+ "$(INTDIR)\Install.res"
+
+"$(OUTDIR)\Install.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ELSEIF "$(CFG)" == "Install - Win32 Canned"
+
+# PROP BASE Use_MFC 2
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Install\Canned"
+# PROP BASE Intermediate_Dir "Install\Canned"
+# PROP BASE Target_Dir "Install"
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Install\Canned"
+# PROP Intermediate_Dir "Install\Canned"
+# PROP Target_Dir "Install"
+OUTDIR=.\Install\Canned
+INTDIR=.\Install\Canned
+
+ALL : "$(OUTDIR)\Install.exe"
+
+CLEAN :
+ -@erase "$(INTDIR)\install.obj"
+ -@erase "$(INTDIR)\Install.res"
+ -@erase "$(OUTDIR)\Install.exe"
+
+"$(OUTDIR)" :
+ if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /YX /c
+# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "K_ANNED" /YX /c
+CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D\
+ "_MBCS" /D "K_ANNED" /Fp"$(INTDIR)/Install.pch" /YX /Fo"$(INTDIR)/" /c
+CPP_OBJS=.\Install\Canned/
+CPP_SBRS=.\.
+# ADD BASE MTL /nologo /D "NDEBUG" /win32
+# ADD MTL /nologo /D "NDEBUG" /win32
+MTL_PROJ=/nologo /D "NDEBUG" /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
+# ADD RSC /l 0x409 /d "NDEBUG" /d "K_ANNED"
+RSC_PROJ=/l 0x409 /fo"$(INTDIR)/Install.res" /d "NDEBUG" /d "K_ANNED"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+BSC32_FLAGS=/nologo /o"$(OUTDIR)/Install.bsc"
+BSC32_SBRS= \
+
+LINK32=link.exe
+# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib version.lib /nologo /subsystem:windows /machine:I386
+LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
+ advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
+ odbccp32.lib version.lib /nologo /subsystem:windows /incremental:no\
+ /pdb:"$(OUTDIR)/Install.pdb" /machine:I386 /out:"$(OUTDIR)/Install.exe"
+LINK32_OBJS= \
+ "$(INTDIR)\install.obj" \
+ "$(INTDIR)\Install.res"
+
+"$(OUTDIR)\Install.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+ $(LINK32) @<<
+ $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ENDIF
+
+.c{$(CPP_OBJS)}.obj:
+ $(CPP) $(CPP_PROJ) $<
+
+.cpp{$(CPP_OBJS)}.obj:
+ $(CPP) $(CPP_PROJ) $<
+
+.cxx{$(CPP_OBJS)}.obj:
+ $(CPP) $(CPP_PROJ) $<
+
+.c{$(CPP_SBRS)}.sbr:
+ $(CPP) $(CPP_PROJ) $<
+
+.cpp{$(CPP_SBRS)}.sbr:
+ $(CPP) $(CPP_PROJ) $<
+
+.cxx{$(CPP_SBRS)}.sbr:
+ $(CPP) $(CPP_PROJ) $<
+
+################################################################################
+# Begin Target
+
+# Name "PumpKIN - Win32 Release"
+# Name "PumpKIN - Win32 Debug"
+# Name "PumpKIN - Win32 Static"
+
+!IF "$(CFG)" == "PumpKIN - Win32 Release"
+
+!ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "PumpKIN - Win32 Static"
+
+!ENDIF
+
+################################################################################
+# Begin Source File
+
+SOURCE=.\PumpKIN.cpp
+DEP_CPP_PUMPK=\
+ ".\PumpKIN.h"\
+ ".\PumpKINDlg.h"\
+ ".\shared-code\BellsNWhistles.h"\
+ ".\shared-code\kHelpers.h"\
+ ".\stdafx.h"\
+
+
+!IF "$(CFG)" == "PumpKIN - Win32 Release"
+
+
+"$(INTDIR)\PumpKIN.obj" : $(SOURCE) $(DEP_CPP_PUMPK) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+
+!ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug"
+
+
+"$(INTDIR)\PumpKIN.obj" : $(SOURCE) $(DEP_CPP_PUMPK) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+"$(INTDIR)\PumpKIN.sbr" : $(SOURCE) $(DEP_CPP_PUMPK) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+
+!ELSEIF "$(CFG)" == "PumpKIN - Win32 Static"
+
+
+"$(INTDIR)\PumpKIN.obj" : $(SOURCE) $(DEP_CPP_PUMPK) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+
+!ENDIF
+
+# End Source File
+################################################################################
+# Begin Source File
+
+SOURCE=.\PumpKINDlg.cpp
+DEP_CPP_PUMPKI=\
+ ".\ConfirmRRQDlg.h"\
+ ".\ConfirmWRQDlg.h"\
+ ".\PropsNetwork.h"\
+ ".\PropsServer.h"\
+ ".\PropsSounds.h"\
+ ".\PumpKIN.h"\
+ ".\PumpKINDlg.h"\
+ ".\RequestDlg.h"\
+ ".\Resolver.h"\
+ ".\Retrier.h"\
+ ".\shared-code\BellsNWhistles.h"\
+ ".\shared-code\kHelpers.h"\
+ ".\stdafx.h"\
+ ".\Trayer.h"\
+
+
+!IF "$(CFG)" == "PumpKIN - Win32 Release"
+
+
+"$(INTDIR)\PumpKINDlg.obj" : $(SOURCE) $(DEP_CPP_PUMPKI) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+
+!ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug"
+
+
+"$(INTDIR)\PumpKINDlg.obj" : $(SOURCE) $(DEP_CPP_PUMPKI) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+"$(INTDIR)\PumpKINDlg.sbr" : $(SOURCE) $(DEP_CPP_PUMPKI) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+
+!ELSEIF "$(CFG)" == "PumpKIN - Win32 Static"
+
+
+"$(INTDIR)\PumpKINDlg.obj" : $(SOURCE) $(DEP_CPP_PUMPKI) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+
+!ENDIF
+
+# End Source File
+################################################################################
+# Begin Source File
+
+SOURCE=.\StdAfx.cpp
+DEP_CPP_STDAF=\
+ ".\shared-code\BellsNWhistles.h"\
+ ".\shared-code\kHelpers.h"\
+ ".\stdafx.h"\
+
+
+!IF "$(CFG)" == "PumpKIN - Win32 Release"
+
+# ADD CPP /Yc"stdafx.h"
+
+BuildCmds= \
+ $(CPP) /nologo /Zp1 /MD /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D\
+ "_AFXDLL" /D "_MBCS" /Fp"$(INTDIR)/pumpkin.pch" /Yc"stdafx.h" /Fo"$(INTDIR)/"\
+ /c $(SOURCE) \
+
+
+"$(INTDIR)\StdAfx.obj" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)"
+ $(BuildCmds)
+
+"$(INTDIR)\pumpkin.pch" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)"
+ $(BuildCmds)
+
+!ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug"
+
+# ADD CPP /Yc"stdafx.h"
+
+BuildCmds= \
+ $(CPP) /nologo /Zp1 /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D\
+ "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR"$(INTDIR)/" /Fp"$(INTDIR)/pumpkin.pch"\
+ /Yc"stdafx.h" /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c $(SOURCE) \
+
+
+"$(INTDIR)\StdAfx.obj" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)"
+ $(BuildCmds)
+
+"$(INTDIR)\StdAfx.sbr" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)"
+ $(BuildCmds)
+
+"$(INTDIR)\pumpkin.pch" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)"
+ $(BuildCmds)
+
+!ELSEIF "$(CFG)" == "PumpKIN - Win32 Static"
+
+# ADD BASE CPP /Yc"stdafx.h"
+# ADD CPP /Yc"stdafx.h"
+
+BuildCmds= \
+ $(CPP) /nologo /Zp1 /MT /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D\
+ "_MBCS" /Fp"$(INTDIR)/pumpkin.pch" /Yc"stdafx.h" /Fo"$(INTDIR)/" /c $(SOURCE) \
+
+
+"$(INTDIR)\StdAfx.obj" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)"
+ $(BuildCmds)
+
+"$(INTDIR)\pumpkin.pch" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)"
+ $(BuildCmds)
+
+!ENDIF
+
+# End Source File
+################################################################################
+# Begin Source File
+
+SOURCE=.\pumpkin.rc
+DEP_RSC_PUMPKIN=\
+ ".\res\failed.wav"\
+ ".\res\finished.wav"\
+ ".\res\PumpKIN.ico"\
+ ".\res\pumpkin.rc2"\
+ ".\res\ring.wav"\
+ ".\res\rrq.ico"\
+ ".\res\wrq.ico"\
+ ".\shared-data\browse-icon.ico"\
+ ".\shared-data\klever-background.bmp"\
+ ".\shared-data\play-icon.ico"\
+
+
+!IF "$(CFG)" == "PumpKIN - Win32 Release"
+
+
+"$(INTDIR)\PumpKIN.res" : $(SOURCE) $(DEP_RSC_PUMPKIN) "$(INTDIR)"
+ $(RSC) $(RSC_PROJ) $(SOURCE)
+
+
+!ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug"
+
+
+"$(INTDIR)\PumpKIN.res" : $(SOURCE) $(DEP_RSC_PUMPKIN) "$(INTDIR)"
+ $(RSC) $(RSC_PROJ) $(SOURCE)
+
+
+!ELSEIF "$(CFG)" == "PumpKIN - Win32 Static"
+
+
+"$(INTDIR)\PumpKIN.res" : $(SOURCE) $(DEP_RSC_PUMPKIN) "$(INTDIR)"
+ $(RSC) $(RSC_PROJ) $(SOURCE)
+
+
+!ENDIF
+
+# End Source File
+################################################################################
+# Begin Source File
+
+SOURCE=.\help\pumpkin.hpj
+
+!IF "$(CFG)" == "PumpKIN - Win32 Release"
+
+# Begin Custom Build - Making help files...
+OutDir=.\Release
+ProjDir=.
+TargetName=pumpkin
+InputPath=.\help\pumpkin.hpj
+
+BuildCmds= \
+ "$(ProjDir)\makehelp.bat" \
+ compress $(OutDir)\$(TargetName).hlp $(OutDir)\$(TargetName).hl_ \
+ compress $(OutDir)\$(TargetName).cnt $(OutDir)\$(TargetName).cn_ \
+
+
+"$(OutDir)\$(TargetName).hlp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(OutDir)\$(TargetName).cnt" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(OutDir)\$(TargetName).hl_" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(OutDir)\$(TargetName).cn_" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug"
+
+# Begin Custom Build - Making help files...
+OutDir=.\Debug
+ProjDir=.
+TargetName=pumpkin
+InputPath=.\help\pumpkin.hpj
+
+BuildCmds= \
+ "$(ProjDir)\makehelp.bat" \
+ compress $(OutDir)\$(TargetName).hlp $(OutDir)\$(TargetName).hl_ \
+ compress $(OutDir)\$(TargetName).cnt $(OutDir)\$(TargetName).cn_ \
+
+
+"$(OutDir)\$(TargetName).hlp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(OutDir)\$(TargetName).cnt" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(OutDir)\$(TargetName).hl_" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(OutDir)\$(TargetName).cn_" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+# End Custom Build
+
+!ELSEIF "$(CFG)" == "PumpKIN - Win32 Static"
+
+# Begin Custom Build - Making help files...
+OutDir=.\Releast
+ProjDir=.
+TargetName=pumpkin
+InputPath=.\help\pumpkin.hpj
+
+BuildCmds= \
+ "$(ProjDir)\makehelp.bat" \
+ compress $(OutDir)\$(TargetName).hlp $(OutDir)\$(TargetName).hl_ \
+ compress $(OutDir)\$(TargetName).cnt $(OutDir)\$(TargetName).cn_ \
+
+
+"$(OutDir)\$(TargetName).hlp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(OutDir)\$(TargetName).cnt" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(OutDir)\$(TargetName).hl_" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+
+"$(OutDir)\$(TargetName).cn_" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+ $(BuildCmds)
+# End Custom Build
+
+!ENDIF
+
+# End Source File
+################################################################################
+# Begin Source File
+
+SOURCE=.\PropsServer.cpp
+DEP_CPP_PROPS=\
+ ".\PropsServer.h"\
+ ".\PumpKIN.h"\
+ ".\shared-code\BellsNWhistles.h"\
+ ".\shared-code\kHelpers.h"\
+ ".\stdafx.h"\
+
+
+!IF "$(CFG)" == "PumpKIN - Win32 Release"
+
+
+"$(INTDIR)\PropsServer.obj" : $(SOURCE) $(DEP_CPP_PROPS) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+
+!ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug"
+
+
+"$(INTDIR)\PropsServer.obj" : $(SOURCE) $(DEP_CPP_PROPS) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+"$(INTDIR)\PropsServer.sbr" : $(SOURCE) $(DEP_CPP_PROPS) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+
+!ELSEIF "$(CFG)" == "PumpKIN - Win32 Static"
+
+
+"$(INTDIR)\PropsServer.obj" : $(SOURCE) $(DEP_CPP_PROPS) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+
+!ENDIF
+
+# End Source File
+################################################################################
+# Begin Source File
+
+SOURCE=.\PropsNetwork.cpp
+DEP_CPP_PROPSN=\
+ ".\PropsNetwork.h"\
+ ".\PumpKIN.h"\
+ ".\shared-code\BellsNWhistles.h"\
+ ".\shared-code\kHelpers.h"\
+ ".\stdafx.h"\
+
+
+!IF "$(CFG)" == "PumpKIN - Win32 Release"
+
+
+"$(INTDIR)\PropsNetwork.obj" : $(SOURCE) $(DEP_CPP_PROPSN) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+
+!ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug"
+
+
+"$(INTDIR)\PropsNetwork.obj" : $(SOURCE) $(DEP_CPP_PROPSN) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+"$(INTDIR)\PropsNetwork.sbr" : $(SOURCE) $(DEP_CPP_PROPSN) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+
+!ELSEIF "$(CFG)" == "PumpKIN - Win32 Static"
+
+
+"$(INTDIR)\PropsNetwork.obj" : $(SOURCE) $(DEP_CPP_PROPSN) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+
+!ENDIF
+
+# End Source File
+################################################################################
+# Begin Source File
+
+SOURCE=.\ConfirmRRQDlg.cpp
+DEP_CPP_CONFI=\
+ ".\ConfirmRRQDlg.h"\
+ ".\PumpKIN.h"\
+ ".\PumpKINDlg.h"\
+ ".\shared-code\BellsNWhistles.h"\
+ ".\shared-code\kHelpers.h"\
+ ".\stdafx.h"\
+
+
+!IF "$(CFG)" == "PumpKIN - Win32 Release"
+
+
+"$(INTDIR)\ConfirmRRQDlg.obj" : $(SOURCE) $(DEP_CPP_CONFI) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+
+!ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug"
+
+
+"$(INTDIR)\ConfirmRRQDlg.obj" : $(SOURCE) $(DEP_CPP_CONFI) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+"$(INTDIR)\ConfirmRRQDlg.sbr" : $(SOURCE) $(DEP_CPP_CONFI) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+
+!ELSEIF "$(CFG)" == "PumpKIN - Win32 Static"
+
+
+"$(INTDIR)\ConfirmRRQDlg.obj" : $(SOURCE) $(DEP_CPP_CONFI) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+
+!ENDIF
+
+# End Source File
+################################################################################
+# Begin Source File
+
+SOURCE=.\ConfirmWRQDlg.cpp
+DEP_CPP_CONFIR=\
+ ".\ConfirmWRQDlg.h"\
+ ".\PumpKIN.h"\
+ ".\PumpKINDlg.h"\
+ ".\shared-code\BellsNWhistles.h"\
+ ".\shared-code\kHelpers.h"\
+ ".\stdafx.h"\
+
+
+!IF "$(CFG)" == "PumpKIN - Win32 Release"
+
+
+"$(INTDIR)\ConfirmWRQDlg.obj" : $(SOURCE) $(DEP_CPP_CONFIR) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+
+!ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug"
+
+
+"$(INTDIR)\ConfirmWRQDlg.obj" : $(SOURCE) $(DEP_CPP_CONFIR) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+"$(INTDIR)\ConfirmWRQDlg.sbr" : $(SOURCE) $(DEP_CPP_CONFIR) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+
+!ELSEIF "$(CFG)" == "PumpKIN - Win32 Static"
+
+
+"$(INTDIR)\ConfirmWRQDlg.obj" : $(SOURCE) $(DEP_CPP_CONFIR) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+
+!ENDIF
+
+# End Source File
+################################################################################
+# Begin Source File
+
+SOURCE=.\RequestDlg.cpp
+DEP_CPP_REQUE=\
+ ".\PumpKIN.h"\
+ ".\RequestDlg.h"\
+ ".\shared-code\BellsNWhistles.h"\
+ ".\shared-code\kHelpers.h"\
+ ".\stdafx.h"\
+
+
+!IF "$(CFG)" == "PumpKIN - Win32 Release"
+
+
+"$(INTDIR)\RequestDlg.obj" : $(SOURCE) $(DEP_CPP_REQUE) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+
+!ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug"
+
+
+"$(INTDIR)\RequestDlg.obj" : $(SOURCE) $(DEP_CPP_REQUE) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+"$(INTDIR)\RequestDlg.sbr" : $(SOURCE) $(DEP_CPP_REQUE) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+
+!ELSEIF "$(CFG)" == "PumpKIN - Win32 Static"
+
+
+"$(INTDIR)\RequestDlg.obj" : $(SOURCE) $(DEP_CPP_REQUE) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+
+!ENDIF
+
+# End Source File
+################################################################################
+# Begin Source File
+
+SOURCE=.\Resolver.cpp
+DEP_CPP_RESOL=\
+ ".\PumpKIN.h"\
+ ".\PumpKINDlg.h"\
+ ".\Resolver.h"\
+ ".\shared-code\BellsNWhistles.h"\
+ ".\shared-code\kHelpers.h"\
+ ".\stdafx.h"\
+
+
+!IF "$(CFG)" == "PumpKIN - Win32 Release"
+
+
+"$(INTDIR)\Resolver.obj" : $(SOURCE) $(DEP_CPP_RESOL) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+
+!ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug"
+
+
+"$(INTDIR)\Resolver.obj" : $(SOURCE) $(DEP_CPP_RESOL) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+"$(INTDIR)\Resolver.sbr" : $(SOURCE) $(DEP_CPP_RESOL) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+
+!ELSEIF "$(CFG)" == "PumpKIN - Win32 Static"
+
+
+"$(INTDIR)\Resolver.obj" : $(SOURCE) $(DEP_CPP_RESOL) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+
+!ENDIF
+
+# End Source File
+################################################################################
+# Begin Source File
+
+SOURCE=.\Retrier.cpp
+DEP_CPP_RETRI=\
+ ".\PumpKIN.h"\
+ ".\PumpKINDlg.h"\
+ ".\Retrier.h"\
+ ".\shared-code\BellsNWhistles.h"\
+ ".\shared-code\kHelpers.h"\
+ ".\stdafx.h"\
+
+
+!IF "$(CFG)" == "PumpKIN - Win32 Release"
+
+
+"$(INTDIR)\Retrier.obj" : $(SOURCE) $(DEP_CPP_RETRI) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+
+!ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug"
+
+
+"$(INTDIR)\Retrier.obj" : $(SOURCE) $(DEP_CPP_RETRI) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+"$(INTDIR)\Retrier.sbr" : $(SOURCE) $(DEP_CPP_RETRI) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+
+!ELSEIF "$(CFG)" == "PumpKIN - Win32 Static"
+
+
+"$(INTDIR)\Retrier.obj" : $(SOURCE) $(DEP_CPP_RETRI) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+
+!ENDIF
+
+# End Source File
+################################################################################
+# Begin Source File
+
+SOURCE=.\Trayer.cpp
+DEP_CPP_TRAYE=\
+ ".\PumpKIN.h"\
+ ".\PumpKINDlg.h"\
+ ".\shared-code\BellsNWhistles.h"\
+ ".\shared-code\kHelpers.h"\
+ ".\stdafx.h"\
+ ".\Trayer.h"\
+
+
+!IF "$(CFG)" == "PumpKIN - Win32 Release"
+
+
+"$(INTDIR)\Trayer.obj" : $(SOURCE) $(DEP_CPP_TRAYE) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+
+!ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug"
+
+
+"$(INTDIR)\Trayer.obj" : $(SOURCE) $(DEP_CPP_TRAYE) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+"$(INTDIR)\Trayer.sbr" : $(SOURCE) $(DEP_CPP_TRAYE) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+
+!ELSEIF "$(CFG)" == "PumpKIN - Win32 Static"
+
+
+"$(INTDIR)\Trayer.obj" : $(SOURCE) $(DEP_CPP_TRAYE) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+
+!ENDIF
+
+# End Source File
+################################################################################
+# Begin Source File
+
+SOURCE=.\help\pumpkin.cnt
+
+!IF "$(CFG)" == "PumpKIN - Win32 Release"
+
+# PROP Exclude_From_Build 1
+
+!ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug"
+
+# PROP Exclude_From_Build 1
+
+!ELSEIF "$(CFG)" == "PumpKIN - Win32 Static"
+
+# PROP Exclude_From_Build 1
+
+!ENDIF
+
+# End Source File
+################################################################################
+# Begin Source File
+
+SOURCE=.\PropsSounds.cpp
+DEP_CPP_PROPSS=\
+ ".\PropsSounds.h"\
+ ".\PumpKIN.h"\
+ ".\PumpKINDlg.h"\
+ ".\shared-code\BellsNWhistles.h"\
+ ".\shared-code\kHelpers.h"\
+ ".\stdafx.h"\
+
+
+!IF "$(CFG)" == "PumpKIN - Win32 Release"
+
+
+"$(INTDIR)\PropsSounds.obj" : $(SOURCE) $(DEP_CPP_PROPSS) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+
+!ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug"
+
+
+"$(INTDIR)\PropsSounds.obj" : $(SOURCE) $(DEP_CPP_PROPSS) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+"$(INTDIR)\PropsSounds.sbr" : $(SOURCE) $(DEP_CPP_PROPSS) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+
+!ELSEIF "$(CFG)" == "PumpKIN - Win32 Static"
+
+
+"$(INTDIR)\PropsSounds.obj" : $(SOURCE) $(DEP_CPP_PROPSS) "$(INTDIR)"\
+ "$(INTDIR)\pumpkin.pch"
+
+
+!ENDIF
+
+# End Source File
+# End Target
+################################################################################
+# Begin Target
+
+# Name "Install - Win32 Debug"
+# Name "Install - Win32 Pure"
+# Name "Install - Win32 Static"
+# Name "Install - Win32 Canned"
+
+!IF "$(CFG)" == "Install - Win32 Debug"
+
+!ELSEIF "$(CFG)" == "Install - Win32 Pure"
+
+!ELSEIF "$(CFG)" == "Install - Win32 Static"
+
+!ELSEIF "$(CFG)" == "Install - Win32 Canned"
+
+!ENDIF
+
+################################################################################
+# Begin Source File
+
+SOURCE=.\Install\Install.rc
+DEP_RSC_INSTA=\
+ ".\Install\Custom.rch"\
+ ".\shared-data\install-icon.ico"\
+
+
+!IF "$(CFG)" == "Install - Win32 Debug"
+
+
+"$(INTDIR)\Install.res" : $(SOURCE) $(DEP_RSC_INSTA) "$(INTDIR)"
+ $(RSC) /l 0x409 /fo"$(INTDIR)/Install.res" /i "Install" /d "_DEBUG"\
+ $(SOURCE)
+
+
+!ELSEIF "$(CFG)" == "Install - Win32 Pure"
+
+
+"$(INTDIR)\Install.res" : $(SOURCE) $(DEP_RSC_INSTA) "$(INTDIR)"
+ $(RSC) /l 0x409 /fo"$(INTDIR)/Install.res" /i "Install" /d "NDEBUG"\
+ $(SOURCE)
+
+
+!ELSEIF "$(CFG)" == "Install - Win32 Static"
+
+
+"$(INTDIR)\Install.res" : $(SOURCE) $(DEP_RSC_INSTA) "$(INTDIR)"
+ $(RSC) /l 0x409 /fo"$(INTDIR)/Install.res" /i "Install" /d "NDEBUG" /d\
+ "STATI_K" $(SOURCE)
+
+
+!ELSEIF "$(CFG)" == "Install - Win32 Canned"
+
+
+"$(INTDIR)\Install.res" : $(SOURCE) $(DEP_RSC_INSTA) "$(INTDIR)"
+ $(RSC) /l 0x409 /fo"$(INTDIR)/Install.res" /i "Install" /d "NDEBUG" /d\
+ "K_ANNED" $(SOURCE)
+
+
+!ENDIF
+
+# End Source File
+################################################################################
+# Begin Source File
+
+SOURCE=.\Install\install.cpp
+DEP_CPP_INSTAL=\
+ ".\shared-code\install.h"\
+
+
+!IF "$(CFG)" == "Install - Win32 Debug"
+
+
+"$(INTDIR)\install.obj" : $(SOURCE) $(DEP_CPP_INSTAL) "$(INTDIR)"
+ $(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+!ELSEIF "$(CFG)" == "Install - Win32 Pure"
+
+
+"$(INTDIR)\install.obj" : $(SOURCE) $(DEP_CPP_INSTAL) "$(INTDIR)"
+ $(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+!ELSEIF "$(CFG)" == "Install - Win32 Static"
+
+
+"$(INTDIR)\install.obj" : $(SOURCE) $(DEP_CPP_INSTAL) "$(INTDIR)"
+ $(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+!ELSEIF "$(CFG)" == "Install - Win32 Canned"
+
+
+"$(INTDIR)\install.obj" : $(SOURCE) $(DEP_CPP_INSTAL) "$(INTDIR)"
+ $(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+!ENDIF
+
+# End Source File
+# End Target
+# End Project
+################################################################################
+################################################################################
+# Section PumpKIN : {4FD78B34-1FD7-11D0-A9FB-444553540000}
+# 2:11:CPumpKINDlg:1
+# 2:11:CRequestDlg:1
+# End Section
+################################################################################
diff --git a/pumpkin.rc b/pumpkin.rc
new file mode 100644
index 0000000..05b6cde
--- a/dev/null
+++ b/pumpkin.rc
@@ -0,0 +1,605 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#include ""afxres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#define _AFX_NO_SPLITTER_RESOURCES\r\n"
+ "#define _AFX_NO_OLE_RESOURCES\r\n"
+ "#define _AFX_NO_TRACKER_RESOURCES\r\n"
+ "#define _AFX_NO_PROPERTY_RESOURCES\r\n"
+ "\r\n"
+ "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
+ "#ifdef _WIN32\r\n"
+ "LANGUAGE 9, 1\r\n"
+ "#pragma code_page(1252)\r\n"
+ "#endif\r\n"
+ "#include ""res\\PumpKIN.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
+ "#include ""afxres.rc"" // Standard components\r\n"
+ "#endif\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_RRQ ICON DISCARDABLE "res\\wrq.ico"
+IDI_WRQ ICON DISCARDABLE "res\\rrq.ico"
+IDI_BROWSE ICON DISCARDABLE "shared-data/browse-icon.ico"
+IDR_MAINFRAME ICON DISCARDABLE "res\\pumpkin.ico"
+IDI_PLAY ICON DISCARDABLE "shared-data/play-icon.ico"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 217, 74
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "About PumpKIN"
+FONT 8, "MS Sans Serif"
+BEGIN
+ ICON IDR_MAINFRAME,IDC_STATIC,7,17,18,20
+ LTEXT "PumpKIN, Version 2.5",IDC_STATIC,40,15,119,8,SS_NOPREFIX
+ LTEXT "Copyright © 1997,1998,2002 Klever Group",IDC_STATIC,40,30,170,
+ 8
+ DEFPUSHBUTTON "OK",IDOK,178,7,32,14,WS_GROUP
+ PUSHBUTTON "http://www.klever.net/",IDC_KLEVERNET,124,53,86,14
+END
+
+IDD_PUMPKIN_DIALOG DIALOGEX 0, 0, 362, 191
+STYLE DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION |
+ WS_SYSMENU
+EXSTYLE WS_EX_ACCEPTFILES | WS_EX_APPWINDOW
+CAPTION " PumpKIN"
+FONT 8, "MS Sans Serif", 0, 0, 0x1
+BEGIN
+ CONTROL "List1",IDC_CONNECTIONS,"SysListView32",LVS_REPORT |
+ LVS_AUTOARRANGE | WS_BORDER | WS_TABSTOP,7,7,295,108,
+ WS_EX_DLGMODALFRAME
+ PUSHBUTTON "&Get File",IDC_GET,305,7,50,17,BS_NOTIFY,
+ WS_EX_CLIENTEDGE
+ PUSHBUTTON "&Put File",IDC_PUT,305,25,50,17,BS_NOTIFY,
+ WS_EX_CLIENTEDGE
+ PUSHBUTTON "&Abort xfer",IDC_ABORT,305,43,50,17,BS_NOTIFY,
+ WS_EX_CLIENTEDGE
+ PUSHBUTTON "&Options",IDC_OPTIONS,305,61,50,17,BS_NOTIFY,
+ WS_EX_CLIENTEDGE
+ PUSHBUTTON "E&xit",IDC_EXIT,305,79,50,17,BS_NOTIFY,WS_EX_CLIENTEDGE
+ PUSHBUTTON "&Help",ID_HELP,305,97,50,17,BS_NOTIFY,WS_EX_CLIENTEDGE
+ LISTBOX IDC_LOG,7,115,348,69,LBS_USETABSTOPS | LBS_NOSEL |
+ WS_VSCROLL | WS_HSCROLL,WS_EX_DLGMODALFRAME
+ PUSHBUTTON "..",IDCANCEL,0,183,6,7,NOT WS_VISIBLE | NOT WS_TABSTOP
+END
+
+IDD_PROPS_SERVER DIALOG DISCARDABLE 0, 0, 210, 154
+STYLE WS_CHILD | WS_DISABLED | WS_CAPTION
+CAPTION "Server"
+FONT 8, "MS Sans Serif"
+BEGIN
+ GROUPBOX "TFTP filesystem &root (download path)",IDC_STATIC,7,7,
+ 196,38
+ EDITTEXT IDC_TFTPROOT,13,16,170,13,ES_AUTOHSCROLL
+ PUSHBUTTON "&B",IDC_BROWSE,186,16,13,13,BS_ICON
+ CONTROL "Allow access to &subdirectories",IDC_TFTPSUBDIRS,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,31,111,10
+ GROUPBOX "Read Request Behavior",IDC_STATIC,7,48,153,42
+ CONTROL "Give &all files",IDC_RRQ_GIVEALL,"Button",
+ BS_AUTORADIOBUTTON | BS_NOTIFY | WS_GROUP,13,57,53,10
+ CONTROL "&Prompt before giving file",IDC_RRQ_ALWAYSCONFIRM,
+ "Button",BS_AUTORADIOBUTTON | BS_NOTIFY,23,67,91,10
+ CONTROL "&Deny all requests",IDC_RRQ_DENYALL,"Button",
+ BS_AUTORADIOBUTTON | BS_NOTIFY,33,77,70,10
+ GROUPBOX "Write Request Behavior",IDC_STATIC,7,93,172,54,WS_GROUP
+ CONTROL "Take a&ll files",IDC_WRQ_TAKEALL,"Button",
+ BS_AUTORADIOBUTTON | WS_GROUP,13,103,55,10
+ CONTROL "Prompt if file &exists",IDC_WRQ_PROMPTEXISTING,"Button",
+ BS_AUTORADIOBUTTON,23,113,73,10
+ CONTROL "Always pro&mpt before accepting file",
+ IDC_WRQ_ALWAYSCONFIRM,"Button",BS_AUTORADIOBUTTON,33,123,
+ 139,10
+ CONTROL "D&eny all requests",IDC_WRQ_DENYALL,"Button",
+ BS_AUTORADIOBUTTON,43,133,70,10
+ CTEXT "Confirmation &timeout",IDC_STATIC,163,52,40,19,
+ SS_NOTIFY
+ CONTROL "Slider1",IDC_PROMPTTIMEOUT,"msctls_trackbar32",
+ TBS_AUTOTICKS | TBS_VERT | TBS_TOP | WS_TABSTOP,182,73,
+ 21,74
+END
+
+IDD_PROPS_NETWORK DIALOG DISCARDABLE 0, 0, 210, 154
+STYLE WS_CHILD | WS_DISABLED | WS_CAPTION
+CAPTION "Network"
+FONT 8, "MS Sans Serif"
+BEGIN
+ GROUPBOX "UDP Ports",IDC_STATIC,7,7,196,40
+ RTEXT "Listen for &incoming requests on port:",IDC_STATIC,13,
+ 18,135,8
+ EDITTEXT IDC_LISTENPORT,154,16,40,13,ES_AUTOHSCROLL
+ CONTROL "Spin1",IDC_LISTENSPIN,"msctls_updown32",UDS_WRAP |
+ UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY |
+ UDS_ARROWKEYS | UDS_NOTHOUSANDS,183,16,11,13
+ RTEXT "Send &outging requests to port:",IDC_STATIC,13,31,135,8
+ EDITTEXT IDC_SPEAKPORT,154,29,40,13,ES_AUTOHSCROLL
+ CONTROL "Spin1",IDC_SPEAKSPIN,"msctls_updown32",UDS_WRAP |
+ UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY |
+ UDS_ARROWKEYS | UDS_NOTHOUSANDS,183,29,11,13
+ LTEXT "Default connection timeout:",IDC_STATIC,7,52,88,8
+ EDITTEXT IDC_TIMEOUT,110,50,40,13,ES_AUTOHSCROLL | ES_NUMBER
+ CONTROL "Spin3",IDC_TIMESPIN,"msctls_updown32",UDS_WRAP |
+ UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY |
+ UDS_ARROWKEYS | UDS_NOTHOUSANDS,140,50,11,13
+ LTEXT "Default block size:",IDC_STATIC,7,66,59,8
+ LTEXT "seconds",IDC_STATIC,154,52,28,8
+ LTEXT "bytes",IDC_STATIC,154,66,18,8
+ EDITTEXT IDC_BLOCKSIZE,110,64,40,13,ES_AUTOHSCROLL | ES_NUMBER
+ CONTROL "Spin3",IDC_BSIZESPIN,"msctls_updown32",UDS_WRAP |
+ UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY |
+ UDS_ARROWKEYS | UDS_NOTHOUSANDS,140,64,11,13
+END
+
+IDD_CONFIRM_RRQ DIALOGEX 0, 0, 181, 79
+STYLE DS_MODALFRAME | DS_NOIDLEMSG | DS_SETFOREGROUND | DS_3DLOOK | WS_POPUP |
+ WS_CAPTION
+EXSTYLE WS_EX_TOOLWINDOW | WS_EX_CLIENTEDGE
+CAPTION " PumpKIN - Confirm Read Request"
+FONT 8, "MS Sans Serif", 0, 0, 0x1
+BEGIN
+ DEFPUSHBUTTON "&Grant Access",IDOK,27,58,54,14
+ PUSHBUTTON "&Deny Access",IDCANCEL,97,58,54,14
+ LTEXT "The host",IDC_STATIC,77,7,29,8
+ CTEXT "255.255.255.255",IDC_HOST,57,15,68,14,SS_NOTIFY |
+ SS_SUNKEN | WS_BORDER,WS_EX_DLGMODALFRAME |
+ WS_EX_CLIENTEDGE
+ CTEXT "is requesting the file",IDC_STATIC,23,29,135,8
+ CTEXT "",IDC_FILE,23,37,135,14,SS_NOTIFY | SS_SUNKEN |
+ WS_BORDER,WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE
+ CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,7,54,167,1
+ ICON IDR_MAINFRAME,IDC_STATIC,7,7,18,20
+ ICON IDR_MAINFRAME,IDC_STATIC,153,7,18,20
+END
+
+IDD_CONFIRM_WRQ DIALOGEX 0, 0, 201, 95
+STYLE DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | WS_POPUP | WS_CAPTION
+EXSTYLE WS_EX_TOOLWINDOW | WS_EX_CLIENTEDGE
+CAPTION " PumpKIN - Confirm Write Request"
+FONT 8, "MS Sans Serif", 0, 0, 0x1
+BEGIN
+ DEFPUSHBUTTON "&Accept",IDOK,7,58,59,14
+ PUSHBUTTON "&Rename",IDC_RENAME,71,58,59,14
+ PUSHBUTTON "&Deny Access",IDCANCEL,135,58,59,14
+ LTEXT "The host",IDC_STATIC,87,7,29,8
+ CTEXT "255.255.255.255",IDC_HOST,67,15,68,14,SS_NOTIFY |
+ SS_SUNKEN | WS_BORDER,WS_EX_DLGMODALFRAME |
+ WS_EX_CLIENTEDGE
+ CTEXT "is attempting to send you a file",IDC_STATIC,33,29,135,
+ 8
+ CTEXT "",IDC_FILE,33,37,135,14,SS_NOTIFY | SS_SUNKEN |
+ WS_BORDER,WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE
+ CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,7,54,187,1
+ ICON IDR_MAINFRAME,IDC_STATIC,7,7,21,20
+ ICON IDR_MAINFRAME,IDC_STATIC,173,7,21,20
+ PUSHBUTTON "Res&ume",IDC_RESUME,71,74,59,14
+END
+
+IDD_REQUEST DIALOGEX 0, 0, 191, 161
+STYLE DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | WS_POPUP | WS_CAPTION |
+ WS_SYSMENU
+EXSTYLE WS_EX_CLIENTEDGE
+CAPTION "Request"
+FONT 8, "MS Sans Serif", 0, 0, 0x1
+BEGIN
+ LTEXT "&Local file:",IDC_STATIC,7,7,31,8,SS_NOTIFY
+ EDITTEXT IDC_LOCALFILE,7,16,157,14,ES_AUTOHSCROLL,
+ WS_EX_CLIENTEDGE | WS_EX_STATICEDGE
+ PUSHBUTTON "...",IDC_BROWSE,165,16,19,14,BS_ICON,WS_EX_STATICEDGE
+ LTEXT "&Remote file:",IDC_STATIC,7,34,38,8,SS_NOTIFY
+ EDITTEXT IDC_REMOTEFILE,7,44,177,14,ES_AUTOHSCROLL,
+ WS_EX_CLIENTEDGE | WS_EX_STATICEDGE
+ LTEXT "Remote &host:",IDC_STATIC,7,61,43,8,SS_NOTIFY
+ COMBOBOX IDC_TALKS,7,72,157,66,CBS_SIMPLE | CBS_AUTOHSCROLL |
+ CBS_SORT | CBS_NOINTEGRALHEIGHT | WS_VSCROLL |
+ WS_TABSTOP,WS_EX_CLIENTEDGE | WS_EX_STATICEDGE
+ PUSHBUTTON "R\nE\n&F\nR\nE\nS\nH",IDC_REFRESH,165,72,19,66,
+ BS_CENTER | BS_VCENTER | BS_MULTILINE | BS_NOTIFY,
+ WS_EX_CLIENTEDGE
+ LTEXT "&Type:",IDC_STATIC,58,34,19,8
+ COMBOBOX IDC_TYPE,80,31,43,41,CBS_DROPDOWN | CBS_AUTOHSCROLL |
+ CBS_LOWERCASE | WS_VSCROLL | WS_TABSTOP
+ LTEXT "&Block:",IDC_STATIC,127,34,21,8
+ COMBOBOX IDC_BSIZE,149,31,35,53,CBS_DROPDOWN | WS_VSCROLL |
+ WS_TABSTOP
+ DEFPUSHBUTTON "OK",IDOK,35,140,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,101,140,50,14
+ CONTROL "",IDC_STATIC,"Static",SS_ETCHEDVERT,52,32,1,11
+END
+
+IDD_PROPS_SOUNDS DIALOG DISCARDABLE 0, 0, 210, 154
+STYLE WS_CHILD | WS_DISABLED | WS_CAPTION
+CAPTION "Sounds"
+FONT 8, "MS Sans Serif"
+BEGIN
+ LTEXT "&Incoming request:",IDC_STATIC,7,9,57,8
+ COMBOBOX IDC_RING,70,7,103,100,CBS_DROPDOWN | CBS_AUTOHSCROLL |
+ CBS_SORT | WS_VSCROLL | WS_TABSTOP
+ PUSHBUTTON "browse",IDC_RING_BROWSE,175,7,13,13,BS_ICON
+ PUSHBUTTON "play",IDC_RING_PLAY,190,7,13,13,BS_ICON
+ LTEXT "xfer &finished:",IDC_STATIC,7,25,57,8
+ COMBOBOX IDC_FINISHED,70,22,103,100,CBS_DROPDOWN |
+ CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP
+ PUSHBUTTON "browse",IDC_FINISHED_BROWSE,175,22,13,13,BS_ICON
+ PUSHBUTTON "play",IDC_FINISHED_PLAY,190,22,13,13,BS_ICON
+ LTEXT "xfer &aborted:",IDC_STATIC,7,40,57,8
+ COMBOBOX IDC_ABORTED,70,37,103,100,CBS_DROPDOWN | CBS_AUTOHSCROLL |
+ CBS_SORT | WS_VSCROLL | WS_TABSTOP
+ PUSHBUTTON "browse",IDC_ABORTED_BROWSE,175,37,13,13,BS_ICON
+ PUSHBUTTON "play",IDC_ABORTED_PLAY,190,37,13,13,BS_ICON
+END
+
+
+#ifndef _MAC
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 2,5,0,0
+ PRODUCTVERSION 2,5,0,0
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x4L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "CompanyName", "Klever Group (http://www.klever.net/)\0"
+ VALUE "FileDescription", "PumpKIN, tftp client/daemon\0"
+ VALUE "FileVersion", "2, 5, 0, 0\0"
+ VALUE "InternalName", "PUMPKIN\0"
+ VALUE "LegalCopyright", "Copyright © 1997, 1998, 2002 Klever Group (http://www.klever.net)\0"
+ VALUE "LegalTrademarks", "Klever Group (http://www.klever.net/)\0"
+ VALUE "OriginalFilename", "PUMPKIN.EXE\0"
+ VALUE "ProductName", "PumpKIN\0"
+ VALUE "ProductVersion", "2, 5, 0, 0\0"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
+
+#endif // !_MAC
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO DISCARDABLE
+BEGIN
+ IDD_ABOUTBOX, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 210
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 67
+ END
+
+ IDD_PUMPKIN_DIALOG, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 355
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 184
+ HORZGUIDE, 115
+ END
+
+ IDD_PROPS_SERVER, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 203
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 147
+ END
+
+ IDD_PROPS_NETWORK, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 203
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 147
+ END
+
+ IDD_CONFIRM_RRQ, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 174
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 72
+ END
+
+ IDD_CONFIRM_WRQ, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 194
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 88
+ END
+
+ IDD_REQUEST, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 184
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 154
+ END
+
+ IDD_PROPS_SOUNDS, DIALOG
+ BEGIN
+ LEFTMARGIN, 7
+ RIGHTMARGIN, 203
+ TOPMARGIN, 7
+ BOTTOMMARGIN, 147
+ END
+END
+#endif // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Bitmap
+//
+
+IDB_BACKGROUND BITMAP DISCARDABLE "shared-data/klever-background.bmp"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// WAVE
+//
+
+IDR_WAVE_RING WAVE DISCARDABLE "res\\ring.wav"
+IDR_WAVE_FINISHED WAVE DISCARDABLE "res\\finished.wav"
+IDR_WAVE_ABORTED WAVE DISCARDABLE "res\\failed.wav"
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog Info
+//
+
+IDD_REQUEST DLGINIT
+BEGIN
+ IDC_TYPE, 0x403, 6, 0
+0x636f, 0x6574, 0x0074,
+ IDC_TYPE, 0x403, 9, 0
+0x656e, 0x6174, 0x6373, 0x6969, "\000"
+ IDC_BSIZE, 0x403, 4, 0
+0x3135, 0x0032,
+ IDC_BSIZE, 0x403, 5, 0
+0x3031, 0x3432, "\000"
+ IDC_BSIZE, 0x403, 5, 0
+0x3032, 0x3834, "\000"
+ IDC_BSIZE, 0x403, 5, 0
+0x3034, 0x3639, "\000"
+ IDC_BSIZE, 0x403, 5, 0
+0x3138, 0x3239, "\000"
+ 0
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Menu
+//
+
+IDM_POPUPS MENU DISCARDABLE
+BEGIN
+ POPUP "&Tray"
+ BEGIN
+ MENUITEM "&Send File", ID_TRAY_SENDFILE
+ MENUITEM "F&etch file", ID_TRAY_FETCHFILE
+ MENUITEM "&Options", ID_TRAY_OPTIONS
+ MENUITEM "Show &PumpKIN Window", ID_TRAY_SHOWPUMPKINWINDOW
+ MENUITEM "Open &Files Folder", ID_TRAY_OPENFILESFOLDER
+ MENUITEM SEPARATOR
+ MENUITEM "&Help Topics", ID_TRAY_HELP
+ MENUITEM "&About PumpKIN", ID_TRAY_ABOUTPUMPKIN
+ MENUITEM SEPARATOR
+ MENUITEM "E&xit", ID_TRAY_EXIT
+ END
+END
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// String Table
+//
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_ABOUTBOX "&About PumpKIN..."
+ IDS_FMT_BYTES "%lu"
+ IDP_SOCKETS_INIT_FAILED "Windows sockets initialization failed."
+ IDS_TFTP_ERROR_ACCESS "Access violation"
+ IDS_TFTP_ERROR_NOTFOUND "File not found"
+ IDS_TFTP_ERROR_DIRFULL "Directory is full"
+ IDS_TFTP_ERROR_SHARING "Sharing violation"
+ IDS_TFTP_ERROR_DISKFULL "Disk full"
+ IDS_TFTP_ERROR_UNDEFINED "Undefined error"
+ IDS_LOG_START "PumpKIN started"
+ IDS_LOG_LISTENRECEIVEERROR "Error listening for incoming connections"
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_LOG_LISTENACCEPTERROR "Error accepting incoming connection"
+ IDS_LOG_RRQSERVE "'%s' of type '%s' is requested from %s"
+ IDS_LOG_LISTENOPCODE "Invalid opcode in initial connection request"
+ IDS_LOG_XFERUDPSEND "UDP packet send failed"
+ IDS_LOG_XFERRECEIVE "Error on xfer socket"
+ IDS_LOG_XFERSEND "Error on xfer socket"
+ IDS_LOG_XFERUDPRECEIVE "UDP packet receive failed"
+ IDS_LOG_XFERSOURCETID "Packet from unexpected source"
+ IDS_LOG_SENTTFTPERROR ":%u: %s"
+ IDS_LOG_GOTTFTPERROR "TFTP:%u: %s"
+ IDS_LOG_XFEROPCODE "Invalid opcode during transfer received"
+ IDS_LOG_XFERRRQFINISHED "Transfer of '%s' has successfully completed"
+ IDS_TITLE_OPTIONS "Options"
+ IDS_LOG_WRQSERVE "Writing of '%s' of type '%s' is requested by %s"
+ IDS_TFTP_ERROR_FAILEDTORENAME "Too many clones of the file"
+ IDS_RENAME_TITLE "Save As"
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_LOG_TIMEDOUT "Transmission of '%s' is timed out"
+ IDS_CONFIRMEXIT_TITLE "Exit"
+ IDS_CONFIRMEXIT_TEXT "File transmission is currently in progress. Are you sure you want to exit?"
+ IDS_LOG_XFERWRQFINISHED "Transfer of '%s' has successfully completed"
+ IDS_LOG_XFERABORTED "Transfer of '%s' was aborted"
+ IDS_TITLE_PUTREQUEST "Send file"
+ IDS_TITLE_GETREQUEST "Fetch file"
+ IDS_WTALKHEADING "Talk with "
+ IDS_TITLE_BROWSEFILE "Browse"
+ IDS_LOG_RESOLVEFAILED "Failed to resolve host address for '%s'"
+ IDS_LOG_FAILEDLOCALFILE "Failed to open local file '%s'"
+ IDS_LOG_FAILEDTOOPEN "Failed to open '%s'"
+ IDS_OTALXHEADING "Open Talks: talking to "
+ IDS_REGISTRYKEY "Klever Group, Inc."
+ IDS_KLEVERNET_URL "http://www.klever.net/"
+ IDS_LOGTIMEFORMAT "%H:%M:%S %B %d"
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ ID_TRAY_HELP "Read the help on PumpKIN"
+ ID_TRAY_ABOUTPUMPKIN "Learn about PumpKIN and it's creator"
+ ID_TRAY_EXIT "Close PumpKIN"
+ ID_TRAY_SENDFILE "Send file over the network to your tete-a-tete"
+ ID_TRAY_FETCHFILE "Fetch file from remote computer"
+ ID_TRAY_OPTIONS "Set PumpKIN options"
+ ID_TRAY_SHOWPUMPKINWINDOW "Show main window"
+ ID_TRAY_OPENFILESFOLDER "Explore TFTP root folder"
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDC_CONNECTIONS "Active transfers"
+ IDC_LOG "PumpKIN Activity Log"
+ IDC_GET "Fetch file from remote server"
+ IDC_PUT "Send file over the net"
+ IDC_ABORT "Abort transfer currently in progress"
+ IDC_EXIT "Close PumpKIN"
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDC_OPTIONS "Set PumpKIN options"
+ IDC_REFRESH "Refresh talks list"
+ IDC_BROWSE "Browse"
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ ID_HELP "Read help on PumpKIN"
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ IDS_DROPFILES_TITLE "Drop Files"
+ IDS_NOMULTIPLEDROP_TEXT "You can't drop more than one file here. Only the first one will be accepted"
+ IDS_LOG_REQUESTING "Requesting '%s' from '%s'"
+ IDS_LOG_SENDING "Sending '%s' to '%s'"
+ IDS_WTALKAT "@"
+ IDS_OTALXAT " at "
+ IDS_TFTP_ERROR_TSIZE "Invalid transfer size"
+ IDS_TFTP_ERROR_BSIZE "Invalid block size"
+ IDS_TFTP_ERROR_TOUT "Invalid timeout"
+ IDS_SELECT_TFTPROOT "Select TFTP filesystem root.."
+ IDS_FILTER_WAV "Sound Files (*.wav)|*.wav||"
+ IDS_TITLE_WAV "Select sound.."
+END
+
+STRINGTABLE DISCARDABLE
+BEGIN
+ AFX_IDS_APP_TITLE "PUMPKIN"
+END
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+#define _AFX_NO_SPLITTER_RESOURCES
+#define _AFX_NO_OLE_RESOURCES
+#define _AFX_NO_TRACKER_RESOURCES
+#define _AFX_NO_PROPERTY_RESOURCES
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE 9, 1
+#pragma code_page(1252)
+#endif
+#include "res\pumpkin.rc2" // non-Microsoft Visual C++ edited resources
+#include "afxres.rc" // Standard components
+#endif
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/res/failed.wav b/res/failed.wav
new file mode 100644
index 0000000..6d38550
--- a/dev/null
+++ b/res/failed.wav
Binary files differ
diff --git a/res/finished.wav b/res/finished.wav
new file mode 100644
index 0000000..d8a0dc4
--- a/dev/null
+++ b/res/finished.wav
Binary files differ
diff --git a/res/pumpkin.ico b/res/pumpkin.ico
new file mode 100644
index 0000000..a48bab9
--- a/dev/null
+++ b/res/pumpkin.ico
Binary files differ
diff --git a/res/pumpkin.rc2 b/res/pumpkin.rc2
new file mode 100644
index 0000000..3471fab
--- a/dev/null
+++ b/res/pumpkin.rc2
@@ -0,0 +1,13 @@
+//
+// PUMPKIN.RC2 - resources Microsoft Visual C++ does not edit directly
+//
+
+#ifdef APSTUDIO_INVOKED
+ #error this file is not editable by Microsoft Visual C++
+#endif //APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+// Add manually edited resources here...
+
+/////////////////////////////////////////////////////////////////////////////
diff --git a/res/ring.wav b/res/ring.wav
new file mode 100644
index 0000000..44b6ce2
--- a/dev/null
+++ b/res/ring.wav
Binary files differ
diff --git a/res/rrq.ico b/res/rrq.ico
new file mode 100644
index 0000000..4396eb3
--- a/dev/null
+++ b/res/rrq.ico
Binary files differ
diff --git a/res/wrq.ico b/res/wrq.ico
new file mode 100644
index 0000000..4e32659
--- a/dev/null
+++ b/res/wrq.ico
Binary files differ
diff --git a/resource.h b/resource.h
new file mode 100644
index 0000000..fcdda9c
--- a/dev/null
+++ b/resource.h
@@ -0,0 +1,147 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by PumpKIN.rc
+//
+#define IDM_ABOUTBOX 0x0010
+#define IDD_ABOUTBOX 100
+#define IDS_ABOUTBOX 101
+#define IDC_TRAYICON 101
+#define IDD_PUMPKIN_DIALOG 102
+#define IDS_FMT_BYTES 102
+#define IDP_SOCKETS_INIT_FAILED 103
+#define IDS_TFTP_ERROR_ACCESS 104
+#define IDS_TFTP_ERROR_NOTFOUND 105
+#define IDS_TFTP_ERROR_DIRFULL 106
+#define IDD_PROPS_SERVER 106
+#define IDS_TFTP_ERROR_SHARING 107
+#define IDD_PROPS_NETWORK 107
+#define IDS_TFTP_ERROR_DISKFULL 108
+#define IDS_TFTP_ERROR_UNDEFINED 109
+#define IDS_LOG_START 110
+#define IDS_LOG_LISTENRECEIVEERROR 111
+#define IDS_LOG_LISTENACCEPTERROR 112
+#define IDS_LOG_RRQSERVE 113
+#define IDS_LOG_LISTENOPCODE 114
+#define IDS_LOG_XFERUDPSEND 115
+#define IDS_LOG_XFERRECEIVE 116
+#define IDS_LOG_XFERSEND 117
+#define IDS_LOG_XFERUDPRECEIVE 118
+#define IDS_LOG_XFERSOURCETID 119
+#define IDS_LOG_SENTTFTPERROR 120
+#define IDS_LOG_GOTTFTPERROR 121
+#define IDS_LOG_XFEROPCODE 122
+#define IDS_LOG_XFERRRQFINISHED 123
+#define IDS_TITLE_OPTIONS 124
+#define IDS_LOG_WRQSERVE 125
+#define IDS_TFTP_ERROR_FAILEDTORENAME 126
+#define IDS_RENAME_TITLE 127
+#define IDR_MAINFRAME 128
+#define IDS_LOG_TIMEDOUT 128
+#define IDS_CONFIRMEXIT_TITLE 129
+#define IDI_RRQ 129
+#define IDS_CONFIRMEXIT_TEXT 130
+#define IDI_WRQ 130
+#define IDD_CONFIRM_RRQ 131
+#define IDS_LOG_XFERWRQFINISHED 131
+#define IDD_CONFIRM_WRQ 132
+#define IDB_BACKGROUND 132
+#define IDS_LOG_XFERABORTED 132
+#define IDS_TITLE_PUTREQUEST 133
+#define IDS_TITLE_GETREQUEST 134
+#define IDR_WAVE_RING 135
+#define IDS_TALKHEADING 135
+#define IDS_WTALKHEADING 135
+#define IDR_WAVE_FINISHED 136
+#define IDS_TITLE_BROWSEFILE 136
+#define IDD_REQUEST 137
+#define IDS_LOG_RESOLVEFAILED 137
+#define IDS_LOG_FAILEDLOCALFILE 138
+#define IDD_PROPS_SOUNDS 138
+#define IDS_LOG_FAILEDTOOPEN 139
+#define IDM_POPUPS 140
+#define IDS_OTALXHEADING 140
+#define IDS_REGISTRYKEY 141
+#define IDS_KLEVERNET_URL 142
+#define IDR_WAVE_ABORTED 142
+#define IDS_LOGTIMEFORMAT 143
+#define IDS_DROPFILES_TITLE 144
+#define IDS_NOMULTIPLEDROP_TEXT 145
+#define IDI_BROWSE 145
+#define IDS_LOG_REQUESTING 146
+#define IDS_LOG_SENDING 147
+#define IDS_WTALKAT 148
+#define IDS_OTALXAT 149
+#define IDI_PLAY 149
+#define IDS_TFTP_ERROR_TSIZE 150
+#define IDS_TFTP_ERROR_BSIZE 151
+#define IDS_TFTP_ERROR_TOUT 152
+#define IDS_SELECT_TFTPROOT 153
+#define IDS_FILTER_WAV 154
+#define IDS_TITLE_WAV 155
+#define IDC_KLEVERNET 1000
+#define IDC_CONNECTIONS 1001
+#define IDC_LOG 1003
+#define IDC_GET 1004
+#define IDC_PUT 1005
+#define IDC_ABORT 1006
+#define IDC_EXIT 1007
+#define IDC_TFTPROOT 1008
+#define IDC_TFTPSUBDIRS 1009
+#define IDC_RRQ_GIVEALL 1010
+#define IDC_RRQ_ALWAYSCONFIRM 1011
+#define IDC_RRQ_DENYALL 1012
+#define IDC_WRQ_TAKEALL 1013
+#define IDC_WRQ_PROMPTEXISTING 1014
+#define IDC_WRQ_ALWAYSCONFIRM 1015
+#define IDC_WRQ_DENYALL 1016
+#define IDC_PROMPTTIMEOUT 1017
+#define IDC_LISTENPORT 1018
+#define IDC_LISTENSPIN 1019
+#define IDC_SPEAKPORT 1020
+#define IDC_SPEAKSPIN 1021
+#define IDC_MAXUDPSIZE 1022
+#define IDC_MAXUDPSPIN 1023
+#define IDC_TIMEOUT 1024
+#define IDC_TIMESPIN 1025
+#define IDC_OPTIONS 1026
+#define IDC_BLOCKSIZE 1026
+#define IDC_BSIZESPIN 1027
+#define IDC_HOST 1028
+#define IDC_FILE 1029
+#define IDC_RENAME 1030
+#define IDC_REMOTEFILE 1030
+#define IDC_RESUME 1031
+#define IDC_REFRESH 1032
+#define IDC_BROWSE 1034
+#define IDC_TALKS 1035
+#define IDC_LOCALFILE 1036
+#define IDC_TYPE 1037
+#define IDC_BSIZE 1039
+#define IDC_RING 1041
+#define IDC_RING_BROWSE 1042
+#define IDC_RING_PLAY 1043
+#define IDC_FINISHED 1044
+#define IDC_FINISHED_BROWSE 1045
+#define IDC_FINISHED_PLAY 1046
+#define IDC_ABORTED 1047
+#define IDC_ABORTED_BROWSE 1048
+#define IDC_ABORTED_PLAY 1049
+#define ID_TRAY_HELP 32771
+#define ID_TRAY_ABOUTPUMPKIN 32772
+#define ID_TRAY_EXIT 32773
+#define ID_TRAY_SENDFILE 32774
+#define ID_TRAY_FETCHFILE 32775
+#define ID_TRAY_OPTIONS 32776
+#define ID_TRAY_SHOWPUMPKINWINDOW 32777
+#define ID_TRAY_OPENFILESFOLDER 32778
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 150
+#define _APS_NEXT_COMMAND_VALUE 32780
+#define _APS_NEXT_CONTROL_VALUE 1043
+#define _APS_NEXT_SYMED_VALUE 102
+#endif
+#endif
diff --git a/shared-code/BTreendex.h b/shared-code/BTreendex.h
new file mode 100644
index 0000000..88109ab
--- a/dev/null
+++ b/shared-code/BTreendex.h
@@ -0,0 +1,595 @@
+#ifndef __BTREENDEX_H
+#define __BTREENDEX_H
+
+#include "Dynamide.h"
+
+namespace Klever {
+
+template<class key,class value,int treeOrder,int cluster>
+class CBTreendex : public CObject {
+public:
+ typedef LONG CBTPageRef;
+ struct CBTRecordRef {
+ CBTPageRef m_Page;
+ INT m_Offset;
+ CBTRecordRef(CBTPageRef page=-1,INT offset=-1) : m_Page(page), m_Offset(offset) {}
+ };
+ class CBTRecord : public CObject {
+ public:
+ CBTPageRef m_ptrLeft;
+ CBTPageRef m_ptrRight;
+ key m_Key;
+ value m_Value;
+ CBTRecord() : m_ptrLeft(-1), m_ptrRight(-1) {}
+ CBTRecord(key& _key,value& _value,CBTPageRef left=-1,CBTPageRef right=-1) : m_Key(_key), m_Value(_value), m_ptrLeft(left), m_ptrRight(right) {}
+ CBTRecord(CBTRecord& r) : m_Key(r.m_Key), m_Value(r.m_Value), m_ptrLeft(r.m_ptrLeft), m_ptrRight(r.m_ptrRight) {}
+
+ CBTRecord& operator=(CBTRecord& r) {m_Key=r.m_Key, m_Value=r.m_Value, m_ptrLeft=r.m_ptrLeft, m_ptrRight=r.m_ptrRight;return *this;}
+
+ void Serialize(CArchive& ar) {
+ if(ar.IsStoring()){
+ ar << m_ptrLeft;
+ ar << m_ptrRight;
+ }else{
+ ar >> m_ptrLeft;
+ ar >> m_ptrRight;
+ }
+ SerializeElements(ar,&m_Key,1);
+ SerializeElements(ar,&m_Value,1);
+ }
+ };
+ class CBTPage : public CArray<CBTRecord,CBTRecord&> {
+ public:
+ void Serialize(CArchive& ar) {
+ int nCount = -1;
+ if(ar.IsStoring()){
+ nCount = GetSize();
+ ar << nCount;
+ }else{
+ nCount = 0;
+ ar >> nCount;
+ RemoveAll();
+ SetSize(nCount);
+ }
+ for(int tmp=0;tmp<nCount;tmp++)
+ ElementAt(tmp).Serialize(ar);
+ }
+ };
+ typedef CDynamide<256,cluster> CBTDyna;
+ typedef CBTDyna::CDynaFile CBTDynaFile;
+ typedef CArray<CBTRecordRef,CBTRecordRef&> CBTRStack;
+
+ CBTDyna m_BT;
+ struct _btCrap {
+ BOOL m_bRootSet;
+ CBTPageRef m_Root;
+ } *m_BTCrap;
+ BOOL m_bRO;
+ CBTRStack m_btStack;
+ CBTPage m_stackTop;
+
+ CBTreendex() {}
+ ~CBTreendex() { Close(); }
+ BOOL Attach(CFile* file,BOOL bAutodelete) {
+ m_bRO = FALSE;
+ if(!m_BT.Attach(file,bAutodelete))
+ return FALSE;
+ return Attach();
+ }
+ BOOL Open(LPCTSTR file,BOOL bReadOnly) {
+ if(!m_BT.Open(file,bReadOnly))
+ return FALSE;
+ m_bRO = bReadOnly;
+ return Attach();
+ }
+ BOOL Create(LPCTSTR file) {
+ try{
+ CFile* f = new CFile(file,CFile::modeCreate|CFile::modeReadWrite|CFile::shareDenyRead|CFile::shareDenyWrite|CFile::typeBinary);
+ ASSERT(f);
+ return Attach(f,TRUE);
+ }catch(CException* e){
+ e->Delete();
+ return FALSE;
+ }
+ }
+ BOOL Attach() {
+ ASSERT(m_BT.IsOpened());
+ m_BTCrap = (_btCrap*)m_BT.m_FB.crap;
+ if(!m_BTCrap->m_bRootSet){
+ m_BTCrap->m_Root = AllocatePage();
+ if(m_BTCrap->m_Root<0)
+ return FALSE;
+ m_BTCrap->m_bRootSet = TRUE;
+ m_BT.Write1stBlock();
+ }
+ return TRUE;
+ }
+ BOOL Close() {
+ m_BT.Close();
+ return TRUE;
+ }
+ BOOL IsOpened() {
+ return m_BT.IsOpened();
+ }
+
+ BOOL Lookup(key& _key,value& value) {
+ if(!IsOpened())
+ return FALSE;
+ ASSERT(m_BTCrap->m_bRootSet);
+ if(!SeekToPage(_key))
+ return FALSE;
+ CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()];
+ if(rr.m_Offset<0)
+ return FALSE;
+ ASSERT(rr.m_Offset<m_stackTop.GetSize());
+ if(_key != m_stackTop[rr.m_Offset].m_Key)
+ return FALSE;
+ value = m_stackTop[rr.m_Offset].m_Value;
+ return TRUE;
+ }
+ BOOL Add(key& _key,value& _value) {
+ if(!IsOpened())
+ return FALSE;
+ ASSERT(m_BTCrap->m_bRootSet);
+ if(!SeekToPage(_key))
+ return FALSE;
+ CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()];
+ CBTRecord nuRecord(_key,_value);
+ if(rr.m_Offset<0){
+ if(m_stackTop.GetSize())
+ nuRecord.m_ptrLeft = m_stackTop[m_stackTop.GetUpperBound()].m_ptrRight;
+ }else if(rr.m_Offset==0){
+ nuRecord.m_ptrRight = m_stackTop[0].m_ptrLeft;
+ }else{
+ nuRecord.m_ptrLeft = m_stackTop[rr.m_Offset-1].m_ptrRight;
+ nuRecord.m_ptrRight = m_stackTop[rr.m_Offset].m_ptrLeft;
+ }
+// ASSERT(rr.m_Offset==0 || (m_stackTop[rr.m_Offset-1].m_Key<_key && m_stackTop[rr.m_Offset-1].m_ptrRight<0));
+// ASSERT(rr.m_Offset<0 || m_stackTop[rr.m_Offset].m_Key>=_key && m_stackTop[rr.m_Offset].m_ptrLeft<0);
+ if(rr.m_Offset>=0 && m_stackTop[rr.m_Offset].m_Key==_key){
+ // Exact match found - just replace.
+ m_stackTop[rr.m_Offset].m_Value = _value;
+ if(!SavePage(rr.m_Page,m_stackTop))
+ return FALSE;
+ return TRUE;
+ }
+ // Split the page and propagate the split if needed..
+ // Insert new element at rr.m_Offset..
+ BOOL nuisnew = TRUE;
+ for(int sp=m_btStack.GetUpperBound();sp>=0;sp--){
+ CBTPageRef opr = m_btStack[sp].m_Page;
+ int iAt = m_btStack[sp].m_Offset;
+ CBTPage op;
+ VERIFY(LoadPage(opr,op));
+ if(iAt<0)
+ iAt = op.GetSize();
+ else{
+ if(op[iAt].m_Key<nuRecord.m_Key)
+ iAt++;
+ ASSERT(iAt==op.GetSize() || op[iAt].m_Key > nuRecord.m_Key);
+ }
+ op.InsertAt(iAt,nuRecord);
+ if(iAt>0)
+ op[iAt-1].m_ptrRight=nuRecord.m_ptrLeft;
+ if(iAt<op.GetUpperBound())
+ op[iAt+1].m_ptrLeft=nuRecord.m_ptrRight;
+ if(op.GetSize()<=treeOrder*2){
+ // This isn't causing overflow
+ VERIFY(SavePage(opr,op));
+ return TRUE;
+ }
+ TRACE0("Split\n");
+ ASSERT(op.GetSize()==(treeOrder*2+1));
+ CBTPageRef npr = AllocatePage();
+ ASSERT(npr>=0);
+ CBTPage np;
+ ASSERT(LoadPage(npr,np));
+ ASSERT(!np.GetSize());
+ nuRecord = op[treeOrder];
+ if(iAt==treeOrder){
+ // We're inserting central element! - drop out the stack top if this is still new one
+ for(int tmp=0;tmp<treeOrder;tmp++)
+ np.InsertAt(tmp,op[tmp]);
+ op.RemoveAt(0,treeOrder+1);
+ nuRecord.m_ptrLeft = npr;
+ nuRecord.m_ptrRight = opr;
+ if(nuisnew)
+ m_btStack.RemoveAt(m_btStack.GetUpperBound());
+ }else{
+ if(iAt<treeOrder){
+ // We're inserting in the left subtree.
+ // Make newpage the right one and forget it.
+ for(int tmp=0;tmp<treeOrder;tmp++)
+ np.InsertAt(tmp,op[tmp+treeOrder+1]);
+ op.RemoveAt(treeOrder,treeOrder+1);
+ nuRecord.m_ptrLeft = opr;
+ nuRecord.m_ptrRight = npr;
+ }else{
+ // We're inserting in the right subtree.
+ // Make newpage the left one, forget it, but also adjust offset in the stack
+ for(int tmp=0;tmp<treeOrder;tmp++)
+ np.InsertAt(tmp,op[tmp]);
+ op.RemoveAt(0,treeOrder+1);
+ nuRecord.m_ptrLeft = npr;
+ nuRecord.m_ptrRight = opr;
+ m_btStack[sp].m_Offset-=treeOrder+1;
+ }
+ // Note that we're not inserting new element anymore.
+ nuisnew = FALSE;
+ }
+ // Do, excessive sanity checks and save pages
+ ASSERT(op.GetSize());
+ ASSERT(np.GetSize());
+ VERIFY(SavePage(opr,op));
+ VERIFY(SavePage(npr,np));
+ }
+ // Here we have root page overflow, which means that we're simply putting new
+ // record in this brand new root page and also inserting this page on the bottom of the stack
+ CBTPageRef nuroot = AllocatePage();
+ ASSERT(nuroot>=0);
+ CBTPage nurpa;
+ ASSERT(LoadPage(nuroot,nurpa));
+ ASSERT(!nurpa.GetSize());
+ nurpa.Add(nuRecord);
+ VERIFY(SavePage(nuroot,nurpa));
+ m_btStack.InsertAt(0,CBTRecordRef(nuroot,0));
+ m_BTCrap->m_Root = nuroot;
+ m_BT.Write1stBlock();
+ return TRUE;
+ }
+ BOOL Delete(key& _key) {
+ if(!IsOpened())
+ return FALSE;
+ ASSERT(m_BTCrap->m_bRootSet);
+ value _value;
+ if(!Lookup(_key,_value))
+ return FALSE;
+ // Found key, check if it's a leaf
+ {
+ CBTRecordRef* rr = &m_btStack[m_btStack.GetUpperBound()];
+ int rrIdx = m_btStack.GetUpperBound();
+ if(m_stackTop[rr->m_Offset].m_ptrLeft>=0){
+ ASSERT(m_stackTop[rr->m_Offset].m_ptrRight>=0);
+ // It isn't - scan for the _next_ key and do dirty deeds
+ m_btStack.Add(CBTRecordRef(m_stackTop[rr->m_Offset].m_ptrRight,0));
+ for(;;){
+ CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()];
+ if(!LoadPage(rr.m_Page,m_stackTop))
+ return FALSE;
+ if(m_stackTop[0].m_ptrLeft<0)
+ break;
+ m_btStack.Add(CBTRecordRef(m_stackTop[0].m_ptrLeft,0));
+ }
+ // We have a leaf node here, replace victim with the first element and kill it.
+ CBTPage uppage;
+ rr = &m_btStack[rrIdx];
+ if(!LoadPage(rr->m_Page,uppage))
+ return FALSE;
+ uppage[rr->m_Offset].m_Key=m_stackTop[0].m_Key; uppage[rr->m_Offset].m_Value=m_stackTop[0].m_Value;
+ m_stackTop.RemoveAt(0);
+ if(!(SavePage(rr->m_Page,uppage) && SavePage(m_btStack[m_btStack.GetUpperBound()].m_Page,m_stackTop)))
+ return FALSE;
+ }else{
+ ASSERT(m_stackTop[rr->m_Offset].m_ptrRight<0);
+ m_stackTop.RemoveAt(rr->m_Offset);
+ if(!SavePage(rr->m_Page,m_stackTop))
+ return FALSE;
+ }
+ }
+ // We have a page to check for underflow at the top of the stack now.
+ for(;;){
+ CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()];
+ if(!LoadPage(rr.m_Page,m_stackTop))
+ return FALSE;
+ if(m_stackTop.GetSize()>=treeOrder || m_btStack.GetSize()==1)
+ return TRUE;
+ CBTRecordRef& rr1 = m_btStack[m_btStack.GetUpperBound()-1];
+ CBTPage daddy;
+ if(!LoadPage(rr1.m_Page,daddy))
+ return FALSE;
+ CBTPageRef nPage = daddy[rr1.m_Offset].m_ptrRight;
+ BOOL bRight=TRUE;
+ if(nPage<0 || nPage==rr.m_Page){
+ nPage = daddy[rr1.m_Offset].m_ptrLeft;
+ bRight = FALSE;
+ }
+ ASSERT(nPage>=0 && nPage!=rr.m_Page);
+ CBTPage neighbor;
+ if(!LoadPage(nPage,neighbor))
+ return FALSE;
+ // Here we have possibly two cases:
+ // 1. Neighboring page can share some data with use, then do share and leave
+ // 2. Neighboring page is of treeorder in size, then merge and propagate
+ if(neighbor.GetSize()>treeOrder){
+ TRACE0("Redistributing..\n");
+ // Borrow some data from there.
+ int toBorrow = neighbor.GetSize()-treeOrder;
+ toBorrow=toBorrow/2+1;
+ ASSERT(toBorrow);
+ if(bRight)
+ m_stackTop.Add(CBTRecord(daddy[rr1.m_Offset].m_Key,daddy[rr1.m_Offset].m_Value,m_stackTop[m_stackTop.GetUpperBound()].m_ptrRight,neighbor[0].m_ptrLeft));
+ else
+ m_stackTop.InsertAt(0,CBTRecord(daddy[rr1.m_Offset].m_Key,daddy[rr1.m_Offset].m_Value,neighbor[neighbor.GetUpperBound()].m_ptrRight,m_stackTop[0].m_ptrLeft));
+ for(toBorrow--;toBorrow;toBorrow--){
+ if(bRight){
+ m_stackTop.Add(neighbor[0]);
+ neighbor.RemoveAt(0);
+ }else{
+ m_stackTop.InsertAt(0,neighbor[neighbor.GetUpperBound()]);
+ neighbor.RemoveAt(neighbor.GetUpperBound());
+ }
+ }
+ daddy[rr1.m_Offset].m_Key = neighbor[bRight?0:neighbor.GetUpperBound()].m_Key; daddy[rr1.m_Offset].m_Value = neighbor[bRight?0:neighbor.GetUpperBound()].m_Value;
+ neighbor.RemoveAt(bRight?0:neighbor.GetUpperBound());
+ if(!(SavePage(rr1.m_Page,daddy) && SavePage(nPage,neighbor) && SavePage(rr.m_Page,m_stackTop)))
+ return FALSE;
+ rr.m_Offset = -1; // *** Point to the next??
+ return TRUE;
+ }
+ TRACE0("Merging..\n");
+ // We need to merge pages here..
+ // We will merge them at stacktop, then we'll discard neighbor guy..
+ if(bRight)
+ m_stackTop.Add(CBTRecord(daddy[rr1.m_Offset].m_Key,daddy[rr1.m_Offset].m_Value,m_stackTop[m_stackTop.GetUpperBound()].m_ptrRight,neighbor[0].m_ptrLeft));
+ else
+ m_stackTop.InsertAt(0,CBTRecord(daddy[rr1.m_Offset].m_Key,daddy[rr1.m_Offset].m_Value,neighbor[neighbor.GetUpperBound()].m_ptrRight,m_stackTop[0].m_ptrLeft));
+ if(bRight){
+ while(neighbor.GetSize()){
+ m_stackTop.Add(neighbor[0]);
+ neighbor.RemoveAt(0);
+ }
+ }else{
+ while(neighbor.GetSize()){
+ m_stackTop.InsertAt(0,neighbor[neighbor.GetUpperBound()]);
+ neighbor.RemoveAt(neighbor.GetUpperBound());
+ }
+ }
+ if(rr1.m_Offset>0)
+ daddy[rr1.m_Offset-1].m_ptrRight=rr.m_Page;
+ if(rr1.m_Offset<daddy.GetUpperBound())
+ daddy[rr1.m_Offset+1].m_ptrLeft=rr.m_Page;
+ daddy.RemoveAt(rr1.m_Offset);
+ if(!(SavePage(rr1.m_Page,daddy) && SavePage(rr.m_Page,m_stackTop)))
+ return FALSE;
+ VERIFY(DeallocatePage(nPage));
+ m_btStack.RemoveAt(m_btStack.GetUpperBound());
+ }
+ return FALSE;
+ }
+ BOOL GoFirst() {
+ if(!IsOpened())
+ return FALSE;
+ ASSERT(m_BTCrap->m_bRootSet);
+ m_btStack.RemoveAll();
+ m_btStack.Add(CBTRecordRef(m_BTCrap->m_Root,-1));
+ for(;;){
+ CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()];
+ if(!LoadPage(rr.m_Page,m_stackTop))
+ return FALSE;
+ if(!m_stackTop.GetSize()){
+ ASSERT(m_btStack.GetSize()==1);
+ return FALSE;
+ }
+ rr.m_Offset = 0;
+ if(m_stackTop[rr.m_Offset].m_ptrLeft<0)
+ return TRUE;
+ m_btStack.Add(CBTRecordRef(m_stackTop[rr.m_Offset].m_ptrLeft,-1));
+ }
+ }
+ BOOL GoLast() {
+ if(!IsOpened())
+ return FALSE;
+ ASSERT(m_BTCrap->m_bRootSet);
+ m_btStack.RemoveAll();
+ m_btStack.Add(CBTRecordRef(m_BTCrap->m_Root,-1));
+ for(;;){
+ CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()];
+ if(!LoadPage(rr.m_Page,m_stackTop))
+ return FALSE;
+ if(!m_stackTop.GetSize()){
+ ASSERT(m_btStack.GetSize()==1);
+ return FALSE;
+ }
+ rr.m_Offset = m_stackTop.GetUpperBound();
+ if(m_stackTop[rr.m_Offset].m_ptrRight<0)
+ return TRUE;
+ m_btStack.Add(CBTRecordRef(m_stackTop[rr.m_Offset++].m_ptrRight,-1));
+ }
+ }
+ BOOL GoNext() {
+ if(!IsOpened())
+ return FALSE;
+ if(!(m_btStack.GetSize() && m_btStack[m_btStack.GetUpperBound()].m_Offset>=0))
+ return FALSE;
+ CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()];
+ if(!LoadPage(rr.m_Page,m_stackTop))
+ return FALSE;
+ ASSERT(rr.m_Offset<m_stackTop.GetSize());
+ if(m_stackTop[rr.m_Offset].m_ptrRight>=0){
+ // Advance pointer in this page and dive into subtree
+ // going left and left until we have nowhere to go.
+// TRACE1("Dive into page %lu",m_stackTop[rr.m_Offset].m_ptrRight);
+ m_btStack.Add(CBTRecordRef(m_stackTop[rr.m_Offset++].m_ptrRight,0));
+ for(;;){
+ CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()];
+ ASSERT(rr.m_Offset==0);
+ if(!LoadPage(rr.m_Page,m_stackTop))
+ return FALSE;
+ if(m_stackTop[rr.m_Offset].m_ptrLeft<0)
+ break;
+// TRACE1(", %lu",m_stackTop[rr.m_Offset].m_ptrLeft);
+ m_btStack.Add(CBTRecordRef(m_stackTop[rr.m_Offset].m_ptrLeft,0));
+ }
+// TRACE0("\n");
+ return TRUE;
+ }else if(rr.m_Offset<m_stackTop.GetUpperBound()){
+ rr.m_Offset++;
+ return TRUE;
+ }
+ // We're at the end of page go up until we're done or we have data.
+ m_btStack.RemoveAt(m_btStack.GetUpperBound());
+// TRACE0("Go up");
+ while(m_btStack.GetSize()){
+ CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()];
+ if(!LoadPage(rr.m_Page,m_stackTop))
+ return FALSE;
+ if(rr.m_Offset<m_stackTop.GetSize()){
+// TRACE0("\n");
+ return TRUE;
+ }
+// TRACE0(", up");
+ m_btStack.RemoveAt(m_btStack.GetUpperBound());
+ }
+// TRACE0("\nBtree is done\n");
+ return FALSE;
+ }
+ BOOL GoPrev() {
+ if(!IsOpened())
+ return FALSE;
+ if(!(m_btStack.GetSize() && m_btStack[m_btStack.GetUpperBound()].m_Offset>=0))
+ return FALSE;
+ CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()];
+ if(!LoadPage(rr.m_Page,m_stackTop))
+ return FALSE;
+ ASSERT(rr.m_Offset<m_stackTop.GetSize());
+ if(m_stackTop[rr.m_Offset].m_ptrLeft>=0){
+ // Dive in and go right and right from the rightmost until
+ // we have nowhere to go.
+ m_btStack.Add(CBTRecordRef(m_stackTop[rr.m_Offset].m_ptrLeft,-1));
+ for(;;){
+ CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()];
+ if(!LoadPage(rr.m_Page,m_stackTop))
+ return FALSE;
+ rr.m_Offset = m_stackTop.GetUpperBound();
+ if(m_stackTop[rr.m_Offset].m_ptrRight<0)
+ return TRUE;
+ m_btStack.Add(CBTRecordRef(m_stackTop[rr.m_Offset++].m_ptrRight,-1));
+ }
+ return TRUE;
+ }else if(rr.m_Offset>0){
+ rr.m_Offset--;
+ return TRUE;
+ }
+ // We're at the leftmost element in page - go up and left until we're
+ // done or we have data.
+ m_btStack.RemoveAt(m_btStack.GetUpperBound());
+ while(m_btStack.GetSize()){
+ CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()];
+ if(!LoadPage(rr.m_Page,m_stackTop))
+ return FALSE;
+ rr.m_Offset--;
+ if(rr.m_Offset>=0)
+ return TRUE;
+ m_btStack.RemoveAt(m_btStack.GetUpperBound());
+ }
+ // No more data - we were at the first element in tree.
+ return FALSE;
+ }
+ BOOL GetThis(key& _key,value& _value) {
+ if(!IsOpened())
+ return FALSE;
+ // *** MORE CHECKING
+ CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()];
+ if(!LoadPage(rr.m_Page,m_stackTop))
+ return FALSE;
+ _key = m_stackTop[rr.m_Offset].m_Key;
+ _value = m_stackTop[rr.m_Offset].m_Value;
+ return TRUE;
+ }
+
+ BOOL SeekToPage(const key& _key) {
+ ASSERT(IsOpened());
+ ASSERT(m_BTCrap->m_bRootSet);
+ m_btStack.RemoveAll();
+ m_btStack.Add(CBTRecordRef(m_BTCrap->m_Root,-1));
+ for(;;){
+ CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()];
+ if(!LoadPage(rr.m_Page,m_stackTop))
+ return FALSE;
+ ASSERT(m_stackTop.GetSize() || !m_btStack.GetUpperBound());
+ if(!m_stackTop.GetSize()){
+ rr.m_Offset=-1;
+ return TRUE;
+ }
+ for(rr.m_Offset=0;rr.m_Offset<m_stackTop.GetSize();rr.m_Offset++){
+ if(_key == m_stackTop[rr.m_Offset].m_Key)
+ return TRUE;
+ if(_key < m_stackTop[rr.m_Offset].m_Key){
+ ASSERT(rr.m_Offset==0 || m_stackTop[rr.m_Offset].m_ptrLeft==m_stackTop[rr.m_Offset-1].m_ptrRight);
+ if(m_stackTop[rr.m_Offset].m_ptrLeft<0)
+ return TRUE;
+ m_btStack.Add(CBTRecordRef(m_stackTop[rr.m_Offset].m_ptrLeft,-1));
+ break;
+ }
+ if(rr.m_Offset==m_stackTop.GetUpperBound()){
+ if(m_stackTop[rr.m_Offset].m_ptrRight<0){
+ rr.m_Offset=-1;
+ return TRUE;
+ }
+ m_btStack.Add(CBTRecordRef(m_stackTop[rr.m_Offset].m_ptrRight,-1));
+ break;
+ }
+ }
+ }
+ }
+
+ BOOL LoadPage(CBTPageRef ref,CBTPage& page) {
+ CFile* pageFile = m_BT.OpenFile(ref);
+ if(!pageFile)
+ return FALSE;
+ BOOL rv = TRUE;
+ try{
+ CArchive ar(pageFile,CArchive::load);
+ page.Serialize(ar);
+ if(m_bRO)
+ page.FreeExtra(); // ** ???
+ ar.Close();
+ }catch(CException* e){
+ e->Delete();
+ rv = FALSE;
+ }
+ delete pageFile;
+ return rv;
+ }
+ BOOL SavePage(CBTPageRef ref,CBTPage& page) {
+ CFile* pageFile = m_BT.OpenFile(ref);
+ if(!pageFile)
+ return FALSE;
+ BOOL rv = TRUE;
+ try{
+ CArchive ar(pageFile,CArchive::store);
+ page.Serialize(ar);
+ ar.Close();
+ }catch(CException* e){
+ e->Delete();
+ rv = FALSE;
+ }
+ delete pageFile;
+ return rv;
+ }
+ CBTPageRef AllocatePage() {
+ CBTDynaFile* pageFile = m_BT.CreateFile();
+ if(!pageFile)
+ return -1;
+ CBTPage nothing;
+ CBTPageRef rv = pageFile->GetFile();
+ try{
+ CArchive ar(pageFile,CArchive::store);
+ nothing.Serialize(ar);
+ ar.Close();
+ }catch(CException* e){
+ e->Delete();
+ rv = -1;
+ }
+ delete pageFile;
+ return rv;
+ }
+ BOOL DeallocatePage(CBTPageRef ref) {
+ return m_BT.DeleteFile(ref);
+ }
+
+};
+
+};
+
+#endif // __BTREENDEX_H
diff --git a/shared-code/BellsNWhistles.h b/shared-code/BellsNWhistles.h
new file mode 100644
index 0000000..1de77ae
--- a/dev/null
+++ b/shared-code/BellsNWhistles.h
@@ -0,0 +1,146 @@
+#ifndef __BELLSNWHISTLES_H
+#define __BELLSNWHISTLES_H
+
+class CBellsNWhistles {
+public:
+ class CBang {
+ public:
+ CString m_codeName;
+ enum _bangType {
+ bangNone, bangSpeaker, bangSystem, bangResource,
+ bangWaveform
+ } m_type;
+ BOOL m_bLoop;
+ union {
+ UINT system;
+ LPCTSTR resource;
+ LPCTSTR wave;
+
+ LPCTSTR str;
+ UINT id;
+ };
+ CString m_strWave;
+ CBang() : m_type(bangNone), m_bLoop(FALSE) {}
+ };
+ typedef CTypedPtrMap<CMapStringToPtr,CString,CBang*> CBangs;
+ struct CBelling {
+ LPCSTR snd;
+ HMODULE hm;
+ DWORD flags;
+ CBelling(LPCSTR snd,HMODULE hm,DWORD flags) : snd(snd), hm(hm),
+ flags(flags) {}
+ CBelling(CBelling& s) : snd(s.snd), hm(s.hm), flags(s.flags) {}
+ CBelling& operator=(CBelling& s) {
+ snd=s.snd; hm=s.hm; flags=s.flags;
+ return *this;
+ }
+ };
+ typedef CBelling* Whistling;
+
+ CBangs m_bangs;
+
+ ~CBellsNWhistles() {
+ POSITION p = m_bangs.GetStartPosition();
+ while(p){
+ CString s; CBang* b;
+ m_bangs.GetNextAssoc(p,s,b);
+ delete b;
+ }
+ m_bangs.RemoveAll();
+ }
+
+ BOOL AssignSound(LPCTSTR codeName,LPCTSTR id,CBang::_bangType type=CBang::bangWaveform) {
+ CString cn = codeName;
+ cn.MakeLower();
+ CBang* b;
+ if(!m_bangs.Lookup(cn,b)) {
+ b = new CBang;
+ b->m_codeName=cn;
+ m_bangs[cn]=b;
+ }
+ b->m_type=type;
+ b->str = id;
+ if(type==CBang::bangWaveform){
+ b->m_strWave=id; b->str = b->m_strWave;
+ }
+ return TRUE;
+ }
+ BOOL AssignSound(LPCTSTR codeName,UINT nID,CBang::_bangType type=CBang::bangResource) {
+ CString cn = codeName;
+ cn.MakeLower();
+ CBang* b;
+ if(!m_bangs.Lookup(cn,b)) {
+ b = new CBang;
+ b->m_codeName=cn;
+ m_bangs[cn]=b;
+ }
+ b->m_type=type;
+ b->id = nID;
+ ASSERT(type!=CBang::bangWaveform);
+ return TRUE;
+ }
+ BOOL UnassignSound(LPCTSTR codeName) {
+ CString cn = codeName;
+ cn.MakeLower();
+ CBang* b;
+ if(m_bangs.Lookup(cn,b)) {
+ m_bangs.RemoveKey(cn);
+ delete b;
+ return TRUE;
+ }
+ return FALSE;
+ }
+
+ Whistling StartSound(LPCTSTR codeName) {
+ Whistling* rv = NULL;
+ CString cn = codeName;
+ CBang* b;
+ if(!m_bangs.Lookup(cn,b)){
+ ::PlaySound(cn,AfxGetInstanceHandle(),SND_ASYNC|SND_NODEFAULT|SND_NOWAIT|SND_FILENAME);
+ return NULL;
+ }
+ UINT flags = SND_ASYNC|SND_NODEFAULT|SND_NOWAIT;
+ LPCSTR snd = NULL;
+ switch(b->m_type){
+ case CBang::bangNone: return NULL;
+ case CBang::bangSpeaker: MessageBeep(0xFFFFFFFF); return NULL;
+ case CBang::bangSystem: MessageBeep(b->system); return NULL;
+ case CBang::bangResource:
+ snd = b->resource;
+ flags|=SND_RESOURCE; break;
+ case CBang::bangWaveform:
+ snd = b->wave;
+ flags|=SND_FILENAME; break;
+#ifdef _DEBUG
+ default:
+ ASSERT(FALSE); return NULL;
+#endif
+ }
+ if(b->m_bLoop)
+ flags|=SND_LOOP;
+ HMODULE hm = AfxGetInstanceHandle();
+ if(!::PlaySound(snd,hm,flags))
+ return NULL;
+ return b->m_bLoop?new CBelling(snd,hm,flags):NULL;
+ }
+ BOOL StopSound(Whistling whistle) {
+ if(!whistle)
+ return FALSE;
+ ::PlaySound(whistle->snd,whistle->hm,whistle->flags|SND_PURGE);
+ delete whistle;
+ return TRUE;
+ }
+ UINT FillInCombo(CComboBox* combo) {
+ POSITION p = m_bangs.GetStartPosition();
+ UINT rv = 0;
+ while(p) {
+ CString s;
+ CBang* b;
+ m_bangs.GetNextAssoc(p,s,b);
+ combo->AddString(s);
+ }
+ return rv;
+ }
+};
+
+#endif // _BELLSNWHISTLES_H \ No newline at end of file
diff --git a/shared-code/BitSet.h b/shared-code/BitSet.h
new file mode 100644
index 0000000..cf36e3b
--- a/dev/null
+++ b/shared-code/BitSet.h
@@ -0,0 +1,105 @@
+#ifndef __BITSET_H
+#define __BITSET_H
+
+namespace Klever {
+
+class CBitSet : public CObject {
+public:
+ CWordArray m_Bits;
+ ULONG m_BitsInSet;
+ enum {
+ bitsPerWord = sizeof(WORD)*8
+ };
+
+ CBitSet(ULONG size = 0) : m_BitsInSet(0) { SetSize(size); }
+ CBitSet(CBitSet& o) : m_BitsInSet(0) { CopyFrom(o); }
+
+ void SetSize(ULONG size,BOOL bFillOnes=FALSE) {
+ UINT os = m_Bits.GetSize();
+ UINT ns = (size+bitsPerWord-1)/bitsPerWord;
+ if(os==ns){
+ if(os){
+ if(bFillOnes)
+ m_Bits[m_BitsInSet/bitsPerWord]|=(~(WORD)0)<<(m_BitsInSet%bitsPerWord);
+ else
+ m_Bits[m_BitsInSet/bitsPerWord]&=~((~(WORD)0)<<(m_BitsInSet%bitsPerWord));
+ }
+ m_BitsInSet=size;
+ }else{
+ // *?* ASSERT((!os) || (((os-1)*bitsPerWord)<=m_BitsInSet && m_BitsInSet<(os*bitsPerWord)));
+ if(os<ns){
+ m_Bits.SetSize(ns);
+ if(bFillOnes)
+ m_Bits[m_BitsInSet/bitsPerWord]|=(~(WORD)0)<<(m_BitsInSet%bitsPerWord);
+ else
+ m_Bits[m_BitsInSet/bitsPerWord]&=~((~(WORD)0)<<(m_BitsInSet%bitsPerWord));
+ WORD* ws = m_Bits.GetData();
+ ASSERT(ws);
+ memset(&ws[os],bFillOnes?0xFF:0,(ns-os)*sizeof(WORD));
+ m_BitsInSet=size;
+ }else{
+ m_Bits.SetSize(ns);
+ m_BitsInSet=size;
+ }
+ }
+ }
+ BOOL BitSet(UINT bit,BOOL bGrow=TRUE) { return SetBit(bit,TRUE,bGrow); }
+ BOOL BitClear(UINT bit,BOOL bGrow=TRUE) { return SetBit(bit,FALSE,bGrow); }
+ BOOL SetBit(UINT bit,BOOL state,BOOL bGrow=TRUE) {
+ if(m_BitsInSet<=bit){
+ if(!bGrow)
+ return FALSE;
+ SetSize(bit+1);
+ }
+ WORD mask = ((WORD)1)<<(bit%bitsPerWord);
+ if(state)
+ m_Bits[bit/bitsPerWord]|=mask;
+ else
+ m_Bits[bit/bitsPerWord]&=~mask;
+ return TRUE;
+ }
+ BOOL IsSet(UINT bit) {
+ if(m_BitsInSet<=bit)
+ return FALSE;
+ return (m_Bits[bit/bitsPerWord]&(((WORD)1)<<(bit%bitsPerWord)))!=0;
+ }
+ void Invert() {
+ for(int i=m_Bits.GetUpperBound();i>=0;i--)
+ m_Bits[i]=~m_Bits[i];
+ }
+ CBitSet& operator&=(CBitSet& o) {
+ if(o.m_BitsInSet<m_BitsInSet)
+ SetSize(o.m_BitsInSet);
+ for(int i=m_Bits.GetUpperBound();i>=0;i--)
+ m_Bits[i]&=o.m_Bits[i];
+ return *this;
+ }
+ CBitSet& operator|=(CBitSet& o) {
+ if(o.m_BitsInSet>m_BitsInSet)
+ SetSize(o.m_BitsInSet);
+ for(int i=o.m_Bits.GetUpperBound();i>=0;i--)
+ m_Bits[i]|=o.m_Bits[i];
+ return *this;
+ }
+ CBitSet& operator=(CBitSet& o) {
+ CopyFrom(o);
+ return *this;
+ }
+ void CopyFrom(CBitSet& o) {
+ m_BitsInSet=o.m_BitsInSet;
+ m_Bits.Copy(o.m_Bits);
+ }
+ void Serialize(CArchive& ar) {
+ if(ar.IsStoring()){
+ ar << m_BitsInSet;
+ m_Bits.Serialize(ar);
+ }else{
+ ar >> m_BitsInSet;
+ m_Bits.Serialize(ar);
+ }
+ }
+};
+
+};
+
+#endif // __BITSET_H
diff --git a/shared-code/Dynamide.h b/shared-code/Dynamide.h
new file mode 100644
index 0000000..32c93f7
--- a/dev/null
+++ b/shared-code/Dynamide.h
@@ -0,0 +1,443 @@
+#ifndef __DYNAMIDE_H
+#define __DYNAMIDE_H
+
+#include "LRUCache.h"
+
+namespace Klever {
+
+template<int fbSize,int bSize>
+class CDynamide : public CObject {
+ struct firstBlock {
+ LONG freeFile;
+ BYTE crap[fbSize-sizeof(LONG)];
+ };
+ struct theBlock {
+ LONG next;
+ BYTE data[bSize-sizeof(LONG)];
+ };
+public:
+ static firstBlock FirstBlock;
+ static theBlock TheBlock;
+private:
+ class CDynaCache : public CLRUCache<DWORD,DWORD,theBlock> {
+ public:
+ CFile* m_File;
+ BOOL m_bAutodelete;
+ CDynaCache(CFile* file,BOOL bAutodelete=TRUE) : CLRUCache<DWORD,DWORD,theBlock>(64) {
+ m_File=file;
+ m_bAutodelete=bAutodelete;
+ }
+ virtual ~CDynaCache() {
+ Flush();
+ if(m_bAutodelete){
+ m_File->Close();
+ delete m_File;
+ }
+ }
+ virtual BOOL _ReadIn(DWORD idx,theBlock* data) {
+ LONG p = sizeof(firstBlock)+idx*sizeof(theBlock);
+ LONG s = m_File->Seek(p,CFile::begin);
+ if(p==s){
+ UINT rb = m_File->Read(data,sizeof(*data));
+ if(rb==sizeof(*data))
+ return TRUE;
+ if(rb)
+ return FALSE;
+ memset(data,0,sizeof(*data));
+ data->next=-1;
+ try{
+ m_File->Write(data,sizeof(*data));
+ }catch(CException* e){
+ e->Delete();
+ return FALSE;
+ }
+ }else{
+ LONG togo = p-s;
+ ASSERT(togo>0);
+ ASSERT(!(togo%sizeof(theBlock)));
+ memset(data,0,sizeof(*data));
+ data->next=-1;
+ while(togo>=0){
+ try{
+ m_File->Write(data,sizeof(*data));
+ }catch(CException* e){
+ e->Delete();
+ return FALSE;
+ }
+ }
+ }
+ return TRUE;
+ }
+ virtual BOOL _WriteOut(DWORD idx,theBlock* data) {
+ LONG p = sizeof(firstBlock)+idx*sizeof(theBlock);
+ LONG s = m_File->Seek(p,CFile::begin);
+ if(p!=s)
+ return FALSE;
+ try{
+ m_File->Write(data,sizeof(*data));
+ }catch(CException* e){
+ e->Delete();
+ return FALSE;
+ }
+ return TRUE;
+ }
+ DWORD AllocateNode() {
+ LONG l = m_File->GetLength();
+ ASSERT(!((l-sizeof(firstBlock))%sizeof(theBlock)));
+ m_File->SetLength(l+sizeof(theBlock));
+ return (l-sizeof(firstBlock))/sizeof(theBlock);
+ }
+ BOOL Read1stBlock(firstBlock* fb) {
+ m_File->SeekToBegin();
+ UINT rb = m_File->Read(fb,sizeof(*fb));
+ if(rb==sizeof(*fb))
+ return TRUE;
+ if(rb)
+ return FALSE;
+ memset(fb,0,sizeof(*fb));
+ fb->freeFile = -1;
+ try{
+ m_File->Write(fb,sizeof(*fb));
+ }catch(CException* e){
+ e->Delete();
+ return FALSE;
+ }
+ return TRUE;
+ }
+ BOOL Write1stBlock(firstBlock* fb) {
+ m_File->SeekToBegin();
+ try{
+ m_File->Write(fb,sizeof(*fb));
+ }catch(CException* e){
+ e->Delete();
+ return FALSE;
+ }
+ return TRUE;
+ }
+ };
+public:
+ class CDynaFile : public CFile {
+ public:
+ CDynamide<fbSize,bSize>* m_Daddy;
+ CArray<LONG,LONG> m_Blocks;
+ LONG m_Position;
+
+ CDynaFile(CDynamide<fbSize,bSize>* daddy) : m_Daddy(NULL) { AttachToDaddy(daddy); }
+ virtual ~CDynaFile() { Close(); DetachFromDaddy(); }
+
+ void AttachToDaddy(CDynamide<fbSize,bSize>* daddy) {
+ ASSERT(!m_Daddy);
+ ASSERT(daddy);
+ m_Daddy=daddy;
+ m_Daddy->AttachDynaFile(this);
+ }
+ void DetachFromDaddy() {
+ ASSERT(m_Daddy);
+ ASSERT(!IsOpened());
+ m_Daddy->DetachDynaFile(this);
+ m_Daddy=NULL;
+ }
+
+ BOOL Create() {
+ if(IsOpened())
+ return FALSE;
+ m_Blocks.SetAtGrow(0,m_Daddy->Allocate());
+ ASSERT(m_Blocks[0]>=0);
+ m_Position=0;
+ return TRUE;
+ }
+ BOOL Open(LONG fb) {
+ if(IsOpened())
+ return FALSE;
+ ASSERT(fb>=0);
+ theBlock* b;
+ do{
+ m_Blocks.Add(fb);
+ b = m_Daddy->m_File->GetCached(fb);
+ ASSERT(b);
+ fb=b->next;
+ if(m_Blocks[m_Blocks.GetUpperBound()]==fb)
+ return FALSE;
+ }while(fb>=0);
+ m_Position=0;
+ return TRUE;
+ }
+
+ LONG GetFile() {
+ if(!IsOpened())
+ return -1;
+ return m_Blocks[0];
+ }
+ virtual DWORD GetPosition() const {
+ if(!IsOpened())
+ return 0;
+ if(m_Position<0)
+ return 0;
+ if(m_Position>GetLength())
+ return GetLength();
+ return m_Position;
+ }
+ virtual CString GetFileName() {
+ CString rv;
+ if(IsOpened())
+ rv.Format("0x%08lX",m_Blocks[0]);
+ else
+ rv.Format("None");
+ return rv;
+ }
+ virtual CString GetFileTitle() { return GetFileName(); }
+ virtual CString GetFilePath() { return GetFileName(); }
+ virtual void SetFilePath(LPCTSTR lpszNewName) { ASSERT(FALSE); }
+
+ virtual BOOL Open(LPCTSTR lpszFileName, UINT nOpenFlags, CFileException* pError = NULL) { ASSERT(FALSE); return FALSE; }
+ virtual CFile* Duplicate() { ASSERT(FALSE); return NULL; }
+
+ virtual LONG Seek(LONG lOff, UINT nFrom) {
+ if(!IsOpened())
+ return -1;
+ switch(nFrom){
+ case CFile::begin:
+ m_Position=lOff;
+ break;
+ case CFile::current:
+ m_Position+=lOff;
+ break;
+ case CFile::end:
+ m_Position=GetLength()+lOff;
+ break;
+ default:
+ ASSERT(FALSE);
+ return -1;
+ }
+ if(m_Position<0)
+ m_Position=0;
+ if(m_Position>GetLength())
+ m_Position=GetLength();
+ return m_Position;
+ }
+ virtual void SetLength(DWORD dwNewLen) {
+ if(!IsOpened())
+ return;
+ if(dwNewLen<GetLength()){
+ dwNewLen=dwNewLen+sizeof(TheBlock.data);
+ dwNewLen-=dwNewLen%sizeof(TheBlock.data);
+ while(dwNewLen<GetLength() && m_Blocks.GetSize()>1){
+ LONG mb = m_Blocks[m_Blocks.GetUpperBound()];
+ LONG mb1 = m_Blocks[m_Blocks.GetUpperBound()-1];
+ theBlock* b = m_Daddy->m_File->GetCached(mb1);
+ ASSERT(b);
+ ASSERT(b->next==mb);
+ b->next=-1;
+ m_Daddy->m_File->MakeDirty(mb1);
+ m_Daddy->Deallocate(mb);
+ m_Blocks.SetSize(m_Blocks.GetSize()-1);
+ }
+ }else{
+ while(dwNewLen>GetLength()){
+ LONG mb = m_Blocks[m_Blocks.GetUpperBound()];
+ LONG newBlock = m_Daddy->Allocate();
+ ASSERT(newBlock>=0);
+ theBlock* b = m_Daddy->m_File->GetCached(mb);
+ ASSERT(b);
+ ASSERT(b->next<0);
+ b->next=newBlock;
+ m_Daddy->m_File->MakeDirty(mb);
+ m_Blocks.Add(newBlock);
+ }
+ }
+ }
+ virtual DWORD GetLength() const {
+ return ((long)m_Blocks.GetSize())*((long)sizeof(TheBlock.data));
+ }
+
+ virtual UINT Read(void* lpBuf, UINT nCount) {
+ UINT rv = 0;
+ ASSERT(m_Position>=0 && m_Position<=GetLength());
+ LPBYTE data = (LPBYTE)lpBuf;
+ while(nCount && m_Position<GetLength()){
+ UINT bn = m_Position/sizeof(TheBlock.data);
+ UINT bo = m_Position%sizeof(TheBlock.data);
+ theBlock* b = m_Daddy->m_File->GetCached(m_Blocks[bn]);
+ ASSERT(b);
+ UINT bc = min(nCount,sizeof(TheBlock.data)-bo);
+ memmove(data,&b->data[bo],bc);
+ nCount-=bc;
+ data=&data[bc];
+ rv+=bc;
+ m_Position+=bc;
+ }
+ return rv;
+ }
+ virtual void Write(const void* lpBuf, UINT nCount) {
+ ASSERT(m_Position>=0 && m_Position<=GetLength());
+ LPBYTE data = (LPBYTE)lpBuf;
+ while(nCount){
+ UINT bn = m_Position/sizeof(TheBlock.data);
+ UINT bo = m_Position%sizeof(TheBlock.data);
+ while(bn>=m_Blocks.GetSize()){
+ LONG mb = m_Blocks[m_Blocks.GetUpperBound()];
+ LONG newBlock = m_Daddy->Allocate();
+ ASSERT(newBlock>=0);
+ theBlock* b = m_Daddy->m_File->GetCached(mb);
+ ASSERT(b);
+ ASSERT(b->next<0);
+ b->next=newBlock;
+ m_Daddy->m_File->MakeDirty(mb);
+ m_Blocks.Add(newBlock);
+ }
+ theBlock* b = m_Daddy->m_File->GetCached(m_Blocks[bn]);
+ ASSERT(b);
+ UINT bc = min(nCount,sizeof(TheBlock.data)-bo);
+ memmove(&b->data[bo],data,bc);
+ m_Daddy->m_File->MakeDirty(m_Blocks[bn]);
+ nCount-=bc;
+ data=&data[bc];
+ m_Position+=bc;
+ }
+ }
+
+ virtual void LockRange(DWORD dwPos, DWORD dwCount) { ASSERT(FALSE); }
+ virtual void UnlockRange(DWORD dwPos, DWORD dwCount) { ASSERT(FALSE); }
+
+ virtual void Abort() { ASSERT(FALSE); }
+ virtual void Flush() {
+ m_Daddy->m_File->Flush();
+ }
+ virtual void Close() {
+ m_Blocks.RemoveAll();
+ }
+
+ BOOL IsOpened() const { return m_Blocks.GetSize()!=0; }
+ };
+
+ CDynaCache* m_File;
+ firstBlock m_FB;
+
+ CDynamide() : m_File(NULL) {}
+ ~CDynamide() { Close(); }
+
+ BOOL AttachDynaFile(CDynaFile* f) {
+ // ASSERT(!m_Files.Find(f));
+ // m_Files.AddHead(f);
+ return TRUE;
+ }
+ BOOL DetachDynaFile(CDynaFile* f) {
+ //POSITION p = m_Files.Find(f);
+ // ASSERT(p);
+ // m_Files.RemoveAt(p);
+ return TRUE;
+ }
+
+ BOOL Open(LPCTSTR file,BOOL bRO=FALSE) {
+ Close();
+ try{
+ CFile* f = new CFile(file,CFile::typeBinary|(bRO?CFile::modeRead|CFile::shareDenyWrite:CFile::modeReadWrite|CFile::shareDenyRead));
+ return Attach(f,TRUE);
+ }catch(CException* e){
+ e->Delete();
+ return FALSE;
+ }
+ }
+ BOOL Create(LPCTSTR file) {
+ Close();
+ try{
+ CFile* f = new CFile(file,CFile::typeBinary|CFile::modeCreate|CFile::modeReadWrite|CFile::shareDenyRead);
+ return Attach(f,TRUE);
+ }catch(CException* e){
+ e->Delete();
+ return FALSE;
+ }
+ }
+ BOOL Attach(CFile* file,BOOL bAutodelete=TRUE) {
+ if(IsOpened())
+ return FALSE;
+ m_File = new CDynaCache(file,bAutodelete);
+ if(!m_File->Read1stBlock(&m_FB)){
+ memset(&m_FB,0,sizeof(m_FB));
+ m_FB.freeFile=-1;
+ VERIFY(m_File->Write1stBlock(&m_FB));
+ }
+ return IsOpened();
+ }
+ // CFile* Detach();
+ BOOL Close() {
+ if(!IsOpened())
+ return FALSE;
+ m_File->Write1stBlock(&m_FB);
+ delete m_File;
+ m_File=NULL;
+ return TRUE;
+ }
+ BOOL IsOpened() {
+ return m_File != NULL;
+ }
+ BOOL Write1stBlock(void) {
+ if(!IsOpened())
+ return FALSE;
+ VERIFY(m_File->Write1stBlock(&m_FB));
+ return TRUE;
+ }
+
+ CDynaFile* CreateFile() {
+ CDynaFile* rv = new CDynaFile(this);
+ if(rv->Create())
+ return rv;
+ delete rv;
+ return NULL;
+ }
+ CDynaFile* OpenFile(LONG fb) {
+ CDynaFile* rv = new CDynaFile(this);
+ if(rv->Open(fb))
+ return rv;
+ delete rv;
+ return NULL;
+ }
+ BOOL DeleteFile(LONG fb) {
+ while(fb>=0){
+ theBlock* b = m_File->GetCached(fb);
+ LONG nb = b->next;
+ Deallocate(fb);
+ fb=nb;
+ }
+ return TRUE;
+ }
+
+ LONG Allocate() {
+ if(!IsOpened())
+ return -1;
+ if(m_FB.freeFile<0){
+ LONG rv = m_File->AllocateNode();
+ theBlock *b = m_File->GetCached(rv);
+ b->next=-1;
+ m_File->MakeDirty(rv);
+ return rv;
+ }
+ LONG rv = m_FB.freeFile;
+ theBlock *b = m_File->GetCached(rv);
+ m_FB.freeFile=b->next;
+ b->next=-1;
+ m_File->MakeDirty(rv);
+ m_File->Write1stBlock(&m_FB);
+ return rv;
+ }
+ BOOL Deallocate(LONG bk) {
+ if(!IsOpened())
+ return FALSE;
+ theBlock* b = m_File->GetCached(bk);
+ ASSERT(b);
+ if(m_FB.freeFile<0){
+ b->next=-1;
+ m_FB.freeFile=bk;
+ }else{
+ b->next=m_FB.freeFile;
+ m_FB.freeFile=bk;
+ }
+ m_File->MakeDirty(bk);
+ m_File->Write1stBlock(&m_FB);
+ return TRUE;
+ }
+};
+
+};
+
+#endif // __DYNAMIDE_H
diff --git a/shared-code/FindIFace.h b/shared-code/FindIFace.h
new file mode 100644
index 0000000..8dec8c4
--- a/dev/null
+++ b/shared-code/FindIFace.h
@@ -0,0 +1,125 @@
+#ifndef __FINDIFACE_H
+#define __FINDIFACE_H
+
+#include "SNMPeer.h"
+#include "SNMPExtDLL.h"
+#include "SNMPOIDs.h"
+
+namespace Klever {
+
+inline BOOL FindIFace(in_addr& target,in_addr& source)
+{
+DEFINE_OID(ipRouteDest, OIDipRouteDest);
+DEFINE_OID(ipRouteMask, OIDipRouteMask);
+DEFINE_OID(ipRouteIfIndex, OIDipRouteIfIndex);
+DEFINE_OID(ipRouteMetric1, OIDipRouteMetric1);
+DEFINE_OID(ipAdEntIfIndex, OIDipAdEntIfIndex);
+DEFINE_OID(ipAdEntAddr, OIDipAdEntAddr);
+struct _route {
+ int iface;
+ int metric;
+ DWORD nm;
+} routes[16];
+int nRoutes = 0;
+CSNMPVarBindList vbl;
+ vbl.AddTail(CSNMPVarBind(CASNAny(CASNAny::typeASNOID,ipRouteDest,sizeof(ipRouteDest))));
+ vbl.AddTail(CSNMPVarBind(CASNAny(CASNAny::typeASNOID,ipRouteMask,sizeof(ipRouteMask))));
+ vbl.AddTail(CSNMPVarBind(CASNAny(CASNAny::typeASNOID,ipRouteIfIndex,sizeof(ipRouteIfIndex))));
+ vbl.AddTail(CSNMPVarBind(CASNAny(CASNAny::typeASNOID,ipRouteMetric1,sizeof(ipRouteMetric1))));
+CSNMPExtDLL snmp("INETMIB1");
+ while(nRoutes<(sizeof(routes)/sizeof(routes[0]))){
+ if(
+ snmp.Request(CASNAny::typeASNGetNextRequest,vbl,vbl)
+ && vbl.GetCount() == 4
+ ){
+ POSITION p = vbl.GetHeadPosition();
+ _route r = {-1,-1};
+ in_addr d, m;
+ BOOL bD = FALSE, bM = FALSE;
+ while(p){
+ CSNMPVarBind& vb = vbl.GetNext(p);
+ if(
+ vb.IsName(ipRouteDest,sizeof(ipRouteDest))
+ && vb.value.type==CASNAny::typeASNIP
+ ){
+ d.s_addr=vb.value.value.ip.s_addr; bD = TRUE;
+ }else if(
+ vb.IsName(ipRouteMask,sizeof(ipRouteMask))
+ && vb.value.type==CASNAny::typeASNIP
+ ){
+ m.s_addr=vb.value.value.ip.s_addr; bM = TRUE;
+ }else if(
+ vb.IsName(ipRouteIfIndex,sizeof(ipRouteIfIndex))
+ && vb.value.type==CASNAny::typeASNInteger
+ ){
+ r.iface=vb.value.value.number;
+ }else if(
+ vb.IsName(ipRouteMetric1,sizeof(ipRouteMetric1))
+ && vb.value.type==CASNAny::typeASNInteger
+ ){
+ r.metric=vb.value.value.number;
+ }else
+ break;
+ }
+ if(r.iface<0 || r.metric<0 || (!bD) || (!bM))
+ break;
+ if((target.s_addr&m.s_addr)==(d.s_addr&m.s_addr)){
+ r.nm=htonl(m.s_addr);
+ memmove(&routes[nRoutes++],&r,sizeof(routes[0]));
+ }
+ }else
+ break;
+ }
+ if(!nRoutes)
+ return FALSE;
+int rn = 0;
+ if(nRoutes>1){
+ for(int tmp=1;tmp<nRoutes;tmp++)
+ if(
+ routes[tmp].metric<routes[rn].metric
+ || routes[tmp].nm>routes[rn].nm
+ )
+ rn = tmp;
+ }
+int iface = routes[rn].iface;
+ vbl.RemoveAll();
+ vbl.AddTail(CSNMPVarBind(CASNAny(CASNAny::typeASNOID,ipAdEntAddr,sizeof(ipAdEntAddr))));
+ vbl.AddTail(CSNMPVarBind(CASNAny(CASNAny::typeASNOID,ipAdEntIfIndex,sizeof(ipAdEntIfIndex))));
+ for(;;){
+ if(
+ snmp.Request(CASNAny::typeASNGetNextRequest,vbl,vbl)
+ && vbl.GetCount()==2
+ ){
+ in_addr a; a.s_addr = INADDR_NONE;
+ int ifn = -1;
+ POSITION p = vbl.GetHeadPosition();
+ while(p){
+ CSNMPVarBind& vb = vbl.GetNext(p);
+ if(
+ vb.IsName(ipAdEntAddr,sizeof(ipAdEntAddr))
+ && vb.value.type==CASNAny::typeASNIP
+ ){
+ a.s_addr=vb.value.value.ip.s_addr;
+ }else if(
+ vb.IsName(ipAdEntIfIndex,sizeof(ipAdEntIfIndex))
+ && vb.value.type==CASNAny::typeASNInteger
+ ){
+ ifn = vb.value.value.number;
+ }else
+ break;
+ }
+ if(ifn<0)
+ break;
+ if(ifn==iface){
+ source.s_addr=a.s_addr;
+ return TRUE;
+ }
+ }else
+ break;
+ }
+ return FALSE;
+}
+
+};
+
+#endif // __FINDIFACE_H
diff --git a/shared-code/LRUCache.h b/shared-code/LRUCache.h
new file mode 100644
index 0000000..569e829
--- a/dev/null
+++ b/shared-code/LRUCache.h
@@ -0,0 +1,113 @@
+#ifndef __LRUCACHE_H
+#define __LRUCACHE_H
+
+namespace Klever {
+
+template<class IDX,class ARGIDX,class DATA>
+class CLRUCache : public CObject {
+public:
+ struct CacheEntry {
+ enum cacheState {
+ cacheClean, cacheDirty, cacheEmpty
+ };
+ cacheState m_State;
+ UINT m_hits;
+
+ IDX m_idx;
+ DATA* m_pData;
+
+ CacheEntry() { m_State=cacheEmpty; VERIFY(m_pData=new DATA); m_hits=0; }
+ virtual ~CacheEntry() { delete m_pData; }
+ };
+ typedef CMap<IDX,ARGIDX,CacheEntry*,CacheEntry*> CCacheMap;
+ typedef CList<CacheEntry*,CacheEntry*> CCacheList;
+
+ CCacheList m_Cache;
+ CCacheMap m_Map;
+
+ CLRUCache(UINT cacheSize) {
+ for(int tmp=0;tmp<cacheSize;tmp++){
+ CacheEntry* p = new CacheEntry;
+ m_Cache.AddTail(p);
+ }
+ }
+ virtual ~CLRUCache() {
+ Flush();
+ POSITION p = m_Cache.GetHeadPosition();
+ while(p){
+ CacheEntry* c = m_Cache.GetNext(p);
+ delete c;
+ }
+ }
+
+ DATA* GetCached(ARGIDX idx,BOOL bLoad=TRUE) {
+ CacheEntry* rv;
+ if(m_Map.Lookup(idx,rv)){
+ rv->m_hits++;
+ PopUp(rv);
+ return rv->m_pData;
+ }
+ if(!bLoad)
+ return NULL;
+ rv = m_Cache.GetTail();
+ ASSERT(rv);
+ switch(rv->m_State){
+ case CacheEntry::cacheDirty:
+ FlushEntry(rv);
+ case CacheEntry::cacheClean:
+ m_Map.RemoveKey(rv->m_idx);
+ rv->m_State=CacheEntry::cacheEmpty;
+ case CacheEntry::cacheEmpty:
+ break;
+ default:
+ ASSERT(FALSE);
+ }
+ if(!_ReadIn(idx,rv->m_pData))
+ return NULL;
+ rv->m_hits=1;
+ rv->m_State=CacheEntry::cacheClean;
+ rv->m_idx=idx;
+ m_Map[idx]=rv;
+ PopUp(rv);
+ return rv->m_pData;
+ }
+ BOOL MakeDirty(ARGIDX idx) {
+ CacheEntry* pEntry;
+ if(m_Map.Lookup(idx,pEntry)){
+ ASSERT(pEntry->m_State==CacheEntry::cacheClean || pEntry->m_State==CacheEntry::cacheDirty);
+ pEntry->m_State=CacheEntry::cacheDirty;
+ return TRUE;
+ }
+ return FALSE;
+ }
+ BOOL Flush() {
+ POSITION p = m_Cache.GetHeadPosition();
+ while(p){
+ CacheEntry* pEntry = m_Cache.GetNext(p);
+ ASSERT(pEntry);
+ FlushEntry(pEntry);
+ }
+ return TRUE;
+ }
+ BOOL FlushEntry(CacheEntry* pEntry) {
+ if(pEntry->m_State==CacheEntry::cacheDirty){
+ BOOL rv = _WriteOut(pEntry->m_idx,pEntry->m_pData);
+ if(rv)
+ pEntry->m_State=CacheEntry::cacheClean;
+ }
+ return FALSE;
+ }
+ void PopUp(CacheEntry* pEntry) {
+ POSITION p = m_Cache.Find(pEntry);
+ ASSERT(p);
+ m_Cache.RemoveAt(p);
+ VERIFY(m_Cache.AddHead(pEntry));
+ }
+
+ virtual BOOL _ReadIn(ARGIDX idx,DATA* data) = 0;
+ virtual BOOL _WriteOut(ARGIDX idx,DATA* data) = 0;
+};
+
+};
+
+#endif // __LRUCACHE_H
diff --git a/shared-code/RegEx.cpp b/shared-code/RegEx.cpp
new file mode 100644
index 0000000..b7bab62
--- a/dev/null
+++ b/shared-code/RegEx.cpp
@@ -0,0 +1,1697 @@
+#include "../stdafx.h"
+#include "RegEx.h"
+
+#define isWordableChar(c) (isalnum(c) || (c)=='_')
+
+BOOL CRegEx::Compile(LPCTSTR regex,int flags)
+{
+ ASSERT(!((flags&regExtended) && (flags&regLiteral)));
+ m_Matches.RemoveAll();
+ m_Strip.RemoveAll();
+ m_Strip.SetSize(0,15);
+ m_Pattern=regex;
+ m_ParsePointer=0;
+ m_Error=0;
+ m_Sets.RemoveAll();
+ m_Flags=flags;
+ m_iFlags=0;
+ m_BOLs=m_EOLs=0;
+ m_Subexps = 0;
+ m_Categories=1; // 0 is 'everything else'
+ m_bBackRefs=FALSE;
+ memset(m_Category,0,sizeof(m_Category));
+
+ // Go ahead.
+ m_Error || m_Strip.Add(CSop(CSop::opEnd));
+ if(flags&regExtended){
+ ParseERE();
+ }else if(flags&regLiteral){
+ ParseLiteral();
+ }else{
+ ParseBRE();
+ }
+ m_Error || m_Strip.Add(CSop(CSop::opEnd));
+ Categorize();
+ m_Strip.FreeExtra();
+ FigureMust();
+ m_Pluses=CountPluses();
+ if(m_iFlags&iflagsBad){
+ m_Error || (m_Error=regeAssert);
+ // ??? point to nuls? ;-)
+ }
+ // We may wish to free some memory here if we're erroneous (ie. m_Error..)
+ m_ParseParens.RemoveAll();
+#ifdef _DEBUG
+ if(m_Error){
+ CString tmp;
+ tmp.Format("RE: ParseError: %d\n",m_Error);
+ TRACE0(tmp);
+ }
+// DumpStrip(afxDump);
+#endif
+ return (m_bCompiled=(!m_Error));
+}
+
+BOOL CRegEx::Match(LPCTSTR src,int flags)
+{
+ if(!m_bCompiled)
+ return FALSE;
+ if(m_iFlags&iflagsBad)
+ return FALSE;
+ m_Input=src;
+ m_mFlags=flags;
+ m_mPointer=m_Input;
+ m_mBegin=m_Input;
+ m_mEnd=&m_mBegin[m_Input.GetLength()];
+ ASSERT(m_mPointer<=m_mEnd);
+ m_Matches.RemoveAll();
+ if(!m_Must.IsEmpty()){
+ if(m_Input.Find(m_Must)<0)
+ return FALSE;
+ }
+ // Go ahead..
+int stripLen = m_Strip.GetSize();
+ m_mLastPos.SetSize(0);
+ for(int tmp=0;tmp<stripLen;tmp++)
+ m_Strip[tmp].m_MatchData=0;
+LPCTSTR beginp = m_mBegin;
+LPCTSTR endp;
+ for(;;){
+ endp = MatchFast(beginp);
+ if(!endp)
+ return FALSE;
+ if((m_mFlags&regNoSubExpressions) && !m_bBackRefs)
+ break;
+ ASSERT(m_cOldP);
+ for(;;){
+ endp = MatchSlow(m_cOldP,m_mEnd,1,stripLen-1);
+ if(endp)
+ break;
+ ASSERT(m_cOldP<m_mEnd);
+ m_cOldP++;
+ }
+ if((m_mFlags&regOneMatch) && !m_bBackRefs)
+ break;
+ // Oh, his, we want the subexpression..
+ m_Matches.SetSize(m_Subexps+1);
+ LPCTSTR dp;
+ if(!m_bBackRefs && !(m_mFlags&regBackRefs)){
+ dp = MatchDissect(m_cOldP,endp,1,stripLen-1);
+ }else{
+ if(m_Pluses>0 && !m_mLastPos.GetSize())
+ m_mLastPos.SetSize(m_Pluses);
+ dp = MatchBackRef(m_cOldP,endp,1,stripLen-1,0);
+ }
+ if(dp)
+ break;
+ // Uh.. oh.. we couldn't find a subexpression-level match
+ ASSERT(m_bBackRefs);
+ ASSERT(m_Pluses==0 || m_mLastPos.GetSize());
+ for(;;){
+ if(dp || endp <= m_cOldP)
+ break; // defeat.. ?
+ endp = MatchSlow(m_cOldP,endp-1,1,stripLen-1);
+ if(!endp)
+ break; // defeat.. ?
+ // Try it on a shorter possibility..
+#ifdef _DEBUG
+ for(tmp=1;tmp<=m_Subexps;tmp++)
+ ASSERT(m_Matches[tmp].m_Begin<0 && m_Matches[tmp].m_End<0);
+#endif
+ dp = MatchBackRef(m_cOldP,endp,1,stripLen-1,0);
+ }
+ ASSERT((!dp) || dp==endp);
+ if(dp) // Found a shorter one..
+ break;
+ // Despite initial appearances, there is no match here
+ beginp = m_cOldP+1;
+ ASSERT(beginp<=m_mEnd);
+ }
+ // Fill in the detail if so requested..
+ if(!(m_mFlags&regNoSubExpressions)){
+ if(!m_Matches.GetSize())
+ m_Matches.SetSize(1);
+ m_Matches[0].m_Begin=m_cOldP-m_mBegin;
+ m_Matches[0].m_End=endp-m_mBegin;
+ }
+ m_mLastPos.RemoveAll();
+ return TRUE;
+}
+
+CString CRegEx::Replace(LPCTSTR src,LPCTSTR rep,int flags)
+{
+ // ***
+ return CString();
+}
+
+void CRegEx::ParseERE(int stop)
+{
+UCHAR c;
+BOOL first=TRUE;
+int prevF, prevB;
+ for(;;){
+ int co = m_Strip.GetSize();
+ while(m_ParsePointer < m_Pattern.GetLength() && ((c=m_Pattern[m_ParsePointer])!='|') && c!=stop)
+ ParseEREexp();
+ if(m_Strip.GetSize()==co){
+ m_Error || (m_Error=regeEmpty);
+ // ??? point to nuls?
+ }
+ if(m_ParsePointer>=m_Pattern.GetLength() || m_Pattern[m_ParsePointer]!='|')
+ break;
+ else
+ m_ParsePointer++;
+ if(first){
+ StripInsert(co,CSop(CSop::opChoice0,m_Strip.GetSize()-co+1));
+ prevF = prevB = co;
+ first=FALSE;
+ }
+ m_Error || m_Strip.Add(CSop(CSop::opOr0,m_Strip.GetSize()-prevB));
+ prevB = m_Strip.GetSize()-1;
+ m_Error || (m_Strip[prevF].m_Operand=m_Strip.GetSize()-prevF);
+ prevF = m_Strip.GetSize();
+ m_Error || m_Strip.Add(CSop(CSop::opOr1,0)); // offset isn't really right.. very so..
+ }
+ if(!first){
+ m_Error || (m_Strip[prevF].m_Operand=m_Strip.GetSize()-prevF);
+ m_Error || m_Strip.Add(CSop(CSop::opChoice1,m_Strip.GetSize()-prevB));
+ }
+ ASSERT(m_ParsePointer >= m_Pattern.GetLength() || m_Pattern[m_ParsePointer]==stop);
+}
+
+void CRegEx::ParseEREexp()
+{
+ ASSERT(m_ParsePointer < m_Pattern.GetLength());
+UCHAR c = m_Pattern[m_ParsePointer++];
+int pos = m_Strip.GetSize();
+int subno;
+int count, count2;
+BOOL wascaret=FALSE;
+ switch(c){
+ case '(':
+ if(!(m_ParsePointer<m_Pattern.GetLength())){
+ TRACE0("RE: '(' at the end of the pattern\n");
+ if(!m_Error)
+ m_Error = regeParen;
+ // ??? point to nuls?
+ }
+ m_Subexps++;
+ subno=m_Subexps;
+ m_ParseParens.SetAtGrow(m_Subexps,CParenthesis(m_Strip.GetSize()));
+ m_Error || m_Strip.Add(CSop(CSop::opLeftParen,subno));
+ if(m_ParsePointer>=m_Pattern.GetLength() || m_Pattern[m_ParsePointer]!=')')
+ ParseERE(')');
+ VERIFY(m_ParseParens[m_Subexps].m_End = m_Strip.GetSize());
+ m_Error || m_Strip.Add(CSop(CSop::opRightParen,subno));
+ if(m_ParsePointer >= m_Pattern.GetLength() || m_Pattern[m_ParsePointer++]!=')'){
+ TRACE0("RE: No matching ')'\n");
+ if(!m_Error)
+ m_Error = regeParen;
+ // ??? point to nuls?
+ }
+ break;
+ case '^':
+ m_Error || m_Strip.Add(CSop(CSop::opBOL));
+ m_iFlags|=iflagsUseBOL;
+ m_BOLs++;
+ wascaret=TRUE;
+ break;
+ case '$':
+ m_Error || m_Strip.Add(CSop(CSop::opEOL));
+ m_iFlags|=iflagsUseEOL;
+ m_EOLs++;
+ break;
+ case '|':
+ TRACE0("RE: '|' outside of expression\n");
+ if(!m_Error)
+ m_Error = regeEmpty;
+ // ??? point to nuls?
+ break;
+ case '*':
+ case '+':
+ case '?':
+ TRACE0("RE: '*'/'+'/'?' with no previous expression\n");
+ if(!m_Error)
+ m_Error = regeBadRepeat;
+ // ??? point to nuls?
+ break;
+ case '.':
+ if(m_Flags&regNewLine)
+ EmitNonNewLineAny();
+ else
+ m_Error || m_Strip.Add(CSop(CSop::opAny));
+ break;
+ case '[':
+ ParseBracket();
+ break;
+ case '\\':
+ if(m_ParsePointer >= m_Pattern.GetLength()){
+ TRACE0("RE: '\\' at the end of the pattern\n");
+ if(!m_Error)
+ m_Error = regeEscape;
+ // ??? point to nuls?
+ }else{
+ c = m_Pattern[m_ParsePointer++];
+ EmitOrdinary(c);
+ }
+ break;
+ case '{':
+ if(m_ParsePointer >= m_Pattern.GetLength() || !isdigit(m_Pattern[m_ParsePointer])){
+ TRACE0("RE: '{' with no repeat count\n");
+ if(!m_Error)
+ m_Error = regeBadRepeat;
+ // ??? point to nuls?
+ }
+ // Fallthrough..
+ default:
+ EmitOrdinary(c);
+ break;
+ }
+ if(m_ParsePointer >= m_Pattern.GetLength())
+ return;
+ c = m_Pattern[m_ParsePointer];
+ // Call a '{' repetition if followed by a digit
+ if (!(c=='*' || c=='+' || c=='?' || ( c=='{' && (m_ParsePointer+1) < m_Pattern.GetLength() && isdigit(m_Pattern[m_ParsePointer+1])) ))
+ return; // No repetitor - done.
+ m_ParsePointer++;
+ if(wascaret){
+ TRACE0("RE: repetitive '^' detected\n");
+ if(!m_Error)
+ m_Error = regeBadRepeat;
+ // ??? point to nuls?
+ }
+ switch(c){
+ case '*': // Implemeted as +?
+ // + expression
+ StripInsert(pos,CSop(CSop::opPlus0,m_Strip.GetSize()-pos+1));
+ m_Error || m_Strip.Add(CSop(CSop::opPlus1,m_Strip.GetSize()-pos));
+ // ? expression
+ StripInsert(pos,CSop(CSop::opQuest0,m_Strip.GetSize()-pos+1));
+ m_Error || m_Strip.Add(CSop(CSop::opQuest1,m_Strip.GetSize()-pos));
+ break;
+ case '+':
+ // + expression
+ StripInsert(pos,CSop(CSop::opPlus0,m_Strip.GetSize()-pos+1));
+ m_Error || m_Strip.Add(CSop(CSop::opPlus1,m_Strip.GetSize()-pos));
+ break;
+ case '?':
+ // Kludge - emit y? as (y|) until subtle bug gets fixed :-)
+ StripInsert(pos,CSop(CSop::opChoice0,m_Strip.GetSize()-pos+1));
+ m_Error || m_Strip.Add(CSop(CSop::opOr0,m_Strip.GetSize()-pos));
+ m_Error || (m_Strip[pos].m_Operand=m_Strip.GetSize()-pos);
+ m_Error || m_Strip.Add(CSop(CSop::opOr1,1));
+ m_Error || m_Strip.Add(CSop(CSop::opChoice1,2));
+ break;
+ case '{':
+ count = ParseCount();
+ if(m_ParsePointer < m_Pattern.GetLength() && m_Pattern[m_ParsePointer]==','){
+ m_ParsePointer++;
+ if(isdigit(m_Pattern[m_ParsePointer])){ // HHH Personally, I doubt it is always available
+ count2=ParseCount();
+ if(!(count<=count2)){
+ TRACE0("RE: Disbalanced counts in '{}' repeater\n");
+ m_Error || (m_Error=regeBadBrace);
+ // ??? point to nuls?
+ }
+ }else // Single number with comma
+ count2=256; // Infinity
+ }else // Single number
+ count2=count;
+ EmitRepeat(pos,count,count2);
+ if(m_ParsePointer >= m_Pattern.GetLength() || m_Pattern[m_ParsePointer]!='}'){
+ // No '}'..
+ TRACE0("RE: No immediately following '}' of '{' expression\n");
+ while(m_ParsePointer < m_Pattern.GetLength() && m_Pattern[m_ParsePointer]!='}')
+ m_ParsePointer++;
+ if(m_ParsePointer >= m_Pattern.GetLength()){
+ TRACE0("RE: No closing '}' found\n");
+ m_Error || (m_Error=regeBrace);
+ }else
+ m_Error || (m_Error=regeBadBrace);
+ // ??? point to nuls?
+ }else
+ m_ParsePointer++;
+ break;
+ }
+ if(m_ParsePointer >= m_Pattern.GetLength())
+ return;
+ c = m_Pattern[m_ParsePointer];
+ if(!(c=='*' || c=='+' || c=='?' || (c=='{' && (m_ParsePointer+1)<m_Pattern.GetLength() && isdigit(m_Pattern[m_ParsePointer+1]))))
+ return;
+ TRACE0("RE: Double repeater\n");
+ m_Error || (m_Error=regeBadRepeat);
+ // ??? point to nuls?
+}
+
+void CRegEx::StripInsert(int pos,CSop& sop)
+{
+ if(m_Error)
+ return;
+int sn = m_Strip.GetSize();
+ m_Strip.InsertAt(pos,sop);
+ for(int tmp=1;tmp<m_ParseParens.GetSize();tmp++){
+ if(m_ParseParens[tmp].m_Begin>=pos)
+ m_ParseParens[tmp].m_Begin++;
+ if(m_ParseParens[tmp].m_End>=pos)
+ m_ParseParens[tmp].m_End++;
+ }
+}
+
+void CRegEx::EmitOrdinary(UCHAR c)
+{
+ if(m_Flags&regIgnoreCase && isalpha(c) && (tolower(c) !=toupper(c))){
+ // Emit both cases
+ CString savePattern = m_Pattern;
+ int savePointer = m_ParsePointer;
+ m_Pattern=c;
+ m_Pattern+=']';
+ m_ParsePointer=0;
+ ParseBracket();
+ m_Pattern=savePattern;
+ m_ParsePointer=savePointer;
+ }else{
+ m_Error || m_Strip.Add(CSop(CSop::opChar,c));
+ if(!m_Category[(BYTE)c])
+ m_Category[(BYTE)c]=m_Categories++;
+ }
+}
+
+void CRegEx::EmitNonNewLineAny()
+{
+ // Kludges're going on and on..
+CString savePattern = m_Pattern;
+int savePointer = m_ParsePointer;
+ m_Pattern="^\n]";
+ m_ParsePointer=0;
+ ParseBracket();
+ m_Pattern=savePattern;
+ m_ParsePointer=savePointer;
+}
+
+int CRegEx::ParseCount()
+{
+BOOL nonEmpty=FALSE;
+int rv = 0;
+UCHAR c;
+ while(m_ParsePointer < m_Pattern.GetLength() && isdigit(c=m_Pattern[m_ParsePointer]) && rv <=255){
+ rv = rv*10 + c-'0';
+ nonEmpty=TRUE;
+ m_ParsePointer++;
+ }
+ if(rv>255 || !nonEmpty){
+ m_Error || (m_Error=regeBadBrace);
+ // ??? point to nuls?
+ }
+ return rv;
+}
+
+void CRegEx::ParseBracket()
+{
+ // Dept. of truly sickening special case kludges
+ if((m_ParsePointer+5) < m_Pattern.GetLength() && !m_Pattern.Mid(m_ParsePointer,6).Compare("[:<]]")){
+ m_Error || m_Strip.Add(CSop(CSop::opBOW));
+ m_ParsePointer+=6;
+ return;
+ }
+ if((m_ParsePointer+5) < m_Pattern.GetLength() && !m_Pattern.Mid(m_ParsePointer,6).Compare("[:>]]")){
+ m_Error || m_Strip.Add(CSop(CSop::opEOW));
+ m_ParsePointer+=6;
+ return;
+ }
+BOOL invert=TRUE;
+ if(m_ParsePointer < m_Pattern.GetLength() && m_Pattern[m_ParsePointer]=='^')
+ m_ParsePointer++;
+ else
+ invert=FALSE;
+CSet cset;
+ if(m_ParsePointer < m_Pattern.GetLength()){
+ switch(m_Pattern[m_ParsePointer]){
+ case ']':
+ case '-':
+ cset.Add(m_Pattern[m_ParsePointer]);
+ m_ParsePointer++;
+ break;
+ }
+ }
+ while(m_ParsePointer < m_Pattern.GetLength() && m_Pattern[m_ParsePointer]!=']' && !((m_ParsePointer+1)<m_Pattern.GetLength() && !m_Pattern.Mid(m_ParsePointer,2).Compare("-]")))
+ ParseBracketTerm(cset);
+ if(m_ParsePointer < m_Pattern.GetLength() && m_Pattern[m_ParsePointer]=='-'){
+ m_ParsePointer++;
+ cset.Add('-');
+ }
+ if(m_ParsePointer < m_Pattern.GetLength() && m_Pattern[m_ParsePointer]==']')
+ m_ParsePointer++;
+ else{
+ m_Error || (m_Error=regeBracket);
+ // ??? point to nuls?
+ return;
+ }
+ if(m_Flags&regIgnoreCase){
+ for(int tmp=CSet::size-1;tmp>=0;tmp--){
+ if(cset.IsIn(tmp) && isalpha(tmp) && (toupper(tmp)!=tolower(tmp)))
+ cset.Add(isupper(tmp)?tolower(tmp):toupper(tmp));
+ }
+ /*
+ if(!cset->m_Multis.IsEmpty())
+ cset.CollatingCase();
+ */
+ }
+ if(invert){
+ for(int tmp=CSet::size-1;tmp>=0;tmp--)
+ if(cset.IsIn(tmp))
+ cset.Sub(tmp);
+ else
+ cset.Add(tmp);
+ if(m_Flags&regNewLine)
+ cset.Sub('\n');
+ /*
+ if(!cset.m_Multis.IsEmpty())
+ cset.CollatingInvert();
+ */
+ }
+UCHAR c = cset.GetOnly();
+ if(c){
+ EmitOrdinary(c);
+ }else
+ m_Error || m_Strip.Add(CSop(CSop::opAnyOf,StoreSet(cset)));
+}
+
+void CRegEx::CSet::Add(UCHAR c)
+{
+ m_Set[(BYTE)c]=TRUE;
+ m_Hash+=c;
+}
+
+BOOL CRegEx::CSet::IsIn(UCHAR c)
+{
+ return m_Set[(BYTE)c];
+}
+
+void CRegEx::CSet::Sub(UCHAR c)
+{
+ m_Set[(BYTE)c]=FALSE;
+ m_Hash-=c;
+}
+
+UCHAR CRegEx::CSet::GetOnly()
+{
+int rv = 0;
+UCHAR only = 0;
+ for(int tmp=0;tmp<size;tmp++){
+ rv+=m_Set[tmp]?(only=tmp,1):0;
+ }
+ return (rv==1)?only:0;
+}
+
+int CRegEx::StoreSet(CSet& cset)
+{
+ for(int tmp=0;tmp<m_Sets.GetSize();tmp++)
+ if(m_Sets[tmp]==cset)
+ return tmp;
+ return m_Sets.Add(cset);
+}
+
+void CRegEx::ParseBracketTerm(CSet& cset)
+{
+UCHAR c;
+ switch((m_ParsePointer<m_Pattern.GetLength())?m_Pattern[m_ParsePointer]:0){
+ case '[':
+ c = ((m_ParsePointer+1)<m_Pattern.GetLength())?m_Pattern[m_ParsePointer+1]:0;
+ break;
+ case '-':
+ m_Error || (m_Error=regeRange);
+ // ??? point to nuls?
+ return;
+ default:
+ c = 0;
+ break;
+ }
+ switch(c){
+ case ':': // Character class
+ m_ParsePointer+=2;
+ if(m_ParsePointer>=m_Pattern.GetLength()){
+ m_Error || (m_Error=regeBracket);
+ // ??? point to nuls?
+ }
+ c = m_Pattern[m_ParsePointer];
+ if(c== '-' || c==']'){
+ m_Error || (m_Error=regeCType);
+ // ??? point to nuls?
+ }
+ ParseBracketCClass(cset);
+ if(m_ParsePointer>=m_Pattern.GetLength()){
+ m_Error || (m_Error=regeBracket);
+ // ??? point to nuls?
+ }
+ if((m_ParsePointer+1)>=m_Pattern.GetLength() || (m_Pattern.Mid(m_ParsePointer,2).Compare(":]"))){
+ m_Error || (m_Error=regeCType);
+ // ??? point to nuls?
+ }else
+ m_ParsePointer+=2;
+ break;
+ case '=': // Equivalence class
+ m_ParsePointer+=2;
+ if(m_ParsePointer >= m_Pattern.GetLength()){
+ m_Error || (m_Error=regeBracket);
+ // ??? point to nuls?
+ }
+ c = m_Pattern[m_ParsePointer];
+ if(c== '-' || c==']'){
+ m_Error || (m_Error=regeCollate);
+ // ??? point to nuls?
+ }
+ ParseBracketEClass(cset);
+ if((m_ParsePointer+1)>=m_Pattern.GetLength() || (m_Pattern.Mid(m_ParsePointer,2).Compare("=]"))){
+ m_Error || (m_Error=regeCollate);
+ // ??? point to nuls?
+ }else
+ m_ParsePointer+=2;
+ break;
+ default: // Symbol, character or range
+ {
+ UCHAR start, finish;
+ start = ParseBracketSymbol();
+ if((m_ParsePointer<m_Pattern.GetLength() && m_Pattern[m_ParsePointer]=='-') /*&& (m_ParsePointer+1)<m_Pattern.GetLength() && m_Pattern[m_ParsePointer+1]==']'*/){
+ // I believe the expression above is seetwo..
+ // range.
+ m_ParsePointer++;
+ if(m_ParsePointer<m_Pattern.GetLength() && m_Pattern[m_ParsePointer]=='-'){
+ m_ParsePointer++;
+ finish='-';
+ }else
+ finish=ParseBracketSymbol();
+ }else
+ finish=start;
+ if(((BYTE)start)>((BYTE)finish)){
+ m_Error || (m_Error=regeRange);
+ // ??? point to nuls?
+ }
+ for(int tmp=start;tmp<=(BYTE)finish;tmp++)
+ cset.Add(tmp);
+ }
+ break;
+ }
+}
+
+void CRegEx::ParseBracketCClass(CSet& cset)
+{
+static struct {
+ char *className;
+ char *classChars;
+} cc[] = {
+ {"alnum","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"},
+ {"alpha","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"},
+ {"blank"," \t"},
+ {"cntrl","\007\b\t\n\v\f\r\1\2\3\4\5\6\16\17\20\21\22\23\24\25\26\27\30\31\32\33\34\35\36\37\177"},
+ {"digit","0123456789"},
+ {"graph","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"},
+ {"lower","abcdefghijklmnopqrstuvwxyz"},
+ {"print","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ "},
+ {"punct","!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"},
+ {"space","\t\n\v\f\r "},
+ {"upper","ABCDEFGHIJKLMNOPQRSTUVWXYZ"},
+ {"xdigit","0123456789ABCDEFabcdef"}
+};
+CString cclass;
+UCHAR c;
+ while(m_ParsePointer < m_Pattern.GetLength() && isalpha(c=m_Pattern[m_ParsePointer])){
+ cclass+=c;
+ m_ParsePointer++;
+ }
+char *classChars = NULL;
+ for(int tmp=0;tmp<(sizeof(cc)/sizeof(cc[0]));tmp++){
+ if(!cclass.CompareNoCase(cc[tmp].className)){
+ classChars=cc[tmp].classChars;
+ break;
+ }
+ }
+ if(!classChars){
+ m_Error || (m_Error=regeCType);
+ // ??? point to nuls?
+ return;
+ }
+ while(*classChars)
+ cset.Add(*(classChars++));
+ // --- multis
+}
+
+void CRegEx::ParseBracketEClass(CSet& cset)
+{
+ cset.Add(ParseBracketCollatingElement('='));;
+}
+
+UCHAR CRegEx::ParseBracketCollatingElement(UCHAR term)
+{
+static struct {
+ char *entityName;
+ char entity;
+} cc[] = { {"NUL",'\0'},{"SOH",'\001'},{"STX",'\002'},{"ETX",'\003'},{"EOT",'\004'},{"ENQ",'\005'},{"ACK",'\006'},{"BEL",'\007'},{"alert",'\007'},{"BS",'\010'},{"backspace",'\b'},{"HT",'\011'},{"tab",'\t'},{"LF",'\012'},{"newline",'\n'},{"VT",'\013'},{"vertical-tab",'\v'},{"FF",'\014'},{"form-feed",'\f'},{"CR",'\015'},{"carriage-return",'\r'},{"SO",'\016'},{"SI",'\017'},{"DLE",'\020'},{"DC1",'\021'},{"DC2",'\022'},{"DC3",'\023'},{"DC4",'\024'},{"NAK",'\025'},{"SYN",'\026'},{"ETB",'\027'},{"CAN",'\030'},{"EM",'\031'},{"SUB",'\032'},{"ESC",'\033'},{"IS4",'\034'},{"FS",'\034'},{"IS3",'\035'},{"GS",'\035'},{"IS2",'\036'},{"RS",'\036'},{"IS1",'\037'},{"US",'\037'},{"space",' '},{"exclamation-mark",'!'},{"quotation-mark",'"'},{"number-sign",'#'},{"dollar-sign",'$'},{"percent-sign",'%'},{"ampersand",'&'},{"apostrophe",'\''},{"left-parenthesis",'('},{"right-parenthesis",')'},{"asterisk",'*'},{"plus-sign",'+'},{"comma",','},{"hyphen",'-'},{"hyphen-minus",'-'},{"period",'.'},{"full-stop",'.'},{"slash",'/'},{"solidus",'/'},{"zero",'0'},{"one",'1'},{"two",'2'},{"three",'3'},{"four",'4'},{"five",'5'},{"six",'6'},{"seven",'7'},{"eight",'8'},{"nine",'9'},{"colon",':'},{"semicolon",';'},{"less-than-sign",'<'},{"equals-sign",'='},{"greater-than-sign",'>'},{"question-mark",'?'},{"commercial-at",'@'},{"left-square-bracket",'['},{"backslash",'\\'},{"reverse-solidus",'\\'},{"right-square-bracket",']'},{"circumflex",'^'},{"circumflex-accent",'^'},{"underscore",'_'},{"low-line",'_'},{"grave-accent",'`'},{"left-brace",'{'},{"left-curly-bracket",'{'},{"vertical-line",'|'},{"right-brace",'}'},{"right-curly-bracket",'}'},{"tilde",'~'},{"DEL",'\177'} };
+CString seeTwo;
+ seeTwo=term;
+ seeTwo+=']';
+CString entityName;
+ while(m_ParsePointer<m_Pattern.GetLength() && !((m_ParsePointer+1)<m_Pattern.GetLength() && !m_Pattern.Mid(m_ParsePointer,2).Compare(seeTwo)))
+ entityName+=m_Pattern[m_ParsePointer++];
+ if(m_ParsePointer>=m_Pattern.GetLength()){
+ m_Error || (m_Error=regeBracket);
+ // ??? point to nuls?
+ return 0;
+ }
+ for(int tmp=0;tmp<(sizeof(cc)/sizeof(cc[0]));tmp++)
+ if(!entityName.CompareNoCase(cc[tmp].entityName))
+ return cc[tmp].entity;
+ if(entityName.GetLength()==1)
+ return entityName[0];
+ m_Error || (m_Error=regeCollate);
+ // ??? point to nuls?
+ return 0;
+}
+
+UCHAR CRegEx::ParseBracketSymbol()
+{
+ if(m_ParsePointer>=m_Pattern.GetLength()){
+ m_Error || (m_Error=regeBracket);
+ // ??? point to nuls?
+ }
+ if((m_ParsePointer+1)<m_Pattern.GetLength() && !m_Pattern.Mid(m_ParsePointer,2).Compare("[."))
+ m_ParsePointer+=2;
+ else
+ return m_Pattern[m_ParsePointer++];
+ // Collating symbol
+UCHAR rv = ParseBracketCollatingElement('.');
+ if((m_ParsePointer+1)<m_Pattern.GetLength() && !m_Pattern.Mid(m_ParsePointer,2).Compare("[."))
+ m_ParsePointer+=2;
+ else{
+ m_Error || (m_Error=regeCollate);
+ // ??? point to nuls?
+ }
+ return rv;
+}
+
+void CRegEx::EmitRepeat(int pos,int from,int to)
+{
+ if(m_Error)
+ return;
+ ASSERT(from<=to);
+int finish = m_Strip.GetSize();
+int copy;
+#define N 2
+#define INF 3
+#define REP(f,t) ((f)*8+(t))
+#define MAP(n) (((n)<=1)?(n):((n)==256)?INF:N)
+ switch(REP(MAP(from),MAP(to))){
+ case REP(0,0): // must be user doing ths??
+ m_Strip.SetSize(pos);
+ break;
+ case REP(0,1): // as in '?'
+ case REP(0,N): // as in '{1,n}?'
+ case REP(0,INF): // as in '{1,}?'
+ // Kludge - emit y? as (y|) until something gets fixed..
+ StripInsert(pos,CSop(CSop::opChoice0,pos));
+ EmitRepeat(pos+1,1,to);
+ m_Error || m_Strip.Add(CSop(CSop::opOr0,m_Strip.GetSize()-pos));
+ m_Error || (m_Strip[pos].m_Operand=m_Strip.GetSize()-pos);
+ m_Error || m_Strip.Add(CSop(CSop::opOr1,1));
+ m_Error || m_Strip.Add(CSop(CSop::opChoice1,2));
+ break;
+ case REP(1,1):
+ break;
+ case REP(1,N): // as in 'x?x{1,n-1}'
+ // Kludge again..
+ StripInsert(pos,CSop(CSop::opChoice0,pos));
+ m_Error || m_Strip.Add(CSop(CSop::opOr0,m_Strip.GetSize()-pos));
+ m_Error || (m_Strip[pos].m_Operand=m_Strip.GetSize()-pos);
+ m_Error || m_Strip.Add(CSop(CSop::opOr1,1));
+ m_Error || m_Strip.Add(CSop(CSop::opChoice1,2));
+ copy = StripDuplicate(pos+1,finish+1);
+ ASSERT(copy==(finish+4));
+ EmitRepeat(copy,1,to-1);
+ break;
+ case REP(1,INF): // as in '+'
+ StripInsert(pos,CSop(CSop::opPlus0,pos));
+ m_Error || m_Strip.Add(CSop(CSop::opPlus1,m_Strip.GetSize()-pos));
+ break;
+ case REP(N,N): // as in 'xx{from-1,to-1}'
+ copy = StripDuplicate(pos,finish);
+ EmitRepeat(copy,from-1,to-1);
+ break;
+ case REP(N,INF): // as in 'xx{n-1,}'
+ copy = StripDuplicate(pos,finish);
+ EmitRepeat(copy,from-1,to);
+ break;
+#ifndef NDEBUG
+ default:
+ ASSERT(FALSE);
+ break;
+#endif
+ }
+#undef MAP
+#undef REP
+#undef INF
+#undef N
+}
+
+int CRegEx::StripDuplicate(int from,int to)
+{
+int rv = m_Strip.GetSize();
+ ASSERT(from<=to);
+ if(from==to)
+ return rv;
+ // Maybe should be optimized for copying the whole thing.
+ for(int tmp=from;tmp<to;tmp++)
+ m_Strip.Add(m_Strip[tmp]);
+ return rv;
+}
+
+void CRegEx::Categorize()
+{
+ if(m_Error)
+ return;
+ for(int tmp=0;tmp<(sizeof(m_Category)/sizeof(m_Category[0]));tmp++)
+ if((!m_Category[tmp]) && IsInSets(tmp)){
+ int cat = m_Categories++;
+ m_Category[tmp]=cat;
+ for(int c=tmp+1;c<(sizeof(m_Category)/sizeof(m_Category[0]));c++)
+ if((!m_Category[c]) && IsInSameSets(tmp,c))
+ m_Category[c]=cat;
+ }
+}
+
+BOOL CRegEx::IsInSets(UCHAR c)
+{
+ for(int tmp=0;tmp<m_Sets.GetSize();tmp++)
+ if(m_Sets[tmp].IsIn(c))
+ return TRUE;
+ return FALSE;
+}
+
+BOOL CRegEx::IsInSameSets(UCHAR c1,UCHAR c2)
+{
+ for(int tmp=0;tmp<m_Sets.GetSize();tmp++)
+ if(m_Sets[tmp].IsIn(c1)!=m_Sets[tmp].IsIn(c2))
+ return FALSE;
+ return TRUE;
+}
+
+void CRegEx::FigureMust()
+{
+ if(m_Error)
+ return;
+ m_Must.Empty();
+int stripLen = m_Strip.GetSize();
+int seqStart, seqLength = 0;
+int mustStart, mustLength = 0;
+ for(int tmp=1;tmp<stripLen;tmp++){
+ switch(m_Strip[tmp].m_Operator){
+ case CSop::opChar:
+ if(!seqLength)
+ seqStart=tmp;
+ seqLength++;
+ break;
+ case CSop::opPlus0:
+ case CSop::opLeftParen:
+ case CSop::opRightParen:
+ break; // Break, since they don't break the sequence
+ case CSop::opQuest0:
+ case CSop::opChoice0:
+ // These ones we skip.
+ do{
+ tmp+=m_Strip[tmp].m_Operand;
+ // I still think it could be ASSERTed..
+ if(m_Strip[tmp].m_Operator!=CSop::opQuest1 && m_Strip[tmp].m_Operator!=CSop::opChoice1 && m_Strip[tmp].m_Operator!=CSop::opOr1){
+ m_iFlags|=iflagsBad;
+ return;
+ }
+ }while(m_Strip[tmp].m_Operator!=CSop::opQuest1 && m_Strip[tmp].m_Operator!=CSop::opChoice1);
+ // Fallthrough..
+ default:
+ // End of sequence
+ if(seqLength>mustLength){
+ mustStart=seqStart;
+ mustLength=seqLength;
+ }
+ seqLength=0;
+ break;
+ }
+ } // Hmm.. originally it's meant to be do while not opEnd..
+ if(!mustLength)
+ return;
+ // Turn into string, but, wait, personally I'm sure it could be put in the main loop.. or maybe not..
+ for(tmp=0;tmp<seqLength;tmp++){
+ while(m_Strip[seqStart+tmp].m_Operator!=CSop::opChar)
+ ASSERT(tmp<seqLength);
+ m_Must+=m_Strip[tmp].m_Operand;
+ }
+}
+
+int CRegEx::CountPluses()
+{
+ if(m_Error)
+ return 0;
+int stripLen = m_Strip.GetSize();
+int rv = 0;
+int nest = 0;
+ for(int tmp=0;tmp<stripLen;tmp++){
+ switch(m_Strip[tmp].m_Operator){
+ case CSop::opPlus0:
+ nest++;
+ break;
+ case CSop::opPlus1:
+ if(nest>rv)
+ rv = nest;
+ nest--;
+ break;
+ }
+ } // Again, originally we were supposed to scan till opEnd..
+ if(nest)
+ m_iFlags|=iflagsBad; // Could this be an ASSERTion?
+ return rv;
+}
+
+void CRegEx::ParseLiteral()
+{
+ if(!m_Pattern.GetLength()){
+ m_Error || (m_Error=regeEmpty);
+ // ??? point to nuls?
+ }
+ while(m_ParsePointer < m_Pattern.GetLength())
+ EmitOrdinary(m_Pattern[m_ParsePointer++]);
+}
+
+void CRegEx::ParseBRE(int stopa,int stopb)
+{
+int start = m_Strip.GetSize();
+BOOL first=TRUE;
+BOOL wasDollar=FALSE;
+ if(m_ParsePointer<m_Pattern.GetLength() && m_Pattern[m_ParsePointer]=='^'){
+ m_ParsePointer++;
+ m_Error || m_Strip.Add(CSop(CSop::opBOL,0));
+ m_iFlags|=iflagsUseBOL;
+ m_BOLs++;
+ }
+CString stopstr;
+ if(stopa){
+ stopstr+=stopa;
+ if(stopb)
+ stopstr+=stopb;
+ }
+ while(m_ParsePointer < m_Pattern.GetLength() && !((m_ParsePointer+1)<m_Pattern.GetLength() && !m_Pattern.Mid(m_ParsePointer,2).Compare(stopstr))){
+ wasDollar = ParseBREexp(first);
+ first=FALSE;
+ }
+ if(wasDollar){ // Trailing anchor that was..
+ m_Strip.SetSize(m_Strip.GetSize()-1);
+ m_Error || m_Strip.Add(CSop(CSop::opEOL,0));
+ m_iFlags|=iflagsUseEOL;
+ m_EOLs++;
+ }
+ if(m_Strip.GetSize()==start){
+ m_Error || (m_Error=regeEmpty);
+ // ??? point to nuls?
+ }
+}
+
+BOOL CRegEx::ParseBREexp(BOOL ordinaryStar)
+{
+int subno;
+int pos = m_Strip.GetSize();
+ ASSERT(m_ParsePointer<m_Pattern.GetLength());
+int c = m_Pattern[m_ParsePointer++];
+ if(c=='\\'){
+ if(m_ParsePointer>=m_Pattern.GetLength()){
+ m_Error || (m_Error=regeEscape);
+ // ??? point to nuls
+ }else
+ c = 0x100|m_Pattern[m_ParsePointer++];
+ }
+ switch(c){
+ case '.':
+ if(m_Flags&regNewLine)
+ EmitNonNewLineAny();
+ else
+ m_Error || m_Strip.Add(CSop(CSop::opAny,0));
+ break;
+ case '[':
+ ParseBracket();
+ break;
+ case 0x100|'{':
+ m_Error || (m_Error=regeBadRepeat);
+ // ??? point to nuls?
+ break;
+ case 0x100|'(':
+ m_Subexps++;
+ subno=m_Subexps;
+ m_ParseParens.SetAtGrow(m_Subexps,CParenthesis(m_Strip.GetSize()));
+ m_Error || m_Strip.Add(CSop(CSop::opLeftParen,subno));
+ if(m_ParsePointer<m_Pattern.GetLength() && !((m_ParsePointer+1)<m_Pattern.GetLength() && !m_Pattern.Mid(m_ParsePointer,2).Compare("\\)")))
+ ParseBRE('\\',')');
+ VERIFY(m_ParseParens[m_Subexps].m_End = m_Strip.GetSize());
+ m_Error || m_Strip.Add(CSop(CSop::opRightParen,subno));
+ if((m_ParsePointer+1) < m_Pattern.GetLength() && !m_Pattern.Mid(m_ParsePointer,2).Compare("\\)"))
+ m_ParsePointer+=2;
+ else{
+ m_Error || (m_Error=regeParen);
+ // ??? point to nuls?
+ }
+ break;
+ case 0x100|')':
+ case 0x100|'}':
+ // Can this possibly happen?!
+ m_Error || (m_Error=regeParen);
+ // ??? point to nuls?
+ break;
+ case 0x100|'1':
+ case 0x100|'2':
+ case 0x100|'3':
+ case 0x100|'4':
+ case 0x100|'5':
+ case 0x100|'6':
+ case 0x100|'7':
+ case 0x100|'8':
+ case 0x100|'9':
+ {
+ int i = (c&0xFF)-'0';
+ if(i < m_ParseParens.GetSize() && m_ParseParens[i].m_End){
+ m_Error || m_Strip.Add(CSop(CSop::opBackRef0,i));
+ ASSERT(m_ParseParens[i].m_Begin);
+ ASSERT(m_Strip[m_ParseParens[i].m_Begin].m_Operator==CSop::opLeftParen);
+ ASSERT(m_Strip[m_ParseParens[i].m_End].m_Operator==CSop::opRightParen);
+ StripDuplicate(m_ParseParens[i].m_Begin+1,m_ParseParens[i].m_End);
+ m_Error || m_Strip.Add(CSop(CSop::opBackRef1,i));
+ }else{
+ m_Error || (m_Error=regeSubReg);
+ // ??? point to nuls?
+ }
+ m_bBackRefs=TRUE;
+ }
+ break;
+ case '*':
+ if(!ordinaryStar){
+ m_Error || (m_Error=regeBadRepeat);
+ // ??? point to nuls?
+ }
+ // Fallthrough..
+ default:
+ EmitOrdinary(c&0xFF);
+ break;
+ }
+ if(m_ParsePointer<m_Pattern.GetLength() && m_Pattern[m_ParsePointer]=='*'){
+ m_ParsePointer++;
+ // as in '+?'
+ StripInsert(pos,CSop(CSop::opPlus0,m_Strip.GetSize()-pos+1));
+ m_Error || m_Strip.Add(CSop(CSop::opPlus1,m_Strip.GetSize()-pos));
+ StripInsert(pos,CSop(CSop::opQuest0,m_Strip.GetSize()-pos+1));
+ m_Error || m_Strip.Add(CSop(CSop::opQuest1,m_Strip.GetSize()-pos));
+ }else if ((m_ParsePointer+1)<m_Pattern.GetLength() && !m_Pattern.Mid(m_ParsePointer,2).Compare("\\{")){
+ m_ParsePointer+=2;
+ int count = ParseCount();
+ int count2;
+ if(m_ParsePointer<m_Pattern.GetLength() && m_Pattern[m_ParsePointer]==','){
+ m_ParsePointer++;
+ if(m_ParsePointer<m_Pattern.GetLength() && isdigit(m_Pattern[m_ParsePointer])){
+ count2=ParseCount();
+ if(count>count2){
+ m_Error || (m_Error=regeBadBrace);
+ // ??? poin to nuls?
+ }
+ }else // Single number with comma
+ count2=256;
+ }else // Single number
+ count2=count;
+ EmitRepeat(pos,count,count2);
+ if((m_ParsePointer+1)>=m_Pattern.GetLength() || m_Pattern.Mid(m_ParsePointer,2).Compare("\\}")){
+ while(m_ParsePointer<m_Pattern.GetLength() && !((m_ParsePointer+1)<m_Pattern.GetLength() && !m_Pattern.Mid(m_ParsePointer,2).Compare("\\}")))
+ m_ParsePointer++;
+ if(m_ParsePointer>=m_Pattern.GetLength()){
+ m_Error || (m_Error=regeBrace);
+ // ??? point to nuls?
+ }
+ m_Error || (m_Error=regeBadBrace);
+ }else
+ m_ParsePointer+=2;
+ }else if(c=='$')
+ return TRUE;
+ return FALSE;
+}
+
+CRegEx::CRegEx()
+{
+ m_bCompiled=FALSE;
+}
+
+LPCTSTR CRegEx::MatchFast(LPCTSTR begin)
+{
+ MatchStatesClear(CSop::stCurrent);
+ m_Strip[1].m_MatchData|=CSop::stCurrent;
+int stripLen = m_Strip.GetSize();
+ MatchStep(1,stripLen-1,CSop::stCurrent,charNothing,CSop::stCurrent);
+ MatchStatesCopy(CSop::stFresh,CSop::stCurrent);
+LPCTSTR coldp = NULL;
+LPCTSTR p = begin;
+int c = (begin==m_mBegin)?charOut:((int)(BYTE)m_mPointer[-1]);
+ for(;;){
+ // next character..
+ int lastc = c;
+ c = (p==m_mEnd)?charOut:(int)*(BYTE*)p;
+ if(MatchStatesEqual(CSop::stCurrent,CSop::stFresh))
+ coldp=p;
+ // Is there an EOL and/or BOL between lastc and c? - they ask..
+ int flagc=0;
+ int i = 0;
+ if((lastc=='\n' && m_Flags&regNewLine) || (lastc==charOut && !(m_mFlags&regNotBOL))){
+ flagc=charBOL;
+ i=m_BOLs;
+ }
+ if((c=='\n' && m_Flags&regNewLine) || (c==charOut && !(m_mFlags&regNotEOL))){
+ flagc=(flagc==charBOL)?charBOLEOL:charEOL;
+ i+=m_EOLs;
+ }
+ if(i){
+ for(;i>0;i--)
+ MatchStep(1,stripLen-1,CSop::stCurrent,flagc,CSop::stCurrent);
+ }
+ // What about a word boundary? - they wonder..
+ if((flagc==charBOL || (lastc!=charOut && !isWordableChar(c))) && (c!=charOut && isWordableChar(c)))
+ flagc = charBOW;
+ if((lastc!=charOut && isWordableChar(lastc)) && (flagc==charEOL || (c!=charOut && !isWordableChar(c))))
+ flagc = charEOW;
+ if(flagc==charBOW || flagc==charEOW){
+ MatchStep(1,stripLen-1,CSop::stCurrent,flagc,CSop::stCurrent);
+ }
+ // Are we done? Now WE wonder..
+ if((m_Strip[stripLen-1].m_MatchData&CSop::stCurrent) || p==m_mEnd)
+ break; // They insist I need to note break out.. Okay, I do..
+ // Nope, we're not done. We have to face this character..
+ MatchStatesCopy(CSop::stTemp,CSop::stCurrent);
+ MatchStatesCopy(CSop::stCurrent,CSop::stFresh);
+ ASSERT(c!=charOut);
+ MatchStep(1,stripLen-1,CSop::stTemp,c,CSop::stCurrent);
+ p++;
+ }
+ ASSERT(coldp);
+ m_cOldP=coldp; // *** I believe this variable can be changed 'in-place'
+ if(m_Strip[stripLen-1].m_MatchData&CSop::stCurrent)
+ return &p[1];
+ else
+ return NULL;
+}
+
+void CRegEx::MatchStatesClear(BYTE mask)
+{
+int stripLen = m_Strip.GetSize();
+ for(int tmp=0;tmp<stripLen;tmp++)
+ m_Strip[tmp].m_MatchData&=~mask;
+}
+
+void CRegEx::MatchStep(int from,int to,BYTE maskBefore,int charCode,BYTE maskAfter)
+{
+BOOL i;
+int look;
+int here = from;
+ for(int pc=from;pc!=to;pc++,here++){
+ CSop s=m_Strip[pc];
+ switch(s.m_Operator){
+ case CSop::opEnd:
+ ASSERT(pc==(to-1));
+ break;
+ case CSop::opChar:
+ // Only characters can match..
+ ASSERT((charCode<charOut) || charCode!=s.m_Operand);
+ if(charCode==s.m_Operand)
+ m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskBefore)?maskAfter:0;
+ break;
+ case CSop::opBOL:
+ if(charCode==charBOL || charCode==charBOLEOL)
+ m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskBefore)?maskAfter:0;
+ break;
+ case CSop::opEOL:
+ if(charCode==charEOL || charCode==charBOLEOL)
+ m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskBefore)?maskAfter:0;
+ break;
+ case CSop::opBOW:
+ if(charCode==charBOW)
+ m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskBefore)?maskAfter:0;
+ break;
+ case CSop::opEOW:
+ if(charCode==charEOW)
+ m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskBefore)?maskAfter:0;
+ break;
+ case CSop::opAny:
+ if(charCode<charOut)
+ m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskBefore)?maskAfter:0;
+ break;
+ case CSop::opAnyOf:
+ if(charCode<charOut && m_Sets[s.m_Operand].m_Set[charCode])
+ m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskBefore)?maskAfter:0;
+ break;
+ case CSop::opBackRef0: // Ignored here..
+ case CSop::opBackRef1:
+ m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0;
+ break;
+ case CSop::opPlus0:
+ // Forward, this is just an empty, comment says..
+ m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0;
+ break;
+ case CSop::opPlus1:
+ m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0;
+ i =(m_Strip[here-s.m_Operand].m_MatchData&maskAfter)!=0;
+ m_Strip[here-s.m_Operand].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0;
+ if(!i && (m_Strip[here-s.m_Operand].m_MatchData&maskAfter)){
+ // oho, must reconsider loop body, comment says.. what's so 'oho' about it?
+ pc-=s.m_Operand+1;
+ here=pc;
+ }
+ break;
+ case CSop::opQuest0:
+ // two branches, both forward..
+ m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0;
+ m_Strip[here+s.m_Operand].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0;
+ break;
+ case CSop::opQuest1:
+ // just an empty.. aren't we tired of justanempties?
+ m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0;
+ break;
+ case CSop::opLeftParen: // they say it's not significan there..
+ case CSop::opRightParen:
+ m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0;
+ break;
+ case CSop::opChoice0: // mark the first two branches..
+ m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0;
+ ASSERT(m_Strip[pc+s.m_Operand].m_Operator==CSop::opOr1);
+ m_Strip[here+s.m_Operand].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0;
+ break;
+ case CSop::opOr0: // done a branch, find the end of choice..
+ if(m_Strip[here].m_MatchData&maskAfter){
+ for(look=1;(s=m_Strip[pc+look]).m_Operator!=CSop::opChoice1;look+=s.m_Operand)
+ ASSERT(s.m_Operator==CSop::opOr1);
+ m_Strip[here+look].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0;
+ }
+ break;
+ case CSop::opOr1: // Propagate Choice's marking..
+ m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0;
+ if(m_Strip[pc+s.m_Operand].m_Operator!=CSop::opChoice1){
+ ASSERT(m_Strip[pc+s.m_Operand].m_Operator==CSop::opOr1);
+ m_Strip[here+s.m_Operand].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0;
+ }
+ break;
+ case CSop::opChoice1: // Just empty.. :-)..
+ m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0;
+ break;
+#ifdef _DEBUG
+ default:
+ ASSERT(FALSE);
+ break;
+#endif
+ }
+ }
+}
+
+void CRegEx::MatchStatesCopy(BYTE dst,BYTE src)
+{
+int stripLen = m_Strip.GetSize();
+ for(int tmp=0;tmp<stripLen;tmp++){
+ // I believe this can be optimized, easily..
+ m_Strip[tmp].m_MatchData&=~dst;
+ m_Strip[tmp].m_MatchData|=(m_Strip[tmp].m_MatchData&src)?dst:0;
+ }
+}
+
+BOOL CRegEx::MatchStatesEqual(BYTE m1,BYTE m2)
+{
+int stripLen = m_Strip.GetSize();
+ for(int tmp=0;tmp<stripLen;tmp++){
+ BYTE mm = m_Strip[tmp].m_MatchData;
+ if(((mm&m1) && (mm&m2)) || !(mm&(m1|m2)))
+ continue;
+ return FALSE;
+ }
+ return TRUE;
+}
+
+LPCTSTR CRegEx::MatchSlow(LPCTSTR begin,LPCTSTR end,int from,int to)
+{
+ MatchStatesClear(CSop::stCurrent);
+ m_Strip[from].m_MatchData|=CSop::stCurrent;
+ MatchStep(from,to,CSop::stCurrent,charNothing,CSop::stCurrent);
+LPCTSTR mp = NULL;
+int c = (m_mBegin==m_mPointer)?charOut:(int)(BYTE)begin[-1];
+LPCTSTR p = begin;
+ for(;;){
+ // next character..
+ int lastc = c;
+ c = (p==m_mEnd)?charOut:(int)*(BYTE*)p;
+ // Now we start to wonder if there is an EOL and/or BOL between lastc and c
+ int flagc = 0;
+ int i = 0;
+ if((lastc=='\n' && m_Flags&regNewLine) || (lastc==charOut && !(m_mFlags&regNotBOL))){
+ flagc = charBOL;
+ i = m_BOLs;
+ }
+ if((c=='\n' && m_Flags&regNewLine) || (c==charOut && !(m_mFlags&regNotEOL))){
+ flagc = (flagc==charBOL)?charBOLEOL:charEOL;
+ i+=m_EOLs;
+ }
+ if(i){
+ for(;i>0;i--)
+ MatchStep(from,to,CSop::stCurrent,flagc,CSop::stCurrent);
+ }
+ // Now we wonder about word boundaries..
+ if((flagc==charBOL || (lastc!=charOut && !isWordableChar(lastc))) && (c!=charOut && isWordableChar(c)))
+ flagc=charBOW;
+ if((lastc!=charOut && isWordableChar(lastc)) && (flagc==charEOL || (c!=charOut && !isWordableChar(c))))
+ flagc=charEOW;
+ if(flagc==charBOW || flagc==charEOW){
+ MatchStep(from,to,CSop::stCurrent,flagc,CSop::stCurrent);
+ }
+ // Are we done we all wonder??
+ if(m_Strip[to].m_MatchData&CSop::stCurrent)
+ mp=p;
+ if(MatchStatesEqual(CSop::stCurrent,CSop::stEmpty) || p==end)
+ break; // Again, we're obliged to note break out. We do.
+ // Sucks.. we have to face this character..
+ MatchStatesCopy(CSop::stTemp,CSop::stCurrent);
+ MatchStatesCopy(CSop::stCurrent,CSop::stEmpty);
+ ASSERT(c!=charOut);
+ MatchStep(from,to,CSop::stTemp,c,CSop::stCurrent);
+ MatchStep(from,to,CSop::stCurrent,charNothing,CSop::stCurrent);
+ p++;
+ }
+ return mp;
+}
+
+LPCTSTR CRegEx::MatchDissect(LPCTSTR begin,LPCTSTR end,int from,int to)
+{
+LPCTSTR sp = begin, dp;
+LPCTSTR stp, rest, tail, ssp, oldssp, sep;
+int ssub, esub;
+int es;
+int i;
+ for(int ss=from;ss<to;ss = es){
+ // Identify end of SubRE
+ es = ss;
+ switch(m_Strip[es].m_Operator){
+ case CSop::opPlus0:
+ case CSop::opQuest0:
+ es+=m_Strip[es].m_Operand;
+ break;
+ case CSop::opChoice0:
+ while(m_Strip[es].m_Operator!=CSop::opChoice1)
+ es+=m_Strip[es].m_Operand;
+ break;
+ }
+ es++;
+ // Figure out what it matched
+ switch(m_Strip[ss].m_Operator){
+ case CSop::opEnd:
+ ASSERT(FALSE);
+ break;
+ case CSop::opChar:
+ sp++;
+ break;
+ case CSop::opBOL:
+ case CSop::opEOL:
+ case CSop::opBOW:
+ case CSop::opEOW:
+ break;
+ case CSop::opAny:
+ case CSop::opAnyOf:
+ sp++;
+ break;
+ case CSop::opBackRef0:
+ case CSop::opBackRef1:
+ ASSERT(FALSE);
+ break;
+ // Cases where lenght of match is hard to find..
+ case CSop::opQuest0:
+ stp=end;
+ for(;;){
+ // How long could this one be??
+ rest = MatchSlow(sp,stp,ss,es);
+ ASSERT(rest); // It did match.. It should've..
+ // Could the rest match the rest? (good question)
+ tail = MatchSlow(rest,end,es,to);
+ if(tail==end)
+ break; // yup.
+ // nope, try a shorter match for this one..
+ stp=rest-1;
+ ASSERT(stp>=sp); // It did work.. It should've..
+ }
+ ssub=ss+1;
+ esub=es-1;
+ // Did innards match?
+ if(MatchSlow(sp,rest,ssub,esub)){
+ dp = MatchDissect(sp,rest,ssub,esub);
+ ASSERT(dp==rest);
+ }else // nope..
+ ASSERT(sp==rest);
+ sp = rest;
+ break;
+ case CSop::opPlus0:
+ stp=end;
+ for(;;){
+ // How long could this one be??
+ rest = MatchSlow(sp,stp,ss,es);
+ ASSERT(rest); // It did.. It should've..
+ // Could the rest match the rest?
+ tail = MatchSlow(rest,end,es,to);
+ if(tail==end)
+ break; // yup.
+ // nope..
+ stp=rest-1;
+ ASSERT(stp>=sp); // It should've worked, we believe..
+ }
+ ssub=ss+1;
+ esub=es-1;
+ ssp=sp;
+ oldssp=ssp;
+ for(;;){ // Find last match of innards..
+ sep = MatchSlow(ssp,rest,ssub,esub);
+ if((!sep) || sep==ssp)
+ break; // Failed or matched nothin'
+ oldssp=ssp;
+ ssp=sep;
+ }
+ if(!sep){
+ // Last successfull..
+ sep=ssp;
+ ssp=oldssp;
+ }
+ ASSERT(sep=rest); // Must exhaust substring they say..
+ VERIFY(MatchSlow(ssp,sep,ssub,esub)==rest); // Assert or verify - that is the question..
+ dp = MatchDissect(ssp,sep,ssub,esub);
+ ASSERT(dp==sep);
+ sp=rest;
+ break;
+ case CSop::opChoice0:
+ stp = end;
+ for(;;){
+ // how long..
+ rest = MatchSlow(sp,stp,ss,es);
+ ASSERT(rest);
+ // Could it..
+ tail = MatchSlow(rest,end,es,to);
+ if(tail==end)
+ break; // y
+ // n
+ stp = rest-1;
+ ASSERT(stp>=sp);
+ }
+ ssub=ss+1;
+ esub=ss+m_Strip[ss].m_Operand-1;
+ ASSERT(m_Strip[esub].m_Operator==CSop::opOr0);
+ for(;;){ // Find first matching branch..
+ if(MatchSlow(sp,rest,ssub,esub)==rest)
+ break;
+ // this one missed, try next..
+ ASSERT(m_Strip[esub].m_Operator==CSop::opOr0);
+ esub++;
+ ASSERT(m_Strip[esub].m_Operator==CSop::opOr1);
+ ssub=esub+1;
+ esub+=m_Strip[esub].m_Operand;
+ if(m_Strip[esub].m_Operator==CSop::opOr1)
+ esub--;
+ else
+ ASSERT(m_Strip[esub].m_Operator==CSop::opChoice1);
+ }
+ dp = MatchDissect(sp,rest,ssub,esub);
+ ASSERT(dp==rest);
+ sp=rest;
+ break;
+ case CSop::opPlus1:
+ case CSop::opQuest1:
+ case CSop::opOr0:
+ case CSop::opOr1:
+ case CSop::opChoice1:
+ ASSERT(FALSE);
+ break;
+ case CSop::opLeftParen:
+ i = m_Strip[ss].m_Operand;
+ ASSERT(0<i && i<=m_Subexps);
+ m_Matches[i].m_Begin=sp-m_mBegin;
+ break;
+ case CSop::opRightParen:
+ i = m_Strip[ss].m_Operand;
+ ASSERT(0<i && i<=m_Subexps);
+ m_Matches[i].m_End=sp-m_mBegin;
+ break;
+#ifdef _DEBUG
+ default: // Uh.. oh..
+ ASSERT(FALSE);
+ break;
+#endif
+ }
+ }
+ ASSERT(sp==end);
+ return sp;
+}
+
+LPCTSTR CRegEx::MatchBackRef(LPCTSTR begin,LPCTSTR end,int from,int to,int level)
+{
+LPCTSTR sp = begin;
+BOOL hard = FALSE;
+ // Get as far as we can as long as it's easy
+ for(int ss=from;!hard && ss<to;ss++){
+ CSop s = m_Strip[ss];
+ switch(s.m_Operator){
+ case CSop::opChar:
+ if(sp==end || *sp++ != s.m_Operand)
+ return NULL;
+ break;
+ case CSop::opAny:
+ if(sp==end)
+ return NULL;
+ sp++; // I'm sure this ++ could be embedded in previous expression..
+ break;
+ case CSop::opAnyOf:
+ if(sp==end || !m_Sets[s.m_Operand].IsIn(*sp++))
+ return NULL;
+ break;
+ case CSop::opBOL:
+ if(!((sp==m_mBegin && !(m_mFlags&regNotBOL)) || (sp<m_mEnd && *(sp-1)=='\n' && (m_Flags&regNewLine))))
+ return NULL;
+ break;
+ case CSop::opEOL:
+ if(!((sp==m_mEnd && !(m_mFlags&regNotEOL)) || (sp<m_mEnd && *sp=='\n' && (m_Flags&regNewLine))))
+ return NULL;
+ break;
+ case CSop::opBOW:
+ if(!(((sp==m_mBegin && !(m_mFlags&regNotBOL)) || (sp<m_mEnd && *(sp-1)=='\n' && (m_Flags&regNewLine)) || (sp>m_mBegin && !isWordableChar(*(sp-1)))) && (sp<m_mEnd && isWordableChar(*sp))))
+ return NULL;
+ break;
+ case CSop::opEOW:
+ if(!(((sp==m_mEnd && !(m_mFlags&regNotEOL)) || (sp<m_mEnd && *sp=='\n' && (m_Flags&regNewLine)) || (sp<m_mEnd && !isWordableChar(*sp))) && (sp>m_mBegin && isWordableChar(*(sp-1)))))
+ return NULL;
+ break;
+ case CSop::opQuest1:
+ break;
+ case CSop::opOr0: // Matches null, but needs to skip
+ ss++;
+ s = m_Strip[ss];
+ do{
+ ASSERT(s.m_Operator==CSop::opOr1);
+ ss+=s.m_Operand;
+ }while((s=m_Strip[ss]).m_Operator!=CSop::opChoice1);
+ // Now we should note that ss++ gets us past the Choice1..
+ break;
+ default:
+ // Have to make a choice..
+ hard=TRUE;
+ break;
+ }
+ }
+ if(!hard){ // That was it..
+ if(sp!=end)
+ return NULL;
+ return sp;
+ }
+ ss--; // Adjust for ther for's final increment..
+ // Hard stuff.. is going on and on..
+CSop s = m_Strip[ss];
+int i, len, offsave;
+int ssub,esub;
+LPCTSTR ssp, dp;
+ switch(s.m_Operator){
+ case CSop::opBackRef0: // The vilest depths they say.. If I only knew what the 'viles' stands for..
+ i = s.m_Operand;
+ ASSERT(0<i && i<=m_Subexps);
+ if(m_Matches[i].m_End<0)
+ return NULL;
+ ASSERT(m_Matches[i].m_Begin>=0);
+ len = m_Matches[i].GetLength();
+ ASSERT((end-m_mBegin)>=len);
+ if(sp>end-len)
+ return NULL; // Not enough left to match..
+ ssp = m_mBegin+m_Matches[i].m_Begin;
+ if(memcmp(sp,ssp,len))
+ return NULL;
+ while(m_Strip[ss]!=CSop(CSop::opBackRef1,i))
+ ss++;
+ return MatchBackRef(sp+len,end,ss+1,to,level-1);
+ break;
+ case CSop::opQuest0: // to null or not they wonder..
+ dp = MatchBackRef(sp,end,ss+1,to,level);
+ if(dp)
+ return dp; // not..
+ return MatchBackRef(sp,end,ss+s.m_Operand+1,to,level-1);
+ break;
+ case CSop::opPlus0:
+ ASSERT(m_mLastPos.GetSize());
+ ASSERT(level+1 <= m_Pluses);
+ m_mLastPos[level+1]=sp;
+ return MatchBackRef(sp,end,ss+1,to,level+1);
+ break;
+ case CSop::opPlus1:
+ if(sp == m_mLastPos[level]) // Last pass matched null
+ return MatchBackRef(sp,end,ss+1,to,level-1);
+ // Try another pass..
+ m_mLastPos[level]=sp;
+ dp = MatchBackRef(sp,end,ss-s.m_Operand+1,to,level);
+ if(dp)
+ return dp;
+ return MatchBackRef(sp,end,ss+1,to,level-1);
+ break;
+ case CSop::opChoice0: // find the right one, ifany
+ ssub = ss+1;
+ esub = ss+s.m_Operand-1;
+ ASSERT(m_Strip[esub].m_Operator==CSop::opOr0);
+ for(;;){ // Find first matching branch.
+ dp = MatchBackRef(sp,end,ssub,esub,level);
+ if(dp)
+ return dp;
+ // This one missed, try next one..
+ if(m_Strip[esub].m_Operator==CSop::opChoice1)
+ return NULL; // There is none..
+ esub++;
+ ASSERT(m_Strip[esub].m_Operator==CSop::opOr1);
+ ssub=esub+1;
+ esub+=m_Strip[esub].m_Operand;
+ if(m_Strip[esub].m_Operator==CSop::opOr1)
+ esub--;
+ else
+ ASSERT(m_Strip[esub].m_Operator==CSop::opChoice1);
+ }
+ break;
+ case CSop::opLeftParen: // Must undo assignment if rest fails..
+ i = s.m_Operand;
+ ASSERT(0<i && i<=m_Subexps);
+ offsave = m_Matches[i].m_Begin;
+ m_Matches[i].m_Begin = sp-m_mBegin;
+ dp = MatchBackRef(sp,end,ss+1,to,level);
+ if(dp)
+ return dp;
+ m_Matches[i].m_Begin=offsave;
+ return NULL;
+ break;
+ case CSop::opRightParen: // Must undo assignment if rest fails..
+ i = s.m_Operand;
+ ASSERT(0<i && i<=m_Subexps);
+ offsave = m_Matches[i].m_End;
+ m_Matches[i].m_End = sp-m_mBegin;
+ dp = MatchBackRef(sp,end,ss+1,to,level);
+ if(dp)
+ return dp;
+ m_Matches[i].m_End = offsave;
+ return NULL;
+ break;
+#ifdef _DEBUG
+ default:
+ ASSERT(FALSE);
+ break;
+#endif
+ }
+ ASSERT(FALSE);
+ return NULL; // Anyway - we can never get here..
+}
+
+#ifdef _DEBUG
+void CRegEx::CSop::Dump(CDumpContext& dc)
+{
+ switch(m_Operator){
+ case opEnd:
+ dc << "end";
+ break;
+ case opChar:
+ dc << "char('" << (char)m_Operand << "')";
+ break;
+ case opBOL:
+ dc << "BOL";
+ break;
+ case opEOL:
+ dc << "EOL";
+ break;
+ case opAny:
+ dc << "any";
+ break;
+ case opAnyOf:
+ dc << "anyOf(" << m_Operand << ")";
+ break;
+ case opBackRef0:
+ dc << "[ backref(" << m_Operand << ")";
+ break;
+ case opBackRef1:
+ dc << "] backref(" << m_Operand << ")";
+ break;
+ case opPlus0:
+ dc << "[ + (" << m_Operand << ")";
+ break;
+ case opPlus1:
+ dc << "] + (" << m_Operand << ")";
+ break;
+ case opQuest0:
+ dc << "[ ? (" << m_Operand << ")";
+ break;
+ case opQuest1:
+ dc << "] ? (" << m_Operand << ")";
+ break;
+ case opLeftParen:
+ dc << "[ ( (" << m_Operand << ")";
+ break;
+ case opRightParen:
+ dc << "] ) (" << m_Operand << ")";
+ break;
+ case opChoice0:
+ dc << "[ choice (" << m_Operand << ")";
+ break;
+ case opOr0:
+ dc << "[ | (" << m_Operand << ")";
+ break;
+ case opOr1:
+ dc << "] | (" << m_Operand << ")";
+ break;
+ case opChoice1:
+ dc << "] choice (" << m_Operand << ")";
+ break;
+ case opBOW:
+ dc << "BOW";
+ break;
+ case opEOW:
+ dc << "EOW";
+ break;
+ }
+}
+void CRegEx::DumpStrip(CDumpContext& dc)
+{
+ for(int tmp=0;tmp<m_Strip.GetSize();tmp++)
+ dc << tmp << ": " << m_Strip[tmp] << ";\n";
+}
+#endif
+
+
+CString CRegEx::GetMatch(int match)
+{
+CString rv;
+ if(!m_Matches.GetSize())
+ return rv;
+ ASSERT(m_Matches[0].m_Begin<m_Input.GetLength() && m_Matches[0].m_End<=m_Input.GetLength());
+ if(match==matchPreMatch)
+ return m_Input.Left(m_Matches[0].m_Begin);
+ if(match==matchPostMatch)
+ return m_Input.Mid(m_Matches[0].m_End);
+ if(match<0 || match >= m_Matches.GetSize())
+ return rv;
+ if(m_Matches[match].m_Begin<0 || m_Matches[match].m_End<0)
+ return rv;
+ ASSERT(m_Matches[match].m_Begin<m_Input.GetLength() && m_Matches[match].m_End<=m_Input.GetLength());
+ rv = m_Input.Mid(m_Matches[match].m_Begin,m_Matches[match].m_End-m_Matches[match].m_Begin);
+ return rv;
+}
diff --git a/shared-code/RegEx.h b/shared-code/RegEx.h
new file mode 100644
index 0000000..2534768
--- a/dev/null
+++ b/shared-code/RegEx.h
@@ -0,0 +1,158 @@
+#ifndef __REGEX_H
+#define __REGEX_H
+
+class CRegEx {
+public:
+ CString GetMatch(int match=0);
+ CString m_Input;
+ struct CMatch {
+ CMatch() : m_Begin(-1), m_End(-1) {}
+ int GetLength() { return m_End-m_Begin; }
+ int m_Begin;
+ int m_End;
+ };
+ typedef CArray<CMatch,CMatch&> CMatchBox;
+ enum {
+ matchMatch = 0,
+ matchPreMatch = -1,
+ matchPostMatch = -2
+ };
+ CMatchBox m_Matches;
+ enum {
+ charOut = 256,
+ charBOL, charEOL, charBOLEOL, charNothing, charBOW, charEOW,
+ charMaxCode = charEOW,
+ charNNChars = (charMaxCode-255)
+ };
+ int m_mFlags;
+ enum {
+ regeSuccess = 0,
+ regeNoMatch = 1, regeBadPattern, regeCollate, regeCType, regeEscape, regeSubReg, regeBracket,
+ regeParen, regeBrace, regeBadBrace, regeRange, regeSpace, regeBadRepeat, regeEmpty, regeAssert,
+ regeInvArg
+ };
+ int m_Error;
+ CRegEx();
+ BOOL m_bCompiled;
+ CString m_Pattern;
+ BOOL m_bBackRefs;
+ int m_Pluses;
+ CString m_Must;
+ BYTE m_Category[CHAR_MAX-CHAR_MIN+1];
+ int m_Categories;
+ int m_EOLs;
+ int m_BOLs;
+ int m_iFlags;
+ int m_Subexps;
+ struct CSop {
+ void Dump(CDumpContext& dc);
+ CSop() {}
+ CSop(BYTE op,DWORD opnd=0) : m_Operator(op), m_Operand(opnd) {}
+ BOOL operator==(CSop& other) {return m_Operator==other.m_Operator && m_Operand==other.m_Operand;}
+ BOOL operator!=(CSop& other) { return !((*this)==other);}
+ enum {
+ opEnd = 1, opChar, opBOL, opEOL, opAny, opAnyOf, opBackRef0, opBackRef1,
+ opPlus0, opPlus1, opQuest0, opQuest1, opLeftParen, opRightParen, opChoice0,
+ opOr0, opOr1, opChoice1, opBOW, opEOW
+ };
+ BYTE m_Operator;
+ DWORD m_Operand;
+ enum {
+ stCurrent = 1, stFresh = 2, stTemp = 4, stEmpty = 8
+ };
+ BYTE m_MatchData;
+ };
+ typedef CArray<CSop,CSop&> CStrip;
+ CStrip m_Strip;
+ int m_Flags;
+ struct CSet {
+ CSet() : m_Hash(0) { memset(m_Set,0,sizeof(m_Set)); }
+ CSet(CSet& src) { (*this)=src; }
+ CSet& operator=(CSet& src) { memmove(this,&src,sizeof(*this)); return *this; }
+ BOOL operator==(CSet& other) { if(m_Hash!=other.m_Hash)return FALSE;return !memcmp(m_Set,other.m_Set,sizeof(m_Set)); }
+ enum {
+ size = (CHAR_MAX-CHAR_MIN+1)
+ };
+ BOOL m_Set[size];
+ BYTE m_Hash;
+ public:
+ UCHAR GetOnly();
+ void Sub(UCHAR c);
+ BOOL IsIn(UCHAR c);
+ void Add(UCHAR c);
+ };
+ typedef CArray<CSet,CSet&> CSets;
+ CSets m_Sets;
+ enum {
+ // Compile flags
+ regBasic = 0, regExtended = 1,
+ regIgnoreCase = 2,
+ regNoSubExpressions = 4, // Also works for matching.
+ regNewLine = 16,
+ regLiteral = 32,
+ // Match Flags
+ regNotBOL = 1,
+ regNotEOL = 2,
+ regOneMatch=64,
+ regBackRefs=128,
+ // iFlags
+ iflagsUseBOL=1, iflagsUseEOL=2, iflagsBad=4
+ };
+ CString Replace(LPCTSTR src,LPCTSTR rep,int flags=0);
+ BOOL Match(LPCTSTR src,int flags=0);
+ BOOL Compile(LPCTSTR regex,int flags=0);
+private:
+#ifdef _DEBUG
+ void DumpStrip(CDumpContext& dc);
+#endif
+ LPCTSTR MatchBackRef(LPCTSTR begin,LPCTSTR end,int from,int to,int level);
+ typedef CArray<LPCTSTR,LPCTSTR> CStrPtrArray;
+ CStrPtrArray m_mLastPos;
+ LPCTSTR MatchDissect(LPCTSTR begin,LPCTSTR end,int from,int to);
+ LPCTSTR MatchSlow(LPCTSTR begin,LPCTSTR end,int from,int to);
+ LPCTSTR m_cOldP;
+ BOOL MatchStatesEqual(BYTE m1,BYTE m2);
+ LPCTSTR m_mBegin;
+ void MatchStatesCopy(BYTE dst,BYTE src);
+ void MatchStep(int from,int to,BYTE maskBefore,int charCode,BYTE maskAfter);
+ void MatchStatesClear(BYTE mask);
+ LPCTSTR MatchFast(LPCTSTR begin);
+ LPCTSTR m_mEnd;
+ LPCTSTR m_mPointer;
+ BOOL ParseBREexp(BOOL ordinaryStar);
+ void ParseBRE(int stopa=0,int stopb=0);
+ void ParseLiteral();
+ int CountPluses();
+ void FigureMust();
+ BOOL IsInSameSets(UCHAR c1,UCHAR c2);
+ BOOL IsInSets(UCHAR c);
+ void Categorize();
+ int StripDuplicate(int from,int to);
+ void EmitRepeat(int pos,int from,int to);
+ UCHAR ParseBracketSymbol();
+ UCHAR ParseBracketCollatingElement(UCHAR term);
+ void ParseBracketEClass(CSet& cset);
+ void ParseBracketCClass(CSet& cset);
+ void ParseBracketTerm(CSet& cset);
+ int StoreSet(CSet& cset);
+ void ParseBracket();
+ int ParseCount();
+ void EmitNonNewLineAny();
+ void EmitOrdinary(UCHAR c);
+ void StripInsert(int pos,CSop& sop);
+ void ParseEREexp();
+ void ParseERE(int stop=0);
+ struct CParenthesis {
+ long m_Begin;
+ long m_End;
+ CParenthesis(long b=0,long e=0) : m_Begin(b), m_End(e) {}
+ };
+ typedef CArray<CParenthesis,CParenthesis&> CParens;
+ CParens m_ParseParens;
+ int m_ParsePointer;
+};
+#ifdef _DEBUG
+inline CDumpContext& operator<<(CDumpContext& dc, CRegEx::CSop& sop) { sop.Dump(dc); return dc; }
+#endif
+
+#endif // __REGEX_H \ No newline at end of file
diff --git a/shared-code/SNMPExtDll.h b/shared-code/SNMPExtDll.h
new file mode 100644
index 0000000..14c920d
--- a/dev/null
+++ b/shared-code/SNMPExtDll.h
@@ -0,0 +1,252 @@
+#ifndef __SNMPEXTDLL_H
+#define __SNMPEXTDLL_H
+
+#include "snmpeer.h"
+
+#include <snmp.h>
+
+namespace Klever {
+
+class CSNMPExtDLL : public CSNMPeer {
+public:
+ HINSTANCE m_hInstance;
+ HANDLE m_hEvent;
+ AsnObjectIdentifier m_OID;
+ BOOL (SNMP_FUNC_TYPE *m_extInit)(DWORD dw,HANDLE h,AsnObjectIdentifier* aoid);
+ BOOL (SNMP_FUNC_TYPE *m_extQuery)(BYTE b,RFC1157VarBindList* rvbl,AsnInteger* ai1,AsnInteger* ai2);
+ BOOL (SNMP_FUNC_TYPE *m_extTrap)(AsnObjectIdentifier*,AsnNetworkAddress*,AsnInteger*,AsnInteger*,AsnTimeticks*,RFC1157VarBindList*);
+
+ HINSTANCE m_hSNMPAPI;
+ void (SNMP_FUNC_TYPE *m_snmpOIDFree)(AsnObjectIdentifier*);
+ LPVOID (SNMP_FUNC_TYPE *m_snmpAlloc)(UINT);
+ void (SNMP_FUNC_TYPE *m_snmpFree)(LPVOID);
+ void (SNMP_FUNC_TYPE *m_snmpVBLFree)(RFC1157VarBindList* vbl);
+ void InitSNMP() {
+ m_hSNMPAPI = ::LoadLibraryEx("SNMPAPI",NULL,0);
+ if(!m_hSNMPAPI)
+ return;
+ *(FARPROC*)&m_snmpOIDFree = ::GetProcAddress(m_hSNMPAPI,"SnmpUtilOidFree");
+ *(FARPROC*)&m_snmpAlloc = ::GetProcAddress(m_hSNMPAPI,"SnmpUtilMemAlloc");
+ *(FARPROC*)&m_snmpFree = ::GetProcAddress(m_hSNMPAPI,"SnmpUtilMemFree");
+ *(FARPROC*)&m_snmpVBLFree = ::GetProcAddress(m_hSNMPAPI,"SnmpUtilVarBindListFree");
+ if(
+ (m_snmpFree && !m_snmpAlloc) ||
+ (m_snmpAlloc && !m_snmpFree)
+ )
+ DeinitSNMP();
+ }
+ void DeinitSNMP() {
+ if(!m_hSNMPAPI)
+ return;
+ ::FreeLibrary(m_hSNMPAPI);
+ m_hSNMPAPI=NULL;
+ }
+ void SNMPFreeOID(AsnObjectIdentifier* oid) {
+ if(m_hSNMPAPI && m_snmpOIDFree)
+ (*m_snmpOIDFree)(oid);
+ else
+ ::GlobalFree((HGLOBAL)oid->ids);
+ }
+ LPVOID SNMPAlloc(UINT size) {
+ if(m_hSNMPAPI && m_snmpAlloc)
+ return (*m_snmpAlloc)(size);
+ else
+ return ::GlobalAlloc(GMEM_FIXED,size);
+ }
+ void SNMPFree(LPVOID addr) {
+ if(m_hSNMPAPI && m_snmpFree)
+ (*m_snmpFree)(addr);
+ else
+ :: GlobalFree((HGLOBAL)addr);
+ }
+ void SNMPFreeVBL(RFC1157VarBindList& vbl) {
+ if(m_hSNMPAPI && m_snmpVBLFree)
+ (*m_snmpVBLFree)(&vbl);
+ else{
+ for(UINT tmp=0;tmp<vbl.len;tmp++) {
+ SNMPFree(vbl.list[tmp].name.ids);
+ switch(vbl.list[tmp].value.asnType){
+ case ASN_OCTETSTRING:
+ case ASN_SEQUENCE:
+ case ASN_RFC1155_IPADDRESS:
+ case ASN_RFC1155_OPAQUE:
+// case ASN_RFC1213_DISPSTRING:
+ if(vbl.list[tmp].value.asnValue.arbitrary.dynamic)
+ SNMPFree(vbl.list[tmp].value.asnValue.arbitrary.stream);
+ break;
+ case ASN_OBJECTIDENTIFIER:
+ SNMPFree(vbl.list[tmp].value.asnValue.object.ids);
+ break;
+ default:
+ break;
+ }
+ }
+ SNMPFree(vbl.list);
+ }
+ }
+
+ BOOL SNMPBuildVBL(RFC1157VarBindList& vbl,CSNMPVarBindList& in) {
+ vbl.len = in.GetCount();
+ vbl.list = (RFC1157VarBind*)SNMPAlloc(sizeof(RFC1157VarBind)*vbl.len);
+ POSITION p = in.GetHeadPosition();
+ UINT ptr = 0;
+ while(p){
+ CSNMPVarBind& vb = in.GetNext(p);
+ ASSERT(ptr<vbl.len);
+ SNMPBuildVB(vbl.list[ptr++],vb);
+ }
+ return TRUE;
+ }
+ BOOL SNMPBuildVB(RFC1157VarBind& vb,CSNMPVarBind& in) {
+ ASSERT(in.name.type==CASNAny::typeASNOID);
+ return SNMPBuildOID(vb.name,in.name.value.oid) && SNMPBuildAA(vb.value,in.value);
+ }
+ BOOL SNMPBuildAA(AsnAny& aa,CASNAny& in) {
+ aa.asnType=in.type;
+ switch(in.type) {
+ case CASNAny::typeASNInteger:
+ aa.asnValue.number=in.value.number; break;
+ case CASNAny::typeASNOctetString:
+// case CASNAny::typeASNDispString:
+ SNMPBuildOS(aa.asnValue.string,in.value.string); break;
+ case CASNAny::typeASNNull:
+ break;
+ case CASNAny::typeASNOID:
+ SNMPBuildOID(aa.asnValue.object,in.value.oid); break;
+ case CASNAny::typeASNSequence:
+// case CASNAny::typeASNSequenceOf:
+ SNMPBuildOS(aa.asnValue.sequence,in.value.sequence); break;
+ case CASNAny::typeASNIP:
+ SNMPBuildFLOS(aa.asnValue.address,(LPBYTE)&in.value.ip,sizeof(in.value.ip)); break;
+ case CASNAny::typeASNCounter:
+ aa.asnValue.counter = in.value.counter; break;
+ case CASNAny::typeASNGauge:
+ aa.asnValue.gauge = in.value.gauge; break;
+ case CASNAny::typeASNTicks:
+ aa.asnValue.ticks = in.value.ticks; break;
+ case CASNAny::typeASNOpaque:
+ ASSERT(in.storeType==CASNAny::storeDynamic);
+ SNMPBuildOS(aa.asnValue.arbitrary,in.value.data); break;
+ break;
+ default:
+ ASSERT(FALSE);
+ return FALSE;
+ }
+ return TRUE;
+ }
+ BOOL SNMPBuildOS(AsnOctetString& os,CASNAny::asnOctetString& in) {
+ return SNMPBuildFLOS(os,in.data,in.size);
+ }
+ BOOL SNMPBuildOID(AsnObjectIdentifier& oid,CASNAny::asnOID& in) {
+ oid.idLength = in.size/sizeof(UINT);
+ ASSERT(!(in.size%sizeof(UINT)));
+ VERIFY(oid.ids = (UINT*)SNMPAlloc(in.size));
+ memmove(oid.ids,in.data,in.size);
+ return TRUE;
+ }
+ BOOL SNMPBuildFLOS(AsnOctetString& os,LPBYTE data,UINT size) {
+ os.length = size;
+ VERIFY(os.stream = (BYTE*)SNMPAlloc(os.length));
+ os.dynamic=TRUE;
+ memmove(os.stream,data,size);
+ return TRUE;
+ }
+ BOOL SNMPParseVBL(RFC1157VarBindList& vbl,CSNMPVarBindList& ou) {
+ for(UINT tmp=0;tmp<vbl.len;tmp++){
+ CSNMPVarBind vb;
+ SNMPParseVB(vbl.list[tmp],vb);
+ ou.AddTail(vb);
+ }
+ return TRUE;
+ }
+ BOOL SNMPParseVB(RFC1157VarBind& vb,CSNMPVarBind& ou) {
+ ou.name.Set(CASNAny::typeASNOID,(LPBYTE)vb.name.ids,vb.name.idLength*sizeof(UINT));
+ return SNMPParseAA(vb.value,ou.value);
+ }
+ BOOL SNMPParseAA(AsnAny& aa,CASNAny& ou) {
+ switch(aa.asnType){
+ case ASN_INTEGER:
+ ou.Set(CASNAny::typeASNInteger,aa.asnValue.number); break;
+ case ASN_OCTETSTRING:
+// case ASN_RFC1213_DISPSTRING:
+ ou.Set(CASNAny::typeASNOctetString,aa.asnValue.string.stream,aa.asnValue.string.length); break;
+ case ASN_OBJECTIDENTIFIER:
+ ou.Set(CASNAny::typeASNOID,(LPBYTE)aa.asnValue.object.ids,aa.asnValue.object.idLength);
+ SNMPParseOID(aa.asnValue.object,ou.value.oid); break;
+ case ASN_SEQUENCE:
+ ou.Set(CASNAny::typeASNSequence,aa.asnValue.sequence.stream,aa.asnValue.sequence.length); break;
+ case ASN_RFC1155_IPADDRESS:
+ SNMPParseIP(aa.asnValue.address,ou); break;
+ case ASN_RFC1155_COUNTER:
+ ou.Set(CASNAny::typeASNCounter,(LONG)aa.asnValue.counter); break;
+ case ASN_RFC1155_GAUGE:
+ ou.Set(CASNAny::typeASNGauge,(LONG)aa.asnValue.gauge); break;
+ case ASN_RFC1155_TIMETICKS:
+ ou.Set(CASNAny::typeASNTicks,(LONG)aa.asnValue.ticks); break;
+ case ASN_RFC1155_OPAQUE:
+ ou.Set(CASNAny::typeASNOpaque,aa.asnValue.arbitrary.stream,aa.asnValue.arbitrary.length); break;
+ case ASN_NULL:
+ ou.Free(); break;
+ default:
+ ASSERT(FALSE);
+ return FALSE;
+ }
+ return TRUE;
+ }
+ BOOL SNMPParseOID(AsnObjectIdentifier& oid,CASNAny::asnOID& ou) {
+ ASSERT(ou.size==(oid.idLength*sizeof(UINT)));
+ memmove(ou.data,oid.ids,ou.size);
+ return TRUE;
+ }
+ BOOL SNMPParseIP(AsnIPAddress& ip,CASNAny& ou) {
+ in_addr i;
+ if(ip.length>sizeof(i))
+ return FALSE;
+ i.s_addr=0;
+ memmove(&i,ip.stream,ip.length);
+ ou.Set(i);
+ return TRUE;
+ }
+
+
+ CSNMPExtDLL(LPCTSTR dllName) : m_hInstance(NULL) { InitSNMP(); Init(dllName); }
+ ~CSNMPExtDLL() { Deinit(); DeinitSNMP(); }
+
+ BOOL Init(LPCTSTR dllName) {
+ Deinit();
+ m_hInstance = ::LoadLibraryEx(dllName,NULL,0);
+ if(!m_hInstance)
+ return FALSE;
+ *(FARPROC*)&m_extInit = ::GetProcAddress(m_hInstance,"SnmpExtensionInit");
+ *(FARPROC*)&m_extQuery = ::GetProcAddress(m_hInstance,"SnmpExtensionQuery");
+ *(FARPROC*)&m_extTrap = ::GetProcAddress(m_hInstance,"SnmpExtensionTrap");
+ if(!(m_extInit && m_extQuery && m_extTrap)){
+ Deinit();
+ return FALSE;
+ }
+ if(!((*m_extInit)(GetCurrentTime(),&m_hEvent,&m_OID))){
+ Deinit();
+ return FALSE;
+ }
+ return TRUE;
+ }
+ void Deinit() {
+ if(!m_hInstance)
+ return;
+ ::FreeLibrary(m_hInstance);
+ }
+ virtual BOOL Request(BYTE type,CSNMPVarBindList& in,CSNMPVarBindList& ou) {
+ RFC1157VarBindList vbl;
+ SNMPBuildVBL(vbl,in);
+ AsnInteger errorStatus, errorIndex;
+ (*m_extQuery)(type,&vbl,&errorStatus,&errorIndex);
+ ou.RemoveAll();
+ SNMPParseVBL(vbl,ou);
+ SNMPFreeVBL(vbl);
+ return TRUE;
+ }
+};
+
+};
+
+#endif // __SNMPEXTDLL_H
diff --git a/shared-code/SNMPOIDs.h b/shared-code/SNMPOIDs.h
new file mode 100644
index 0000000..68ee659
--- a/dev/null
+++ b/shared-code/SNMPOIDs.h
@@ -0,0 +1,221 @@
+#ifndef __SNMPOIDS_H
+#define __SNMPOIDS_H
+
+#define DEFINE_OID(name,oid) static UINT name[] = oid
+
+// MIB-II OIDs
+
+#define OIDccitt {0}
+#define OIDnull {0,0}
+#define OIDiso {1}
+#define OIDorg {1,3}
+#define OIDdod {1,3,6}
+#define OIDinternet {1,3,6,1}
+#define OIDdirectory {1,3,6,1,1}
+#define OIDmgmt {1,3,6,1,2}
+#define OIDmib_2 {1,3,6,1,2,1}
+#define OIDsystem {1,3,6,1,2,1,1}
+#define OIDsysDescr {1,3,6,1,2,1,1,1}
+#define OIDsysObjectID {1,3,6,1,2,1,1,2}
+#define OIDsysUpTime {1,3,6,1,2,1,1,3}
+#define OIDsysContact {1,3,6,1,2,1,1,4}
+#define OIDsysName {1,3,6,1,2,1,1,5}
+#define OIDsysLocation {1,3,6,1,2,1,1,6}
+#define OIDsysServices {1,3,6,1,2,1,1,7}
+#define OIDtransmission {1,3,6,1,2,1,10}
+#define OIDsnmp {1,3,6,1,2,1,11}
+#define OIDsnmpInPkts {1,3,6,1,2,1,11,1}
+#define OIDsnmpInBadValues {1,3,6,1,2,1,11,10}
+#define OIDsnmpInReadOnlys {1,3,6,1,2,1,11,11}
+#define OIDsnmpInGenErrs {1,3,6,1,2,1,11,12}
+#define OIDsnmpInTotalReqVars {1,3,6,1,2,1,11,13}
+#define OIDsnmpInTotalSetVars {1,3,6,1,2,1,11,14}
+#define OIDsnmpInGetRequests {1,3,6,1,2,1,11,15}
+#define OIDsnmpInGetNexts {1,3,6,1,2,1,11,16}
+#define OIDsnmpInSetRequests {1,3,6,1,2,1,11,17}
+#define OIDsnmpInGetResponses {1,3,6,1,2,1,11,18}
+#define OIDsnmpInTraps {1,3,6,1,2,1,11,19}
+#define OIDsnmpOutPkts {1,3,6,1,2,1,11,2}
+#define OIDsnmpOutTooBigs {1,3,6,1,2,1,11,20}
+#define OIDsnmpOutNoSuchNames {1,3,6,1,2,1,11,21}
+#define OIDsnmpOutBadValues {1,3,6,1,2,1,11,22}
+#define OIDsnmpOutGenErrs {1,3,6,1,2,1,11,24}
+#define OIDsnmpOutGetRequests {1,3,6,1,2,1,11,25}
+#define OIDsnmpOutGetNexts {1,3,6,1,2,1,11,26}
+#define OIDsnmpOutSetRequests {1,3,6,1,2,1,11,27}
+#define OIDsnmpOutGetResponses {1,3,6,1,2,1,11,28}
+#define OIDsnmpOutTraps {1,3,6,1,2,1,11,29}
+#define OIDsnmpInBadVersions {1,3,6,1,2,1,11,3}
+#define OIDsnmpEnableAuthenTraps {1,3,6,1,2,1,11,30}
+#define OIDsnmpInBadCommunityNames {1,3,6,1,2,1,11,4}
+#define OIDsnmpInBadCommunityUses {1,3,6,1,2,1,11,5}
+#define OIDsnmpInASNParseErrs {1,3,6,1,2,1,11,6}
+#define OIDsnmpInTooBigs {1,3,6,1,2,1,11,8}
+#define OIDsnmpInNoSuchNames {1,3,6,1,2,1,11,9}
+#define OIDinterfaces {1,3,6,1,2,1,2}
+#define OIDifNumber {1,3,6,1,2,1,2,1}
+#define OIDifTable {1,3,6,1,2,1,2,2}
+#define OIDifEntry {1,3,6,1,2,1,2,2,1}
+#define OIDifIndex {1,3,6,1,2,1,2,2,1,1}
+#define OIDifInOctets {1,3,6,1,2,1,2,2,1,10}
+#define OIDifInUcastPkts {1,3,6,1,2,1,2,2,1,11}
+#define OIDifInNUcastPkts {1,3,6,1,2,1,2,2,1,12}
+#define OIDifInDiscards {1,3,6,1,2,1,2,2,1,13}
+#define OIDifInErrors {1,3,6,1,2,1,2,2,1,14}
+#define OIDifInUnknownProtos {1,3,6,1,2,1,2,2,1,15}
+#define OIDifOutOctets {1,3,6,1,2,1,2,2,1,16}
+#define OIDifOutUcastPkts {1,3,6,1,2,1,2,2,1,17}
+#define OIDifOutNUcastPkts {1,3,6,1,2,1,2,2,1,18}
+#define OIDifOutDiscards {1,3,6,1,2,1,2,2,1,19}
+#define OIDifDescr {1,3,6,1,2,1,2,2,1,2}
+#define OIDifOutErrors {1,3,6,1,2,1,2,2,1,20}
+#define OIDifOutQLen {1,3,6,1,2,1,2,2,1,21}
+#define OIDifSpecific {1,3,6,1,2,1,2,2,1,22}
+#define OIDifType {1,3,6,1,2,1,2,2,1,3}
+#define OIDifMtu {1,3,6,1,2,1,2,2,1,4}
+#define OIDifSpeed {1,3,6,1,2,1,2,2,1,5}
+#define OIDifPhysAddress {1,3,6,1,2,1,2,2,1,6}
+#define OIDifAdminStatus {1,3,6,1,2,1,2,2,1,7}
+#define OIDifOperStatus {1,3,6,1,2,1,2,2,1,8}
+#define OIDifLastChange {1,3,6,1,2,1,2,2,1,9}
+#define OIDat {1,3,6,1,2,1,3}
+#define OIDatTable {1,3,6,1,2,1,3,1}
+#define OIDatEntry {1,3,6,1,2,1,3,1,1}
+#define OIDatIfIndex {1,3,6,1,2,1,3,1,1,1}
+#define OIDatPhysAddress {1,3,6,1,2,1,3,1,1,2}
+#define OIDatNetAddress {1,3,6,1,2,1,3,1,1,3}
+#define OIDip {1,3,6,1,2,1,4}
+#define OIDipForwarding {1,3,6,1,2,1,4,1}
+#define OIDipOutRequests {1,3,6,1,2,1,4,10}
+#define OIDipOutDiscards {1,3,6,1,2,1,4,11}
+#define OIDipOutNoRoutes {1,3,6,1,2,1,4,12}
+#define OIDipReasmTimeout {1,3,6,1,2,1,4,13}
+#define OIDipReasmReqds {1,3,6,1,2,1,4,14}
+#define OIDipReasmOKs {1,3,6,1,2,1,4,15}
+#define OIDipReasmFails {1,3,6,1,2,1,4,16}
+#define OIDipFragOKs {1,3,6,1,2,1,4,17}
+#define OIDipFragFails {1,3,6,1,2,1,4,18}
+#define OIDipFragCreates {1,3,6,1,2,1,4,19}
+#define OIDipDefaultTTL {1,3,6,1,2,1,4,2}
+#define OIDipAddrTable {1,3,6,1,2,1,4,20}
+#define OIDipAddrEntry {1,3,6,1,2,1,4,20,1}
+#define OIDipAdEntAddr {1,3,6,1,2,1,4,20,1,1}
+#define OIDipAdEntIfIndex {1,3,6,1,2,1,4,20,1,2}
+#define OIDipAdEntNetMask {1,3,6,1,2,1,4,20,1,3}
+#define OIDipAdEntBcastAddr {1,3,6,1,2,1,4,20,1,4}
+#define OIDipAdEntReasmMaxSize {1,3,6,1,2,1,4,20,1,5}
+#define OIDipRouteTable {1,3,6,1,2,1,4,21}
+#define OIDipRouteEntry {1,3,6,1,2,1,4,21,1}
+#define OIDipRouteDest {1,3,6,1,2,1,4,21,1,1}
+#define OIDipRouteAge {1,3,6,1,2,1,4,21,1,10}
+#define OIDipRouteMask {1,3,6,1,2,1,4,21,1,11}
+#define OIDipRouteMetric5 {1,3,6,1,2,1,4,21,1,12}
+#define OIDipRouteInfo {1,3,6,1,2,1,4,21,1,13}
+#define OIDipRouteIfIndex {1,3,6,1,2,1,4,21,1,2}
+#define OIDipRouteMetric1 {1,3,6,1,2,1,4,21,1,3}
+#define OIDipRouteMetric2 {1,3,6,1,2,1,4,21,1,4}
+#define OIDipRouteMetric3 {1,3,6,1,2,1,4,21,1,5}
+#define OIDipRouteMetric4 {1,3,6,1,2,1,4,21,1,6}
+#define OIDipRouteNextHop {1,3,6,1,2,1,4,21,1,7}
+#define OIDipRouteType {1,3,6,1,2,1,4,21,1,8}
+#define OIDipRouteProto {1,3,6,1,2,1,4,21,1,9}
+#define OIDipNetToMediaTable {1,3,6,1,2,1,4,22}
+#define OIDipNetToMediaEntry {1,3,6,1,2,1,4,22,1}
+#define OIDipNetToMediaIfIndex {1,3,6,1,2,1,4,22,1,1}
+#define OIDipNetToMediaPhysAddress {1,3,6,1,2,1,4,22,1,2}
+#define OIDipNetToMediaNetAddress {1,3,6,1,2,1,4,22,1,3}
+#define OIDipNetToMediaType {1,3,6,1,2,1,4,22,1,4}
+#define OIDipRoutingDiscards {1,3,6,1,2,1,4,23}
+#define OIDipInReceives {1,3,6,1,2,1,4,3}
+#define OIDipInHdrErrors {1,3,6,1,2,1,4,4}
+#define OIDipInAddrErrors {1,3,6,1,2,1,4,5}
+#define OIDipForwDatagrams {1,3,6,1,2,1,4,6}
+#define OIDipInUnknownProtos {1,3,6,1,2,1,4,7}
+#define OIDipInDiscards {1,3,6,1,2,1,4,8}
+#define OIDipInDelivers {1,3,6,1,2,1,4,9}
+#define OIDicmp {1,3,6,1,2,1,5}
+#define OIDicmpInMsgs {1,3,6,1,2,1,5,1}
+#define OIDicmpInTimestamps {1,3,6,1,2,1,5,10}
+#define OIDicmpInTimestampReps {1,3,6,1,2,1,5,11}
+#define OIDicmpInAddrMasks {1,3,6,1,2,1,5,12}
+#define OIDicmpInAddrMaskReps {1,3,6,1,2,1,5,13}
+#define OIDicmpOutMsgs {1,3,6,1,2,1,5,14}
+#define OIDicmpOutErrors {1,3,6,1,2,1,5,15}
+#define OIDicmpOutDestUnreachs {1,3,6,1,2,1,5,16}
+#define OIDicmpOutTimeExcds {1,3,6,1,2,1,5,17}
+#define OIDicmpOutParmProbs {1,3,6,1,2,1,5,18}
+#define OIDicmpOutSrcQuenchs {1,3,6,1,2,1,5,19}
+#define OIDicmpInErrors {1,3,6,1,2,1,5,2}
+#define OIDicmpOutRedirects {1,3,6,1,2,1,5,20}
+#define OIDicmpOutEchos {1,3,6,1,2,1,5,21}
+#define OIDicmpOutEchoReps {1,3,6,1,2,1,5,22}
+#define OIDicmpOutTimestamps {1,3,6,1,2,1,5,23}
+#define OIDicmpOutTimestampReps {1,3,6,1,2,1,5,24}
+#define OIDicmpOutAddrMasks {1,3,6,1,2,1,5,25}
+#define OIDicmpOutAddrMaskReps {1,3,6,1,2,1,5,26}
+#define OIDicmpInDestUnreachs {1,3,6,1,2,1,5,3}
+#define OIDicmpInTimeExcds {1,3,6,1,2,1,5,4}
+#define OIDicmpInParmProbs {1,3,6,1,2,1,5,5}
+#define OIDicmpInSrcQuenchs {1,3,6,1,2,1,5,6}
+#define OIDicmpInRedirects {1,3,6,1,2,1,5,7}
+#define OIDicmpInEchos {1,3,6,1,2,1,5,8}
+#define OIDicmpInEchoReps {1,3,6,1,2,1,5,9}
+#define OIDtcp {1,3,6,1,2,1,6}
+#define OIDtcpRtoAlgorithm {1,3,6,1,2,1,6,1}
+#define OIDtcpInSegs {1,3,6,1,2,1,6,10}
+#define OIDtcpOutSegs {1,3,6,1,2,1,6,11}
+#define OIDtcpRetransSegs {1,3,6,1,2,1,6,12}
+#define OIDtcpConnTable {1,3,6,1,2,1,6,13}
+#define OIDtcpConnEntry {1,3,6,1,2,1,6,13,1}
+#define OIDtcpConnState {1,3,6,1,2,1,6,13,1,1}
+#define OIDtcpConnLocalAddress {1,3,6,1,2,1,6,13,1,2}
+#define OIDtcpConnLocalPort {1,3,6,1,2,1,6,13,1,3}
+#define OIDtcpConnRemAddress {1,3,6,1,2,1,6,13,1,4}
+#define OIDtcpConnRemPort {1,3,6,1,2,1,6,13,1,5}
+#define OIDtcpInErrs {1,3,6,1,2,1,6,14}
+#define OIDtcpOutRsts {1,3,6,1,2,1,6,15}
+#define OIDtcpRtoMin {1,3,6,1,2,1,6,2}
+#define OIDtcpRtoMax {1,3,6,1,2,1,6,3}
+#define OIDtcpMaxConn {1,3,6,1,2,1,6,4}
+#define OIDtcpActiveOpens {1,3,6,1,2,1,6,5}
+#define OIDtcpPassiveOpens {1,3,6,1,2,1,6,6}
+#define OIDtcpAttemptFails {1,3,6,1,2,1,6,7}
+#define OIDtcpEstabResets {1,3,6,1,2,1,6,8}
+#define OIDtcpCurrEstab {1,3,6,1,2,1,6,9}
+#define OIDudp {1,3,6,1,2,1,7}
+#define OIDudpInDatagrams {1,3,6,1,2,1,7,1}
+#define OIDudpNoPorts {1,3,6,1,2,1,7,2}
+#define OIDudpInErrors {1,3,6,1,2,1,7,3}
+#define OIDudpOutDatagrams {1,3,6,1,2,1,7,4}
+#define OIDudpTable {1,3,6,1,2,1,7,5}
+#define OIDudpEntry {1,3,6,1,2,1,7,5,1}
+#define OIDudpLocalAddress {1,3,6,1,2,1,7,5,1,1}
+#define OIDudpLocalPort {1,3,6,1,2,1,7,5,1,2}
+#define OIDegp {1,3,6,1,2,1,8}
+#define OIDegpInMsgs {1,3,6,1,2,1,8,1}
+#define OIDegpInErrors {1,3,6,1,2,1,8,2}
+#define OIDegpOutMsgs {1,3,6,1,2,1,8,3}
+#define OIDegpOutErrors {1,3,6,1,2,1,8,4}
+#define OIDegpNeighTable {1,3,6,1,2,1,8,5}
+#define OIDegpNeighEntry {1,3,6,1,2,1,8,5,1}
+#define OIDegpNeighState {1,3,6,1,2,1,8,5,1,1}
+#define OIDegpNeighStateUps {1,3,6,1,2,1,8,5,1,10}
+#define OIDegpNeighStateDowns {1,3,6,1,2,1,8,5,1,11}
+#define OIDegpNeighIntervalHello {1,3,6,1,2,1,8,5,1,12}
+#define OIDegpNeighIntervalPoll {1,3,6,1,2,1,8,5,1,13}
+#define OIDegpNeighMode {1,3,6,1,2,1,8,5,1,14}
+#define OIDegpNeighEventTrigger {1,3,6,1,2,1,8,5,1,15}
+#define OIDegpNeighAddr {1,3,6,1,2,1,8,5,1,2}
+#define OIDegpNeighAs {1,3,6,1,2,1,8,5,1,3}
+#define OIDegpNeighInMsgs {1,3,6,1,2,1,8,5,1,4}
+#define OIDegpNeighInErrs {1,3,6,1,2,1,8,5,1,5}
+#define OIDegpNeighOutMsgs {1,3,6,1,2,1,8,5,1,6}
+#define OIDegpNeighOutErrs {1,3,6,1,2,1,8,5,1,7}
+#define OIDegpNeighInErrMsgs {1,3,6,1,2,1,8,5,1,8}
+#define OIDegpNeighOutErrMsgs {1,3,6,1,2,1,8,5,1,9}
+#define OIDegpAs {1,3,6,1,2,1,8,6}
+#define OIDexperimental {1,3,6,1,3}
+#define OIDprivate {1,3,6,1,4}
+#define OIDenterprises {1,3,6,1,4,1}
+
+#endif // __SNMPOIDS_H \ No newline at end of file
diff --git a/shared-code/SNMPeer.h b/shared-code/SNMPeer.h
new file mode 100644
index 0000000..68f2efe
--- a/dev/null
+++ b/shared-code/SNMPeer.h
@@ -0,0 +1,286 @@
+#ifndef __SNMPEER_H
+#define __SNMPEER_H
+
+namespace Klever {
+
+class CASNAny {
+public:
+ enum {
+ asnCls = 0xC0,
+ asnClsUniversal = 0x00,
+ asnClsApplication = 0x40,
+ asnClsContextSpecific = 0x80,
+ asnClsPrivate = 0xC0,
+ asnConstructed = 0x20,
+ asnPrimitive = 0x00,
+ asnTag = 0x1F,
+ // ASN.1 Primitive Tags
+ asnTagInteger = 0x02,
+ asnTagOctetString = 0x04,
+ asnTagNull = 0x05,
+ asnTagOID = 0x06,
+ // ASN.1 Constructed Tags
+ asnTagSequence = 0x10,
+ // RFC1155 Primitive Tags
+ asnTagIP = 0x00,
+ asnTagCounter = 0x01,
+ asnTagGauge = 0x02,
+ asnTagTicks = 0x03,
+ asnTagOpaque = 0x04,
+ // RFC1213 alias
+ asnTagDispString = 0x04, // (ASN.1 Octet string)
+ // RFC1157 Constructed Tags
+ asnTagGetRequest = 0x00,
+ asnTagGetNextRequest = 0x01,
+ asnTagGetResponse = 0x02,
+ asnTagSetRequest = 0x03,
+ asnTagTrap = 0x04
+ };
+ enum {
+ typeASNInteger = (asnClsUniversal|asnPrimitive|asnTagInteger),
+ typeASNOctetString = (asnClsUniversal|asnPrimitive|asnTagOctetString),
+ typeASNNull = (asnClsUniversal|asnPrimitive|asnTagNull),
+ typeASNOID = (asnClsUniversal|asnPrimitive|asnTagOID),
+
+ typeASNSequence = (asnClsUniversal|asnConstructed|asnTagSequence),
+ typeASNSequenceOf = (asnClsUniversal|asnConstructed|asnTagSequence),
+
+ typeASNIP = (asnClsApplication|asnPrimitive|asnTagIP),
+ typeASNCounter = (asnClsApplication|asnPrimitive|asnTagCounter),
+ typeASNGauge = (asnClsApplication|asnPrimitive|asnTagGauge),
+ typeASNTicks = (asnClsApplication|asnPrimitive|asnTagTicks),
+ typeASNOpaque = (asnClsApplication|asnPrimitive|asnTagOpaque),
+ typeASNDispString = (asnClsUniversal|asnPrimitive|asnTagOctetString),
+
+ typeASNGetRequest = (asnClsContextSpecific|asnConstructed|asnTagGetRequest),
+ typeASNGetNextRequest = (asnClsContextSpecific|asnConstructed|asnTagGetNextRequest),
+ typeASNGetResponse = (asnClsContextSpecific|asnConstructed|asnTagGetResponse),
+ typeASNSetRequest = (asnClsContextSpecific|asnConstructed|asnTagSetRequest),
+ typeASNTrap = (asnClsContextSpecific|asnConstructed|asnTagTrap)
+ };
+
+ typedef LONG asnInteger;
+ typedef LARGE_INTEGER asnInteger64;
+ typedef DWORD asnCounter;
+ typedef ULARGE_INTEGER asnCounter64;
+ typedef DWORD asnGauge;
+ typedef ULARGE_INTEGER asnGauge64;
+ typedef DWORD asnTicks;
+ typedef ULARGE_INTEGER asnTicks64;
+ struct asnDynamic {
+ UINT size;
+ LPBYTE data;
+ BOOL Allocate(UINT size) {
+ BOOL rv = Free();
+ if(size)
+ rv=rv&&(data=new BYTE[size]);
+ if(rv)
+ asnDynamic::size=size;
+ return rv;
+ }
+ BOOL Set(LPBYTE data,UINT size) {
+ BOOL rv = Allocate(size);
+ if(rv && size)
+ memmove(asnDynamic::data,data,size);
+ return rv;
+ }
+ BOOL Free() {
+ if(!size)
+ return TRUE;
+ delete data;
+ size=0;
+ data=0;
+ return TRUE;
+ }
+ void Clean() {
+ size=0;
+ data=0;
+ }
+ BOOL Copy(asnDynamic& src) {
+ BOOL rv = Free();
+ if(rv){
+ if(src.size)
+ rv=rv&&(data = new BYTE[src.size]);
+ if(rv){
+ if(size=src.size)
+ memmove(data,src.data,size);
+ }
+ }
+ return rv;
+ }
+ };
+ typedef asnDynamic asnOctetString;
+ typedef asnDynamic asnOID;
+ typedef in_addr asnIP;
+ typedef asnDynamic asnSequence;
+
+ BYTE type;
+ enum _storeType {
+ storeDynamic,
+ storeStatic
+ } storeType;
+ union {
+ asnInteger number;
+ asnInteger64 number64;
+ asnOctetString string;
+ asnOID oid;
+ asnSequence sequence;
+ asnIP ip;
+ asnCounter counter;
+ asnCounter64 counter64;
+ asnGauge gauge;
+ asnGauge64 gauge64;
+ asnTicks ticks;
+ asnTicks64 ticks64;
+ asnDynamic data;
+ } value;
+
+ CASNAny() : type(typeASNNull), storeType(storeStatic) { value.data.Clean(); }
+ CASNAny(CASNAny& src) : type(typeASNNull), storeType(storeStatic) { value.data.Clean();Copy(src); }
+ CASNAny(BYTE type) : type(type), storeType(storeStatic) { value.data.Clean(); }
+ CASNAny(BYTE type,LONG number) : type(typeASNNull), storeType(storeStatic) { value.data.Clean();Set(type,number); }
+ CASNAny(BYTE type,LONGLONG number) : type(typeASNNull), storeType(storeStatic) { value.data.Clean();Set(type,number); }
+ CASNAny(BYTE type,LPCTSTR string) : type(typeASNNull), storeType(storeStatic) { value.data.Clean();Set(type,string); }
+ CASNAny(BYTE type,LPBYTE data,UINT length) : type(typeASNNull), storeType(storeStatic) { value.data.Clean();Set(type,data,length); }
+ CASNAny(BYTE type,UINT* data,UINT size) : type(typeASNNull), storeType(storeStatic) { value.data.Clean();Set(type,(LPBYTE)data,size); }
+ CASNAny(in_addr& ip) : type(typeASNNull), storeType(storeStatic) { value.data.Clean();Set(ip); }
+ ~CASNAny() { Free(); }
+
+ BOOL Set(BYTE type) {
+ BOOL rv = Free();
+ CASNAny::type=type;
+ return rv;
+ }
+ BOOL Set(BYTE type,LONG number) {
+ BOOL rv = Free();
+ CASNAny::type=type;
+ value.number=number;
+ storeType=storeStatic;
+ return rv;
+ }
+ BOOL Set(BYTE type,LONGLONG number) {
+ BOOL rv = Free();
+ CASNAny::type=type;
+ value.number64.QuadPart = number;
+ storeType=storeStatic;
+ return rv;
+ }
+ BOOL Set(BYTE type,LPCTSTR string) {
+ BOOL rv = Free();
+ CASNAny::type=type;
+ rv=rv&&value.string.Set((LPBYTE)string,strlen(string)+1);
+ if(rv){
+ value.string.size--;
+ storeType=storeDynamic;
+ }
+ return rv;
+ }
+ BOOL Set(BYTE type,LPBYTE data,UINT length) {
+ BOOL rv = Free();
+ CASNAny::type=type;
+ rv=rv&&value.data.Set(data,length);
+ if(rv)
+ storeType=storeDynamic;
+ return rv;
+ }
+ BOOL Set(in_addr& ip) {
+ BOOL rv = Free();
+ memmove(&value.ip,&ip,sizeof(value.ip));
+ type=typeASNIP;
+ storeType=storeStatic;
+ return rv;
+ }
+ BOOL Free() {
+ if(storeType==storeDynamic)
+ value.data.Free();
+ else{
+ memset(&value,0,sizeof(value));
+ value.data.Clean();
+ }
+ storeType=storeStatic;
+ type=typeASNNull;
+ return TRUE;
+ }
+ BOOL Copy(CASNAny& src) {
+ BOOL rv = Free();
+ if(src.storeType==storeDynamic){
+ rv=rv&&value.data.Copy(src.value.data);
+ if(rv){
+ type=src.type;
+ storeType=src.storeType;
+ }
+ }else{
+ memmove(this,&src,sizeof(*this));
+ }
+ return rv;
+ }
+ CASNAny& operator=(CASNAny& src) {
+ VERIFY(Copy(src));
+ return *this;
+ }
+
+ // High Level
+ CString GetString() {
+ ASSERT(storeType==storeDynamic);
+ CString rv;
+ LPTSTR b = rv.GetBuffer(value.data.size+1);
+ ASSERT(b);
+ b[value.data.size]=0;
+ memmove(b,value.data.data,value.data.size);
+ rv.ReleaseBuffer();
+ return rv;
+ }
+};
+
+
+class CSNMPVarBind {
+public:
+ CASNAny name;
+ CASNAny value;
+
+ CSNMPVarBind() {}
+ CSNMPVarBind(CASNAny& name,CASNAny& value) : name(name), value(value) {}
+ CSNMPVarBind(CASNAny& name) : name(name) {}
+ CSNMPVarBind(CSNMPVarBind& src) { Copy(src); }
+ BOOL Copy(CSNMPVarBind& src) {
+ name.Copy(src.name);
+ value.Copy(src.value);
+ return TRUE;
+ }
+ CSNMPVarBind& operator=(CSNMPVarBind& src) {
+ Copy(src);
+ return *this;
+ }
+ // High level
+ BOOL IsName(UINT* prefix,UINT prefixSize,BOOL bExact=FALSE) {
+ if(name.type!=CASNAny::typeASNOID)
+ return FALSE;
+ if(name.value.oid.size<prefixSize)
+ return FALSE;
+ if(bExact && (name.value.oid.size!=prefixSize))
+ return FALSE;
+ return !memcmp(prefix,name.value.oid.data,prefixSize);
+ }
+};
+
+class CSNMPVarBindList : public CList<CSNMPVarBind,CSNMPVarBind&> {
+public:
+ CSNMPVarBind* GetVarBind(UINT* prefix,UINT prefixSize,BOOL bExact=FALSE) {
+ POSITION p = GetHeadPosition();
+ while(p){
+ CSNMPVarBind& vb = GetNext(p);
+ if(vb.IsName(prefix,prefixSize,bExact))
+ return &vb;
+ }
+ return NULL;
+ }
+};
+
+class CSNMPeer {
+public:
+ virtual BOOL Request(BYTE type,CSNMPVarBindList& in,CSNMPVarBindList& ou) = 0;
+};
+
+};
+
+#endif // __SNMPEER_H
diff --git a/shared-code/install.h b/shared-code/install.h
new file mode 100644
index 0000000..8c55ca9
--- a/dev/null
+++ b/shared-code/install.h
@@ -0,0 +1,370 @@
+#define WIN32_LEAN_AND_MEAN
+#define VC_EXTRALEAN
+#define WIN32_EXTRALEAN
+#include <windows.h>
+#include <shlobj.h>
+#include <winver.h>
+#include <crtdbg.h>
+#include <string.h>
+#include <stdio.h>
+
+extern "C" WINSHELLAPI void WINAPI SHFree( LPVOID);
+
+template<class T> class Smart {
+public:
+ T *pT;
+
+ Smart() : pT(NULL) {}
+ Smart(int cb) : pT(new T[cb]) {}
+ Smart(T* p) : pT(p) {}
+ ~Smart() { if(pT)delete pT; }
+
+ Smart& operator=(T* p) { if(pT)delete pT; pT=p; return *this; }
+ operator T* () { return pT; }
+
+// T& operator[](int ndx) { return pT[ndx]; }
+
+ T* Detach() { T* rv = pT; pT=NULL; return rv; }
+};
+typedef Smart<char> STRING;
+
+#define APPEND_SLASH(str) if((str)[strlen(str)-1]!='\\')strcat(str,"\\")
+
+HINSTANCE theInstance;
+
+LPSTR strFETCH_REG_KEY(HKEY hRoot,LPCSTR subKey,LPCSTR val)
+{
+HKEY hkey;
+ if(RegOpenKeyEx(hRoot,subKey,0,KEY_QUERY_VALUE,&hkey)!=ERROR_SUCCESS)
+ return NULL;
+DWORD kType,cb=0;
+STRING rv;
+ if(RegQueryValueEx(hkey,val,NULL,&kType,NULL,&cb)==ERROR_SUCCESS && kType==REG_SZ){
+ rv= new char[cb];
+ _ASSERT(rv!=NULL);
+ if(RegQueryValueEx(hkey,val,NULL,&kType,(LPBYTE)(LPSTR)rv,&cb)!=ERROR_SUCCESS)
+ rv=NULL;
+ }
+ RegCloseKey(hkey);
+ return rv.Detach();
+}
+
+BOOL strSET_REG_KEY(HKEY hRoot,LPCSTR subKey,LPCSTR valName,LPCSTR val)
+{
+HKEY hkey;
+DWORD dw;
+ if(RegCreateKeyEx(hRoot,subKey,0,REG_NONE,REG_OPTION_NON_VOLATILE,KEY_READ|KEY_WRITE,NULL,&hkey,&dw)!=ERROR_SUCCESS)
+ return FALSE;
+BOOL rv = (RegSetValueEx(hkey,valName,0,REG_SZ,(LPBYTE)val,strlen(val)+1)==ERROR_SUCCESS);
+ RegCloseKey(hkey);
+ return rv;
+}
+
+void MAKE_PATH(LPCSTR path)
+{
+STRING tmp(strlen(path)+1);
+LPCSTR t0=path;
+LPSTR t1=tmp;
+ while(*t0){
+ if((*t0)=='\\'){
+ *t1=0;
+ CreateDirectory(tmp,NULL);
+ }
+ *(t1++)=*(t0++);
+ }
+ *t1=0;
+ CreateDirectory(tmp,NULL);
+}
+
+BOOL ADDMENU(LPCSTR menu,LPCSTR item,LPCSTR path,LPCSTR program)
+{
+STRING stm = strFETCH_REG_KEY(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders","Programs");
+ if(!stm)
+ return FALSE;
+int pil = 1+strlen(path)+1+strlen(program)+1+1;
+STRING pi(pil);
+ strcpy(pi,path);
+ APPEND_SLASH(pi);
+ strcat(pi,program);
+int ipl = strlen(stm)+1+strlen(menu)+1+strlen(item)+4+1;
+STRING ip(ipl);
+ memmove(ip,stm,strlen(stm)+1);
+ APPEND_SLASH(ip);
+ strcat(ip,menu);
+ MAKE_PATH(ip);
+ APPEND_SLASH(ip);
+ strcat(ip,item);
+ strcat(ip,".lnk");
+IShellLink* sl = NULL;
+IPersistFile* pf = NULL;
+BOOL rv = FALSE;
+ do{
+ HRESULT hrv = CoCreateInstance(CLSID_ShellLink,NULL,CLSCTX_INPROC_SERVER,IID_IShellLink,(LPVOID*)&sl);
+ if(!SUCCEEDED(hrv))
+ break;
+ sl->SetDescription(item);
+ sl->SetPath(pi);
+ hrv = sl->QueryInterface(IID_IPersistFile,(LPVOID*)&pf);
+ if(!SUCCEEDED(hrv))
+ break;
+ WORD wsz[MAX_PATH];
+ MultiByteToWideChar(CP_ACP,0,ip,-1,wsz,MAX_PATH);
+ hrv = pf->Save(wsz,TRUE);
+ if(SUCCEEDED(hrv))
+ rv=TRUE;
+ }while(FALSE);
+ if(pf)
+ pf->Release();
+ if(sl)
+ sl->Release();
+ return rv;
+}
+
+FILE* CREATE_INF_FILE(LPCSTR path,LPCSTR file)
+{
+STRING fn(strlen(path)+1+strlen(file)+1);
+ strcpy(fn,path);
+ APPEND_SLASH(fn);
+ strcat(fn,file);
+ return fopen(fn,"wt");
+}
+
+BOOL INSTALLFILE(LPCSTR res,LPCSTR path,LPCSTR file)
+{
+STRING temp(MAX_PATH);
+ if(!GetTempPath(MAX_PATH,temp)) return FALSE;
+STRING tf(MAX_PATH);
+ if(!GetTempFileName(temp,"KGI",0,tf)) return FALSE;
+HRSRC hrsrc = FindResource(NULL,res,MAKEINTRESOURCE(RT_RCDATA));
+ if(!hrsrc) return FALSE;
+DWORD sor = SizeofResource(NULL,hrsrc);
+ if(!sor) return FALSE;
+HGLOBAL hglobal = LoadResource(NULL,hrsrc);
+ if(!hglobal) return FALSE;
+LPVOID lpv = LockResource(hglobal);
+ if(!lpv) return FALSE;
+HANDLE hf = CreateFile(tf,GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_TEMPORARY,NULL);
+ if(!hf) return FALSE;
+DWORD written = 0;
+ if(!WriteFile(hf,lpv,sor,&written,NULL) || written!=sor){
+ CloseHandle(hf);
+ return FALSE;
+ }
+ CloseHandle(hf);
+STRING toKill(strlen(tf)+1);
+ strcpy(toKill,tf);
+ for(int tmp=strlen(tf)-1;tmp>0 && ((tf[tmp])!='\\');tmp--);
+ if(tf[tmp]=='\\')
+ tf[tmp++]=0;
+STRING nothing(_MAX_PATH);
+UINT nothingLength=_MAX_PATH;
+ if(VerInstallFile(0,&tf[tmp],(LPSTR)file,tf,(LPSTR)path,NULL,nothing,&nothingLength)){
+ DeleteFile(toKill);
+ return FALSE;
+ }
+ DeleteFile(toKill);
+ return TRUE;
+}
+
+LPCSTR pdTitle, pdPrompt;
+char pdPath[_MAX_PATH];
+BOOL CALLBACK pathDlgProc(HWND hwnd,UINT uMsg,WPARAM wP,LPARAM lP)
+{
+ switch(uMsg){
+ case WM_INITDIALOG:
+ SetWindowText(hwnd,pdTitle);
+ SetDlgItemText(hwnd,IDC_PROMPT,pdPrompt);
+ SetDlgItemText(hwnd,IDC_PATH,pdPath);
+ SetWindowPos(hwnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
+ return 1;
+ case WM_COMMAND:
+ switch(LOWORD(wP)){ // ID
+ case IDC_BROWSE:
+ switch(HIWORD(wP)){
+ case BN_CLICKED:
+ {
+ BROWSEINFO bi;
+ memset(&bi,0,sizeof(bi));
+ bi.hwndOwner=hwnd;
+ bi.pszDisplayName=pdPath;
+ bi.lpszTitle="Select Folder..";
+ bi.ulFlags=BIF_RETURNONLYFSDIRS;
+ LPITEMIDLIST lpidl=SHBrowseForFolder(&bi);
+ if(lpidl){
+ SHGetPathFromIDList(lpidl,pdPath);
+ SHFree(lpidl);
+ SetDlgItemText(hwnd,IDC_PATH,pdPath);
+ }
+ }
+ return 1;
+ }
+ break;
+ case IDOK:
+ switch(HIWORD(wP)){
+ case BN_CLICKED:
+ if(GetDlgItemText(hwnd,IDC_PATH,pdPath,sizeof(pdPath)))
+ EndDialog(hwnd,IDOK);
+ else
+ // *** Error message
+ EndDialog(hwnd,IDCANCEL);
+ return 1;
+ }
+ break;
+ case IDCANCEL:
+ switch(HIWORD(wP)){
+ case BN_CLICKED:
+ EndDialog(hwnd,IDCANCEL);
+ return 1;
+ }
+ break;
+ };
+ break;
+ }
+ return 0;
+}
+
+LPSTR REQUESTPATH(LPCSTR title,LPCSTR prompt,LPCSTR defPath)
+{
+ pdTitle=title;pdPrompt=prompt;
+ strcpy(pdPath,defPath);
+ if(DialogBox(NULL,MAKEINTRESOURCE(IDD_PATH),NULL/*Parent*/,(DLGPROC)&pathDlgProc)!=IDOK)
+ return NULL;
+STRING rv(strlen(pdPath)+1);
+ strcpy(rv,pdPath);
+ return rv.Detach();
+}
+
+HKEY uninstallKey(LPCSTR regKey) {
+ STRING rk(100+strlen(regKey)+1);
+ sprintf(rk,"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s",regKey);
+ HKEY rv = NULL;
+ DWORD dw;
+ if(RegCreateKeyEx(HKEY_LOCAL_MACHINE,rk,0,REG_NONE,REG_OPTION_NON_VOLATILE,KEY_READ|KEY_WRITE,NULL,&rv,&dw)!=ERROR_SUCCESS)
+ return NULL;
+ return rv;
+}
+
+BOOL REG_UNINSTALL_COMMAND(LPCSTR regKey,LPCSTR dName,LPCSTR iPath,LPCSTR iFile,LPCSTR iSection)
+{
+ HKEY hKey = uninstallKey(regKey);
+ if(!hKey)
+ return FALSE;
+ BOOL rv=FALSE;
+ do{
+ if(RegSetValueEx(hKey,"DisplayName",0,REG_SZ,(LPBYTE)dName,strlen(dName)+1)!=ERROR_SUCCESS)
+ break;
+ STRING us(50+strlen(iPath)+1+strlen(iFile)+strlen(iSection)+1);
+ strcpy(us,"RunDll32 setupapi.dll,InstallHinfSection ");
+ strcat(us,iSection);
+ strcat(us," 132 ");
+ strcat(us,iPath);
+ APPEND_SLASH(us);
+ strcat(us,iFile);
+ if(RegSetValueEx(hKey,"UninstallString",0,REG_SZ,(LPBYTE)(LPCSTR)us,strlen(us)+1)!=ERROR_SUCCESS)
+ break;
+ rv=TRUE;
+ }while(FALSE);
+ RegCloseKey(hKey);
+ return rv;
+}
+BOOL REG_UNINSTALL_ICON(LPCSTR regKey,LPCSTR path,LPCSTR file,int n) {
+ HKEY hKey = uninstallKey(regKey);
+ if(!hKey)
+ return FALSE;
+ STRING uis(strlen(path)+1+strlen(file)+7);
+ strcpy(uis,path);
+ APPEND_SLASH(uis);
+ strcat(uis,file);
+ char tmp[8];
+ sprintf(tmp,";%d",n);
+ strcat(uis,tmp);
+ BOOL rv = TRUE;
+ if(RegSetValueEx(hKey,"DisplayIcon",0,REG_SZ,(LPBYTE)(LPCSTR)uis,strlen(uis)+1)!=ERROR_SUCCESS)
+ rv = FALSE;
+ RegCloseKey(hKey);
+ return rv;
+}
+BOOL REG_UNINSTALL_COMMENT(LPCSTR regKey,LPCSTR comment) {
+ HKEY hKey = uninstallKey(regKey);
+ if(!hKey)
+ return FALSE;
+ BOOL rv = TRUE;
+ if(RegSetValueEx(hKey,"lComment",0,REG_SZ,(LPBYTE)comment,strlen(comment)+1)!=ERROR_SUCCESS)
+ rv = FALSE;
+ RegCloseKey(hKey);
+ return rv;
+}
+BOOL REG_UNINSTALL_VERSION(LPCSTR regKey,LPCSTR version) {
+ HKEY hKey = uninstallKey(regKey);
+ if(!hKey)
+ return FALSE;
+ BOOL rv = TRUE;
+ if(RegSetValueEx(hKey,"DisplayVersion",0,REG_SZ,(LPBYTE)version,strlen(version)+1)!=ERROR_SUCCESS)
+ rv = FALSE;
+ RegCloseKey(hKey);
+ return rv;
+}
+BOOL REG_UNINSTALL_LOCATION(LPCSTR regKey,LPCSTR location) {
+ HKEY hKey = uninstallKey(regKey);
+ if(!hKey)
+ return FALSE;
+ BOOL rv = TRUE;
+ if(RegSetValueEx(hKey,"InstallLocation",0,REG_SZ,(LPBYTE)location,strlen(location)+1)!=ERROR_SUCCESS)
+ rv = FALSE;
+ RegCloseKey(hKey);
+ return rv;
+}
+BOOL REG_UNINSTALL_PUBLISHER(LPCSTR regKey,LPCSTR publisher) {
+ HKEY hKey = uninstallKey(regKey);
+ if(!hKey)
+ return FALSE;
+ BOOL rv = TRUE;
+ if(RegSetValueEx(hKey,"Publisher",0,REG_SZ,(LPBYTE)publisher,strlen(publisher)+1)!=ERROR_SUCCESS)
+ rv = FALSE;
+ RegCloseKey(hKey);
+ return rv;
+}
+BOOL REG_UNINSTALL_URLS(LPCSTR regKey,LPCSTR about,LPCSTR update) {
+ HKEY hKey = uninstallKey(regKey);
+ if(!hKey)
+ return FALSE;
+ BOOL rv = TRUE;
+ if(RegSetValueEx(hKey,"URLInfoAbout",0,REG_SZ,(LPBYTE)about,strlen(about)+1)!=ERROR_SUCCESS)
+ rv = FALSE;
+ if(RegSetValueEx(hKey,"URLUpdateInfo",0,REG_SZ,(LPBYTE)update,strlen(update)+1)!=ERROR_SUCCESS)
+ rv = FALSE;
+ RegCloseKey(hKey);
+ return rv;
+}
+
+#define INF_FILE_HEADER(i) fprintf(i,"[Version]\nSignature=\"$CHICAGO$\"\n\n")
+#define INF_FILE_SECTION(i,s) fprintf(i,"\n[%s]\n",s)
+#define INF_UNINSTALL_REG(i,p) fprintf(i,"HKLM,Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s\nHKLM,Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s,DisplayName\nHKLM,Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s,UninstallString\n",p,p,p)
+#define INF_MENU_GROUP(i,n,m) fprintf(i,"setup.ini, progman.groups,,\"group%d=%s\"\n",n,m)
+#define INF_MENU_ITEM(i,n,m) fprintf(i,"setup.ini, group%d,, \"\"\"%s\"\"\"\n",n,m);
+#define INF_REMOVE_ROOT(i,g,r) fprintf(i,"HKLM,Software\\Microsoft\\Windows\\CurrentVersion\\DeleteFiles\\%s,,,\"%s\"\n",g,r)
+#define INF_REMOVE_FILE(i,g,f) fprintf(i,"HKLM,Software\\Microsoft\\Windows\\CurrentVersion\\DeleteFiles\\%s,%s,,\"%s\"\n",g,f,f)
+#define INF_REMOVE_HELP_FILE(i,g,f) {INF_REMOVE_FILE(i,g,f".hlp");INF_REMOVE_FILE(i,g,f".cnt");INF_REMOVE_FILE(i,g,f".GID");INF_REMOVE_FILE(i,g,f".FTS");}
+
+LPSTR GET_SHORT_PATH(LPCSTR path)
+{
+char tmp;
+DWORD len = GetShortPathName(path,&tmp,1);
+ if(!len)
+ return NULL;
+STRING rv(len+1);
+ if(!GetShortPathName(path,rv,len+1))
+ return NULL;
+ return rv.Detach();
+}
+
+BOOL Install(void);
+
+int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE,LPSTR,int)
+{
+ theInstance=hInstance;
+ CoInitialize(NULL);
+ Install();
+ CoUninitialize();
+ return 0;
+}
diff --git a/shared-code/ip_icmp.h b/shared-code/ip_icmp.h
new file mode 100644
index 0000000..acaf7e9
--- a/dev/null
+++ b/shared-code/ip_icmp.h
@@ -0,0 +1,91 @@
+#ifndef IP_ICMPHEADER
+
+#define IP_ICMPHEADER
+
+struct icmp {
+ BYTE icmp_type;
+ BYTE icmp_code;
+ WORD icmp_cksum;
+ WORD icmp_id;
+ WORD icmp_seq;
+ char icmp_data[1];
+};
+
+#define SIZE_ICMP_HDR 8
+#define SIZE_TIME_DATA 8
+
+struct ip {
+ BYTE ip_hl:4, /* header length */
+ ip_v:4; /* version */
+ BYTE ip_tos; /* type of service */
+ short ip_len; /* total length */
+ u_short ip_id; /* identification */
+ short ip_off; /* fragment offset field */
+ BYTE ip_ttl; /* time to live */
+ BYTE ip_p; /* protocol */
+ u_short ip_sum; /* checksum */
+ struct in_addr ip_src,ip_dst; /* source and dest address */
+};
+
+#define ICMP_ECHOREPLY 0 /* echo reply */
+#define ICMP_UNREACH 3 /* dest unreachable, codes: */
+#define ICMP_UNREACH_NET 0 /* bad net */
+#define ICMP_UNREACH_HOST 1 /* bad host */
+#define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */
+#define ICMP_UNREACH_PORT 3 /* bad port */
+#define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */
+#define ICMP_UNREACH_SRCFAIL 5 /* src route failed */
+#define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */
+#define ICMP_REDIRECT 5 /* shorter route, codes: */
+#define ICMP_REDIRECT_NET 0 /* for network */
+#define ICMP_REDIRECT_HOST 1 /* for host */
+#define ICMP_REDIRECT_TOSNET 2 /* for tos and net */
+#define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */
+#define ICMP_ECHO 8 /* echo service */
+#define ICMP_TIMXCEED 11 /* time exceeded, code: */
+#define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */
+#define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */
+#define ICMP_PARAMPROB 12 /* ip header bad */
+#define ICMP_TSTAMP 13 /* timestamp request */
+#define ICMP_TSTAMPREPLY 14 /* timestamp reply */
+#define ICMP_IREQ 15 /* information request */
+#define ICMP_IREQREPLY 16 /* information reply */
+#define ICMP_MASKREQ 17 /* address mask request */
+#define ICMP_MASKREPLY 18 /* address mask reply */
+
+#define ICMP_MAXTYPE 18
+
+#define ICMP_MINLEN 8 /* abs minimum */
+#define ICMP_TSLEN (8 + 3 * sizeof (n_time)) /* timestamp */
+#define ICMP_MASKLEN 12 /* address mask */
+#define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */
+#define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8)
+
+#define STNORM 0
+
+/* Definition of the lowest telnet byte following an IAC byte */
+#define LOW_TEL_OPT 236
+
+#define TEL_EOF 236
+#define SUSP 237
+#define ABORT 238
+
+#define SE 240
+#define NOP 241
+#define DM 242
+#define BREAK 243
+#define IP 244
+#define AO 245
+#define AYT 246
+#define EC 247
+#define EL 248
+#define GOAHEAD 249
+#define SB 250
+#define WILL 251
+#define WONT 252
+#define DO 253
+#define DONT 254
+#define IAC 255
+
+#endif
+
diff --git a/shared-code/kHelpers.h b/shared-code/kHelpers.h
new file mode 100644
index 0000000..209c6b0
--- a/dev/null
+++ b/shared-code/kHelpers.h
@@ -0,0 +1,159 @@
+#ifndef __KHELPERS_H
+#define __KHELPERS_H
+
+#include <shlobj.h>
+
+extern "C" WINSHELLAPI void WINAPI SHFree( LPVOID);
+
+namespace Klever {
+
+ inline BOOL BrowseForFolder(CString& folder,LPCTSTR title=NULL,CWnd* pParent=NULL) {
+ BROWSEINFO bi;
+ memset(&bi,0,sizeof(bi));
+ if(pParent)
+ bi.hwndOwner=pParent->GetSafeHwnd();
+ CString rv;
+ bi.pszDisplayName=rv.GetBuffer(MAX_PATH);
+ bi.lpszTitle=title;
+ bi.ulFlags=BIF_RETURNONLYFSDIRS;
+ LPITEMIDLIST lpidl = SHBrowseForFolder(&bi);
+ if(lpidl){
+ SHGetPathFromIDList(lpidl,bi.pszDisplayName);
+ SHFree(lpidl);
+ rv.ReleaseBuffer();
+ folder=rv;
+ return TRUE;
+ }
+ rv.ReleaseBuffer();
+ return FALSE;
+ }
+ inline BOOL BrowseForFolder(CString& folder,UINT idTitle,CWnd* pParent=NULL) {
+ CString title;
+ VERIFY(title.LoadString(idTitle));
+ return BrowseForFolder(folder,title,pParent);
+ }
+ inline CString GluePathAndFile(LPCTSTR path,LPCTSTR file) {
+ CString rv = path;
+ while((!rv.IsEmpty()) && rv[rv.GetLength()-1]=='\\')
+ rv=rv.Left(rv.GetLength()-1);
+ rv+='\\';
+ while(*file && *file=='\\')
+ file++;
+ rv+=file;
+ return rv;
+ }
+ inline UINT TokenizeString(CStringList& rv,LPCTSTR string,LPCTSTR delimiter) {
+ CString s = string;
+ int found;
+ int delength = strlen(delimiter);
+ int rvc = 0;
+ while((found=s.Find(delimiter))>=0){
+ rv.AddTail(s.Left(found));
+ rvc++;
+ s=s.Mid(found+delength);
+ }
+ if(!s.IsEmpty()){
+ rv.AddTail(s);
+ rvc++;
+ }
+ return rvc;
+ }
+ inline BOOL LogRecord(LPCTSTR logFile,LPCTSTR logRecord) {
+ try{
+ CFile f(logFile,CFile::modeCreate|CFile::modeNoTruncate|CFile::modeReadWrite|CFile::shareDenyWrite);
+ f.SeekToEnd();
+ CString s = CTime::GetCurrentTime().Format("[%c] ")+logRecord+"\r\n";
+ f.Write((LPCTSTR)s,s.GetLength());
+ }catch(CException* e){
+ e->Delete();
+ return FALSE;
+ }
+ return TRUE;
+ }
+ inline BOOL ReadString(CFile* file,CString& rv) {
+ rv.Empty();
+ int nBuffer = 256;
+ TCHAR* ch = rv.GetBuffer(nBuffer);
+ int nPos = 0;
+ BOOL bRV = FALSE;
+ for(;;){
+ TCHAR c;
+ try{
+ if(file->Read(&c,sizeof(c))!=sizeof(c))
+ break;
+ bRV=TRUE;
+ }catch(CException* e){
+ e->Delete();
+ TRACE0("Exception in ReadString\n");
+ return FALSE;
+ }
+ if(nPos>=(nBuffer-1)){
+ rv.ReleaseBuffer();
+ ch = rv.GetBuffer(nBuffer=nBuffer+256);
+ ASSERT(ch);
+ }
+ if(c=='\n')
+ break;
+ ch[nPos++]=c;
+ }
+ ch[nPos]=0;
+ for(;;){
+ nPos--;
+ if(nPos<0)
+ break;
+ if(ch[nPos]!='\r')
+ break;
+ ch[nPos]=0;
+ }
+ rv.ReleaseBuffer();
+ rv.FreeExtra();
+ return bRV;
+ }
+
+ inline int LoadStringList(CStringList& list,LPCTSTR section) {
+ CString n;
+ list.RemoveAll();
+ CWinApp* app = AfxGetApp();
+ ASSERT(app);
+ for(int tmp=0;;tmp++){
+ n.Format("%d",tmp);
+ CString str = app->GetProfileString(section,n,NULL);
+ if(str.IsEmpty())
+ break;
+ list.AddTail(str);
+ }
+ return tmp;
+ }
+ inline int SaveStringList(CStringList& list,LPCTSTR section) {
+ CString n;
+ CWinApp* app = AfxGetApp();
+ ASSERT(app);
+ POSITION p = list.GetHeadPosition();
+ for(int tmp=0;p;tmp++){
+ n.Format("%d",tmp);
+ app->WriteProfileString(section,n,list.GetNext(p));
+ }
+ n.Format("%d",tmp);
+ app->WriteProfileString(section,n,NULL);
+ return tmp;
+ }
+
+ inline BOOL WriteProfileString(LPCTSTR section,LPCTSTR entry,LPCTSTR str) {
+ CWinApp* app = AfxGetApp();
+ return app->WriteProfileBinary(section,entry,(LPBYTE)str,strlen(str)+1);
+ }
+ inline CString GetProfileString(LPCTSTR section,LPCTSTR entry,LPCTSTR defval) {
+ CWinApp* app = AfxGetApp();
+ LPBYTE pData;
+ UINT nCount;
+ CString rv = defval;
+ if(app->GetProfileBinary(section,entry,&pData,&nCount)){
+ rv = (LPCTSTR)pData;
+ delete pData;
+ }
+ return rv;
+ }
+
+};
+
+#endif // __KHELPERS_H
diff --git a/shared-code/kICMP.cpp b/shared-code/kICMP.cpp
new file mode 100644
index 0000000..09a8f94
--- a/dev/null
+++ b/shared-code/kICMP.cpp
@@ -0,0 +1,300 @@
+#include "../stdafx.h"
+#include "kICMP.h"
+
+CICMP::_mechanismus CICMP::m_mechanismus = CICMP::_icmpUndetermined;
+
+BOOL CICMPDll::Initialize()
+{
+ if(m_hICMP!=INVALID_HANDLE_VALUE || m_hICMPDLL)
+ Deinitialize();
+ m_hICMPDLL = ::LoadLibraryEx("ICMP",NULL,0);
+ if(!m_hICMPDLL)
+ return FALSE;
+ *(FARPROC*)&m_icmpCF = ::GetProcAddress(m_hICMPDLL,"IcmpCreateFile");
+ *(FARPROC*)&m_icmpSE = ::GetProcAddress(m_hICMPDLL,"IcmpSendEcho");
+ *(FARPROC*)&m_icmpCH = ::GetProcAddress(m_hICMPDLL,"IcmpCloseHandle");
+ if(!(m_icmpCF && m_icmpSE && m_icmpCH)){
+ Deinitialize(); return FALSE;
+ }
+ m_hICMP = (*m_icmpCF)();
+ if(m_hICMP==INVALID_HANDLE_VALUE){
+ Deinitialize(); return FALSE;
+ }
+ TRACE0("ICMP-DLL Initialized\n");
+ return TRUE;
+}
+void CICMPDll::Deinitialize()
+{
+ if(m_hICMPDLL){
+ if(m_hICMP!=INVALID_HANDLE_VALUE && m_icmpCH)
+ (*m_icmpCH)(m_hICMP);
+ ::FreeLibrary(m_hICMPDLL); m_hICMPDLL = NULL;
+ m_icmpCF = NULL;
+ m_icmpSE = NULL;
+ m_icmpCH = NULL;
+ }
+ m_hICMP=INVALID_HANDLE_VALUE;
+ if(m_sizeOut && m_bsOut){
+ delete m_bsOut;
+ m_bsOut = NULL; m_sizeOut = 0;
+ }
+ if(m_sizeIn && m_bsIn){
+ delete m_bsIn;
+ m_bsIn = NULL; m_sizeIn = 0;
+ }
+}
+
+LONG CICMPDll::Ping(const in_addr host,const UINT packetSize,
+ const UINT timeOut,LPINT pStatus)
+{
+ if(!(m_hICMP && m_hICMPDLL && m_icmpSE)){
+ if(pStatus)
+ (*pStatus) = icmpNotInitialized;
+ return -1;
+ }
+ VERIFY(AdjustBuffers(packetSize));
+IPINFO ipi;
+ memset(&ipi,0,sizeof(ipi));
+ ipi.Ttl = 30;
+ for(UINT tmp=0;tmp<packetSize;tmp++)
+ m_bsOut[tmp]=tmp&0xFF;
+LPICMPECHO pRep = (LPICMPECHO)m_bsIn;
+ pRep->Status = 0xFFFFFFFFl;
+ if((*m_icmpSE)(m_hICMP,host.s_addr,m_bsOut,packetSize,
+ &ipi,pRep,m_sizeIn,timeOut))
+ TRACE0("ICMP-SendEcho succeeded\n");
+ else
+ TRACE0("ICMP-SendEcho failed\n");
+LONG lrv = -1;
+INT rv = ipUnknown;
+ switch(pRep->Status){
+ case IP_SUCCESS:
+ lrv = pRep->RTTime; rv = ipSuccess;
+ break;
+ case IP_BUF_TOO_SMALL: rv = ipBuffTooSmall; break;
+ case IP_DEST_NET_UNREACHABLE: rv = ipDestNetUnreachable; break;
+ case IP_DEST_HOST_UNREACHABLE: rv = ipDestHostUnreachable; break;
+ case IP_DEST_PROT_UNREACHABLE: rv = ipDestProtUnreachable; break;
+ case IP_DEST_PORT_UNREACHABLE: rv = ipDestPortUnreachable; break;
+ case IP_NO_RESOURCES: rv = ipNoResources; break;
+ case IP_BAD_OPTION: rv = ipBadOption; break;
+ case IP_HW_ERROR: rv = ipHWError; break;
+ case IP_PACKET_TOO_BIG: rv = ipPacketTooBig; break;
+ case IP_REQ_TIMED_OUT: rv = ipTimeOut; break;
+ case IP_BAD_REQ: rv = ipBadRequest; break;
+ case IP_BAD_ROUTE: rv = ipBadRoute; break;
+ case IP_TTL_EXPIRED_TRANSIT: rv = ipTTLExpiredInTransit; break;
+ case IP_TTL_EXPIRED_REASSEM: rv = ipTTLExpiredInReasm; break;
+ case IP_PARAM_PROBLEM: rv = ipParamProblem; break;
+ case IP_SOURCE_QUENCH: rv = ipSourceQuench; break;
+ case IP_OPTION_TOO_BIG: rv = ipOptionTooBig; break;
+ case IP_BAD_DESTINATION: rv = ipBadDest; break;
+ }
+ if(pStatus)
+ (*pStatus)=rv;
+ return lrv;
+}
+
+BOOL CICMPDll::AdjustBuffers(UINT packetSize)
+{
+ if(!packetSize)
+ packetSize=1;
+ if(packetSize>m_sizeOut){
+ if(m_sizeOut && m_bsOut)
+ delete m_bsOut;
+ m_bsOut = new BYTE[m_sizeOut=packetSize];
+ if(!m_bsOut)
+ return FALSE;
+ }
+UINT sin = sizeof(ICMPECHO)+SIZE_ICMP_HDR+packetSize;
+ if(sin>m_sizeIn){
+ if(m_sizeIn && m_bsIn)
+ delete m_bsIn;
+ m_bsIn = new BYTE[m_sizeIn=sin];
+ if(!m_bsIn)
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+WORD CICMPWS::m_icmpSeq = 0;
+
+BOOL CICMPWS::Initialize()
+{
+ if(m_socket!=INVALID_SOCKET)
+ Deinitialize();
+ m_socket = socket(AF_INET,SOCK_RAW,1/*ICMP*/);
+ if(m_socket==INVALID_SOCKET)
+ return FALSE;
+ TRACE0("ICMP-WS Initialized\n");
+ return TRUE;
+}
+void CICMPWS::Deinitialize()
+{
+ if(m_socket!=INVALID_SOCKET){
+ closesocket(m_socket);
+ m_socket=INVALID_SOCKET;
+ }
+ if(m_sizeOut && m_bsOut){
+ delete m_bsOut;
+ m_bsOut = NULL; m_sizeOut = 0;
+ }
+ if(m_sizeIn && m_bsIn){
+ delete m_bsIn;
+ m_bsIn = NULL; m_sizeIn = 0;
+ }
+}
+LONG CICMPWS::Ping(const in_addr host,const UINT packetSize,
+ const UINT timeOut,LPINT pStatus)
+{
+ if(m_socket==INVALID_SOCKET){
+ if(pStatus)
+ (*pStatus)=icmpNotInitialized;
+ }
+ VERIFY(AdjustBuffers(packetSize));
+icmp* pPacket = (icmp*)m_bsOut;
+ memset(pPacket,0,m_sizeOut);
+ pPacket->icmp_type = ICMP_ECHO;
+ pPacket->icmp_seq = m_icmpSeq++;
+ pPacket->icmp_id = (WORD)(::GetCurrentThreadId()&0xFFFF);
+ for(UINT tmp=0;tmp<packetSize;tmp++)
+ pPacket->icmp_data[tmp]=tmp&0xFF;
+ pPacket->icmp_cksum = cksum(pPacket,SIZE_ICMP_HDR+packetSize);
+sockaddr_in to;
+ memset(&to,0,sizeof(to));
+ to.sin_addr.s_addr = host.s_addr;
+ to.sin_family = AF_INET;
+ if(sendto(m_socket,(char*)pPacket,SIZE_ICMP_HDR+packetSize,0,
+ (SOCKADDR*)&to,sizeof(to)) != (int)(SIZE_ICMP_HDR+packetSize)){
+ TRACE1("sendto: %lu\n",WSAGetLastError());
+ if(pStatus)
+ (*pStatus)=icmpSocketError;
+ return -1;
+ }
+DWORD sentTime = ::GetTickCount();
+sockaddr_in from;
+ memset(&from,0,sizeof(from));
+ from.sin_family=AF_INET;
+ from.sin_addr.s_addr=INADDR_ANY;
+fd_set fds;
+ FD_ZERO(&fds);
+ FD_SET(m_socket,&fds);
+long lrv = -1;
+INT rv = ipTimeOut;
+ for(;;){
+ DWORD ct = ::GetTickCount();
+ if((ct-sentTime)>=timeOut){
+ TRACE0("Timeout\n");
+ break;
+ }
+ timeval tv = {
+ (timeOut-ct+sentTime)/1000,
+ (timeOut-ct+sentTime)%1000
+ }; // tv_sec, tv_usec (secs,microsecs)
+ if(!select(m_socket,&fds,NULL,NULL,&tv)){
+ TRACE1("select: %d\n",WSAGetLastError());
+ break;
+ }
+ DWORD rtime = ::GetTickCount();
+ ASSERT(FD_ISSET(m_socket,&fds));
+ int fl = sizeof(from);
+ int rb = recvfrom(m_socket,(char*)m_bsIn,m_sizeIn,0,(SOCKADDR*)&from,&fl);
+ ip* pIP = (ip*)m_bsIn;
+ icmp* pICMP = (icmp*)&m_bsIn[sizeof(ip)];
+ if(pICMP->icmp_id!=pPacket->icmp_id)
+ continue;
+ if(pICMP->icmp_seq!=pPacket->icmp_seq)
+ continue;
+ if(from.sin_addr.s_addr!=host.s_addr)
+ continue;
+ if(pICMP->icmp_type==ICMP_ECHOREPLY){
+ lrv=rtime-sentTime;
+ rv=ipSuccess;
+ break;
+ }
+ rv = ipUnknown; // ***
+ break;
+ }
+ if(pStatus)
+ (*pStatus)=rv;
+ return lrv;
+}
+
+BOOL CICMPWS::AdjustBuffers(UINT packetSize)
+{
+ if(!packetSize)
+ packetSize=0;
+UINT osize = packetSize+SIZE_ICMP_HDR;
+ if(m_sizeOut<osize){
+ if(m_sizeOut && m_bsOut)
+ delete m_bsOut;
+ m_bsOut = new BYTE[m_sizeOut=osize];
+ if(!m_bsOut)
+ return FALSE;
+ }
+UINT isize = osize+sizeof(ip);
+ if(m_sizeIn<isize){
+ if(m_sizeIn && m_bsIn)
+ delete m_bsIn;
+ m_bsIn = new BYTE[m_sizeIn=isize];
+ if(!m_bsIn)
+ return FALSE;
+ }
+ return TRUE;
+}
+
+WORD CICMPWS::cksum(LPVOID data,int count)
+{
+long lSum = 0;
+WORD *pData = (WORD*)data;
+ while(count>0){
+ if(count>1){
+ lSum+=*(pData++);
+ count-=2;
+ }else{
+ lSum+=((WORD)*(BYTE*)pData)&0xFF;
+ count--;
+ }
+ }
+ lSum = (lSum&0xFFFF)+(lSum>>16);
+ lSum += (lSum>>16);
+ return (~lSum)&0xFFFF;
+}
+
+CICMP* CICMP::CreateICMP()
+{
+ if(m_mechanismus==_icmpUndetermined)
+ GuessMechanismus();
+ switch(m_mechanismus){
+ case _icmpWinsock:
+ return new CICMPWS;
+ break;
+ case _icmpDLL:
+ return new CICMPDll;
+ break;
+ }
+ return NULL;
+}
+
+void CICMP::GuessMechanismus()
+{
+ m_mechanismus=_icmpUndetermined;
+SOCKET testSocket = socket(AF_INET,SOCK_RAW,1);
+ if(testSocket!=INVALID_SOCKET){
+ closesocket(testSocket);
+ m_mechanismus=_icmpWinsock;
+ }else{
+ HINSTANCE hICMP = ::LoadLibraryEx("ICMP",NULL,0);
+ if(!hICMP)
+ return;
+ BOOL isThere = (
+ ::GetProcAddress(hICMP,"IcmpCreateFile")
+ && ::GetProcAddress(hICMP,"IcmpSendEcho")
+ && ::GetProcAddress(hICMP,"IcmpCloseHandle")
+ );
+ ::FreeLibrary(hICMP);
+ if(isThere)
+ m_mechanismus=_icmpDLL;
+ }
+} \ No newline at end of file
diff --git a/shared-code/kICMP.h b/shared-code/kICMP.h
new file mode 100644
index 0000000..7a5ceaa
--- a/dev/null
+++ b/shared-code/kICMP.h
@@ -0,0 +1,80 @@
+#ifndef __KICMP_H
+#define __KICMP_H
+
+class CICMP {
+ enum _mechanismus {
+ _icmpUndetermined = -1,
+ _icmpWinsock = 0, _icmpDLL
+ };
+static _mechanismus m_mechanismus;
+static void GuessMechanismus();
+public:
+static
+ CICMP* CreateICMP();
+
+ enum {
+ ipSuccess = 0,
+ ipBuffTooSmall, ipDestNetUnreachable, ipDestHostUnreachable,
+ ipDestProtUnreachable, ipDestPortUnreachable, ipNoResources,
+ ipBadOption, ipHWError, ipPacketTooBig, ipTimeOut, ipBadRequest,
+ ipBadRoute, ipTTLExpiredInTransit, ipTTLExpiredInReasm,
+ ipParamProblem, ipSourceQuench, ipOptionTooBig, ipBadDest,
+ ipUnknown = -1,
+ icmpNotInitialized = -2,
+ icmpSocketError = -3
+ };
+
+ virtual BOOL Initialize() = 0;
+ virtual void Deinitialize() = 0;
+
+ virtual LONG Ping(const in_addr host,const UINT packetSize=0,
+ const UINT timeOut=10000,LPINT pStatus=NULL) = 0;
+};
+
+class CICMPDll : public CICMP {
+ HANDLE (WINAPI *m_icmpCF)(VOID);
+ BOOL (WINAPI *m_icmpSE)(HANDLE,ULONG,LPVOID,WORD,
+ PIPINFO,LPVOID,DWORD,DWORD);
+ BOOL (WINAPI *m_icmpCH)(HANDLE);
+public:
+ HINSTANCE m_hICMPDLL;
+ HANDLE m_hICMP;
+ LPBYTE m_bsIn, m_bsOut;
+ UINT m_sizeIn, m_sizeOut;
+
+ CICMPDll() : m_hICMP(INVALID_HANDLE_VALUE), m_hICMPDLL(NULL),
+ m_bsIn(NULL), m_bsOut(NULL), m_sizeIn(0), m_sizeOut(0) {}
+ virtual ~CICMPDll() { Deinitialize(); }
+
+ virtual BOOL Initialize();
+ virtual void Deinitialize();
+
+ virtual LONG Ping(const in_addr host,const UINT packetSize=0,
+ const UINT timeOut=10000,LPINT pStatus=NULL);
+
+ BOOL AdjustBuffers(UINT packetSize=0);
+};
+
+class CICMPWS : public CICMP {
+static
+ WORD m_icmpSeq;
+public:
+ SOCKET m_socket;
+ LPBYTE m_bsIn, m_bsOut;
+ UINT m_sizeIn, m_sizeOut;
+
+ CICMPWS() : m_socket(INVALID_SOCKET), m_bsIn(NULL), m_bsOut(NULL),
+ m_sizeIn(0), m_sizeOut(0) {}
+ virtual ~CICMPWS() { Deinitialize(); }
+
+ virtual BOOL Initialize();
+ virtual void Deinitialize();
+
+ virtual LONG Ping(const in_addr host,const UINT packetSize=0,
+ const UINT timeOut=10000,LPINT pStatus=NULL);
+
+ BOOL AdjustBuffers(UINT packetSize=0);
+ WORD cksum(LPVOID data,int count);
+};
+
+#endif // __KICMP_H \ No newline at end of file
diff --git a/shared-code/kinhelp.xsl b/shared-code/kinhelp.xsl
new file mode 100644
index 0000000..0bb384a
--- a/dev/null
+++ b/shared-code/kinhelp.xsl
@@ -0,0 +1,250 @@
+<?xml version="1.0"?>
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ >
+ <xsl:output
+ method="text"
+ encoding="us-ascii"/>
+ <xsl:strip-space elements="*"/>
+
+ <xsl:template match="winhelp">
+ <xsl:text>{\rtf1\ansi</xsl:text>
+ <xsl:text>&#xA;@{\footnote</xsl:text>
+ <xsl:text>&#xA;THIS FILE WAS AUTOMATICALLY GENERATED FROM XML DOCUMENT.</xsl:text>
+ <xsl:text>&#xA;DO NOT MODIFY THIS FILE DIRECTLY. EDIT XML DOCUMENT INSTEAD</xsl:text>
+ <xsl:text>&#xA;}&#xA;</xsl:text>
+ <xsl:call-template name="fonttbl"/>
+ <xsl:call-template name="colortbl"/>
+ <xsl:apply-templates/>
+ <xsl:text>}</xsl:text>
+ </xsl:template>
+
+ <xsl:template match="topic">
+ <xsl:text>&#xA;\pard\plain</xsl:text>
+ <xsl:if test="descendant::*[ (@scroll='no') and
+ count(preceding-sibling::*[not(@scroll='no') and (name()!='a' and @name)])=0] ">
+ <xsl:text>\keepn</xsl:text>
+ </xsl:if>
+ <xsl:if test="@id">
+ <xsl:text>&#xA;#{\footnote </xsl:text>
+ <xsl:value-of select="@id"/>
+ <xsl:text>}</xsl:text>
+ </xsl:if>
+ <xsl:if test="@title">
+ <xsl:text>&#xA;${\footnote </xsl:text>
+ <xsl:value-of select="@title"/>
+ <xsl:text>}</xsl:text>
+ </xsl:if>
+ <xsl:if test="@keywords">
+ <xsl:text>&#xA;K{\footnote </xsl:text>
+ <xsl:value-of select="@keywords"/>
+ <xsl:text>}</xsl:text>
+ </xsl:if>
+ <xsl:apply-templates/>
+ <xsl:text>&#xA;\page&#xA;</xsl:text>
+ </xsl:template>
+
+ <xsl:template match="a[@name]">
+ <xsl:text>{#{\footnote </xsl:text>
+ <xsl:value-of select="@name"/>
+ <xsl:text>}}</xsl:text>
+ </xsl:template>
+ <xsl:template match="a[@href]">
+ <xsl:call-template name="hyperref">
+ <xsl:with-param name="href" select="@href"/>
+ <xsl:with-param name="inset"><xsl:apply-templates/></xsl:with-param>
+ </xsl:call-template>
+ </xsl:template>
+ <xsl:template name="hyperref">
+ <xsl:param name="href"/>
+ <xsl:param name="inset"/>
+ <xsl:choose>
+ <xsl:when test="starts-with($href,'http:') or starts-with($href,'mailto:') or
+ starts-with($href,'ftp:')">
+ <xsl:text>{\uldb </xsl:text>
+ <xsl:value-of select="$inset"/>
+ <xsl:text>}{\v %!ExecFile("</xsl:text>
+ <xsl:value-of select="$href"/>
+ <xsl:text>")}</xsl:text>
+ </xsl:when>
+ <xsl:when test="starts-with($href,'#')">
+ <xsl:text>{\uldb </xsl:text>
+ <xsl:value-of select="$inset"/>
+ <xsl:text>}{\v </xsl:text>
+ <xsl:value-of select="substring($href,2)"/>
+ <xsl:text>}</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:message>Warining: Unqualified hyper-reference. Using as help-internal</xsl:message>
+ <xsl:text>{\uldb </xsl:text>
+ <xsl:value-of select="$inset"/>
+ <xsl:text>}{\v </xsl:text>
+ <xsl:value-of select="$href"/>
+ <xsl:text>}</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template match="heading">
+ <xsl:text>&#xA;</xsl:text>
+ <xsl:if test="@scroll!='no'">
+ <xsl:text>\pard </xsl:text>
+ </xsl:if>
+ <xsl:text>{ \f1\fs18\b\sb120 </xsl:text>
+ <xsl:apply-templates/>
+ <xsl:text>}</xsl:text>
+ </xsl:template>
+
+ <xsl:template match="p">
+ <xsl:text>&#xA;\par\sa120\sb120\qj</xsl:text>
+ <xsl:if test="@scroll!='no'">
+ <xsl:text>\pard</xsl:text>
+ </xsl:if>
+ <xsl:text> \f1\fs18\sb120 </xsl:text>
+ <xsl:apply-templates/>
+ </xsl:template>
+
+ <xsl:template match="note">
+ <xsl:text>&#xA;\par\sa120\sb120\qj\f1\fs16 </xsl:text>
+ <xsl:apply-templates/>
+ </xsl:template>
+
+ <xsl:template match="dedication">
+ <xsl:text>&#xA;\par\sa120\sb120\qr\f1\fs16 </xsl:text>
+ <xsl:apply-templates/>
+ </xsl:template>
+
+ <xsl:template match="image">
+ <xsl:text>\{bmct </xsl:text>
+ <xsl:value-of select="@source"/>
+ <xsl:text>\}</xsl:text>
+ </xsl:template>
+
+ <xsl:template match="newsfor">
+ <xsl:text>&#xA;\par\pard\plain\f1\fs24\qc\cf2\b </xsl:text>
+ <xsl:value-of select="@version"/>
+ <xsl:text> - </xsl:text>
+ <xsl:value-of select="@date"/>
+ <xsl:apply-templates/>
+ </xsl:template>
+ <xsl:template match="ni">
+ <xsl:text>&#xA;\par\pard\plain\fi0\li0\f1\fs18 \bullet </xsl:text>
+ <xsl:apply-templates/>
+ </xsl:template>
+
+ <xsl:template match="b">
+ <xsl:text>{\b </xsl:text>
+ <xsl:apply-templates/>
+ <xsl:text>}</xsl:text>
+ </xsl:template>
+ <xsl:template match="i">
+ <xsl:text>{\i </xsl:text>
+ <xsl:apply-templates/>
+ <xsl:text>}</xsl:text>
+ </xsl:template>
+ <xsl:template match="u">
+ <xsl:text>{\ul </xsl:text>
+ <xsl:apply-templates/>
+ <xsl:text>}</xsl:text>
+ </xsl:template>
+ <xsl:template match="strike">
+ <xsl:text>{\strike </xsl:text>
+ <xsl:apply-templates/>
+ <xsl:text>}</xsl:text>
+ </xsl:template>
+
+ <xsl:template match="kin">
+ <xsl:choose>
+ <xsl:when test="@href">
+ <xsl:call-template name="hyperref">
+ <xsl:with-param name="href" select="@href"/>
+ <xsl:with-param name="inset"><xsl:text>{\b </xsl:text><xsl:apply-templates/><xsl:text>}</xsl:text></xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>{\b </xsl:text>
+ <xsl:apply-templates/>
+ <xsl:text>}</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+ <xsl:template match="product">
+ <xsl:choose>
+ <xsl:when test="@href">
+ <xsl:call-template name="hyperref">
+ <xsl:with-param name="href" select="@href"/>
+ <xsl:with-param name="inset"><xsl:text>{\b\cf6 </xsl:text><xsl:apply-templates/><xsl:text>}</xsl:text></xsl:with-param>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>{\b\cf6 </xsl:text>
+ <xsl:apply-templates/>
+ <xsl:text>}</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+ <xsl:template match="term">
+ <xsl:text>{\i </xsl:text>
+ <xsl:apply-templates/>
+ <xsl:text>}</xsl:text>
+ </xsl:template>
+
+ <xsl:template match="rfc">
+ <xsl:call-template name="hyperref">
+ <xsl:with-param name="href" select="concat('http://www.rfc-editor.org/rfc/rfc',@num,'.txt')"/>
+ <xsl:with-param name="inset" select="concat('{\b RFC',@num,'}')"/>
+ </xsl:call-template>
+ </xsl:template>
+
+ <xsl:template match="license">
+ <xsl:text>&#xA;{</xsl:text>
+ <xsl:text>&#xA;\par\pard\plain\sb360\sa120 \f1\fs16 Copyright (c) </xsl:text>
+ <xsl:value-of select="@years"/>
+ <xsl:text> {\uldb\cf0 Klever Group (http://www.klever.net/)}{\v %!ExecFile("http://www.klever.net/")}</xsl:text>
+ <xsl:text>&#xA;\par\qj\sb120\sa120</xsl:text>
+ <xsl:text>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</xsl:text>
+ <xsl:text>&#xA;\par The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</xsl:text>
+ <xsl:text>&#xA;\par \sa360 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</xsl:text>
+ <xsl:text>&#xA;}</xsl:text>
+ </xsl:template>
+ <xsl:template match="credits">
+ <xsl:text>&#xA;\par \sa0\sb120\ql \f1\fs16 Author: {\b\uldb\cf11 Michael Krelin ({\i hacker@klever.net})}{\v %!ExecFile("mailto:hacker@klever.net")}</xsl:text>
+ <xsl:text>&#xA;\par \sa0\sb0 Fan mail send to {\i\uldb gefilte@klever.net}{\v %!ExecFile("mailto:gefilte@klever.net")}</xsl:text>
+ </xsl:template>
+
+ <xsl:template match="ul">
+ <xsl:text>\pard</xsl:text>
+ <xsl:apply-templates/>
+ <xsl:text>\pard</xsl:text>
+ </xsl:template>
+ <xsl:template match="li">
+ <!-- TODO: could be done better, but you never know with winhelp.. -->
+ <xsl:variable name="li" select=" count(ancestor::ul) "/>
+ <xsl:text>&#xA;\par \fi0\li</xsl:text><xsl:value-of
+ select="0"/><xsl:text> \bullet </xsl:text>
+ <xsl:apply-templates/>
+ </xsl:template>
+
+ <xsl:template match="topic/text()">
+ <!-- maybe only omit spaces? -->
+ </xsl:template>
+ <xsl:template match="ul/text()">
+ </xsl:template>
+
+ <xsl:template name="colortbl">
+ <xsl:text>{\colortbl;
+ \red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;
+ \red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;
+ \red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;
+ \red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;}
+ </xsl:text>
+ </xsl:template>
+ <xsl:template name="fonttbl">
+ <xsl:text>{\fonttbl</xsl:text>
+ <xsl:text>{\f0\froman Times New Roman;}</xsl:text>
+ <xsl:text>{\f1\fswiss Arial;}</xsl:text>
+ <xsl:text>{\f3\froman Symbol;}</xsl:text>
+ <xsl:text>}</xsl:text>
+ </xsl:template>
+
+</xsl:stylesheet>
diff --git a/shared-code/ms_icmp.h b/shared-code/ms_icmp.h
new file mode 100644
index 0000000..32d97f5
--- a/dev/null
+++ b/shared-code/ms_icmp.h
@@ -0,0 +1,77 @@
+/*------------------------------------------------------------------
+* Filename: MS_ICMP.H
+*
+* Description: Prototypes of Microsoft's ICMP.DLL functions for
+* access to Internet Control Message Protocol (their stacks do
+* not support the standard Berkeley Sockets raw socket API).
+* Use this to do "ping" or "traceroute," although beware that
+* Microsoft discourages its use.
+*/
+
+
+/* Note 2: For the most part, you can refer to RFC 791 for detials on
+* how to fill in values for the IP option information structure. */
+typedef struct ip_option_information {
+ u_char Ttl; /* Time To Live (used for traceroute) */
+ u_char Tos; /* Type Of Service (usually 0) */
+ u_char Flags; /* IP header flags (usually 0) */
+ u_char OptionsSize; /* Size of options data (usually 0, max 40) */
+ u_char FAR *OptionsData;/* Options data buffer */
+} IPINFO, *PIPINFO, FAR *LPIPINFO;
+
+/* Note 1: The Reply Buffer will have an array of ICMP_ECHO_REPLY
+* structures, followed by options and the data in ICMP echo reply
+* datagram received. You must have room for at least one ICMP
+* echo reply structure, plus 8 bytes for an ICMP header. */
+typedef struct icmp_echo_reply {
+ u_long Address; /* source address */
+ u_long Status; /* IP status value (see below) */
+ u_long RTTime; /* Round Trip Time in milliseconds */
+ u_short DataSize; /* reply data size */
+ u_short Reserved; /* */
+ void FAR *Data; /* reply data buffer */
+ typedef struct ip_option_information Options; /* reply options */
+} ICMPECHO, *PICMPECHO, FAR *LPICMPECHO;
+
+#define IP_STATUS_BASE 11000
+#define IP_SUCCESS 0
+#define IP_BUF_TOO_SMALL (IP_STATUS_BASE + 1)
+#define IP_DEST_NET_UNREACHABLE (IP_STATUS_BASE + 2)
+#define IP_DEST_HOST_UNREACHABLE (IP_STATUS_BASE + 3)
+#define IP_DEST_PROT_UNREACHABLE (IP_STATUS_BASE + 4)
+#define IP_DEST_PORT_UNREACHABLE (IP_STATUS_BASE + 5)
+#define IP_NO_RESOURCES (IP_STATUS_BASE + 6)
+#define IP_BAD_OPTION (IP_STATUS_BASE + 7)
+#define IP_HW_ERROR (IP_STATUS_BASE + 8)
+#define IP_PACKET_TOO_BIG (IP_STATUS_BASE + 9)
+#define IP_REQ_TIMED_OUT (IP_STATUS_BASE + 10)
+#define IP_BAD_REQ (IP_STATUS_BASE + 11)
+#define IP_BAD_ROUTE (IP_STATUS_BASE + 12)
+#define IP_TTL_EXPIRED_TRANSIT (IP_STATUS_BASE + 13)
+#define IP_TTL_EXPIRED_REASSEM (IP_STATUS_BASE + 14)
+#define IP_PARAM_PROBLEM (IP_STATUS_BASE + 15)
+#define IP_SOURCE_QUENCH (IP_STATUS_BASE + 16)
+#define IP_OPTION_TOO_BIG (IP_STATUS_BASE + 17)
+#define IP_BAD_DESTINATION (IP_STATUS_BASE + 18)
+#define IP_ADDR_DELETED (IP_STATUS_BASE + 19)
+#define IP_SPEC_MTU_CHANGE (IP_STATUS_BASE + 20)
+#define IP_MTU_CHANGE (IP_STATUS_BASE + 21)
+#define IP_UNLOAD (IP_STATUS_BASE + 22)
+#define IP_GENERAL_FAILURE (IP_STATUS_BASE + 50)
+#define MAX_IP_STATUS IP_GENERAL_FAILURE
+#define IP_PENDING (IP_STATUS_BASE + 255)
+
+
+HANDLE WINAPI PASCAL IcmpCreateFile(VOID); /* INVALID_HANDLE_VALUE on error */
+BOOL WINAPI PASCAL IcmpCloseHandle(HANDLE IcmpHandle); /* FALSE on error */
+DWORD WINAPI PASCAL IcmpSendEcho(
+ HANDLE IcmpHandle, /* handle returned from IcmpCreateFile() */
+ u_long DestAddress, /* destination IP address (in network order) */
+ LPVOID RequestData, /* pointer to buffer to send */
+ WORD RequestSize, /* length of data in buffer */
+ LPIPINFO RequestOptns, /* see Note 2 below */
+ LPVOID ReplyBuffer, /* see Note 1 below */
+ DWORD ReplySize, /* length of reply (must allow at least 1 reply) */
+ DWORD Timeout /* time in milliseconds to wait for reply */
+);
+
diff --git a/shared-data/browse-icon.ico b/shared-data/browse-icon.ico
new file mode 100644
index 0000000..d2d1b3c
--- a/dev/null
+++ b/shared-data/browse-icon.ico
Binary files differ
diff --git a/shared-data/install-icon.ico b/shared-data/install-icon.ico
new file mode 100644
index 0000000..23e86a6
--- a/dev/null
+++ b/shared-data/install-icon.ico
Binary files differ
diff --git a/shared-data/klever-background.bmp b/shared-data/klever-background.bmp
new file mode 100644
index 0000000..e4d87ec
--- a/dev/null
+++ b/shared-data/klever-background.bmp
Binary files differ
diff --git a/shared-data/play-icon.ico b/shared-data/play-icon.ico
new file mode 100644
index 0000000..3d2a11e
--- a/dev/null
+++ b/shared-data/play-icon.ico
Binary files differ
diff --git a/stdafx.cpp b/stdafx.cpp
new file mode 100644
index 0000000..45b4220
--- a/dev/null
+++ b/stdafx.cpp
@@ -0,0 +1,6 @@
+// stdafx.cpp : source file that includes just the standard includes
+// PumpKIN.pch will be the pre-compiled header
+// stdafx.obj will contain the pre-compiled type information
+
+#include "stdafx.h"
+
diff --git a/stdafx.h b/stdafx.h
new file mode 100644
index 0000000..b2d650d
--- a/dev/null
+++ b/stdafx.h
@@ -0,0 +1,27 @@
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
+
+#include <afxwin.h> // MFC core and standard components
+#include <afxext.h> // MFC extensions
+#ifndef _AFX_NO_AFXCMN_SUPPORT
+#include <afxcmn.h> // MFC support for Windows 95 Common Controls
+#endif // _AFX_NO_AFXCMN_SUPPORT
+
+#include <afxtempl.h>
+
+#include <afxsock.h> // MFC socket extensions
+#include <MMSystem.h>
+// CG: The following line was added by the Windows Multimedia component.
+#pragma comment(lib, "winmm.lib")
+
+enum {
+ WM_RESOLVED = WM_USER,
+ WM_TRAYICON
+};
+
+#include "shared-code/kHelpers.h"
+#include "shared-code/BellsNWhistles.h" \ No newline at end of file