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) (unidiff)
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) (ignore 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 @@
1
2# /
3/Debug
4/Release
5/Releast
6/debug
7/release
8/releast
9/DEBUG
10/RELEASE
11/RELEAST
12/*.mdp
13/*.ncb
14/*.aps
15/redist
16
17# /help/
18/help/PUMPKIN.HLP
19/help/pumpkin.LOG
20/help/pumpkin.hm
21/help/pumpkin.GID
22/help/PumpKIN.FTS
23
24# /install/
25/install/debug
26/install/pure
27/install/canned
28/install/static
29/install/Debug
30/install/Pure
31/install/Canned
32/install/Static
33/install/DEBUG
34/install/PURE
35/install/CANNED
36/install/STATIC
37/install/*.aps
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..98e8827
--- a/dev/null
+++ b/COPYING
@@ -0,0 +1,19 @@
1Copyright (c) 1997, 1998, 2002 Klever Group (http://www.klever.net/)
2
3Permission is hereby granted, free of charge, to any person obtaining a copy of
4this software and associated documentation files (the "Software"), to deal in
5the Software without restriction, including without limitation the rights to
6use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7of the Software, and to permit persons to whom the Software is furnished to do
8so, subject to the following conditions:
9
10The above copyright notice and this permission notice shall be included in all
11copies or substantial portions of the Software.
12
13THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19SOFTWARE.
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 @@
1// ConfirmRRQDlg.cpp : implementation file
2//
3
4#include "stdafx.h"
5#include "PumpKIN.h"
6#include "ConfirmRRQDlg.h"
7#include "PumpKINDlg.h"
8
9#ifdef _DEBUG
10#define new DEBUG_NEW
11#undef THIS_FILE
12static char THIS_FILE[] = __FILE__;
13#endif
14
15/////////////////////////////////////////////////////////////////////////////
16// CConfirmRRQDlg dialog
17
18
19CConfirmRRQDlg::CConfirmRRQDlg(CWnd* pParent /*=NULL*/)
20 : CDialog(CConfirmRRQDlg::IDD, pParent)
21{
22 m_Daddy=NULL;
23 //{{AFX_DATA_INIT(CConfirmRRQDlg)
24 m_File = _T("");
25 m_Host = _T("");
26 //}}AFX_DATA_INIT
27}
28
29
30void CConfirmRRQDlg::DoDataExchange(CDataExchange* pDX)
31{
32 CDialog::DoDataExchange(pDX);
33 //{{AFX_DATA_MAP(CConfirmRRQDlg)
34 DDX_Text(pDX, IDC_FILE, m_File);
35 DDX_Text(pDX, IDC_HOST, m_Host);
36 //}}AFX_DATA_MAP
37}
38
39
40BEGIN_MESSAGE_MAP(CConfirmRRQDlg, CDialog)
41 //{{AFX_MSG_MAP(CConfirmRRQDlg)
42 ON_WM_TIMER()
43 //}}AFX_MSG_MAP
44END_MESSAGE_MAP()
45
46/////////////////////////////////////////////////////////////////////////////
47// CConfirmRRQDlg message handlers
48
49BOOL CConfirmRRQDlg::OnInitDialog()
50{
51 CDialog::OnInitDialog();
52
53 m_Daddy->m_Daddy->m_bnw.StartSound(m_Daddy->m_Daddy->m_bnwRequest);
54 if(m_Daddy->m_Daddy->m_PromptTimeOut)
55 SetTimer(1,m_Daddy->m_Daddy->m_PromptTimeOut*1000,NULL);
56 SetWindowPos(&CWnd::wndTopMost,0,0,0,0,SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE);
57
58 return TRUE; // return TRUE unless you set the focus to a control
59 // EXCEPTION: OCX Property Pages should return FALSE
60}
61
62void CConfirmRRQDlg::OnTimer(UINT nIDEvent)
63{
64 if(nIDEvent==1)
65 EndDialog(IDCANCEL);
66 CDialog::OnTimer(nIDEvent);
67}
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 @@
1// ConfirmRRQDlg.h : header file
2//
3
4/////////////////////////////////////////////////////////////////////////////
5// CConfirmRRQDlg dialog
6
7class CRRQSocket;
8class CConfirmRRQDlg : public CDialog
9{
10// Construction
11public:
12 CRRQSocket * m_Daddy;
13 CConfirmRRQDlg(CWnd* pParent = NULL); // standard constructor
14
15// Dialog Data
16 //{{AFX_DATA(CConfirmRRQDlg)
17 enum { IDD = IDD_CONFIRM_RRQ };
18 CStringm_File;
19 CStringm_Host;
20 //}}AFX_DATA
21
22
23// Overrides
24 // ClassWizard generated virtual function overrides
25 //{{AFX_VIRTUAL(CConfirmRRQDlg)
26 protected:
27 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
28 //}}AFX_VIRTUAL
29
30// Implementation
31protected:
32
33 // Generated message map functions
34 //{{AFX_MSG(CConfirmRRQDlg)
35 virtual BOOL OnInitDialog();
36 afx_msg void OnTimer(UINT nIDEvent);
37 //}}AFX_MSG
38 DECLARE_MESSAGE_MAP()
39};
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 @@
1// ConfirmWRQDlg.cpp : implementation file
2//
3
4#include "stdafx.h"
5#include "PumpKIN.h"
6#include "ConfirmWRQDlg.h"
7
8#include "PumpKINDlg.h"
9
10#ifdef _DEBUG
11#define new DEBUG_NEW
12#undef THIS_FILE
13static char THIS_FILE[] = __FILE__;
14#endif
15
16/////////////////////////////////////////////////////////////////////////////
17// CConfirmWRQDlg dialog
18
19
20CConfirmWRQDlg::CConfirmWRQDlg(CWnd* pParent /*=NULL*/)
21 : CDialog(CConfirmWRQDlg::IDD, pParent)
22{
23 //{{AFX_DATA_INIT(CConfirmWRQDlg)
24 m_File = _T("");
25 m_Host = _T("");
26 //}}AFX_DATA_INIT
27}
28
29
30void CConfirmWRQDlg::DoDataExchange(CDataExchange* pDX)
31{
32 CDialog::DoDataExchange(pDX);
33 //{{AFX_DATA_MAP(CConfirmWRQDlg)
34 DDX_Control(pDX, IDC_RESUME, m_ResumeCtl);
35 DDX_Control(pDX, IDOK, m_OkCtl);
36 DDX_Control(pDX, IDC_RENAME, m_RenameCtl);
37 DDX_Text(pDX, IDC_FILE, m_File);
38 DDX_Text(pDX, IDC_HOST, m_Host);
39 //}}AFX_DATA_MAP
40}
41
42
43BEGIN_MESSAGE_MAP(CConfirmWRQDlg, CDialog)
44 //{{AFX_MSG_MAP(CConfirmWRQDlg)
45 ON_BN_CLICKED(IDC_RENAME, OnRename)
46 ON_WM_TIMER()
47 ON_BN_CLICKED(IDC_RESUME, OnResume)
48 //}}AFX_MSG_MAP
49END_MESSAGE_MAP()
50
51/////////////////////////////////////////////////////////////////////////////
52// CConfirmWRQDlg message handlers
53
54void CConfirmWRQDlg::OnRename()
55{
56 EndDialog(IDC_RENAME);
57}
58
59BOOL CConfirmWRQDlg::OnInitDialog()
60{
61 CDialog::OnInitDialog();
62
63 m_Daddy->m_Daddy->m_bnw.StartSound(m_Daddy->m_Daddy->m_bnwRequest);
64 if(m_Daddy->m_Daddy->m_PromptTimeOut)
65 SetTimer(1,m_Daddy->m_Daddy->m_PromptTimeOut*1000,NULL);
66 SetWindowPos(&CWnd::wndTopMost,0,0,0,0,SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE);
67 m_ResumeCtl.EnableWindow(m_Daddy->m_bResume);
68 if(m_Daddy->m_Rename){
69 m_OkCtl.SetButtonStyle(m_OkCtl.GetButtonStyle()&~BS_DEFPUSHBUTTON);
70 m_RenameCtl.SetButtonStyle(m_RenameCtl.GetButtonStyle()|BS_DEFPUSHBUTTON);
71 m_RenameCtl.SetFocus();
72 return FALSE;
73 }
74
75 return TRUE; // return TRUE unless you set the focus to a control
76 // EXCEPTION: OCX Property Pages should return FALSE
77}
78
79void CConfirmWRQDlg::OnTimer(UINT nIDEvent)
80{
81 if(nIDEvent==1)
82 EndDialog(IDCANCEL);
83 CDialog::OnTimer(nIDEvent);
84}
85
86void CConfirmWRQDlg::OnResume()
87{
88 EndDialog(IDC_RESUME);
89}
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 @@
1// ConfirmWRQDlg.h : header file
2//
3
4/////////////////////////////////////////////////////////////////////////////
5// CConfirmWRQDlg dialog
6
7class CWRQSocket;
8class CConfirmWRQDlg : public CDialog
9{
10// Construction
11public:
12 CWRQSocket *m_Daddy;
13 CConfirmWRQDlg(CWnd* pParent = NULL); // standard constructor
14
15// Dialog Data
16 //{{AFX_DATA(CConfirmWRQDlg)
17 enum { IDD = IDD_CONFIRM_WRQ };
18 CButtonm_ResumeCtl;
19 CButtonm_OkCtl;
20 CButtonm_RenameCtl;
21 CStringm_File;
22 CStringm_Host;
23 //}}AFX_DATA
24
25
26// Overrides
27 // ClassWizard generated virtual function overrides
28 //{{AFX_VIRTUAL(CConfirmWRQDlg)
29 protected:
30 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
31 //}}AFX_VIRTUAL
32
33// Implementation
34protected:
35
36 // Generated message map functions
37 //{{AFX_MSG(CConfirmWRQDlg)
38 afx_msg void OnRename();
39 virtual BOOL OnInitDialog();
40 afx_msg void OnTimer(UINT nIDEvent);
41 afx_msg void OnResume();
42 //}}AFX_MSG
43 DECLARE_MESSAGE_MAP()
44};
diff --git a/KTAGS b/KTAGS
new file mode 100644
index 0000000..36d22e5
--- a/dev/null
+++ b/KTAGS
@@ -0,0 +1,12 @@
1 about-date pumpkin.rc /LTEXT\s\+"Copyright /;"kind:d
2 about-version pumpkin.rc /LTEXT\s\+"PumpKIN, Version /;"kind:v
3 help-license-date ./help/pumpkin.xml /<license\s/;"kind:d
4 help-news ./help/pumpkin.xml/<newsfor\s/
5 install-version ./install/install.cpp /^#define\s\+KINAME\s\+"/;"kind:v
6 install-vsinfo-date install/install.rc /^\s\+VALUE\s\+"LegalCopyright",/;"kind:d
7 install-vsinfo-numeric-version install/install.rc /^\s\+FILEVERSION\s\+/;"kind:v
8 install-vsinfo-string-version install/install.rc /^\s\+VALUE\s\+"FileVersion",/;"kind:v
9 license-date COPYING :1;"kind:d
10 vsinfo-date pumpkin.rc /VALUE\s\+"LegalCopyright",/;"kind:d
11 vsinfo-numeric-version pumpkin.rc /^\s\+FILEVERSION\s\+/;"kind:v
12 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 @@
1// PropsNetwork.cpp : implementation file
2//
3
4#include "stdafx.h"
5#include "PumpKIN.h"
6#include "PropsNetwork.h"
7
8#ifdef _DEBUG
9#define new DEBUG_NEW
10#undef THIS_FILE
11static char THIS_FILE[] = __FILE__;
12#endif
13
14/////////////////////////////////////////////////////////////////////////////
15// CPropsNetwork property page
16
17IMPLEMENT_DYNCREATE(CPropsNetwork, CPropertyPage)
18
19CPropsNetwork::CPropsNetwork() : CPropertyPage(CPropsNetwork::IDD)
20{
21 //{{AFX_DATA_INIT(CPropsNetwork)
22 m_ListenPort = 0;
23 m_SpeakPort = 0;
24 m_TimeOut = 0;
25 m_BlockSize = 0;
26 //}}AFX_DATA_INIT
27}
28
29CPropsNetwork::~CPropsNetwork()
30{
31}
32
33void CPropsNetwork::DoDataExchange(CDataExchange* pDX)
34{
35 CPropertyPage::DoDataExchange(pDX);
36 //{{AFX_DATA_MAP(CPropsNetwork)
37 DDX_Control(pDX, IDC_BSIZESPIN, m_BSizeSpinCtl);
38 DDX_Control(pDX, IDC_TIMESPIN, m_TimeSpinCtl);
39 DDX_Control(pDX, IDC_SPEAKSPIN, m_SpeakSpinCtl);
40 DDX_Control(pDX, IDC_LISTENSPIN, m_ListenSpinCtl);
41 DDX_Text(pDX, IDC_LISTENPORT, m_ListenPort);
42 DDX_Text(pDX, IDC_SPEAKPORT, m_SpeakPort);
43 DDX_Text(pDX, IDC_TIMEOUT, m_TimeOut);
44 DDV_MinMaxUInt(pDX, m_TimeOut, 5, 60);
45 DDX_Text(pDX, IDC_BLOCKSIZE, m_BlockSize);
46 //}}AFX_DATA_MAP
47}
48
49
50BEGIN_MESSAGE_MAP(CPropsNetwork, CPropertyPage)
51 //{{AFX_MSG_MAP(CPropsNetwork)
52 //}}AFX_MSG_MAP
53END_MESSAGE_MAP()
54
55/////////////////////////////////////////////////////////////////////////////
56// CPropsNetwork message handlers
57
58BOOL CPropsNetwork::OnInitDialog()
59{
60 CPropertyPage::OnInitDialog();
61
62 m_ListenSpinCtl.SetRange(0,32767);
63 m_SpeakSpinCtl.SetRange(0,32767);
64 m_TimeSpinCtl.SetRange(5,60);
65 m_BSizeSpinCtl.SetRange(512,16384);
66UDACCEL uda = {0,512};
67 m_BSizeSpinCtl.SetAccel(1,&uda);
68
69 return TRUE; // return TRUE unless you set the focus to a control
70 // EXCEPTION: OCX Property Pages should return FALSE
71}
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 @@
1// PropsNetwork.h : header file
2//
3
4/////////////////////////////////////////////////////////////////////////////
5// CPropsNetwork dialog
6
7class CPropsNetwork : public CPropertyPage
8{
9 DECLARE_DYNCREATE(CPropsNetwork)
10
11// Construction
12public:
13 CPropsNetwork();
14 ~CPropsNetwork();
15
16// Dialog Data
17 //{{AFX_DATA(CPropsNetwork)
18 enum { IDD = IDD_PROPS_NETWORK };
19 CSpinButtonCtrlm_BSizeSpinCtl;
20 CSpinButtonCtrlm_TimeSpinCtl;
21 CSpinButtonCtrlm_SpeakSpinCtl;
22 CSpinButtonCtrlm_ListenSpinCtl;
23 UINTm_ListenPort;
24 UINTm_SpeakPort;
25 UINTm_TimeOut;
26 UINTm_BlockSize;
27 //}}AFX_DATA
28
29
30// Overrides
31 // ClassWizard generate virtual function overrides
32 //{{AFX_VIRTUAL(CPropsNetwork)
33 protected:
34 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
35 //}}AFX_VIRTUAL
36
37// Implementation
38protected:
39 // Generated message map functions
40 //{{AFX_MSG(CPropsNetwork)
41 virtual BOOL OnInitDialog();
42 //}}AFX_MSG
43 DECLARE_MESSAGE_MAP()
44
45};
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 @@
1// PropsServer.cpp : implementation file
2//
3
4#include "stdafx.h"
5#include "PumpKIN.h"
6#include "PropsServer.h"
7
8#ifdef _DEBUG
9#define new DEBUG_NEW
10#undef THIS_FILE
11static char THIS_FILE[] = __FILE__;
12#endif
13
14/////////////////////////////////////////////////////////////////////////////
15// CPropsServer property page
16
17IMPLEMENT_DYNCREATE(CPropsServer, CPropertyPage)
18
19CPropsServer::CPropsServer() : CPropertyPage(CPropsServer::IDD)
20{
21 //{{AFX_DATA_INIT(CPropsServer)
22 m_RRQMode = -1;
23 m_TFTPRoot = _T("");
24 m_TFTPSubdirs = FALSE;
25 m_WRQMode = -1;
26 //}}AFX_DATA_INIT
27}
28
29CPropsServer::~CPropsServer()
30{
31}
32
33void CPropsServer::DoDataExchange(CDataExchange* pDX)
34{
35 CPropertyPage::DoDataExchange(pDX);
36 //{{AFX_DATA_MAP(CPropsServer)
37 DDX_Control(pDX, IDC_BROWSE, m_BrowseCtl);
38 DDX_Control(pDX, IDC_PROMPTTIMEOUT, m_PromptTimeoutCtl);
39 DDX_Radio(pDX, IDC_RRQ_GIVEALL, m_RRQMode);
40 DDX_Text(pDX, IDC_TFTPROOT, m_TFTPRoot);
41 DDX_Check(pDX, IDC_TFTPSUBDIRS, m_TFTPSubdirs);
42 DDX_Radio(pDX, IDC_WRQ_TAKEALL, m_WRQMode);
43 //}}AFX_DATA_MAP
44 if(pDX->m_bSaveAndValidate)
45 m_PromptTimeOut=m_PromptTimeoutCtl.GetPos();
46 else
47 m_PromptTimeoutCtl.SetPos(m_PromptTimeOut);
48}
49
50
51BEGIN_MESSAGE_MAP(CPropsServer, CPropertyPage)
52 //{{AFX_MSG_MAP(CPropsServer)
53 ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
54 //}}AFX_MSG_MAP
55END_MESSAGE_MAP()
56
57/////////////////////////////////////////////////////////////////////////////
58// CPropsServer message handlers
59
60BOOL CPropsServer::OnInitDialog()
61{
62 CPropertyPage::OnInitDialog();
63
64 m_PromptTimeoutCtl.SetRange(5,60);
65 m_BrowseCtl.SetIcon(AfxGetApp()->LoadIcon(IDI_BROWSE));
66
67 return TRUE; // return TRUE unless you set the focus to a control
68 // EXCEPTION: OCX Property Pages should return FALSE
69}
70
71void CPropsServer::OnBrowse()
72{
73CString nr = m_TFTPRoot;
74 if(Klever::BrowseForFolder(nr,IDS_SELECT_TFTPROOT,this)){
75 UpdateData(TRUE);
76 m_TFTPRoot=nr;
77 UpdateData(FALSE);
78 }
79}
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 @@
1// PropsServer.h : header file
2//
3
4/////////////////////////////////////////////////////////////////////////////
5// CPropsServer dialog
6
7class CPropsServer : public CPropertyPage
8{
9 DECLARE_DYNCREATE(CPropsServer)
10
11// Construction
12public:
13 UINT m_PromptTimeOut;
14 CPropsServer();
15 ~CPropsServer();
16
17// Dialog Data
18 //{{AFX_DATA(CPropsServer)
19 enum { IDD = IDD_PROPS_SERVER };
20 CButtonm_BrowseCtl;
21 CSliderCtrlm_PromptTimeoutCtl;
22 int m_RRQMode;
23 CStringm_TFTPRoot;
24 BOOLm_TFTPSubdirs;
25 int m_WRQMode;
26 //}}AFX_DATA
27
28
29// Overrides
30 // ClassWizard generate virtual function overrides
31 //{{AFX_VIRTUAL(CPropsServer)
32 protected:
33 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
34 //}}AFX_VIRTUAL
35
36// Implementation
37protected:
38 // Generated message map functions
39 //{{AFX_MSG(CPropsServer)
40 virtual BOOL OnInitDialog();
41 afx_msg void OnBrowse();
42 //}}AFX_MSG
43 DECLARE_MESSAGE_MAP()
44
45};
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 @@
1// PropsSounds.cpp : implementation file
2//
3
4#include "stdafx.h"
5#include "PumpKIN.h"
6#include "PropsSounds.h"
7#include "PumpKINDlg.h"
8
9#ifdef _DEBUG
10#define new DEBUG_NEW
11#undef THIS_FILE
12static char THIS_FILE[] = __FILE__;
13#endif
14
15/////////////////////////////////////////////////////////////////////////////
16// CPropsSounds property page
17
18IMPLEMENT_DYNCREATE(CPropsSounds, CPropertyPage)
19
20CPropsSounds::CPropsSounds() : CPropertyPage(CPropsSounds::IDD)
21{
22 //{{AFX_DATA_INIT(CPropsSounds)
23 m_Abort = _T("");
24 m_Success = _T("");
25 m_Request = _T("");
26 //}}AFX_DATA_INIT
27}
28
29CPropsSounds::~CPropsSounds()
30{
31}
32
33void CPropsSounds::DoDataExchange(CDataExchange* pDX)
34{
35 CPropertyPage::DoDataExchange(pDX);
36 //{{AFX_DATA_MAP(CPropsSounds)
37 DDX_Control(pDX, IDC_RING_PLAY, m_RequestPlayCtl);
38 DDX_Control(pDX, IDC_RING_BROWSE, m_RequestBrowseCtl);
39 DDX_Control(pDX, IDC_RING, m_RequestCtl);
40 DDX_Control(pDX, IDC_FINISHED_PLAY, m_SuccessPlayCtl);
41 DDX_Control(pDX, IDC_FINISHED_BROWSE, m_SuccessBrowseCtl);
42 DDX_Control(pDX, IDC_FINISHED, m_SuccessCtl);
43 DDX_Control(pDX, IDC_ABORTED_PLAY, m_AbortPlayCtl);
44 DDX_Control(pDX, IDC_ABORTED_BROWSE, m_AbortBrowseCtl);
45 DDX_Control(pDX, IDC_ABORTED, m_AbortCtl);
46 DDX_CBString(pDX, IDC_ABORTED, m_Abort);
47 DDX_CBString(pDX, IDC_FINISHED, m_Success);
48 DDX_CBString(pDX, IDC_RING, m_Request);
49 //}}AFX_DATA_MAP
50}
51
52
53BEGIN_MESSAGE_MAP(CPropsSounds, CPropertyPage)
54 //{{AFX_MSG_MAP(CPropsSounds)
55 ON_BN_CLICKED(IDC_ABORTED_BROWSE, OnAbortedBrowse)
56 ON_BN_CLICKED(IDC_FINISHED_BROWSE, OnFinishedBrowse)
57 ON_BN_CLICKED(IDC_RING_BROWSE, OnRingBrowse)
58 ON_BN_CLICKED(IDC_ABORTED_PLAY, OnAbortedPlay)
59 ON_BN_CLICKED(IDC_FINISHED_PLAY, OnFinishedPlay)
60 ON_BN_CLICKED(IDC_RING_PLAY, OnRingPlay)
61 //}}AFX_MSG_MAP
62END_MESSAGE_MAP()
63
64/////////////////////////////////////////////////////////////////////////////
65// CPropsSounds message handlers
66
67BOOL CPropsSounds::OnInitDialog()
68{
69 CPropertyPage::OnInitDialog();
70
71HICON hP = AfxGetApp()->LoadIcon(IDI_PLAY);
72HICON hB = AfxGetApp()->LoadIcon(IDI_BROWSE);
73 m_RequestPlayCtl.SetIcon(hP);
74 m_SuccessPlayCtl.SetIcon(hP);
75 m_AbortPlayCtl.SetIcon(hP);
76 m_RequestBrowseCtl.SetIcon(hB);
77 m_SuccessBrowseCtl.SetIcon(hB);
78 m_AbortBrowseCtl.SetIcon(hB);
79
80CPumpKINDlg* pd = (CPumpKINDlg*)AfxGetMainWnd();
81 //ASSERT_KINDOF(CPumpKINDlg,pd);
82 m_bnw=&pd->m_bnw;
83
84 m_bnw->FillInCombo(&m_RequestCtl);
85 m_bnw->FillInCombo(&m_SuccessCtl);
86 m_bnw->FillInCombo(&m_AbortCtl);
87
88 return TRUE; // return TRUE unless you set the focus to a control
89 // EXCEPTION: OCX Property Pages should return FALSE
90}
91
92void CPropsSounds::OnAbortedBrowse()
93{
94 Browse(m_AbortCtl);
95}
96void CPropsSounds::OnFinishedBrowse()
97{
98 Browse(m_SuccessCtl);
99}
100void CPropsSounds::OnRingBrowse()
101{
102 Browse(m_RequestCtl);
103}
104
105void CPropsSounds::OnAbortedPlay()
106{
107 Play(m_AbortCtl);
108}
109
110void CPropsSounds::OnFinishedPlay()
111{
112 Play(m_SuccessCtl);
113}
114
115void CPropsSounds::OnRingPlay()
116{
117 Play(m_RequestCtl);
118}
119
120void CPropsSounds::Browse(CComboBox& ctl)
121{
122CString f;
123 ctl.GetWindowText(f);
124CString filter;
125 filter.LoadString(IDS_FILTER_WAV);
126CFileDialog fd(TRUE,NULL,(LPCTSTR)f,
127 OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY
128 |OFN_LONGNAMES|OFN_NOCHANGEDIR|OFN_PATHMUSTEXIST,
129 filter,this);
130CString title;
131 title.LoadString(IDS_TITLE_WAV);
132 fd.m_ofn.lpstrTitle=(LPCTSTR)title;
133 if(fd.DoModal()==IDOK)
134 ctl.SetWindowText(fd.GetPathName());
135}
136
137void CPropsSounds::Play(CComboBox& ctl)
138{
139CString s;
140 ctl.GetWindowText(s);
141CBellsNWhistles::Whistling w = m_bnw->StartSound(s);
142 if(w){
143 Sleep(5000);
144 m_bnw->StopSound(w);
145 }
146}
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 @@
1// PropsSounds.h : header file
2//
3
4/////////////////////////////////////////////////////////////////////////////
5// CPropsSounds dialog
6
7class CPropsSounds : public CPropertyPage
8{
9 DECLARE_DYNCREATE(CPropsSounds)
10
11// Construction
12public:
13 void Play(CComboBox& ctl);
14 void Browse(CComboBox& ctl);
15 CBellsNWhistles* m_bnw;
16 CPropsSounds();
17 ~CPropsSounds();
18
19// Dialog Data
20 //{{AFX_DATA(CPropsSounds)
21 enum { IDD = IDD_PROPS_SOUNDS };
22 CButtonm_RequestPlayCtl;
23 CButtonm_RequestBrowseCtl;
24 CComboBoxm_RequestCtl;
25 CButtonm_SuccessPlayCtl;
26 CButtonm_SuccessBrowseCtl;
27 CComboBoxm_SuccessCtl;
28 CButtonm_AbortPlayCtl;
29 CButtonm_AbortBrowseCtl;
30 CComboBoxm_AbortCtl;
31 CStringm_Abort;
32 CStringm_Success;
33 CStringm_Request;
34 //}}AFX_DATA
35
36
37// Overrides
38 // ClassWizard generate virtual function overrides
39 //{{AFX_VIRTUAL(CPropsSounds)
40 protected:
41 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
42 //}}AFX_VIRTUAL
43
44// Implementation
45protected:
46 // Generated message map functions
47 //{{AFX_MSG(CPropsSounds)
48 virtual BOOL OnInitDialog();
49 afx_msg void OnAbortedBrowse();
50 afx_msg void OnFinishedBrowse();
51 afx_msg void OnRingBrowse();
52 afx_msg void OnAbortedPlay();
53 afx_msg void OnFinishedPlay();
54 afx_msg void OnRingPlay();
55 //}}AFX_MSG
56 DECLARE_MESSAGE_MAP()
57
58};
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 @@
1// PumpKINDlg.cpp : implementation file
2//
3
4#include "stdafx.h"
5#include "PumpKIN.h"
6#include "PumpKINDlg.h"
7
8#include "PropsServer.h"
9#include "PropsNetwork.h"
10#include "PropsSounds.h"
11#include "ConfirmRRQDlg.h"
12#include "ConfirmWRQDlg.h"
13#include "RequestDlg.h"
14#include "Resolver.h"
15#include "Retrier.h"
16#include "Trayer.h"
17
18#include <io.h>
19
20#ifdef _DEBUG
21#define new DEBUG_NEW
22#undef THIS_FILE
23static char THIS_FILE[] = __FILE__;
24#endif
25
26IMPLEMENT_DYNAMIC(CXferSocket, CAsyncSocket)
27IMPLEMENT_DYNAMIC(CWRQSocket, CXferSocket)
28IMPLEMENT_DYNAMIC(CRRQSocket, CXferSocket)
29
30/////////////////////////////////////////////////////////////////////////////
31// CAboutDlg dialog used for App About
32
33class CAboutDlg : public CDialog
34{
35public:
36 CAboutDlg();
37
38// Dialog Data
39 //{{AFX_DATA(CAboutDlg)
40 enum { IDD = IDD_ABOUTBOX };
41 //}}AFX_DATA
42
43 // ClassWizard generated virtual function overrides
44 //{{AFX_VIRTUAL(CAboutDlg)
45 protected:
46 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
47 //}}AFX_VIRTUAL
48
49// Implementation
50protected:
51 //{{AFX_MSG(CAboutDlg)
52 afx_msg void OnKlevernet();
53 //}}AFX_MSG
54 DECLARE_MESSAGE_MAP()
55};
56
57CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
58{
59 //{{AFX_DATA_INIT(CAboutDlg)
60 //}}AFX_DATA_INIT
61}
62
63void CAboutDlg::DoDataExchange(CDataExchange* pDX)
64{
65 CDialog::DoDataExchange(pDX);
66 //{{AFX_DATA_MAP(CAboutDlg)
67 //}}AFX_DATA_MAP
68}
69
70BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
71 //{{AFX_MSG_MAP(CAboutDlg)
72 ON_BN_CLICKED(IDC_KLEVERNET, OnKlevernet)
73 //}}AFX_MSG_MAP
74END_MESSAGE_MAP()
75
76/////////////////////////////////////////////////////////////////////////////
77// CPumpKINDlg dialog
78
79CPumpKINDlg::CPumpKINDlg(CWnd* pParent /*=NULL*/)
80 : CDialog(CPumpKINDlg::IDD, pParent)
81{
82 m_ListenPort = 69;
83 m_bTFTPSubdirs = TRUE;
84 m_RRQMode = rrqAlwaysConfirm;
85 m_WRQMode = wrqAlwaysConfirm;
86 m_TFTPTimeOut = CTimeSpan(0,0,0,30);
87 m_RetryTimeOut = CTimeSpan(0,0,0,10);
88 m_LogLength = 100;
89 m_SpeakPort = 69;
90 m_PromptTimeOut=30;
91 m_bShown=TRUE;
92 m_bExiting=FALSE;
93 m_BlockSize=1024;
94 m_bnw.AssignSound("(bang)",IDR_WAVE_RING,CBellsNWhistles::CBang::bangResource);
95 m_bnw.AssignSound("(done)",IDR_WAVE_FINISHED,CBellsNWhistles::CBang::bangResource);
96 m_bnw.AssignSound("(oops)",IDR_WAVE_ABORTED,CBellsNWhistles::CBang::bangResource);
97 m_bnw.AssignSound("(none)",(int)0,CBellsNWhistles::CBang::bangNone);
98 m_bnwRequest="(bang)"; m_bnwSuccess="(done)";
99 m_bnwAbort="(oops)";
100 //{{AFX_DATA_INIT(CPumpKINDlg)
101 //}}AFX_DATA_INIT
102 // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
103 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
104 m_bmpBack.LoadBitmap(IDB_BACKGROUND);
105 m_bmpBack.GetBitmap(&m_bitmapBack);
106 m_Retrier = new CRetrier(this);
107 ASSERT(m_Retrier);
108 m_Trayer = new CTrayer(this);
109 ASSERT(m_Trayer);
110 LoadSettings();
111}
112
113void CPumpKINDlg::DoDataExchange(CDataExchange* pDX)
114{
115 CDialog::DoDataExchange(pDX);
116 //{{AFX_DATA_MAP(CPumpKINDlg)
117 DDX_Control(pDX, IDC_ABORT, m_AbortCtl);
118 DDX_Control(pDX, IDC_OPTIONS, m_OptionsCtl);
119 DDX_Control(pDX, IDC_LOG, m_Log);
120 DDX_Control(pDX, IDC_CONNECTIONS, m_List);
121 //}}AFX_DATA_MAP
122}
123
124BEGIN_MESSAGE_MAP(CPumpKINDlg, CDialog)
125 //{{AFX_MSG_MAP(CPumpKINDlg)
126 ON_WM_SYSCOMMAND()
127 ON_WM_DESTROY()
128 ON_WM_PAINT()
129 ON_WM_QUERYDRAGICON()
130 ON_WM_CREATE()
131 ON_BN_CLICKED(IDC_OPTIONS, OnOptions)
132 ON_WM_TIMER()
133 ON_BN_CLICKED(IDC_EXIT, OnExit)
134 ON_BN_CLICKED(IDC_PUT, OnPut)
135 ON_BN_CLICKED(IDC_GET, OnGet)
136 ON_NOTIFY(LVN_DELETEALLITEMS, IDC_CONNECTIONS, OnDeleteallitemsConnections)
137 ON_NOTIFY(LVN_DELETEITEM, IDC_CONNECTIONS, OnDeleteitemConnections)
138 ON_NOTIFY(LVN_INSERTITEM, IDC_CONNECTIONS, OnInsertitemConnections)
139 ON_NOTIFY(LVN_ITEMCHANGED, IDC_CONNECTIONS, OnItemchangedConnections)
140 ON_BN_CLICKED(IDC_ABORT, OnAbort)
141 ON_WM_CLOSE()
142 ON_COMMAND(ID_TRAY_SHOWPUMPKINWINDOW, OnTrayShowpumpkinwindow)
143 ON_COMMAND(ID_TRAY_EXIT, OnTrayExit)
144 ON_COMMAND(ID_TRAY_ABOUTPUMPKIN, OnTrayAboutpumpkin)
145 ON_COMMAND(ID_TRAY_FETCHFILE, OnTrayFetchfile)
146 ON_COMMAND(ID_TRAY_HELP, OnTrayHelp)
147 ON_COMMAND(ID_TRAY_OPTIONS, OnTrayOptions)
148 ON_COMMAND(ID_TRAY_SENDFILE, OnTraySendfile)
149 ON_WM_WINDOWPOSCHANGING()
150 ON_LBN_SELCHANGE(IDC_LOG, OnSelchangeLog)
151 ON_COMMAND(ID_TRAY_OPENFILESFOLDER, OnTrayOpenfilesfolder)
152 ON_WM_DROPFILES()
153 ON_BN_CLICKED(ID_HELP, OnHelp)
154 //}}AFX_MSG_MAP
155END_MESSAGE_MAP()
156
157/////////////////////////////////////////////////////////////////////////////
158// CPumpKINDlg message handlers
159
160BOOL CPumpKINDlg::OnInitDialog()
161{
162 CDialog::OnInitDialog();
163
164 // Add "About..." menu item to system menu.
165
166 // IDM_ABOUTBOX must be in the system command range.
167 ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
168 ASSERT(IDM_ABOUTBOX < 0xF000);
169
170 CMenu* pSysMenu = GetSystemMenu(FALSE);
171 CString strAboutMenu;
172 strAboutMenu.LoadString(IDS_ABOUTBOX);
173 if (!strAboutMenu.IsEmpty())
174 {
175 pSysMenu->AppendMenu(MF_SEPARATOR);
176 pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
177 }
178
179 // Set the icon for this dialog. The framework does this automatically
180 // when the application's main window is not a dialog
181 SetIcon(m_hIcon, TRUE); // Set big icon
182 SetIcon(m_hIcon, FALSE); // Set small icon
183
184 VERIFY(m_Retrier->Create(NULL,"PumpKIN-Retrier",WS_CHILD,CRect(0,0,0,0),this,0));
185
186
187 m_Images.Create(16,16,TRUE,2,1);
188 m_iRRQ = m_Images.Add(AfxGetApp()->LoadIcon(IDI_RRQ));
189 m_iWRQ = m_Images.Add(AfxGetApp()->LoadIcon(IDI_WRQ));
190 ASSERT(m_iRRQ>=0);
191 ASSERT(m_iWRQ>=0);
192 m_List.SetImageList(&m_Images,LVSIL_NORMAL);
193 m_List.SetImageList(&m_Images,LVSIL_SMALL);
194 m_List.SetImageList(&m_Images,LVSIL_STATE);
195 m_List.SetTextColor(RGB(255,255,0));// Yellow
196 m_List.SetTextBkColor(RGB(12,167,0));// Green
197 m_List.SetBkColor(RGB(12,167,0));// Green
198CRect listrc;
199 m_List.GetClientRect(&listrc);
200 m_List.InsertColumn(0,"File",LVCFMT_LEFT,listrc.Width()-((listrc.Width()/7)*3+listrc.Width()*2/7),subitemFile);
201 m_List.InsertColumn(1,"type",LVCFMT_CENTER,listrc.Width()/7,subitemType);
202 m_List.InsertColumn(2,"peer",LVCFMT_LEFT,listrc.Width()*2/7,subitemPeer);
203 m_List.InsertColumn(3,"ACK",LVCFMT_RIGHT,listrc.Width()/7,subitemBytes);
204 m_List.InsertColumn(4,"tsize",LVCFMT_RIGHT,listrc.Width()/7,subitemTSize);
205
206 LogLine(IDS_LOG_START);
207
208 SetupButtons();
209
210CRect rc, drc;
211 GetWindowRect(rc);
212 GetDesktopWindow()->GetWindowRect(drc);
213 SetWindowPos(NULL,drc.right-6-rc.Width(),6,0,0,SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER);
214
215 if(m_bShown)
216 ShowWindow(SW_SHOW);
217 else
218 ShowWindow(SW_HIDE);
219
220 // CG: The following block was added by the ToolTips component.
221 {
222 // Create the ToolTip control.
223 m_tooltip.Create(this);
224 m_tooltip.Activate(TRUE);
225
226 m_tooltip.AddTool(&m_List,IDC_CONNECTIONS);
227 m_tooltip.AddTool(GetDlgItem(IDC_PUT),IDC_PUT);
228 m_tooltip.AddTool(GetDlgItem(IDC_GET),IDC_GET);
229 m_tooltip.AddTool(&m_AbortCtl,IDC_ABORT);
230 m_tooltip.AddTool(GetDlgItem(IDC_OPTIONS),IDC_OPTIONS);
231 m_tooltip.AddTool(GetDlgItem(IDC_EXIT),IDC_EXIT);
232 m_tooltip.AddTool(GetDlgItem(ID_HELP),ID_HELP);
233 m_tooltip.AddTool(GetDlgItem(IDC_LOG),IDC_LOG);
234 }
235 return TRUE; // return TRUE unless you set the focus to a control
236}
237
238void CPumpKINDlg::OnSysCommand(UINT nID, LPARAM lParam)
239{
240 if ((nID & 0xFFF0) == IDM_ABOUTBOX)
241 {
242 CAboutDlg dlgAbout;
243 dlgAbout.DoModal();
244 }
245 else
246 {
247 CDialog::OnSysCommand(nID, lParam);
248 }
249}
250
251void CPumpKINDlg::OnDestroy()
252{
253 SaveSettings();
254
255NOTIFYICONDATA nid;
256 memset(&nid,0,sizeof(nid));
257 nid.cbSize=sizeof(nid);
258 nid.hWnd=m_Trayer->m_hWnd;
259 nid.uID=IDC_TRAYICON;
260 nid.uFlags=0;
261 VERIFY(Shell_NotifyIcon(NIM_DELETE,&nid));
262
263 WinHelp(0L, HELP_QUIT);
264 CDialog::OnDestroy();
265POSITION p = m_LogTimes.GetStartPosition();
266 while(p){
267 CTime *t,*tt;
268 m_LogTimes.GetNextAssoc(p,t,tt);
269 ASSERT(t && tt && t==tt);
270 delete t;
271 }
272 // *** Abort and cleanup transfers
273 m_LogTimes.RemoveAll();
274}
275
276// If you add a minimize button to your dialog, you will need the code below
277// to draw the icon. For MFC applications using the document/view model,
278// this is automatically done for you by the framework.
279
280void CPumpKINDlg::OnPaint()
281{
282 if (IsIconic())
283 {
284 CPaintDC dc(this); // device context for painting
285
286 SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
287
288 // Center icon in client rectangle
289 int cxIcon = GetSystemMetrics(SM_CXICON);
290 int cyIcon = GetSystemMetrics(SM_CYICON);
291 CRect rect;
292 GetClientRect(&rect);
293 int x = (rect.Width() - cxIcon + 1) / 2;
294 int y = (rect.Height() - cyIcon + 1) / 2;
295
296 // Draw the icon
297 dc.DrawIcon(x, y, m_hIcon);
298 }
299 else
300 {
301 CPaintDC pDC(this);
302 CDC bmpDC;
303 bmpDC.CreateCompatibleDC(&pDC);
304 bmpDC.SelectObject(&m_bmpBack);
305 CRect rc;
306 GetClientRect(&rc);
307 for(int x=-m_bitmapBack.bmWidth*2/4;x<rc.Width();x+=m_bitmapBack.bmWidth)
308 for(int y=-m_bitmapBack.bmHeight*2/4;y<rc.Height();y+=m_bitmapBack.bmHeight)
309 pDC.BitBlt(x,y,m_bitmapBack.bmWidth,m_bitmapBack.bmHeight,&bmpDC,0,0,SRCCOPY);
310 bmpDC.DeleteDC();
311 CDialog::OnPaint();
312 }
313}
314
315// The system calls this to obtain the cursor to display while the user drags
316// the minimized window.
317HCURSOR CPumpKINDlg::OnQueryDragIcon()
318{
319 return (HCURSOR) m_hIcon;
320}
321
322int CPumpKINDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
323{
324 if (CDialog::OnCreate(lpCreateStruct) == -1)
325 return -1;
326
327 m_Listener.m_Daddy=this;
328 if(!m_Listener.Create(m_ListenPort,SOCK_DGRAM)){
329 TRACE0("Failed to create socket\n");
330 return -1;
331 }
332
333 if(!m_Trayer->Create(NULL,"PumpKIN TrayIcon",WS_CHILD,CRect(0,0,0,0),this,0)){
334 TRACE0("Failed to create trayer\n");
335 return -1;
336 }
337
338NOTIFYICONDATA nid;
339 memset(&nid,0,sizeof(nid));
340 nid.cbSize=sizeof(nid);
341 nid.hWnd=m_Trayer->m_hWnd;
342 nid.uID=IDC_TRAYICON;
343 nid.uFlags=NIF_MESSAGE|NIF_ICON|NIF_TIP;
344 nid.uCallbackMessage=WM_TRAYICON;
345 nid.hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME);
346 // *** Load from resource
347 strcpy(nid.szTip,"PumpKIN");
348 VERIFY(Shell_NotifyIcon(NIM_ADD,&nid));
349
350 return 0;
351}
352
353void CListenSocket::OnReceive(int nErrorCode)
354{
355 ASSERT(m_Daddy);
356 if(nErrorCode){
357 m_Daddy->LogLine(IDS_LOG_LISTENRECEIVEERROR);
358 return;
359 }
360DWORD fionread = 0;
361 VERIFY(IOCtl(FIONREAD,&fionread));// *** Do some checking on the value acquired
362tftp *tftpRQ = tftp::Allocate(fionread);
363 ASSERT(tftpRQ);
364SOCKADDR_IN sin;
365 if(!tftpRQ->Receive(this,fionread,&sin)){
366 m_Daddy->LogLine(IDS_LOG_LISTENACCEPTERROR);
367 delete tftpRQ;
368 return;
369 }
370 #ifndefNDEBUG
371CString tmp;
372 tmp.Format("%u - %s - %u\n",tftpRQ->Opcode(),inet_ntoa(sin.sin_addr),sin.sin_port);
373 TRACE0(tmp);
374#endif
375POSITION p = m_Daddy->m_Xfers.GetStartPosition();
376 while(p){
377 SOCKET key;
378 CXferSocket *sock;
379 m_Daddy->m_Xfers.GetNextAssoc(p,key,sock);
380 ASSERT(sock);
381 if(sock->m_Peer.sin_addr.s_addr==sin.sin_addr.s_addr && sock->m_Peer.sin_port==sin.sin_port){
382 TRACE0("Ignoring request which we are already processing\n");
383 delete tftpRQ;
384 return;
385 }
386 }
387 switch(tftpRQ->Opcode()){
388 case tftp::opRRQ:
389 // Read Request
390 {
391 CString tmp;
392 tmp.Format(IDS_LOG_RRQSERVE,tftpRQ->rqFileName(),tftpRQ->rqType(),inet_ntoa(sin.sin_addr));
393 m_Daddy->LogLine(tmp);
394 CRRQSocket *s = new CRRQSocket(m_Daddy,tftpRQ->rqFileName(),tftpRQ->rqType(),&sin);
395 ASSERT(s);
396 tftpRQ->GetOptions(&s->m_Options);
397 if(!s->Create())
398 s->Destroy(FALSE);
399 }
400 break;
401 case tftp::opWRQ:
402 // Write Request
403 {
404 CString tmp;
405 tmp.Format(IDS_LOG_WRQSERVE,tftpRQ->rqFileName(),tftpRQ->rqType(),inet_ntoa(sin.sin_addr));
406 m_Daddy->LogLine(tmp);
407 CWRQSocket *s = new CWRQSocket(m_Daddy,tftpRQ->rqFileName(),tftpRQ->rqType(),&sin);
408 ASSERT(s);
409 tftpRQ->GetOptions(&s->m_Options);
410 if(!s->Create(NULL,NULL))
411 s->Destroy(FALSE);
412 }
413 break;
414 default:
415 m_Daddy->LogLine(IDS_LOG_LISTENOPCODE);
416 delete tftpRQ;
417 return;
418 }
419 delete tftpRQ;
420}
421
422BOOL tftp::Receive(CAsyncSocket* socket,UINT maxLength,SOCKADDR_IN *sin)
423{
424 ASSERT(socket);
425int saddrLen = sizeof(SOCKADDR_IN);
426 length = sin ?
427 socket->ReceiveFrom(udpBase(),maxLength,(SOCKADDR*)sin,&saddrLen)
428 :
429 socket->Receive(udpBase(),maxLength)
430 ;
431 if(!length)
432 return FALSE;
433 if(length==(tftpLength)SOCKET_ERROR)
434 return FALSE;
435 return TRUE;
436}
437
438UINT tftp::Opcode()
439{
440 return REVERSEBYTES(opcode);
441}
442
443CString tftp::rqFileName()
444{
445 ASSERT(length);
446 ASSERT(Opcode()==opRRQ || Opcode()==opWRQ);
447CString rv;
448 if(memchr(&data.m_RQ.data,0,length-sizeof(opcode)))
449 rv = (LPCTSTR)data.m_RQ.data;
450 return rv;
451}
452
453CString tftp::rqType()
454{
455 ASSERT(length);
456 ASSERT(Opcode()==opRRQ || Opcode()==opWRQ);
457CString rv;
458char *tmp = (char*)memchr(&data.m_RQ.data,0,length-sizeof(opcode));
459 if(tmp++)
460 rv = (LPCTSTR)tmp;
461 return rv;
462}
463
464UINT tftp::GetOptions(tftp::tftpOptions* ops)
465{
466 ASSERT(length);
467 ASSERT(Opcode()==opRRQ || Opcode()==opWRQ || Opcode()==opOACK);
468 ASSERT(ops);
469tftpOptions& o = *ops;
470LPSTR base = (LPSTR)&data.m_RQ.data;
471UINT basePtr = 0;
472 if(Opcode()==opRRQ || Opcode()==opWRQ){
473 base = (LPSTR)memchr(&data.m_RQ.data,0,length-sizeof(opcode));
474 if(!base)
475 return 0;
476 base++;
477 basePtr = (base-(LPSTR)&data.m_RQ.data);
478 base = (LPSTR)memchr(base,0,length-basePtr);
479 if(!base)
480 return 0;
481 base++;
482 basePtr = (base-(LPSTR)&data.m_RQ.data);
483 }
484 ops->RemoveAll();
485UINT rv = 0;
486 while(basePtr<(length-sizeof(opcode))){
487 CString onam = (LPSTR)&data.m_RQ.data[basePtr];
488 basePtr+=onam.GetLength()+1;
489 CString oval = (LPSTR)&data.m_RQ.data[basePtr];
490 basePtr+=oval.GetLength()+1;
491 onam.MakeLower();
492 o[onam]=oval;
493 rv++;
494 }
495 return rv;
496}
497
498tftp::tftp()
499{
500 length=0;
501}
502
503
504void CXferSocket::OnSend(int nErrorCode)
505{
506 if(nErrorCode){
507 ASSERT(m_Daddy);
508 m_Daddy->LogLine(IDS_LOG_XFERSEND);
509 return;
510 }
511 if(!m_Queue.IsEmpty()){
512 tftp *p = m_Queue.GetHead();
513 ASSERT(p);
514 m_Queue.RemoveHead();
515 if(!p->Send(this,&m_Peer)){
516 ASSERT(m_Daddy);
517 m_Daddy->LogLine(IDS_LOG_XFERUDPSEND);
518 }
519 delete p;
520 }
521 DoSelect();
522 if(m_Queue.IsEmpty()){
523 switch(state){
524 case stateDeny:
525 Destroy(FALSE);
526 break;
527 case stateFinish:
528 Destroy(TRUE);
529 break;
530 }
531 }
532}
533
534BOOL tftp::Send(CAsyncSocket *socket,SOCKADDR_IN* saddr)
535{
536 ASSERT(socket);
537int rv = socket->SendTo(udpBase(),length,(SOCKADDR*)saddr,sizeof(SOCKADDR_IN));
538 if(rv!=length)
539 return FALSE;
540 return TRUE;
541}
542
543void CXferSocket::DoSelect()
544{
545 if(m_Peer.sin_addr.s_addr!=INADDR_NONE)
546 AsyncSelect(FD_CLOSE|FD_READ|(m_Queue.IsEmpty()?0:FD_WRITE));
547}
548
549void CXferSocket::OnReceive(int nErrorCode)
550{
551 if(nErrorCode){
552 ASSERT(m_Daddy);
553 m_Daddy->LogLine(IDS_LOG_XFERRECEIVE);
554 return;
555 }
556 ASSERT(m_Daddy);
557DWORD fionread = 0;
558 VERIFY(IOCtl(FIONREAD,&fionread));
559tftp *p = tftp::Allocate(fionread);
560 ASSERT(p);
561SOCKADDR_IN sin;
562 if(!p->Receive(this,fionread,&sin)){
563 m_Daddy->LogLine(IDS_LOG_XFERUDPRECEIVE);
564 delete p;
565 }else
566 if(m_Peer.sin_addr.s_addr==INADDR_NONE){
567 m_Peer.sin_addr=sin.sin_addr;
568 m_Peer.sin_port=sin.sin_port;
569 }
570BOOL alive = TRUE;
571 if(state==stateInit){
572 state=stateXfer;
573 m_Peer.sin_port=sin.sin_port;
574 UpdateList();
575 }
576 if(sin.sin_addr.s_addr!=m_Peer.sin_addr.s_addr || sin.sin_port!=m_Peer.sin_port){
577 m_Daddy->LogLine(IDS_LOG_XFERSOURCETID);
578 // *** Bounce it!
579 }else{
580 alive = OnTFTP(p);
581 }
582 delete p;
583 if(alive){
584 DoSelect();
585 ResetTimeout();
586 }
587}
588
589void CXferSocket::SetPeer(SOCKADDR_IN *sin)
590{
591 ASSERT(sin);
592 memmove(&m_Peer,sin,sizeof(m_Peer));
593}
594
595void CXferSocket::UpdateList()
596{
597 ASSERT(m_Daddy);
598LV_FINDINFO lvf;
599 memset(&lvf,0,sizeof(lvf));
600 lvf.flags=LVFI_PARAM;
601 lvf.lParam=(LPARAM)this;
602int i = m_Daddy->m_List.FindItem(&lvf);
603 if(i<0){
604 ASSERT(IsKindOf(RUNTIME_CLASS(CRRQSocket)) || IsKindOf(RUNTIME_CLASS(CWRQSocket)));
605 i=m_Daddy->m_List.InsertItem(0,m_FileName,IsKindOf(RUNTIME_CLASS(CRRQSocket))?m_Daddy->m_iRRQ:m_Daddy->m_iWRQ);
606 ASSERT(!(i<0));
607 m_Daddy->m_List.SetItemData(i,(DWORD)this);
608 }
609 m_Daddy->m_List.SetItemText(i,CPumpKINDlg::subitemFile,m_FileName);
610 m_Daddy->m_List.SetItemText(i,CPumpKINDlg::subitemType,m_Type);
611 m_Daddy->m_List.SetItemText(i,CPumpKINDlg::subitemPeer,inet_ntoa(m_Peer.sin_addr));
612CString tmp;
613 tmp.Format(IDS_FMT_BYTES,GetACK());
614 m_Daddy->m_List.SetItemText(i,CPumpKINDlg::subitemBytes,tmp);
615 if(m_xferSize>=0){
616 tmp.Format(IDS_FMT_BYTES,m_xferSize);
617 m_Daddy->m_List.SetItemText(i,CPumpKINDlg::subitemTSize,tmp);
618 }
619}
620
621CXferSocket::CXferSocket()
622 : m_wndResolver(NULL), m_Retry(NULL), m_bRetry(FALSE),
623 m_blkSize(512), m_timeOut(30), m_xferSize(-1),
624 m__blkSize(512), m__timeOut(30)
625{
626 m_Daddy=NULL;
627 m_Peer.sin_addr.s_addr=INADDR_NONE;
628 m_Peer.sin_family=AF_INET;
629 state=stateNone;
630}
631
632ULONG CXferSocket::GetACK()
633{
634 return 0;
635}
636
637CXferSocket::CXferSocket(CPumpKINDlg *daddy,LPCTSTR fileName,LPCTSTR type,SOCKADDR_IN* sin)
638 : m_wndResolver(NULL), m_Retry(NULL), m_bRetry(FALSE),
639 m_blkSize(512), m_timeOut(30), m_xferSize(-1),
640 m__blkSize(512), m__timeOut(30)
641{
642 m_Peer.sin_family=AF_INET;
643 state=stateNone;
644 ASSERT(daddy);
645 m_Daddy=daddy;
646 m_timeOut=m__timeOut=m_Daddy->m_TFTPTimeOut.GetTotalSeconds();
647 if(sin){
648 m_Peer.sin_addr.s_addr=sin->sin_addr.s_addr;
649 m_Peer.sin_port=sin->sin_port;
650 }else
651 m_Peer.sin_addr.s_addr=INADDR_NONE;
652 m_FileName=fileName;
653 m_Type=type;
654}
655
656BOOL CRRQSocket::Create(LPCTSTR localFile,LPCTSTR hostName)
657{
658 if(!CAsyncSocket::Create(0,SOCK_DGRAM))
659 return FALSE;
660 ASSERT(m_Daddy);
661 ASSERT(m_Peer.sin_addr.s_addr!=INADDR_NONE || hostName);
662 m_Daddy->m_Xfers[m_hSocket]=this;
663CString lFile = localFile?localFile:m_FileName;
664 TurnSlashes(lFile,TRUE);
665 UpdateList();
666 if(!localFile){// Check only if server
667 if(CheckBadRelativeness(m_FileName)){
668 Deny(tftp::errAccessViolation,IDS_TFTP_ERROR_ACCESS);
669 return TRUE;
670 }
671 switch(m_Daddy->m_RRQMode){
672 case CPumpKINDlg::rrqGiveAll:
673 break;
674 case CPumpKINDlg::rrqAlwaysConfirm:
675 if(ConfirmRequest())
676 break;
677 case CPumpKINDlg::rrqDenyAll:
678 Deny(tftp::errAccessViolation,IDS_TFTP_ERROR_ACCESS);
679 return TRUE;
680 }
681 }
682CString fn = localFile?ApplyRootGently(lFile):ApplyRoot(lFile);
683CFileException e;
684 if(!m_File.Open(fn,CFile::modeRead|CFile::shareDenyWrite,&e)){
685 if(localFile){
686 CString tmp;
687 tmp.Format(IDS_LOG_FAILEDLOCALFILE,fn);
688 m_Daddy->LogLine(tmp);
689 return FALSE;
690 }
691 Deny(&e);
692 return TRUE;
693 }
694 m_xferSize=m_File.GetLength();// *** HANDLE EXCEPTION
695 if(hostName){
696 m_HostName=hostName;
697
698 CString tmp;
699 tmp.Format(IDS_LOG_SENDING,m_FileName,m_HostName);
700 m_Daddy->LogLine(tmp);
701
702 CString inAddr = hostName;
703 int at = inAddr.Find('@');
704 if(at>=0)
705 inAddr=inAddr.Mid(at+1);
706 if((m_Peer.sin_addr.s_addr=inet_addr((LPCTSTR)inAddr))==INADDR_NONE){
707 ASSERT(!m_wndResolver);
708 m_wndResolver = new CResolver(this);
709 ASSERT(m_wndResolver);
710 return m_wndResolver->Resolve();
711 }
712 else
713 OnHostKnown();
714 }else{
715 tftp::tftpOptions o;
716 CString v;
717 if(m_Options.Lookup(tftpoBSize,v)){
718 m__blkSize=atoi(v);
719 if(m__blkSize){
720 m_blkSize=m__blkSize;
721 v.Format("%u",m_blkSize);
722 o[tftpoBSize]=v;
723 }
724 }
725 if(m_Options.Lookup(tftpoTSize,v)){
726 v.Format("%lu",m_xferSize);
727 o[tftpoTSize]=v;
728 }
729 if(m_Options.Lookup(tftpoTOut,v)){
730 m__timeOut=atoi(v);
731 if(m__timeOut){
732 m_timeOut=m__timeOut;
733 v.Format("%u",m_timeOut);
734 o[tftpoTOut]=v;
735 }
736 }
737 state = stateXfer;
738 m_ACK=0;
739 if(o.GetCount()){
740 tftp *p = tftp::Allocate(tftp::tftpOACK::tftpSize(&o));
741 ASSERT(p);
742 p->SetOpcode(tftp::opOACK);
743 p->data.m_OACK.Set(&o);
744 PostTFTP(p,TRUE);
745 }else
746 DoXfer();
747 }
748 return TRUE;
749}
750
751CRRQSocket::CRRQSocket(CPumpKINDlg *daddy,LPCTSTR fileName,LPCTSTR type,SOCKADDR_IN *sin)
752 : CXferSocket(daddy,fileName,type,sin)
753{
754 m_ACK=0;
755 m_LastSlack=0;
756}
757
758UINT tftp::tftpERROR::tftpSize(LPCTSTR msg)
759{
760 return tftpHdrSize-tftpSlackSize+sizeof(tftp::tftpERROR::tftpErrorCode)+strlen(msg)+1;
761}
762
763tftp* tftp::Allocate(UINT tftpSize)
764{
765 ASSERT(tftpSize);
766tftp* rv = (tftp*) new BYTE[tftpSlackSize+tftpSize];
767 ASSERT(rv);
768 rv->length=tftpSize;
769 return rv;
770}
771
772void tftp::errSet(UINT code,LPCTSTR msg)
773{
774 ASSERT(this);
775 ASSERT(length>=data.m_ERROR.tftpSize(msg));
776 strcpy((char*)data.m_ERROR.data,msg);
777 data.m_ERROR.SetCode(code);
778}
779
780void CXferSocket::PostTFTP(tftp* p,BOOL retryable)
781{
782 ASSERT(p);
783 m_Queue.AddTail(p);
784 DoSelect();
785 if(!m_bRetry){
786 if(retryable)
787 SetTry(p);
788 else
789 SetTry();
790 }
791 ResetTimeout();
792}
793
794void CXferSocket::Deny(UINT errCode,UINT errID)
795{
796 PostError(errCode,errID);
797 state=stateDeny;
798}
799
800void CRRQSocket::DoXfer()
801{
802tftp *p = tftp::Allocate(tftp::tftpDATA::tftpSize(m_blkSize));
803 ASSERT(p);
804 p->SetOpcode(tftp::opDATA);
805 TRY{
806 m_File.Seek(m_ACK*m_blkSize,CFile::begin);
807 int bytes = m_File.Read(p->data.m_DATA.data,m_blkSize);
808 p->data.m_DATA.SetBlock(m_ACK+1);
809 p->length=p->length-m_blkSize+bytes;
810 m_LastSlack = m_blkSize-bytes;
811 PostTFTP(p);
812 if(bytes<m_blkSize){
813 state=stateFinish;
814 ASSERT(m_Daddy);
815 CString tmp;
816 tmp.Format(IDS_LOG_XFERRRQFINISHED,(LPCTSTR)m_FileName);
817 m_Daddy->LogLine(tmp);
818 }
819 }CATCH(CFileException,e){
820 Deny(e);
821 }END_CATCH
822}
823
824UINT tftp::tftpDATA::tftpSize(UINT blkSize)
825{
826 return tftpHdrSize-tftpSlackSize+sizeof(tftp::tftpDATA)
827 -sizeof(BYTE)+blkSize;
828}
829
830void CXferSocket::Deny(CFileException* e)
831{
832 PostError(e);
833 state=stateDeny;
834}
835
836void CXferSocket::PostError(UINT errCode,UINT errID)
837{
838CString msg;
839 msg.LoadString(errID);
840 ASSERT(m_Daddy);
841 /*// ***
842CString tmp;
843 tmp.Format(IDS_LOG_SENTTFTPERROR,errCode,(LPCTSTR)msg);
844 m_Daddy->LogLine(tmp);
845 */
846tftp* err = tftp::Allocate(tftp::tftpERROR::tftpSize(msg));
847err->SetOpcode(tftp::opERROR);
848 err->errSet(errCode,msg);
849 PostTFTP(err);
850}
851
852void CXferSocket::PostError(CFileException* e)
853{
854UINT eCode;
855UINT eMsgID;
856 switch(e->m_cause){
857 case CFileException::fileNotFound:
858 eCode=tftp::errNotFound;
859 eMsgID=IDS_TFTP_ERROR_NOTFOUND;
860 break;
861 case CFileException::accessDenied:
862 eCode=tftp::errAccessViolation;
863 eMsgID=IDS_TFTP_ERROR_ACCESS;
864 break;
865 case CFileException::directoryFull:
866 eCode=tftp::errDiskFull;
867 eMsgID=IDS_TFTP_ERROR_DIRFULL;
868 break;
869 case CFileException::sharingViolation:
870 eCode=tftp::errAccessViolation;
871 eMsgID=IDS_TFTP_ERROR_SHARING;
872 break;
873 case CFileException::diskFull:
874 eCode=tftp::errDiskFull;
875 eMsgID=IDS_TFTP_ERROR_DISKFULL;
876 break;
877 default:
878 eCode=tftp::errUndefined;
879 eMsgID=IDS_TFTP_ERROR_UNDEFINED;
880 break;
881 }
882 PostError(eCode,eMsgID);
883}
884
885ULONG CRRQSocket::GetACK(void)
886{
887 return (m_ACK*m_blkSize)-m_LastSlack;
888}
889
890BOOL CRRQSocket::OnTFTP(tftp* p)
891{
892BOOL rv = TRUE;
893 switch(p->Opcode()){
894 case tftp::opOACK:
895 m_ACK=0;
896 ASSERT(state!=stateFinish);
897 {
898 tftp::tftpOptions o;
899 if(p->GetOptions(&o)){
900 CString v;
901 if(o.Lookup(tftpoBSize,v)){
902 m_blkSize=atoi(v);
903 if(!m_blkSize){// *** More sanity checks
904 Deny(tftp::errOption,IDS_TFTP_ERROR_BSIZE);
905 rv = TRUE;
906 break;
907 }
908 }
909 if(o.Lookup(tftpoTOut,v)){
910 m_timeOut=atoi(v);
911 if(!m_timeOut){// *** More sanity checks
912 Deny(tftp::errOption,IDS_TFTP_ERROR_TOUT);
913 rv = TRUE;
914 break;
915 }
916 }
917 if(o.Lookup(tftpoXResume,v)){
918 m_ACK=atoi(v);
919 }
920 }
921 UpdateList();
922 DoXfer();
923 }
924 break;
925 case tftp::opACK:
926 m_ACK=p->data.m_ACK.Block();
927 if(state!=stateFinish){
928 UpdateList();
929 DoXfer();
930 }
931 break;
932 case tftp::opERROR:
933 {
934 ASSERT(m_Daddy);
935 CString tmp;
936 tmp.Format(IDS_LOG_GOTTFTPERROR,p->data.m_ERROR.Code(),(LPCTSTR)p->errMessage());
937 m_Daddy->LogLine(tmp);
938 }
939 Destroy(FALSE);
940 rv = FALSE;
941 break;
942 default:
943 ASSERT(m_Daddy);
944 m_Daddy->LogLine(IDS_LOG_XFEROPCODE);
945 // *** Self destruct maybe??
946 break;
947 }
948 return rv;
949}
950
951BOOL CWRQSocket::OnTFTP(tftp* p)
952{
953 switch(p->Opcode()){
954 case tftp::opOACK:
955 ASSERT(state!=stateFinish);
956 {
957 if(m_bResume)
958 m_ACK=m_File.GetLength()/m_blkSize;
959 else
960 m_ACK=0;
961 tftp::tftpOptions o;
962 if(p->GetOptions(&o)){
963 CString v;
964 if(o.Lookup(tftpoBSize,v)){
965 m_blkSize=atoi(v);
966 if(!m_blkSize){// *** More sanity checks
967 Deny(tftp::errOption,IDS_TFTP_ERROR_BSIZE);
968 return TRUE;
969 }
970 }
971 if(o.Lookup(tftpoTOut,v)){
972 m_timeOut=atoi(v);
973 if(!m_timeOut){// *** More sanity checks
974 Deny(tftp::errOption,IDS_TFTP_ERROR_TOUT);
975 return TRUE;
976 }
977 }
978 if(o.Lookup(tftpoTSize,v)){
979 m_xferSize=atoi(v);
980 }
981 }
982 UpdateList();
983 DoXfer();
984 }
985 break;
986 case tftp::opDATA:
987 {
988 UINTblock = p->data.m_DATA.Block();
989 TRY{
990 m_File.Seek((block-1)*m_blkSize,CFile::begin);
991 int bytes = p->length-sizeof(p->data.m_DATA.block)-(tftpHdrSize-tftpSlackSize);
992 if(bytes){
993 m_File.Write(p->data.m_DATA.data,bytes);
994 // *** Move to the other place where we can do it not that often
995 m_File.SetLength(m_File.GetPosition());
996 }
997 if(bytes<m_blkSize){
998 state=stateFinish;
999 ASSERT(m_Daddy);
1000 CString tmp;
1001 tmp.Format(IDS_LOG_XFERWRQFINISHED,(LPCTSTR)m_FileName);
1002 m_Daddy->LogLine(tmp);
1003 }
1004 m_ACK=block;
1005 m_LastSlack=m_blkSize-bytes;
1006 UpdateList();
1007 DoXfer();
1008 }CATCH(CFileException,e){
1009 Deny(e);
1010 }END_CATCH
1011 }
1012 break;
1013 case tftp::opERROR:
1014 {
1015 ASSERT(m_Daddy);
1016 CString tmp;
1017 tmp.Format(IDS_LOG_GOTTFTPERROR,p->data.m_ERROR.Code(),(LPCTSTR)p->errMessage());
1018 m_Daddy->LogLine(tmp);
1019 }
1020 Destroy(FALSE);
1021 return FALSE;
1022 default:
1023 ASSERT(m_Daddy);
1024 m_Daddy->LogLine(IDS_LOG_XFEROPCODE);
1025 // *** Self destruct maybe??
1026 break;
1027 }
1028 return TRUE;
1029}
1030
1031void tftp::SetOpcode(WORD op)
1032{
1033 opcode = REVERSEBYTES(op);
1034}
1035void tftp::tftpDATA::SetBlock(WORD b)
1036{
1037 block=REVERSEBYTES(b);
1038}
1039WORD tftp::tftpDATA::Block()
1040{
1041 return REVERSEBYTES(block);
1042}
1043WORD tftp::tftpACK::Block()
1044{
1045 return REVERSEBYTES(block);
1046}
1047void tftp::tftpACK::SetBlock(WORD b)
1048{
1049 block = REVERSEBYTES(b);
1050}
1051WORD tftp::tftpERROR::Code()
1052{
1053 return REVERSEBYTES(code);
1054}
1055void tftp::tftpERROR::SetCode(WORD c)
1056{
1057 code = REVERSEBYTES(c);
1058}
1059
1060
1061CString tftp::errMessage()
1062{
1063CString rv;
1064 if(memchr(data.m_ERROR.data,0,length-(tftpHdrSize-tftpSlackSize)-sizeof(data.m_ERROR.code)))
1065 rv = (LPCTSTR)data.m_ERROR.data;
1066 return rv;
1067}
1068
1069void CXferSocket::Destroy(BOOL success)
1070{
1071 if(m_wndResolver){
1072 delete m_wndResolver;
1073 m_wndResolver=NULL;
1074 }
1075 SetTry();
1076 m_Daddy->m_bnw.StartSound(
1077 success
1078 ? m_Daddy->m_bnwSuccess
1079 : m_Daddy->m_bnwAbort
1080 );
1081 if(m_File.m_hFile!=CFile::hFileNull){
1082 TRY{
1083 m_File.Close();
1084 }CATCH(CFileException,e){
1085 TRACE0("Error closing file\n");
1086 }END_CATCH
1087 }
1088 ASSERT(m_Daddy);
1089 m_Daddy->KillTimer(m_hSocket);
1090 m_Daddy->m_Xfers.RemoveKey(m_hSocket);
1091LV_FINDINFO lvf;
1092 memset(&lvf,0,sizeof(lvf));
1093 lvf.flags=LVFI_PARAM;
1094 lvf.lParam=(LPARAM)this;
1095int i = m_Daddy->m_List.FindItem(&lvf);
1096 if(i>=0)
1097 m_Daddy->m_List.DeleteItem(i);
1098 delete this;
1099}
1100
1101void CPumpKINDlg::LogLine(LPCTSTR str)
1102{
1103 ASSERT(m_LogLength);
1104 while(m_Log.GetCount()>m_LogLength && m_Log.GetCount()!=LB_ERR){
1105 CTime *t = (CTime*)m_Log.GetItemData(0);
1106 if(((DWORD)t)!=LB_ERR){
1107 ASSERT(t);
1108 m_LogTimes.RemoveKey(t);
1109 delete t;
1110 }
1111 m_Log.DeleteString(0);
1112 }
1113int i = m_Log.AddString(str);
1114 ASSERT(i!=LB_ERR);
1115CTime *t = new CTime(CTime::GetCurrentTime());
1116 m_Log.SetItemData(i,(DWORD)(m_LogTimes[t]=t));
1117 m_Log.SetCurSel(i);
1118}
1119
1120void CPumpKINDlg::LogLine(UINT msgID)
1121{
1122CString tmp;
1123 tmp.Format(msgID);
1124 LogLine(tmp);
1125}
1126
1127void CXferSocket::TurnSlashes(CString& fn,BOOL bBack)
1128{
1129 ints = fn.Find(bBack?'/':'\\');
1130 while(s>=0){
1131 fn.SetAt(s,bBack?'\\':'/');
1132 s = fn.Find(bBack?'/':'\\');
1133 }
1134}
1135
1136CString CXferSocket::ApplyRoot(LPCTSTR fileName)
1137{
1138 ASSERT(m_Daddy);
1139CString fn = fileName;
1140CString rv = m_Daddy->m_TFTPRoot;
1141 if(rv.IsEmpty())
1142 rv = ".";
1143 if(rv[rv.GetLength()-1]!='\\')
1144 rv+="\\";
1145 while((!fn.IsEmpty()) && fn[0]=='\\')
1146 fn=fn.Mid(1);
1147 rv+=fn;
1148 return rv;
1149}
1150
1151void CPumpKINDlg::OnOptions()
1152{
1153CPropertySheet cps(IDS_TITLE_OPTIONS,this);
1154CPropsServer server;
1155CPropsNetwork network;
1156CPropsSounds sounds;
1157
1158 server.m_RRQMode=m_RRQMode;
1159 server.m_TFTPRoot=m_TFTPRoot;
1160 server.m_TFTPSubdirs=m_bTFTPSubdirs;
1161 server.m_WRQMode=m_WRQMode;
1162 server.m_PromptTimeOut=m_PromptTimeOut;
1163
1164 network.m_ListenPort=m_ListenPort;
1165 network.m_SpeakPort=m_SpeakPort;
1166 network.m_TimeOut=m_TFTPTimeOut.GetTotalSeconds();
1167 network.m_BlockSize=m_BlockSize;
1168
1169 sounds.m_Request = m_bnwRequest;
1170 sounds.m_Success = m_bnwSuccess;
1171 sounds.m_Abort = m_bnwAbort;
1172
1173 cps.AddPage(&server);
1174 cps.AddPage(&network);
1175 cps.AddPage(&sounds);
1176 if(cps.DoModal()==IDOK){
1177 m_RRQMode=server.m_RRQMode;
1178 m_TFTPRoot=server.m_TFTPRoot;
1179 m_bTFTPSubdirs=server.m_TFTPSubdirs;
1180 m_WRQMode=server.m_WRQMode;
1181 m_PromptTimeOut=server.m_PromptTimeOut;
1182
1183 m_ListenPort=network.m_ListenPort;
1184 m_SpeakPort=network.m_SpeakPort;
1185 m_TFTPTimeOut=CTimeSpan(network.m_TimeOut);
1186 m_BlockSize=network.m_BlockSize;
1187
1188 m_bnwRequest = sounds.m_Request;
1189 m_bnwSuccess = sounds.m_Success;
1190 m_bnwAbort = sounds.m_Abort;
1191 }
1192}
1193
1194BOOL CRRQSocket::ConfirmRequest()
1195{
1196CConfirmRRQDlg cd(NULL);
1197 cd.m_Daddy=this;
1198 cd.m_File=m_FileName;
1199 cd.m_Host=inet_ntoa(m_Peer.sin_addr);
1200 if(cd.DoModal()==IDOK)
1201 return TRUE;
1202 return FALSE;
1203}
1204
1205CWRQSocket::CWRQSocket(CPumpKINDlg* daddy,LPCTSTR fileName,LPCTSTR type,SOCKADDR_IN *sin)
1206 : CXferSocket(daddy,fileName,type,sin)
1207{
1208 state=stateNone;
1209 m_ACK=0;
1210 m_LastSlack=0;
1211 m_bResume=FALSE;
1212}
1213
1214BOOL CWRQSocket::Create(LPCTSTR localFile,LPCTSTR hostName)
1215{
1216 if(!CAsyncSocket::Create(0,SOCK_DGRAM))
1217 return FALSE;
1218 ASSERT(m_Daddy);
1219 ASSERT(m_Peer.sin_addr.s_addr!=INADDR_NONE || hostName);
1220 m_Daddy->m_Xfers[m_hSocket]=this;
1221 TurnSlashes(m_FileName,TRUE);
1222 UpdateList();
1223CString fn = localFile?ApplyRootGently(localFile):ApplyRoot(m_FileName);
1224 if(!localFile){// This is an incoming request..
1225 if(CheckBadRelativeness(m_FileName)){
1226 Deny(tftp::errAccessViolation,IDS_TFTP_ERROR_ACCESS);
1227 return TRUE;
1228 }
1229 BOOL exists;
1230 if(!_access((LPCTSTR)fn,0))
1231 m_Rename=exists=TRUE;
1232 else
1233 m_Rename=exists=FALSE;
1234 // *** m_WRQMode only if server transfer
1235 switch(m_Daddy->m_WRQMode){
1236 case CPumpKINDlg::wrqTakeAll:
1237 if(exists){
1238 if(!RenameFile(fn)){
1239 Deny(tftp::errDiskFull,IDS_TFTP_ERROR_FAILEDTORENAME);
1240 return TRUE;
1241 }
1242 }
1243 break;
1244 case CPumpKINDlg::wrqConfirmIfExists:
1245 if(!exists)
1246 break;
1247 case CPumpKINDlg::wrqAlwaysConfirm:
1248 if(exists)
1249 m_bResume=TRUE;
1250 if(ConfirmRequest()){
1251 if(m_Rename){
1252 RenameFile(fn);
1253 if(SaveAs(fn))
1254 break;
1255 }else
1256 break;
1257 }
1258 case CPumpKINDlg::wrqDenyAll:
1259 Deny(tftp::errAccessViolation,IDS_TFTP_ERROR_ACCESS);
1260 return TRUE;
1261 }
1262 }
1263CFileException e;
1264 if(!m_File.Open(
1265 fn,
1266 m_bResume
1267 ?(CFile::modeWrite|CFile::shareDenyWrite)
1268 :(CFile::modeCreate|CFile::modeWrite|CFile::shareDenyWrite),
1269 &e
1270 )){
1271 if(localFile){// Outgoing request
1272 CString tmp;
1273 tmp.Format(IDS_LOG_FAILEDTOOPEN,fn);
1274 m_Daddy->LogLine(tmp);
1275 return FALSE;
1276 }else{
1277 Deny(&e);
1278 return TRUE;
1279 }
1280 }
1281 if(hostName){
1282 m_HostName=hostName;
1283
1284 CString tmp;
1285 tmp.Format(IDS_LOG_REQUESTING,m_FileName,m_HostName);
1286 m_Daddy->LogLine(tmp);
1287
1288 CString inAddr = hostName;
1289 int at = inAddr.Find('@');
1290 if(at>=0)
1291 inAddr=inAddr.Mid(at+1);
1292 if((m_Peer.sin_addr.s_addr=inet_addr((LPCTSTR)inAddr))==INADDR_NONE){
1293 ASSERT(!m_wndResolver);
1294 m_wndResolver = new CResolver(this);
1295 ASSERT(m_wndResolver);
1296 return m_wndResolver->Resolve();
1297 }else{
1298 OnHostKnown();
1299 return TRUE;
1300 }
1301 }
1302CString v;
1303tftp::tftpOptions oack;
1304 if(m_Options.Lookup(tftpoTSize,v)){
1305 m_xferSize=atol(v);
1306 if(!m_xferSize){
1307 Deny(tftp::errOption,IDS_TFTP_ERROR_TSIZE);
1308 return TRUE;
1309 }
1310 }
1311 if(m_Options.Lookup(tftpoBSize,v)){
1312 m_blkSize=atoi(v);
1313 if(!m_blkSize){// *** Do more about sanity check
1314 Deny(tftp::errOption,IDS_TFTP_ERROR_BSIZE);
1315 return TRUE;
1316 }
1317 v.Format("%u",m_blkSize);
1318 oack[tftpoBSize]=v;
1319 }
1320 if(m_Options.Lookup(tftpoTOut,v)){
1321 m_timeOut=atoi(v);
1322 if(!m_timeOut){// *** Do more about sanity check
1323 Deny(tftp::errOption,IDS_TFTP_ERROR_TOUT);
1324 return TRUE;
1325 }
1326 v.Format("%u",m_timeOut);
1327 oack[tftpoTOut]=v;
1328 }
1329 if(m_Options.Lookup(tftpoXResume,v) && m_bResume){
1330 m_ACK=m_File.GetLength()/m_blkSize;
1331 v.Format("%u",m_ACK);
1332 oack[tftpoXResume]=v;
1333 }else
1334 m_ACK=0;
1335 state=stateXfer;
1336 if(oack.GetCount()){
1337 tftp *p = tftp::Allocate(tftp::tftpOACK::tftpSize(&oack));
1338 ASSERT(p);
1339 p->SetOpcode(tftp::opOACK);
1340 p->data.m_OACK.Set(&oack);
1341 PostTFTP(p,TRUE);
1342 }else
1343 DoXfer();
1344 return TRUE;
1345}
1346
1347BOOL CWRQSocket::ConfirmRequest()
1348{
1349CConfirmWRQDlg cd(NULL);
1350 cd.m_Daddy=this;
1351 cd.m_File=m_FileName;
1352 cd.m_Host=inet_ntoa(m_Peer.sin_addr);
1353 switch(cd.DoModal()){
1354 case IDOK:
1355 m_Rename=FALSE;
1356 m_bResume=FALSE;
1357 return TRUE;
1358 case IDC_RENAME:
1359 m_bResume=FALSE;
1360 m_Rename=TRUE;
1361 return TRUE;
1362 case IDC_RESUME:
1363 m_Rename=FALSE;
1364 m_bResume=TRUE;
1365 return TRUE;
1366 case IDCANCEL:
1367 return FALSE;
1368 }
1369 return FALSE;
1370}
1371
1372BOOL CWRQSocket::RenameFile(CString& fn)
1373{
1374CString renamed = fn;
1375 if(fn.IsEmpty())
1376 return FALSE;
1377 if(fn[fn.GetLength()-1]==')'){
1378 int op = fn.ReverseFind('(');
1379 if(op>0 && fn[op-1]==' '){
1380 if(fn.Mid(op+1,fn.GetLength()-op-2).SpanExcluding("0123456789").IsEmpty())
1381 renamed = renamed.Left(op-1);
1382 }
1383 }
1384CString testFN;
1385 for(UINT tmp=0;tmp<32768;tmp++){
1386 testFN.Format("%s (%u)",(LPCTSTR)renamed,tmp);
1387 if(!_access((LPCTSTR)testFN,0))
1388 continue;
1389 fn=testFN;
1390 return TRUE;
1391 }
1392 return FALSE;
1393}
1394
1395BOOL CWRQSocket::SaveAs(CString& fn)
1396{
1397CFileDialog cfd(FALSE,NULL,fn,OFN_EXPLORER|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_PATHMUSTEXIST,NULL,m_Daddy);
1398CString title;
1399 title.LoadString(IDS_RENAME_TITLE);
1400 cfd.m_ofn.lpstrTitle=(LPCTSTR)title;
1401 if(cfd.DoModal()!=IDOK)
1402 return FALSE;
1403 fn = cfd.GetPathName();
1404 return TRUE;
1405}
1406
1407void CWRQSocket::DoXfer()
1408{
1409tftp *p = tftp::Allocate(tftp::tftpACK::tftpSize());
1410 ASSERT(p);
1411 p->SetOpcode(tftp::opACK);
1412 p->data.m_ACK.SetBlock(m_ACK);
1413 TRACE1("WRQ-ACK-%u\n",m_ACK);
1414 PostTFTP(p,TRUE);// *** ??? Hope this is right
1415}
1416
1417UINT tftp::tftpACK::tftpSize()
1418{
1419 return tftpHdrSize-tftpSlackSize+sizeof(tftp::tftpACK);
1420}
1421
1422ULONG CWRQSocket::GetACK()
1423{
1424 return (m_ACK*m_blkSize)-m_LastSlack;
1425}
1426
1427void CXferSocket::ResetTimeout()
1428{
1429 ASSERT(m_Daddy);
1430 m_Daddy->m_Retrier->KillTimer(m_hSocket);
1431 if(m_Retry)
1432 m_Daddy->m_Retrier->SetTimer(m_hSocket,min(60,m_Daddy->m_RetryTimeOut.GetTotalSeconds())*1000,NULL);
1433 if(!m_bRetry){
1434 m_Daddy->KillTimer(m_hSocket);
1435 m_Daddy->SetTimer(m_hSocket,min(60,m_timeOut)*1000,NULL);
1436 }
1437}
1438
1439void CXferSocket::Abort()
1440{
1441 ASSERT(m_Daddy);
1442CString tmp;
1443 tmp.Format(IDS_LOG_XFERABORTED,(LPCTSTR)m_FileName);
1444 m_Daddy->LogLine(tmp);
1445 Destroy(FALSE);
1446}
1447
1448void CPumpKINDlg::OnTimer(UINT nIDEvent)
1449{
1450CXferSocket *socket;
1451 if(m_Xfers.Lookup(nIDEvent,socket)){
1452 CString tmp;
1453 tmp.Format(IDS_LOG_TIMEDOUT,socket->m_FileName);
1454 LogLine(tmp);
1455 socket->Abort();
1456 }else{
1457 TRACE0("Failed to find timed out socket!\n");
1458 }
1459 CDialog::OnTimer(nIDEvent);
1460}
1461
1462void CPumpKINDlg::OnExit()
1463{
1464 if(!m_Xfers.IsEmpty()){
1465 CString title,text;
1466 title.LoadString(IDS_CONFIRMEXIT_TITLE);
1467 text.LoadString(IDS_CONFIRMEXIT_TEXT);
1468 if(MessageBox(text,title,MB_ICONQUESTION|MB_YESNO)!=IDYES)
1469 return;
1470 }
1471 m_bExiting=TRUE;
1472 EndDialog(IDOK);
1473}
1474
1475void CPumpKINDlg::OnPut()
1476{
1477CRequestDlg crd(NULL);
1478 crd.m_Put=TRUE;
1479 crd.m_BSize=m_BlockSize;
1480 if(crd.DoModal()==IDOK){
1481 CRRQSocket *socket = new CRRQSocket(this,crd.m_RemoteFile,crd.m_Type,NULL);
1482 if(crd.m_BSize)
1483 socket->m__blkSize=crd.m_BSize;
1484 if(!socket->Create(crd.m_LocalFile,crd.m_Host))
1485 socket->Destroy();
1486 }
1487}
1488
1489void CPumpKINDlg::OnGet()
1490{
1491CRequestDlg crd(NULL);
1492 crd.m_Put=FALSE;
1493 crd.m_BSize=m_BlockSize;
1494 if(crd.DoModal()==IDOK){
1495 CWRQSocket *socket = new CWRQSocket(this,crd.m_RemoteFile,crd.m_Type,NULL);
1496 if(crd.m_BSize)
1497 socket->m__blkSize=crd.m_BSize;
1498 if(!socket->Create(crd.m_LocalFile,crd.m_Host))
1499 socket->Destroy();
1500 }
1501}
1502
1503void CPumpKINDlg::SetupButtons()
1504{
1505 m_AbortCtl.EnableWindow(m_List.GetSelectedCount()>0);
1506}
1507
1508void CPumpKINDlg::OnDeleteallitemsConnections(NMHDR* pNMHDR, LRESULT* pResult)
1509{
1510 NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
1511 SetupButtons();
1512 *pResult = 0;
1513}
1514
1515void CPumpKINDlg::OnDeleteitemConnections(NMHDR* pNMHDR, LRESULT* pResult)
1516{
1517 NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
1518 SetupButtons();
1519 *pResult = 0;
1520}
1521
1522void CPumpKINDlg::OnInsertitemConnections(NMHDR* pNMHDR, LRESULT* pResult)
1523{
1524 NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
1525 SetupButtons();
1526 *pResult = 0;
1527}
1528
1529void CPumpKINDlg::OnItemchangedConnections(NMHDR* pNMHDR, LRESULT* pResult)
1530{
1531 NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
1532 SetupButtons();
1533 *pResult = 0;
1534}
1535
1536void CPumpKINDlg::OnAbort()
1537{
1538 if(!m_List.GetSelectedCount())
1539 return;
1540 intitems = m_List.GetItemCount();
1541 for(int tmp=0;tmp<items;tmp++){
1542 if(!(m_List.GetItemState(tmp,LVIS_SELECTED)&LVIS_SELECTED))
1543 continue;
1544 CXferSocket *xfer = (CXferSocket*) m_List.GetItemData(tmp);
1545 ASSERT(xfer);
1546 xfer->Abort();
1547 }
1548}
1549
1550void CXferSocket::OnFailedToResolve()
1551{
1552 TRACE0("Resolve failed\n");
1553 delete m_wndResolver;
1554 m_wndResolver=NULL;
1555 ASSERT(m_Daddy);
1556CString tmp;
1557 tmp.Format(IDS_LOG_RESOLVEFAILED,m_HostName);
1558 m_Daddy->LogLine(tmp);
1559 Abort();
1560}
1561
1562void CXferSocket::OnResolved()
1563{
1564 delete m_wndResolver;
1565 m_wndResolver=NULL;
1566 TRACE0("Resolved\n");
1567 m_Peer.sin_addr.s_addr = *(DWORD*)(((hostent*)m_ResolveBuff)->h_addr);
1568}
1569
1570void CRRQSocket::OnResolved()
1571{
1572 CXferSocket::OnResolved();
1573 OnHostKnown();
1574}
1575
1576void CRRQSocket::OnHostKnown()
1577{
1578 ASSERT(m_Daddy);
1579 m_Peer.sin_port=htons(m_Daddy->m_SpeakPort);
1580tftp::tftpOptions o;
1581CString v;
1582 ASSERT(m_xferSize>=0);
1583 v.Format("%lu",m_xferSize);
1584 o[tftpoTSize] = v;
1585 ASSERT(m__blkSize);
1586 v.Format("%u",m__blkSize);
1587 o[tftpoBSize] = v;
1588 ASSERT(m__timeOut);
1589 v.Format("%u",m__timeOut);
1590 o[tftpoTOut] = v;
1591 o[tftpoXResume] = "0";
1592 tftp*p = tftp::Allocate(tftp::tftpWRQ::tftpSize(m_FileName,m_Type,&o));
1593 ASSERT(p);
1594 p->SetOpcode(tftp::opWRQ);
1595 p->data.m_WRQ.Set(m_FileName,m_Type,&o);
1596 PostTFTP(p,TRUE);
1597 state=stateInit;
1598 UpdateList();
1599}
1600
1601UINT tftp::tftpRQ::tftpSize(LPCTSTR file,LPCTSTR type,tftp::tftpOptions* ops)
1602{
1603UINT rv = tftpHdrSize-tftpSlackSize+strlen(file)+1+strlen(type)+1;
1604 if(ops){
1605 tftpOptions& o = *ops;
1606 POSITION p = o.GetStartPosition();
1607 while(p){
1608 CString n,v;
1609 o.GetNextAssoc(p,n,v);
1610 rv+=n.GetLength()+1+v.GetLength()+1;
1611 }
1612 }
1613 return rv;
1614}
1615UINT tftp::tftpRRQ::tftpSize(LPCTSTR file,LPCTSTR type,tftp::tftpOptions* ops)
1616{
1617 return tftp::tftpRQ::tftpSize(file,type,ops);
1618}
1619UINT tftp::tftpWRQ::tftpSize(LPCTSTR file,LPCTSTR type,tftp::tftpOptions* ops)
1620{
1621 return tftp::tftpRQ::tftpSize(file,type,ops);
1622}
1623UINT tftp::tftpOACK::tftpSize(tftp::tftpOptions* ops)
1624{
1625UINT rv = tftpHdrSize-tftpSlackSize;
1626 if(ops){
1627 tftpOptions& o = *ops;
1628 POSITION p = o.GetStartPosition();
1629 while(p){
1630 CString n,v;
1631 o.GetNextAssoc(p,n,v);
1632 rv+=n.GetLength()+1+v.GetLength()+1;
1633 }
1634 }
1635 return rv;
1636}
1637void tftp::tftpRQ::Set(LPCTSTR file,LPCTSTR type,tftp::tftpOptions* ops)
1638{
1639 // MAY BE DANGEROUS!
1640UINT ptr = 0;
1641 strcpy((LPTSTR)&data[ptr],file); ptr+=strlen(file)+1;
1642 strcpy((LPTSTR)&data[ptr],type); ptr+=strlen(type)+1;
1643 if(ops){
1644 tftpOptions& o = *ops;
1645 POSITION p = o.GetStartPosition();
1646 while(p){
1647 CString n,v;
1648 o.GetNextAssoc(p,n,v);
1649 strcpy((LPTSTR)&data[ptr],(LPCTSTR)n); ptr+=n.GetLength()+1;
1650 strcpy((LPTSTR)&data[ptr],(LPCTSTR)v); ptr+=v.GetLength()+1;
1651 }
1652 }
1653}
1654void tftp::tftpRRQ::Set(LPCTSTR file,LPCTSTR type,tftp::tftpOptions* ops)
1655{
1656 // MAY BE DANGEROUS!
1657UINT ptr = 0;
1658 strcpy((LPTSTR)&data[ptr],file); ptr+=strlen(file)+1;
1659 strcpy((LPTSTR)&data[ptr],type); ptr+=strlen(type)+1;
1660 if(ops){
1661 tftpOptions& o = *ops;
1662 POSITION p = o.GetStartPosition();
1663 while(p){
1664 CString n,v;
1665 o.GetNextAssoc(p,n,v);
1666 strcpy((LPTSTR)&data[ptr],(LPCTSTR)n); ptr+=n.GetLength()+1;
1667 strcpy((LPTSTR)&data[ptr],(LPCTSTR)v); ptr+=v.GetLength()+1;
1668 }
1669 }
1670}
1671void tftp::tftpWRQ::Set(LPCTSTR file,LPCTSTR type,tftp::tftpOptions* ops)
1672{
1673 // MAY BE DANGEROUS!
1674UINT ptr = 0;
1675 strcpy((LPTSTR)&data[ptr],file); ptr+=strlen(file)+1;
1676 strcpy((LPTSTR)&data[ptr],type); ptr+=strlen(type)+1;
1677 if(ops){
1678 tftpOptions& o = *ops;
1679 POSITION p = o.GetStartPosition();
1680 while(p){
1681 CString n,v;
1682 o.GetNextAssoc(p,n,v);
1683 strcpy((LPTSTR)&data[ptr],(LPCTSTR)n); ptr+=n.GetLength()+1;
1684 strcpy((LPTSTR)&data[ptr],(LPCTSTR)v); ptr+=v.GetLength()+1;
1685 }
1686 }
1687}
1688void tftp::tftpOACK::Set(tftpOptions* ops)
1689{
1690 ASSERT(ops);
1691UINT ptr = 0;
1692tftpOptions& o = *ops;
1693POSITION p = o.GetStartPosition();
1694 while(p){
1695 CString n,v;
1696 o.GetNextAssoc(p,n,v);
1697 strcpy((LPTSTR)&data[ptr],(LPCTSTR)n); ptr+=n.GetLength()+1;
1698 strcpy((LPTSTR)&data[ptr],(LPCTSTR)v); ptr+=v.GetLength()+1;
1699 }
1700}
1701
1702void CWRQSocket::OnResolved()
1703{
1704 CXferSocket::OnResolved();
1705 OnHostKnown();
1706}
1707
1708void CWRQSocket::OnHostKnown()
1709{
1710 ASSERT(m_Daddy);
1711 m_Peer.sin_port=htons(m_Daddy->m_SpeakPort);
1712tftp::tftpOptions o;
1713CString v;
1714 o[tftpoTSize]="0";
1715 if(m__blkSize){
1716 v.Format("%u",m__blkSize);
1717 o[tftpoBSize]=v;
1718 }
1719 if(m__timeOut){
1720 v.Format("%u",m__timeOut);
1721 o[tftpoTOut]=v;
1722 }
1723 tftp*p = tftp::Allocate(tftp::tftpRRQ::tftpSize(m_FileName,m_Type,&o));
1724 ASSERT(p);
1725 p->SetOpcode(tftp::opRRQ);
1726 p->data.m_RRQ.Set(m_FileName,m_Type,&o);
1727 PostTFTP(p,TRUE);
1728 state=stateInit;
1729 UpdateList();
1730}
1731
1732void CPumpKINDlg::OnClose()
1733{
1734 OnTrayShowpumpkinwindow();
1735}
1736
1737void CPumpKINDlg::OnTrayShowpumpkinwindow()
1738{
1739 if(IsWindowVisible()){
1740 m_bShown=FALSE;
1741 ShowWindow(SW_HIDE);
1742 }else{
1743 m_bShown=TRUE;
1744 ShowWindow(SW_SHOW);
1745 SetForegroundWindow();
1746 SetFocus();
1747 }
1748}
1749
1750void CPumpKINDlg::OnTrayExit()
1751{
1752 OnExit();
1753}
1754
1755void CPumpKINDlg::OnTrayAboutpumpkin()
1756{
1757CAboutDlg dlgAbout;
1758 dlgAbout.DoModal();
1759}
1760
1761void CPumpKINDlg::OnTrayFetchfile()
1762{
1763 OnGet();
1764}
1765
1766void CPumpKINDlg::OnTrayHelp()
1767{
1768 OnHelp();
1769}
1770
1771void CPumpKINDlg::OnTrayOptions()
1772{
1773 OnOptions();
1774}
1775
1776void CPumpKINDlg::OnTraySendfile()
1777{
1778 OnPut();
1779}
1780
1781void CPumpKINDlg::LoadSettings()
1782{
1783CWinApp *app = AfxGetApp();
1784 ASSERT(app);
1785 m_bnwRequest=app->GetProfileString("BellsNWhistles","Request",m_bnwRequest);
1786 m_bnwSuccess=app->GetProfileString("BellsNWhistles","Success",m_bnwSuccess);
1787 m_bnwAbort=app->GetProfileString("BellsNWhistles","Abort",m_bnwAbort);
1788 m_bTFTPSubdirs=app->GetProfileInt("TFTPSettings","Subdirs",m_bTFTPSubdirs);
1789 m_ListenPort=app->GetProfileInt("TFTPSettings","ListenPort",m_ListenPort);
1790 m_LogLength=app->GetProfileInt("UISettings","LogLength",m_LogLength);
1791 m_PromptTimeOut=app->GetProfileInt("UISettings","PromptTimeout",m_PromptTimeOut);
1792 m_RRQMode=app->GetProfileInt("TFTPSettings","RRQMode",m_RRQMode);
1793 m_SpeakPort=app->GetProfileInt("TFTPSettings","SpeakPort",m_SpeakPort);
1794 m_TFTPRoot=app->GetProfileString("TFTPSettings","TFTPRoot",m_TFTPRoot);
1795 m_TFTPTimeOut=CTimeSpan(app->GetProfileInt("TFTPSettings","TFTPTimeout",m_TFTPTimeOut.GetTotalSeconds()));
1796 m_BlockSize=app->GetProfileInt("TFTPSettings","TFTPBlockSize",m_BlockSize);
1797 m_RetryTimeOut=CTimeSpan(app->GetProfileInt("TFTPSettings","RetryTimeout",m_RetryTimeOut.GetTotalSeconds()));
1798 m_WRQMode=app->GetProfileInt("TFTPSettings","WRQMode",m_WRQMode);
1799 m_bShown=app->GetProfileInt("UISettings","Visble",m_bShown);
1800 if(m_TFTPRoot.IsEmpty()){
1801 DWORD dL = ::GetCurrentDirectory(0,NULL);
1802 VERIFY(::GetCurrentDirectory(dL,m_TFTPRoot.GetBuffer(dL)));
1803 m_TFTPRoot.ReleaseBuffer();
1804 }
1805 ::SetCurrentDirectory(m_TFTPRoot);
1806}
1807
1808void CPumpKINDlg::SaveSettings()
1809{
1810CWinApp *app = AfxGetApp();
1811 ASSERT(app);
1812 app->WriteProfileString("BellsNWhistles","Request",m_bnwRequest);
1813 app->WriteProfileString("BellsNWhistles","Success",m_bnwSuccess);
1814 app->WriteProfileString("BellsNWhistles","Abort",m_bnwAbort);
1815 app->WriteProfileInt("TFTPSettings","Subdirs",m_bTFTPSubdirs);
1816 app->WriteProfileInt("TFTPSettings","ListenPort",m_ListenPort);
1817 app->WriteProfileInt("UISettings","LogLength",m_LogLength);
1818 app->WriteProfileInt("UISettings","PromptTimeout",m_PromptTimeOut);
1819 app->WriteProfileInt("TFTPSettings","RRQMode",m_RRQMode);
1820 app->WriteProfileInt("TFTPSettings","SpeakPort",m_SpeakPort);
1821 app->WriteProfileString("TFTPSettings","TFTPRoot",m_TFTPRoot);
1822 app->WriteProfileInt("TFTPSettings","TFTPTimeout",m_TFTPTimeOut.GetTotalSeconds());
1823 app->WriteProfileInt("TFTPSettings","TFTPBlockSize",m_BlockSize);
1824 app->WriteProfileInt("TFTPSettings","RetryTimeout",m_RetryTimeOut.GetTotalSeconds());
1825 app->WriteProfileInt("TFTPSettings","WRQMode",m_WRQMode);
1826 app->WriteProfileInt("UISettings","Visble",m_bShown);
1827}
1828
1829void CPumpKINDlg::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos)
1830{
1831 CDialog::OnWindowPosChanging(lpwndpos);
1832 if(!m_bExiting){
1833 if(m_bShown){
1834 lpwndpos->flags&=~SWP_HIDEWINDOW;
1835 lpwndpos->flags|=SWP_SHOWWINDOW;
1836 }else{
1837 lpwndpos->flags&=~SWP_SHOWWINDOW;
1838 lpwndpos->flags|=SWP_HIDEWINDOW;
1839 if(::GetForegroundWindow()==m_hWnd && (m_Trayer && !m_Trayer->m_inMenu))
1840 GetDesktopWindow()->SetForegroundWindow();
1841 }
1842 }
1843}
1844
1845CString CXferSocket::ApplyRootGently(LPCTSTR fn)
1846{
1847CString f = fn;
1848CString rv = f;
1849 if((!f.IsEmpty()) && f[0]!='\\' && f.Find(":")<0 && f.Find("\\")<0)
1850 rv = ApplyRoot(f);
1851 return rv;
1852}
1853
1854BOOL CXferSocket::CheckBadRelativeness(LPCTSTR file)
1855{
1856CString tmp = file;
1857 if(tmp.IsEmpty())
1858 return FALSE;
1859 if(tmp.Find("..")>=0)
1860 return TRUE;
1861 if(tmp.Find(":")>=0)
1862 return TRUE;
1863 if((!m_Daddy->m_bTFTPSubdirs) && m_FileName.Find('\\')>=0)
1864 return TRUE;
1865 return FALSE;
1866}
1867
1868void CAboutDlg::OnKlevernet()
1869{
1870CString url;
1871 url.LoadString(IDS_KLEVERNET_URL);
1872 ShellExecute(::GetDesktopWindow(),"open",url,NULL,NULL,SW_SHOWMAXIMIZED);
1873}
1874
1875BOOL CPumpKINDlg::PreTranslateMessage(MSG* pMsg)
1876{
1877 // CG: The following block was added by the ToolTips component.
1878 {
1879 // Let the ToolTip process this message.
1880 m_tooltip.RelayEvent(pMsg);
1881
1882 return CDialog::PreTranslateMessage(pMsg);
1883 }
1884}
1885
1886void CPumpKINDlg::OnSelchangeLog()
1887{
1888int sel = m_Log.GetCurSel();
1889 if(sel==LB_ERR){
1890 TRACE0("Error retrieving selection\n");
1891 }else{
1892 CTime *t = (CTime*)m_Log.GetItemData(sel);
1893 ASSERT(t);
1894 m_tooltip.UpdateTipText(t->Format(IDS_LOGTIMEFORMAT),&m_Log);
1895 }
1896}
1897
1898void CPumpKINDlg::OnTrayOpenfilesfolder()
1899{
1900 ShellExecute(::GetDesktopWindow(),NULL,m_TFTPRoot,NULL,NULL,SW_SHOWDEFAULT);
1901}
1902
1903void CPumpKINDlg::OnDropFiles(HDROP hDropInfo)
1904{
1905UINT files = ::DragQueryFile(hDropInfo,0xFFFFFFFF,NULL,0);
1906 ASSERT(files);
1907 for(UINT file=0;file<files;file++){
1908 CString theFile;
1909 UINT fileNameLength = ::DragQueryFile(hDropInfo,file,NULL,0);
1910 ASSERT(fileNameLength);
1911 VERIFY(::DragQueryFile(hDropInfo,file,theFile.GetBuffer(fileNameLength+5),fileNameLength+4)<=fileNameLength);
1912 theFile.ReleaseBuffer();
1913 // Send it over!
1914 CRequestDlg crd(NULL);
1915 crd.m_Drop=TRUE;
1916 crd.m_Put=TRUE;
1917 crd.m_BSize=m_BlockSize;
1918 crd.m_LocalFile=theFile;
1919 if(crd.DoModal()==IDOK){
1920 CRRQSocket *socket = new CRRQSocket(this,crd.m_RemoteFile,crd.m_Type,NULL);
1921 if(crd.m_BSize)
1922 socket->m__blkSize=crd.m_BSize;
1923 if(!socket->Create(crd.m_LocalFile,crd.m_Host))
1924 socket->Destroy();
1925 }
1926 }
1927 ::DragFinish(hDropInfo);
1928}
1929
1930void CPumpKINDlg::OnCancel()
1931{
1932 OnClose();
1933}
1934
1935CPumpKINDlg::~CPumpKINDlg()
1936{
1937 delete m_Trayer;
1938 delete m_Retrier;
1939}
1940
1941void CXferSocket::OnRetry()
1942{
1943 if(!m_Retry){
1944 TRACE("Retrying unretriable..\n");
1945 return;
1946 }
1947 TRACE0("Retrying..\n");
1948 m_bRetry=TRUE;
1949 PostTFTP(tftp::Copy(m_Retry));
1950 m_bRetry=FALSE;
1951}
1952
1953tftp* tftp::Copy(tftp *src)
1954{
1955 ASSERT(src);
1956 ASSERT(src->length);
1957tftp* rv = Allocate(src->length);
1958 ASSERT(rv);
1959 memmove(rv,src,tftpSlackSize+src->length);
1960 return rv;
1961}
1962
1963void CXferSocket::SetTry(tftp *p)
1964{
1965 if(m_Retry)
1966 delete m_Retry;
1967 m_Retry=p?tftp::Copy(p):NULL;
1968}
1969
1970void CPumpKINDlg::OnHelp()
1971{
1972 AfxGetApp()->WinHelp(0,HELP_FINDER);
1973}
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 @@
1// PumpKINDlg.h : header file
2//
3
4 //#define REVERSEBYTES(w)MAKEWORD(HIBYTE(w),LOBYTE(w));
5 #defineREVERSEBYTES(w) (htons((WORD)w))
6 #define tftpoBSize"blksize"
7 #define tftpoTSize"tsize"
8 #define tftpoTOut"timeout"
9
10 #define tftpoXResume"x-resume"
11
12 struct tftp{
13 typedef CMapStringToString tftpOptions;
14 typedef WORD tftpLength;
15 typedef WORD tftpOpcode;
16 tftpLengthlength;
17 tftpOpcode opcode;
18 enum{
19 opRRQ = 1,
20 opWRQ = 2,
21 opDATA = 3,
22 opACK = 4,
23 opERROR = 5,
24 opOACK = 6,
25
26 errUndefined = 0,
27 errNotFound = 1,
28 errAccessViolation = 2,
29 errDiskFull = 3,
30 errIllegalOp = 4,
31 errUnknownTID = 5,
32 errFileExists = 6,
33 errNoUser = 7,
34 errOption = 8
35 };
36 structtftpUNKNOWN {
37 BYTE data[1];
38 };
39 structtftpRQ {
40 BYTE data[1];
41public:
42 void Set(LPCTSTR file,LPCTSTR type,tftpOptions* ops=NULL);
43 static UINT tftpSize(LPCTSTR file,LPCTSTR type,tftpOptions* ops=NULL);
44 };
45 structtftpRRQ {
46 BYTE data[1];
47public:
48 void Set(LPCTSTR file,LPCTSTR type,tftpOptions* ops=NULL);
49 static UINT tftpSize(LPCTSTR file,LPCTSTR type,tftpOptions* ops=NULL);
50 };
51 structtftpWRQ {
52 BYTE data[1];
53public:
54 void Set(LPCTSTR file,LPCTSTR type,tftpOptions* ops=NULL);
55 static UINT tftpSize(LPCTSTR file,LPCTSTR type,tftpOptions* ops=NULL);
56 };
57 structtftpDATA {
58 WORD block;
59 BYTE data[1];
60 public:
61 WORD Block();
62 void SetBlock(WORD b);
63 static UINT tftpSize(UINT blkSize=512);
64 };
65 struct tftpACK {
66 WORD block;
67 public:
68 static UINT tftpSize();
69 void SetBlock(WORD b);
70 WORD Block();
71 };
72 structtftpERROR {
73 typedef WORD tftpErrorCode;
74 tftpErrorCode code;
75 BYTE data[1];
76 public:
77 void SetCode(WORD c);
78 WORD Code();
79 static UINT tftpSize(LPCTSTR msg);
80 };
81 struct tftpOACK {
82 BYTE data[1];
83 public:
84 void Set(tftpOptions* ops);
85 static UINT tftpSize(tftpOptions* ops);
86 };
87 uniontftpPacket {
88 tftpUNKNOWN m_UNKNOWN;
89 tftpRQ m_RQ;
90 tftpRRQ m_RRQ;
91 tftpWRQ m_WRQ;
92 tftpDATA m_DATA;
93 tftpACK m_ACK;
94 tftpERROR m_ERROR;
95 tftpOACK m_OACK;
96 }data;
97
98 void *udpBase(void){ return &opcode; }
99public:
100 static tftp* Copy(tftp *src);
101 CString errMessage();
102 void SetOpcode(WORD op);
103 void errSet(UINT code,LPCTSTR msg);
104 static tftp* Allocate(UINT tftpSize=0);
105 BOOL Send(CAsyncSocket *socket,SOCKADDR_IN* saddr);
106 CString rqType();
107 CString rqFileName();
108 UINT GetOptions(tftpOptions* ops);
109 tftp();
110 UINT Opcode();
111 BOOL Receive(CAsyncSocket* socket,UINT maxLength,SOCKADDR_IN *sin=NULL);
112};
113 #define tftpHdrSize(sizeof(tftp)-sizeof(tftp::tftpPacket))
114 #definetftpSlackSize sizeof(tftp::tftpLength)
115
116class CPumpKINDlg;
117 class CListenSocket : public CAsyncSocket{
118public:
119 virtual void OnReceive(int nErrorCode);
120 CPumpKINDlg* m_Daddy;
121};
122
123 typedef CList<tftp*,tftp*>CTFTPList;
124class CResolver;
125 class CXferSocket : public CAsyncSocket{
126public:
127 UINT m__timeOut;
128 UINT m__blkSize;
129 tftp::tftpOptions m_Options;
130 LONG m_xferSize;
131 UINT m_timeOut;
132 UINT m_blkSize;
133 BOOL m_bRetry;
134 void SetTry(tftp *p=NULL);
135 tftp* m_Retry;
136 void OnRetry();
137 BOOL CheckBadRelativeness(LPCTSTR file);
138 CString ApplyRootGently(LPCTSTR fn);
139 CString m_HostName;
140 virtual void OnResolved();
141 virtual void OnFailedToResolve();
142 CResolver *m_wndResolver;
143 BYTE m_ResolveBuff[MAXGETHOSTSTRUCT];
144 virtual void Abort();
145 void ResetTimeout();
146 enum{
147 stateNone, stateDeny, stateInit, stateOACK, stateXfer, stateFinish, stateClosing
148 };
149 int state;
150 void Deny(UINT errCode,UINT errID);
151 void Deny(CFileException* e);
152 CString ApplyRoot(LPCTSTR fileName);
153 void TurnSlashes(CString& fn,BOOL bBack=TRUE);
154 virtual void Destroy(BOOL success=TRUE);
155 void PostError(CFileException* e);
156 void PostError(UINT errCode,UINT errID);
157 void PostTFTP(tftp* p,BOOL retryable=FALSE);
158 CXferSocket(CPumpKINDlg *daddy,LPCTSTR fileName,LPCTSTR type,SOCKADDR_IN* sin);
159 CFile m_File;
160 virtual ULONG GetACK();
161 CString m_Type;
162 CString m_FileName;
163 CXferSocket();
164 void UpdateList();
165 void SetPeer(SOCKADDR_IN *sin);
166 virtual BOOL OnTFTP(tftp* p) = 0;
167 virtual void OnReceive(int nErrorCode);
168 void DoSelect();
169 SOCKADDR_IN m_Peer;
170 virtual void OnSend(int nErrorCode);
171 CPumpKINDlg* m_Daddy;
172 CTFTPList m_Queue;
173
174 DECLARE_DYNAMIC(CXferSocket)
175};
176class CWRQSocket : public CXferSocket {
177public:
178 BOOL m_bResume;
179 void OnHostKnown();
180 virtual void OnResolved();
181 UINT m_LastSlack;
182 ULONG GetACK();
183 void DoXfer();
184 UINT m_ACK;
185 BOOL SaveAs(CString& fn);
186 BOOL RenameFile(CString& fn);
187 BOOL m_Rename;
188 BOOL ConfirmRequest();
189 BOOL Create(LPCTSTR localFile=NULL,LPCTSTR hostName=NULL);
190 CWRQSocket(CPumpKINDlg* daddy,LPCTSTR fileName,LPCTSTR type,SOCKADDR_IN *sin);
191 BOOL OnTFTP(tftp* p);
192
193 DECLARE_DYNAMIC(CWRQSocket)
194};
195class CRRQSocket : public CXferSocket {
196public:
197 void OnHostKnown();
198 virtual void OnResolved();
199 BOOL ConfirmRequest();
200 WORD m_LastSlack;
201 UINT m_ACK;
202 BOOL OnTFTP(tftp* p);
203 ULONG GetACK(void);
204 void DoXfer();
205 CRRQSocket(CPumpKINDlg *daddy,LPCTSTR fileName,LPCTSTR type,SOCKADDR_IN *sin);
206 BOOL Create(LPCTSTR localFile=NULL,LPCTSTR hostName=NULL);
207
208 DECLARE_DYNAMIC(CRRQSocket)
209};
210
211 typedef CMap<SOCKET,SOCKET,CXferSocket*,CXferSocket*>CTIDMap;
212typedef CMap<CTime*,CTime*,CTime*,CTime*> CTimeMap;
213
214/////////////////////////////////////////////////////////////////////////////
215// CPumpKINDlg dialog
216
217class CTrayer;
218class CRetrier;
219class CPumpKINDlg : public CDialog
220{
221// Construction
222public:
223 CString m_bnwRequest;
224 CString m_bnwSuccess;
225 CString m_bnwAbort;
226 CBellsNWhistles m_bnw;
227 CTrayer *m_Trayer;
228 CTimeSpan m_RetryTimeOut;
229 virtual ~CPumpKINDlg();
230 CRetrier* m_Retrier;
231 virtual BOOL PreTranslateMessage(MSG* pMsg);
232 BOOL m_bShown;
233 BOOL m_bExiting;
234 void SaveSettings();
235 void LoadSettings();
236 void SetupButtons();
237 BITMAP m_bitmapBack;
238 CBitmap m_bmpBack;
239 UINT m_PromptTimeOut;
240 UINT m_SpeakPort;
241 void LogLine(UINT msgID);
242 CTimeMap m_LogTimes;
243 void LogLine(LPCTSTR str);
244 int m_LogLength;
245 enum{
246 subitemFile=0, subitemType, subitemPeer, subitemBytes, subitemTSize
247 };
248 int m_iWRQ;
249 int m_iRRQ;
250 CImageList m_Images;
251 CTIDMap m_Xfers;
252 CTimeSpan m_TFTPTimeOut;
253 enum{
254 rrqGiveAll=0,
255 rrqAlwaysConfirm,
256 rrqDenyAll
257 };
258 enum{
259 wrqTakeAll=0,
260 wrqConfirmIfExists,
261 wrqAlwaysConfirm,
262 wrqDenyAll
263 };
264 UINT m_RRQMode;
265 UINT m_WRQMode;
266 BOOL m_bTFTPSubdirs;
267 CString m_TFTPRoot;
268 UINT m_ListenPort;
269 UINT m_BlockSize;
270 CListenSocket m_Listener;
271 CPumpKINDlg(CWnd* pParent = NULL);// standard constructor
272
273// Dialog Data
274 //{{AFX_DATA(CPumpKINDlg)
275 enum { IDD = IDD_PUMPKIN_DIALOG };
276 CButtonm_AbortCtl;
277 CButtonm_OptionsCtl;
278 CListBoxm_Log;
279 CListCtrlm_List;
280 //}}AFX_DATA
281
282 // ClassWizard generated virtual function overrides
283 //{{AFX_VIRTUAL(CPumpKINDlg)
284 protected:
285 virtual void DoDataExchange(CDataExchange* pDX);// DDX/DDV support
286 //}}AFX_VIRTUAL
287
288// Implementation
289protected:
290 CToolTipCtrl m_tooltip;
291 HICON m_hIcon;
292
293 // Generated message map functions
294 //{{AFX_MSG(CPumpKINDlg)
295 virtual BOOL OnInitDialog();
296 afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
297 afx_msg void OnDestroy();
298 afx_msg void OnPaint();
299 afx_msg HCURSOR OnQueryDragIcon();
300 afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
301 afx_msg void OnOptions();
302 afx_msg void OnTimer(UINT nIDEvent);
303 afx_msg void OnExit();
304 afx_msg void OnPut();
305 afx_msg void OnGet();
306 afx_msg void OnDeleteallitemsConnections(NMHDR* pNMHDR, LRESULT* pResult);
307 afx_msg void OnDeleteitemConnections(NMHDR* pNMHDR, LRESULT* pResult);
308 afx_msg void OnInsertitemConnections(NMHDR* pNMHDR, LRESULT* pResult);
309 afx_msg void OnItemchangedConnections(NMHDR* pNMHDR, LRESULT* pResult);
310 afx_msg void OnAbort();
311 afx_msg void OnClose();
312 afx_msg void OnTrayShowpumpkinwindow();
313 afx_msg void OnTrayExit();
314 afx_msg void OnTrayAboutpumpkin();
315 afx_msg void OnTrayFetchfile();
316 afx_msg void OnTrayHelp();
317 afx_msg void OnTrayOptions();
318 afx_msg void OnTraySendfile();
319 afx_msg void OnWindowPosChanging(WINDOWPOS FAR* lpwndpos);
320 afx_msg void OnSelchangeLog();
321 afx_msg void OnTrayOpenfilesfolder();
322 afx_msg void OnDropFiles(HDROP hDropInfo);
323 virtual void OnCancel();
324 afx_msg void OnHelp();
325 //}}AFX_MSG
326 DECLARE_MESSAGE_MAP()
327};
diff --git a/README b/README
new file mode 100644
index 0000000..fbdfd9c
--- a/dev/null
+++ b/README
@@ -0,0 +1,33 @@
1
2Before compiling canned install executable the following files should be placed
3in the build tree:
4
5redist/mfc42.dl_
6
7Release checklist:
8 (These are tags stored in KTAGS file. please, keep in sync. Use vim to
9 jump to these tags. I haven't tried it on windows, though).
10
11 |help-news| - Release notes in help file
12
13Version number in the following places:
14
15 |about-version| - About box
16 |vsinfo-numeric-version| - VERSIONINFO numerical File&Prod V
17 |vsinfo-string-version| - VERSIONINFO string File&Prod V
18 |install-version| - Version used in install
19 |install-vsinfo-numeric-version|- install's VERSIONINFO block
20 |install-vsinfo-string-version| - install's VERSIONINFO block
21
22If the year flips check these:
23
24 |about-date| - About box
25 |help-license-date| - license in help file
26 |license-date| - license in COPYING file
27 |vsinfo-date| - Copyright in VERSIONINFO block
28 |install-vsinfo-date| - Copyright in install's VERSIONINFO
29 block
30
31
32This is for vim (don't remove):
33 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 @@
1// RequestDlg.cpp : implementation file
2//
3
4#include "stdafx.h"
5#include "PumpKIN.h"
6#include "RequestDlg.h"
7
8#ifdef _DEBUG
9#define new DEBUG_NEW
10#undef THIS_FILE
11static char THIS_FILE[] = __FILE__;
12#endif
13
14/////////////////////////////////////////////////////////////////////////////
15// CRequestDlg dialog
16
17
18CRequestDlg::CRequestDlg(CWnd* pParent /*=NULL*/)
19 : CDialog(CRequestDlg::IDD, pParent)
20{
21 m_Put=TRUE;
22 m_Drop=FALSE;
23 //{{AFX_DATA_INIT(CRequestDlg)
24 m_Host = m_MRUHost;
25 m_LocalFile = _T("");
26 m_RemoteFile = _T("");
27 m_Type = _T("octet");
28 m_strBSize = _T("");
29 //}}AFX_DATA_INIT
30}
31
32
33void CRequestDlg::DoDataExchange(CDataExchange* pDX)
34{
35 CDialog::DoDataExchange(pDX);
36 if(!pDX->m_bSaveAndValidate)
37 m_strBSize.Format("%u",m_BSize);
38 //{{AFX_DATA_MAP(CRequestDlg)
39 DDX_Control(pDX, IDC_REMOTEFILE, m_RemoteFileCtl);
40 DDX_Control(pDX, IDC_LOCALFILE, m_LocalFileCtl);
41 DDX_Control(pDX, IDC_REFRESH, m_RefreshCtl);
42 DDX_Control(pDX, IDOK, m_OKCtl);
43 DDX_Control(pDX, IDC_TALKS, m_TalksCtl);
44 DDX_Control(pDX, IDC_BROWSE, m_BrowseCtl);
45 DDX_CBString(pDX, IDC_TALKS, m_Host);
46 DDX_Text(pDX, IDC_LOCALFILE, m_LocalFile);
47 DDX_Text(pDX, IDC_REMOTEFILE, m_RemoteFile);
48 DDX_CBString(pDX, IDC_TYPE, m_Type);
49 DDX_CBString(pDX, IDC_BSIZE, m_strBSize);
50 //}}AFX_DATA_MAP
51 if(pDX->m_bSaveAndValidate)
52 m_BSize=atoi(m_strBSize);
53}
54
55CString CRequestDlg::m_MRUHost;
56
57BEGIN_MESSAGE_MAP(CRequestDlg, CDialog)
58 //{{AFX_MSG_MAP(CRequestDlg)
59 ON_BN_CLICKED(IDC_REFRESH, OnRefresh)
60 ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
61 ON_EN_CHANGE(IDC_LOCALFILE, OnChangeLocalfile)
62 ON_EN_CHANGE(IDC_REMOTEFILE, OnChangeRemotefile)
63 ON_CBN_EDITCHANGE(IDC_TALKS, OnEditchangeTalks)
64 ON_CBN_SELCHANGE(IDC_TALKS, OnSelchangeTalks)
65 ON_WM_CTLCOLOR()
66 ON_WM_DROPFILES()
67 //}}AFX_MSG_MAP
68END_MESSAGE_MAP()
69
70/////////////////////////////////////////////////////////////////////////////
71// CRequestDlg message handlers
72
73BOOL CRequestDlg::OnInitDialog()
74{
75 CDialog::OnInitDialog();
76
77 m_RefreshCtl.SendMessage(WM_SETFONT,(WPARAM)::GetStockObject(ANSI_FIXED_FONT),0);
78 m_BrowseCtl.SetIcon(AfxGetApp()->LoadIcon(IDI_BROWSE));
79
80CString title;
81 title.LoadString(m_Put?IDS_TITLE_PUTREQUEST:IDS_TITLE_GETREQUEST);
82 SetWindowText(title);
83 UpdateOK();
84 SyncNames();
85 BringWindowToTop();
86 SetForegroundWindow();
87 OnRefresh();
88 if(!m_MRUHost.IsEmpty())
89 m_TalksCtl.SetWindowText(m_MRUHost);
90 else{
91 if(m_TalksCtl.GetCount()==1){
92 CString tmp;
93 m_TalksCtl.GetLBText(0,tmp);
94 m_TalksCtl.SetWindowText(tmp);
95 }
96 }
97
98 // CG: The following block was added by the ToolTips component.
99 {
100 // Create the ToolTip control.
101 m_tooltip.Create(this);
102 m_tooltip.Activate(TRUE);
103
104 m_tooltip.AddTool(&m_BrowseCtl,IDC_BROWSE);
105 m_tooltip.AddTool(&m_RefreshCtl,IDC_REFRESH);
106 }
107
108 if(m_Put)
109 DragAcceptFiles();
110
111 if(m_Drop || !m_Put){
112 m_RemoteFileCtl.SetFocus();
113 return FALSE;
114 }
115
116 return TRUE; // return TRUE unless you set the focus to a control
117 // EXCEPTION: OCX Property Pages should return FALSE
118}
119
120void CRequestDlg::OnRefresh()
121{
122 m_TalksCtl.ResetContent();
123CWnd *wnd = CWnd::FindWindow(NULL,NULL);
124CString wtalkHead,wtalkAt;
125 wtalkHead.LoadString(IDS_WTALKHEADING);wtalkAt.LoadString(IDS_WTALKAT);
126CString otalxHead,otalxAt;
127 otalxHead.LoadString(IDS_OTALXHEADING);otalxAt.LoadString(IDS_OTALXAT);
128 while(wnd){
129 CString text;
130 wnd->GetWindowText(text);
131 int tw = text.Find(wtalkHead);
132 if(tw==0){
133 text=text.Mid(wtalkHead.GetLength());
134 int at = text.Find(wtalkAt);
135 if(at>=0){
136 if(text.GetLength()>(at+wtalkAt.GetLength())){
137 text=text.Left(at)+'@'+text.Mid(at+wtalkAt.GetLength());
138 text.TrimLeft();
139 text.TrimRight();
140 VERIFY(m_TalksCtl.AddString(text)>=0);
141 }
142 }
143 }else{
144 tw = text.Find(otalxHead);
145 if(tw==0){
146 text=text.Mid(otalxHead.GetLength());
147 int at = text.Find(otalxAt);
148 if(at>=0){
149 if(text.GetLength()>(at+otalxAt.GetLength())){
150 text=text.Left(at)+'@'+text.Mid(at+otalxAt.GetLength());
151 text.TrimLeft();
152 text.TrimRight();
153 VERIFY(m_TalksCtl.AddString(text)>=0);
154 }
155 }
156 }
157 }
158 wnd = wnd->GetNextWindow();
159 }
160 UpdateOK();
161}
162
163void CRequestDlg::OnBrowse()
164{
165 UpdateData(TRUE);
166CFileDialog cfd(m_Put,NULL,m_LocalFile.IsEmpty()?NULL:m_LocalFile,OFN_EXPLORER|OFN_HIDEREADONLY|OFN_PATHMUSTEXIST|(m_Put?OFN_FILEMUSTEXIST:OFN_OVERWRITEPROMPT),NULL,this);
167CString title;
168 title.LoadString(IDS_TITLE_BROWSEFILE);
169 cfd.m_ofn.lpstrTitle=(LPCTSTR)title;
170 if(cfd.DoModal()==IDOK){
171 m_LocalFile=cfd.GetPathName();
172 UpdateData(FALSE);
173 SyncNames();
174 UpdateOK();
175 }
176}
177
178void CRequestDlg::SyncNames()
179{
180 if(m_Put){
181 CString tmp;
182 m_LocalFileCtl.GetWindowText(tmp);
183 int s=tmp.ReverseFind('\\');
184 if(s>=0)
185 tmp=tmp.Mid(s+1);
186 else{
187 s = tmp.ReverseFind('/');
188 if(s>=0)
189 tmp=tmp.Mid(s+1);
190 }
191 if(!tmp.IsEmpty())
192 m_RemoteFileCtl.SetWindowText(tmp);
193 }else{
194 CString tmp;
195 m_RemoteFileCtl.GetWindowText(tmp);
196 int s=tmp.ReverseFind('\\');
197 if(s>=0)
198 tmp=tmp.Mid(s+1);
199 else{
200 s = tmp.ReverseFind('/');
201 if(s>=0)
202 tmp=tmp.Mid(s+1);
203 }
204 if(!tmp.IsEmpty())
205 m_LocalFileCtl.SetWindowText(tmp);
206 }
207}
208
209void CRequestDlg::OnChangeLocalfile()
210{
211 if(m_Put)
212 SyncNames();
213 UpdateOK();
214}
215
216void CRequestDlg::OnChangeRemotefile()
217{
218 if(!m_Put)
219 SyncNames();
220 UpdateOK();
221}
222
223void CRequestDlg::UpdateOK()
224{
225CString t;
226 m_LocalFileCtl.GetWindowText(t);
227 if(t.IsEmpty())
228 gotodAble;
229 m_RemoteFileCtl.GetWindowText(t);
230 if(t.IsEmpty())
231 goto dAble;
232 m_TalksCtl.GetWindowText(t);
233 if(t.IsEmpty())
234 goto dAble;
235 m_OKCtl.EnableWindow(TRUE);
236 return;
237dAble:
238 m_OKCtl.EnableWindow(FALSE);
239}
240
241void CRequestDlg::OnEditchangeTalks()
242{
243 UpdateOK();
244}
245
246void CRequestDlg::OnSelchangeTalks()
247{
248 UpdateOK();
249}
250
251HBRUSH CRequestDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
252{
253 HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
254 UpdateOK();
255 return hbr;
256}
257
258BOOL CRequestDlg::PreTranslateMessage(MSG* pMsg)
259{
260 // CG: The following block was added by the ToolTips component.
261 {
262 // Let the ToolTip process this message.
263 if(::IsWindow(m_tooltip.m_hWnd))
264 m_tooltip.RelayEvent(pMsg);
265
266 return CDialog::PreTranslateMessage(pMsg);
267 }
268}
269
270int CRequestDlg::DoModal()
271{
272int rv = CDialog::DoModal();
273 if(rv==IDOK)
274 m_MRUHost=m_Host;
275 return rv;
276}
277
278void CRequestDlg::OnDropFiles(HDROP hDropInfo)
279{
280UINT files = ::DragQueryFile(hDropInfo,0xFFFFFFFF,NULL,0);
281 if(files!=1){
282 CString title,text;
283 title.LoadString(IDS_DROPFILES_TITLE);
284 text.LoadString(IDS_NOMULTIPLEDROP_TEXT);
285 if(MessageBox(text,title,MB_ICONSTOP|MB_OKCANCEL)!=IDOK){
286 ::DragFinish(hDropInfo);
287 return;
288 }
289 }
290 ASSERT(files);
291CString theFile;
292UINT fileNameLength = ::DragQueryFile(hDropInfo,0,NULL,0);
293 ASSERT(fileNameLength);
294 VERIFY(::DragQueryFile(hDropInfo,0,theFile.GetBuffer(fileNameLength+5),fileNameLength+4)<=fileNameLength);
295 theFile.ReleaseBuffer();
296 m_LocalFileCtl.SetWindowText(theFile);
297 SyncNames();
298 ::DragFinish(hDropInfo);
299}
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 @@
1// RequestDlg.h : header file
2//
3
4/////////////////////////////////////////////////////////////////////////////
5// CRequestDlg dialog
6
7class CRequestDlg : public CDialog
8{
9// Construction
10public:
11 UINT m_BSize;
12 static CString m_MRUHost;
13 BOOL m_Drop;
14 virtual BOOL PreTranslateMessage(MSG* pMsg);
15 void UpdateOK();
16 void SyncNames();
17 BOOL m_Put;
18 CRequestDlg(CWnd* pParent = NULL); // standard constructor
19
20// Dialog Data
21 //{{AFX_DATA(CRequestDlg)
22 enum { IDD = IDD_REQUEST };
23 CEditm_RemoteFileCtl;
24 CEditm_LocalFileCtl;
25 CButtonm_RefreshCtl;
26 CButtonm_OKCtl;
27 CComboBoxm_TalksCtl;
28 CButtonm_BrowseCtl;
29 CStringm_Host;
30 CStringm_LocalFile;
31 CStringm_RemoteFile;
32 CStringm_Type;
33 CStringm_strBSize;
34 //}}AFX_DATA
35
36
37// Overrides
38 // ClassWizard generated virtual function overrides
39 //{{AFX_VIRTUAL(CRequestDlg)
40 public:
41 virtual int DoModal();
42 protected:
43 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
44 //}}AFX_VIRTUAL
45
46// Implementation
47protected:
48 CToolTipCtrl m_tooltip;
49
50 // Generated message map functions
51 //{{AFX_MSG(CRequestDlg)
52 virtual BOOL OnInitDialog();
53 afx_msg void OnRefresh();
54 afx_msg void OnBrowse();
55 afx_msg void OnChangeLocalfile();
56 afx_msg void OnChangeRemotefile();
57 afx_msg void OnEditchangeTalks();
58 afx_msg void OnSelchangeTalks();
59 afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
60 afx_msg void OnDropFiles(HDROP hDropInfo);
61 //}}AFX_MSG
62 DECLARE_MESSAGE_MAP()
63};
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 @@
1// Resolver.cpp : implementation file
2//
3
4#include "stdafx.h"
5#include "PumpKIN.h"
6#include "Resolver.h"
7#include "PumpKINDlg.h"
8
9#ifdef _DEBUG
10#define new DEBUG_NEW
11#undef THIS_FILE
12static char THIS_FILE[] = __FILE__;
13#endif
14
15/////////////////////////////////////////////////////////////////////////////
16// CResolver
17
18CResolver::CResolver()
19{
20 ASSERT(NULL);
21}
22
23CResolver::~CResolver()
24{
25}
26
27
28BEGIN_MESSAGE_MAP(CResolver, CWnd)
29 //{{AFX_MSG_MAP(CResolver)
30 ON_WM_CREATE()
31 ON_MESSAGE(WM_RESOLVED, OnResolved)
32 //}}AFX_MSG_MAP
33END_MESSAGE_MAP()
34
35
36/////////////////////////////////////////////////////////////////////////////
37// CResolver message handlers
38
39CResolver::CResolver(CXferSocket *socket)
40 : socket(socket)
41{
42}
43
44int CResolver::OnCreate(LPCREATESTRUCT lpCreateStruct)
45{
46 if (CWnd::OnCreate(lpCreateStruct) == -1)
47 return -1;
48
49 ASSERT(socket);
50CString hostName = socket->m_HostName;
51int at = hostName.Find('@');
52 if(at>=0)
53 hostName=hostName.Mid(at+1);
54 m_hAsync=WSAAsyncGetHostByName(m_hWnd,WM_RESOLVED,(LPCTSTR)hostName,(char*)socket->m_ResolveBuff,sizeof(socket->m_ResolveBuff));
55 ASSERT(m_hAsync);
56 return 0;
57}
58
59LRESULT CResolver::OnResolved(WPARAM wP,LPARAM lP)
60{
61 if(WSAGETASYNCERROR(lP))
62 socket->OnFailedToResolve();
63 else
64 socket->OnResolved();
65 return 0;
66}
67
68BOOL CResolver::Resolve()
69{
70 return Create(NULL,"PumpKIN-Resolver",WS_CHILD,CRect(0,0,0,0),socket->m_Daddy,0);
71}
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 @@
1// Resolver.h : header file
2//
3
4/////////////////////////////////////////////////////////////////////////////
5// CResolver window
6
7class CXferSocket;
8class CResolver : public CWnd
9{
10// Construction
11public:
12 BOOL Resolve();
13 HANDLE m_hAsync;
14 CResolver(CXferSocket *socket);
15 CXferSocket* socket;
16 CResolver();
17
18// Attributes
19public:
20
21// Operations
22public:
23
24// Overrides
25 // ClassWizard generated virtual function overrides
26 //{{AFX_VIRTUAL(CResolver)
27 //}}AFX_VIRTUAL
28
29// Implementation
30public:
31 virtual ~CResolver();
32
33 // Generated message map functions
34protected:
35 //{{AFX_MSG(CResolver)
36 afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
37 afx_msg LRESULT OnResolved(WPARAM wP,LPARAM lP);
38 //}}AFX_MSG
39 DECLARE_MESSAGE_MAP()
40};
41
42/////////////////////////////////////////////////////////////////////////////
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 @@
1// Retrier.cpp : implementation file
2//
3
4#include "stdafx.h"
5#include "PumpKIN.h"
6#include "Retrier.h"
7
8#include "PumpKINDlg.h"
9
10#ifdef _DEBUG
11#define new DEBUG_NEW
12#undef THIS_FILE
13static char THIS_FILE[] = __FILE__;
14#endif
15
16/////////////////////////////////////////////////////////////////////////////
17// CRetrier
18
19CRetrier::CRetrier(CPumpKINDlg *daddy)
20 : m_Daddy(daddy)
21{
22}
23
24CRetrier::~CRetrier()
25{
26}
27
28
29BEGIN_MESSAGE_MAP(CRetrier, CWnd)
30 //{{AFX_MSG_MAP(CRetrier)
31 ON_WM_TIMER()
32 //}}AFX_MSG_MAP
33END_MESSAGE_MAP()
34
35
36/////////////////////////////////////////////////////////////////////////////
37// CRetrier message handlers
38
39void CRetrier::OnTimer(UINT nIDEvent)
40{
41 ASSERT(m_Daddy);
42CXferSocket *socket;
43 if(m_Daddy->m_Xfers.Lookup(nIDEvent,socket))
44 socket->OnRetry();
45 CWnd::OnTimer(nIDEvent);
46}
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 @@
1// Retrier.h : header file
2//
3
4/////////////////////////////////////////////////////////////////////////////
5// CRetrier window
6
7class CPumpKINDlg;
8class CRetrier : public CWnd
9{
10// Construction
11public:
12 CPumpKINDlg* m_Daddy;
13 CRetrier(CPumpKINDlg *daddy);
14
15// Attributes
16public:
17
18// Operations
19public:
20
21// Overrides
22 // ClassWizard generated virtual function overrides
23 //{{AFX_VIRTUAL(CRetrier)
24 //}}AFX_VIRTUAL
25
26// Implementation
27public:
28 virtual ~CRetrier();
29
30 // Generated message map functions
31protected:
32 //{{AFX_MSG(CRetrier)
33 afx_msg void OnTimer(UINT nIDEvent);
34 //}}AFX_MSG
35 DECLARE_MESSAGE_MAP()
36};
37
38/////////////////////////////////////////////////////////////////////////////
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 @@
1// Trayer.cpp : implementation file
2//
3
4#include "stdafx.h"
5#include "PumpKIN.h"
6#include "Trayer.h"
7
8#include "PumpKINDlg.h"
9
10#ifdef _DEBUG
11#define new DEBUG_NEW
12#undef THIS_FILE
13static char THIS_FILE[] = __FILE__;
14#endif
15
16/////////////////////////////////////////////////////////////////////////////
17// CTrayer
18
19CTrayer::CTrayer()
20{
21 m_inMenu=0;
22}
23
24CTrayer::~CTrayer()
25{
26}
27
28
29BEGIN_MESSAGE_MAP(CTrayer, CWnd)
30 //{{AFX_MSG_MAP(CTrayer)
31 ON_MESSAGE(WM_TRAYICON, OnTray)
32 ON_COMMAND(ID_TRAY_ABOUTPUMPKIN, OnTrayAboutpumpkin)
33 ON_COMMAND(ID_TRAY_EXIT, OnTrayExit)
34 ON_COMMAND(ID_TRAY_FETCHFILE, OnTrayFetchfile)
35 ON_COMMAND(ID_TRAY_HELP, OnTrayHelp)
36 ON_COMMAND(ID_TRAY_OPENFILESFOLDER, OnTrayOpenfilesfolder)
37 ON_COMMAND(ID_TRAY_OPTIONS, OnTrayOptions)
38 ON_COMMAND(ID_TRAY_SENDFILE, OnTraySendfile)
39 ON_COMMAND(ID_TRAY_SHOWPUMPKINWINDOW, OnTrayShowpumpkinwindow)
40 //}}AFX_MSG_MAP
41END_MESSAGE_MAP()
42
43
44/////////////////////////////////////////////////////////////////////////////
45// CTrayer message handlers
46
47CTrayer::CTrayer(CPumpKINDlg* daddy)
48 : m_Daddy(daddy)
49{
50 m_inMenu=0;
51}
52
53LRESULT CTrayer::OnTray(WPARAM wP,LPARAM lP)
54{
55 ASSERT(wP==IDC_TRAYICON);
56 switch(lP){
57 case WM_RBUTTONDOWN:
58 {
59 CMenu menu;
60 VERIFY(menu.LoadMenu(IDM_POPUPS));
61 CMenu *popUp = menu.GetSubMenu(0);
62 ASSERT(popUp);
63 CPoint pt;
64 VERIFY(::GetCursorPos(&pt));
65 m_inMenu++;
66 SetForegroundWindow();
67 popUp->CheckMenuItem(ID_TRAY_SHOWPUMPKINWINDOW,MF_BYCOMMAND|(IsWindowVisible()?MF_CHECKED:MF_UNCHECKED));
68 popUp->TrackPopupMenu(TPM_RIGHTALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON,pt.x,pt.y,this);
69 m_inMenu--;
70 SendMessage(WM_NULL);
71 }
72 break;
73 case WM_LBUTTONDOWN:
74 m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_SHOWPUMPKINWINDOW);
75 break;
76 }
77 return 0;
78}
79
80void CTrayer::OnTrayAboutpumpkin()
81{
82 m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_ABOUTPUMPKIN);
83}
84
85void CTrayer::OnTrayExit()
86{
87 m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_EXIT);
88}
89
90void CTrayer::OnTrayFetchfile()
91{
92 m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_FETCHFILE);
93}
94
95void CTrayer::OnTrayHelp()
96{
97 m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_HELP);
98}
99
100void CTrayer::OnTrayOpenfilesfolder()
101{
102 m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_OPENFILESFOLDER);
103}
104
105void CTrayer::OnTrayOptions()
106{
107 m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_OPTIONS);
108}
109
110void CTrayer::OnTraySendfile()
111{
112 m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_SENDFILE);
113}
114
115void CTrayer::OnTrayShowpumpkinwindow()
116{
117 m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_SHOWPUMPKINWINDOW);
118}
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 @@
1// Trayer.h : header file
2//
3
4/////////////////////////////////////////////////////////////////////////////
5// CTrayer window
6
7class CPumpKINDlg;
8class CTrayer : public CWnd
9{
10// Construction
11public:
12 int m_inMenu;
13 CPumpKINDlg* m_Daddy;
14 CTrayer(CPumpKINDlg* daddy);
15 CTrayer();
16
17// Attributes
18public:
19
20// Operations
21public:
22
23// Overrides
24 // ClassWizard generated virtual function overrides
25 //{{AFX_VIRTUAL(CTrayer)
26 //}}AFX_VIRTUAL
27
28// Implementation
29public:
30 virtual ~CTrayer();
31
32 // Generated message map functions
33protected:
34 //{{AFX_MSG(CTrayer)
35 afx_msg LRESULT OnTray(WPARAM,LPARAM);
36 afx_msg void OnTrayAboutpumpkin();
37 afx_msg void OnTrayExit();
38 afx_msg void OnTrayFetchfile();
39 afx_msg void OnTrayHelp();
40 afx_msg void OnTrayOpenfilesfolder();
41 afx_msg void OnTrayOptions();
42 afx_msg void OnTraySendfile();
43 afx_msg void OnTrayShowpumpkinwindow();
44 //}}AFX_MSG
45 DECLARE_MESSAGE_MAP()
46};
47
48/////////////////////////////////////////////////////////////////////////////
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 @@
1:Base PumpKIN.hlp>Standard
2:Title PumpKIN
31 PumpKIN
42 About PumpKIN=About
52 What's New=News
62 Using PumpKIN=Using
71 PumpKIN Dialogs
82 Confirm Read Request Dialog=ConfirmRRQ
92 Confirm Write Request Dialog=ConfirmWRQ
102 Request Dialog=Request
111 PumpKIN Options
122 Server Options=ServerOptions
132 Network Options=NetworkOptions
142 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 @@
1; This file is maintained by HCW. Do not modify this file directly.
2
3[OPTIONS]
4COMPRESS=12 Hall Zeck
5LCID=0x409 0x0 0x0 ; English (United States)
6REPORT=Yes
7CONTENTS=Using
8TITLE=PumpKIN
9CNT=pumpkin.cnt
10HLP=PUMPKIN.HLP
11
12[FILES]
13pumpkin.rtf
14
15[MAP]
16#include pumpkin.hm
17
18[WINDOWS]
19Standard="",(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 @@
1{\rtf1\ansi
2@{\footnote
3THIS FILE WAS AUTOMATICALLY GENERATED FROM XML DOCUMENT.
4DO NOT MODIFY THIS FILE DIRECTLY. EDIT XML DOCUMENT INSTEAD
5}
6{\fonttbl{\f0\froman Times New Roman;}{\f1\fswiss Arial;}{\f3\froman Symbol;}}{\colortbl;
7 \red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;
8 \red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;
9 \red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;
10 \red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;}
11
12\pard\plain\keepn
13#{\footnote About}
14${\footnote About PumpKIN}
15K{\footnote about}
16{ \f1\fs18\b\sb120 About {\b PumpKIN}}
17\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.
18\par\sa120\sb120\qj\pard \f1\fs18\sb120
19\par\sa120\sb120\qj\pard \f1\fs18\sb120 {\b {\i Enjoy!}}
20{
21\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/")}
22\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:
23\par The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
24\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.
25}
26\page
27
28\pard\plain
29#{\footnote News}
30${\footnote What's New}
31\par\pard\plain\f1\fs24\qc\cf2\b 2.5 - August 19st, 2002
32\par\pard\plain\fi0\li0\f1\fs18 \bullet Change of {\uldb license}{\v About} and opening the source.
33\par\pard\plain\fi0\li0\f1\fs18 \bullet Minor cosmetic changes, mostly in build process
34\par\pard\plain\f1\fs24\qc\cf2\b 2.0 - June 13th, 1998
35\par\pard\plain\fi0\li0\f1\fs18 \bullet Sounds customization. Now you can customize {\b PumpKIN} bells and whistles or turn them off completely.
36\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}).
37\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.
38\par\pard\plain\fi0\li0\f1\fs18 \bullet Something else that you may not notice and I can not remember.
39\par\pard\plain\f1\fs24\qc\cf2\b 1.5 - February 12th, 1998
40\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.
41\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.
42\par\pard\plain\fi0\li0\f1\fs18 \bullet New Install program
43\page
44
45\pard\plain\keepn
46#{\footnote Using}
47${\footnote Using PumpKIN}
48{ \f1\fs18\b\sb120 Using {\b PumpKIN}}
49\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}.
50\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.
51\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.
52\par\sa120\sb120\qj\pard \f1\fs18\sb120 Use {\uldb Options}{\v Options} button to set {\b PumpKIN} options.
53\page
54
55\pard\plain\keepn
56#{\footnote ConfirmRRQ}
57${\footnote Confirm Read Request Dialog}
58{ \f1\fs18\b\sb120 Confirm Read Request Dialog}
59\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.
60\page
61
62\pard\plain\keepn
63#{\footnote ConfirmWRQ}
64${\footnote Confirm Write Request Dialog}
65{ \f1\fs18\b\sb120 Confirm Write Request Dialog}
66\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).
67\page
68
69\pard\plain\keepn
70#{\footnote Request}
71${\footnote Request Dialog}
72{ \f1\fs18\b\sb120 Request Dialog}
73\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
74\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.
75\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).
76\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.
77\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}'.
78\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
79\page
80
81\pard\plain\keepn
82#{\footnote Options}
83${\footnote Options}
84{ \f1\fs18\b\sb120 Options}
85\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.
86\page
87
88\pard\plain\keepn
89#{\footnote NetworkOptions}
90${\footnote Network Options}
91{ \f1\fs18\b\sb120 Network Options}\pard
92\par \fi0\li0 \bullet {\b UDP Ports}\pard
93\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.
94\par \fi0\li0 \bullet {\b Send outgoing requests to port} - specifies the port we're going to send all requests to.\pard
95\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.
96\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
97\page
98
99\pard\plain\keepn
100#{\footnote ServerOptions}
101${\footnote Server Options}
102{ \f1\fs18\b\sb120 Server Options}\pard
103\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.
104\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.
105\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.
106\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}.
107\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
108\page
109
110\pard\plain\keepn
111#{\footnote SoundsOptoins}
112${\footnote Sounds Options}
113{ \f1\fs18\b\sb120 Sounds}
114\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.
115\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.
116\page
117} \ 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 @@
1<?xml version="1.0"?>
2<winhelp>
3 <topic id="About" title="About PumpKIN" keywords="about">
4 <heading scroll="no">About <kin>PumpKIN</kin></heading>
5 <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>
6 <p/>
7 <p><b><i>Enjoy!</i></b></p>
8 <license years="1997, 1998, 2002"/>
9 <credist/>
10 </topic>
11 <topic id="News" title="What's New">
12 <newsfor version="2.5" date="August 19st, 2002">
13 <ni>Change of <a href="#About">license</a> and opening the source.</ni>
14 <ni>Minor cosmetic changes, mostly in build process</ni>
15 </newsfor>
16 <newsfor version="2.0" date="June 13th, 1998">
17 <ni>Sounds customization. Now you can customize <kin>PumpKIN</kin> bells and whistles or turn them off completely.</ni>
18 <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>
19 <ni>Typo causing <kin>PumpKIN</kin> to log outgoing request in reverse (i.e. <i>Requesting 'hostname' from 'filename'</i>) fixed.</ni>
20 <ni>Something else that you may not notice and I can not remember.</ni>
21 </newsfor>
22 <newsfor version="1.5" date="February 12th, 1998">
23 <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>
24 <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>
25 <ni>New Install program</ni>
26 </newsfor>
27 </topic>
28 <topic id="Using" title="Using PumpKIN">
29 <heading scroll="no">Using <kin>PumpKIN</kin></heading>
30 <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>
31 <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>
32 <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>
33 <p>Use <a href="#Options">Options</a> button to set <kin>PumpKIN</kin> options.</p>
34 </topic>
35 <topic id="ConfirmRRQ" title="Confirm Read Request Dialog">
36 <heading scroll="no">Confirm Read Request Dialog</heading>
37 <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>
38 </topic>
39 <topic id="ConfirmWRQ" title="Confirm Write Request Dialog">
40 <heading scroll="no">Confirm Write Request Dialog</heading>
41 <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>
42 </topic>
43 <topic id="Request" title="Request Dialog">
44 <heading scroll="no">Request Dialog</heading>
45 <p>Request dialog is aimed to let you form read or write request. You may set the following options:</p>
46 <ul>
47 <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>
48 <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>
49 <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>
50 <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>
51 <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>
52 </ul>
53 </topic>
54 <topic id="Options" title="Options">
55 <heading scroll="no">Options</heading>
56 <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>
57 </topic>
58 <topic id="NetworkOptions" title="Network Options">
59 <heading scroll="no">Network Options</heading>
60 <ul>
61 <li><b>UDP Ports</b>
62 <ul>
63 <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>
64 <li><b>Send outgoing requests to port</b> - specifies the port we're going to send all requests to.</li>
65 </ul>
66 </li>
67 <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>
68 <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>
69 </ul>
70 </topic>
71 <topic id="ServerOptions" title="Server Options">
72 <heading scroll="no">Server Options</heading>
73 <ul>
74 <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>
75 <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>
76 <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>
77 <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>
78 <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>
79 </ul>
80 </topic>
81 <topic id="SoundsOptoins" title="Sounds Options">
82 <heading scroll="no">Sounds</heading>
83 <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>
84 <p>You can select any <b>.wav</b> file or one of the predefined sounds from the dropdown list.</p>
85 </topic>
86</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 @@
1 #ifdefSTATI_K
2PumpKIN.ex_ rcdata discardable "../releast/pumpkin.ex_"
3#else
4PumpKIN.ex_ rcdata discardable "../release/pumpkin.ex_"
5#endif
6PumpKIN.cn_ rcdata discardable "../release/pumpkin.cn_"
7PumpKIN.hl_ rcdata discardable "../release/pumpkin.hl_"
8#ifdef K_ANNED
9mfc42.dl_ rcdata discardable "../redist/mfc42.dl_"
10#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 @@
1#include "resource.h"
2#include "../shared-code/install.h"
3
4 #defineKINAME "PumpKIN 2.5"
5#define SKINAME "PumpKIN"
6
7BOOL Install(void)
8{
9STRING dPath = strFETCH_REG_KEY(HKEY_LOCAL_MACHINE,"Software\\Klever Group, Inc.",SKINAME "Path");
10STRING kPath = strFETCH_REG_KEY(HKEY_LOCAL_MACHINE,"Software\\Klever Group, Inc.","KINPath");
11LPCSTR qPath = ((LPCSTR)dPath)?(LPCSTR)dPath:(((LPCSTR)kPath)?(LPSTR)kPath:"C:\\Program Files\\Klever\\Nothings");
12STRING path = REQUESTPATH(" " KINAME,"\nEnter destination path:",qPath);
13 if(!path)
14 return NULL;
15
16 #ifdefK_ANNED
17STRING sysDir(_MAX_PATH);
18 GetSystemDirectory(sysDir,_MAX_PATH);
19 INSTALLFILE("mfc42.dl_",sysDir,"mfc42.dll");
20#endif
21
22 MAKE_PATH(path);
23STRING shortPath = GET_SHORT_PATH(path);
24 if(!shortPath){
25 MessageBox(NULL,"Failed to install " KINAME " in specified directory",NULL,MB_ICONERROR|MB_OK);
26 return FALSE;
27 }
28
29 if(!(
30 INSTALLFILE(SKINAME ".ex_",path,SKINAME ".exe") &&
31 INSTALLFILE(SKINAME ".hl_",path,SKINAME ".hlp") &&
32 INSTALLFILE(SKINAME ".cn_",path,SKINAME ".cnt")
33 )){
34 MessageBox(NULL,"Failed to install " KINAME " in specified directory",NULL,MB_ICONERROR|MB_OK);
35 return FALSE;
36 }
37 ADDMENU("Accessories\\Klever Co.",SKINAME,path, SKINAME ".exe");
38
39 strSET_REG_KEY(HKEY_LOCAL_MACHINE,"Software\\Klever Group, Inc.",SKINAME "Path",path);
40 strSET_REG_KEY(HKEY_LOCAL_MACHINE,"Software\\Klever Group, Inc.","KINPath",path);
41
42FILE* inf=CREATE_INF_FILE(path,SKINAME ".INF");
43 if(!inf){
44 MessageBox(NULL,"Failed to install " KINAME,NULL,MB_ICONERROR|MB_OK);
45 return FALSE;
46 }
47 INF_FILE_HEADER(inf);
48 INF_FILE_SECTION(inf,"Uninstall");
49 fprintf(inf,"AddReg=kFiles\nDelReg=kReg\nUpdateInis=kMenu\n");
50 INF_FILE_SECTION(inf,"kFiles");
51 INF_REMOVE_ROOT(inf,SKINAME "Files",shortPath);
52 INF_REMOVE_FILE(inf,SKINAME "Files",SKINAME ".exe");
53 INF_REMOVE_HELP_FILE(inf,SKINAME "Files",SKINAME);
54 INF_REMOVE_FILE(inf,SKINAME "Files",SKINAME ".inf");
55 INF_FILE_SECTION(inf,"kReg");
56 INF_UNINSTALL_REG(inf,SKINAME);
57 INF_FILE_SECTION(inf,"kMenu");
58 INF_MENU_GROUP(inf,1,"Accessories\\Klever Co.");
59 INF_MENU_ITEM(inf,1,SKINAME);
60 fclose(inf);
61
62 REG_UNINSTALL_COMMAND(SKINAME,"Klever " KINAME,shortPath,SKINAME ".INF","Uninstall");
63
64 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);
65
66 return TRUE;
67}
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 @@
1//Microsoft Developer Studio generated resource script.
2//
3#include "resource.h"
4
5#define APSTUDIO_READONLY_SYMBOLS
6/////////////////////////////////////////////////////////////////////////////
7//
8// Generated from the TEXTINCLUDE 2 resource.
9//
10#include "afxres.h"
11
12/////////////////////////////////////////////////////////////////////////////
13#undef APSTUDIO_READONLY_SYMBOLS
14
15/////////////////////////////////////////////////////////////////////////////
16// English (U.S.) resources
17
18#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
19#ifdef _WIN32
20LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
21#pragma code_page(1252)
22#endif //_WIN32
23
24/////////////////////////////////////////////////////////////////////////////
25//
26// Dialog
27//
28
29#if defined(APSTUDIO_INVOKED) || defined(FALSE)
30#if defined(APSTUDIO_INVOKED)
31IDD_INSTALLING$(FALSE) DIALOGEX 0, 0, 200, 74
32#else
33IDD_INSTALLING DIALOGEX 0, 0, 200, 74
34#endif
35STYLE DS_MODALFRAME | DS_3DLOOK | WS_POPUP
36FONT 8, "MS Sans Serif", 0, 0, 0x1
37BEGIN
38 PUSHBUTTON "Cancel",IDCANCEL,143,53,50,14,BS_CENTER | BS_VCENTER |
39 BS_NOTIFY | BS_FLAT,WS_EX_DLGMODALFRAME
40 CONTROL "Animate1",IDC_DISKS,"SysAnimate32",ACS_TRANSPARENT |
41 ACS_AUTOPLAY | WS_TABSTOP,161,7,32,32
42 LTEXT "",IDC_STATE,7,7,150,32,SS_NOPREFIX | SS_NOTIFY
43 CONTROL "Progress1",IDC_PROGRESS,"msctls_progress32",0x0,7,45,
44 186,7,WS_EX_DLGMODALFRAME
45END
46#endif
47
48IDD_PATH DIALOGEX 0, 0, 255, 73
49STYLE DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_CENTER | WS_POPUP |
50 WS_VISIBLE | WS_CAPTION
51EXSTYLE WS_EX_TOOLWINDOW | WS_EX_CLIENTEDGE
52FONT 8, "MS Sans Serif", 0, 0, 0x1
53BEGIN
54 LTEXT "",IDC_PROMPT,7,7,241,30
55 EDITTEXT IDC_PATH,7,37,195,12,ES_AUTOHSCROLL
56 PUSHBUTTON "B&rowse..",IDC_BROWSE,208,37,40,12
57 DEFPUSHBUTTON "OK",IDOK,69,52,50,14
58 PUSHBUTTON "Cancel",IDCANCEL,135,52,50,14
59END
60
61
62/////////////////////////////////////////////////////////////////////////////
63//
64// DESIGNINFO
65//
66
67#ifdef APSTUDIO_INVOKED
68GUIDELINES DESIGNINFO DISCARDABLE
69BEGIN
70 "IDD_INSTALLING$(FALSE)", DIALOG
71 BEGIN
72 LEFTMARGIN, 7
73 RIGHTMARGIN, 193
74 TOPMARGIN, 7
75 BOTTOMMARGIN, 67
76 HORZGUIDE, 39
77 END
78
79 IDD_PATH, DIALOG
80 BEGIN
81 LEFTMARGIN, 7
82 RIGHTMARGIN, 248
83 VERTGUIDE, 202
84 VERTGUIDE, 208
85 TOPMARGIN, 7
86 BOTTOMMARGIN, 66
87 HORZGUIDE, 37
88 END
89END
90#endif // APSTUDIO_INVOKED
91
92
93#ifdef APSTUDIO_INVOKED
94/////////////////////////////////////////////////////////////////////////////
95//
96// TEXTINCLUDE
97//
98
991 TEXTINCLUDE DISCARDABLE
100BEGIN
101 "resource.h\0"
102END
103
1042 TEXTINCLUDE DISCARDABLE
105BEGIN
106 "#include ""afxres.h""\r\n"
107 "\0"
108END
109
1103 TEXTINCLUDE DISCARDABLE
111BEGIN
112 "#include ""custom.rch""\0"
113END
114
115#endif // APSTUDIO_INVOKED
116
117
118/////////////////////////////////////////////////////////////////////////////
119//
120// Icon
121//
122
123// Icon with lowest ID value placed first to ensure application icon
124// remains consistent on all systems.
125IDI_ICON ICON DISCARDABLE "../shared-data/install-icon.ico"
126
127#ifndef _MAC
128/////////////////////////////////////////////////////////////////////////////
129//
130// Version
131//
132
133VS_VERSION_INFO VERSIONINFO
134 FILEVERSION 2,5,0,0
135 PRODUCTVERSION 2,5,0,0
136 FILEFLAGSMASK 0x3fL
137#ifdef _DEBUG
138 FILEFLAGS 0x1L
139#else
140 FILEFLAGS 0x0L
141#endif
142 FILEOS 0x40004L
143 FILETYPE 0x1L
144 FILESUBTYPE 0x0L
145BEGIN
146 BLOCK "StringFileInfo"
147 BEGIN
148 BLOCK "040904b0"
149 BEGIN
150 VALUE "CompanyName", "Klever Group (http://www.klever.net/)\0"
151 VALUE "FileDescription", "INSTALL: PumpKIN, tftp client/daemon\0"
152 VALUE "FileVersion", "2, 5, 0, 0\0"
153 VALUE "InternalName", "INSTALL\0"
154 VALUE "LegalCopyright", "Copyright © 1997, 1998, 2002 Klever Group (http://www.klever.net/)\0"
155 VALUE "LegalTrademarks", "Klever Group (http://www.klever.net/)\0"
156 VALUE "OriginalFilename", "INSTALL.EXE\0"
157 VALUE "ProductName", "PumpKIN\0"
158 VALUE "ProductVersion", "2, 5, 0, 0\0"
159 END
160 END
161 BLOCK "VarFileInfo"
162 BEGIN
163 VALUE "Translation", 0x409, 1200
164 END
165END
166
167#endif // !_MAC
168
169#endif // English (U.S.) resources
170/////////////////////////////////////////////////////////////////////////////
171
172
173
174#ifndef APSTUDIO_INVOKED
175/////////////////////////////////////////////////////////////////////////////
176//
177// Generated from the TEXTINCLUDE 3 resource.
178//
179#include "custom.rch"
180/////////////////////////////////////////////////////////////////////////////
181#endif // not APSTUDIO_INVOKED
182
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 @@
1//{{NO_DEPENDENCIES}}
2// Microsoft Developer Studio generated include file.
3// Used by Install.rc
4//
5#define IDD_INSTALLING 101
6#define IDD_PATH 102
7#define IDI_ICON 105
8#define IDC_DISKS 1000
9#define IDC_STATE 1001
10#define IDC_PROGRESS 1002
11#define IDC_PROMPT 1003
12#define IDC_PATH 1004
13#define IDC_BROWSE 1005
14
15// Next default values for new objects
16//
17#ifdef APSTUDIO_INVOKED
18#ifndef APSTUDIO_READONLY_SYMBOLS
19#define _APS_NEXT_RESOURCE_VALUE 107
20#define _APS_NEXT_COMMAND_VALUE 40001
21#define _APS_NEXT_CONTROL_VALUE 1006
22#define _APS_NEXT_SYMED_VALUE 101
23#endif
24#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 @@
1@echo off
2REM -- First make map file from Microsoft Visual C++ generated resource.h
3echo // MAKEHELP.BAT generated Help Map file. Used by PUMPKIN.HPJ. >"help\pumpkin.hm"
4echo. >>"help\pumpkin.hm"
5echo // Commands (ID_* and IDM_*) >>"help\pumpkin.hm"
6makehm ID_,HID_,0x10000 IDM_,HIDM_,0x10000 resource.h >>"help\pumpkin.hm"
7echo. >>"help\pumpkin.hm"
8echo // Prompts (IDP_*) >>"help\pumpkin.hm"
9makehm IDP_,HIDP_,0x30000 resource.h >>"help\pumpkin.hm"
10echo. >>"help\pumpkin.hm"
11echo // Resources (IDR_*) >>"help\pumpkin.hm"
12makehm IDR_,HIDR_,0x20000 resource.h >>"help\pumpkin.hm"
13echo. >>"help\pumpkin.hm"
14echo // Dialogs (IDD_*) >>"help\pumpkin.hm"
15makehm IDD_,HIDD_,0x20000 resource.h >>"help\pumpkin.hm"
16echo. >>"help\pumpkin.hm"
17echo // Frame Controls (IDW_*) >>"help\pumpkin.hm"
18makehm IDW_,HIDW_,0x50000 resource.h >>"help\pumpkin.hm"
19REM -- Make help for Project PUMPKIN
20
21echo Building RTF file
22xsltproc -o help/pumpkin.rtf shared-code/kinhelp.xsl help/pumpkin.xml
23echo Building Win32 Help files
24start /wait hcrtf -x "help\pumpkin.hpj"
25echo.
26if exist Debug\nul copy "help\pumpkin.hlp" Debug
27if exist Debug\nul copy "help\pumpkin.cnt" Debug
28if exist Release\nul copy "help\pumpkin.hlp" Release
29if exist Release\nul copy "help\pumpkin.cnt" Release
30if exist Releast\nul copy "help\pumpkin.hlp" Releast
31if exist Releast\nul copy "help\pumpkin.cnt" Releast
32echo.
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 @@
1; CLW file contains information for the MFC ClassWizard
2
3[General Info]
4Version=1
5LastClass=CPropsSounds
6LastTemplate=CPropertyPage
7NewFileInclude1=#include "stdafx.h"
8NewFileInclude2=#include "PumpKIN.h"
9
10ClassCount=12
11Class1=CPumpKINApp
12Class2=CPumpKINDlg
13Class3=CAboutDlg
14
15ResourceCount=9
16Resource1=IDD_REQUEST
17Resource2=IDD_PROPS_SERVER
18Resource3=IDD_CONFIRM_RRQ
19Resource4=IDD_ABOUTBOX
20Class4=CPropsServer
21Class5=CPropsNetwork
22Resource5=IDD_CONFIRM_WRQ
23Resource6=IDD_PROPS_NETWORK
24Class6=CConfirmRRQDlg
25Class7=CConfirmWRQDlg
26Resource7=IDD_PUMPKIN_DIALOG
27Class8=CRequestDlg
28Class9=CResolver
29Class10=CRetrier
30Class11=CTrayer
31Resource8=IDD_PROPS_SOUNDS
32Class12=CPropsSounds
33Resource9=IDM_POPUPS
34
35[CLS:CPumpKINApp]
36Type=0
37HeaderFile=PumpKIN.h
38ImplementationFile=PumpKIN.cpp
39Filter=N
40
41[CLS:CPumpKINDlg]
42Type=0
43HeaderFile=PumpKINDlg.h
44ImplementationFile=PumpKINDlg.cpp
45Filter=W
46BaseClass=CDialog
47VirtualFilter=dWC
48LastObject=ID_HELP
49
50[CLS:CAboutDlg]
51Type=0
52HeaderFile=PumpKINDlg.h
53ImplementationFile=PumpKINDlg.cpp
54Filter=D
55BaseClass=CDialog
56VirtualFilter=dWC
57LastObject=CAboutDlg
58
59[DLG:IDD_ABOUTBOX]
60Type=1
61Class=CAboutDlg
62ControlCount=5
63Control1=IDC_STATIC,static,1342177283
64Control2=IDC_STATIC,static,1342308480
65Control3=IDC_STATIC,static,1342308352
66Control4=IDOK,button,1342373889
67Control5=IDC_KLEVERNET,button,1342242816
68
69[DLG:IDD_PUMPKIN_DIALOG]
70Type=1
71Class=CPumpKINDlg
72ControlCount=9
73Control1=IDC_CONNECTIONS,SysListView32,1350631681
74Control2=IDC_GET,button,1342259200
75Control3=IDC_PUT,button,1342259200
76Control4=IDC_ABORT,button,1342259200
77Control5=IDC_OPTIONS,button,1342259200
78Control6=IDC_EXIT,button,1342259200
79Control7=ID_HELP,button,1342259200
80Control8=IDC_LOG,listbox,1353728129
81Control9=IDCANCEL,button,1073741824
82
83[DLG:IDD_PROPS_SERVER]
84Type=1
85Class=CPropsServer
86ControlCount=15
87Control1=IDC_STATIC,button,1342177287
88Control2=IDC_TFTPROOT,edit,1350631552
89Control3=IDC_BROWSE,button,1342242880
90Control4=IDC_TFTPSUBDIRS,button,1342242819
91Control5=IDC_STATIC,button,1342177287
92Control6=IDC_RRQ_GIVEALL,button,1342324745
93Control7=IDC_RRQ_ALWAYSCONFIRM,button,1342193673
94Control8=IDC_RRQ_DENYALL,button,1342193673
95Control9=IDC_STATIC,button,1342308359
96Control10=IDC_WRQ_TAKEALL,button,1342308361
97Control11=IDC_WRQ_PROMPTEXISTING,button,1342177289
98Control12=IDC_WRQ_ALWAYSCONFIRM,button,1342177289
99Control13=IDC_WRQ_DENYALL,button,1342177289
100Control14=IDC_STATIC,static,1342308609
101Control15=IDC_PROMPTTIMEOUT,msctls_trackbar32,1342242823
102
103[DLG:IDD_PROPS_NETWORK]
104Type=1
105Class=CPropsNetwork
106ControlCount=15
107Control1=IDC_STATIC,button,1342177287
108Control2=IDC_STATIC,static,1342308354
109Control3=IDC_LISTENPORT,edit,1350631552
110Control4=IDC_LISTENSPIN,msctls_updown32,1342177463
111Control5=IDC_STATIC,static,1342308354
112Control6=IDC_SPEAKPORT,edit,1350631552
113Control7=IDC_SPEAKSPIN,msctls_updown32,1342177463
114Control8=IDC_STATIC,static,1342308352
115Control9=IDC_TIMEOUT,edit,1350639744
116Control10=IDC_TIMESPIN,msctls_updown32,1342177463
117Control11=IDC_STATIC,static,1342308352
118Control12=IDC_STATIC,static,1342308352
119Control13=IDC_STATIC,static,1342308352
120Control14=IDC_BLOCKSIZE,edit,1350639744
121Control15=IDC_BSIZESPIN,msctls_updown32,1342177463
122
123[CLS:CPropsServer]
124Type=0
125HeaderFile=PropsServer.h
126ImplementationFile=PropsServer.cpp
127BaseClass=CPropertyPage
128Filter=D
129VirtualFilter=idWC
130LastObject=CPropsServer
131
132[CLS:CPropsNetwork]
133Type=0
134HeaderFile=PropsNetwork.h
135ImplementationFile=PropsNetwork.cpp
136BaseClass=CPropertyPage
137Filter=D
138VirtualFilter=idWC
139LastObject=CPropsNetwork
140
141[DLG:IDD_CONFIRM_RRQ]
142Type=1
143Class=CConfirmRRQDlg
144ControlCount=9
145Control1=IDOK,button,1342242817
146Control2=IDCANCEL,button,1342242816
147Control3=IDC_STATIC,static,1342308352
148Control4=IDC_HOST,static,1350701313
149Control5=IDC_STATIC,static,1342308353
150Control6=IDC_FILE,static,1350701313
151Control7=IDC_STATIC,static,1342177296
152Control8=IDC_STATIC,static,1342177283
153Control9=IDC_STATIC,static,1342177283
154
155[DLG:IDD_CONFIRM_WRQ]
156Type=1
157Class=CConfirmWRQDlg
158ControlCount=11
159Control1=IDOK,button,1342242817
160Control2=IDC_RENAME,button,1342242816
161Control3=IDCANCEL,button,1342242816
162Control4=IDC_STATIC,static,1342308352
163Control5=IDC_HOST,static,1350701313
164Control6=IDC_STATIC,static,1342308353
165Control7=IDC_FILE,static,1350701313
166Control8=IDC_STATIC,static,1342177296
167Control9=IDC_STATIC,static,1342177283
168Control10=IDC_STATIC,static,1342177283
169Control11=IDC_RESUME,button,1342242816
170
171[CLS:CConfirmRRQDlg]
172Type=0
173HeaderFile=ConfirmRRQDlg.h
174ImplementationFile=ConfirmRRQDlg.cpp
175BaseClass=CDialog
176Filter=D
177VirtualFilter=dWC
178LastObject=CConfirmRRQDlg
179
180[CLS:CConfirmWRQDlg]
181Type=0
182HeaderFile=ConfirmWRQDlg.h
183ImplementationFile=ConfirmWRQDlg.cpp
184BaseClass=CDialog
185Filter=D
186VirtualFilter=dWC
187LastObject=IDC_RESUME
188
189[DLG:IDD_REQUEST]
190Type=1
191Class=CRequestDlg
192ControlCount=15
193Control1=IDC_STATIC,static,1342308608
194Control2=IDC_LOCALFILE,edit,1350631552
195Control3=IDC_BROWSE,button,1342242880
196Control4=IDC_STATIC,static,1342308608
197Control5=IDC_REMOTEFILE,edit,1350631552
198Control6=IDC_STATIC,static,1342308608
199Control7=IDC_TALKS,combobox,1344341313
200Control8=IDC_REFRESH,button,1342271232
201Control9=IDC_STATIC,static,1342308352
202Control10=IDC_TYPE,combobox,1344356418
203Control11=IDC_STATIC,static,1342308352
204Control12=IDC_BSIZE,combobox,1344339970
205Control13=IDOK,button,1342242817
206Control14=IDCANCEL,button,1342242816
207Control15=IDC_STATIC,static,1342177297
208
209[CLS:CRequestDlg]
210Type=0
211HeaderFile=RequestDlg.h
212ImplementationFile=RequestDlg.cpp
213BaseClass=CDialog
214Filter=W
215VirtualFilter=dWC
216LastObject=CRequestDlg
217
218[CLS:CResolver]
219Type=0
220HeaderFile=Resolver.h
221ImplementationFile=Resolver.cpp
222BaseClass=CWnd
223Filter=W
224LastObject=CResolver
225VirtualFilter=WC
226
227[MNU:IDM_POPUPS]
228Type=1
229Class=CPumpKINDlg
230Command1=ID_TRAY_SENDFILE
231Command2=ID_TRAY_FETCHFILE
232Command3=ID_TRAY_OPTIONS
233Command4=ID_TRAY_SHOWPUMPKINWINDOW
234Command5=ID_TRAY_OPENFILESFOLDER
235Command6=ID_TRAY_HELP
236Command7=ID_TRAY_ABOUTPUMPKIN
237Command8=ID_TRAY_EXIT
238CommandCount=8
239
240[CLS:CRetrier]
241Type=0
242HeaderFile=Retrier.h
243ImplementationFile=Retrier.cpp
244BaseClass=CWnd
245Filter=W
246LastObject=CRetrier
247VirtualFilter=WC
248
249[CLS:CTrayer]
250Type=0
251HeaderFile=Trayer.h
252ImplementationFile=Trayer.cpp
253BaseClass=CWnd
254Filter=W
255LastObject=CTrayer
256VirtualFilter=WC
257
258[DLG:IDD_PROPS_SOUNDS]
259Type=1
260Class=CPropsSounds
261ControlCount=12
262Control1=IDC_STATIC,static,1342308352
263Control2=IDC_RING,combobox,1344340290
264Control3=IDC_RING_BROWSE,button,1342242880
265Control4=IDC_RING_PLAY,button,1342242880
266Control5=IDC_STATIC,static,1342308352
267Control6=IDC_FINISHED,combobox,1344340290
268Control7=IDC_FINISHED_BROWSE,button,1342242880
269Control8=IDC_FINISHED_PLAY,button,1342242880
270Control9=IDC_STATIC,static,1342308352
271Control10=IDC_ABORTED,combobox,1344340290
272Control11=IDC_ABORTED_BROWSE,button,1342242880
273Control12=IDC_ABORTED_PLAY,button,1342242880
274
275[CLS:CPropsSounds]
276Type=0
277HeaderFile=PropsSounds.h
278ImplementationFile=PropsSounds.cpp
279BaseClass=CPropertyPage
280Filter=D
281LastObject=CPropsSounds
282VirtualFilter=idWC
283
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 @@
1// PumpKIN.cpp : Defines the class behaviors for the application.
2//
3
4#include "stdafx.h"
5#include "PumpKIN.h"
6#include "PumpKINDlg.h"
7
8#ifdef _DEBUG
9#define new DEBUG_NEW
10#undef THIS_FILE
11static char THIS_FILE[] = __FILE__;
12#endif
13
14/////////////////////////////////////////////////////////////////////////////
15// CPumpKINApp
16
17BEGIN_MESSAGE_MAP(CPumpKINApp, CWinApp)
18 //{{AFX_MSG_MAP(CPumpKINApp)
19 //}}AFX_MSG
20 ON_COMMAND(ID_HELP, CWinApp::OnHelp)
21END_MESSAGE_MAP()
22
23/////////////////////////////////////////////////////////////////////////////
24// CPumpKINApp construction
25
26CPumpKINApp::CPumpKINApp()
27{
28}
29
30/////////////////////////////////////////////////////////////////////////////
31// The one and only CPumpKINApp object
32
33CPumpKINApp theApp;
34
35/////////////////////////////////////////////////////////////////////////////
36// CPumpKINApp initialization
37
38BOOL CPumpKINApp::InitInstance()
39{
40 if (!AfxSocketInit())
41 {
42 AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
43 return FALSE;
44 }
45
46 // Standard initialization
47 // If you are not using these features and wish to reduce the size
48 // of your final executable, you should remove from the following
49 // the specific initialization routines you do not need.
50
51#ifdef _AFXDLL
52 Enable3dControls(); // Call this when using MFC in a shared DLL
53#else
54 Enable3dControlsStatic();// Call this when linking to MFC statically
55#endif
56
57 SetRegistryKey(IDS_REGISTRYKEY);
58 m_HelpFile = m_pszHelpFilePath;
59 m_HelpFile+=">Standard";
60 m_pszHelpFilePath=(LPCTSTR)m_HelpFile;
61
62 CPumpKINDlg dlg;
63 m_pMainWnd = &dlg;
64 int nResponse = dlg.DoModal();
65
66 // Since the dialog has been closed, return FALSE so that we exit the
67 // application, rather than start the application's message pump.
68 return FALSE;
69}
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 @@
1// PumpKIN.h : main header file for the PUMPKIN application
2//
3
4#ifndef __AFXWIN_H__
5 #error include 'stdafx.h' before including this file for PCH
6#endif
7
8 #include "resource.h" // main symbols
9
10/////////////////////////////////////////////////////////////////////////////
11// CPumpKINApp:
12// See PumpKIN.cpp for the implementation of this class
13//
14
15class CPumpKINApp : public CWinApp
16{
17public:
18 CString m_HelpFile;
19 CPumpKINApp();
20
21// Overrides
22 // ClassWizard generated virtual function overrides
23 //{{AFX_VIRTUAL(CPumpKINApp)
24 public:
25 virtual BOOL InitInstance();
26 //}}AFX_VIRTUAL
27
28// Implementation
29
30 //{{AFX_MSG(CPumpKINApp)
31 //}}AFX_MSG
32 DECLARE_MESSAGE_MAP()
33};
34
35
36/////////////////////////////////////////////////////////////////////////////
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 @@
1# Microsoft Developer Studio Generated NMAKE File, Format Version 4.20
2# ** DO NOT EDIT **
3
4# TARGTYPE "Win32 (x86) Application" 0x0101
5
6!IF "$(CFG)" == ""
7CFG=Install - Win32 Debug
8!MESSAGE No configuration specified. Defaulting to Install - Win32 Debug.
9!ENDIF
10
11!IF "$(CFG)" != "PumpKIN - Win32 Release" && "$(CFG)" !=\
12 "PumpKIN - Win32 Debug" && "$(CFG)" != "PumpKIN - Win32 Static" && "$(CFG)" !=\
13 "Install - Win32 Debug" && "$(CFG)" != "Install - Win32 Pure" && "$(CFG)" !=\
14 "Install - Win32 Static" && "$(CFG)" != "Install - Win32 Canned"
15!MESSAGE Invalid configuration "$(CFG)" specified.
16!MESSAGE You can specify a configuration when running NMAKE on this makefile
17!MESSAGE by defining the macro CFG on the command line. For example:
18!MESSAGE
19!MESSAGE NMAKE /f "pumpkin.mak" CFG="Install - Win32 Debug"
20!MESSAGE
21!MESSAGE Possible choices for configuration are:
22!MESSAGE
23!MESSAGE "PumpKIN - Win32 Release" (based on "Win32 (x86) Application")
24!MESSAGE "PumpKIN - Win32 Debug" (based on "Win32 (x86) Application")
25!MESSAGE "PumpKIN - Win32 Static" (based on "Win32 (x86) Application")
26!MESSAGE "Install - Win32 Debug" (based on "Win32 (x86) Application")
27!MESSAGE "Install - Win32 Pure" (based on "Win32 (x86) Application")
28!MESSAGE "Install - Win32 Static" (based on "Win32 (x86) Application")
29!MESSAGE "Install - Win32 Canned" (based on "Win32 (x86) Application")
30!MESSAGE
31!ERROR An invalid configuration is specified.
32!ENDIF
33
34!IF "$(OS)" == "Windows_NT"
35NULL=
36!ELSE
37NULL=nul
38!ENDIF
39################################################################################
40# Begin Project
41# PROP Target_Last_Scanned "Install - Win32 Canned"
42RSC=rc.exe
43MTL=mktyplib.exe
44CPP=cl.exe
45
46!IF "$(CFG)" == "PumpKIN - Win32 Release"
47
48# PROP BASE Use_MFC 6
49# PROP BASE Use_Debug_Libraries 0
50# PROP BASE Output_Dir "Release"
51# PROP BASE Intermediate_Dir "Release"
52# PROP BASE Target_Dir ""
53# PROP Use_MFC 6
54# PROP Use_Debug_Libraries 0
55# PROP Output_Dir "Release"
56# PROP Intermediate_Dir "Release"
57# PROP Target_Dir ""
58OUTDIR=.\Release
59INTDIR=.\Release
60# Begin Custom Macros
61OutDir=.\Release
62TargetName=pumpkin
63# End Custom Macros
64
65ALL : "$(OUTDIR)\pumpkin.exe" "$(OUTDIR)\pumpkin.ex_" "$(OUTDIR)\pumpkin.hlp"\
66 "$(OUTDIR)\pumpkin.cnt" "$(OUTDIR)\pumpkin.hl_" "$(OUTDIR)\pumpkin.cn_"
67
68CLEAN :
69 -@erase "$(INTDIR)\ConfirmRRQDlg.obj"
70 -@erase "$(INTDIR)\ConfirmWRQDlg.obj"
71 -@erase "$(INTDIR)\PropsNetwork.obj"
72 -@erase "$(INTDIR)\PropsServer.obj"
73 -@erase "$(INTDIR)\PropsSounds.obj"
74 -@erase "$(INTDIR)\pumpkin.cn_"
75 -@erase "$(INTDIR)\pumpkin.cnt"
76 -@erase "$(INTDIR)\pumpkin.hl_"
77 -@erase "$(INTDIR)\pumpkin.hlp"
78 -@erase "$(INTDIR)\PumpKIN.obj"
79 -@erase "$(INTDIR)\pumpkin.pch"
80 -@erase "$(INTDIR)\PumpKIN.res"
81 -@erase "$(INTDIR)\PumpKINDlg.obj"
82 -@erase "$(INTDIR)\RequestDlg.obj"
83 -@erase "$(INTDIR)\Resolver.obj"
84 -@erase "$(INTDIR)\Retrier.obj"
85 -@erase "$(INTDIR)\StdAfx.obj"
86 -@erase "$(INTDIR)\Trayer.obj"
87 -@erase "$(OUTDIR)\pumpkin.ex_"
88 -@erase "$(OUTDIR)\pumpkin.exe"
89
90"$(OUTDIR)" :
91 if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
92
93# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /c
94# ADD CPP /nologo /Zp1 /MD /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /c
95CPP_PROJ=/nologo /Zp1 /MD /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D\
96 "_AFXDLL" /D "_MBCS" /Fp"$(INTDIR)/pumpkin.pch" /Yu"stdafx.h" /Fo"$(INTDIR)/"\
97 /c
98CPP_OBJS=.\Release/
99CPP_SBRS=.\.
100# ADD BASE MTL /nologo /D "NDEBUG" /win32
101# ADD MTL /nologo /D "NDEBUG" /win32
102MTL_PROJ=/nologo /D "NDEBUG" /win32
103# ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
104# ADD RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
105RSC_PROJ=/l 0x409 /fo"$(INTDIR)/PumpKIN.res" /d "NDEBUG" /d "_AFXDLL"
106BSC32=bscmake.exe
107# ADD BASE BSC32 /nologo
108# ADD BSC32 /nologo
109BSC32_FLAGS=/nologo /o"$(OUTDIR)/pumpkin.bsc"
110BSC32_SBRS= \
111
112LINK32=link.exe
113# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
114# ADD LINK32 /nologo /subsystem:windows /machine:I386
115LINK32_FLAGS=/nologo /subsystem:windows /incremental:no\
116 /pdb:"$(OUTDIR)/pumpkin.pdb" /machine:I386 /out:"$(OUTDIR)/pumpkin.exe"
117LINK32_OBJS= \
118 "$(INTDIR)\ConfirmRRQDlg.obj" \
119 "$(INTDIR)\ConfirmWRQDlg.obj" \
120 "$(INTDIR)\PropsNetwork.obj" \
121 "$(INTDIR)\PropsServer.obj" \
122 "$(INTDIR)\PropsSounds.obj" \
123 "$(INTDIR)\PumpKIN.obj" \
124 "$(INTDIR)\PumpKIN.res" \
125 "$(INTDIR)\PumpKINDlg.obj" \
126 "$(INTDIR)\RequestDlg.obj" \
127 "$(INTDIR)\Resolver.obj" \
128 "$(INTDIR)\Retrier.obj" \
129 "$(INTDIR)\StdAfx.obj" \
130 "$(INTDIR)\Trayer.obj"
131
132"$(OUTDIR)\pumpkin.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
133 $(LINK32) @<<
134 $(LINK32_FLAGS) $(LINK32_OBJS)
135<<
136
137# Begin Custom Build
138OutDir=.\Release
139TargetName=pumpkin
140InputPath=.\Release\pumpkin.exe
141SOURCE=$(InputPath)
142
143"$(OutDir)\$(TargetName).ex_" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
144 compress $(OutDir)\$(TargetName).exe $(OutDir)\$(TargetName).ex_
145
146# End Custom Build
147
148!ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug"
149
150# PROP BASE Use_MFC 6
151# PROP BASE Use_Debug_Libraries 1
152# PROP BASE Output_Dir "Debug"
153# PROP BASE Intermediate_Dir "Debug"
154# PROP BASE Target_Dir ""
155# PROP Use_MFC 6
156# PROP Use_Debug_Libraries 1
157# PROP Output_Dir "Debug"
158# PROP Intermediate_Dir "Debug"
159# PROP Target_Dir ""
160OUTDIR=.\Debug
161INTDIR=.\Debug
162# Begin Custom Macros
163OutDir=.\Debug
164TargetName=pumpkin
165# End Custom Macros
166
167ALL : "$(OUTDIR)\pumpkin.exe" "$(OUTDIR)\pumpkin.bsc" "$(OUTDIR)\pumpkin.ex_"\
168 "$(OUTDIR)\pumpkin.hlp" "$(OUTDIR)\pumpkin.cnt" "$(OUTDIR)\pumpkin.hl_"\
169 "$(OUTDIR)\pumpkin.cn_"
170
171CLEAN :
172 -@erase "$(INTDIR)\ConfirmRRQDlg.obj"
173 -@erase "$(INTDIR)\ConfirmRRQDlg.sbr"
174 -@erase "$(INTDIR)\ConfirmWRQDlg.obj"
175 -@erase "$(INTDIR)\ConfirmWRQDlg.sbr"
176 -@erase "$(INTDIR)\PropsNetwork.obj"
177 -@erase "$(INTDIR)\PropsNetwork.sbr"
178 -@erase "$(INTDIR)\PropsServer.obj"
179 -@erase "$(INTDIR)\PropsServer.sbr"
180 -@erase "$(INTDIR)\PropsSounds.obj"
181 -@erase "$(INTDIR)\PropsSounds.sbr"
182 -@erase "$(INTDIR)\pumpkin.cn_"
183 -@erase "$(INTDIR)\pumpkin.cnt"
184 -@erase "$(INTDIR)\pumpkin.hl_"
185 -@erase "$(INTDIR)\pumpkin.hlp"
186 -@erase "$(INTDIR)\PumpKIN.obj"
187 -@erase "$(INTDIR)\pumpkin.pch"
188 -@erase "$(INTDIR)\PumpKIN.res"
189 -@erase "$(INTDIR)\PumpKIN.sbr"
190 -@erase "$(INTDIR)\PumpKINDlg.obj"
191 -@erase "$(INTDIR)\PumpKINDlg.sbr"
192 -@erase "$(INTDIR)\RequestDlg.obj"
193 -@erase "$(INTDIR)\RequestDlg.sbr"
194 -@erase "$(INTDIR)\Resolver.obj"
195 -@erase "$(INTDIR)\Resolver.sbr"
196 -@erase "$(INTDIR)\Retrier.obj"
197 -@erase "$(INTDIR)\Retrier.sbr"
198 -@erase "$(INTDIR)\StdAfx.obj"
199 -@erase "$(INTDIR)\StdAfx.sbr"
200 -@erase "$(INTDIR)\Trayer.obj"
201 -@erase "$(INTDIR)\Trayer.sbr"
202 -@erase "$(INTDIR)\vc40.idb"
203 -@erase "$(INTDIR)\vc40.pdb"
204 -@erase "$(OUTDIR)\pumpkin.bsc"
205 -@erase "$(OUTDIR)\pumpkin.ex_"
206 -@erase "$(OUTDIR)\pumpkin.exe"
207 -@erase "$(OUTDIR)\pumpkin.ilk"
208 -@erase "$(OUTDIR)\pumpkin.pdb"
209
210"$(OUTDIR)" :
211 if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
212
213# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /c
214# 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
215CPP_PROJ=/nologo /Zp1 /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D\
216 "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR"$(INTDIR)/" /Fp"$(INTDIR)/pumpkin.pch"\
217 /Yu"stdafx.h" /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c
218CPP_OBJS=.\Debug/
219CPP_SBRS=.\Debug/
220# ADD BASE MTL /nologo /D "_DEBUG" /win32
221# ADD MTL /nologo /D "_DEBUG" /win32
222MTL_PROJ=/nologo /D "_DEBUG" /win32
223# ADD BASE RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
224# ADD RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
225RSC_PROJ=/l 0x409 /fo"$(INTDIR)/PumpKIN.res" /d "_DEBUG" /d "_AFXDLL"
226BSC32=bscmake.exe
227# ADD BASE BSC32 /nologo
228# ADD BSC32 /nologo
229BSC32_FLAGS=/nologo /o"$(OUTDIR)/pumpkin.bsc"
230BSC32_SBRS= \
231 "$(INTDIR)\ConfirmRRQDlg.sbr" \
232 "$(INTDIR)\ConfirmWRQDlg.sbr" \
233 "$(INTDIR)\PropsNetwork.sbr" \
234 "$(INTDIR)\PropsServer.sbr" \
235 "$(INTDIR)\PropsSounds.sbr" \
236 "$(INTDIR)\PumpKIN.sbr" \
237 "$(INTDIR)\PumpKINDlg.sbr" \
238 "$(INTDIR)\RequestDlg.sbr" \
239 "$(INTDIR)\Resolver.sbr" \
240 "$(INTDIR)\Retrier.sbr" \
241 "$(INTDIR)\StdAfx.sbr" \
242 "$(INTDIR)\Trayer.sbr"
243
244"$(OUTDIR)\pumpkin.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
245 $(BSC32) @<<
246 $(BSC32_FLAGS) $(BSC32_SBRS)
247<<
248
249LINK32=link.exe
250# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386
251# ADD LINK32 /nologo /subsystem:windows /debug /machine:I386
252LINK32_FLAGS=/nologo /subsystem:windows /incremental:yes\
253 /pdb:"$(OUTDIR)/pumpkin.pdb" /debug /machine:I386 /out:"$(OUTDIR)/pumpkin.exe"
254LINK32_OBJS= \
255 "$(INTDIR)\ConfirmRRQDlg.obj" \
256 "$(INTDIR)\ConfirmWRQDlg.obj" \
257 "$(INTDIR)\PropsNetwork.obj" \
258 "$(INTDIR)\PropsServer.obj" \
259 "$(INTDIR)\PropsSounds.obj" \
260 "$(INTDIR)\PumpKIN.obj" \
261 "$(INTDIR)\PumpKIN.res" \
262 "$(INTDIR)\PumpKINDlg.obj" \
263 "$(INTDIR)\RequestDlg.obj" \
264 "$(INTDIR)\Resolver.obj" \
265 "$(INTDIR)\Retrier.obj" \
266 "$(INTDIR)\StdAfx.obj" \
267 "$(INTDIR)\Trayer.obj"
268
269"$(OUTDIR)\pumpkin.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
270 $(LINK32) @<<
271 $(LINK32_FLAGS) $(LINK32_OBJS)
272<<
273
274# Begin Custom Build
275OutDir=.\Debug
276TargetName=pumpkin
277InputPath=.\Debug\pumpkin.exe
278SOURCE=$(InputPath)
279
280"$(OutDir)\$(TargetName).ex_" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
281 compress $(OutDir)\$(TargetName).exe $(OutDir)\$(TargetName).ex_
282
283# End Custom Build
284
285!ELSEIF "$(CFG)" == "PumpKIN - Win32 Static"
286
287# PROP BASE Use_MFC 6
288# PROP BASE Use_Debug_Libraries 0
289# PROP BASE Output_Dir "PumpKIN_"
290# PROP BASE Intermediate_Dir "PumpKIN_"
291# PROP BASE Target_Dir ""
292# PROP Use_MFC 5
293# PROP Use_Debug_Libraries 0
294# PROP Output_Dir "Releast"
295# PROP Intermediate_Dir "Releast"
296# PROP Target_Dir ""
297OUTDIR=.\Releast
298INTDIR=.\Releast
299# Begin Custom Macros
300OutDir=.\Releast
301TargetName=pumpkin
302# End Custom Macros
303
304ALL : "$(OUTDIR)\pumpkin.exe" "$(OUTDIR)\pumpkin.ex_" "$(OUTDIR)\pumpkin.hlp"\
305 "$(OUTDIR)\pumpkin.cnt" "$(OUTDIR)\pumpkin.hl_" "$(OUTDIR)\pumpkin.cn_"
306
307CLEAN :
308 -@erase "$(INTDIR)\ConfirmRRQDlg.obj"
309 -@erase "$(INTDIR)\ConfirmWRQDlg.obj"
310 -@erase "$(INTDIR)\PropsNetwork.obj"
311 -@erase "$(INTDIR)\PropsServer.obj"
312 -@erase "$(INTDIR)\PropsSounds.obj"
313 -@erase "$(INTDIR)\pumpkin.cn_"
314 -@erase "$(INTDIR)\pumpkin.cnt"
315 -@erase "$(INTDIR)\pumpkin.hl_"
316 -@erase "$(INTDIR)\pumpkin.hlp"
317 -@erase "$(INTDIR)\PumpKIN.obj"
318 -@erase "$(INTDIR)\pumpkin.pch"
319 -@erase "$(INTDIR)\PumpKIN.res"
320 -@erase "$(INTDIR)\PumpKINDlg.obj"
321 -@erase "$(INTDIR)\RequestDlg.obj"
322 -@erase "$(INTDIR)\Resolver.obj"
323 -@erase "$(INTDIR)\Retrier.obj"
324 -@erase "$(INTDIR)\StdAfx.obj"
325 -@erase "$(INTDIR)\Trayer.obj"
326 -@erase "$(OUTDIR)\pumpkin.ex_"
327 -@erase "$(OUTDIR)\pumpkin.exe"
328
329"$(OUTDIR)" :
330 if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
331
332# ADD BASE CPP /nologo /Zp1 /MD /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /Yu"stdafx.h" /c
333# ADD CPP /nologo /Zp1 /MT /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Yu"stdafx.h" /c
334CPP_PROJ=/nologo /Zp1 /MT /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D\
335 "_MBCS" /Fp"$(INTDIR)/pumpkin.pch" /Yu"stdafx.h" /Fo"$(INTDIR)/" /c
336CPP_OBJS=.\Releast/
337CPP_SBRS=.\.
338# ADD BASE MTL /nologo /D "NDEBUG" /win32
339# ADD MTL /nologo /D "NDEBUG" /win32
340MTL_PROJ=/nologo /D "NDEBUG" /win32
341# ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
342# ADD RSC /l 0x409 /d "NDEBUG"
343RSC_PROJ=/l 0x409 /fo"$(INTDIR)/PumpKIN.res" /d "NDEBUG"
344BSC32=bscmake.exe
345# ADD BASE BSC32 /nologo
346# ADD BSC32 /nologo
347BSC32_FLAGS=/nologo /o"$(OUTDIR)/pumpkin.bsc"
348BSC32_SBRS= \
349
350LINK32=link.exe
351# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
352# ADD LINK32 /nologo /subsystem:windows /machine:I386
353LINK32_FLAGS=/nologo /subsystem:windows /incremental:no\
354 /pdb:"$(OUTDIR)/pumpkin.pdb" /machine:I386 /out:"$(OUTDIR)/pumpkin.exe"
355LINK32_OBJS= \
356 "$(INTDIR)\ConfirmRRQDlg.obj" \
357 "$(INTDIR)\ConfirmWRQDlg.obj" \
358 "$(INTDIR)\PropsNetwork.obj" \
359 "$(INTDIR)\PropsServer.obj" \
360 "$(INTDIR)\PropsSounds.obj" \
361 "$(INTDIR)\PumpKIN.obj" \
362 "$(INTDIR)\PumpKIN.res" \
363 "$(INTDIR)\PumpKINDlg.obj" \
364 "$(INTDIR)\RequestDlg.obj" \
365 "$(INTDIR)\Resolver.obj" \
366 "$(INTDIR)\Retrier.obj" \
367 "$(INTDIR)\StdAfx.obj" \
368 "$(INTDIR)\Trayer.obj"
369
370"$(OUTDIR)\pumpkin.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
371 $(LINK32) @<<
372 $(LINK32_FLAGS) $(LINK32_OBJS)
373<<
374
375# Begin Custom Build
376OutDir=.\Releast
377TargetName=pumpkin
378InputPath=.\Releast\pumpkin.exe
379SOURCE=$(InputPath)
380
381"$(OutDir)\$(TargetName).ex_" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
382 compress $(OutDir)\$(TargetName).exe $(OutDir)\$(TargetName).ex_
383
384# End Custom Build
385
386!ELSEIF "$(CFG)" == "Install - Win32 Debug"
387
388# PROP BASE Use_MFC 2
389# PROP BASE Use_Debug_Libraries 1
390# PROP BASE Output_Dir "Install\Debug"
391# PROP BASE Intermediate_Dir "Install\Debug"
392# PROP BASE Target_Dir "Install"
393# PROP Use_MFC 0
394# PROP Use_Debug_Libraries 1
395# PROP Output_Dir "Install\Debug"
396# PROP Intermediate_Dir "Install\Debug"
397# PROP Target_Dir "Install"
398OUTDIR=.\Install\Debug
399INTDIR=.\Install\Debug
400
401ALL : "$(OUTDIR)\Install.exe"
402
403CLEAN :
404 -@erase "$(INTDIR)\install.obj"
405 -@erase "$(INTDIR)\Install.res"
406 -@erase "$(INTDIR)\vc40.idb"
407 -@erase "$(INTDIR)\vc40.pdb"
408 -@erase "$(OUTDIR)\Install.exe"
409 -@erase "$(OUTDIR)\Install.ilk"
410 -@erase "$(OUTDIR)\Install.pdb"
411
412"$(OUTDIR)" :
413 if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
414
415# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /YX /c
416# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /c
417CPP_PROJ=/nologo /MLd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS"\
418 /D "_MBCS" /Fp"$(INTDIR)/Install.pch" /YX /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c
419CPP_OBJS=.\Install\Debug/
420CPP_SBRS=.\.
421# ADD BASE MTL /nologo /D "_DEBUG" /win32
422# ADD MTL /nologo /D "_DEBUG" /win32
423MTL_PROJ=/nologo /D "_DEBUG" /win32
424# ADD BASE RSC /l 0x409 /d "_DEBUG" /d "_AFXDLL"
425# ADD RSC /l 0x409 /d "_DEBUG"
426RSC_PROJ=/l 0x409 /fo"$(INTDIR)/Install.res" /d "_DEBUG"
427BSC32=bscmake.exe
428# ADD BASE BSC32 /nologo
429# ADD BSC32 /nologo
430BSC32_FLAGS=/nologo /o"$(OUTDIR)/Install.bsc"
431BSC32_SBRS= \
432
433LINK32=link.exe
434# ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386
435# 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
436LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
437 advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
438 odbccp32.lib version.lib /nologo /subsystem:windows /incremental:yes\
439 /pdb:"$(OUTDIR)/Install.pdb" /debug /machine:I386 /out:"$(OUTDIR)/Install.exe"
440LINK32_OBJS= \
441 "$(INTDIR)\install.obj" \
442 "$(INTDIR)\Install.res"
443
444"$(OUTDIR)\Install.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
445 $(LINK32) @<<
446 $(LINK32_FLAGS) $(LINK32_OBJS)
447<<
448
449!ELSEIF "$(CFG)" == "Install - Win32 Pure"
450
451# PROP BASE Use_MFC 2
452# PROP BASE Use_Debug_Libraries 0
453# PROP BASE Output_Dir "Install\Pure"
454# PROP BASE Intermediate_Dir "Install\Pure"
455# PROP BASE Target_Dir "Install"
456# PROP Use_MFC 0
457# PROP Use_Debug_Libraries 0
458# PROP Output_Dir "Install\Pure"
459# PROP Intermediate_Dir "Install\Pure"
460# PROP Target_Dir "Install"
461OUTDIR=.\Install\Pure
462INTDIR=.\Install\Pure
463
464ALL : "$(OUTDIR)\Install.exe"
465
466CLEAN :
467 -@erase "$(INTDIR)\install.obj"
468 -@erase "$(INTDIR)\Install.res"
469 -@erase "$(OUTDIR)\Install.exe"
470
471"$(OUTDIR)" :
472 if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
473
474# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /YX /c
475# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /c
476CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D\
477 "_MBCS" /Fp"$(INTDIR)/Install.pch" /YX /Fo"$(INTDIR)/" /c
478CPP_OBJS=.\Install\Pure/
479CPP_SBRS=.\.
480# ADD BASE MTL /nologo /D "NDEBUG" /win32
481# ADD MTL /nologo /D "NDEBUG" /win32
482MTL_PROJ=/nologo /D "NDEBUG" /win32
483# ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
484# ADD RSC /l 0x409 /d "NDEBUG"
485RSC_PROJ=/l 0x409 /fo"$(INTDIR)/Install.res" /d "NDEBUG"
486BSC32=bscmake.exe
487# ADD BASE BSC32 /nologo
488# ADD BSC32 /nologo
489BSC32_FLAGS=/nologo /o"$(OUTDIR)/Install.bsc"
490BSC32_SBRS= \
491
492LINK32=link.exe
493# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
494# 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
495LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
496 advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
497 odbccp32.lib version.lib /nologo /subsystem:windows /incremental:no\
498 /pdb:"$(OUTDIR)/Install.pdb" /machine:I386 /out:"$(OUTDIR)/Install.exe"
499LINK32_OBJS= \
500 "$(INTDIR)\install.obj" \
501 "$(INTDIR)\Install.res"
502
503"$(OUTDIR)\Install.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
504 $(LINK32) @<<
505 $(LINK32_FLAGS) $(LINK32_OBJS)
506<<
507
508!ELSEIF "$(CFG)" == "Install - Win32 Static"
509
510# PROP BASE Use_MFC 2
511# PROP BASE Use_Debug_Libraries 0
512# PROP BASE Output_Dir "Install\Static"
513# PROP BASE Intermediate_Dir "Install\Static"
514# PROP BASE Target_Dir "Install"
515# PROP Use_MFC 0
516# PROP Use_Debug_Libraries 0
517# PROP Output_Dir "Install\Static"
518# PROP Intermediate_Dir "Install\Static"
519# PROP Target_Dir "Install"
520OUTDIR=.\Install\Static
521INTDIR=.\Install\Static
522
523ALL : "$(OUTDIR)\Install.exe"
524
525CLEAN :
526 -@erase "$(INTDIR)\install.obj"
527 -@erase "$(INTDIR)\Install.res"
528 -@erase "$(OUTDIR)\Install.exe"
529
530"$(OUTDIR)" :
531 if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
532
533# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /YX /c
534# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "STATI_K" /YX /c
535CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D\
536 "_MBCS" /D "STATI_K" /Fp"$(INTDIR)/Install.pch" /YX /Fo"$(INTDIR)/" /c
537CPP_OBJS=.\Install\Static/
538CPP_SBRS=.\.
539# ADD BASE MTL /nologo /D "NDEBUG" /win32
540# ADD MTL /nologo /D "NDEBUG" /win32
541MTL_PROJ=/nologo /D "NDEBUG" /win32
542# ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
543# ADD RSC /l 0x409 /d "NDEBUG" /d "STATI_K"
544RSC_PROJ=/l 0x409 /fo"$(INTDIR)/Install.res" /d "NDEBUG" /d "STATI_K"
545BSC32=bscmake.exe
546# ADD BASE BSC32 /nologo
547# ADD BSC32 /nologo
548BSC32_FLAGS=/nologo /o"$(OUTDIR)/Install.bsc"
549BSC32_SBRS= \
550
551LINK32=link.exe
552# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
553# 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
554LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
555 advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
556 odbccp32.lib version.lib /nologo /subsystem:windows /incremental:no\
557 /pdb:"$(OUTDIR)/Install.pdb" /machine:I386 /out:"$(OUTDIR)/Install.exe"
558LINK32_OBJS= \
559 "$(INTDIR)\install.obj" \
560 "$(INTDIR)\Install.res"
561
562"$(OUTDIR)\Install.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
563 $(LINK32) @<<
564 $(LINK32_FLAGS) $(LINK32_OBJS)
565<<
566
567!ELSEIF "$(CFG)" == "Install - Win32 Canned"
568
569# PROP BASE Use_MFC 2
570# PROP BASE Use_Debug_Libraries 0
571# PROP BASE Output_Dir "Install\Canned"
572# PROP BASE Intermediate_Dir "Install\Canned"
573# PROP BASE Target_Dir "Install"
574# PROP Use_MFC 0
575# PROP Use_Debug_Libraries 0
576# PROP Output_Dir "Install\Canned"
577# PROP Intermediate_Dir "Install\Canned"
578# PROP Target_Dir "Install"
579OUTDIR=.\Install\Canned
580INTDIR=.\Install\Canned
581
582ALL : "$(OUTDIR)\Install.exe"
583
584CLEAN :
585 -@erase "$(INTDIR)\install.obj"
586 -@erase "$(INTDIR)\Install.res"
587 -@erase "$(OUTDIR)\Install.exe"
588
589"$(OUTDIR)" :
590 if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
591
592# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /YX /c
593# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "K_ANNED" /YX /c
594CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D\
595 "_MBCS" /D "K_ANNED" /Fp"$(INTDIR)/Install.pch" /YX /Fo"$(INTDIR)/" /c
596CPP_OBJS=.\Install\Canned/
597CPP_SBRS=.\.
598# ADD BASE MTL /nologo /D "NDEBUG" /win32
599# ADD MTL /nologo /D "NDEBUG" /win32
600MTL_PROJ=/nologo /D "NDEBUG" /win32
601# ADD BASE RSC /l 0x409 /d "NDEBUG" /d "_AFXDLL"
602# ADD RSC /l 0x409 /d "NDEBUG" /d "K_ANNED"
603RSC_PROJ=/l 0x409 /fo"$(INTDIR)/Install.res" /d "NDEBUG" /d "K_ANNED"
604BSC32=bscmake.exe
605# ADD BASE BSC32 /nologo
606# ADD BSC32 /nologo
607BSC32_FLAGS=/nologo /o"$(OUTDIR)/Install.bsc"
608BSC32_SBRS= \
609
610LINK32=link.exe
611# ADD BASE LINK32 /nologo /subsystem:windows /machine:I386
612# 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
613LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
614 advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
615 odbccp32.lib version.lib /nologo /subsystem:windows /incremental:no\
616 /pdb:"$(OUTDIR)/Install.pdb" /machine:I386 /out:"$(OUTDIR)/Install.exe"
617LINK32_OBJS= \
618 "$(INTDIR)\install.obj" \
619 "$(INTDIR)\Install.res"
620
621"$(OUTDIR)\Install.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
622 $(LINK32) @<<
623 $(LINK32_FLAGS) $(LINK32_OBJS)
624<<
625
626!ENDIF
627
628.c{$(CPP_OBJS)}.obj:
629 $(CPP) $(CPP_PROJ) $<
630
631.cpp{$(CPP_OBJS)}.obj:
632 $(CPP) $(CPP_PROJ) $<
633
634.cxx{$(CPP_OBJS)}.obj:
635 $(CPP) $(CPP_PROJ) $<
636
637.c{$(CPP_SBRS)}.sbr:
638 $(CPP) $(CPP_PROJ) $<
639
640.cpp{$(CPP_SBRS)}.sbr:
641 $(CPP) $(CPP_PROJ) $<
642
643.cxx{$(CPP_SBRS)}.sbr:
644 $(CPP) $(CPP_PROJ) $<
645
646################################################################################
647# Begin Target
648
649# Name "PumpKIN - Win32 Release"
650# Name "PumpKIN - Win32 Debug"
651# Name "PumpKIN - Win32 Static"
652
653!IF "$(CFG)" == "PumpKIN - Win32 Release"
654
655!ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug"
656
657!ELSEIF "$(CFG)" == "PumpKIN - Win32 Static"
658
659!ENDIF
660
661################################################################################
662# Begin Source File
663
664SOURCE=.\PumpKIN.cpp
665DEP_CPP_PUMPK=\
666 ".\PumpKIN.h"\
667 ".\PumpKINDlg.h"\
668 ".\shared-code\BellsNWhistles.h"\
669 ".\shared-code\kHelpers.h"\
670 ".\stdafx.h"\
671
672
673!IF "$(CFG)" == "PumpKIN - Win32 Release"
674
675
676"$(INTDIR)\PumpKIN.obj" : $(SOURCE) $(DEP_CPP_PUMPK) "$(INTDIR)"\
677 "$(INTDIR)\pumpkin.pch"
678
679
680!ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug"
681
682
683"$(INTDIR)\PumpKIN.obj" : $(SOURCE) $(DEP_CPP_PUMPK) "$(INTDIR)"\
684 "$(INTDIR)\pumpkin.pch"
685
686"$(INTDIR)\PumpKIN.sbr" : $(SOURCE) $(DEP_CPP_PUMPK) "$(INTDIR)"\
687 "$(INTDIR)\pumpkin.pch"
688
689
690!ELSEIF "$(CFG)" == "PumpKIN - Win32 Static"
691
692
693"$(INTDIR)\PumpKIN.obj" : $(SOURCE) $(DEP_CPP_PUMPK) "$(INTDIR)"\
694 "$(INTDIR)\pumpkin.pch"
695
696
697!ENDIF
698
699# End Source File
700################################################################################
701# Begin Source File
702
703SOURCE=.\PumpKINDlg.cpp
704DEP_CPP_PUMPKI=\
705 ".\ConfirmRRQDlg.h"\
706 ".\ConfirmWRQDlg.h"\
707 ".\PropsNetwork.h"\
708 ".\PropsServer.h"\
709 ".\PropsSounds.h"\
710 ".\PumpKIN.h"\
711 ".\PumpKINDlg.h"\
712 ".\RequestDlg.h"\
713 ".\Resolver.h"\
714 ".\Retrier.h"\
715 ".\shared-code\BellsNWhistles.h"\
716 ".\shared-code\kHelpers.h"\
717 ".\stdafx.h"\
718 ".\Trayer.h"\
719
720
721!IF "$(CFG)" == "PumpKIN - Win32 Release"
722
723
724"$(INTDIR)\PumpKINDlg.obj" : $(SOURCE) $(DEP_CPP_PUMPKI) "$(INTDIR)"\
725 "$(INTDIR)\pumpkin.pch"
726
727
728!ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug"
729
730
731"$(INTDIR)\PumpKINDlg.obj" : $(SOURCE) $(DEP_CPP_PUMPKI) "$(INTDIR)"\
732 "$(INTDIR)\pumpkin.pch"
733
734"$(INTDIR)\PumpKINDlg.sbr" : $(SOURCE) $(DEP_CPP_PUMPKI) "$(INTDIR)"\
735 "$(INTDIR)\pumpkin.pch"
736
737
738!ELSEIF "$(CFG)" == "PumpKIN - Win32 Static"
739
740
741"$(INTDIR)\PumpKINDlg.obj" : $(SOURCE) $(DEP_CPP_PUMPKI) "$(INTDIR)"\
742 "$(INTDIR)\pumpkin.pch"
743
744
745!ENDIF
746
747# End Source File
748################################################################################
749# Begin Source File
750
751SOURCE=.\StdAfx.cpp
752DEP_CPP_STDAF=\
753 ".\shared-code\BellsNWhistles.h"\
754 ".\shared-code\kHelpers.h"\
755 ".\stdafx.h"\
756
757
758!IF "$(CFG)" == "PumpKIN - Win32 Release"
759
760# ADD CPP /Yc"stdafx.h"
761
762BuildCmds= \
763 $(CPP) /nologo /Zp1 /MD /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D\
764 "_AFXDLL" /D "_MBCS" /Fp"$(INTDIR)/pumpkin.pch" /Yc"stdafx.h" /Fo"$(INTDIR)/"\
765 /c $(SOURCE) \
766
767
768"$(INTDIR)\StdAfx.obj" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)"
769 $(BuildCmds)
770
771"$(INTDIR)\pumpkin.pch" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)"
772 $(BuildCmds)
773
774!ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug"
775
776# ADD CPP /Yc"stdafx.h"
777
778BuildCmds= \
779 $(CPP) /nologo /Zp1 /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D\
780 "_WINDOWS" /D "_AFXDLL" /D "_MBCS" /FR"$(INTDIR)/" /Fp"$(INTDIR)/pumpkin.pch"\
781 /Yc"stdafx.h" /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c $(SOURCE) \
782
783
784"$(INTDIR)\StdAfx.obj" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)"
785 $(BuildCmds)
786
787"$(INTDIR)\StdAfx.sbr" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)"
788 $(BuildCmds)
789
790"$(INTDIR)\pumpkin.pch" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)"
791 $(BuildCmds)
792
793!ELSEIF "$(CFG)" == "PumpKIN - Win32 Static"
794
795# ADD BASE CPP /Yc"stdafx.h"
796# ADD CPP /Yc"stdafx.h"
797
798BuildCmds= \
799 $(CPP) /nologo /Zp1 /MT /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D\
800 "_MBCS" /Fp"$(INTDIR)/pumpkin.pch" /Yc"stdafx.h" /Fo"$(INTDIR)/" /c $(SOURCE) \
801
802
803"$(INTDIR)\StdAfx.obj" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)"
804 $(BuildCmds)
805
806"$(INTDIR)\pumpkin.pch" : $(SOURCE) $(DEP_CPP_STDAF) "$(INTDIR)"
807 $(BuildCmds)
808
809!ENDIF
810
811# End Source File
812################################################################################
813# Begin Source File
814
815SOURCE=.\pumpkin.rc
816DEP_RSC_PUMPKIN=\
817 ".\res\failed.wav"\
818 ".\res\finished.wav"\
819 ".\res\PumpKIN.ico"\
820 ".\res\pumpkin.rc2"\
821 ".\res\ring.wav"\
822 ".\res\rrq.ico"\
823 ".\res\wrq.ico"\
824 ".\shared-data\browse-icon.ico"\
825 ".\shared-data\klever-background.bmp"\
826 ".\shared-data\play-icon.ico"\
827
828
829!IF "$(CFG)" == "PumpKIN - Win32 Release"
830
831
832"$(INTDIR)\PumpKIN.res" : $(SOURCE) $(DEP_RSC_PUMPKIN) "$(INTDIR)"
833 $(RSC) $(RSC_PROJ) $(SOURCE)
834
835
836!ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug"
837
838
839"$(INTDIR)\PumpKIN.res" : $(SOURCE) $(DEP_RSC_PUMPKIN) "$(INTDIR)"
840 $(RSC) $(RSC_PROJ) $(SOURCE)
841
842
843!ELSEIF "$(CFG)" == "PumpKIN - Win32 Static"
844
845
846"$(INTDIR)\PumpKIN.res" : $(SOURCE) $(DEP_RSC_PUMPKIN) "$(INTDIR)"
847 $(RSC) $(RSC_PROJ) $(SOURCE)
848
849
850!ENDIF
851
852# End Source File
853################################################################################
854# Begin Source File
855
856SOURCE=.\help\pumpkin.hpj
857
858!IF "$(CFG)" == "PumpKIN - Win32 Release"
859
860# Begin Custom Build - Making help files...
861OutDir=.\Release
862ProjDir=.
863TargetName=pumpkin
864InputPath=.\help\pumpkin.hpj
865
866BuildCmds= \
867 "$(ProjDir)\makehelp.bat" \
868 compress $(OutDir)\$(TargetName).hlp $(OutDir)\$(TargetName).hl_ \
869 compress $(OutDir)\$(TargetName).cnt $(OutDir)\$(TargetName).cn_ \
870
871
872"$(OutDir)\$(TargetName).hlp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
873 $(BuildCmds)
874
875"$(OutDir)\$(TargetName).cnt" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
876 $(BuildCmds)
877
878"$(OutDir)\$(TargetName).hl_" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
879 $(BuildCmds)
880
881"$(OutDir)\$(TargetName).cn_" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
882 $(BuildCmds)
883# End Custom Build
884
885!ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug"
886
887# Begin Custom Build - Making help files...
888OutDir=.\Debug
889ProjDir=.
890TargetName=pumpkin
891InputPath=.\help\pumpkin.hpj
892
893BuildCmds= \
894 "$(ProjDir)\makehelp.bat" \
895 compress $(OutDir)\$(TargetName).hlp $(OutDir)\$(TargetName).hl_ \
896 compress $(OutDir)\$(TargetName).cnt $(OutDir)\$(TargetName).cn_ \
897
898
899"$(OutDir)\$(TargetName).hlp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
900 $(BuildCmds)
901
902"$(OutDir)\$(TargetName).cnt" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
903 $(BuildCmds)
904
905"$(OutDir)\$(TargetName).hl_" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
906 $(BuildCmds)
907
908"$(OutDir)\$(TargetName).cn_" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
909 $(BuildCmds)
910# End Custom Build
911
912!ELSEIF "$(CFG)" == "PumpKIN - Win32 Static"
913
914# Begin Custom Build - Making help files...
915OutDir=.\Releast
916ProjDir=.
917TargetName=pumpkin
918InputPath=.\help\pumpkin.hpj
919
920BuildCmds= \
921 "$(ProjDir)\makehelp.bat" \
922 compress $(OutDir)\$(TargetName).hlp $(OutDir)\$(TargetName).hl_ \
923 compress $(OutDir)\$(TargetName).cnt $(OutDir)\$(TargetName).cn_ \
924
925
926"$(OutDir)\$(TargetName).hlp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
927 $(BuildCmds)
928
929"$(OutDir)\$(TargetName).cnt" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
930 $(BuildCmds)
931
932"$(OutDir)\$(TargetName).hl_" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
933 $(BuildCmds)
934
935"$(OutDir)\$(TargetName).cn_" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
936 $(BuildCmds)
937# End Custom Build
938
939!ENDIF
940
941# End Source File
942################################################################################
943# Begin Source File
944
945SOURCE=.\PropsServer.cpp
946DEP_CPP_PROPS=\
947 ".\PropsServer.h"\
948 ".\PumpKIN.h"\
949 ".\shared-code\BellsNWhistles.h"\
950 ".\shared-code\kHelpers.h"\
951 ".\stdafx.h"\
952
953
954!IF "$(CFG)" == "PumpKIN - Win32 Release"
955
956
957"$(INTDIR)\PropsServer.obj" : $(SOURCE) $(DEP_CPP_PROPS) "$(INTDIR)"\
958 "$(INTDIR)\pumpkin.pch"
959
960
961!ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug"
962
963
964"$(INTDIR)\PropsServer.obj" : $(SOURCE) $(DEP_CPP_PROPS) "$(INTDIR)"\
965 "$(INTDIR)\pumpkin.pch"
966
967"$(INTDIR)\PropsServer.sbr" : $(SOURCE) $(DEP_CPP_PROPS) "$(INTDIR)"\
968 "$(INTDIR)\pumpkin.pch"
969
970
971!ELSEIF "$(CFG)" == "PumpKIN - Win32 Static"
972
973
974"$(INTDIR)\PropsServer.obj" : $(SOURCE) $(DEP_CPP_PROPS) "$(INTDIR)"\
975 "$(INTDIR)\pumpkin.pch"
976
977
978!ENDIF
979
980# End Source File
981################################################################################
982# Begin Source File
983
984SOURCE=.\PropsNetwork.cpp
985DEP_CPP_PROPSN=\
986 ".\PropsNetwork.h"\
987 ".\PumpKIN.h"\
988 ".\shared-code\BellsNWhistles.h"\
989 ".\shared-code\kHelpers.h"\
990 ".\stdafx.h"\
991
992
993!IF "$(CFG)" == "PumpKIN - Win32 Release"
994
995
996"$(INTDIR)\PropsNetwork.obj" : $(SOURCE) $(DEP_CPP_PROPSN) "$(INTDIR)"\
997 "$(INTDIR)\pumpkin.pch"
998
999
1000!ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug"
1001
1002
1003"$(INTDIR)\PropsNetwork.obj" : $(SOURCE) $(DEP_CPP_PROPSN) "$(INTDIR)"\
1004 "$(INTDIR)\pumpkin.pch"
1005
1006"$(INTDIR)\PropsNetwork.sbr" : $(SOURCE) $(DEP_CPP_PROPSN) "$(INTDIR)"\
1007 "$(INTDIR)\pumpkin.pch"
1008
1009
1010!ELSEIF "$(CFG)" == "PumpKIN - Win32 Static"
1011
1012
1013"$(INTDIR)\PropsNetwork.obj" : $(SOURCE) $(DEP_CPP_PROPSN) "$(INTDIR)"\
1014 "$(INTDIR)\pumpkin.pch"
1015
1016
1017!ENDIF
1018
1019# End Source File
1020################################################################################
1021# Begin Source File
1022
1023SOURCE=.\ConfirmRRQDlg.cpp
1024DEP_CPP_CONFI=\
1025 ".\ConfirmRRQDlg.h"\
1026 ".\PumpKIN.h"\
1027 ".\PumpKINDlg.h"\
1028 ".\shared-code\BellsNWhistles.h"\
1029 ".\shared-code\kHelpers.h"\
1030 ".\stdafx.h"\
1031
1032
1033!IF "$(CFG)" == "PumpKIN - Win32 Release"
1034
1035
1036"$(INTDIR)\ConfirmRRQDlg.obj" : $(SOURCE) $(DEP_CPP_CONFI) "$(INTDIR)"\
1037 "$(INTDIR)\pumpkin.pch"
1038
1039
1040!ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug"
1041
1042
1043"$(INTDIR)\ConfirmRRQDlg.obj" : $(SOURCE) $(DEP_CPP_CONFI) "$(INTDIR)"\
1044 "$(INTDIR)\pumpkin.pch"
1045
1046"$(INTDIR)\ConfirmRRQDlg.sbr" : $(SOURCE) $(DEP_CPP_CONFI) "$(INTDIR)"\
1047 "$(INTDIR)\pumpkin.pch"
1048
1049
1050!ELSEIF "$(CFG)" == "PumpKIN - Win32 Static"
1051
1052
1053"$(INTDIR)\ConfirmRRQDlg.obj" : $(SOURCE) $(DEP_CPP_CONFI) "$(INTDIR)"\
1054 "$(INTDIR)\pumpkin.pch"
1055
1056
1057!ENDIF
1058
1059# End Source File
1060################################################################################
1061# Begin Source File
1062
1063SOURCE=.\ConfirmWRQDlg.cpp
1064DEP_CPP_CONFIR=\
1065 ".\ConfirmWRQDlg.h"\
1066 ".\PumpKIN.h"\
1067 ".\PumpKINDlg.h"\
1068 ".\shared-code\BellsNWhistles.h"\
1069 ".\shared-code\kHelpers.h"\
1070 ".\stdafx.h"\
1071
1072
1073!IF "$(CFG)" == "PumpKIN - Win32 Release"
1074
1075
1076"$(INTDIR)\ConfirmWRQDlg.obj" : $(SOURCE) $(DEP_CPP_CONFIR) "$(INTDIR)"\
1077 "$(INTDIR)\pumpkin.pch"
1078
1079
1080!ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug"
1081
1082
1083"$(INTDIR)\ConfirmWRQDlg.obj" : $(SOURCE) $(DEP_CPP_CONFIR) "$(INTDIR)"\
1084 "$(INTDIR)\pumpkin.pch"
1085
1086"$(INTDIR)\ConfirmWRQDlg.sbr" : $(SOURCE) $(DEP_CPP_CONFIR) "$(INTDIR)"\
1087 "$(INTDIR)\pumpkin.pch"
1088
1089
1090!ELSEIF "$(CFG)" == "PumpKIN - Win32 Static"
1091
1092
1093"$(INTDIR)\ConfirmWRQDlg.obj" : $(SOURCE) $(DEP_CPP_CONFIR) "$(INTDIR)"\
1094 "$(INTDIR)\pumpkin.pch"
1095
1096
1097!ENDIF
1098
1099# End Source File
1100################################################################################
1101# Begin Source File
1102
1103SOURCE=.\RequestDlg.cpp
1104DEP_CPP_REQUE=\
1105 ".\PumpKIN.h"\
1106 ".\RequestDlg.h"\
1107 ".\shared-code\BellsNWhistles.h"\
1108 ".\shared-code\kHelpers.h"\
1109 ".\stdafx.h"\
1110
1111
1112!IF "$(CFG)" == "PumpKIN - Win32 Release"
1113
1114
1115"$(INTDIR)\RequestDlg.obj" : $(SOURCE) $(DEP_CPP_REQUE) "$(INTDIR)"\
1116 "$(INTDIR)\pumpkin.pch"
1117
1118
1119!ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug"
1120
1121
1122"$(INTDIR)\RequestDlg.obj" : $(SOURCE) $(DEP_CPP_REQUE) "$(INTDIR)"\
1123 "$(INTDIR)\pumpkin.pch"
1124
1125"$(INTDIR)\RequestDlg.sbr" : $(SOURCE) $(DEP_CPP_REQUE) "$(INTDIR)"\
1126 "$(INTDIR)\pumpkin.pch"
1127
1128
1129!ELSEIF "$(CFG)" == "PumpKIN - Win32 Static"
1130
1131
1132"$(INTDIR)\RequestDlg.obj" : $(SOURCE) $(DEP_CPP_REQUE) "$(INTDIR)"\
1133 "$(INTDIR)\pumpkin.pch"
1134
1135
1136!ENDIF
1137
1138# End Source File
1139################################################################################
1140# Begin Source File
1141
1142SOURCE=.\Resolver.cpp
1143DEP_CPP_RESOL=\
1144 ".\PumpKIN.h"\
1145 ".\PumpKINDlg.h"\
1146 ".\Resolver.h"\
1147 ".\shared-code\BellsNWhistles.h"\
1148 ".\shared-code\kHelpers.h"\
1149 ".\stdafx.h"\
1150
1151
1152!IF "$(CFG)" == "PumpKIN - Win32 Release"
1153
1154
1155"$(INTDIR)\Resolver.obj" : $(SOURCE) $(DEP_CPP_RESOL) "$(INTDIR)"\
1156 "$(INTDIR)\pumpkin.pch"
1157
1158
1159!ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug"
1160
1161
1162"$(INTDIR)\Resolver.obj" : $(SOURCE) $(DEP_CPP_RESOL) "$(INTDIR)"\
1163 "$(INTDIR)\pumpkin.pch"
1164
1165"$(INTDIR)\Resolver.sbr" : $(SOURCE) $(DEP_CPP_RESOL) "$(INTDIR)"\
1166 "$(INTDIR)\pumpkin.pch"
1167
1168
1169!ELSEIF "$(CFG)" == "PumpKIN - Win32 Static"
1170
1171
1172"$(INTDIR)\Resolver.obj" : $(SOURCE) $(DEP_CPP_RESOL) "$(INTDIR)"\
1173 "$(INTDIR)\pumpkin.pch"
1174
1175
1176!ENDIF
1177
1178# End Source File
1179################################################################################
1180# Begin Source File
1181
1182SOURCE=.\Retrier.cpp
1183DEP_CPP_RETRI=\
1184 ".\PumpKIN.h"\
1185 ".\PumpKINDlg.h"\
1186 ".\Retrier.h"\
1187 ".\shared-code\BellsNWhistles.h"\
1188 ".\shared-code\kHelpers.h"\
1189 ".\stdafx.h"\
1190
1191
1192!IF "$(CFG)" == "PumpKIN - Win32 Release"
1193
1194
1195"$(INTDIR)\Retrier.obj" : $(SOURCE) $(DEP_CPP_RETRI) "$(INTDIR)"\
1196 "$(INTDIR)\pumpkin.pch"
1197
1198
1199!ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug"
1200
1201
1202"$(INTDIR)\Retrier.obj" : $(SOURCE) $(DEP_CPP_RETRI) "$(INTDIR)"\
1203 "$(INTDIR)\pumpkin.pch"
1204
1205"$(INTDIR)\Retrier.sbr" : $(SOURCE) $(DEP_CPP_RETRI) "$(INTDIR)"\
1206 "$(INTDIR)\pumpkin.pch"
1207
1208
1209!ELSEIF "$(CFG)" == "PumpKIN - Win32 Static"
1210
1211
1212"$(INTDIR)\Retrier.obj" : $(SOURCE) $(DEP_CPP_RETRI) "$(INTDIR)"\
1213 "$(INTDIR)\pumpkin.pch"
1214
1215
1216!ENDIF
1217
1218# End Source File
1219################################################################################
1220# Begin Source File
1221
1222SOURCE=.\Trayer.cpp
1223DEP_CPP_TRAYE=\
1224 ".\PumpKIN.h"\
1225 ".\PumpKINDlg.h"\
1226 ".\shared-code\BellsNWhistles.h"\
1227 ".\shared-code\kHelpers.h"\
1228 ".\stdafx.h"\
1229 ".\Trayer.h"\
1230
1231
1232!IF "$(CFG)" == "PumpKIN - Win32 Release"
1233
1234
1235"$(INTDIR)\Trayer.obj" : $(SOURCE) $(DEP_CPP_TRAYE) "$(INTDIR)"\
1236 "$(INTDIR)\pumpkin.pch"
1237
1238
1239!ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug"
1240
1241
1242"$(INTDIR)\Trayer.obj" : $(SOURCE) $(DEP_CPP_TRAYE) "$(INTDIR)"\
1243 "$(INTDIR)\pumpkin.pch"
1244
1245"$(INTDIR)\Trayer.sbr" : $(SOURCE) $(DEP_CPP_TRAYE) "$(INTDIR)"\
1246 "$(INTDIR)\pumpkin.pch"
1247
1248
1249!ELSEIF "$(CFG)" == "PumpKIN - Win32 Static"
1250
1251
1252"$(INTDIR)\Trayer.obj" : $(SOURCE) $(DEP_CPP_TRAYE) "$(INTDIR)"\
1253 "$(INTDIR)\pumpkin.pch"
1254
1255
1256!ENDIF
1257
1258# End Source File
1259################################################################################
1260# Begin Source File
1261
1262SOURCE=.\help\pumpkin.cnt
1263
1264!IF "$(CFG)" == "PumpKIN - Win32 Release"
1265
1266# PROP Exclude_From_Build 1
1267
1268!ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug"
1269
1270# PROP Exclude_From_Build 1
1271
1272!ELSEIF "$(CFG)" == "PumpKIN - Win32 Static"
1273
1274# PROP Exclude_From_Build 1
1275
1276!ENDIF
1277
1278# End Source File
1279################################################################################
1280# Begin Source File
1281
1282SOURCE=.\PropsSounds.cpp
1283DEP_CPP_PROPSS=\
1284 ".\PropsSounds.h"\
1285 ".\PumpKIN.h"\
1286 ".\PumpKINDlg.h"\
1287 ".\shared-code\BellsNWhistles.h"\
1288 ".\shared-code\kHelpers.h"\
1289 ".\stdafx.h"\
1290
1291
1292!IF "$(CFG)" == "PumpKIN - Win32 Release"
1293
1294
1295"$(INTDIR)\PropsSounds.obj" : $(SOURCE) $(DEP_CPP_PROPSS) "$(INTDIR)"\
1296 "$(INTDIR)\pumpkin.pch"
1297
1298
1299!ELSEIF "$(CFG)" == "PumpKIN - Win32 Debug"
1300
1301
1302"$(INTDIR)\PropsSounds.obj" : $(SOURCE) $(DEP_CPP_PROPSS) "$(INTDIR)"\
1303 "$(INTDIR)\pumpkin.pch"
1304
1305"$(INTDIR)\PropsSounds.sbr" : $(SOURCE) $(DEP_CPP_PROPSS) "$(INTDIR)"\
1306 "$(INTDIR)\pumpkin.pch"
1307
1308
1309!ELSEIF "$(CFG)" == "PumpKIN - Win32 Static"
1310
1311
1312"$(INTDIR)\PropsSounds.obj" : $(SOURCE) $(DEP_CPP_PROPSS) "$(INTDIR)"\
1313 "$(INTDIR)\pumpkin.pch"
1314
1315
1316!ENDIF
1317
1318# End Source File
1319# End Target
1320################################################################################
1321# Begin Target
1322
1323# Name "Install - Win32 Debug"
1324# Name "Install - Win32 Pure"
1325# Name "Install - Win32 Static"
1326# Name "Install - Win32 Canned"
1327
1328!IF "$(CFG)" == "Install - Win32 Debug"
1329
1330!ELSEIF "$(CFG)" == "Install - Win32 Pure"
1331
1332!ELSEIF "$(CFG)" == "Install - Win32 Static"
1333
1334!ELSEIF "$(CFG)" == "Install - Win32 Canned"
1335
1336!ENDIF
1337
1338################################################################################
1339# Begin Source File
1340
1341SOURCE=.\Install\Install.rc
1342DEP_RSC_INSTA=\
1343 ".\Install\Custom.rch"\
1344 ".\shared-data\install-icon.ico"\
1345
1346
1347!IF "$(CFG)" == "Install - Win32 Debug"
1348
1349
1350"$(INTDIR)\Install.res" : $(SOURCE) $(DEP_RSC_INSTA) "$(INTDIR)"
1351 $(RSC) /l 0x409 /fo"$(INTDIR)/Install.res" /i "Install" /d "_DEBUG"\
1352 $(SOURCE)
1353
1354
1355!ELSEIF "$(CFG)" == "Install - Win32 Pure"
1356
1357
1358"$(INTDIR)\Install.res" : $(SOURCE) $(DEP_RSC_INSTA) "$(INTDIR)"
1359 $(RSC) /l 0x409 /fo"$(INTDIR)/Install.res" /i "Install" /d "NDEBUG"\
1360 $(SOURCE)
1361
1362
1363!ELSEIF "$(CFG)" == "Install - Win32 Static"
1364
1365
1366"$(INTDIR)\Install.res" : $(SOURCE) $(DEP_RSC_INSTA) "$(INTDIR)"
1367 $(RSC) /l 0x409 /fo"$(INTDIR)/Install.res" /i "Install" /d "NDEBUG" /d\
1368 "STATI_K" $(SOURCE)
1369
1370
1371!ELSEIF "$(CFG)" == "Install - Win32 Canned"
1372
1373
1374"$(INTDIR)\Install.res" : $(SOURCE) $(DEP_RSC_INSTA) "$(INTDIR)"
1375 $(RSC) /l 0x409 /fo"$(INTDIR)/Install.res" /i "Install" /d "NDEBUG" /d\
1376 "K_ANNED" $(SOURCE)
1377
1378
1379!ENDIF
1380
1381# End Source File
1382################################################################################
1383# Begin Source File
1384
1385SOURCE=.\Install\install.cpp
1386DEP_CPP_INSTAL=\
1387 ".\shared-code\install.h"\
1388
1389
1390!IF "$(CFG)" == "Install - Win32 Debug"
1391
1392
1393"$(INTDIR)\install.obj" : $(SOURCE) $(DEP_CPP_INSTAL) "$(INTDIR)"
1394 $(CPP) $(CPP_PROJ) $(SOURCE)
1395
1396
1397!ELSEIF "$(CFG)" == "Install - Win32 Pure"
1398
1399
1400"$(INTDIR)\install.obj" : $(SOURCE) $(DEP_CPP_INSTAL) "$(INTDIR)"
1401 $(CPP) $(CPP_PROJ) $(SOURCE)
1402
1403
1404!ELSEIF "$(CFG)" == "Install - Win32 Static"
1405
1406
1407"$(INTDIR)\install.obj" : $(SOURCE) $(DEP_CPP_INSTAL) "$(INTDIR)"
1408 $(CPP) $(CPP_PROJ) $(SOURCE)
1409
1410
1411!ELSEIF "$(CFG)" == "Install - Win32 Canned"
1412
1413
1414"$(INTDIR)\install.obj" : $(SOURCE) $(DEP_CPP_INSTAL) "$(INTDIR)"
1415 $(CPP) $(CPP_PROJ) $(SOURCE)
1416
1417
1418!ENDIF
1419
1420# End Source File
1421# End Target
1422# End Project
1423################################################################################
1424################################################################################
1425# Section PumpKIN : {4FD78B34-1FD7-11D0-A9FB-444553540000}
1426 # 2:11:CPumpKINDlg:1
1427 # 2:11:CRequestDlg:1
1428# End Section
1429################################################################################
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 @@
1//Microsoft Developer Studio generated resource script.
2//
3#include "resource.h"
4
5#define APSTUDIO_READONLY_SYMBOLS
6/////////////////////////////////////////////////////////////////////////////
7//
8// Generated from the TEXTINCLUDE 2 resource.
9//
10#include "afxres.h"
11
12/////////////////////////////////////////////////////////////////////////////
13#undef APSTUDIO_READONLY_SYMBOLS
14
15/////////////////////////////////////////////////////////////////////////////
16// English (U.S.) resources
17
18#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
19#ifdef _WIN32
20LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
21#pragma code_page(1252)
22#endif //_WIN32
23
24#ifdef APSTUDIO_INVOKED
25/////////////////////////////////////////////////////////////////////////////
26//
27// TEXTINCLUDE
28//
29
301 TEXTINCLUDE DISCARDABLE
31BEGIN
32 "resource.h\0"
33END
34
352 TEXTINCLUDE DISCARDABLE
36BEGIN
37 "#include ""afxres.h""\r\n"
38 "\0"
39END
40
413 TEXTINCLUDE DISCARDABLE
42BEGIN
43 "#define _AFX_NO_SPLITTER_RESOURCES\r\n"
44 "#define _AFX_NO_OLE_RESOURCES\r\n"
45 "#define _AFX_NO_TRACKER_RESOURCES\r\n"
46 "#define _AFX_NO_PROPERTY_RESOURCES\r\n"
47 "\r\n"
48 "#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\r\n"
49 "#ifdef _WIN32\r\n"
50 "LANGUAGE 9, 1\r\n"
51 "#pragma code_page(1252)\r\n"
52 "#endif\r\n"
53 "#include ""res\\PumpKIN.rc2"" // non-Microsoft Visual C++ edited resources\r\n"
54 "#include ""afxres.rc"" // Standard components\r\n"
55 "#endif\0"
56END
57
58#endif // APSTUDIO_INVOKED
59
60
61/////////////////////////////////////////////////////////////////////////////
62//
63// Icon
64//
65
66// Icon with lowest ID value placed first to ensure application icon
67// remains consistent on all systems.
68IDI_RRQ ICON DISCARDABLE "res\\wrq.ico"
69IDI_WRQ ICON DISCARDABLE "res\\rrq.ico"
70IDI_BROWSE ICON DISCARDABLE "shared-data/browse-icon.ico"
71IDR_MAINFRAME ICON DISCARDABLE "res\\pumpkin.ico"
72IDI_PLAY ICON DISCARDABLE "shared-data/play-icon.ico"
73
74/////////////////////////////////////////////////////////////////////////////
75//
76// Dialog
77//
78
79IDD_ABOUTBOX DIALOG DISCARDABLE 0, 0, 217, 74
80STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
81CAPTION "About PumpKIN"
82FONT 8, "MS Sans Serif"
83BEGIN
84 ICON IDR_MAINFRAME,IDC_STATIC,7,17,18,20
85 LTEXT "PumpKIN, Version 2.5",IDC_STATIC,40,15,119,8,SS_NOPREFIX
86 LTEXT "Copyright © 1997,1998,2002 Klever Group",IDC_STATIC,40,30,170,
87 8
88 DEFPUSHBUTTON "OK",IDOK,178,7,32,14,WS_GROUP
89 PUSHBUTTON "http://www.klever.net/",IDC_KLEVERNET,124,53,86,14
90END
91
92IDD_PUMPKIN_DIALOG DIALOGEX 0, 0, 362, 191
93STYLE DS_MODALFRAME | DS_3DLOOK | WS_POPUP | WS_VISIBLE | WS_CAPTION |
94 WS_SYSMENU
95EXSTYLE WS_EX_ACCEPTFILES | WS_EX_APPWINDOW
96CAPTION " PumpKIN"
97FONT 8, "MS Sans Serif", 0, 0, 0x1
98BEGIN
99 CONTROL "List1",IDC_CONNECTIONS,"SysListView32",LVS_REPORT |
100 LVS_AUTOARRANGE | WS_BORDER | WS_TABSTOP,7,7,295,108,
101 WS_EX_DLGMODALFRAME
102 PUSHBUTTON "&Get File",IDC_GET,305,7,50,17,BS_NOTIFY,
103 WS_EX_CLIENTEDGE
104 PUSHBUTTON "&Put File",IDC_PUT,305,25,50,17,BS_NOTIFY,
105 WS_EX_CLIENTEDGE
106 PUSHBUTTON "&Abort xfer",IDC_ABORT,305,43,50,17,BS_NOTIFY,
107 WS_EX_CLIENTEDGE
108 PUSHBUTTON "&Options",IDC_OPTIONS,305,61,50,17,BS_NOTIFY,
109 WS_EX_CLIENTEDGE
110 PUSHBUTTON "E&xit",IDC_EXIT,305,79,50,17,BS_NOTIFY,WS_EX_CLIENTEDGE
111 PUSHBUTTON "&Help",ID_HELP,305,97,50,17,BS_NOTIFY,WS_EX_CLIENTEDGE
112 LISTBOX IDC_LOG,7,115,348,69,LBS_USETABSTOPS | LBS_NOSEL |
113 WS_VSCROLL | WS_HSCROLL,WS_EX_DLGMODALFRAME
114 PUSHBUTTON "..",IDCANCEL,0,183,6,7,NOT WS_VISIBLE | NOT WS_TABSTOP
115END
116
117IDD_PROPS_SERVER DIALOG DISCARDABLE 0, 0, 210, 154
118STYLE WS_CHILD | WS_DISABLED | WS_CAPTION
119CAPTION "Server"
120FONT 8, "MS Sans Serif"
121BEGIN
122 GROUPBOX "TFTP filesystem &root (download path)",IDC_STATIC,7,7,
123 196,38
124 EDITTEXT IDC_TFTPROOT,13,16,170,13,ES_AUTOHSCROLL
125 PUSHBUTTON "&B",IDC_BROWSE,186,16,13,13,BS_ICON
126 CONTROL "Allow access to &subdirectories",IDC_TFTPSUBDIRS,
127 "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,31,111,10
128 GROUPBOX "Read Request Behavior",IDC_STATIC,7,48,153,42
129 CONTROL "Give &all files",IDC_RRQ_GIVEALL,"Button",
130 BS_AUTORADIOBUTTON | BS_NOTIFY | WS_GROUP,13,57,53,10
131 CONTROL "&Prompt before giving file",IDC_RRQ_ALWAYSCONFIRM,
132 "Button",BS_AUTORADIOBUTTON | BS_NOTIFY,23,67,91,10
133 CONTROL "&Deny all requests",IDC_RRQ_DENYALL,"Button",
134 BS_AUTORADIOBUTTON | BS_NOTIFY,33,77,70,10
135 GROUPBOX "Write Request Behavior",IDC_STATIC,7,93,172,54,WS_GROUP
136 CONTROL "Take a&ll files",IDC_WRQ_TAKEALL,"Button",
137 BS_AUTORADIOBUTTON | WS_GROUP,13,103,55,10
138 CONTROL "Prompt if file &exists",IDC_WRQ_PROMPTEXISTING,"Button",
139 BS_AUTORADIOBUTTON,23,113,73,10
140 CONTROL "Always pro&mpt before accepting file",
141 IDC_WRQ_ALWAYSCONFIRM,"Button",BS_AUTORADIOBUTTON,33,123,
142 139,10
143 CONTROL "D&eny all requests",IDC_WRQ_DENYALL,"Button",
144 BS_AUTORADIOBUTTON,43,133,70,10
145 CTEXT "Confirmation &timeout",IDC_STATIC,163,52,40,19,
146 SS_NOTIFY
147 CONTROL "Slider1",IDC_PROMPTTIMEOUT,"msctls_trackbar32",
148 TBS_AUTOTICKS | TBS_VERT | TBS_TOP | WS_TABSTOP,182,73,
149 21,74
150END
151
152IDD_PROPS_NETWORK DIALOG DISCARDABLE 0, 0, 210, 154
153STYLE WS_CHILD | WS_DISABLED | WS_CAPTION
154CAPTION "Network"
155FONT 8, "MS Sans Serif"
156BEGIN
157 GROUPBOX "UDP Ports",IDC_STATIC,7,7,196,40
158 RTEXT "Listen for &incoming requests on port:",IDC_STATIC,13,
159 18,135,8
160 EDITTEXT IDC_LISTENPORT,154,16,40,13,ES_AUTOHSCROLL
161 CONTROL "Spin1",IDC_LISTENSPIN,"msctls_updown32",UDS_WRAP |
162 UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY |
163 UDS_ARROWKEYS | UDS_NOTHOUSANDS,183,16,11,13
164 RTEXT "Send &outging requests to port:",IDC_STATIC,13,31,135,8
165 EDITTEXT IDC_SPEAKPORT,154,29,40,13,ES_AUTOHSCROLL
166 CONTROL "Spin1",IDC_SPEAKSPIN,"msctls_updown32",UDS_WRAP |
167 UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY |
168 UDS_ARROWKEYS | UDS_NOTHOUSANDS,183,29,11,13
169 LTEXT "Default connection timeout:",IDC_STATIC,7,52,88,8
170 EDITTEXT IDC_TIMEOUT,110,50,40,13,ES_AUTOHSCROLL | ES_NUMBER
171 CONTROL "Spin3",IDC_TIMESPIN,"msctls_updown32",UDS_WRAP |
172 UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY |
173 UDS_ARROWKEYS | UDS_NOTHOUSANDS,140,50,11,13
174 LTEXT "Default block size:",IDC_STATIC,7,66,59,8
175 LTEXT "seconds",IDC_STATIC,154,52,28,8
176 LTEXT "bytes",IDC_STATIC,154,66,18,8
177 EDITTEXT IDC_BLOCKSIZE,110,64,40,13,ES_AUTOHSCROLL | ES_NUMBER
178 CONTROL "Spin3",IDC_BSIZESPIN,"msctls_updown32",UDS_WRAP |
179 UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY |
180 UDS_ARROWKEYS | UDS_NOTHOUSANDS,140,64,11,13
181END
182
183IDD_CONFIRM_RRQ DIALOGEX 0, 0, 181, 79
184STYLE DS_MODALFRAME | DS_NOIDLEMSG | DS_SETFOREGROUND | DS_3DLOOK | WS_POPUP |
185 WS_CAPTION
186EXSTYLE WS_EX_TOOLWINDOW | WS_EX_CLIENTEDGE
187CAPTION " PumpKIN - Confirm Read Request"
188FONT 8, "MS Sans Serif", 0, 0, 0x1
189BEGIN
190 DEFPUSHBUTTON "&Grant Access",IDOK,27,58,54,14
191 PUSHBUTTON "&Deny Access",IDCANCEL,97,58,54,14
192 LTEXT "The host",IDC_STATIC,77,7,29,8
193 CTEXT "255.255.255.255",IDC_HOST,57,15,68,14,SS_NOTIFY |
194 SS_SUNKEN | WS_BORDER,WS_EX_DLGMODALFRAME |
195 WS_EX_CLIENTEDGE
196 CTEXT "is requesting the file",IDC_STATIC,23,29,135,8
197 CTEXT "",IDC_FILE,23,37,135,14,SS_NOTIFY | SS_SUNKEN |
198 WS_BORDER,WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE
199 CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,7,54,167,1
200 ICON IDR_MAINFRAME,IDC_STATIC,7,7,18,20
201 ICON IDR_MAINFRAME,IDC_STATIC,153,7,18,20
202END
203
204IDD_CONFIRM_WRQ DIALOGEX 0, 0, 201, 95
205STYLE DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | WS_POPUP | WS_CAPTION
206EXSTYLE WS_EX_TOOLWINDOW | WS_EX_CLIENTEDGE
207CAPTION " PumpKIN - Confirm Write Request"
208FONT 8, "MS Sans Serif", 0, 0, 0x1
209BEGIN
210 DEFPUSHBUTTON "&Accept",IDOK,7,58,59,14
211 PUSHBUTTON "&Rename",IDC_RENAME,71,58,59,14
212 PUSHBUTTON "&Deny Access",IDCANCEL,135,58,59,14
213 LTEXT "The host",IDC_STATIC,87,7,29,8
214 CTEXT "255.255.255.255",IDC_HOST,67,15,68,14,SS_NOTIFY |
215 SS_SUNKEN | WS_BORDER,WS_EX_DLGMODALFRAME |
216 WS_EX_CLIENTEDGE
217 CTEXT "is attempting to send you a file",IDC_STATIC,33,29,135,
218 8
219 CTEXT "",IDC_FILE,33,37,135,14,SS_NOTIFY | SS_SUNKEN |
220 WS_BORDER,WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE
221 CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,7,54,187,1
222 ICON IDR_MAINFRAME,IDC_STATIC,7,7,21,20
223 ICON IDR_MAINFRAME,IDC_STATIC,173,7,21,20
224 PUSHBUTTON "Res&ume",IDC_RESUME,71,74,59,14
225END
226
227IDD_REQUEST DIALOGEX 0, 0, 191, 161
228STYLE DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | WS_POPUP | WS_CAPTION |
229 WS_SYSMENU
230EXSTYLE WS_EX_CLIENTEDGE
231CAPTION "Request"
232FONT 8, "MS Sans Serif", 0, 0, 0x1
233BEGIN
234 LTEXT "&Local file:",IDC_STATIC,7,7,31,8,SS_NOTIFY
235 EDITTEXT IDC_LOCALFILE,7,16,157,14,ES_AUTOHSCROLL,
236 WS_EX_CLIENTEDGE | WS_EX_STATICEDGE
237 PUSHBUTTON "...",IDC_BROWSE,165,16,19,14,BS_ICON,WS_EX_STATICEDGE
238 LTEXT "&Remote file:",IDC_STATIC,7,34,38,8,SS_NOTIFY
239 EDITTEXT IDC_REMOTEFILE,7,44,177,14,ES_AUTOHSCROLL,
240 WS_EX_CLIENTEDGE | WS_EX_STATICEDGE
241 LTEXT "Remote &host:",IDC_STATIC,7,61,43,8,SS_NOTIFY
242 COMBOBOX IDC_TALKS,7,72,157,66,CBS_SIMPLE | CBS_AUTOHSCROLL |
243 CBS_SORT | CBS_NOINTEGRALHEIGHT | WS_VSCROLL |
244 WS_TABSTOP,WS_EX_CLIENTEDGE | WS_EX_STATICEDGE
245 PUSHBUTTON "R\nE\n&F\nR\nE\nS\nH",IDC_REFRESH,165,72,19,66,
246 BS_CENTER | BS_VCENTER | BS_MULTILINE | BS_NOTIFY,
247 WS_EX_CLIENTEDGE
248 LTEXT "&Type:",IDC_STATIC,58,34,19,8
249 COMBOBOX IDC_TYPE,80,31,43,41,CBS_DROPDOWN | CBS_AUTOHSCROLL |
250 CBS_LOWERCASE | WS_VSCROLL | WS_TABSTOP
251 LTEXT "&Block:",IDC_STATIC,127,34,21,8
252 COMBOBOX IDC_BSIZE,149,31,35,53,CBS_DROPDOWN | WS_VSCROLL |
253 WS_TABSTOP
254 DEFPUSHBUTTON "OK",IDOK,35,140,50,14
255 PUSHBUTTON "Cancel",IDCANCEL,101,140,50,14
256 CONTROL "",IDC_STATIC,"Static",SS_ETCHEDVERT,52,32,1,11
257END
258
259IDD_PROPS_SOUNDS DIALOG DISCARDABLE 0, 0, 210, 154
260STYLE WS_CHILD | WS_DISABLED | WS_CAPTION
261CAPTION "Sounds"
262FONT 8, "MS Sans Serif"
263BEGIN
264 LTEXT "&Incoming request:",IDC_STATIC,7,9,57,8
265 COMBOBOX IDC_RING,70,7,103,100,CBS_DROPDOWN | CBS_AUTOHSCROLL |
266 CBS_SORT | WS_VSCROLL | WS_TABSTOP
267 PUSHBUTTON "browse",IDC_RING_BROWSE,175,7,13,13,BS_ICON
268 PUSHBUTTON "play",IDC_RING_PLAY,190,7,13,13,BS_ICON
269 LTEXT "xfer &finished:",IDC_STATIC,7,25,57,8
270 COMBOBOX IDC_FINISHED,70,22,103,100,CBS_DROPDOWN |
271 CBS_AUTOHSCROLL | CBS_SORT | WS_VSCROLL | WS_TABSTOP
272 PUSHBUTTON "browse",IDC_FINISHED_BROWSE,175,22,13,13,BS_ICON
273 PUSHBUTTON "play",IDC_FINISHED_PLAY,190,22,13,13,BS_ICON
274 LTEXT "xfer &aborted:",IDC_STATIC,7,40,57,8
275 COMBOBOX IDC_ABORTED,70,37,103,100,CBS_DROPDOWN | CBS_AUTOHSCROLL |
276 CBS_SORT | WS_VSCROLL | WS_TABSTOP
277 PUSHBUTTON "browse",IDC_ABORTED_BROWSE,175,37,13,13,BS_ICON
278 PUSHBUTTON "play",IDC_ABORTED_PLAY,190,37,13,13,BS_ICON
279END
280
281
282#ifndef _MAC
283/////////////////////////////////////////////////////////////////////////////
284//
285// Version
286//
287
288VS_VERSION_INFO VERSIONINFO
289 FILEVERSION 2,5,0,0
290 PRODUCTVERSION 2,5,0,0
291 FILEFLAGSMASK 0x3fL
292#ifdef _DEBUG
293 FILEFLAGS 0x1L
294#else
295 FILEFLAGS 0x0L
296#endif
297 FILEOS 0x4L
298 FILETYPE 0x1L
299 FILESUBTYPE 0x0L
300BEGIN
301 BLOCK "StringFileInfo"
302 BEGIN
303 BLOCK "040904b0"
304 BEGIN
305 VALUE "CompanyName", "Klever Group (http://www.klever.net/)\0"
306 VALUE "FileDescription", "PumpKIN, tftp client/daemon\0"
307 VALUE "FileVersion", "2, 5, 0, 0\0"
308 VALUE "InternalName", "PUMPKIN\0"
309 VALUE "LegalCopyright", "Copyright © 1997, 1998, 2002 Klever Group (http://www.klever.net)\0"
310 VALUE "LegalTrademarks", "Klever Group (http://www.klever.net/)\0"
311 VALUE "OriginalFilename", "PUMPKIN.EXE\0"
312 VALUE "ProductName", "PumpKIN\0"
313 VALUE "ProductVersion", "2, 5, 0, 0\0"
314 END
315 END
316 BLOCK "VarFileInfo"
317 BEGIN
318 VALUE "Translation", 0x409, 1200
319 END
320END
321
322#endif // !_MAC
323
324
325/////////////////////////////////////////////////////////////////////////////
326//
327// DESIGNINFO
328//
329
330#ifdef APSTUDIO_INVOKED
331GUIDELINES DESIGNINFO DISCARDABLE
332BEGIN
333 IDD_ABOUTBOX, DIALOG
334 BEGIN
335 LEFTMARGIN, 7
336 RIGHTMARGIN, 210
337 TOPMARGIN, 7
338 BOTTOMMARGIN, 67
339 END
340
341 IDD_PUMPKIN_DIALOG, DIALOG
342 BEGIN
343 LEFTMARGIN, 7
344 RIGHTMARGIN, 355
345 TOPMARGIN, 7
346 BOTTOMMARGIN, 184
347 HORZGUIDE, 115
348 END
349
350 IDD_PROPS_SERVER, DIALOG
351 BEGIN
352 LEFTMARGIN, 7
353 RIGHTMARGIN, 203
354 TOPMARGIN, 7
355 BOTTOMMARGIN, 147
356 END
357
358 IDD_PROPS_NETWORK, DIALOG
359 BEGIN
360 LEFTMARGIN, 7
361 RIGHTMARGIN, 203
362 TOPMARGIN, 7
363 BOTTOMMARGIN, 147
364 END
365
366 IDD_CONFIRM_RRQ, DIALOG
367 BEGIN
368 LEFTMARGIN, 7
369 RIGHTMARGIN, 174
370 TOPMARGIN, 7
371 BOTTOMMARGIN, 72
372 END
373
374 IDD_CONFIRM_WRQ, DIALOG
375 BEGIN
376 LEFTMARGIN, 7
377 RIGHTMARGIN, 194
378 TOPMARGIN, 7
379 BOTTOMMARGIN, 88
380 END
381
382 IDD_REQUEST, DIALOG
383 BEGIN
384 LEFTMARGIN, 7
385 RIGHTMARGIN, 184
386 TOPMARGIN, 7
387 BOTTOMMARGIN, 154
388 END
389
390 IDD_PROPS_SOUNDS, DIALOG
391 BEGIN
392 LEFTMARGIN, 7
393 RIGHTMARGIN, 203
394 TOPMARGIN, 7
395 BOTTOMMARGIN, 147
396 END
397END
398#endif // APSTUDIO_INVOKED
399
400
401/////////////////////////////////////////////////////////////////////////////
402//
403// Bitmap
404//
405
406IDB_BACKGROUND BITMAP DISCARDABLE "shared-data/klever-background.bmp"
407
408/////////////////////////////////////////////////////////////////////////////
409//
410// WAVE
411//
412
413IDR_WAVE_RING WAVE DISCARDABLE "res\\ring.wav"
414IDR_WAVE_FINISHED WAVE DISCARDABLE "res\\finished.wav"
415IDR_WAVE_ABORTED WAVE DISCARDABLE "res\\failed.wav"
416
417/////////////////////////////////////////////////////////////////////////////
418//
419// Dialog Info
420//
421
422IDD_REQUEST DLGINIT
423BEGIN
424 IDC_TYPE, 0x403, 6, 0
4250x636f, 0x6574, 0x0074,
426 IDC_TYPE, 0x403, 9, 0
4270x656e, 0x6174, 0x6373, 0x6969, "\000"
428 IDC_BSIZE, 0x403, 4, 0
4290x3135, 0x0032,
430 IDC_BSIZE, 0x403, 5, 0
4310x3031, 0x3432, "\000"
432 IDC_BSIZE, 0x403, 5, 0
4330x3032, 0x3834, "\000"
434 IDC_BSIZE, 0x403, 5, 0
4350x3034, 0x3639, "\000"
436 IDC_BSIZE, 0x403, 5, 0
4370x3138, 0x3239, "\000"
438 0
439END
440
441
442/////////////////////////////////////////////////////////////////////////////
443//
444// Menu
445//
446
447IDM_POPUPS MENU DISCARDABLE
448BEGIN
449 POPUP "&Tray"
450 BEGIN
451 MENUITEM "&Send File", ID_TRAY_SENDFILE
452 MENUITEM "F&etch file", ID_TRAY_FETCHFILE
453 MENUITEM "&Options", ID_TRAY_OPTIONS
454 MENUITEM "Show &PumpKIN Window", ID_TRAY_SHOWPUMPKINWINDOW
455 MENUITEM "Open &Files Folder", ID_TRAY_OPENFILESFOLDER
456 MENUITEM SEPARATOR
457 MENUITEM "&Help Topics", ID_TRAY_HELP
458 MENUITEM "&About PumpKIN", ID_TRAY_ABOUTPUMPKIN
459 MENUITEM SEPARATOR
460 MENUITEM "E&xit", ID_TRAY_EXIT
461 END
462END
463
464
465/////////////////////////////////////////////////////////////////////////////
466//
467// String Table
468//
469
470STRINGTABLE DISCARDABLE
471BEGIN
472 IDS_ABOUTBOX "&About PumpKIN..."
473 IDS_FMT_BYTES "%lu"
474 IDP_SOCKETS_INIT_FAILED "Windows sockets initialization failed."
475 IDS_TFTP_ERROR_ACCESS "Access violation"
476 IDS_TFTP_ERROR_NOTFOUND "File not found"
477 IDS_TFTP_ERROR_DIRFULL "Directory is full"
478 IDS_TFTP_ERROR_SHARING "Sharing violation"
479 IDS_TFTP_ERROR_DISKFULL "Disk full"
480 IDS_TFTP_ERROR_UNDEFINED "Undefined error"
481 IDS_LOG_START "PumpKIN started"
482 IDS_LOG_LISTENRECEIVEERROR "Error listening for incoming connections"
483END
484
485STRINGTABLE DISCARDABLE
486BEGIN
487 IDS_LOG_LISTENACCEPTERROR "Error accepting incoming connection"
488 IDS_LOG_RRQSERVE "'%s' of type '%s' is requested from %s"
489 IDS_LOG_LISTENOPCODE "Invalid opcode in initial connection request"
490 IDS_LOG_XFERUDPSEND "UDP packet send failed"
491 IDS_LOG_XFERRECEIVE "Error on xfer socket"
492 IDS_LOG_XFERSEND "Error on xfer socket"
493 IDS_LOG_XFERUDPRECEIVE "UDP packet receive failed"
494 IDS_LOG_XFERSOURCETID "Packet from unexpected source"
495 IDS_LOG_SENTTFTPERROR ":%u: %s"
496 IDS_LOG_GOTTFTPERROR "TFTP:%u: %s"
497 IDS_LOG_XFEROPCODE "Invalid opcode during transfer received"
498 IDS_LOG_XFERRRQFINISHED "Transfer of '%s' has successfully completed"
499 IDS_TITLE_OPTIONS "Options"
500 IDS_LOG_WRQSERVE "Writing of '%s' of type '%s' is requested by %s"
501 IDS_TFTP_ERROR_FAILEDTORENAME "Too many clones of the file"
502 IDS_RENAME_TITLE "Save As"
503END
504
505STRINGTABLE DISCARDABLE
506BEGIN
507 IDS_LOG_TIMEDOUT "Transmission of '%s' is timed out"
508 IDS_CONFIRMEXIT_TITLE "Exit"
509 IDS_CONFIRMEXIT_TEXT "File transmission is currently in progress. Are you sure you want to exit?"
510 IDS_LOG_XFERWRQFINISHED "Transfer of '%s' has successfully completed"
511 IDS_LOG_XFERABORTED "Transfer of '%s' was aborted"
512 IDS_TITLE_PUTREQUEST "Send file"
513 IDS_TITLE_GETREQUEST "Fetch file"
514 IDS_WTALKHEADING "Talk with "
515 IDS_TITLE_BROWSEFILE "Browse"
516 IDS_LOG_RESOLVEFAILED "Failed to resolve host address for '%s'"
517 IDS_LOG_FAILEDLOCALFILE "Failed to open local file '%s'"
518 IDS_LOG_FAILEDTOOPEN "Failed to open '%s'"
519 IDS_OTALXHEADING "Open Talks: talking to "
520 IDS_REGISTRYKEY "Klever Group, Inc."
521 IDS_KLEVERNET_URL "http://www.klever.net/"
522 IDS_LOGTIMEFORMAT "%H:%M:%S %B %d"
523END
524
525STRINGTABLE DISCARDABLE
526BEGIN
527 ID_TRAY_HELP "Read the help on PumpKIN"
528 ID_TRAY_ABOUTPUMPKIN "Learn about PumpKIN and it's creator"
529 ID_TRAY_EXIT "Close PumpKIN"
530 ID_TRAY_SENDFILE "Send file over the network to your tete-a-tete"
531 ID_TRAY_FETCHFILE "Fetch file from remote computer"
532 ID_TRAY_OPTIONS "Set PumpKIN options"
533 ID_TRAY_SHOWPUMPKINWINDOW "Show main window"
534 ID_TRAY_OPENFILESFOLDER "Explore TFTP root folder"
535END
536
537STRINGTABLE DISCARDABLE
538BEGIN
539 IDC_CONNECTIONS "Active transfers"
540 IDC_LOG "PumpKIN Activity Log"
541 IDC_GET "Fetch file from remote server"
542 IDC_PUT "Send file over the net"
543 IDC_ABORT "Abort transfer currently in progress"
544 IDC_EXIT "Close PumpKIN"
545END
546
547STRINGTABLE DISCARDABLE
548BEGIN
549 IDC_OPTIONS "Set PumpKIN options"
550 IDC_REFRESH "Refresh talks list"
551 IDC_BROWSE "Browse"
552END
553
554STRINGTABLE DISCARDABLE
555BEGIN
556 ID_HELP "Read help on PumpKIN"
557END
558
559STRINGTABLE DISCARDABLE
560BEGIN
561 IDS_DROPFILES_TITLE "Drop Files"
562 IDS_NOMULTIPLEDROP_TEXT "You can't drop more than one file here. Only the first one will be accepted"
563 IDS_LOG_REQUESTING "Requesting '%s' from '%s'"
564 IDS_LOG_SENDING "Sending '%s' to '%s'"
565 IDS_WTALKAT "@"
566 IDS_OTALXAT " at "
567 IDS_TFTP_ERROR_TSIZE "Invalid transfer size"
568 IDS_TFTP_ERROR_BSIZE "Invalid block size"
569 IDS_TFTP_ERROR_TOUT "Invalid timeout"
570 IDS_SELECT_TFTPROOT "Select TFTP filesystem root.."
571 IDS_FILTER_WAV "Sound Files (*.wav)|*.wav||"
572 IDS_TITLE_WAV "Select sound.."
573END
574
575STRINGTABLE DISCARDABLE
576BEGIN
577 AFX_IDS_APP_TITLE "PUMPKIN"
578END
579
580#endif // English (U.S.) resources
581/////////////////////////////////////////////////////////////////////////////
582
583
584
585#ifndef APSTUDIO_INVOKED
586/////////////////////////////////////////////////////////////////////////////
587//
588// Generated from the TEXTINCLUDE 3 resource.
589//
590#define _AFX_NO_SPLITTER_RESOURCES
591#define _AFX_NO_OLE_RESOURCES
592#define _AFX_NO_TRACKER_RESOURCES
593#define _AFX_NO_PROPERTY_RESOURCES
594
595#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
596#ifdef _WIN32
597LANGUAGE 9, 1
598#pragma code_page(1252)
599#endif
600#include "res\pumpkin.rc2" // non-Microsoft Visual C++ edited resources
601#include "afxres.rc" // Standard components
602#endif
603/////////////////////////////////////////////////////////////////////////////
604#endif // not APSTUDIO_INVOKED
605
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 @@
1//
2// PUMPKIN.RC2 - resources Microsoft Visual C++ does not edit directly
3//
4
5#ifdef APSTUDIO_INVOKED
6 #error this file is not editable by Microsoft Visual C++
7#endif //APSTUDIO_INVOKED
8
9
10/////////////////////////////////////////////////////////////////////////////
11// Add manually edited resources here...
12
13/////////////////////////////////////////////////////////////////////////////
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 @@
1//{{NO_DEPENDENCIES}}
2// Microsoft Developer Studio generated include file.
3// Used by PumpKIN.rc
4//
5#define IDM_ABOUTBOX 0x0010
6#define IDD_ABOUTBOX 100
7#define IDS_ABOUTBOX 101
8#define IDC_TRAYICON 101
9#define IDD_PUMPKIN_DIALOG 102
10#define IDS_FMT_BYTES 102
11#define IDP_SOCKETS_INIT_FAILED 103
12#define IDS_TFTP_ERROR_ACCESS 104
13#define IDS_TFTP_ERROR_NOTFOUND 105
14#define IDS_TFTP_ERROR_DIRFULL 106
15#define IDD_PROPS_SERVER 106
16#define IDS_TFTP_ERROR_SHARING 107
17#define IDD_PROPS_NETWORK 107
18#define IDS_TFTP_ERROR_DISKFULL 108
19#define IDS_TFTP_ERROR_UNDEFINED 109
20#define IDS_LOG_START 110
21#define IDS_LOG_LISTENRECEIVEERROR 111
22#define IDS_LOG_LISTENACCEPTERROR 112
23#define IDS_LOG_RRQSERVE 113
24#define IDS_LOG_LISTENOPCODE 114
25#define IDS_LOG_XFERUDPSEND 115
26#define IDS_LOG_XFERRECEIVE 116
27#define IDS_LOG_XFERSEND 117
28#define IDS_LOG_XFERUDPRECEIVE 118
29#define IDS_LOG_XFERSOURCETID 119
30#define IDS_LOG_SENTTFTPERROR 120
31#define IDS_LOG_GOTTFTPERROR 121
32#define IDS_LOG_XFEROPCODE 122
33#define IDS_LOG_XFERRRQFINISHED 123
34#define IDS_TITLE_OPTIONS 124
35#define IDS_LOG_WRQSERVE 125
36#define IDS_TFTP_ERROR_FAILEDTORENAME 126
37#define IDS_RENAME_TITLE 127
38#define IDR_MAINFRAME 128
39#define IDS_LOG_TIMEDOUT 128
40#define IDS_CONFIRMEXIT_TITLE 129
41#define IDI_RRQ 129
42#define IDS_CONFIRMEXIT_TEXT 130
43#define IDI_WRQ 130
44#define IDD_CONFIRM_RRQ 131
45#define IDS_LOG_XFERWRQFINISHED 131
46#define IDD_CONFIRM_WRQ 132
47#define IDB_BACKGROUND 132
48#define IDS_LOG_XFERABORTED 132
49#define IDS_TITLE_PUTREQUEST 133
50#define IDS_TITLE_GETREQUEST 134
51#define IDR_WAVE_RING 135
52#define IDS_TALKHEADING 135
53#define IDS_WTALKHEADING 135
54#define IDR_WAVE_FINISHED 136
55#define IDS_TITLE_BROWSEFILE 136
56#define IDD_REQUEST 137
57#define IDS_LOG_RESOLVEFAILED 137
58#define IDS_LOG_FAILEDLOCALFILE 138
59#define IDD_PROPS_SOUNDS 138
60#define IDS_LOG_FAILEDTOOPEN 139
61#define IDM_POPUPS 140
62#define IDS_OTALXHEADING 140
63#define IDS_REGISTRYKEY 141
64#define IDS_KLEVERNET_URL 142
65#define IDR_WAVE_ABORTED 142
66#define IDS_LOGTIMEFORMAT 143
67#define IDS_DROPFILES_TITLE 144
68#define IDS_NOMULTIPLEDROP_TEXT 145
69#define IDI_BROWSE 145
70#define IDS_LOG_REQUESTING 146
71#define IDS_LOG_SENDING 147
72#define IDS_WTALKAT 148
73#define IDS_OTALXAT 149
74#define IDI_PLAY 149
75#define IDS_TFTP_ERROR_TSIZE 150
76#define IDS_TFTP_ERROR_BSIZE 151
77#define IDS_TFTP_ERROR_TOUT 152
78#define IDS_SELECT_TFTPROOT 153
79#define IDS_FILTER_WAV 154
80#define IDS_TITLE_WAV 155
81#define IDC_KLEVERNET 1000
82#define IDC_CONNECTIONS 1001
83#define IDC_LOG 1003
84#define IDC_GET 1004
85#define IDC_PUT 1005
86#define IDC_ABORT 1006
87#define IDC_EXIT 1007
88#define IDC_TFTPROOT 1008
89#define IDC_TFTPSUBDIRS 1009
90#define IDC_RRQ_GIVEALL 1010
91#define IDC_RRQ_ALWAYSCONFIRM 1011
92#define IDC_RRQ_DENYALL 1012
93#define IDC_WRQ_TAKEALL 1013
94#define IDC_WRQ_PROMPTEXISTING 1014
95#define IDC_WRQ_ALWAYSCONFIRM 1015
96#define IDC_WRQ_DENYALL 1016
97#define IDC_PROMPTTIMEOUT 1017
98#define IDC_LISTENPORT 1018
99#define IDC_LISTENSPIN 1019
100#define IDC_SPEAKPORT 1020
101#define IDC_SPEAKSPIN 1021
102#define IDC_MAXUDPSIZE 1022
103#define IDC_MAXUDPSPIN 1023
104#define IDC_TIMEOUT 1024
105#define IDC_TIMESPIN 1025
106#define IDC_OPTIONS 1026
107#define IDC_BLOCKSIZE 1026
108#define IDC_BSIZESPIN 1027
109#define IDC_HOST 1028
110#define IDC_FILE 1029
111#define IDC_RENAME 1030
112#define IDC_REMOTEFILE 1030
113#define IDC_RESUME 1031
114#define IDC_REFRESH 1032
115#define IDC_BROWSE 1034
116#define IDC_TALKS 1035
117#define IDC_LOCALFILE 1036
118#define IDC_TYPE 1037
119#define IDC_BSIZE 1039
120#define IDC_RING 1041
121#define IDC_RING_BROWSE 1042
122#define IDC_RING_PLAY 1043
123#define IDC_FINISHED 1044
124#define IDC_FINISHED_BROWSE 1045
125#define IDC_FINISHED_PLAY 1046
126#define IDC_ABORTED 1047
127#define IDC_ABORTED_BROWSE 1048
128#define IDC_ABORTED_PLAY 1049
129#define ID_TRAY_HELP 32771
130#define ID_TRAY_ABOUTPUMPKIN 32772
131#define ID_TRAY_EXIT 32773
132#define ID_TRAY_SENDFILE 32774
133#define ID_TRAY_FETCHFILE 32775
134#define ID_TRAY_OPTIONS 32776
135#define ID_TRAY_SHOWPUMPKINWINDOW 32777
136#define ID_TRAY_OPENFILESFOLDER 32778
137
138// Next default values for new objects
139//
140#ifdef APSTUDIO_INVOKED
141#ifndef APSTUDIO_READONLY_SYMBOLS
142#define _APS_NEXT_RESOURCE_VALUE 150
143#define _APS_NEXT_COMMAND_VALUE 32780
144#define _APS_NEXT_CONTROL_VALUE 1043
145#define _APS_NEXT_SYMED_VALUE 102
146#endif
147#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 @@
1 #ifndef__BTREENDEX_H
2 #define__BTREENDEX_H
3
4#include "Dynamide.h"
5
6namespace Klever {
7
8template<class key,class value,int treeOrder,int cluster>
9 class CBTreendex : public CObject{
10public:
11 typedef LONG CBTPageRef;
12 struct CBTRecordRef {
13 CBTPageRef m_Page;
14 INT m_Offset;
15 CBTRecordRef(CBTPageRef page=-1,INT offset=-1) : m_Page(page), m_Offset(offset) {}
16 };
17 class CBTRecord : public CObject {
18 public:
19 CBTPageRef m_ptrLeft;
20 CBTPageRef m_ptrRight;
21 key m_Key;
22 value m_Value;
23 CBTRecord() : m_ptrLeft(-1), m_ptrRight(-1) {}
24 CBTRecord(key& _key,value& _value,CBTPageRef left=-1,CBTPageRef right=-1) : m_Key(_key), m_Value(_value), m_ptrLeft(left), m_ptrRight(right) {}
25 CBTRecord(CBTRecord& r) : m_Key(r.m_Key), m_Value(r.m_Value), m_ptrLeft(r.m_ptrLeft), m_ptrRight(r.m_ptrRight) {}
26
27 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;}
28
29 void Serialize(CArchive& ar) {
30 if(ar.IsStoring()){
31 ar << m_ptrLeft;
32 ar << m_ptrRight;
33 }else{
34 ar >> m_ptrLeft;
35 ar >> m_ptrRight;
36 }
37 SerializeElements(ar,&m_Key,1);
38 SerializeElements(ar,&m_Value,1);
39 }
40 };
41 class CBTPage : public CArray<CBTRecord,CBTRecord&> {
42 public:
43 void Serialize(CArchive& ar) {
44 int nCount = -1;
45 if(ar.IsStoring()){
46 nCount = GetSize();
47 ar << nCount;
48 }else{
49 nCount = 0;
50 ar >> nCount;
51 RemoveAll();
52 SetSize(nCount);
53 }
54 for(int tmp=0;tmp<nCount;tmp++)
55 ElementAt(tmp).Serialize(ar);
56 }
57 };
58 typedef CDynamide<256,cluster> CBTDyna;
59 typedef CBTDyna::CDynaFile CBTDynaFile;
60 typedef CArray<CBTRecordRef,CBTRecordRef&> CBTRStack;
61
62 CBTDyna m_BT;
63 struct_btCrap {
64 BOOL m_bRootSet;
65 CBTPageRef m_Root;
66 } *m_BTCrap;
67 BOOL m_bRO;
68 CBTRStack m_btStack;
69 CBTPage m_stackTop;
70
71 CBTreendex() {}
72 ~CBTreendex() { Close(); }
73 BOOL Attach(CFile* file,BOOL bAutodelete) {
74 m_bRO = FALSE;
75 if(!m_BT.Attach(file,bAutodelete))
76 return FALSE;
77 return Attach();
78 }
79 BOOL Open(LPCTSTR file,BOOL bReadOnly) {
80 if(!m_BT.Open(file,bReadOnly))
81 return FALSE;
82 m_bRO = bReadOnly;
83 return Attach();
84 }
85 BOOL Create(LPCTSTR file) {
86 try{
87 CFile* f = new CFile(file,CFile::modeCreate|CFile::modeReadWrite|CFile::shareDenyRead|CFile::shareDenyWrite|CFile::typeBinary);
88 ASSERT(f);
89 return Attach(f,TRUE);
90 }catch(CException* e){
91 e->Delete();
92 return FALSE;
93 }
94 }
95 BOOL Attach() {
96 ASSERT(m_BT.IsOpened());
97 m_BTCrap = (_btCrap*)m_BT.m_FB.crap;
98 if(!m_BTCrap->m_bRootSet){
99 m_BTCrap->m_Root = AllocatePage();
100 if(m_BTCrap->m_Root<0)
101 return FALSE;
102 m_BTCrap->m_bRootSet = TRUE;
103 m_BT.Write1stBlock();
104 }
105 return TRUE;
106 }
107 BOOL Close() {
108 m_BT.Close();
109 return TRUE;
110 }
111 BOOL IsOpened() {
112 return m_BT.IsOpened();
113 }
114
115 BOOL Lookup(key& _key,value& value) {
116 if(!IsOpened())
117 return FALSE;
118 ASSERT(m_BTCrap->m_bRootSet);
119 if(!SeekToPage(_key))
120 return FALSE;
121 CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()];
122 if(rr.m_Offset<0)
123 return FALSE;
124 ASSERT(rr.m_Offset<m_stackTop.GetSize());
125 if(_key != m_stackTop[rr.m_Offset].m_Key)
126 return FALSE;
127 value = m_stackTop[rr.m_Offset].m_Value;
128 return TRUE;
129 }
130 BOOL Add(key& _key,value& _value) {
131 if(!IsOpened())
132 return FALSE;
133 ASSERT(m_BTCrap->m_bRootSet);
134 if(!SeekToPage(_key))
135 return FALSE;
136 CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()];
137 CBTRecord nuRecord(_key,_value);
138 if(rr.m_Offset<0){
139 if(m_stackTop.GetSize())
140 nuRecord.m_ptrLeft = m_stackTop[m_stackTop.GetUpperBound()].m_ptrRight;
141 }else if(rr.m_Offset==0){
142 nuRecord.m_ptrRight = m_stackTop[0].m_ptrLeft;
143 }else{
144 nuRecord.m_ptrLeft = m_stackTop[rr.m_Offset-1].m_ptrRight;
145 nuRecord.m_ptrRight = m_stackTop[rr.m_Offset].m_ptrLeft;
146 }
147 // ASSERT(rr.m_Offset==0 || (m_stackTop[rr.m_Offset-1].m_Key<_key && m_stackTop[rr.m_Offset-1].m_ptrRight<0));
148 // ASSERT(rr.m_Offset<0 || m_stackTop[rr.m_Offset].m_Key>=_key && m_stackTop[rr.m_Offset].m_ptrLeft<0);
149 if(rr.m_Offset>=0 && m_stackTop[rr.m_Offset].m_Key==_key){
150 // Exact match found - just replace.
151 m_stackTop[rr.m_Offset].m_Value = _value;
152 if(!SavePage(rr.m_Page,m_stackTop))
153 return FALSE;
154 return TRUE;
155 }
156 // Split the page and propagate the split if needed..
157 // Insert new element at rr.m_Offset..
158 BOOL nuisnew = TRUE;
159 for(int sp=m_btStack.GetUpperBound();sp>=0;sp--){
160 CBTPageRef opr = m_btStack[sp].m_Page;
161 int iAt = m_btStack[sp].m_Offset;
162 CBTPage op;
163 VERIFY(LoadPage(opr,op));
164 if(iAt<0)
165 iAt = op.GetSize();
166 else{
167 if(op[iAt].m_Key<nuRecord.m_Key)
168 iAt++;
169 ASSERT(iAt==op.GetSize() || op[iAt].m_Key > nuRecord.m_Key);
170 }
171 op.InsertAt(iAt,nuRecord);
172 if(iAt>0)
173 op[iAt-1].m_ptrRight=nuRecord.m_ptrLeft;
174 if(iAt<op.GetUpperBound())
175 op[iAt+1].m_ptrLeft=nuRecord.m_ptrRight;
176 if(op.GetSize()<=treeOrder*2){
177 // This isn't causing overflow
178 VERIFY(SavePage(opr,op));
179 return TRUE;
180 }
181 TRACE0("Split\n");
182 ASSERT(op.GetSize()==(treeOrder*2+1));
183 CBTPageRef npr = AllocatePage();
184 ASSERT(npr>=0);
185 CBTPage np;
186 ASSERT(LoadPage(npr,np));
187 ASSERT(!np.GetSize());
188 nuRecord = op[treeOrder];
189 if(iAt==treeOrder){
190 // We're inserting central element! - drop out the stack top if this is still new one
191 for(int tmp=0;tmp<treeOrder;tmp++)
192 np.InsertAt(tmp,op[tmp]);
193 op.RemoveAt(0,treeOrder+1);
194 nuRecord.m_ptrLeft = npr;
195 nuRecord.m_ptrRight = opr;
196 if(nuisnew)
197 m_btStack.RemoveAt(m_btStack.GetUpperBound());
198 }else{
199 if(iAt<treeOrder){
200 // We're inserting in the left subtree.
201 // Make newpage the right one and forget it.
202 for(int tmp=0;tmp<treeOrder;tmp++)
203 np.InsertAt(tmp,op[tmp+treeOrder+1]);
204 op.RemoveAt(treeOrder,treeOrder+1);
205 nuRecord.m_ptrLeft = opr;
206 nuRecord.m_ptrRight = npr;
207 }else{
208 // We're inserting in the right subtree.
209 // Make newpage the left one, forget it, but also adjust offset in the stack
210 for(int tmp=0;tmp<treeOrder;tmp++)
211 np.InsertAt(tmp,op[tmp]);
212 op.RemoveAt(0,treeOrder+1);
213 nuRecord.m_ptrLeft = npr;
214 nuRecord.m_ptrRight = opr;
215 m_btStack[sp].m_Offset-=treeOrder+1;
216 }
217 // Note that we're not inserting new element anymore.
218 nuisnew = FALSE;
219 }
220 // Do, excessive sanity checks and save pages
221 ASSERT(op.GetSize());
222 ASSERT(np.GetSize());
223 VERIFY(SavePage(opr,op));
224 VERIFY(SavePage(npr,np));
225 }
226 // Here we have root page overflow, which means that we're simply putting new
227 // record in this brand new root page and also inserting this page on the bottom of the stack
228 CBTPageRef nuroot = AllocatePage();
229 ASSERT(nuroot>=0);
230 CBTPage nurpa;
231 ASSERT(LoadPage(nuroot,nurpa));
232 ASSERT(!nurpa.GetSize());
233 nurpa.Add(nuRecord);
234 VERIFY(SavePage(nuroot,nurpa));
235 m_btStack.InsertAt(0,CBTRecordRef(nuroot,0));
236 m_BTCrap->m_Root = nuroot;
237 m_BT.Write1stBlock();
238 return TRUE;
239 }
240 BOOL Delete(key& _key) {
241 if(!IsOpened())
242 return FALSE;
243 ASSERT(m_BTCrap->m_bRootSet);
244 value _value;
245 if(!Lookup(_key,_value))
246 return FALSE;
247 // Found key, check if it's a leaf
248 {
249 CBTRecordRef* rr = &m_btStack[m_btStack.GetUpperBound()];
250 int rrIdx = m_btStack.GetUpperBound();
251 if(m_stackTop[rr->m_Offset].m_ptrLeft>=0){
252 ASSERT(m_stackTop[rr->m_Offset].m_ptrRight>=0);
253 // It isn't - scan for the _next_ key and do dirty deeds
254 m_btStack.Add(CBTRecordRef(m_stackTop[rr->m_Offset].m_ptrRight,0));
255 for(;;){
256 CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()];
257 if(!LoadPage(rr.m_Page,m_stackTop))
258 return FALSE;
259 if(m_stackTop[0].m_ptrLeft<0)
260 break;
261 m_btStack.Add(CBTRecordRef(m_stackTop[0].m_ptrLeft,0));
262 }
263 // We have a leaf node here, replace victim with the first element and kill it.
264 CBTPage uppage;
265 rr = &m_btStack[rrIdx];
266 if(!LoadPage(rr->m_Page,uppage))
267 return FALSE;
268 uppage[rr->m_Offset].m_Key=m_stackTop[0].m_Key; uppage[rr->m_Offset].m_Value=m_stackTop[0].m_Value;
269 m_stackTop.RemoveAt(0);
270 if(!(SavePage(rr->m_Page,uppage) && SavePage(m_btStack[m_btStack.GetUpperBound()].m_Page,m_stackTop)))
271 return FALSE;
272 }else{
273 ASSERT(m_stackTop[rr->m_Offset].m_ptrRight<0);
274 m_stackTop.RemoveAt(rr->m_Offset);
275 if(!SavePage(rr->m_Page,m_stackTop))
276 return FALSE;
277 }
278 }
279 // We have a page to check for underflow at the top of the stack now.
280 for(;;){
281 CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()];
282 if(!LoadPage(rr.m_Page,m_stackTop))
283 return FALSE;
284 if(m_stackTop.GetSize()>=treeOrder || m_btStack.GetSize()==1)
285 return TRUE;
286 CBTRecordRef& rr1 = m_btStack[m_btStack.GetUpperBound()-1];
287 CBTPage daddy;
288 if(!LoadPage(rr1.m_Page,daddy))
289 return FALSE;
290 CBTPageRef nPage = daddy[rr1.m_Offset].m_ptrRight;
291 BOOL bRight=TRUE;
292 if(nPage<0 || nPage==rr.m_Page){
293 nPage = daddy[rr1.m_Offset].m_ptrLeft;
294 bRight = FALSE;
295 }
296 ASSERT(nPage>=0 && nPage!=rr.m_Page);
297 CBTPage neighbor;
298 if(!LoadPage(nPage,neighbor))
299 return FALSE;
300 // Here we have possibly two cases:
301 // 1. Neighboring page can share some data with use, then do share and leave
302 // 2. Neighboring page is of treeorder in size, then merge and propagate
303 if(neighbor.GetSize()>treeOrder){
304 TRACE0("Redistributing..\n");
305 // Borrow some data from there.
306 int toBorrow = neighbor.GetSize()-treeOrder;
307 toBorrow=toBorrow/2+1;
308 ASSERT(toBorrow);
309 if(bRight)
310 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));
311 else
312 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));
313 for(toBorrow--;toBorrow;toBorrow--){
314 if(bRight){
315 m_stackTop.Add(neighbor[0]);
316 neighbor.RemoveAt(0);
317 }else{
318 m_stackTop.InsertAt(0,neighbor[neighbor.GetUpperBound()]);
319 neighbor.RemoveAt(neighbor.GetUpperBound());
320 }
321 }
322 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;
323 neighbor.RemoveAt(bRight?0:neighbor.GetUpperBound());
324 if(!(SavePage(rr1.m_Page,daddy) && SavePage(nPage,neighbor) && SavePage(rr.m_Page,m_stackTop)))
325 return FALSE;
326 rr.m_Offset = -1;// *** Point to the next??
327 return TRUE;
328 }
329 TRACE0("Merging..\n");
330 // We need to merge pages here..
331 // We will merge them at stacktop, then we'll discard neighbor guy..
332 if(bRight)
333 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));
334 else
335 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));
336 if(bRight){
337 while(neighbor.GetSize()){
338 m_stackTop.Add(neighbor[0]);
339 neighbor.RemoveAt(0);
340 }
341 }else{
342 while(neighbor.GetSize()){
343 m_stackTop.InsertAt(0,neighbor[neighbor.GetUpperBound()]);
344 neighbor.RemoveAt(neighbor.GetUpperBound());
345 }
346 }
347 if(rr1.m_Offset>0)
348 daddy[rr1.m_Offset-1].m_ptrRight=rr.m_Page;
349 if(rr1.m_Offset<daddy.GetUpperBound())
350 daddy[rr1.m_Offset+1].m_ptrLeft=rr.m_Page;
351 daddy.RemoveAt(rr1.m_Offset);
352 if(!(SavePage(rr1.m_Page,daddy) && SavePage(rr.m_Page,m_stackTop)))
353 return FALSE;
354 VERIFY(DeallocatePage(nPage));
355 m_btStack.RemoveAt(m_btStack.GetUpperBound());
356 }
357 return FALSE;
358 }
359 BOOL GoFirst() {
360 if(!IsOpened())
361 return FALSE;
362 ASSERT(m_BTCrap->m_bRootSet);
363 m_btStack.RemoveAll();
364 m_btStack.Add(CBTRecordRef(m_BTCrap->m_Root,-1));
365 for(;;){
366 CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()];
367 if(!LoadPage(rr.m_Page,m_stackTop))
368 return FALSE;
369 if(!m_stackTop.GetSize()){
370 ASSERT(m_btStack.GetSize()==1);
371 return FALSE;
372 }
373 rr.m_Offset = 0;
374 if(m_stackTop[rr.m_Offset].m_ptrLeft<0)
375 return TRUE;
376 m_btStack.Add(CBTRecordRef(m_stackTop[rr.m_Offset].m_ptrLeft,-1));
377 }
378 }
379 BOOL GoLast() {
380 if(!IsOpened())
381 return FALSE;
382 ASSERT(m_BTCrap->m_bRootSet);
383 m_btStack.RemoveAll();
384 m_btStack.Add(CBTRecordRef(m_BTCrap->m_Root,-1));
385 for(;;){
386 CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()];
387 if(!LoadPage(rr.m_Page,m_stackTop))
388 return FALSE;
389 if(!m_stackTop.GetSize()){
390 ASSERT(m_btStack.GetSize()==1);
391 return FALSE;
392 }
393 rr.m_Offset = m_stackTop.GetUpperBound();
394 if(m_stackTop[rr.m_Offset].m_ptrRight<0)
395 return TRUE;
396 m_btStack.Add(CBTRecordRef(m_stackTop[rr.m_Offset++].m_ptrRight,-1));
397 }
398 }
399 BOOL GoNext() {
400 if(!IsOpened())
401 return FALSE;
402 if(!(m_btStack.GetSize() && m_btStack[m_btStack.GetUpperBound()].m_Offset>=0))
403 return FALSE;
404 CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()];
405 if(!LoadPage(rr.m_Page,m_stackTop))
406 return FALSE;
407 ASSERT(rr.m_Offset<m_stackTop.GetSize());
408 if(m_stackTop[rr.m_Offset].m_ptrRight>=0){
409 // Advance pointer in this page and dive into subtree
410 // going left and left until we have nowhere to go.
411 // TRACE1("Dive into page %lu",m_stackTop[rr.m_Offset].m_ptrRight);
412 m_btStack.Add(CBTRecordRef(m_stackTop[rr.m_Offset++].m_ptrRight,0));
413 for(;;){
414 CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()];
415 ASSERT(rr.m_Offset==0);
416 if(!LoadPage(rr.m_Page,m_stackTop))
417 return FALSE;
418 if(m_stackTop[rr.m_Offset].m_ptrLeft<0)
419 break;
420 // TRACE1(", %lu",m_stackTop[rr.m_Offset].m_ptrLeft);
421 m_btStack.Add(CBTRecordRef(m_stackTop[rr.m_Offset].m_ptrLeft,0));
422 }
423 // TRACE0("\n");
424 return TRUE;
425 }else if(rr.m_Offset<m_stackTop.GetUpperBound()){
426 rr.m_Offset++;
427 return TRUE;
428 }
429 // We're at the end of page go up until we're done or we have data.
430 m_btStack.RemoveAt(m_btStack.GetUpperBound());
431 // TRACE0("Go up");
432 while(m_btStack.GetSize()){
433 CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()];
434 if(!LoadPage(rr.m_Page,m_stackTop))
435 return FALSE;
436 if(rr.m_Offset<m_stackTop.GetSize()){
437 // TRACE0("\n");
438 return TRUE;
439 }
440 // TRACE0(", up");
441 m_btStack.RemoveAt(m_btStack.GetUpperBound());
442 }
443 // TRACE0("\nBtree is done\n");
444 return FALSE;
445 }
446 BOOL GoPrev() {
447 if(!IsOpened())
448 return FALSE;
449 if(!(m_btStack.GetSize() && m_btStack[m_btStack.GetUpperBound()].m_Offset>=0))
450 return FALSE;
451 CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()];
452 if(!LoadPage(rr.m_Page,m_stackTop))
453 return FALSE;
454 ASSERT(rr.m_Offset<m_stackTop.GetSize());
455 if(m_stackTop[rr.m_Offset].m_ptrLeft>=0){
456 // Dive in and go right and right from the rightmost until
457 // we have nowhere to go.
458 m_btStack.Add(CBTRecordRef(m_stackTop[rr.m_Offset].m_ptrLeft,-1));
459 for(;;){
460 CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()];
461 if(!LoadPage(rr.m_Page,m_stackTop))
462 return FALSE;
463 rr.m_Offset = m_stackTop.GetUpperBound();
464 if(m_stackTop[rr.m_Offset].m_ptrRight<0)
465 return TRUE;
466 m_btStack.Add(CBTRecordRef(m_stackTop[rr.m_Offset++].m_ptrRight,-1));
467 }
468 return TRUE;
469 }else if(rr.m_Offset>0){
470 rr.m_Offset--;
471 return TRUE;
472 }
473 // We're at the leftmost element in page - go up and left until we're
474 // done or we have data.
475 m_btStack.RemoveAt(m_btStack.GetUpperBound());
476 while(m_btStack.GetSize()){
477 CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()];
478 if(!LoadPage(rr.m_Page,m_stackTop))
479 return FALSE;
480 rr.m_Offset--;
481 if(rr.m_Offset>=0)
482 return TRUE;
483 m_btStack.RemoveAt(m_btStack.GetUpperBound());
484 }
485 // No more data - we were at the first element in tree.
486 return FALSE;
487 }
488 BOOL GetThis(key& _key,value& _value) {
489 if(!IsOpened())
490 return FALSE;
491 // *** MORE CHECKING
492 CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()];
493 if(!LoadPage(rr.m_Page,m_stackTop))
494 return FALSE;
495 _key = m_stackTop[rr.m_Offset].m_Key;
496 _value = m_stackTop[rr.m_Offset].m_Value;
497 return TRUE;
498 }
499
500 BOOL SeekToPage(const key& _key) {
501 ASSERT(IsOpened());
502 ASSERT(m_BTCrap->m_bRootSet);
503 m_btStack.RemoveAll();
504 m_btStack.Add(CBTRecordRef(m_BTCrap->m_Root,-1));
505 for(;;){
506 CBTRecordRef& rr = m_btStack[m_btStack.GetUpperBound()];
507 if(!LoadPage(rr.m_Page,m_stackTop))
508 return FALSE;
509 ASSERT(m_stackTop.GetSize() || !m_btStack.GetUpperBound());
510 if(!m_stackTop.GetSize()){
511 rr.m_Offset=-1;
512 return TRUE;
513 }
514 for(rr.m_Offset=0;rr.m_Offset<m_stackTop.GetSize();rr.m_Offset++){
515 if(_key == m_stackTop[rr.m_Offset].m_Key)
516 return TRUE;
517 if(_key < m_stackTop[rr.m_Offset].m_Key){
518 ASSERT(rr.m_Offset==0 || m_stackTop[rr.m_Offset].m_ptrLeft==m_stackTop[rr.m_Offset-1].m_ptrRight);
519 if(m_stackTop[rr.m_Offset].m_ptrLeft<0)
520 return TRUE;
521 m_btStack.Add(CBTRecordRef(m_stackTop[rr.m_Offset].m_ptrLeft,-1));
522 break;
523 }
524 if(rr.m_Offset==m_stackTop.GetUpperBound()){
525 if(m_stackTop[rr.m_Offset].m_ptrRight<0){
526 rr.m_Offset=-1;
527 return TRUE;
528 }
529 m_btStack.Add(CBTRecordRef(m_stackTop[rr.m_Offset].m_ptrRight,-1));
530 break;
531 }
532 }
533 }
534 }
535
536 BOOL LoadPage(CBTPageRef ref,CBTPage& page) {
537 CFile* pageFile = m_BT.OpenFile(ref);
538 if(!pageFile)
539 return FALSE;
540 BOOL rv = TRUE;
541 try{
542 CArchive ar(pageFile,CArchive::load);
543 page.Serialize(ar);
544 if(m_bRO)
545 page.FreeExtra();// ** ???
546 ar.Close();
547 }catch(CException* e){
548 e->Delete();
549 rv = FALSE;
550 }
551 delete pageFile;
552 return rv;
553 }
554 BOOL SavePage(CBTPageRef ref,CBTPage& page) {
555 CFile* pageFile = m_BT.OpenFile(ref);
556 if(!pageFile)
557 return FALSE;
558 BOOL rv = TRUE;
559 try{
560 CArchive ar(pageFile,CArchive::store);
561 page.Serialize(ar);
562 ar.Close();
563 }catch(CException* e){
564 e->Delete();
565 rv = FALSE;
566 }
567 delete pageFile;
568 return rv;
569 }
570 CBTPageRef AllocatePage() {
571 CBTDynaFile* pageFile = m_BT.CreateFile();
572 if(!pageFile)
573 return -1;
574 CBTPage nothing;
575 CBTPageRef rv = pageFile->GetFile();
576 try{
577 CArchive ar(pageFile,CArchive::store);
578 nothing.Serialize(ar);
579 ar.Close();
580 }catch(CException* e){
581 e->Delete();
582 rv = -1;
583 }
584 delete pageFile;
585 return rv;
586 }
587 BOOL DeallocatePage(CBTPageRef ref) {
588 return m_BT.DeleteFile(ref);
589 }
590
591};
592
593};
594
595 #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 @@
1 #ifndef__BELLSNWHISTLES_H
2#define __BELLSNWHISTLES_H
3
4 class CBellsNWhistles{
5public:
6 class CBang {
7 public:
8 CString m_codeName;
9 enum_bangType {
10 bangNone, bangSpeaker, bangSystem, bangResource,
11 bangWaveform
12 }m_type;
13 BOOL m_bLoop;
14 union{
15 UINT system;
16 LPCTSTR resource;
17 LPCTSTR wave;
18
19 LPCTSTR str;
20 UINT id;
21 };
22 CString m_strWave;
23 CBang() : m_type(bangNone), m_bLoop(FALSE) {}
24 };
25 typedef CTypedPtrMap<CMapStringToPtr,CString,CBang*> CBangs;
26 structCBelling {
27 LPCSTR snd;
28 HMODULE hm;
29 DWORD flags;
30 CBelling(LPCSTR snd,HMODULE hm,DWORD flags) : snd(snd), hm(hm),
31 flags(flags) {}
32 CBelling(CBelling& s) : snd(s.snd), hm(s.hm), flags(s.flags) {}
33 CBelling& operator=(CBelling& s) {
34 snd=s.snd; hm=s.hm; flags=s.flags;
35 return *this;
36 }
37 };
38 typedef CBelling* Whistling;
39
40 CBangs m_bangs;
41
42 ~CBellsNWhistles() {
43 POSITION p = m_bangs.GetStartPosition();
44 while(p){
45 CString s; CBang* b;
46 m_bangs.GetNextAssoc(p,s,b);
47 delete b;
48 }
49 m_bangs.RemoveAll();
50 }
51
52 BOOL AssignSound(LPCTSTR codeName,LPCTSTR id,CBang::_bangType type=CBang::bangWaveform) {
53 CString cn = codeName;
54 cn.MakeLower();
55 CBang* b;
56 if(!m_bangs.Lookup(cn,b)) {
57 b = new CBang;
58 b->m_codeName=cn;
59 m_bangs[cn]=b;
60 }
61 b->m_type=type;
62 b->str = id;
63 if(type==CBang::bangWaveform){
64 b->m_strWave=id; b->str = b->m_strWave;
65 }
66 return TRUE;
67 }
68 BOOL AssignSound(LPCTSTR codeName,UINT nID,CBang::_bangType type=CBang::bangResource) {
69 CString cn = codeName;
70 cn.MakeLower();
71 CBang* b;
72 if(!m_bangs.Lookup(cn,b)) {
73 b = new CBang;
74 b->m_codeName=cn;
75 m_bangs[cn]=b;
76 }
77 b->m_type=type;
78 b->id = nID;
79 ASSERT(type!=CBang::bangWaveform);
80 return TRUE;
81 }
82 BOOL UnassignSound(LPCTSTR codeName) {
83 CString cn = codeName;
84 cn.MakeLower();
85 CBang* b;
86 if(m_bangs.Lookup(cn,b)) {
87 m_bangs.RemoveKey(cn);
88 delete b;
89 return TRUE;
90 }
91 return FALSE;
92 }
93
94 Whistling StartSound(LPCTSTR codeName) {
95 Whistling* rv = NULL;
96 CString cn = codeName;
97 CBang* b;
98 if(!m_bangs.Lookup(cn,b)){
99 ::PlaySound(cn,AfxGetInstanceHandle(),SND_ASYNC|SND_NODEFAULT|SND_NOWAIT|SND_FILENAME);
100 return NULL;
101 }
102 UINT flags = SND_ASYNC|SND_NODEFAULT|SND_NOWAIT;
103 LPCSTR snd = NULL;
104 switch(b->m_type){
105 case CBang::bangNone: return NULL;
106 case CBang::bangSpeaker: MessageBeep(0xFFFFFFFF); return NULL;
107 case CBang::bangSystem: MessageBeep(b->system); return NULL;
108 case CBang::bangResource:
109 snd = b->resource;
110 flags|=SND_RESOURCE; break;
111 case CBang::bangWaveform:
112 snd = b->wave;
113 flags|=SND_FILENAME; break;
114#ifdef _DEBUG
115 default:
116 ASSERT(FALSE); return NULL;
117#endif
118 }
119 if(b->m_bLoop)
120 flags|=SND_LOOP;
121 HMODULE hm = AfxGetInstanceHandle();
122 if(!::PlaySound(snd,hm,flags))
123 return NULL;
124 return b->m_bLoop?new CBelling(snd,hm,flags):NULL;
125 }
126 BOOL StopSound(Whistling whistle) {
127 if(!whistle)
128 return FALSE;
129 ::PlaySound(whistle->snd,whistle->hm,whistle->flags|SND_PURGE);
130 delete whistle;
131 return TRUE;
132 }
133 UINT FillInCombo(CComboBox* combo) {
134 POSITION p = m_bangs.GetStartPosition();
135 UINT rv = 0;
136 while(p) {
137 CString s;
138 CBang* b;
139 m_bangs.GetNextAssoc(p,s,b);
140 combo->AddString(s);
141 }
142 return rv;
143 }
144};
145
146 #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 @@
1 #ifndef__BITSET_H
2#define __BITSET_H
3
4namespace Klever {
5
6 class CBitSet: public CObject {
7public:
8 CWordArray m_Bits;
9 ULONG m_BitsInSet;
10 enum{
11 bitsPerWord = sizeof(WORD)*8
12 };
13
14 CBitSet(ULONG size = 0) : m_BitsInSet(0) { SetSize(size); }
15 CBitSet(CBitSet& o) : m_BitsInSet(0) { CopyFrom(o); }
16
17 void SetSize(ULONG size,BOOL bFillOnes=FALSE) {
18 UINT os = m_Bits.GetSize();
19 UINT ns = (size+bitsPerWord-1)/bitsPerWord;
20 if(os==ns){
21 if(os){
22 if(bFillOnes)
23 m_Bits[m_BitsInSet/bitsPerWord]|=(~(WORD)0)<<(m_BitsInSet%bitsPerWord);
24 else
25 m_Bits[m_BitsInSet/bitsPerWord]&=~((~(WORD)0)<<(m_BitsInSet%bitsPerWord));
26 }
27 m_BitsInSet=size;
28 }else{
29 // *?* ASSERT((!os) || (((os-1)*bitsPerWord)<=m_BitsInSet && m_BitsInSet<(os*bitsPerWord)));
30 if(os<ns){
31 m_Bits.SetSize(ns);
32 if(bFillOnes)
33 m_Bits[m_BitsInSet/bitsPerWord]|=(~(WORD)0)<<(m_BitsInSet%bitsPerWord);
34 else
35 m_Bits[m_BitsInSet/bitsPerWord]&=~((~(WORD)0)<<(m_BitsInSet%bitsPerWord));
36 WORD* ws = m_Bits.GetData();
37 ASSERT(ws);
38 memset(&ws[os],bFillOnes?0xFF:0,(ns-os)*sizeof(WORD));
39 m_BitsInSet=size;
40 }else{
41 m_Bits.SetSize(ns);
42 m_BitsInSet=size;
43 }
44 }
45 }
46 BOOL BitSet(UINT bit,BOOL bGrow=TRUE) { return SetBit(bit,TRUE,bGrow); }
47 BOOL BitClear(UINT bit,BOOL bGrow=TRUE) { return SetBit(bit,FALSE,bGrow); }
48 BOOL SetBit(UINT bit,BOOL state,BOOL bGrow=TRUE) {
49 if(m_BitsInSet<=bit){
50 if(!bGrow)
51 return FALSE;
52 SetSize(bit+1);
53 }
54 WORD mask = ((WORD)1)<<(bit%bitsPerWord);
55 if(state)
56 m_Bits[bit/bitsPerWord]|=mask;
57 else
58 m_Bits[bit/bitsPerWord]&=~mask;
59 return TRUE;
60 }
61 BOOL IsSet(UINT bit) {
62 if(m_BitsInSet<=bit)
63 return FALSE;
64 return (m_Bits[bit/bitsPerWord]&(((WORD)1)<<(bit%bitsPerWord)))!=0;
65 }
66 void Invert() {
67 for(int i=m_Bits.GetUpperBound();i>=0;i--)
68 m_Bits[i]=~m_Bits[i];
69 }
70 CBitSet& operator&=(CBitSet& o) {
71 if(o.m_BitsInSet<m_BitsInSet)
72 SetSize(o.m_BitsInSet);
73 for(int i=m_Bits.GetUpperBound();i>=0;i--)
74 m_Bits[i]&=o.m_Bits[i];
75 return *this;
76 }
77 CBitSet& operator|=(CBitSet& o) {
78 if(o.m_BitsInSet>m_BitsInSet)
79 SetSize(o.m_BitsInSet);
80 for(int i=o.m_Bits.GetUpperBound();i>=0;i--)
81 m_Bits[i]|=o.m_Bits[i];
82 return *this;
83 }
84 CBitSet& operator=(CBitSet& o) {
85 CopyFrom(o);
86 return *this;
87 }
88 void CopyFrom(CBitSet& o) {
89 m_BitsInSet=o.m_BitsInSet;
90 m_Bits.Copy(o.m_Bits);
91 }
92 void Serialize(CArchive& ar) {
93 if(ar.IsStoring()){
94 ar << m_BitsInSet;
95 m_Bits.Serialize(ar);
96 }else{
97 ar >> m_BitsInSet;
98 m_Bits.Serialize(ar);
99 }
100 }
101};
102
103};
104
105#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 @@
1#ifndef __DYNAMIDE_H
2#define __DYNAMIDE_H
3
4#include "LRUCache.h"
5
6namespace Klever {
7
8template<int fbSize,int bSize>
9class CDynamide : public CObject {
10 structfirstBlock {
11 LONGfreeFile;
12 BYTEcrap[fbSize-sizeof(LONG)];
13 };
14 structtheBlock {
15 LONGnext;
16 BYTEdata[bSize-sizeof(LONG)];
17 };
18public:
19 static firstBlock FirstBlock;
20 static theBlock TheBlock;
21private:
22 classCDynaCache : public CLRUCache<DWORD,DWORD,theBlock> {
23 public:
24 CFile* m_File;
25 BOOL m_bAutodelete;
26 CDynaCache(CFile* file,BOOL bAutodelete=TRUE) : CLRUCache<DWORD,DWORD,theBlock>(64) {
27 m_File=file;
28 m_bAutodelete=bAutodelete;
29 }
30 virtual ~CDynaCache() {
31 Flush();
32 if(m_bAutodelete){
33 m_File->Close();
34 delete m_File;
35 }
36 }
37 virtual BOOL _ReadIn(DWORD idx,theBlock* data) {
38 LONG p = sizeof(firstBlock)+idx*sizeof(theBlock);
39 LONG s = m_File->Seek(p,CFile::begin);
40 if(p==s){
41 UINT rb = m_File->Read(data,sizeof(*data));
42 if(rb==sizeof(*data))
43 return TRUE;
44 if(rb)
45 return FALSE;
46 memset(data,0,sizeof(*data));
47 data->next=-1;
48 try{
49 m_File->Write(data,sizeof(*data));
50 }catch(CException* e){
51 e->Delete();
52 return FALSE;
53 }
54 }else{
55 LONG togo = p-s;
56 ASSERT(togo>0);
57 ASSERT(!(togo%sizeof(theBlock)));
58 memset(data,0,sizeof(*data));
59 data->next=-1;
60 while(togo>=0){
61 try{
62 m_File->Write(data,sizeof(*data));
63 }catch(CException* e){
64 e->Delete();
65 return FALSE;
66 }
67 }
68 }
69 return TRUE;
70 }
71 virtual BOOL _WriteOut(DWORD idx,theBlock* data) {
72 LONG p = sizeof(firstBlock)+idx*sizeof(theBlock);
73 LONG s = m_File->Seek(p,CFile::begin);
74 if(p!=s)
75 return FALSE;
76 try{
77 m_File->Write(data,sizeof(*data));
78 }catch(CException* e){
79 e->Delete();
80 return FALSE;
81 }
82 return TRUE;
83 }
84 DWORD AllocateNode() {
85 LONG l = m_File->GetLength();
86 ASSERT(!((l-sizeof(firstBlock))%sizeof(theBlock)));
87 m_File->SetLength(l+sizeof(theBlock));
88 return (l-sizeof(firstBlock))/sizeof(theBlock);
89 }
90 BOOL Read1stBlock(firstBlock* fb) {
91 m_File->SeekToBegin();
92 UINT rb = m_File->Read(fb,sizeof(*fb));
93 if(rb==sizeof(*fb))
94 return TRUE;
95 if(rb)
96 return FALSE;
97 memset(fb,0,sizeof(*fb));
98 fb->freeFile = -1;
99 try{
100 m_File->Write(fb,sizeof(*fb));
101 }catch(CException* e){
102 e->Delete();
103 return FALSE;
104 }
105 return TRUE;
106 }
107 BOOL Write1stBlock(firstBlock* fb) {
108 m_File->SeekToBegin();
109 try{
110 m_File->Write(fb,sizeof(*fb));
111 }catch(CException* e){
112 e->Delete();
113 return FALSE;
114 }
115 return TRUE;
116 }
117 };
118public:
119 class CDynaFile : public CFile{
120 public:
121 CDynamide<fbSize,bSize>* m_Daddy;
122 CArray<LONG,LONG> m_Blocks;
123 LONG m_Position;
124
125 CDynaFile(CDynamide<fbSize,bSize>* daddy) : m_Daddy(NULL) { AttachToDaddy(daddy); }
126 virtual ~CDynaFile() { Close(); DetachFromDaddy(); }
127
128 void AttachToDaddy(CDynamide<fbSize,bSize>* daddy) {
129 ASSERT(!m_Daddy);
130 ASSERT(daddy);
131 m_Daddy=daddy;
132 m_Daddy->AttachDynaFile(this);
133 }
134 void DetachFromDaddy() {
135 ASSERT(m_Daddy);
136 ASSERT(!IsOpened());
137 m_Daddy->DetachDynaFile(this);
138 m_Daddy=NULL;
139 }
140
141 BOOL Create() {
142 if(IsOpened())
143 return FALSE;
144 m_Blocks.SetAtGrow(0,m_Daddy->Allocate());
145 ASSERT(m_Blocks[0]>=0);
146 m_Position=0;
147 return TRUE;
148 }
149 BOOL Open(LONG fb) {
150 if(IsOpened())
151 return FALSE;
152 ASSERT(fb>=0);
153 theBlock* b;
154 do{
155 m_Blocks.Add(fb);
156 b = m_Daddy->m_File->GetCached(fb);
157 ASSERT(b);
158 fb=b->next;
159 if(m_Blocks[m_Blocks.GetUpperBound()]==fb)
160 return FALSE;
161 }while(fb>=0);
162 m_Position=0;
163 return TRUE;
164 }
165
166 LONG GetFile() {
167 if(!IsOpened())
168 return -1;
169 return m_Blocks[0];
170 }
171 virtual DWORD GetPosition() const {
172 if(!IsOpened())
173 return 0;
174 if(m_Position<0)
175 return 0;
176 if(m_Position>GetLength())
177 return GetLength();
178 return m_Position;
179 }
180 virtual CString GetFileName() {
181 CString rv;
182 if(IsOpened())
183 rv.Format("0x%08lX",m_Blocks[0]);
184 else
185 rv.Format("None");
186 return rv;
187 }
188 virtual CString GetFileTitle() { return GetFileName(); }
189 virtual CString GetFilePath() { return GetFileName(); }
190 virtual void SetFilePath(LPCTSTR lpszNewName) { ASSERT(FALSE); }
191
192 virtual BOOL Open(LPCTSTR lpszFileName, UINT nOpenFlags, CFileException* pError = NULL) { ASSERT(FALSE); return FALSE; }
193 virtual CFile* Duplicate() { ASSERT(FALSE); return NULL; }
194
195 virtual LONG Seek(LONG lOff, UINT nFrom) {
196 if(!IsOpened())
197 return -1;
198 switch(nFrom){
199 case CFile::begin:
200 m_Position=lOff;
201 break;
202 case CFile::current:
203 m_Position+=lOff;
204 break;
205 case CFile::end:
206 m_Position=GetLength()+lOff;
207 break;
208 default:
209 ASSERT(FALSE);
210 return -1;
211 }
212 if(m_Position<0)
213 m_Position=0;
214 if(m_Position>GetLength())
215 m_Position=GetLength();
216 return m_Position;
217 }
218 virtual void SetLength(DWORD dwNewLen) {
219 if(!IsOpened())
220 return;
221 if(dwNewLen<GetLength()){
222 dwNewLen=dwNewLen+sizeof(TheBlock.data);
223 dwNewLen-=dwNewLen%sizeof(TheBlock.data);
224 while(dwNewLen<GetLength() && m_Blocks.GetSize()>1){
225 LONG mb = m_Blocks[m_Blocks.GetUpperBound()];
226 LONG mb1 = m_Blocks[m_Blocks.GetUpperBound()-1];
227 theBlock* b = m_Daddy->m_File->GetCached(mb1);
228 ASSERT(b);
229 ASSERT(b->next==mb);
230 b->next=-1;
231 m_Daddy->m_File->MakeDirty(mb1);
232 m_Daddy->Deallocate(mb);
233 m_Blocks.SetSize(m_Blocks.GetSize()-1);
234 }
235 }else{
236 while(dwNewLen>GetLength()){
237 LONG mb = m_Blocks[m_Blocks.GetUpperBound()];
238 LONG newBlock = m_Daddy->Allocate();
239 ASSERT(newBlock>=0);
240 theBlock* b = m_Daddy->m_File->GetCached(mb);
241 ASSERT(b);
242 ASSERT(b->next<0);
243 b->next=newBlock;
244 m_Daddy->m_File->MakeDirty(mb);
245 m_Blocks.Add(newBlock);
246 }
247 }
248 }
249 virtual DWORD GetLength() const {
250 return ((long)m_Blocks.GetSize())*((long)sizeof(TheBlock.data));
251 }
252
253 virtual UINT Read(void* lpBuf, UINT nCount) {
254 UINT rv = 0;
255 ASSERT(m_Position>=0 && m_Position<=GetLength());
256 LPBYTE data = (LPBYTE)lpBuf;
257 while(nCount && m_Position<GetLength()){
258 UINT bn = m_Position/sizeof(TheBlock.data);
259 UINT bo = m_Position%sizeof(TheBlock.data);
260 theBlock* b = m_Daddy->m_File->GetCached(m_Blocks[bn]);
261 ASSERT(b);
262 UINT bc = min(nCount,sizeof(TheBlock.data)-bo);
263 memmove(data,&b->data[bo],bc);
264 nCount-=bc;
265 data=&data[bc];
266 rv+=bc;
267 m_Position+=bc;
268 }
269 return rv;
270 }
271 virtual void Write(const void* lpBuf, UINT nCount) {
272 ASSERT(m_Position>=0 && m_Position<=GetLength());
273 LPBYTE data = (LPBYTE)lpBuf;
274 while(nCount){
275 UINT bn = m_Position/sizeof(TheBlock.data);
276 UINT bo = m_Position%sizeof(TheBlock.data);
277 while(bn>=m_Blocks.GetSize()){
278 LONG mb = m_Blocks[m_Blocks.GetUpperBound()];
279 LONG newBlock = m_Daddy->Allocate();
280 ASSERT(newBlock>=0);
281 theBlock* b = m_Daddy->m_File->GetCached(mb);
282 ASSERT(b);
283 ASSERT(b->next<0);
284 b->next=newBlock;
285 m_Daddy->m_File->MakeDirty(mb);
286 m_Blocks.Add(newBlock);
287 }
288 theBlock* b = m_Daddy->m_File->GetCached(m_Blocks[bn]);
289 ASSERT(b);
290 UINT bc = min(nCount,sizeof(TheBlock.data)-bo);
291 memmove(&b->data[bo],data,bc);
292 m_Daddy->m_File->MakeDirty(m_Blocks[bn]);
293 nCount-=bc;
294 data=&data[bc];
295 m_Position+=bc;
296 }
297 }
298
299 virtual void LockRange(DWORD dwPos, DWORD dwCount) { ASSERT(FALSE); }
300 virtual void UnlockRange(DWORD dwPos, DWORD dwCount) { ASSERT(FALSE); }
301
302 virtual void Abort() { ASSERT(FALSE); }
303 virtual void Flush() {
304 m_Daddy->m_File->Flush();
305 }
306 virtual void Close() {
307 m_Blocks.RemoveAll();
308 }
309
310 BOOL IsOpened() const { return m_Blocks.GetSize()!=0; }
311 };
312
313 CDynaCache* m_File;
314 firstBlock m_FB;
315
316 CDynamide() : m_File(NULL) {}
317 ~CDynamide() { Close(); }
318
319 BOOL AttachDynaFile(CDynaFile* f) {
320 //ASSERT(!m_Files.Find(f));
321 //m_Files.AddHead(f);
322 return TRUE;
323 }
324 BOOL DetachDynaFile(CDynaFile* f) {
325 //POSITION p = m_Files.Find(f);
326 //ASSERT(p);
327 //m_Files.RemoveAt(p);
328 return TRUE;
329 }
330
331 BOOL Open(LPCTSTR file,BOOL bRO=FALSE) {
332 Close();
333 try{
334 CFile* f = new CFile(file,CFile::typeBinary|(bRO?CFile::modeRead|CFile::shareDenyWrite:CFile::modeReadWrite|CFile::shareDenyRead));
335 return Attach(f,TRUE);
336 }catch(CException* e){
337 e->Delete();
338 return FALSE;
339 }
340 }
341 BOOL Create(LPCTSTR file) {
342 Close();
343 try{
344 CFile* f = new CFile(file,CFile::typeBinary|CFile::modeCreate|CFile::modeReadWrite|CFile::shareDenyRead);
345 return Attach(f,TRUE);
346 }catch(CException* e){
347 e->Delete();
348 return FALSE;
349 }
350 }
351 BOOL Attach(CFile* file,BOOL bAutodelete=TRUE) {
352 if(IsOpened())
353 return FALSE;
354 m_File = new CDynaCache(file,bAutodelete);
355 if(!m_File->Read1stBlock(&m_FB)){
356 memset(&m_FB,0,sizeof(m_FB));
357 m_FB.freeFile=-1;
358 VERIFY(m_File->Write1stBlock(&m_FB));
359 }
360 return IsOpened();
361 }
362 // CFile* Detach();
363 BOOL Close() {
364 if(!IsOpened())
365 return FALSE;
366 m_File->Write1stBlock(&m_FB);
367 delete m_File;
368 m_File=NULL;
369 return TRUE;
370 }
371 BOOL IsOpened() {
372 return m_File != NULL;
373 }
374 BOOL Write1stBlock(void) {
375 if(!IsOpened())
376 return FALSE;
377 VERIFY(m_File->Write1stBlock(&m_FB));
378 return TRUE;
379 }
380
381 CDynaFile* CreateFile() {
382 CDynaFile* rv = new CDynaFile(this);
383 if(rv->Create())
384 return rv;
385 delete rv;
386 return NULL;
387 }
388 CDynaFile* OpenFile(LONG fb) {
389 CDynaFile* rv = new CDynaFile(this);
390 if(rv->Open(fb))
391 return rv;
392 delete rv;
393 return NULL;
394 }
395 BOOL DeleteFile(LONG fb) {
396 while(fb>=0){
397 theBlock* b = m_File->GetCached(fb);
398 LONG nb = b->next;
399 Deallocate(fb);
400 fb=nb;
401 }
402 return TRUE;
403 }
404
405 LONG Allocate() {
406 if(!IsOpened())
407 return -1;
408 if(m_FB.freeFile<0){
409 LONG rv = m_File->AllocateNode();
410 theBlock *b = m_File->GetCached(rv);
411 b->next=-1;
412 m_File->MakeDirty(rv);
413 return rv;
414 }
415 LONG rv = m_FB.freeFile;
416 theBlock *b = m_File->GetCached(rv);
417 m_FB.freeFile=b->next;
418 b->next=-1;
419 m_File->MakeDirty(rv);
420 m_File->Write1stBlock(&m_FB);
421 return rv;
422 }
423 BOOL Deallocate(LONG bk) {
424 if(!IsOpened())
425 return FALSE;
426 theBlock* b = m_File->GetCached(bk);
427 ASSERT(b);
428 if(m_FB.freeFile<0){
429 b->next=-1;
430 m_FB.freeFile=bk;
431 }else{
432 b->next=m_FB.freeFile;
433 m_FB.freeFile=bk;
434 }
435 m_File->MakeDirty(bk);
436 m_File->Write1stBlock(&m_FB);
437 return TRUE;
438 }
439};
440
441};
442
443#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 @@
1 #ifndef__FINDIFACE_H
2 #define__FINDIFACE_H
3
4#include "SNMPeer.h"
5#include "SNMPExtDLL.h"
6#include "SNMPOIDs.h"
7
8namespace Klever {
9
10inline BOOL FindIFace(in_addr& target,in_addr& source)
11{
12 DEFINE_OID(ipRouteDest, OIDipRouteDest);
13 DEFINE_OID(ipRouteMask, OIDipRouteMask);
14 DEFINE_OID(ipRouteIfIndex,OIDipRouteIfIndex);
15 DEFINE_OID(ipRouteMetric1,OIDipRouteMetric1);
16 DEFINE_OID(ipAdEntIfIndex,OIDipAdEntIfIndex);
17 DEFINE_OID(ipAdEntAddr, OIDipAdEntAddr);
18 struct _route{
19 int iface;
20 int metric;
21 DWORD nm;
22 }routes[16];
23int nRoutes = 0;
24CSNMPVarBindList vbl;
25 vbl.AddTail(CSNMPVarBind(CASNAny(CASNAny::typeASNOID,ipRouteDest,sizeof(ipRouteDest))));
26 vbl.AddTail(CSNMPVarBind(CASNAny(CASNAny::typeASNOID,ipRouteMask,sizeof(ipRouteMask))));
27 vbl.AddTail(CSNMPVarBind(CASNAny(CASNAny::typeASNOID,ipRouteIfIndex,sizeof(ipRouteIfIndex))));
28 vbl.AddTail(CSNMPVarBind(CASNAny(CASNAny::typeASNOID,ipRouteMetric1,sizeof(ipRouteMetric1))));
29CSNMPExtDLL snmp("INETMIB1");
30 while(nRoutes<(sizeof(routes)/sizeof(routes[0]))){
31 if(
32 snmp.Request(CASNAny::typeASNGetNextRequest,vbl,vbl)
33 && vbl.GetCount() == 4
34 ){
35 POSITION p = vbl.GetHeadPosition();
36 _route r = {-1,-1};
37 in_addr d, m;
38 BOOL bD = FALSE, bM = FALSE;
39 while(p){
40 CSNMPVarBind& vb = vbl.GetNext(p);
41 if(
42 vb.IsName(ipRouteDest,sizeof(ipRouteDest))
43 && vb.value.type==CASNAny::typeASNIP
44 ){
45 d.s_addr=vb.value.value.ip.s_addr; bD = TRUE;
46 }else if(
47 vb.IsName(ipRouteMask,sizeof(ipRouteMask))
48 && vb.value.type==CASNAny::typeASNIP
49 ){
50 m.s_addr=vb.value.value.ip.s_addr; bM = TRUE;
51 }else if(
52 vb.IsName(ipRouteIfIndex,sizeof(ipRouteIfIndex))
53 && vb.value.type==CASNAny::typeASNInteger
54 ){
55 r.iface=vb.value.value.number;
56 }else if(
57 vb.IsName(ipRouteMetric1,sizeof(ipRouteMetric1))
58 && vb.value.type==CASNAny::typeASNInteger
59 ){
60 r.metric=vb.value.value.number;
61 }else
62 break;
63 }
64 if(r.iface<0 || r.metric<0 || (!bD) || (!bM))
65 break;
66 if((target.s_addr&m.s_addr)==(d.s_addr&m.s_addr)){
67 r.nm=htonl(m.s_addr);
68 memmove(&routes[nRoutes++],&r,sizeof(routes[0]));
69 }
70 }else
71 break;
72 }
73 if(!nRoutes)
74 return FALSE;
75int rn = 0;
76 if(nRoutes>1){
77 for(int tmp=1;tmp<nRoutes;tmp++)
78 if(
79 routes[tmp].metric<routes[rn].metric
80 || routes[tmp].nm>routes[rn].nm
81 )
82 rn = tmp;
83 }
84int iface = routes[rn].iface;
85 vbl.RemoveAll();
86 vbl.AddTail(CSNMPVarBind(CASNAny(CASNAny::typeASNOID,ipAdEntAddr,sizeof(ipAdEntAddr))));
87 vbl.AddTail(CSNMPVarBind(CASNAny(CASNAny::typeASNOID,ipAdEntIfIndex,sizeof(ipAdEntIfIndex))));
88 for(;;){
89 if(
90 snmp.Request(CASNAny::typeASNGetNextRequest,vbl,vbl)
91 && vbl.GetCount()==2
92 ){
93 in_addr a; a.s_addr = INADDR_NONE;
94 int ifn = -1;
95 POSITION p = vbl.GetHeadPosition();
96 while(p){
97 CSNMPVarBind& vb = vbl.GetNext(p);
98 if(
99 vb.IsName(ipAdEntAddr,sizeof(ipAdEntAddr))
100 && vb.value.type==CASNAny::typeASNIP
101 ){
102 a.s_addr=vb.value.value.ip.s_addr;
103 }else if(
104 vb.IsName(ipAdEntIfIndex,sizeof(ipAdEntIfIndex))
105 && vb.value.type==CASNAny::typeASNInteger
106 ){
107 ifn = vb.value.value.number;
108 }else
109 break;
110 }
111 if(ifn<0)
112 break;
113 if(ifn==iface){
114 source.s_addr=a.s_addr;
115 return TRUE;
116 }
117 }else
118 break;
119 }
120 return FALSE;
121}
122
123};
124
125 #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 @@
1 #ifndef__LRUCACHE_H
2 #define__LRUCACHE_H
3
4namespace Klever {
5
6template<class IDX,class ARGIDX,class DATA>
7class CLRUCache : public CObject {
8public:
9 struct CacheEntry{
10 enum cacheState{
11 cacheClean, cacheDirty, cacheEmpty
12 };
13 cacheStatem_State;
14 UINT m_hits;
15
16 IDX m_idx;
17 DATA* m_pData;
18
19 CacheEntry() { m_State=cacheEmpty; VERIFY(m_pData=new DATA); m_hits=0; }
20 virtual ~CacheEntry() { delete m_pData; }
21 };
22 typedef CMap<IDX,ARGIDX,CacheEntry*,CacheEntry*> CCacheMap;
23 typedef CList<CacheEntry*,CacheEntry*> CCacheList;
24
25 CCacheList m_Cache;
26 CCacheMap m_Map;
27
28 CLRUCache(UINT cacheSize){
29 for(int tmp=0;tmp<cacheSize;tmp++){
30 CacheEntry* p = new CacheEntry;
31 m_Cache.AddTail(p);
32 }
33 }
34 virtual ~CLRUCache(){
35 Flush();
36 POSITION p = m_Cache.GetHeadPosition();
37 while(p){
38 CacheEntry* c = m_Cache.GetNext(p);
39 delete c;
40 }
41 }
42
43 DATA* GetCached(ARGIDX idx,BOOL bLoad=TRUE) {
44 CacheEntry* rv;
45 if(m_Map.Lookup(idx,rv)){
46 rv->m_hits++;
47 PopUp(rv);
48 return rv->m_pData;
49 }
50 if(!bLoad)
51 return NULL;
52 rv = m_Cache.GetTail();
53 ASSERT(rv);
54 switch(rv->m_State){
55 case CacheEntry::cacheDirty:
56 FlushEntry(rv);
57 case CacheEntry::cacheClean:
58 m_Map.RemoveKey(rv->m_idx);
59 rv->m_State=CacheEntry::cacheEmpty;
60 case CacheEntry::cacheEmpty:
61 break;
62 default:
63 ASSERT(FALSE);
64 }
65 if(!_ReadIn(idx,rv->m_pData))
66 return NULL;
67 rv->m_hits=1;
68 rv->m_State=CacheEntry::cacheClean;
69 rv->m_idx=idx;
70 m_Map[idx]=rv;
71 PopUp(rv);
72 return rv->m_pData;
73 }
74 BOOL MakeDirty(ARGIDX idx) {
75 CacheEntry* pEntry;
76 if(m_Map.Lookup(idx,pEntry)){
77 ASSERT(pEntry->m_State==CacheEntry::cacheClean || pEntry->m_State==CacheEntry::cacheDirty);
78 pEntry->m_State=CacheEntry::cacheDirty;
79 return TRUE;
80 }
81 return FALSE;
82 }
83 BOOL Flush() {
84 POSITION p = m_Cache.GetHeadPosition();
85 while(p){
86 CacheEntry* pEntry = m_Cache.GetNext(p);
87 ASSERT(pEntry);
88 FlushEntry(pEntry);
89 }
90 return TRUE;
91 }
92 BOOL FlushEntry(CacheEntry* pEntry) {
93 if(pEntry->m_State==CacheEntry::cacheDirty){
94 BOOL rv = _WriteOut(pEntry->m_idx,pEntry->m_pData);
95 if(rv)
96 pEntry->m_State=CacheEntry::cacheClean;
97 }
98 return FALSE;
99 }
100 void PopUp(CacheEntry* pEntry) {
101 POSITION p = m_Cache.Find(pEntry);
102 ASSERT(p);
103 m_Cache.RemoveAt(p);
104 VERIFY(m_Cache.AddHead(pEntry));
105 }
106
107 virtualBOOL _ReadIn(ARGIDX idx,DATA* data) = 0;
108 virtual BOOL _WriteOut(ARGIDX idx,DATA* data) = 0;
109};
110
111};
112
113 #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 @@
1#include "../stdafx.h"
2#include "RegEx.h"
3
4 #defineisWordableChar(c) (isalnum(c) || (c)=='_')
5
6BOOL CRegEx::Compile(LPCTSTR regex,int flags)
7{
8 ASSERT(!((flags&regExtended) && (flags&regLiteral)));
9 m_Matches.RemoveAll();
10 m_Strip.RemoveAll();
11 m_Strip.SetSize(0,15);
12 m_Pattern=regex;
13 m_ParsePointer=0;
14 m_Error=0;
15 m_Sets.RemoveAll();
16 m_Flags=flags;
17 m_iFlags=0;
18 m_BOLs=m_EOLs=0;
19 m_Subexps = 0;
20 m_Categories=1;// 0 is 'everything else'
21 m_bBackRefs=FALSE;
22 memset(m_Category,0,sizeof(m_Category));
23
24 // Go ahead.
25 m_Error || m_Strip.Add(CSop(CSop::opEnd));
26 if(flags&regExtended){
27 ParseERE();
28 }else if(flags&regLiteral){
29 ParseLiteral();
30 }else{
31 ParseBRE();
32 }
33 m_Error || m_Strip.Add(CSop(CSop::opEnd));
34 Categorize();
35 m_Strip.FreeExtra();
36 FigureMust();
37 m_Pluses=CountPluses();
38 if(m_iFlags&iflagsBad){
39 m_Error || (m_Error=regeAssert);
40 // ??? point to nuls? ;-)
41 }
42 // We may wish to free some memory here if we're erroneous (ie. m_Error..)
43 m_ParseParens.RemoveAll();
44#ifdef _DEBUG
45 if(m_Error){
46 CString tmp;
47 tmp.Format("RE: ParseError: %d\n",m_Error);
48 TRACE0(tmp);
49 }
50 //DumpStrip(afxDump);
51#endif
52 return (m_bCompiled=(!m_Error));
53}
54
55BOOL CRegEx::Match(LPCTSTR src,int flags)
56{
57 if(!m_bCompiled)
58 return FALSE;
59 if(m_iFlags&iflagsBad)
60 return FALSE;
61 m_Input=src;
62 m_mFlags=flags;
63 m_mPointer=m_Input;
64 m_mBegin=m_Input;
65 m_mEnd=&m_mBegin[m_Input.GetLength()];
66 ASSERT(m_mPointer<=m_mEnd);
67 m_Matches.RemoveAll();
68 if(!m_Must.IsEmpty()){
69 if(m_Input.Find(m_Must)<0)
70 return FALSE;
71 }
72 // Go ahead..
73int stripLen = m_Strip.GetSize();
74 m_mLastPos.SetSize(0);
75 for(int tmp=0;tmp<stripLen;tmp++)
76 m_Strip[tmp].m_MatchData=0;
77LPCTSTR beginp = m_mBegin;
78LPCTSTR endp;
79 for(;;){
80 endp = MatchFast(beginp);
81 if(!endp)
82 return FALSE;
83 if((m_mFlags&regNoSubExpressions) && !m_bBackRefs)
84 break;
85 ASSERT(m_cOldP);
86 for(;;){
87 endp = MatchSlow(m_cOldP,m_mEnd,1,stripLen-1);
88 if(endp)
89 break;
90 ASSERT(m_cOldP<m_mEnd);
91 m_cOldP++;
92 }
93 if((m_mFlags&regOneMatch) && !m_bBackRefs)
94 break;
95 // Oh, his, we want the subexpression..
96 m_Matches.SetSize(m_Subexps+1);
97 LPCTSTR dp;
98 if(!m_bBackRefs && !(m_mFlags&regBackRefs)){
99 dp = MatchDissect(m_cOldP,endp,1,stripLen-1);
100 }else{
101 if(m_Pluses>0 && !m_mLastPos.GetSize())
102 m_mLastPos.SetSize(m_Pluses);
103 dp = MatchBackRef(m_cOldP,endp,1,stripLen-1,0);
104 }
105 if(dp)
106 break;
107 // Uh.. oh.. we couldn't find a subexpression-level match
108 ASSERT(m_bBackRefs);
109 ASSERT(m_Pluses==0 || m_mLastPos.GetSize());
110 for(;;){
111 if(dp || endp <= m_cOldP)
112 break;// defeat.. ?
113 endp = MatchSlow(m_cOldP,endp-1,1,stripLen-1);
114 if(!endp)
115 break;// defeat.. ?
116 // Try it on a shorter possibility..
117#ifdef _DEBUG
118 for(tmp=1;tmp<=m_Subexps;tmp++)
119 ASSERT(m_Matches[tmp].m_Begin<0 && m_Matches[tmp].m_End<0);
120#endif
121 dp = MatchBackRef(m_cOldP,endp,1,stripLen-1,0);
122 }
123 ASSERT((!dp) || dp==endp);
124 if(dp)// Found a shorter one..
125 break;
126 // Despite initial appearances, there is no match here
127 beginp = m_cOldP+1;
128 ASSERT(beginp<=m_mEnd);
129 }
130 // Fill in the detail if so requested..
131 if(!(m_mFlags&regNoSubExpressions)){
132 if(!m_Matches.GetSize())
133 m_Matches.SetSize(1);
134 m_Matches[0].m_Begin=m_cOldP-m_mBegin;
135 m_Matches[0].m_End=endp-m_mBegin;
136 }
137 m_mLastPos.RemoveAll();
138 return TRUE;
139}
140
141CString CRegEx::Replace(LPCTSTR src,LPCTSTR rep,int flags)
142{
143 // ***
144 return CString();
145}
146
147void CRegEx::ParseERE(int stop)
148{
149UCHAR c;
150BOOL first=TRUE;
151int prevF, prevB;
152 for(;;){
153 int co = m_Strip.GetSize();
154 while(m_ParsePointer < m_Pattern.GetLength() && ((c=m_Pattern[m_ParsePointer])!='|') && c!=stop)
155 ParseEREexp();
156 if(m_Strip.GetSize()==co){
157 m_Error || (m_Error=regeEmpty);
158 // ??? point to nuls?
159 }
160 if(m_ParsePointer>=m_Pattern.GetLength() || m_Pattern[m_ParsePointer]!='|')
161 break;
162 else
163 m_ParsePointer++;
164 if(first){
165 StripInsert(co,CSop(CSop::opChoice0,m_Strip.GetSize()-co+1));
166 prevF = prevB = co;
167 first=FALSE;
168 }
169 m_Error || m_Strip.Add(CSop(CSop::opOr0,m_Strip.GetSize()-prevB));
170 prevB = m_Strip.GetSize()-1;
171 m_Error || (m_Strip[prevF].m_Operand=m_Strip.GetSize()-prevF);
172 prevF = m_Strip.GetSize();
173 m_Error || m_Strip.Add(CSop(CSop::opOr1,0));// offset isn't really right.. very so..
174 }
175 if(!first){
176 m_Error || (m_Strip[prevF].m_Operand=m_Strip.GetSize()-prevF);
177 m_Error || m_Strip.Add(CSop(CSop::opChoice1,m_Strip.GetSize()-prevB));
178 }
179 ASSERT(m_ParsePointer >= m_Pattern.GetLength() || m_Pattern[m_ParsePointer]==stop);
180}
181
182void CRegEx::ParseEREexp()
183{
184 ASSERT(m_ParsePointer < m_Pattern.GetLength());
185UCHAR c = m_Pattern[m_ParsePointer++];
186int pos = m_Strip.GetSize();
187int subno;
188int count, count2;
189BOOL wascaret=FALSE;
190 switch(c){
191 case '(':
192 if(!(m_ParsePointer<m_Pattern.GetLength())){
193 TRACE0("RE: '(' at the end of the pattern\n");
194 if(!m_Error)
195 m_Error = regeParen;
196 // ??? point to nuls?
197 }
198 m_Subexps++;
199 subno=m_Subexps;
200 m_ParseParens.SetAtGrow(m_Subexps,CParenthesis(m_Strip.GetSize()));
201 m_Error || m_Strip.Add(CSop(CSop::opLeftParen,subno));
202 if(m_ParsePointer>=m_Pattern.GetLength() || m_Pattern[m_ParsePointer]!=')')
203 ParseERE(')');
204 VERIFY(m_ParseParens[m_Subexps].m_End = m_Strip.GetSize());
205 m_Error || m_Strip.Add(CSop(CSop::opRightParen,subno));
206 if(m_ParsePointer >= m_Pattern.GetLength() || m_Pattern[m_ParsePointer++]!=')'){
207 TRACE0("RE: No matching ')'\n");
208 if(!m_Error)
209 m_Error = regeParen;
210 // ??? point to nuls?
211 }
212 break;
213 case '^':
214 m_Error || m_Strip.Add(CSop(CSop::opBOL));
215 m_iFlags|=iflagsUseBOL;
216 m_BOLs++;
217 wascaret=TRUE;
218 break;
219 case '$':
220 m_Error || m_Strip.Add(CSop(CSop::opEOL));
221 m_iFlags|=iflagsUseEOL;
222 m_EOLs++;
223 break;
224 case '|':
225 TRACE0("RE: '|' outside of expression\n");
226 if(!m_Error)
227 m_Error = regeEmpty;
228 // ??? point to nuls?
229 break;
230 case '*':
231 case '+':
232 case '?':
233 TRACE0("RE: '*'/'+'/'?' with no previous expression\n");
234 if(!m_Error)
235 m_Error = regeBadRepeat;
236 // ??? point to nuls?
237 break;
238 case '.':
239 if(m_Flags&regNewLine)
240 EmitNonNewLineAny();
241 else
242 m_Error || m_Strip.Add(CSop(CSop::opAny));
243 break;
244 case '[':
245 ParseBracket();
246 break;
247 case '\\':
248 if(m_ParsePointer >= m_Pattern.GetLength()){
249 TRACE0("RE: '\\' at the end of the pattern\n");
250 if(!m_Error)
251 m_Error = regeEscape;
252 // ??? point to nuls?
253 }else{
254 c = m_Pattern[m_ParsePointer++];
255 EmitOrdinary(c);
256 }
257 break;
258 case '{':
259 if(m_ParsePointer >= m_Pattern.GetLength() || !isdigit(m_Pattern[m_ParsePointer])){
260 TRACE0("RE: '{' with no repeat count\n");
261 if(!m_Error)
262 m_Error = regeBadRepeat;
263 // ??? point to nuls?
264 }
265 // Fallthrough..
266 default:
267 EmitOrdinary(c);
268 break;
269 }
270 if(m_ParsePointer >= m_Pattern.GetLength())
271 return;
272 c = m_Pattern[m_ParsePointer];
273 // Call a '{' repetition if followed by a digit
274 if (!(c=='*' || c=='+' || c=='?' || ( c=='{' && (m_ParsePointer+1) < m_Pattern.GetLength() && isdigit(m_Pattern[m_ParsePointer+1])) ))
275 return; // No repetitor - done.
276 m_ParsePointer++;
277 if(wascaret){
278 TRACE0("RE: repetitive '^' detected\n");
279 if(!m_Error)
280 m_Error = regeBadRepeat;
281 // ??? point to nuls?
282 }
283 switch(c){
284 case '*':// Implemeted as +?
285 // + expression
286 StripInsert(pos,CSop(CSop::opPlus0,m_Strip.GetSize()-pos+1));
287 m_Error || m_Strip.Add(CSop(CSop::opPlus1,m_Strip.GetSize()-pos));
288 // ? expression
289 StripInsert(pos,CSop(CSop::opQuest0,m_Strip.GetSize()-pos+1));
290 m_Error || m_Strip.Add(CSop(CSop::opQuest1,m_Strip.GetSize()-pos));
291 break;
292 case '+':
293 // + expression
294 StripInsert(pos,CSop(CSop::opPlus0,m_Strip.GetSize()-pos+1));
295 m_Error || m_Strip.Add(CSop(CSop::opPlus1,m_Strip.GetSize()-pos));
296 break;
297 case '?':
298 // Kludge - emit y? as (y|) until subtle bug gets fixed :-)
299 StripInsert(pos,CSop(CSop::opChoice0,m_Strip.GetSize()-pos+1));
300 m_Error || m_Strip.Add(CSop(CSop::opOr0,m_Strip.GetSize()-pos));
301 m_Error || (m_Strip[pos].m_Operand=m_Strip.GetSize()-pos);
302 m_Error || m_Strip.Add(CSop(CSop::opOr1,1));
303 m_Error || m_Strip.Add(CSop(CSop::opChoice1,2));
304 break;
305 case '{':
306 count = ParseCount();
307 if(m_ParsePointer < m_Pattern.GetLength() && m_Pattern[m_ParsePointer]==','){
308 m_ParsePointer++;
309 if(isdigit(m_Pattern[m_ParsePointer])){ // HHH Personally, I doubt it is always available
310 count2=ParseCount();
311 if(!(count<=count2)){
312 TRACE0("RE: Disbalanced counts in '{}' repeater\n");
313 m_Error || (m_Error=regeBadBrace);
314 // ??? point to nuls?
315 }
316 }else // Single number with comma
317 count2=256; // Infinity
318 }else // Single number
319 count2=count;
320 EmitRepeat(pos,count,count2);
321 if(m_ParsePointer >= m_Pattern.GetLength() || m_Pattern[m_ParsePointer]!='}'){
322 // No '}'..
323 TRACE0("RE: No immediately following '}' of '{' expression\n");
324 while(m_ParsePointer < m_Pattern.GetLength() && m_Pattern[m_ParsePointer]!='}')
325 m_ParsePointer++;
326 if(m_ParsePointer >= m_Pattern.GetLength()){
327 TRACE0("RE: No closing '}' found\n");
328 m_Error || (m_Error=regeBrace);
329 }else
330 m_Error || (m_Error=regeBadBrace);
331 // ??? point to nuls?
332 }else
333 m_ParsePointer++;
334 break;
335 }
336 if(m_ParsePointer >= m_Pattern.GetLength())
337 return;
338 c = m_Pattern[m_ParsePointer];
339 if(!(c=='*' || c=='+' || c=='?' || (c=='{' && (m_ParsePointer+1)<m_Pattern.GetLength() && isdigit(m_Pattern[m_ParsePointer+1]))))
340 return;
341 TRACE0("RE: Double repeater\n");
342 m_Error || (m_Error=regeBadRepeat);
343 // ??? point to nuls?
344}
345
346void CRegEx::StripInsert(int pos,CSop& sop)
347{
348 if(m_Error)
349 return;
350int sn = m_Strip.GetSize();
351 m_Strip.InsertAt(pos,sop);
352 for(int tmp=1;tmp<m_ParseParens.GetSize();tmp++){
353 if(m_ParseParens[tmp].m_Begin>=pos)
354 m_ParseParens[tmp].m_Begin++;
355 if(m_ParseParens[tmp].m_End>=pos)
356 m_ParseParens[tmp].m_End++;
357 }
358}
359
360void CRegEx::EmitOrdinary(UCHAR c)
361{
362 if(m_Flags&regIgnoreCase && isalpha(c) && (tolower(c) !=toupper(c))){
363 // Emit both cases
364 CString savePattern = m_Pattern;
365 int savePointer = m_ParsePointer;
366 m_Pattern=c;
367 m_Pattern+=']';
368 m_ParsePointer=0;
369 ParseBracket();
370 m_Pattern=savePattern;
371 m_ParsePointer=savePointer;
372 }else{
373 m_Error || m_Strip.Add(CSop(CSop::opChar,c));
374 if(!m_Category[(BYTE)c])
375 m_Category[(BYTE)c]=m_Categories++;
376 }
377}
378
379void CRegEx::EmitNonNewLineAny()
380{
381 // Kludges're going on and on..
382CString savePattern = m_Pattern;
383int savePointer = m_ParsePointer;
384 m_Pattern="^\n]";
385 m_ParsePointer=0;
386 ParseBracket();
387 m_Pattern=savePattern;
388 m_ParsePointer=savePointer;
389}
390
391int CRegEx::ParseCount()
392{
393BOOL nonEmpty=FALSE;
394int rv = 0;
395UCHAR c;
396 while(m_ParsePointer < m_Pattern.GetLength() && isdigit(c=m_Pattern[m_ParsePointer]) && rv <=255){
397 rv = rv*10 + c-'0';
398 nonEmpty=TRUE;
399 m_ParsePointer++;
400 }
401 if(rv>255 || !nonEmpty){
402 m_Error || (m_Error=regeBadBrace);
403 // ??? point to nuls?
404 }
405 return rv;
406}
407
408void CRegEx::ParseBracket()
409{
410 // Dept. of truly sickening special case kludges
411 if((m_ParsePointer+5) < m_Pattern.GetLength() && !m_Pattern.Mid(m_ParsePointer,6).Compare("[:<]]")){
412 m_Error || m_Strip.Add(CSop(CSop::opBOW));
413 m_ParsePointer+=6;
414 return;
415 }
416 if((m_ParsePointer+5) < m_Pattern.GetLength() && !m_Pattern.Mid(m_ParsePointer,6).Compare("[:>]]")){
417 m_Error || m_Strip.Add(CSop(CSop::opEOW));
418 m_ParsePointer+=6;
419 return;
420 }
421BOOL invert=TRUE;
422 if(m_ParsePointer < m_Pattern.GetLength() && m_Pattern[m_ParsePointer]=='^')
423 m_ParsePointer++;
424 else
425 invert=FALSE;
426CSet cset;
427 if(m_ParsePointer < m_Pattern.GetLength()){
428 switch(m_Pattern[m_ParsePointer]){
429 case ']':
430 case '-':
431 cset.Add(m_Pattern[m_ParsePointer]);
432 m_ParsePointer++;
433 break;
434 }
435 }
436 while(m_ParsePointer < m_Pattern.GetLength() && m_Pattern[m_ParsePointer]!=']' && !((m_ParsePointer+1)<m_Pattern.GetLength() && !m_Pattern.Mid(m_ParsePointer,2).Compare("-]")))
437 ParseBracketTerm(cset);
438 if(m_ParsePointer < m_Pattern.GetLength() && m_Pattern[m_ParsePointer]=='-'){
439 m_ParsePointer++;
440 cset.Add('-');
441 }
442 if(m_ParsePointer < m_Pattern.GetLength() && m_Pattern[m_ParsePointer]==']')
443 m_ParsePointer++;
444 else{
445 m_Error || (m_Error=regeBracket);
446 // ??? point to nuls?
447 return;
448 }
449 if(m_Flags&regIgnoreCase){
450 for(int tmp=CSet::size-1;tmp>=0;tmp--){
451 if(cset.IsIn(tmp) && isalpha(tmp) && (toupper(tmp)!=tolower(tmp)))
452 cset.Add(isupper(tmp)?tolower(tmp):toupper(tmp));
453 }
454 /*
455 if(!cset->m_Multis.IsEmpty())
456 cset.CollatingCase();
457 */
458 }
459 if(invert){
460 for(int tmp=CSet::size-1;tmp>=0;tmp--)
461 if(cset.IsIn(tmp))
462 cset.Sub(tmp);
463 else
464 cset.Add(tmp);
465 if(m_Flags&regNewLine)
466 cset.Sub('\n');
467 /*
468 if(!cset.m_Multis.IsEmpty())
469 cset.CollatingInvert();
470 */
471 }
472UCHAR c = cset.GetOnly();
473 if(c){
474 EmitOrdinary(c);
475 }else
476 m_Error || m_Strip.Add(CSop(CSop::opAnyOf,StoreSet(cset)));
477}
478
479void CRegEx::CSet::Add(UCHAR c)
480{
481 m_Set[(BYTE)c]=TRUE;
482 m_Hash+=c;
483}
484
485BOOL CRegEx::CSet::IsIn(UCHAR c)
486{
487 return m_Set[(BYTE)c];
488}
489
490void CRegEx::CSet::Sub(UCHAR c)
491{
492 m_Set[(BYTE)c]=FALSE;
493 m_Hash-=c;
494}
495
496UCHAR CRegEx::CSet::GetOnly()
497{
498int rv = 0;
499UCHAR only = 0;
500 for(int tmp=0;tmp<size;tmp++){
501 rv+=m_Set[tmp]?(only=tmp,1):0;
502 }
503 return (rv==1)?only:0;
504}
505
506int CRegEx::StoreSet(CSet& cset)
507{
508 for(int tmp=0;tmp<m_Sets.GetSize();tmp++)
509 if(m_Sets[tmp]==cset)
510 return tmp;
511 return m_Sets.Add(cset);
512}
513
514void CRegEx::ParseBracketTerm(CSet& cset)
515{
516UCHAR c;
517 switch((m_ParsePointer<m_Pattern.GetLength())?m_Pattern[m_ParsePointer]:0){
518 case '[':
519 c = ((m_ParsePointer+1)<m_Pattern.GetLength())?m_Pattern[m_ParsePointer+1]:0;
520 break;
521 case '-':
522 m_Error || (m_Error=regeRange);
523 // ??? point to nuls?
524 return;
525 default:
526 c = 0;
527 break;
528 }
529 switch(c){
530 case ':':// Character class
531 m_ParsePointer+=2;
532 if(m_ParsePointer>=m_Pattern.GetLength()){
533 m_Error || (m_Error=regeBracket);
534 // ??? point to nuls?
535 }
536 c = m_Pattern[m_ParsePointer];
537 if(c== '-' || c==']'){
538 m_Error || (m_Error=regeCType);
539 // ??? point to nuls?
540 }
541 ParseBracketCClass(cset);
542 if(m_ParsePointer>=m_Pattern.GetLength()){
543 m_Error || (m_Error=regeBracket);
544 // ??? point to nuls?
545 }
546 if((m_ParsePointer+1)>=m_Pattern.GetLength() || (m_Pattern.Mid(m_ParsePointer,2).Compare(":]"))){
547 m_Error || (m_Error=regeCType);
548 // ??? point to nuls?
549 }else
550 m_ParsePointer+=2;
551 break;
552 case '=':// Equivalence class
553 m_ParsePointer+=2;
554 if(m_ParsePointer >= m_Pattern.GetLength()){
555 m_Error || (m_Error=regeBracket);
556 // ??? point to nuls?
557 }
558 c = m_Pattern[m_ParsePointer];
559 if(c== '-' || c==']'){
560 m_Error || (m_Error=regeCollate);
561 // ??? point to nuls?
562 }
563 ParseBracketEClass(cset);
564 if((m_ParsePointer+1)>=m_Pattern.GetLength() || (m_Pattern.Mid(m_ParsePointer,2).Compare("=]"))){
565 m_Error || (m_Error=regeCollate);
566 // ??? point to nuls?
567 }else
568 m_ParsePointer+=2;
569 break;
570 default:// Symbol, character or range
571 {
572 UCHAR start, finish;
573 start = ParseBracketSymbol();
574 if((m_ParsePointer<m_Pattern.GetLength() && m_Pattern[m_ParsePointer]=='-') /*&& (m_ParsePointer+1)<m_Pattern.GetLength() && m_Pattern[m_ParsePointer+1]==']'*/){
575 // I believe the expression above is seetwo..
576 // range.
577 m_ParsePointer++;
578 if(m_ParsePointer<m_Pattern.GetLength() && m_Pattern[m_ParsePointer]=='-'){
579 m_ParsePointer++;
580 finish='-';
581 }else
582 finish=ParseBracketSymbol();
583 }else
584 finish=start;
585 if(((BYTE)start)>((BYTE)finish)){
586 m_Error || (m_Error=regeRange);
587 // ??? point to nuls?
588 }
589 for(int tmp=start;tmp<=(BYTE)finish;tmp++)
590 cset.Add(tmp);
591 }
592 break;
593 }
594}
595
596void CRegEx::ParseBracketCClass(CSet& cset)
597{
598 static struct{
599 char *className;
600 char *classChars;
601 }cc[] = {
602 {"alnum","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"},
603 {"alpha","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"},
604 {"blank"," \t"},
605 {"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"},
606 {"digit","0123456789"},
607 {"graph","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"},
608 {"lower","abcdefghijklmnopqrstuvwxyz"},
609 {"print","ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ "},
610 {"punct","!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"},
611 {"space","\t\n\v\f\r "},
612 {"upper","ABCDEFGHIJKLMNOPQRSTUVWXYZ"},
613 {"xdigit","0123456789ABCDEFabcdef"}
614};
615CString cclass;
616UCHAR c;
617 while(m_ParsePointer < m_Pattern.GetLength() && isalpha(c=m_Pattern[m_ParsePointer])){
618 cclass+=c;
619 m_ParsePointer++;
620 }
621char *classChars = NULL;
622 for(int tmp=0;tmp<(sizeof(cc)/sizeof(cc[0]));tmp++){
623 if(!cclass.CompareNoCase(cc[tmp].className)){
624 classChars=cc[tmp].classChars;
625 break;
626 }
627 }
628 if(!classChars){
629 m_Error || (m_Error=regeCType);
630 // ??? point to nuls?
631 return;
632 }
633 while(*classChars)
634 cset.Add(*(classChars++));
635 // --- multis
636}
637
638void CRegEx::ParseBracketEClass(CSet& cset)
639{
640 cset.Add(ParseBracketCollatingElement('='));;
641}
642
643UCHAR CRegEx::ParseBracketCollatingElement(UCHAR term)
644{
645 static struct{
646 char *entityName;
647 char entity;
648 }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'} };
649CString seeTwo;
650 seeTwo=term;
651 seeTwo+=']';
652CString entityName;
653 while(m_ParsePointer<m_Pattern.GetLength() && !((m_ParsePointer+1)<m_Pattern.GetLength() && !m_Pattern.Mid(m_ParsePointer,2).Compare(seeTwo)))
654 entityName+=m_Pattern[m_ParsePointer++];
655 if(m_ParsePointer>=m_Pattern.GetLength()){
656 m_Error || (m_Error=regeBracket);
657 // ??? point to nuls?
658 return 0;
659 }
660 for(int tmp=0;tmp<(sizeof(cc)/sizeof(cc[0]));tmp++)
661 if(!entityName.CompareNoCase(cc[tmp].entityName))
662 return cc[tmp].entity;
663 if(entityName.GetLength()==1)
664 return entityName[0];
665 m_Error || (m_Error=regeCollate);
666 // ??? point to nuls?
667 return 0;
668}
669
670UCHAR CRegEx::ParseBracketSymbol()
671{
672 if(m_ParsePointer>=m_Pattern.GetLength()){
673 m_Error || (m_Error=regeBracket);
674 // ??? point to nuls?
675 }
676 if((m_ParsePointer+1)<m_Pattern.GetLength() && !m_Pattern.Mid(m_ParsePointer,2).Compare("[."))
677 m_ParsePointer+=2;
678 else
679 return m_Pattern[m_ParsePointer++];
680 // Collating symbol
681UCHAR rv = ParseBracketCollatingElement('.');
682 if((m_ParsePointer+1)<m_Pattern.GetLength() && !m_Pattern.Mid(m_ParsePointer,2).Compare("[."))
683 m_ParsePointer+=2;
684 else{
685 m_Error || (m_Error=regeCollate);
686 // ??? point to nuls?
687 }
688 return rv;
689}
690
691void CRegEx::EmitRepeat(int pos,int from,int to)
692{
693 if(m_Error)
694 return;
695 ASSERT(from<=to);
696int finish = m_Strip.GetSize();
697int copy;
698 #defineN 2
699#define INF 3
700#define REP(f,t) ((f)*8+(t))
701#define MAP(n) (((n)<=1)?(n):((n)==256)?INF:N)
702 switch(REP(MAP(from),MAP(to))){
703 case REP(0,0):// must be user doing ths??
704 m_Strip.SetSize(pos);
705 break;
706 case REP(0,1):// as in '?'
707 case REP(0,N):// as in '{1,n}?'
708 case REP(0,INF):// as in '{1,}?'
709 // Kludge - emit y? as (y|) until something gets fixed..
710 StripInsert(pos,CSop(CSop::opChoice0,pos));
711 EmitRepeat(pos+1,1,to);
712 m_Error || m_Strip.Add(CSop(CSop::opOr0,m_Strip.GetSize()-pos));
713 m_Error || (m_Strip[pos].m_Operand=m_Strip.GetSize()-pos);
714 m_Error || m_Strip.Add(CSop(CSop::opOr1,1));
715 m_Error || m_Strip.Add(CSop(CSop::opChoice1,2));
716 break;
717 case REP(1,1):
718 break;
719 case REP(1,N):// as in 'x?x{1,n-1}'
720 // Kludge again..
721 StripInsert(pos,CSop(CSop::opChoice0,pos));
722 m_Error || m_Strip.Add(CSop(CSop::opOr0,m_Strip.GetSize()-pos));
723 m_Error || (m_Strip[pos].m_Operand=m_Strip.GetSize()-pos);
724 m_Error || m_Strip.Add(CSop(CSop::opOr1,1));
725 m_Error || m_Strip.Add(CSop(CSop::opChoice1,2));
726 copy = StripDuplicate(pos+1,finish+1);
727 ASSERT(copy==(finish+4));
728 EmitRepeat(copy,1,to-1);
729 break;
730 case REP(1,INF): // as in '+'
731 StripInsert(pos,CSop(CSop::opPlus0,pos));
732 m_Error || m_Strip.Add(CSop(CSop::opPlus1,m_Strip.GetSize()-pos));
733 break;
734 case REP(N,N):// as in 'xx{from-1,to-1}'
735 copy = StripDuplicate(pos,finish);
736 EmitRepeat(copy,from-1,to-1);
737 break;
738 case REP(N,INF): // as in 'xx{n-1,}'
739 copy = StripDuplicate(pos,finish);
740 EmitRepeat(copy,from-1,to);
741 break;
742#ifndef NDEBUG
743 default:
744 ASSERT(FALSE);
745 break;
746#endif
747 }
748#undef MAP
749#undef REP
750#undef INF
751#undef N
752}
753
754int CRegEx::StripDuplicate(int from,int to)
755{
756int rv = m_Strip.GetSize();
757 ASSERT(from<=to);
758 if(from==to)
759 return rv;
760 // Maybe should be optimized for copying the whole thing.
761 for(int tmp=from;tmp<to;tmp++)
762 m_Strip.Add(m_Strip[tmp]);
763 return rv;
764}
765
766void CRegEx::Categorize()
767{
768 if(m_Error)
769 return;
770 for(int tmp=0;tmp<(sizeof(m_Category)/sizeof(m_Category[0]));tmp++)
771 if((!m_Category[tmp]) && IsInSets(tmp)){
772 int cat = m_Categories++;
773 m_Category[tmp]=cat;
774 for(int c=tmp+1;c<(sizeof(m_Category)/sizeof(m_Category[0]));c++)
775 if((!m_Category[c]) && IsInSameSets(tmp,c))
776 m_Category[c]=cat;
777 }
778}
779
780BOOL CRegEx::IsInSets(UCHAR c)
781{
782 for(int tmp=0;tmp<m_Sets.GetSize();tmp++)
783 if(m_Sets[tmp].IsIn(c))
784 return TRUE;
785 return FALSE;
786}
787
788BOOL CRegEx::IsInSameSets(UCHAR c1,UCHAR c2)
789{
790 for(int tmp=0;tmp<m_Sets.GetSize();tmp++)
791 if(m_Sets[tmp].IsIn(c1)!=m_Sets[tmp].IsIn(c2))
792 return FALSE;
793 return TRUE;
794}
795
796void CRegEx::FigureMust()
797{
798 if(m_Error)
799 return;
800 m_Must.Empty();
801int stripLen = m_Strip.GetSize();
802int seqStart, seqLength = 0;
803int mustStart, mustLength = 0;
804 for(int tmp=1;tmp<stripLen;tmp++){
805 switch(m_Strip[tmp].m_Operator){
806 case CSop::opChar:
807 if(!seqLength)
808 seqStart=tmp;
809 seqLength++;
810 break;
811 case CSop::opPlus0:
812 case CSop::opLeftParen:
813 case CSop::opRightParen:
814 break;// Break, since they don't break the sequence
815 case CSop::opQuest0:
816 case CSop::opChoice0:
817 // These ones we skip.
818 do{
819 tmp+=m_Strip[tmp].m_Operand;
820 // I still think it could be ASSERTed..
821 if(m_Strip[tmp].m_Operator!=CSop::opQuest1 && m_Strip[tmp].m_Operator!=CSop::opChoice1 && m_Strip[tmp].m_Operator!=CSop::opOr1){
822 m_iFlags|=iflagsBad;
823 return;
824 }
825 }while(m_Strip[tmp].m_Operator!=CSop::opQuest1 && m_Strip[tmp].m_Operator!=CSop::opChoice1);
826 // Fallthrough..
827 default:
828 // End of sequence
829 if(seqLength>mustLength){
830 mustStart=seqStart;
831 mustLength=seqLength;
832 }
833 seqLength=0;
834 break;
835 }
836 }// Hmm.. originally it's meant to be do while not opEnd..
837 if(!mustLength)
838 return;
839 // Turn into string, but, wait, personally I'm sure it could be put in the main loop.. or maybe not..
840 for(tmp=0;tmp<seqLength;tmp++){
841 while(m_Strip[seqStart+tmp].m_Operator!=CSop::opChar)
842 ASSERT(tmp<seqLength);
843 m_Must+=m_Strip[tmp].m_Operand;
844 }
845}
846
847int CRegEx::CountPluses()
848{
849 if(m_Error)
850 return 0;
851int stripLen = m_Strip.GetSize();
852int rv = 0;
853int nest = 0;
854 for(int tmp=0;tmp<stripLen;tmp++){
855 switch(m_Strip[tmp].m_Operator){
856 case CSop::opPlus0:
857 nest++;
858 break;
859 case CSop::opPlus1:
860 if(nest>rv)
861 rv = nest;
862 nest--;
863 break;
864 }
865 }// Again, originally we were supposed to scan till opEnd..
866 if(nest)
867 m_iFlags|=iflagsBad;// Could this be an ASSERTion?
868 return rv;
869}
870
871void CRegEx::ParseLiteral()
872{
873 if(!m_Pattern.GetLength()){
874 m_Error || (m_Error=regeEmpty);
875 // ??? point to nuls?
876 }
877 while(m_ParsePointer < m_Pattern.GetLength())
878 EmitOrdinary(m_Pattern[m_ParsePointer++]);
879}
880
881void CRegEx::ParseBRE(int stopa,int stopb)
882{
883int start = m_Strip.GetSize();
884BOOL first=TRUE;
885BOOL wasDollar=FALSE;
886 if(m_ParsePointer<m_Pattern.GetLength() && m_Pattern[m_ParsePointer]=='^'){
887 m_ParsePointer++;
888 m_Error || m_Strip.Add(CSop(CSop::opBOL,0));
889 m_iFlags|=iflagsUseBOL;
890 m_BOLs++;
891 }
892CString stopstr;
893 if(stopa){
894 stopstr+=stopa;
895 if(stopb)
896 stopstr+=stopb;
897 }
898 while(m_ParsePointer < m_Pattern.GetLength() && !((m_ParsePointer+1)<m_Pattern.GetLength() && !m_Pattern.Mid(m_ParsePointer,2).Compare(stopstr))){
899 wasDollar = ParseBREexp(first);
900 first=FALSE;
901 }
902 if(wasDollar){// Trailing anchor that was..
903 m_Strip.SetSize(m_Strip.GetSize()-1);
904 m_Error || m_Strip.Add(CSop(CSop::opEOL,0));
905 m_iFlags|=iflagsUseEOL;
906 m_EOLs++;
907 }
908 if(m_Strip.GetSize()==start){
909 m_Error || (m_Error=regeEmpty);
910 // ??? point to nuls?
911 }
912}
913
914BOOL CRegEx::ParseBREexp(BOOL ordinaryStar)
915{
916int subno;
917int pos = m_Strip.GetSize();
918 ASSERT(m_ParsePointer<m_Pattern.GetLength());
919int c = m_Pattern[m_ParsePointer++];
920 if(c=='\\'){
921 if(m_ParsePointer>=m_Pattern.GetLength()){
922 m_Error || (m_Error=regeEscape);
923 // ??? point to nuls
924 }else
925 c = 0x100|m_Pattern[m_ParsePointer++];
926 }
927 switch(c){
928 case '.':
929 if(m_Flags&regNewLine)
930 EmitNonNewLineAny();
931 else
932 m_Error || m_Strip.Add(CSop(CSop::opAny,0));
933 break;
934 case '[':
935 ParseBracket();
936 break;
937 case 0x100|'{':
938 m_Error || (m_Error=regeBadRepeat);
939 // ??? point to nuls?
940 break;
941 case 0x100|'(':
942 m_Subexps++;
943 subno=m_Subexps;
944 m_ParseParens.SetAtGrow(m_Subexps,CParenthesis(m_Strip.GetSize()));
945 m_Error || m_Strip.Add(CSop(CSop::opLeftParen,subno));
946 if(m_ParsePointer<m_Pattern.GetLength() && !((m_ParsePointer+1)<m_Pattern.GetLength() && !m_Pattern.Mid(m_ParsePointer,2).Compare("\\)")))
947 ParseBRE('\\',')');
948 VERIFY(m_ParseParens[m_Subexps].m_End = m_Strip.GetSize());
949 m_Error || m_Strip.Add(CSop(CSop::opRightParen,subno));
950 if((m_ParsePointer+1) < m_Pattern.GetLength() && !m_Pattern.Mid(m_ParsePointer,2).Compare("\\)"))
951 m_ParsePointer+=2;
952 else{
953 m_Error || (m_Error=regeParen);
954 // ??? point to nuls?
955 }
956 break;
957 case 0x100|')':
958 case 0x100|'}':
959 // Can this possibly happen?!
960 m_Error || (m_Error=regeParen);
961 // ??? point to nuls?
962 break;
963 case 0x100|'1':
964 case 0x100|'2':
965 case 0x100|'3':
966 case 0x100|'4':
967 case 0x100|'5':
968 case 0x100|'6':
969 case 0x100|'7':
970 case 0x100|'8':
971 case 0x100|'9':
972 {
973 int i = (c&0xFF)-'0';
974 if(i < m_ParseParens.GetSize() && m_ParseParens[i].m_End){
975 m_Error || m_Strip.Add(CSop(CSop::opBackRef0,i));
976 ASSERT(m_ParseParens[i].m_Begin);
977 ASSERT(m_Strip[m_ParseParens[i].m_Begin].m_Operator==CSop::opLeftParen);
978 ASSERT(m_Strip[m_ParseParens[i].m_End].m_Operator==CSop::opRightParen);
979 StripDuplicate(m_ParseParens[i].m_Begin+1,m_ParseParens[i].m_End);
980 m_Error || m_Strip.Add(CSop(CSop::opBackRef1,i));
981 }else{
982 m_Error || (m_Error=regeSubReg);
983 // ??? point to nuls?
984 }
985 m_bBackRefs=TRUE;
986 }
987 break;
988 case '*':
989 if(!ordinaryStar){
990 m_Error || (m_Error=regeBadRepeat);
991 // ??? point to nuls?
992 }
993 // Fallthrough..
994 default:
995 EmitOrdinary(c&0xFF);
996 break;
997 }
998 if(m_ParsePointer<m_Pattern.GetLength() && m_Pattern[m_ParsePointer]=='*'){
999 m_ParsePointer++;
1000 // as in '+?'
1001 StripInsert(pos,CSop(CSop::opPlus0,m_Strip.GetSize()-pos+1));
1002 m_Error || m_Strip.Add(CSop(CSop::opPlus1,m_Strip.GetSize()-pos));
1003 StripInsert(pos,CSop(CSop::opQuest0,m_Strip.GetSize()-pos+1));
1004 m_Error || m_Strip.Add(CSop(CSop::opQuest1,m_Strip.GetSize()-pos));
1005 }else if ((m_ParsePointer+1)<m_Pattern.GetLength() && !m_Pattern.Mid(m_ParsePointer,2).Compare("\\{")){
1006 m_ParsePointer+=2;
1007 int count = ParseCount();
1008 int count2;
1009 if(m_ParsePointer<m_Pattern.GetLength() && m_Pattern[m_ParsePointer]==','){
1010 m_ParsePointer++;
1011 if(m_ParsePointer<m_Pattern.GetLength() && isdigit(m_Pattern[m_ParsePointer])){
1012 count2=ParseCount();
1013 if(count>count2){
1014 m_Error || (m_Error=regeBadBrace);
1015 // ??? poin to nuls?
1016 }
1017 }else // Single number with comma
1018 count2=256;
1019 }else // Single number
1020 count2=count;
1021 EmitRepeat(pos,count,count2);
1022 if((m_ParsePointer+1)>=m_Pattern.GetLength() || m_Pattern.Mid(m_ParsePointer,2).Compare("\\}")){
1023 while(m_ParsePointer<m_Pattern.GetLength() && !((m_ParsePointer+1)<m_Pattern.GetLength() && !m_Pattern.Mid(m_ParsePointer,2).Compare("\\}")))
1024 m_ParsePointer++;
1025 if(m_ParsePointer>=m_Pattern.GetLength()){
1026 m_Error || (m_Error=regeBrace);
1027 // ??? point to nuls?
1028 }
1029 m_Error || (m_Error=regeBadBrace);
1030 }else
1031 m_ParsePointer+=2;
1032 }else if(c=='$')
1033 return TRUE;
1034 return FALSE;
1035}
1036
1037CRegEx::CRegEx()
1038{
1039 m_bCompiled=FALSE;
1040}
1041
1042LPCTSTR CRegEx::MatchFast(LPCTSTR begin)
1043{
1044 MatchStatesClear(CSop::stCurrent);
1045 m_Strip[1].m_MatchData|=CSop::stCurrent;
1046int stripLen = m_Strip.GetSize();
1047 MatchStep(1,stripLen-1,CSop::stCurrent,charNothing,CSop::stCurrent);
1048 MatchStatesCopy(CSop::stFresh,CSop::stCurrent);
1049LPCTSTR coldp = NULL;
1050LPCTSTR p = begin;
1051int c = (begin==m_mBegin)?charOut:((int)(BYTE)m_mPointer[-1]);
1052 for(;;){
1053 // next character..
1054 int lastc = c;
1055 c = (p==m_mEnd)?charOut:(int)*(BYTE*)p;
1056 if(MatchStatesEqual(CSop::stCurrent,CSop::stFresh))
1057 coldp=p;
1058 // Is there an EOL and/or BOL between lastc and c? - they ask..
1059 intflagc=0;
1060 inti = 0;
1061 if((lastc=='\n' && m_Flags&regNewLine) || (lastc==charOut && !(m_mFlags&regNotBOL))){
1062 flagc=charBOL;
1063 i=m_BOLs;
1064 }
1065 if((c=='\n' && m_Flags&regNewLine) || (c==charOut && !(m_mFlags&regNotEOL))){
1066 flagc=(flagc==charBOL)?charBOLEOL:charEOL;
1067 i+=m_EOLs;
1068 }
1069 if(i){
1070 for(;i>0;i--)
1071 MatchStep(1,stripLen-1,CSop::stCurrent,flagc,CSop::stCurrent);
1072 }
1073 // What about a word boundary? - they wonder..
1074 if((flagc==charBOL || (lastc!=charOut && !isWordableChar(c))) && (c!=charOut && isWordableChar(c)))
1075 flagc = charBOW;
1076 if((lastc!=charOut && isWordableChar(lastc)) && (flagc==charEOL || (c!=charOut && !isWordableChar(c))))
1077 flagc = charEOW;
1078 if(flagc==charBOW || flagc==charEOW){
1079 MatchStep(1,stripLen-1,CSop::stCurrent,flagc,CSop::stCurrent);
1080 }
1081 // Are we done? Now WE wonder..
1082 if((m_Strip[stripLen-1].m_MatchData&CSop::stCurrent) || p==m_mEnd)
1083 break;// They insist I need to note break out.. Okay, I do..
1084 // Nope, we're not done. We have to face this character..
1085 MatchStatesCopy(CSop::stTemp,CSop::stCurrent);
1086 MatchStatesCopy(CSop::stCurrent,CSop::stFresh);
1087 ASSERT(c!=charOut);
1088 MatchStep(1,stripLen-1,CSop::stTemp,c,CSop::stCurrent);
1089 p++;
1090 }
1091 ASSERT(coldp);
1092 m_cOldP=coldp;// *** I believe this variable can be changed 'in-place'
1093 if(m_Strip[stripLen-1].m_MatchData&CSop::stCurrent)
1094 return &p[1];
1095 else
1096 return NULL;
1097}
1098
1099void CRegEx::MatchStatesClear(BYTE mask)
1100{
1101int stripLen = m_Strip.GetSize();
1102 for(int tmp=0;tmp<stripLen;tmp++)
1103 m_Strip[tmp].m_MatchData&=~mask;
1104}
1105
1106void CRegEx::MatchStep(int from,int to,BYTE maskBefore,int charCode,BYTE maskAfter)
1107{
1108BOOL i;
1109int look;
1110int here = from;
1111 for(int pc=from;pc!=to;pc++,here++){
1112 CSop s=m_Strip[pc];
1113 switch(s.m_Operator){
1114 case CSop::opEnd:
1115 ASSERT(pc==(to-1));
1116 break;
1117 case CSop::opChar:
1118 // Only characters can match..
1119 ASSERT((charCode<charOut) || charCode!=s.m_Operand);
1120 if(charCode==s.m_Operand)
1121 m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskBefore)?maskAfter:0;
1122 break;
1123 case CSop::opBOL:
1124 if(charCode==charBOL || charCode==charBOLEOL)
1125 m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskBefore)?maskAfter:0;
1126 break;
1127 case CSop::opEOL:
1128 if(charCode==charEOL || charCode==charBOLEOL)
1129 m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskBefore)?maskAfter:0;
1130 break;
1131 case CSop::opBOW:
1132 if(charCode==charBOW)
1133 m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskBefore)?maskAfter:0;
1134 break;
1135 case CSop::opEOW:
1136 if(charCode==charEOW)
1137 m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskBefore)?maskAfter:0;
1138 break;
1139 case CSop::opAny:
1140 if(charCode<charOut)
1141 m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskBefore)?maskAfter:0;
1142 break;
1143 case CSop::opAnyOf:
1144 if(charCode<charOut && m_Sets[s.m_Operand].m_Set[charCode])
1145 m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskBefore)?maskAfter:0;
1146 break;
1147 case CSop::opBackRef0:// Ignored here..
1148 case CSop::opBackRef1:
1149 m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0;
1150 break;
1151 case CSop::opPlus0:
1152 // Forward, this is just an empty, comment says..
1153 m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0;
1154 break;
1155 case CSop::opPlus1:
1156 m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0;
1157 i =(m_Strip[here-s.m_Operand].m_MatchData&maskAfter)!=0;
1158 m_Strip[here-s.m_Operand].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0;
1159 if(!i && (m_Strip[here-s.m_Operand].m_MatchData&maskAfter)){
1160 // oho, must reconsider loop body, comment says.. what's so 'oho' about it?
1161 pc-=s.m_Operand+1;
1162 here=pc;
1163 }
1164 break;
1165 case CSop::opQuest0:
1166 // two branches, both forward..
1167 m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0;
1168 m_Strip[here+s.m_Operand].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0;
1169 break;
1170 case CSop::opQuest1:
1171 // just an empty.. aren't we tired of justanempties?
1172 m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0;
1173 break;
1174 case CSop::opLeftParen: // they say it's not significan there..
1175 case CSop::opRightParen:
1176 m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0;
1177 break;
1178 case CSop::opChoice0:// mark the first two branches..
1179 m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0;
1180 ASSERT(m_Strip[pc+s.m_Operand].m_Operator==CSop::opOr1);
1181 m_Strip[here+s.m_Operand].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0;
1182 break;
1183 case CSop::opOr0:// done a branch, find the end of choice..
1184 if(m_Strip[here].m_MatchData&maskAfter){
1185 for(look=1;(s=m_Strip[pc+look]).m_Operator!=CSop::opChoice1;look+=s.m_Operand)
1186 ASSERT(s.m_Operator==CSop::opOr1);
1187 m_Strip[here+look].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0;
1188 }
1189 break;
1190 case CSop::opOr1: // Propagate Choice's marking..
1191 m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0;
1192 if(m_Strip[pc+s.m_Operand].m_Operator!=CSop::opChoice1){
1193 ASSERT(m_Strip[pc+s.m_Operand].m_Operator==CSop::opOr1);
1194 m_Strip[here+s.m_Operand].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0;
1195 }
1196 break;
1197 case CSop::opChoice1: // Just empty.. :-)..
1198 m_Strip[here+1].m_MatchData|=(m_Strip[here].m_MatchData&maskAfter)?maskAfter:0;
1199 break;
1200#ifdef _DEBUG
1201 default:
1202 ASSERT(FALSE);
1203 break;
1204#endif
1205 }
1206 }
1207}
1208
1209void CRegEx::MatchStatesCopy(BYTE dst,BYTE src)
1210{
1211int stripLen = m_Strip.GetSize();
1212 for(int tmp=0;tmp<stripLen;tmp++){
1213 // I believe this can be optimized, easily..
1214 m_Strip[tmp].m_MatchData&=~dst;
1215 m_Strip[tmp].m_MatchData|=(m_Strip[tmp].m_MatchData&src)?dst:0;
1216 }
1217}
1218
1219BOOL CRegEx::MatchStatesEqual(BYTE m1,BYTE m2)
1220{
1221int stripLen = m_Strip.GetSize();
1222 for(int tmp=0;tmp<stripLen;tmp++){
1223 BYTE mm = m_Strip[tmp].m_MatchData;
1224 if(((mm&m1) && (mm&m2)) || !(mm&(m1|m2)))
1225 continue;
1226 return FALSE;
1227 }
1228 return TRUE;
1229}
1230
1231LPCTSTR CRegEx::MatchSlow(LPCTSTR begin,LPCTSTR end,int from,int to)
1232{
1233 MatchStatesClear(CSop::stCurrent);
1234 m_Strip[from].m_MatchData|=CSop::stCurrent;
1235 MatchStep(from,to,CSop::stCurrent,charNothing,CSop::stCurrent);
1236LPCTSTR mp = NULL;
1237int c = (m_mBegin==m_mPointer)?charOut:(int)(BYTE)begin[-1];
1238LPCTSTR p = begin;
1239 for(;;){
1240 // next character..
1241 int lastc = c;
1242 c = (p==m_mEnd)?charOut:(int)*(BYTE*)p;
1243 // Now we start to wonder if there is an EOL and/or BOL between lastc and c
1244 int flagc = 0;
1245 int i = 0;
1246 if((lastc=='\n' && m_Flags&regNewLine) || (lastc==charOut && !(m_mFlags&regNotBOL))){
1247 flagc = charBOL;
1248 i = m_BOLs;
1249 }
1250 if((c=='\n' && m_Flags&regNewLine) || (c==charOut && !(m_mFlags&regNotEOL))){
1251 flagc = (flagc==charBOL)?charBOLEOL:charEOL;
1252 i+=m_EOLs;
1253 }
1254 if(i){
1255 for(;i>0;i--)
1256 MatchStep(from,to,CSop::stCurrent,flagc,CSop::stCurrent);
1257 }
1258 // Now we wonder about word boundaries..
1259 if((flagc==charBOL || (lastc!=charOut && !isWordableChar(lastc))) && (c!=charOut && isWordableChar(c)))
1260 flagc=charBOW;
1261 if((lastc!=charOut && isWordableChar(lastc)) && (flagc==charEOL || (c!=charOut && !isWordableChar(c))))
1262 flagc=charEOW;
1263 if(flagc==charBOW || flagc==charEOW){
1264 MatchStep(from,to,CSop::stCurrent,flagc,CSop::stCurrent);
1265 }
1266 // Are we done we all wonder??
1267 if(m_Strip[to].m_MatchData&CSop::stCurrent)
1268 mp=p;
1269 if(MatchStatesEqual(CSop::stCurrent,CSop::stEmpty) || p==end)
1270 break;// Again, we're obliged to note break out. We do.
1271 // Sucks.. we have to face this character..
1272 MatchStatesCopy(CSop::stTemp,CSop::stCurrent);
1273 MatchStatesCopy(CSop::stCurrent,CSop::stEmpty);
1274 ASSERT(c!=charOut);
1275 MatchStep(from,to,CSop::stTemp,c,CSop::stCurrent);
1276 MatchStep(from,to,CSop::stCurrent,charNothing,CSop::stCurrent);
1277 p++;
1278 }
1279 return mp;
1280}
1281
1282LPCTSTR CRegEx::MatchDissect(LPCTSTR begin,LPCTSTR end,int from,int to)
1283{
1284LPCTSTR sp = begin, dp;
1285LPCTSTR stp, rest, tail, ssp, oldssp, sep;
1286int ssub, esub;
1287int es;
1288int i;
1289 for(int ss=from;ss<to;ss = es){
1290 // Identify end of SubRE
1291 es = ss;
1292 switch(m_Strip[es].m_Operator){
1293 case CSop::opPlus0:
1294 case CSop::opQuest0:
1295 es+=m_Strip[es].m_Operand;
1296 break;
1297 case CSop::opChoice0:
1298 while(m_Strip[es].m_Operator!=CSop::opChoice1)
1299 es+=m_Strip[es].m_Operand;
1300 break;
1301 }
1302 es++;
1303 // Figure out what it matched
1304 switch(m_Strip[ss].m_Operator){
1305 case CSop::opEnd:
1306 ASSERT(FALSE);
1307 break;
1308 case CSop::opChar:
1309 sp++;
1310 break;
1311 case CSop::opBOL:
1312 case CSop::opEOL:
1313 case CSop::opBOW:
1314 case CSop::opEOW:
1315 break;
1316 case CSop::opAny:
1317 case CSop::opAnyOf:
1318 sp++;
1319 break;
1320 case CSop::opBackRef0:
1321 case CSop::opBackRef1:
1322 ASSERT(FALSE);
1323 break;
1324 // Cases where lenght of match is hard to find..
1325 case CSop::opQuest0:
1326 stp=end;
1327 for(;;){
1328 // How long could this one be??
1329 rest = MatchSlow(sp,stp,ss,es);
1330 ASSERT(rest);// It did match.. It should've..
1331 // Could the rest match the rest? (good question)
1332 tail = MatchSlow(rest,end,es,to);
1333 if(tail==end)
1334 break;// yup.
1335 // nope, try a shorter match for this one..
1336 stp=rest-1;
1337 ASSERT(stp>=sp);// It did work.. It should've..
1338 }
1339 ssub=ss+1;
1340 esub=es-1;
1341 // Did innards match?
1342 if(MatchSlow(sp,rest,ssub,esub)){
1343 dp = MatchDissect(sp,rest,ssub,esub);
1344 ASSERT(dp==rest);
1345 }else// nope..
1346 ASSERT(sp==rest);
1347 sp = rest;
1348 break;
1349 case CSop::opPlus0:
1350 stp=end;
1351 for(;;){
1352 // How long could this one be??
1353 rest = MatchSlow(sp,stp,ss,es);
1354 ASSERT(rest);// It did.. It should've..
1355 // Could the rest match the rest?
1356 tail = MatchSlow(rest,end,es,to);
1357 if(tail==end)
1358 break;// yup.
1359 // nope..
1360 stp=rest-1;
1361 ASSERT(stp>=sp);// It should've worked, we believe..
1362 }
1363 ssub=ss+1;
1364 esub=es-1;
1365 ssp=sp;
1366 oldssp=ssp;
1367 for(;;){// Find last match of innards..
1368 sep = MatchSlow(ssp,rest,ssub,esub);
1369 if((!sep) || sep==ssp)
1370 break; // Failed or matched nothin'
1371 oldssp=ssp;
1372 ssp=sep;
1373 }
1374 if(!sep){
1375 // Last successfull..
1376 sep=ssp;
1377 ssp=oldssp;
1378 }
1379 ASSERT(sep=rest);// Must exhaust substring they say..
1380 VERIFY(MatchSlow(ssp,sep,ssub,esub)==rest);// Assert or verify - that is the question..
1381 dp = MatchDissect(ssp,sep,ssub,esub);
1382 ASSERT(dp==sep);
1383 sp=rest;
1384 break;
1385 case CSop::opChoice0:
1386 stp = end;
1387 for(;;){
1388 // how long..
1389 rest = MatchSlow(sp,stp,ss,es);
1390 ASSERT(rest);
1391 // Could it..
1392 tail = MatchSlow(rest,end,es,to);
1393 if(tail==end)
1394 break;// y
1395 // n
1396 stp = rest-1;
1397 ASSERT(stp>=sp);
1398 }
1399 ssub=ss+1;
1400 esub=ss+m_Strip[ss].m_Operand-1;
1401 ASSERT(m_Strip[esub].m_Operator==CSop::opOr0);
1402 for(;;){// Find first matching branch..
1403 if(MatchSlow(sp,rest,ssub,esub)==rest)
1404 break;
1405 // this one missed, try next..
1406 ASSERT(m_Strip[esub].m_Operator==CSop::opOr0);
1407 esub++;
1408 ASSERT(m_Strip[esub].m_Operator==CSop::opOr1);
1409 ssub=esub+1;
1410 esub+=m_Strip[esub].m_Operand;
1411 if(m_Strip[esub].m_Operator==CSop::opOr1)
1412 esub--;
1413 else
1414 ASSERT(m_Strip[esub].m_Operator==CSop::opChoice1);
1415 }
1416 dp = MatchDissect(sp,rest,ssub,esub);
1417 ASSERT(dp==rest);
1418 sp=rest;
1419 break;
1420 case CSop::opPlus1:
1421 case CSop::opQuest1:
1422 case CSop::opOr0:
1423 case CSop::opOr1:
1424 case CSop::opChoice1:
1425 ASSERT(FALSE);
1426 break;
1427 case CSop::opLeftParen:
1428 i = m_Strip[ss].m_Operand;
1429 ASSERT(0<i && i<=m_Subexps);
1430 m_Matches[i].m_Begin=sp-m_mBegin;
1431 break;
1432 case CSop::opRightParen:
1433 i = m_Strip[ss].m_Operand;
1434 ASSERT(0<i && i<=m_Subexps);
1435 m_Matches[i].m_End=sp-m_mBegin;
1436 break;
1437#ifdef _DEBUG
1438 default:// Uh.. oh..
1439 ASSERT(FALSE);
1440 break;
1441#endif
1442 }
1443 }
1444 ASSERT(sp==end);
1445 return sp;
1446}
1447
1448LPCTSTR CRegEx::MatchBackRef(LPCTSTR begin,LPCTSTR end,int from,int to,int level)
1449{
1450LPCTSTR sp = begin;
1451BOOL hard = FALSE;
1452 // Get as far as we can as long as it's easy
1453 for(int ss=from;!hard && ss<to;ss++){
1454 CSop s = m_Strip[ss];
1455 switch(s.m_Operator){
1456 case CSop::opChar:
1457 if(sp==end || *sp++ != s.m_Operand)
1458 return NULL;
1459 break;
1460 case CSop::opAny:
1461 if(sp==end)
1462 return NULL;
1463 sp++;// I'm sure this ++ could be embedded in previous expression..
1464 break;
1465 case CSop::opAnyOf:
1466 if(sp==end || !m_Sets[s.m_Operand].IsIn(*sp++))
1467 return NULL;
1468 break;
1469 case CSop::opBOL:
1470 if(!((sp==m_mBegin && !(m_mFlags&regNotBOL)) || (sp<m_mEnd && *(sp-1)=='\n' && (m_Flags&regNewLine))))
1471 return NULL;
1472 break;
1473 case CSop::opEOL:
1474 if(!((sp==m_mEnd && !(m_mFlags&regNotEOL)) || (sp<m_mEnd && *sp=='\n' && (m_Flags&regNewLine))))
1475 return NULL;
1476 break;
1477 case CSop::opBOW:
1478 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))))
1479 return NULL;
1480 break;
1481 case CSop::opEOW:
1482 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)))))
1483 return NULL;
1484 break;
1485 case CSop::opQuest1:
1486 break;
1487 case CSop::opOr0:// Matches null, but needs to skip
1488 ss++;
1489 s = m_Strip[ss];
1490 do{
1491 ASSERT(s.m_Operator==CSop::opOr1);
1492 ss+=s.m_Operand;
1493 }while((s=m_Strip[ss]).m_Operator!=CSop::opChoice1);
1494 // Now we should note that ss++ gets us past the Choice1..
1495 break;
1496 default:
1497 // Have to make a choice..
1498 hard=TRUE;
1499 break;
1500 }
1501 }
1502 if(!hard){// That was it..
1503 if(sp!=end)
1504 return NULL;
1505 return sp;
1506 }
1507 ss--;// Adjust for ther for's final increment..
1508 // Hard stuff.. is going on and on..
1509CSop s = m_Strip[ss];
1510int i, len, offsave;
1511int ssub,esub;
1512LPCTSTR ssp, dp;
1513 switch(s.m_Operator){
1514 case CSop::opBackRef0:// The vilest depths they say.. If I only knew what the 'viles' stands for..
1515 i = s.m_Operand;
1516 ASSERT(0<i && i<=m_Subexps);
1517 if(m_Matches[i].m_End<0)
1518 return NULL;
1519 ASSERT(m_Matches[i].m_Begin>=0);
1520 len = m_Matches[i].GetLength();
1521 ASSERT((end-m_mBegin)>=len);
1522 if(sp>end-len)
1523 return NULL;// Not enough left to match..
1524 ssp = m_mBegin+m_Matches[i].m_Begin;
1525 if(memcmp(sp,ssp,len))
1526 return NULL;
1527 while(m_Strip[ss]!=CSop(CSop::opBackRef1,i))
1528 ss++;
1529 return MatchBackRef(sp+len,end,ss+1,to,level-1);
1530 break;
1531 case CSop::opQuest0:// to null or not they wonder..
1532 dp = MatchBackRef(sp,end,ss+1,to,level);
1533 if(dp)
1534 return dp;// not..
1535 return MatchBackRef(sp,end,ss+s.m_Operand+1,to,level-1);
1536 break;
1537 case CSop::opPlus0:
1538 ASSERT(m_mLastPos.GetSize());
1539 ASSERT(level+1 <= m_Pluses);
1540 m_mLastPos[level+1]=sp;
1541 return MatchBackRef(sp,end,ss+1,to,level+1);
1542 break;
1543 case CSop::opPlus1:
1544 if(sp == m_mLastPos[level])// Last pass matched null
1545 return MatchBackRef(sp,end,ss+1,to,level-1);
1546 // Try another pass..
1547 m_mLastPos[level]=sp;
1548 dp = MatchBackRef(sp,end,ss-s.m_Operand+1,to,level);
1549 if(dp)
1550 return dp;
1551 return MatchBackRef(sp,end,ss+1,to,level-1);
1552 break;
1553 case CSop::opChoice0:// find the right one, ifany
1554 ssub = ss+1;
1555 esub = ss+s.m_Operand-1;
1556 ASSERT(m_Strip[esub].m_Operator==CSop::opOr0);
1557 for(;;){// Find first matching branch.
1558 dp = MatchBackRef(sp,end,ssub,esub,level);
1559 if(dp)
1560 return dp;
1561 // This one missed, try next one..
1562 if(m_Strip[esub].m_Operator==CSop::opChoice1)
1563 return NULL;// There is none..
1564 esub++;
1565 ASSERT(m_Strip[esub].m_Operator==CSop::opOr1);
1566 ssub=esub+1;
1567 esub+=m_Strip[esub].m_Operand;
1568 if(m_Strip[esub].m_Operator==CSop::opOr1)
1569 esub--;
1570 else
1571 ASSERT(m_Strip[esub].m_Operator==CSop::opChoice1);
1572 }
1573 break;
1574 case CSop::opLeftParen:// Must undo assignment if rest fails..
1575 i = s.m_Operand;
1576 ASSERT(0<i && i<=m_Subexps);
1577 offsave = m_Matches[i].m_Begin;
1578 m_Matches[i].m_Begin = sp-m_mBegin;
1579 dp = MatchBackRef(sp,end,ss+1,to,level);
1580 if(dp)
1581 return dp;
1582 m_Matches[i].m_Begin=offsave;
1583 return NULL;
1584 break;
1585 case CSop::opRightParen: // Must undo assignment if rest fails..
1586 i = s.m_Operand;
1587 ASSERT(0<i && i<=m_Subexps);
1588 offsave = m_Matches[i].m_End;
1589 m_Matches[i].m_End = sp-m_mBegin;
1590 dp = MatchBackRef(sp,end,ss+1,to,level);
1591 if(dp)
1592 return dp;
1593 m_Matches[i].m_End = offsave;
1594 return NULL;
1595 break;
1596 #ifdef_DEBUG
1597 default:
1598 ASSERT(FALSE);
1599 break;
1600#endif
1601 }
1602 ASSERT(FALSE);
1603 return NULL;// Anyway - we can never get here..
1604}
1605
1606 #ifdef_DEBUG
1607void CRegEx::CSop::Dump(CDumpContext& dc)
1608{
1609 switch(m_Operator){
1610 case opEnd:
1611 dc << "end";
1612 break;
1613 case opChar:
1614 dc << "char('" << (char)m_Operand << "')";
1615 break;
1616 case opBOL:
1617 dc << "BOL";
1618 break;
1619 case opEOL:
1620 dc << "EOL";
1621 break;
1622 case opAny:
1623 dc << "any";
1624 break;
1625 case opAnyOf:
1626 dc << "anyOf(" << m_Operand << ")";
1627 break;
1628 case opBackRef0:
1629 dc << "[ backref(" << m_Operand << ")";
1630 break;
1631 case opBackRef1:
1632 dc << "] backref(" << m_Operand << ")";
1633 break;
1634 case opPlus0:
1635 dc << "[ + (" << m_Operand << ")";
1636 break;
1637 case opPlus1:
1638 dc << "] + (" << m_Operand << ")";
1639 break;
1640 case opQuest0:
1641 dc << "[ ? (" << m_Operand << ")";
1642 break;
1643 case opQuest1:
1644 dc << "] ? (" << m_Operand << ")";
1645 break;
1646 case opLeftParen:
1647 dc << "[ ( (" << m_Operand << ")";
1648 break;
1649 case opRightParen:
1650 dc << "] ) (" << m_Operand << ")";
1651 break;
1652 case opChoice0:
1653 dc << "[ choice (" << m_Operand << ")";
1654 break;
1655 case opOr0:
1656 dc << "[ | (" << m_Operand << ")";
1657 break;
1658 case opOr1:
1659 dc << "] | (" << m_Operand << ")";
1660 break;
1661 case opChoice1:
1662 dc << "] choice (" << m_Operand << ")";
1663 break;
1664 case opBOW:
1665 dc << "BOW";
1666 break;
1667 case opEOW:
1668 dc << "EOW";
1669 break;
1670 }
1671}
1672void CRegEx::DumpStrip(CDumpContext& dc)
1673{
1674 for(int tmp=0;tmp<m_Strip.GetSize();tmp++)
1675 dc << tmp << ": " << m_Strip[tmp] << ";\n";
1676}
1677#endif
1678
1679
1680CString CRegEx::GetMatch(int match)
1681{
1682CString rv;
1683 if(!m_Matches.GetSize())
1684 return rv;
1685 ASSERT(m_Matches[0].m_Begin<m_Input.GetLength() && m_Matches[0].m_End<=m_Input.GetLength());
1686 if(match==matchPreMatch)
1687 return m_Input.Left(m_Matches[0].m_Begin);
1688 if(match==matchPostMatch)
1689 return m_Input.Mid(m_Matches[0].m_End);
1690 if(match<0 || match >= m_Matches.GetSize())
1691 return rv;
1692 if(m_Matches[match].m_Begin<0 || m_Matches[match].m_End<0)
1693 return rv;
1694 ASSERT(m_Matches[match].m_Begin<m_Input.GetLength() && m_Matches[match].m_End<=m_Input.GetLength());
1695 rv = m_Input.Mid(m_Matches[match].m_Begin,m_Matches[match].m_End-m_Matches[match].m_Begin);
1696 return rv;
1697}
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 @@
1#ifndef __REGEX_H
2#define __REGEX_H
3
4 class CRegEx{
5public:
6 CString GetMatch(int match=0);
7 CString m_Input;
8 struct CMatch{
9 CMatch() : m_Begin(-1), m_End(-1) {}
10 int GetLength() { return m_End-m_Begin; }
11 int m_Begin;
12 int m_End;
13 };
14 typedefCArray<CMatch,CMatch&> CMatchBox;
15 enum{
16 matchMatch = 0,
17 matchPreMatch = -1,
18 matchPostMatch = -2
19 };
20 CMatchBox m_Matches;
21 enum{
22 charOut = 256,
23 charBOL, charEOL, charBOLEOL, charNothing, charBOW, charEOW,
24 charMaxCode = charEOW,
25 charNNChars = (charMaxCode-255)
26 };
27 int m_mFlags;
28 enum{
29 regeSuccess = 0,
30 regeNoMatch = 1, regeBadPattern, regeCollate, regeCType, regeEscape, regeSubReg, regeBracket,
31 regeParen, regeBrace, regeBadBrace, regeRange, regeSpace, regeBadRepeat, regeEmpty, regeAssert,
32 regeInvArg
33 };
34 int m_Error;
35 CRegEx();
36 BOOL m_bCompiled;
37 CString m_Pattern;
38 BOOL m_bBackRefs;
39 int m_Pluses;
40 CString m_Must;
41 BYTE m_Category[CHAR_MAX-CHAR_MIN+1];
42 int m_Categories;
43 int m_EOLs;
44 int m_BOLs;
45 int m_iFlags;
46 int m_Subexps;
47 struct CSop {
48 void Dump(CDumpContext& dc);
49 CSop(){}
50 CSop(BYTE op,DWORD opnd=0) : m_Operator(op), m_Operand(opnd) {}
51 BOOL operator==(CSop& other) {return m_Operator==other.m_Operator && m_Operand==other.m_Operand;}
52 BOOL operator!=(CSop& other) { return !((*this)==other);}
53 enum{
54 opEnd = 1, opChar, opBOL, opEOL, opAny, opAnyOf, opBackRef0, opBackRef1,
55 opPlus0, opPlus1, opQuest0, opQuest1, opLeftParen, opRightParen, opChoice0,
56 opOr0, opOr1, opChoice1, opBOW, opEOW
57 };
58 BYTE m_Operator;
59 DWORD m_Operand;
60 enum{
61 stCurrent = 1, stFresh = 2, stTemp = 4, stEmpty = 8
62 };
63 BYTE m_MatchData;
64 };
65 typedef CArray<CSop,CSop&> CStrip;
66 CStrip m_Strip;
67 int m_Flags;
68 struct CSet{
69 CSet() : m_Hash(0) { memset(m_Set,0,sizeof(m_Set)); }
70 CSet(CSet& src) { (*this)=src; }
71 CSet& operator=(CSet& src) { memmove(this,&src,sizeof(*this)); return *this; }
72 BOOL operator==(CSet& other) { if(m_Hash!=other.m_Hash)return FALSE;return !memcmp(m_Set,other.m_Set,sizeof(m_Set)); }
73 enum{
74 size = (CHAR_MAX-CHAR_MIN+1)
75 };
76 BOOL m_Set[size];
77 BYTE m_Hash;
78 public:
79 UCHAR GetOnly();
80 void Sub(UCHAR c);
81 BOOL IsIn(UCHAR c);
82 void Add(UCHAR c);
83 };
84 typedef CArray<CSet,CSet&> CSets;
85 CSets m_Sets;
86 enum{
87 // Compile flags
88 regBasic = 0, regExtended = 1,
89 regIgnoreCase = 2,
90 regNoSubExpressions = 4,// Also works for matching.
91 regNewLine = 16,
92 regLiteral = 32,
93 // Match Flags
94 regNotBOL = 1,
95 regNotEOL = 2,
96 regOneMatch=64,
97 regBackRefs=128,
98 // iFlags
99 iflagsUseBOL=1, iflagsUseEOL=2, iflagsBad=4
100 };
101 CString Replace(LPCTSTR src,LPCTSTR rep,int flags=0);
102 BOOL Match(LPCTSTR src,int flags=0);
103 BOOL Compile(LPCTSTR regex,int flags=0);
104private:
105 #ifdef_DEBUG
106 void DumpStrip(CDumpContext& dc);
107#endif
108 LPCTSTR MatchBackRef(LPCTSTR begin,LPCTSTR end,int from,int to,int level);
109 typedef CArray<LPCTSTR,LPCTSTR> CStrPtrArray;
110 CStrPtrArray m_mLastPos;
111 LPCTSTR MatchDissect(LPCTSTR begin,LPCTSTR end,int from,int to);
112 LPCTSTR MatchSlow(LPCTSTR begin,LPCTSTR end,int from,int to);
113 LPCTSTR m_cOldP;
114 BOOL MatchStatesEqual(BYTE m1,BYTE m2);
115 LPCTSTR m_mBegin;
116 void MatchStatesCopy(BYTE dst,BYTE src);
117 void MatchStep(int from,int to,BYTE maskBefore,int charCode,BYTE maskAfter);
118 void MatchStatesClear(BYTE mask);
119 LPCTSTR MatchFast(LPCTSTR begin);
120 LPCTSTR m_mEnd;
121 LPCTSTR m_mPointer;
122 BOOL ParseBREexp(BOOL ordinaryStar);
123 void ParseBRE(int stopa=0,int stopb=0);
124 void ParseLiteral();
125 int CountPluses();
126 void FigureMust();
127 BOOL IsInSameSets(UCHAR c1,UCHAR c2);
128 BOOL IsInSets(UCHAR c);
129 void Categorize();
130 int StripDuplicate(int from,int to);
131 void EmitRepeat(int pos,int from,int to);
132 UCHAR ParseBracketSymbol();
133 UCHAR ParseBracketCollatingElement(UCHAR term);
134 void ParseBracketEClass(CSet& cset);
135 void ParseBracketCClass(CSet& cset);
136 void ParseBracketTerm(CSet& cset);
137 int StoreSet(CSet& cset);
138 void ParseBracket();
139 int ParseCount();
140 void EmitNonNewLineAny();
141 void EmitOrdinary(UCHAR c);
142 void StripInsert(int pos,CSop& sop);
143 void ParseEREexp();
144 void ParseERE(int stop=0);
145 struct CParenthesis{
146 long m_Begin;
147 long m_End;
148 CParenthesis(long b=0,long e=0) : m_Begin(b), m_End(e) {}
149 };
150 typedef CArray<CParenthesis,CParenthesis&> CParens;
151 CParens m_ParseParens;
152 int m_ParsePointer;
153};
154 #ifdef_DEBUG
155inline CDumpContext& operator<<(CDumpContext& dc, CRegEx::CSop& sop) { sop.Dump(dc); return dc; }
156#endif
157
158#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 @@
1 #ifndef__SNMPEXTDLL_H
2#define __SNMPEXTDLL_H
3
4#include "snmpeer.h"
5
6#include <snmp.h>
7
8namespace Klever {
9
10 class CSNMPExtDLL : public CSNMPeer{
11public:
12 HINSTANCE m_hInstance;
13 HANDLE m_hEvent;
14 AsnObjectIdentifier m_OID;
15 BOOL (SNMP_FUNC_TYPE *m_extInit)(DWORD dw,HANDLE h,AsnObjectIdentifier* aoid);
16 BOOL (SNMP_FUNC_TYPE *m_extQuery)(BYTE b,RFC1157VarBindList* rvbl,AsnInteger* ai1,AsnInteger* ai2);
17 BOOL (SNMP_FUNC_TYPE *m_extTrap)(AsnObjectIdentifier*,AsnNetworkAddress*,AsnInteger*,AsnInteger*,AsnTimeticks*,RFC1157VarBindList*);
18
19 HINSTANCE m_hSNMPAPI;
20 void (SNMP_FUNC_TYPE *m_snmpOIDFree)(AsnObjectIdentifier*);
21 LPVOID (SNMP_FUNC_TYPE *m_snmpAlloc)(UINT);
22 void (SNMP_FUNC_TYPE *m_snmpFree)(LPVOID);
23 void (SNMP_FUNC_TYPE *m_snmpVBLFree)(RFC1157VarBindList* vbl);
24 void InitSNMP() {
25 m_hSNMPAPI = ::LoadLibraryEx("SNMPAPI",NULL,0);
26 if(!m_hSNMPAPI)
27 return;
28 *(FARPROC*)&m_snmpOIDFree = ::GetProcAddress(m_hSNMPAPI,"SnmpUtilOidFree");
29 *(FARPROC*)&m_snmpAlloc = ::GetProcAddress(m_hSNMPAPI,"SnmpUtilMemAlloc");
30 *(FARPROC*)&m_snmpFree = ::GetProcAddress(m_hSNMPAPI,"SnmpUtilMemFree");
31 *(FARPROC*)&m_snmpVBLFree = ::GetProcAddress(m_hSNMPAPI,"SnmpUtilVarBindListFree");
32 if(
33 (m_snmpFree && !m_snmpAlloc) ||
34 (m_snmpAlloc && !m_snmpFree)
35 )
36 DeinitSNMP();
37 }
38 void DeinitSNMP() {
39 if(!m_hSNMPAPI)
40 return;
41 ::FreeLibrary(m_hSNMPAPI);
42 m_hSNMPAPI=NULL;
43 }
44 void SNMPFreeOID(AsnObjectIdentifier* oid) {
45 if(m_hSNMPAPI && m_snmpOIDFree)
46 (*m_snmpOIDFree)(oid);
47 else
48 ::GlobalFree((HGLOBAL)oid->ids);
49 }
50 LPVOID SNMPAlloc(UINT size) {
51 if(m_hSNMPAPI && m_snmpAlloc)
52 return (*m_snmpAlloc)(size);
53 else
54 return ::GlobalAlloc(GMEM_FIXED,size);
55 }
56 void SNMPFree(LPVOID addr) {
57 if(m_hSNMPAPI && m_snmpFree)
58 (*m_snmpFree)(addr);
59 else
60 :: GlobalFree((HGLOBAL)addr);
61 }
62 void SNMPFreeVBL(RFC1157VarBindList& vbl) {
63 if(m_hSNMPAPI && m_snmpVBLFree)
64 (*m_snmpVBLFree)(&vbl);
65 else{
66 for(UINT tmp=0;tmp<vbl.len;tmp++) {
67 SNMPFree(vbl.list[tmp].name.ids);
68 switch(vbl.list[tmp].value.asnType){
69 case ASN_OCTETSTRING:
70 case ASN_SEQUENCE:
71 case ASN_RFC1155_IPADDRESS:
72 case ASN_RFC1155_OPAQUE:
73 // case ASN_RFC1213_DISPSTRING:
74 if(vbl.list[tmp].value.asnValue.arbitrary.dynamic)
75 SNMPFree(vbl.list[tmp].value.asnValue.arbitrary.stream);
76 break;
77 case ASN_OBJECTIDENTIFIER:
78 SNMPFree(vbl.list[tmp].value.asnValue.object.ids);
79 break;
80 default:
81 break;
82 }
83 }
84 SNMPFree(vbl.list);
85 }
86 }
87
88 BOOL SNMPBuildVBL(RFC1157VarBindList& vbl,CSNMPVarBindList& in) {
89 vbl.len = in.GetCount();
90 vbl.list = (RFC1157VarBind*)SNMPAlloc(sizeof(RFC1157VarBind)*vbl.len);
91 POSITION p = in.GetHeadPosition();
92 UINT ptr = 0;
93 while(p){
94 CSNMPVarBind& vb = in.GetNext(p);
95 ASSERT(ptr<vbl.len);
96 SNMPBuildVB(vbl.list[ptr++],vb);
97 }
98 return TRUE;
99 }
100 BOOL SNMPBuildVB(RFC1157VarBind& vb,CSNMPVarBind& in) {
101 ASSERT(in.name.type==CASNAny::typeASNOID);
102 return SNMPBuildOID(vb.name,in.name.value.oid) && SNMPBuildAA(vb.value,in.value);
103 }
104 BOOL SNMPBuildAA(AsnAny& aa,CASNAny& in) {
105 aa.asnType=in.type;
106 switch(in.type) {
107 case CASNAny::typeASNInteger:
108 aa.asnValue.number=in.value.number; break;
109 case CASNAny::typeASNOctetString:
110 // case CASNAny::typeASNDispString:
111 SNMPBuildOS(aa.asnValue.string,in.value.string); break;
112 case CASNAny::typeASNNull:
113 break;
114 case CASNAny::typeASNOID:
115 SNMPBuildOID(aa.asnValue.object,in.value.oid); break;
116 case CASNAny::typeASNSequence:
117 // case CASNAny::typeASNSequenceOf:
118 SNMPBuildOS(aa.asnValue.sequence,in.value.sequence); break;
119 case CASNAny::typeASNIP:
120 SNMPBuildFLOS(aa.asnValue.address,(LPBYTE)&in.value.ip,sizeof(in.value.ip)); break;
121 case CASNAny::typeASNCounter:
122 aa.asnValue.counter = in.value.counter; break;
123 case CASNAny::typeASNGauge:
124 aa.asnValue.gauge = in.value.gauge; break;
125 case CASNAny::typeASNTicks:
126 aa.asnValue.ticks = in.value.ticks; break;
127 case CASNAny::typeASNOpaque:
128 ASSERT(in.storeType==CASNAny::storeDynamic);
129 SNMPBuildOS(aa.asnValue.arbitrary,in.value.data); break;
130 break;
131 default:
132 ASSERT(FALSE);
133 return FALSE;
134 }
135 return TRUE;
136 }
137 BOOL SNMPBuildOS(AsnOctetString& os,CASNAny::asnOctetString& in) {
138 return SNMPBuildFLOS(os,in.data,in.size);
139 }
140 BOOL SNMPBuildOID(AsnObjectIdentifier& oid,CASNAny::asnOID& in) {
141 oid.idLength = in.size/sizeof(UINT);
142 ASSERT(!(in.size%sizeof(UINT)));
143 VERIFY(oid.ids = (UINT*)SNMPAlloc(in.size));
144 memmove(oid.ids,in.data,in.size);
145 return TRUE;
146 }
147 BOOL SNMPBuildFLOS(AsnOctetString& os,LPBYTE data,UINT size) {
148 os.length = size;
149 VERIFY(os.stream = (BYTE*)SNMPAlloc(os.length));
150 os.dynamic=TRUE;
151 memmove(os.stream,data,size);
152 return TRUE;
153 }
154 BOOL SNMPParseVBL(RFC1157VarBindList& vbl,CSNMPVarBindList& ou) {
155 for(UINT tmp=0;tmp<vbl.len;tmp++){
156 CSNMPVarBind vb;
157 SNMPParseVB(vbl.list[tmp],vb);
158 ou.AddTail(vb);
159 }
160 return TRUE;
161 }
162 BOOL SNMPParseVB(RFC1157VarBind& vb,CSNMPVarBind& ou) {
163 ou.name.Set(CASNAny::typeASNOID,(LPBYTE)vb.name.ids,vb.name.idLength*sizeof(UINT));
164 return SNMPParseAA(vb.value,ou.value);
165 }
166 BOOL SNMPParseAA(AsnAny& aa,CASNAny& ou) {
167 switch(aa.asnType){
168 case ASN_INTEGER:
169 ou.Set(CASNAny::typeASNInteger,aa.asnValue.number); break;
170 case ASN_OCTETSTRING:
171 // case ASN_RFC1213_DISPSTRING:
172 ou.Set(CASNAny::typeASNOctetString,aa.asnValue.string.stream,aa.asnValue.string.length); break;
173 case ASN_OBJECTIDENTIFIER:
174 ou.Set(CASNAny::typeASNOID,(LPBYTE)aa.asnValue.object.ids,aa.asnValue.object.idLength);
175 SNMPParseOID(aa.asnValue.object,ou.value.oid); break;
176 case ASN_SEQUENCE:
177 ou.Set(CASNAny::typeASNSequence,aa.asnValue.sequence.stream,aa.asnValue.sequence.length); break;
178 case ASN_RFC1155_IPADDRESS:
179 SNMPParseIP(aa.asnValue.address,ou); break;
180 case ASN_RFC1155_COUNTER:
181 ou.Set(CASNAny::typeASNCounter,(LONG)aa.asnValue.counter); break;
182 case ASN_RFC1155_GAUGE:
183 ou.Set(CASNAny::typeASNGauge,(LONG)aa.asnValue.gauge); break;
184 case ASN_RFC1155_TIMETICKS:
185 ou.Set(CASNAny::typeASNTicks,(LONG)aa.asnValue.ticks); break;
186 case ASN_RFC1155_OPAQUE:
187 ou.Set(CASNAny::typeASNOpaque,aa.asnValue.arbitrary.stream,aa.asnValue.arbitrary.length); break;
188 case ASN_NULL:
189 ou.Free(); break;
190 default:
191 ASSERT(FALSE);
192 return FALSE;
193 }
194 return TRUE;
195 }
196 BOOL SNMPParseOID(AsnObjectIdentifier& oid,CASNAny::asnOID& ou) {
197 ASSERT(ou.size==(oid.idLength*sizeof(UINT)));
198 memmove(ou.data,oid.ids,ou.size);
199 return TRUE;
200 }
201 BOOL SNMPParseIP(AsnIPAddress& ip,CASNAny& ou) {
202 in_addr i;
203 if(ip.length>sizeof(i))
204 return FALSE;
205 i.s_addr=0;
206 memmove(&i,ip.stream,ip.length);
207 ou.Set(i);
208 return TRUE;
209 }
210
211
212 CSNMPExtDLL(LPCTSTR dllName) : m_hInstance(NULL) { InitSNMP(); Init(dllName); }
213 ~CSNMPExtDLL() { Deinit(); DeinitSNMP(); }
214
215 BOOL Init(LPCTSTR dllName) {
216 Deinit();
217 m_hInstance = ::LoadLibraryEx(dllName,NULL,0);
218 if(!m_hInstance)
219 return FALSE;
220 *(FARPROC*)&m_extInit = ::GetProcAddress(m_hInstance,"SnmpExtensionInit");
221 *(FARPROC*)&m_extQuery = ::GetProcAddress(m_hInstance,"SnmpExtensionQuery");
222 *(FARPROC*)&m_extTrap = ::GetProcAddress(m_hInstance,"SnmpExtensionTrap");
223 if(!(m_extInit && m_extQuery && m_extTrap)){
224 Deinit();
225 return FALSE;
226 }
227 if(!((*m_extInit)(GetCurrentTime(),&m_hEvent,&m_OID))){
228 Deinit();
229 return FALSE;
230 }
231 return TRUE;
232 }
233 void Deinit() {
234 if(!m_hInstance)
235 return;
236 ::FreeLibrary(m_hInstance);
237 }
238 virtual BOOL Request(BYTE type,CSNMPVarBindList& in,CSNMPVarBindList& ou) {
239 RFC1157VarBindList vbl;
240 SNMPBuildVBL(vbl,in);
241 AsnInteger errorStatus, errorIndex;
242 (*m_extQuery)(type,&vbl,&errorStatus,&errorIndex);
243 ou.RemoveAll();
244 SNMPParseVBL(vbl,ou);
245 SNMPFreeVBL(vbl);
246 return TRUE;
247 }
248};
249
250};
251
252 #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 @@
1 #ifndef__SNMPOIDS_H
2 #define__SNMPOIDS_H
3
4 #define DEFINE_OID(name,oid)static UINT name[] = oid
5
6 // MIB-II OIDs
7
8#define OIDccitt {0}
9#define OIDnull {0,0}
10#define OIDiso {1}
11#define OIDorg {1,3}
12#define OIDdod {1,3,6}
13#define OIDinternet {1,3,6,1}
14#define OIDdirectory {1,3,6,1,1}
15#define OIDmgmt {1,3,6,1,2}
16#define OIDmib_2 {1,3,6,1,2,1}
17#define OIDsystem {1,3,6,1,2,1,1}
18#define OIDsysDescr {1,3,6,1,2,1,1,1}
19#define OIDsysObjectID {1,3,6,1,2,1,1,2}
20#define OIDsysUpTime {1,3,6,1,2,1,1,3}
21#define OIDsysContact {1,3,6,1,2,1,1,4}
22#define OIDsysName {1,3,6,1,2,1,1,5}
23#define OIDsysLocation {1,3,6,1,2,1,1,6}
24#define OIDsysServices {1,3,6,1,2,1,1,7}
25#define OIDtransmission {1,3,6,1,2,1,10}
26#define OIDsnmp {1,3,6,1,2,1,11}
27#define OIDsnmpInPkts {1,3,6,1,2,1,11,1}
28#define OIDsnmpInBadValues {1,3,6,1,2,1,11,10}
29#define OIDsnmpInReadOnlys {1,3,6,1,2,1,11,11}
30#define OIDsnmpInGenErrs {1,3,6,1,2,1,11,12}
31#define OIDsnmpInTotalReqVars {1,3,6,1,2,1,11,13}
32#define OIDsnmpInTotalSetVars {1,3,6,1,2,1,11,14}
33#define OIDsnmpInGetRequests {1,3,6,1,2,1,11,15}
34#define OIDsnmpInGetNexts {1,3,6,1,2,1,11,16}
35#define OIDsnmpInSetRequests {1,3,6,1,2,1,11,17}
36#define OIDsnmpInGetResponses {1,3,6,1,2,1,11,18}
37#define OIDsnmpInTraps {1,3,6,1,2,1,11,19}
38#define OIDsnmpOutPkts {1,3,6,1,2,1,11,2}
39#define OIDsnmpOutTooBigs {1,3,6,1,2,1,11,20}
40#define OIDsnmpOutNoSuchNames {1,3,6,1,2,1,11,21}
41#define OIDsnmpOutBadValues {1,3,6,1,2,1,11,22}
42#define OIDsnmpOutGenErrs {1,3,6,1,2,1,11,24}
43#define OIDsnmpOutGetRequests {1,3,6,1,2,1,11,25}
44#define OIDsnmpOutGetNexts {1,3,6,1,2,1,11,26}
45#define OIDsnmpOutSetRequests {1,3,6,1,2,1,11,27}
46#define OIDsnmpOutGetResponses {1,3,6,1,2,1,11,28}
47#define OIDsnmpOutTraps {1,3,6,1,2,1,11,29}
48#define OIDsnmpInBadVersions {1,3,6,1,2,1,11,3}
49#define OIDsnmpEnableAuthenTraps {1,3,6,1,2,1,11,30}
50#define OIDsnmpInBadCommunityNames {1,3,6,1,2,1,11,4}
51#define OIDsnmpInBadCommunityUses {1,3,6,1,2,1,11,5}
52#define OIDsnmpInASNParseErrs {1,3,6,1,2,1,11,6}
53#define OIDsnmpInTooBigs {1,3,6,1,2,1,11,8}
54#define OIDsnmpInNoSuchNames {1,3,6,1,2,1,11,9}
55#define OIDinterfaces {1,3,6,1,2,1,2}
56#define OIDifNumber {1,3,6,1,2,1,2,1}
57#define OIDifTable {1,3,6,1,2,1,2,2}
58#define OIDifEntry {1,3,6,1,2,1,2,2,1}
59#define OIDifIndex {1,3,6,1,2,1,2,2,1,1}
60#define OIDifInOctets {1,3,6,1,2,1,2,2,1,10}
61#define OIDifInUcastPkts {1,3,6,1,2,1,2,2,1,11}
62#define OIDifInNUcastPkts {1,3,6,1,2,1,2,2,1,12}
63#define OIDifInDiscards {1,3,6,1,2,1,2,2,1,13}
64#define OIDifInErrors {1,3,6,1,2,1,2,2,1,14}
65#define OIDifInUnknownProtos {1,3,6,1,2,1,2,2,1,15}
66#define OIDifOutOctets {1,3,6,1,2,1,2,2,1,16}
67#define OIDifOutUcastPkts {1,3,6,1,2,1,2,2,1,17}
68#define OIDifOutNUcastPkts {1,3,6,1,2,1,2,2,1,18}
69#define OIDifOutDiscards {1,3,6,1,2,1,2,2,1,19}
70#define OIDifDescr {1,3,6,1,2,1,2,2,1,2}
71#define OIDifOutErrors {1,3,6,1,2,1,2,2,1,20}
72#define OIDifOutQLen {1,3,6,1,2,1,2,2,1,21}
73#define OIDifSpecific {1,3,6,1,2,1,2,2,1,22}
74#define OIDifType {1,3,6,1,2,1,2,2,1,3}
75#define OIDifMtu {1,3,6,1,2,1,2,2,1,4}
76#define OIDifSpeed {1,3,6,1,2,1,2,2,1,5}
77#define OIDifPhysAddress {1,3,6,1,2,1,2,2,1,6}
78#define OIDifAdminStatus {1,3,6,1,2,1,2,2,1,7}
79#define OIDifOperStatus {1,3,6,1,2,1,2,2,1,8}
80#define OIDifLastChange {1,3,6,1,2,1,2,2,1,9}
81#define OIDat {1,3,6,1,2,1,3}
82#define OIDatTable {1,3,6,1,2,1,3,1}
83#define OIDatEntry {1,3,6,1,2,1,3,1,1}
84#define OIDatIfIndex {1,3,6,1,2,1,3,1,1,1}
85#define OIDatPhysAddress {1,3,6,1,2,1,3,1,1,2}
86#define OIDatNetAddress {1,3,6,1,2,1,3,1,1,3}
87#define OIDip {1,3,6,1,2,1,4}
88#define OIDipForwarding {1,3,6,1,2,1,4,1}
89#define OIDipOutRequests {1,3,6,1,2,1,4,10}
90#define OIDipOutDiscards {1,3,6,1,2,1,4,11}
91#define OIDipOutNoRoutes {1,3,6,1,2,1,4,12}
92#define OIDipReasmTimeout {1,3,6,1,2,1,4,13}
93#define OIDipReasmReqds {1,3,6,1,2,1,4,14}
94#define OIDipReasmOKs {1,3,6,1,2,1,4,15}
95#define OIDipReasmFails {1,3,6,1,2,1,4,16}
96#define OIDipFragOKs {1,3,6,1,2,1,4,17}
97#define OIDipFragFails {1,3,6,1,2,1,4,18}
98#define OIDipFragCreates {1,3,6,1,2,1,4,19}
99#define OIDipDefaultTTL {1,3,6,1,2,1,4,2}
100#define OIDipAddrTable {1,3,6,1,2,1,4,20}
101#define OIDipAddrEntry {1,3,6,1,2,1,4,20,1}
102#define OIDipAdEntAddr {1,3,6,1,2,1,4,20,1,1}
103#define OIDipAdEntIfIndex {1,3,6,1,2,1,4,20,1,2}
104#define OIDipAdEntNetMask {1,3,6,1,2,1,4,20,1,3}
105#define OIDipAdEntBcastAddr {1,3,6,1,2,1,4,20,1,4}
106#define OIDipAdEntReasmMaxSize {1,3,6,1,2,1,4,20,1,5}
107#define OIDipRouteTable {1,3,6,1,2,1,4,21}
108#define OIDipRouteEntry {1,3,6,1,2,1,4,21,1}
109#define OIDipRouteDest {1,3,6,1,2,1,4,21,1,1}
110#define OIDipRouteAge {1,3,6,1,2,1,4,21,1,10}
111#define OIDipRouteMask {1,3,6,1,2,1,4,21,1,11}
112#define OIDipRouteMetric5 {1,3,6,1,2,1,4,21,1,12}
113#define OIDipRouteInfo {1,3,6,1,2,1,4,21,1,13}
114#define OIDipRouteIfIndex {1,3,6,1,2,1,4,21,1,2}
115#define OIDipRouteMetric1 {1,3,6,1,2,1,4,21,1,3}
116#define OIDipRouteMetric2 {1,3,6,1,2,1,4,21,1,4}
117#define OIDipRouteMetric3 {1,3,6,1,2,1,4,21,1,5}
118#define OIDipRouteMetric4 {1,3,6,1,2,1,4,21,1,6}
119#define OIDipRouteNextHop {1,3,6,1,2,1,4,21,1,7}
120#define OIDipRouteType {1,3,6,1,2,1,4,21,1,8}
121#define OIDipRouteProto {1,3,6,1,2,1,4,21,1,9}
122#define OIDipNetToMediaTable {1,3,6,1,2,1,4,22}
123#define OIDipNetToMediaEntry {1,3,6,1,2,1,4,22,1}
124#define OIDipNetToMediaIfIndex {1,3,6,1,2,1,4,22,1,1}
125#define OIDipNetToMediaPhysAddress {1,3,6,1,2,1,4,22,1,2}
126#define OIDipNetToMediaNetAddress {1,3,6,1,2,1,4,22,1,3}
127#define OIDipNetToMediaType {1,3,6,1,2,1,4,22,1,4}
128#define OIDipRoutingDiscards {1,3,6,1,2,1,4,23}
129#define OIDipInReceives {1,3,6,1,2,1,4,3}
130#define OIDipInHdrErrors {1,3,6,1,2,1,4,4}
131#define OIDipInAddrErrors {1,3,6,1,2,1,4,5}
132#define OIDipForwDatagrams {1,3,6,1,2,1,4,6}
133#define OIDipInUnknownProtos {1,3,6,1,2,1,4,7}
134#define OIDipInDiscards {1,3,6,1,2,1,4,8}
135#define OIDipInDelivers {1,3,6,1,2,1,4,9}
136#define OIDicmp {1,3,6,1,2,1,5}
137#define OIDicmpInMsgs {1,3,6,1,2,1,5,1}
138#define OIDicmpInTimestamps {1,3,6,1,2,1,5,10}
139#define OIDicmpInTimestampReps {1,3,6,1,2,1,5,11}
140#define OIDicmpInAddrMasks {1,3,6,1,2,1,5,12}
141#define OIDicmpInAddrMaskReps {1,3,6,1,2,1,5,13}
142#define OIDicmpOutMsgs {1,3,6,1,2,1,5,14}
143#define OIDicmpOutErrors {1,3,6,1,2,1,5,15}
144#define OIDicmpOutDestUnreachs {1,3,6,1,2,1,5,16}
145#define OIDicmpOutTimeExcds {1,3,6,1,2,1,5,17}
146#define OIDicmpOutParmProbs {1,3,6,1,2,1,5,18}
147#define OIDicmpOutSrcQuenchs {1,3,6,1,2,1,5,19}
148#define OIDicmpInErrors {1,3,6,1,2,1,5,2}
149#define OIDicmpOutRedirects {1,3,6,1,2,1,5,20}
150#define OIDicmpOutEchos {1,3,6,1,2,1,5,21}
151#define OIDicmpOutEchoReps {1,3,6,1,2,1,5,22}
152#define OIDicmpOutTimestamps {1,3,6,1,2,1,5,23}
153#define OIDicmpOutTimestampReps {1,3,6,1,2,1,5,24}
154#define OIDicmpOutAddrMasks {1,3,6,1,2,1,5,25}
155#define OIDicmpOutAddrMaskReps {1,3,6,1,2,1,5,26}
156#define OIDicmpInDestUnreachs {1,3,6,1,2,1,5,3}
157#define OIDicmpInTimeExcds {1,3,6,1,2,1,5,4}
158#define OIDicmpInParmProbs {1,3,6,1,2,1,5,5}
159#define OIDicmpInSrcQuenchs {1,3,6,1,2,1,5,6}
160#define OIDicmpInRedirects {1,3,6,1,2,1,5,7}
161#define OIDicmpInEchos {1,3,6,1,2,1,5,8}
162#define OIDicmpInEchoReps {1,3,6,1,2,1,5,9}
163#define OIDtcp {1,3,6,1,2,1,6}
164#define OIDtcpRtoAlgorithm {1,3,6,1,2,1,6,1}
165#define OIDtcpInSegs {1,3,6,1,2,1,6,10}
166#define OIDtcpOutSegs {1,3,6,1,2,1,6,11}
167#define OIDtcpRetransSegs {1,3,6,1,2,1,6,12}
168#define OIDtcpConnTable {1,3,6,1,2,1,6,13}
169#define OIDtcpConnEntry {1,3,6,1,2,1,6,13,1}
170#define OIDtcpConnState {1,3,6,1,2,1,6,13,1,1}
171#define OIDtcpConnLocalAddress {1,3,6,1,2,1,6,13,1,2}
172#define OIDtcpConnLocalPort {1,3,6,1,2,1,6,13,1,3}
173#define OIDtcpConnRemAddress {1,3,6,1,2,1,6,13,1,4}
174#define OIDtcpConnRemPort {1,3,6,1,2,1,6,13,1,5}
175#define OIDtcpInErrs {1,3,6,1,2,1,6,14}
176#define OIDtcpOutRsts {1,3,6,1,2,1,6,15}
177#define OIDtcpRtoMin {1,3,6,1,2,1,6,2}
178#define OIDtcpRtoMax {1,3,6,1,2,1,6,3}
179#define OIDtcpMaxConn {1,3,6,1,2,1,6,4}
180#define OIDtcpActiveOpens {1,3,6,1,2,1,6,5}
181#define OIDtcpPassiveOpens {1,3,6,1,2,1,6,6}
182#define OIDtcpAttemptFails {1,3,6,1,2,1,6,7}
183#define OIDtcpEstabResets {1,3,6,1,2,1,6,8}
184#define OIDtcpCurrEstab {1,3,6,1,2,1,6,9}
185#define OIDudp {1,3,6,1,2,1,7}
186#define OIDudpInDatagrams {1,3,6,1,2,1,7,1}
187#define OIDudpNoPorts {1,3,6,1,2,1,7,2}
188#define OIDudpInErrors {1,3,6,1,2,1,7,3}
189#define OIDudpOutDatagrams {1,3,6,1,2,1,7,4}
190#define OIDudpTable {1,3,6,1,2,1,7,5}
191#define OIDudpEntry {1,3,6,1,2,1,7,5,1}
192#define OIDudpLocalAddress {1,3,6,1,2,1,7,5,1,1}
193#define OIDudpLocalPort {1,3,6,1,2,1,7,5,1,2}
194#define OIDegp {1,3,6,1,2,1,8}
195#define OIDegpInMsgs {1,3,6,1,2,1,8,1}
196#define OIDegpInErrors {1,3,6,1,2,1,8,2}
197#define OIDegpOutMsgs {1,3,6,1,2,1,8,3}
198#define OIDegpOutErrors {1,3,6,1,2,1,8,4}
199#define OIDegpNeighTable {1,3,6,1,2,1,8,5}
200#define OIDegpNeighEntry {1,3,6,1,2,1,8,5,1}
201#define OIDegpNeighState {1,3,6,1,2,1,8,5,1,1}
202#define OIDegpNeighStateUps {1,3,6,1,2,1,8,5,1,10}
203#define OIDegpNeighStateDowns {1,3,6,1,2,1,8,5,1,11}
204#define OIDegpNeighIntervalHello {1,3,6,1,2,1,8,5,1,12}
205#define OIDegpNeighIntervalPoll {1,3,6,1,2,1,8,5,1,13}
206#define OIDegpNeighMode {1,3,6,1,2,1,8,5,1,14}
207#define OIDegpNeighEventTrigger {1,3,6,1,2,1,8,5,1,15}
208#define OIDegpNeighAddr {1,3,6,1,2,1,8,5,1,2}
209#define OIDegpNeighAs {1,3,6,1,2,1,8,5,1,3}
210#define OIDegpNeighInMsgs {1,3,6,1,2,1,8,5,1,4}
211#define OIDegpNeighInErrs {1,3,6,1,2,1,8,5,1,5}
212#define OIDegpNeighOutMsgs {1,3,6,1,2,1,8,5,1,6}
213#define OIDegpNeighOutErrs {1,3,6,1,2,1,8,5,1,7}
214#define OIDegpNeighInErrMsgs {1,3,6,1,2,1,8,5,1,8}
215#define OIDegpNeighOutErrMsgs {1,3,6,1,2,1,8,5,1,9}
216#define OIDegpAs {1,3,6,1,2,1,8,6}
217#define OIDexperimental {1,3,6,1,3}
218#define OIDprivate {1,3,6,1,4}
219#define OIDenterprises {1,3,6,1,4,1}
220
221 #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 @@
1 #ifndef__SNMPEER_H
2#define __SNMPEER_H
3
4namespace Klever {
5
6 class CASNAny{
7public:
8 enum{
9 asnCls = 0xC0,
10 asnClsUniversal = 0x00,
11 asnClsApplication = 0x40,
12 asnClsContextSpecific = 0x80,
13 asnClsPrivate = 0xC0,
14 asnConstructed = 0x20,
15 asnPrimitive = 0x00,
16 asnTag = 0x1F,
17 // ASN.1 Primitive Tags
18 asnTagInteger = 0x02,
19 asnTagOctetString = 0x04,
20 asnTagNull = 0x05,
21 asnTagOID = 0x06,
22 // ASN.1 Constructed Tags
23 asnTagSequence = 0x10,
24 // RFC1155 Primitive Tags
25 asnTagIP = 0x00,
26 asnTagCounter = 0x01,
27 asnTagGauge = 0x02,
28 asnTagTicks = 0x03,
29 asnTagOpaque = 0x04,
30 // RFC1213 alias
31 asnTagDispString = 0x04,// (ASN.1 Octet string)
32 // RFC1157 Constructed Tags
33 asnTagGetRequest = 0x00,
34 asnTagGetNextRequest = 0x01,
35 asnTagGetResponse = 0x02,
36 asnTagSetRequest = 0x03,
37 asnTagTrap = 0x04
38 };
39 enum{
40 typeASNInteger = (asnClsUniversal|asnPrimitive|asnTagInteger),
41 typeASNOctetString = (asnClsUniversal|asnPrimitive|asnTagOctetString),
42 typeASNNull = (asnClsUniversal|asnPrimitive|asnTagNull),
43 typeASNOID = (asnClsUniversal|asnPrimitive|asnTagOID),
44
45 typeASNSequence = (asnClsUniversal|asnConstructed|asnTagSequence),
46 typeASNSequenceOf = (asnClsUniversal|asnConstructed|asnTagSequence),
47
48 typeASNIP = (asnClsApplication|asnPrimitive|asnTagIP),
49 typeASNCounter = (asnClsApplication|asnPrimitive|asnTagCounter),
50 typeASNGauge = (asnClsApplication|asnPrimitive|asnTagGauge),
51 typeASNTicks = (asnClsApplication|asnPrimitive|asnTagTicks),
52 typeASNOpaque = (asnClsApplication|asnPrimitive|asnTagOpaque),
53 typeASNDispString = (asnClsUniversal|asnPrimitive|asnTagOctetString),
54
55 typeASNGetRequest = (asnClsContextSpecific|asnConstructed|asnTagGetRequest),
56 typeASNGetNextRequest = (asnClsContextSpecific|asnConstructed|asnTagGetNextRequest),
57 typeASNGetResponse = (asnClsContextSpecific|asnConstructed|asnTagGetResponse),
58 typeASNSetRequest = (asnClsContextSpecific|asnConstructed|asnTagSetRequest),
59 typeASNTrap = (asnClsContextSpecific|asnConstructed|asnTagTrap)
60 };
61
62 typedefLONG asnInteger;
63 typedef LARGE_INTEGER asnInteger64;
64 typedefDWORD asnCounter;
65 typedef ULARGE_INTEGER asnCounter64;
66 typedef DWORD asnGauge;
67 typedef ULARGE_INTEGER asnGauge64;
68 typedefDWORD asnTicks;
69 typedef ULARGE_INTEGER asnTicks64;
70 struct asnDynamic{
71 UINT size;
72 LPBYTE data;
73 BOOL Allocate(UINT size) {
74 BOOL rv = Free();
75 if(size)
76 rv=rv&&(data=new BYTE[size]);
77 if(rv)
78 asnDynamic::size=size;
79 return rv;
80 }
81 BOOL Set(LPBYTE data,UINT size) {
82 BOOL rv = Allocate(size);
83 if(rv && size)
84 memmove(asnDynamic::data,data,size);
85 return rv;
86 }
87 BOOL Free() {
88 if(!size)
89 return TRUE;
90 delete data;
91 size=0;
92 data=0;
93 return TRUE;
94 }
95 void Clean() {
96 size=0;
97 data=0;
98 }
99 BOOL Copy(asnDynamic& src) {
100 BOOL rv = Free();
101 if(rv){
102 if(src.size)
103 rv=rv&&(data = new BYTE[src.size]);
104 if(rv){
105 if(size=src.size)
106 memmove(data,src.data,size);
107 }
108 }
109 return rv;
110 }
111 };
112 typedefasnDynamic asnOctetString;
113 typedef asnDynamic asnOID;
114 typedef in_addr asnIP;
115 typedef asnDynamic asnSequence;
116
117 BYTE type;
118 enum _storeType{
119 storeDynamic,
120 storeStatic
121 }storeType;
122 union{
123 asnInteger number;
124 asnInteger64 number64;
125 asnOctetString string;
126 asnOID oid;
127 asnSequence sequence;
128 asnIP ip;
129 asnCounter counter;
130 asnCounter64 counter64;
131 asnGauge gauge;
132 asnGauge64 gauge64;
133 asnTicks ticks;
134 asnTicks64 ticks64;
135 asnDynamic data;
136 } value;
137
138 CASNAny() : type(typeASNNull), storeType(storeStatic) { value.data.Clean(); }
139 CASNAny(CASNAny& src) : type(typeASNNull), storeType(storeStatic) { value.data.Clean();Copy(src); }
140 CASNAny(BYTE type) : type(type), storeType(storeStatic) { value.data.Clean(); }
141 CASNAny(BYTE type,LONG number) : type(typeASNNull), storeType(storeStatic) { value.data.Clean();Set(type,number); }
142 CASNAny(BYTE type,LONGLONG number) : type(typeASNNull), storeType(storeStatic) { value.data.Clean();Set(type,number); }
143 CASNAny(BYTE type,LPCTSTR string) : type(typeASNNull), storeType(storeStatic) { value.data.Clean();Set(type,string); }
144 CASNAny(BYTE type,LPBYTE data,UINT length) : type(typeASNNull), storeType(storeStatic) { value.data.Clean();Set(type,data,length); }
145 CASNAny(BYTE type,UINT* data,UINT size) : type(typeASNNull), storeType(storeStatic) { value.data.Clean();Set(type,(LPBYTE)data,size); }
146 CASNAny(in_addr& ip) : type(typeASNNull), storeType(storeStatic) { value.data.Clean();Set(ip); }
147 ~CASNAny() { Free(); }
148
149 BOOL Set(BYTE type) {
150 BOOL rv = Free();
151 CASNAny::type=type;
152 return rv;
153 }
154 BOOL Set(BYTE type,LONG number) {
155 BOOL rv = Free();
156 CASNAny::type=type;
157 value.number=number;
158 storeType=storeStatic;
159 return rv;
160 }
161 BOOL Set(BYTE type,LONGLONG number) {
162 BOOL rv = Free();
163 CASNAny::type=type;
164 value.number64.QuadPart = number;
165 storeType=storeStatic;
166 return rv;
167 }
168 BOOL Set(BYTE type,LPCTSTR string) {
169 BOOL rv = Free();
170 CASNAny::type=type;
171 rv=rv&&value.string.Set((LPBYTE)string,strlen(string)+1);
172 if(rv){
173 value.string.size--;
174 storeType=storeDynamic;
175 }
176 return rv;
177 }
178 BOOL Set(BYTE type,LPBYTE data,UINT length) {
179 BOOL rv = Free();
180 CASNAny::type=type;
181 rv=rv&&value.data.Set(data,length);
182 if(rv)
183 storeType=storeDynamic;
184 return rv;
185 }
186 BOOL Set(in_addr& ip) {
187 BOOL rv = Free();
188 memmove(&value.ip,&ip,sizeof(value.ip));
189 type=typeASNIP;
190 storeType=storeStatic;
191 return rv;
192 }
193 BOOL Free() {
194 if(storeType==storeDynamic)
195 value.data.Free();
196 else{
197 memset(&value,0,sizeof(value));
198 value.data.Clean();
199 }
200 storeType=storeStatic;
201 type=typeASNNull;
202 return TRUE;
203 }
204 BOOL Copy(CASNAny& src) {
205 BOOL rv = Free();
206 if(src.storeType==storeDynamic){
207 rv=rv&&value.data.Copy(src.value.data);
208 if(rv){
209 type=src.type;
210 storeType=src.storeType;
211 }
212 }else{
213 memmove(this,&src,sizeof(*this));
214 }
215 return rv;
216 }
217 CASNAny& operator=(CASNAny& src) {
218 VERIFY(Copy(src));
219 return *this;
220 }
221
222 // High Level
223 CString GetString() {
224 ASSERT(storeType==storeDynamic);
225 CString rv;
226 LPTSTR b = rv.GetBuffer(value.data.size+1);
227 ASSERT(b);
228 b[value.data.size]=0;
229 memmove(b,value.data.data,value.data.size);
230 rv.ReleaseBuffer();
231 return rv;
232 }
233};
234
235
236 class CSNMPVarBind{
237public:
238 CASNAny name;
239 CASNAny value;
240
241 CSNMPVarBind() {}
242 CSNMPVarBind(CASNAny& name,CASNAny& value) : name(name), value(value) {}
243 CSNMPVarBind(CASNAny& name) : name(name) {}
244 CSNMPVarBind(CSNMPVarBind& src) { Copy(src); }
245 BOOL Copy(CSNMPVarBind& src) {
246 name.Copy(src.name);
247 value.Copy(src.value);
248 return TRUE;
249 }
250 CSNMPVarBind& operator=(CSNMPVarBind& src) {
251 Copy(src);
252 return *this;
253 }
254 // High level
255 BOOL IsName(UINT* prefix,UINT prefixSize,BOOL bExact=FALSE) {
256 if(name.type!=CASNAny::typeASNOID)
257 return FALSE;
258 if(name.value.oid.size<prefixSize)
259 return FALSE;
260 if(bExact && (name.value.oid.size!=prefixSize))
261 return FALSE;
262 return !memcmp(prefix,name.value.oid.data,prefixSize);
263 }
264};
265
266 class CSNMPVarBindList: public CList<CSNMPVarBind,CSNMPVarBind&> {
267public:
268 CSNMPVarBind* GetVarBind(UINT* prefix,UINT prefixSize,BOOL bExact=FALSE) {
269 POSITION p = GetHeadPosition();
270 while(p){
271 CSNMPVarBind& vb = GetNext(p);
272 if(vb.IsName(prefix,prefixSize,bExact))
273 return &vb;
274 }
275 return NULL;
276 }
277};
278
279 class CSNMPeer{
280public:
281 virtual BOOL Request(BYTE type,CSNMPVarBindList& in,CSNMPVarBindList& ou) = 0;
282};
283
284};
285
286 #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 @@
1 #defineWIN32_LEAN_AND_MEAN
2#define VC_EXTRALEAN
3#define WIN32_EXTRALEAN
4#include <windows.h>
5#include <shlobj.h>
6#include <winver.h>
7#include <crtdbg.h>
8#include <string.h>
9#include <stdio.h>
10
11extern "C" WINSHELLAPI void WINAPI SHFree( LPVOID);
12
13 template<class T> class Smart{
14public:
15 T *pT;
16
17 Smart() : pT(NULL) {}
18 Smart(int cb) : pT(new T[cb]) {}
19 Smart(T* p) : pT(p) {}
20 ~Smart() { if(pT)delete pT; }
21
22 Smart& operator=(T* p) { if(pT)delete pT; pT=p; return *this; }
23 operator T* () { return pT; }
24
25 //T& operator[](int ndx) { return pT[ndx]; }
26
27 T* Detach() { T* rv = pT; pT=NULL; return rv; }
28};
29 typedefSmart<char> STRING;
30
31 #define APPEND_SLASH(str) if((str)[strlen(str)-1]!='\\')strcat(str,"\\")
32
33HINSTANCE theInstance;
34
35LPSTR strFETCH_REG_KEY(HKEY hRoot,LPCSTR subKey,LPCSTR val)
36{
37HKEY hkey;
38 if(RegOpenKeyEx(hRoot,subKey,0,KEY_QUERY_VALUE,&hkey)!=ERROR_SUCCESS)
39 return NULL;
40DWORD kType,cb=0;
41STRING rv;
42 if(RegQueryValueEx(hkey,val,NULL,&kType,NULL,&cb)==ERROR_SUCCESS && kType==REG_SZ){
43 rv= new char[cb];
44 _ASSERT(rv!=NULL);
45 if(RegQueryValueEx(hkey,val,NULL,&kType,(LPBYTE)(LPSTR)rv,&cb)!=ERROR_SUCCESS)
46 rv=NULL;
47 }
48 RegCloseKey(hkey);
49 return rv.Detach();
50}
51
52BOOL strSET_REG_KEY(HKEY hRoot,LPCSTR subKey,LPCSTR valName,LPCSTR val)
53{
54HKEY hkey;
55DWORD dw;
56 if(RegCreateKeyEx(hRoot,subKey,0,REG_NONE,REG_OPTION_NON_VOLATILE,KEY_READ|KEY_WRITE,NULL,&hkey,&dw)!=ERROR_SUCCESS)
57 return FALSE;
58BOOL rv = (RegSetValueEx(hkey,valName,0,REG_SZ,(LPBYTE)val,strlen(val)+1)==ERROR_SUCCESS);
59 RegCloseKey(hkey);
60 return rv;
61}
62
63void MAKE_PATH(LPCSTR path)
64{
65STRING tmp(strlen(path)+1);
66LPCSTR t0=path;
67LPSTR t1=tmp;
68 while(*t0){
69 if((*t0)=='\\'){
70 *t1=0;
71 CreateDirectory(tmp,NULL);
72 }
73 *(t1++)=*(t0++);
74 }
75 *t1=0;
76 CreateDirectory(tmp,NULL);
77}
78
79BOOL ADDMENU(LPCSTR menu,LPCSTR item,LPCSTR path,LPCSTR program)
80{
81STRING stm = strFETCH_REG_KEY(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders","Programs");
82 if(!stm)
83 return FALSE;
84int pil = 1+strlen(path)+1+strlen(program)+1+1;
85STRING pi(pil);
86 strcpy(pi,path);
87 APPEND_SLASH(pi);
88 strcat(pi,program);
89int ipl = strlen(stm)+1+strlen(menu)+1+strlen(item)+4+1;
90STRING ip(ipl);
91 memmove(ip,stm,strlen(stm)+1);
92 APPEND_SLASH(ip);
93 strcat(ip,menu);
94 MAKE_PATH(ip);
95 APPEND_SLASH(ip);
96 strcat(ip,item);
97 strcat(ip,".lnk");
98IShellLink* sl = NULL;
99IPersistFile* pf = NULL;
100BOOL rv = FALSE;
101 do{
102 HRESULT hrv = CoCreateInstance(CLSID_ShellLink,NULL,CLSCTX_INPROC_SERVER,IID_IShellLink,(LPVOID*)&sl);
103 if(!SUCCEEDED(hrv))
104 break;
105 sl->SetDescription(item);
106 sl->SetPath(pi);
107 hrv = sl->QueryInterface(IID_IPersistFile,(LPVOID*)&pf);
108 if(!SUCCEEDED(hrv))
109 break;
110 WORD wsz[MAX_PATH];
111 MultiByteToWideChar(CP_ACP,0,ip,-1,wsz,MAX_PATH);
112 hrv = pf->Save(wsz,TRUE);
113 if(SUCCEEDED(hrv))
114 rv=TRUE;
115 }while(FALSE);
116 if(pf)
117 pf->Release();
118 if(sl)
119 sl->Release();
120 return rv;
121}
122
123FILE* CREATE_INF_FILE(LPCSTR path,LPCSTR file)
124{
125STRING fn(strlen(path)+1+strlen(file)+1);
126 strcpy(fn,path);
127 APPEND_SLASH(fn);
128 strcat(fn,file);
129 return fopen(fn,"wt");
130}
131
132BOOL INSTALLFILE(LPCSTR res,LPCSTR path,LPCSTR file)
133{
134STRING temp(MAX_PATH);
135 if(!GetTempPath(MAX_PATH,temp)) return FALSE;
136STRING tf(MAX_PATH);
137 if(!GetTempFileName(temp,"KGI",0,tf)) return FALSE;
138HRSRC hrsrc = FindResource(NULL,res,MAKEINTRESOURCE(RT_RCDATA));
139 if(!hrsrc) return FALSE;
140DWORD sor = SizeofResource(NULL,hrsrc);
141 if(!sor) return FALSE;
142HGLOBAL hglobal = LoadResource(NULL,hrsrc);
143 if(!hglobal) return FALSE;
144LPVOID lpv = LockResource(hglobal);
145 if(!lpv) return FALSE;
146HANDLE hf = CreateFile(tf,GENERIC_READ|GENERIC_WRITE,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_TEMPORARY,NULL);
147 if(!hf) return FALSE;
148DWORD written = 0;
149 if(!WriteFile(hf,lpv,sor,&written,NULL) || written!=sor){
150 CloseHandle(hf);
151 return FALSE;
152 }
153 CloseHandle(hf);
154STRING toKill(strlen(tf)+1);
155 strcpy(toKill,tf);
156 for(int tmp=strlen(tf)-1;tmp>0 && ((tf[tmp])!='\\');tmp--);
157 if(tf[tmp]=='\\')
158 tf[tmp++]=0;
159STRING nothing(_MAX_PATH);
160UINT nothingLength=_MAX_PATH;
161 if(VerInstallFile(0,&tf[tmp],(LPSTR)file,tf,(LPSTR)path,NULL,nothing,&nothingLength)){
162 DeleteFile(toKill);
163 return FALSE;
164 }
165 DeleteFile(toKill);
166 return TRUE;
167}
168
169LPCSTR pdTitle, pdPrompt;
170char pdPath[_MAX_PATH];
171BOOL CALLBACK pathDlgProc(HWND hwnd,UINT uMsg,WPARAM wP,LPARAM lP)
172{
173 switch(uMsg){
174 case WM_INITDIALOG:
175 SetWindowText(hwnd,pdTitle);
176 SetDlgItemText(hwnd,IDC_PROMPT,pdPrompt);
177 SetDlgItemText(hwnd,IDC_PATH,pdPath);
178 SetWindowPos(hwnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
179 return 1;
180 case WM_COMMAND:
181 switch(LOWORD(wP)){ // ID
182 case IDC_BROWSE:
183 switch(HIWORD(wP)){
184 case BN_CLICKED:
185 {
186 BROWSEINFO bi;
187 memset(&bi,0,sizeof(bi));
188 bi.hwndOwner=hwnd;
189 bi.pszDisplayName=pdPath;
190 bi.lpszTitle="Select Folder..";
191 bi.ulFlags=BIF_RETURNONLYFSDIRS;
192 LPITEMIDLIST lpidl=SHBrowseForFolder(&bi);
193 if(lpidl){
194 SHGetPathFromIDList(lpidl,pdPath);
195 SHFree(lpidl);
196 SetDlgItemText(hwnd,IDC_PATH,pdPath);
197 }
198 }
199 return 1;
200 }
201 break;
202 case IDOK:
203 switch(HIWORD(wP)){
204 case BN_CLICKED:
205 if(GetDlgItemText(hwnd,IDC_PATH,pdPath,sizeof(pdPath)))
206 EndDialog(hwnd,IDOK);
207 else
208 // *** Error message
209 EndDialog(hwnd,IDCANCEL);
210 return 1;
211 }
212 break;
213 case IDCANCEL:
214 switch(HIWORD(wP)){
215 case BN_CLICKED:
216 EndDialog(hwnd,IDCANCEL);
217 return 1;
218 }
219 break;
220 };
221 break;
222 }
223 return 0;
224}
225
226LPSTR REQUESTPATH(LPCSTR title,LPCSTR prompt,LPCSTR defPath)
227{
228 pdTitle=title;pdPrompt=prompt;
229 strcpy(pdPath,defPath);
230 if(DialogBox(NULL,MAKEINTRESOURCE(IDD_PATH),NULL/*Parent*/,(DLGPROC)&pathDlgProc)!=IDOK)
231 return NULL;
232STRING rv(strlen(pdPath)+1);
233 strcpy(rv,pdPath);
234 return rv.Detach();
235}
236
237HKEY uninstallKey(LPCSTR regKey) {
238 STRING rk(100+strlen(regKey)+1);
239 sprintf(rk,"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s",regKey);
240 HKEY rv = NULL;
241 DWORD dw;
242 if(RegCreateKeyEx(HKEY_LOCAL_MACHINE,rk,0,REG_NONE,REG_OPTION_NON_VOLATILE,KEY_READ|KEY_WRITE,NULL,&rv,&dw)!=ERROR_SUCCESS)
243 return NULL;
244 return rv;
245}
246
247BOOL REG_UNINSTALL_COMMAND(LPCSTR regKey,LPCSTR dName,LPCSTR iPath,LPCSTR iFile,LPCSTR iSection)
248{
249 HKEY hKey = uninstallKey(regKey);
250 if(!hKey)
251 return FALSE;
252 BOOL rv=FALSE;
253 do{
254 if(RegSetValueEx(hKey,"DisplayName",0,REG_SZ,(LPBYTE)dName,strlen(dName)+1)!=ERROR_SUCCESS)
255 break;
256 STRING us(50+strlen(iPath)+1+strlen(iFile)+strlen(iSection)+1);
257 strcpy(us,"RunDll32 setupapi.dll,InstallHinfSection ");
258 strcat(us,iSection);
259 strcat(us," 132 ");
260 strcat(us,iPath);
261 APPEND_SLASH(us);
262 strcat(us,iFile);
263 if(RegSetValueEx(hKey,"UninstallString",0,REG_SZ,(LPBYTE)(LPCSTR)us,strlen(us)+1)!=ERROR_SUCCESS)
264 break;
265 rv=TRUE;
266 }while(FALSE);
267 RegCloseKey(hKey);
268 return rv;
269}
270BOOL REG_UNINSTALL_ICON(LPCSTR regKey,LPCSTR path,LPCSTR file,int n) {
271 HKEY hKey = uninstallKey(regKey);
272 if(!hKey)
273 return FALSE;
274 STRING uis(strlen(path)+1+strlen(file)+7);
275 strcpy(uis,path);
276 APPEND_SLASH(uis);
277 strcat(uis,file);
278 char tmp[8];
279 sprintf(tmp,";%d",n);
280 strcat(uis,tmp);
281 BOOL rv = TRUE;
282 if(RegSetValueEx(hKey,"DisplayIcon",0,REG_SZ,(LPBYTE)(LPCSTR)uis,strlen(uis)+1)!=ERROR_SUCCESS)
283 rv = FALSE;
284 RegCloseKey(hKey);
285 return rv;
286}
287BOOL REG_UNINSTALL_COMMENT(LPCSTR regKey,LPCSTR comment) {
288 HKEY hKey = uninstallKey(regKey);
289 if(!hKey)
290 return FALSE;
291 BOOL rv = TRUE;
292 if(RegSetValueEx(hKey,"lComment",0,REG_SZ,(LPBYTE)comment,strlen(comment)+1)!=ERROR_SUCCESS)
293 rv = FALSE;
294 RegCloseKey(hKey);
295 return rv;
296}
297BOOL REG_UNINSTALL_VERSION(LPCSTR regKey,LPCSTR version) {
298 HKEY hKey = uninstallKey(regKey);
299 if(!hKey)
300 return FALSE;
301 BOOL rv = TRUE;
302 if(RegSetValueEx(hKey,"DisplayVersion",0,REG_SZ,(LPBYTE)version,strlen(version)+1)!=ERROR_SUCCESS)
303 rv = FALSE;
304 RegCloseKey(hKey);
305 return rv;
306}
307BOOL REG_UNINSTALL_LOCATION(LPCSTR regKey,LPCSTR location) {
308 HKEY hKey = uninstallKey(regKey);
309 if(!hKey)
310 return FALSE;
311 BOOL rv = TRUE;
312 if(RegSetValueEx(hKey,"InstallLocation",0,REG_SZ,(LPBYTE)location,strlen(location)+1)!=ERROR_SUCCESS)
313 rv = FALSE;
314 RegCloseKey(hKey);
315 return rv;
316}
317BOOL REG_UNINSTALL_PUBLISHER(LPCSTR regKey,LPCSTR publisher) {
318 HKEY hKey = uninstallKey(regKey);
319 if(!hKey)
320 return FALSE;
321 BOOL rv = TRUE;
322 if(RegSetValueEx(hKey,"Publisher",0,REG_SZ,(LPBYTE)publisher,strlen(publisher)+1)!=ERROR_SUCCESS)
323 rv = FALSE;
324 RegCloseKey(hKey);
325 return rv;
326}
327BOOL REG_UNINSTALL_URLS(LPCSTR regKey,LPCSTR about,LPCSTR update) {
328 HKEY hKey = uninstallKey(regKey);
329 if(!hKey)
330 return FALSE;
331 BOOL rv = TRUE;
332 if(RegSetValueEx(hKey,"URLInfoAbout",0,REG_SZ,(LPBYTE)about,strlen(about)+1)!=ERROR_SUCCESS)
333 rv = FALSE;
334 if(RegSetValueEx(hKey,"URLUpdateInfo",0,REG_SZ,(LPBYTE)update,strlen(update)+1)!=ERROR_SUCCESS)
335 rv = FALSE;
336 RegCloseKey(hKey);
337 return rv;
338}
339
340 #defineINF_FILE_HEADER(i) fprintf(i,"[Version]\nSignature=\"$CHICAGO$\"\n\n")
341#define INF_FILE_SECTION(i,s) fprintf(i,"\n[%s]\n",s)
342 #defineINF_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)
343#define INF_MENU_GROUP(i,n,m) fprintf(i,"setup.ini, progman.groups,,\"group%d=%s\"\n",n,m)
344#define INF_MENU_ITEM(i,n,m) fprintf(i,"setup.ini, group%d,, \"\"\"%s\"\"\"\n",n,m);
345#define INF_REMOVE_ROOT(i,g,r) fprintf(i,"HKLM,Software\\Microsoft\\Windows\\CurrentVersion\\DeleteFiles\\%s,,,\"%s\"\n",g,r)
346#define INF_REMOVE_FILE(i,g,f) fprintf(i,"HKLM,Software\\Microsoft\\Windows\\CurrentVersion\\DeleteFiles\\%s,%s,,\"%s\"\n",g,f,f)
347#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");}
348
349LPSTR GET_SHORT_PATH(LPCSTR path)
350{
351char tmp;
352DWORD len = GetShortPathName(path,&tmp,1);
353 if(!len)
354 return NULL;
355STRING rv(len+1);
356 if(!GetShortPathName(path,rv,len+1))
357 return NULL;
358 return rv.Detach();
359}
360
361BOOL Install(void);
362
363int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE,LPSTR,int)
364{
365 theInstance=hInstance;
366 CoInitialize(NULL);
367 Install();
368 CoUninitialize();
369 return 0;
370}
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 @@
1#ifndef IP_ICMPHEADER
2
3#define IP_ICMPHEADER
4
5struct icmp {
6 BYTE icmp_type;
7 BYTE icmp_code;
8 WORD icmp_cksum;
9 WORD icmp_id;
10 WORD icmp_seq;
11 char icmp_data[1];
12};
13
14#define SIZE_ICMP_HDR 8
15#define SIZE_TIME_DATA 8
16
17struct ip {
18 BYTE ip_hl:4, /* header length */
19 ip_v:4; /* version */
20 BYTE ip_tos; /* type of service */
21 short ip_len; /* total length */
22 u_short ip_id; /* identification */
23 short ip_off; /* fragment offset field */
24 BYTE ip_ttl; /* time to live */
25 BYTE ip_p; /* protocol */
26 u_short ip_sum; /* checksum */
27 struct in_addr ip_src,ip_dst; /* source and dest address */
28};
29
30#define ICMP_ECHOREPLY 0 /* echo reply */
31#define ICMP_UNREACH 3 /* dest unreachable, codes: */
32#define ICMP_UNREACH_NET 0 /* bad net */
33#define ICMP_UNREACH_HOST 1 /* bad host */
34#define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */
35#define ICMP_UNREACH_PORT 3 /* bad port */
36#define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */
37#define ICMP_UNREACH_SRCFAIL 5 /* src route failed */
38#define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */
39#define ICMP_REDIRECT 5 /* shorter route, codes: */
40#define ICMP_REDIRECT_NET 0 /* for network */
41#define ICMP_REDIRECT_HOST 1 /* for host */
42#define ICMP_REDIRECT_TOSNET 2 /* for tos and net */
43#define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */
44#define ICMP_ECHO 8 /* echo service */
45#define ICMP_TIMXCEED 11 /* time exceeded, code: */
46#define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */
47#define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */
48#define ICMP_PARAMPROB 12 /* ip header bad */
49#define ICMP_TSTAMP 13 /* timestamp request */
50#define ICMP_TSTAMPREPLY 14 /* timestamp reply */
51#define ICMP_IREQ 15 /* information request */
52#define ICMP_IREQREPLY 16 /* information reply */
53#define ICMP_MASKREQ 17 /* address mask request */
54#define ICMP_MASKREPLY 18 /* address mask reply */
55
56#define ICMP_MAXTYPE 18
57
58#define ICMP_MINLEN 8 /* abs minimum */
59#define ICMP_TSLEN (8 + 3 * sizeof (n_time)) /* timestamp */
60#define ICMP_MASKLEN 12 /* address mask */
61#define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */
62#define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8)
63
64#define STNORM 0
65
66/* Definition of the lowest telnet byte following an IAC byte */
67#define LOW_TEL_OPT 236
68
69#define TEL_EOF 236
70#define SUSP 237
71#define ABORT 238
72
73#define SE 240
74#define NOP 241
75#define DM 242
76#define BREAK 243
77#define IP 244
78#define AO 245
79#define AYT 246
80#define EC 247
81#define EL 248
82#define GOAHEAD 249
83#define SB 250
84#define WILL 251
85#define WONT 252
86#define DO 253
87#define DONT 254
88#define IAC 255
89
90#endif
91
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 @@
1 #ifndef__KHELPERS_H
2#define __KHELPERS_H
3
4#include <shlobj.h>
5
6extern "C" WINSHELLAPI void WINAPI SHFree( LPVOID);
7
8namespace Klever {
9
10 inline BOOL BrowseForFolder(CString& folder,LPCTSTR title=NULL,CWnd* pParent=NULL) {
11 BROWSEINFO bi;
12 memset(&bi,0,sizeof(bi));
13 if(pParent)
14 bi.hwndOwner=pParent->GetSafeHwnd();
15 CString rv;
16 bi.pszDisplayName=rv.GetBuffer(MAX_PATH);
17 bi.lpszTitle=title;
18 bi.ulFlags=BIF_RETURNONLYFSDIRS;
19 LPITEMIDLIST lpidl = SHBrowseForFolder(&bi);
20 if(lpidl){
21 SHGetPathFromIDList(lpidl,bi.pszDisplayName);
22 SHFree(lpidl);
23 rv.ReleaseBuffer();
24 folder=rv;
25 return TRUE;
26 }
27 rv.ReleaseBuffer();
28 return FALSE;
29 }
30 inline BOOL BrowseForFolder(CString& folder,UINT idTitle,CWnd* pParent=NULL) {
31 CString title;
32 VERIFY(title.LoadString(idTitle));
33 return BrowseForFolder(folder,title,pParent);
34 }
35 inline CString GluePathAndFile(LPCTSTR path,LPCTSTR file) {
36 CString rv = path;
37 while((!rv.IsEmpty()) && rv[rv.GetLength()-1]=='\\')
38 rv=rv.Left(rv.GetLength()-1);
39 rv+='\\';
40 while(*file && *file=='\\')
41 file++;
42 rv+=file;
43 return rv;
44 }
45 inline UINT TokenizeString(CStringList& rv,LPCTSTR string,LPCTSTR delimiter) {
46 CString s = string;
47 int found;
48 int delength = strlen(delimiter);
49 int rvc = 0;
50 while((found=s.Find(delimiter))>=0){
51 rv.AddTail(s.Left(found));
52 rvc++;
53 s=s.Mid(found+delength);
54 }
55 if(!s.IsEmpty()){
56 rv.AddTail(s);
57 rvc++;
58 }
59 return rvc;
60 }
61 inline BOOL LogRecord(LPCTSTR logFile,LPCTSTR logRecord) {
62 try{
63 CFile f(logFile,CFile::modeCreate|CFile::modeNoTruncate|CFile::modeReadWrite|CFile::shareDenyWrite);
64 f.SeekToEnd();
65 CString s = CTime::GetCurrentTime().Format("[%c] ")+logRecord+"\r\n";
66 f.Write((LPCTSTR)s,s.GetLength());
67 }catch(CException* e){
68 e->Delete();
69 return FALSE;
70 }
71 return TRUE;
72 }
73 inline BOOL ReadString(CFile* file,CString& rv) {
74 rv.Empty();
75 int nBuffer = 256;
76 TCHAR* ch = rv.GetBuffer(nBuffer);
77 int nPos = 0;
78 BOOL bRV = FALSE;
79 for(;;){
80 TCHAR c;
81 try{
82 if(file->Read(&c,sizeof(c))!=sizeof(c))
83 break;
84 bRV=TRUE;
85 }catch(CException* e){
86 e->Delete();
87 TRACE0("Exception in ReadString\n");
88 return FALSE;
89 }
90 if(nPos>=(nBuffer-1)){
91 rv.ReleaseBuffer();
92 ch = rv.GetBuffer(nBuffer=nBuffer+256);
93 ASSERT(ch);
94 }
95 if(c=='\n')
96 break;
97 ch[nPos++]=c;
98 }
99 ch[nPos]=0;
100 for(;;){
101 nPos--;
102 if(nPos<0)
103 break;
104 if(ch[nPos]!='\r')
105 break;
106 ch[nPos]=0;
107 }
108 rv.ReleaseBuffer();
109 rv.FreeExtra();
110 return bRV;
111 }
112
113 inline int LoadStringList(CStringList& list,LPCTSTR section) {
114 CString n;
115 list.RemoveAll();
116 CWinApp* app = AfxGetApp();
117 ASSERT(app);
118 for(int tmp=0;;tmp++){
119 n.Format("%d",tmp);
120 CString str = app->GetProfileString(section,n,NULL);
121 if(str.IsEmpty())
122 break;
123 list.AddTail(str);
124 }
125 return tmp;
126 }
127 inline int SaveStringList(CStringList& list,LPCTSTR section) {
128 CString n;
129 CWinApp* app = AfxGetApp();
130 ASSERT(app);
131 POSITION p = list.GetHeadPosition();
132 for(int tmp=0;p;tmp++){
133 n.Format("%d",tmp);
134 app->WriteProfileString(section,n,list.GetNext(p));
135 }
136 n.Format("%d",tmp);
137 app->WriteProfileString(section,n,NULL);
138 return tmp;
139 }
140
141 inline BOOL WriteProfileString(LPCTSTR section,LPCTSTR entry,LPCTSTR str) {
142 CWinApp* app = AfxGetApp();
143 return app->WriteProfileBinary(section,entry,(LPBYTE)str,strlen(str)+1);
144 }
145 inline CString GetProfileString(LPCTSTR section,LPCTSTR entry,LPCTSTR defval) {
146 CWinApp* app = AfxGetApp();
147 LPBYTE pData;
148 UINT nCount;
149 CString rv = defval;
150 if(app->GetProfileBinary(section,entry,&pData,&nCount)){
151 rv = (LPCTSTR)pData;
152 delete pData;
153 }
154 return rv;
155 }
156
157};
158
159#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 @@
1#include "../stdafx.h"
2#include "kICMP.h"
3
4CICMP::_mechanismus CICMP::m_mechanismus = CICMP::_icmpUndetermined;
5
6BOOL CICMPDll::Initialize()
7{
8 if(m_hICMP!=INVALID_HANDLE_VALUE || m_hICMPDLL)
9 Deinitialize();
10 m_hICMPDLL = ::LoadLibraryEx("ICMP",NULL,0);
11 if(!m_hICMPDLL)
12 return FALSE;
13 *(FARPROC*)&m_icmpCF = ::GetProcAddress(m_hICMPDLL,"IcmpCreateFile");
14 *(FARPROC*)&m_icmpSE = ::GetProcAddress(m_hICMPDLL,"IcmpSendEcho");
15 *(FARPROC*)&m_icmpCH = ::GetProcAddress(m_hICMPDLL,"IcmpCloseHandle");
16 if(!(m_icmpCF && m_icmpSE && m_icmpCH)){
17 Deinitialize(); return FALSE;
18 }
19 m_hICMP = (*m_icmpCF)();
20 if(m_hICMP==INVALID_HANDLE_VALUE){
21 Deinitialize(); return FALSE;
22 }
23 TRACE0("ICMP-DLL Initialized\n");
24 return TRUE;
25}
26void CICMPDll::Deinitialize()
27{
28 if(m_hICMPDLL){
29 if(m_hICMP!=INVALID_HANDLE_VALUE && m_icmpCH)
30 (*m_icmpCH)(m_hICMP);
31 ::FreeLibrary(m_hICMPDLL); m_hICMPDLL = NULL;
32 m_icmpCF = NULL;
33 m_icmpSE = NULL;
34 m_icmpCH = NULL;
35 }
36 m_hICMP=INVALID_HANDLE_VALUE;
37 if(m_sizeOut && m_bsOut){
38 delete m_bsOut;
39 m_bsOut = NULL; m_sizeOut = 0;
40 }
41 if(m_sizeIn && m_bsIn){
42 delete m_bsIn;
43 m_bsIn = NULL; m_sizeIn = 0;
44 }
45}
46
47LONG CICMPDll::Ping(const in_addr host,const UINT packetSize,
48 const UINT timeOut,LPINT pStatus)
49{
50 if(!(m_hICMP && m_hICMPDLL && m_icmpSE)){
51 if(pStatus)
52 (*pStatus) = icmpNotInitialized;
53 return -1;
54 }
55 VERIFY(AdjustBuffers(packetSize));
56IPINFO ipi;
57 memset(&ipi,0,sizeof(ipi));
58 ipi.Ttl = 30;
59 for(UINT tmp=0;tmp<packetSize;tmp++)
60 m_bsOut[tmp]=tmp&0xFF;
61LPICMPECHO pRep = (LPICMPECHO)m_bsIn;
62 pRep->Status = 0xFFFFFFFFl;
63 if((*m_icmpSE)(m_hICMP,host.s_addr,m_bsOut,packetSize,
64 &ipi,pRep,m_sizeIn,timeOut))
65 TRACE0("ICMP-SendEcho succeeded\n");
66 else
67 TRACE0("ICMP-SendEcho failed\n");
68LONG lrv = -1;
69INT rv = ipUnknown;
70 switch(pRep->Status){
71 case IP_SUCCESS:
72 lrv = pRep->RTTime; rv = ipSuccess;
73 break;
74 case IP_BUF_TOO_SMALL: rv = ipBuffTooSmall; break;
75 case IP_DEST_NET_UNREACHABLE: rv = ipDestNetUnreachable; break;
76 case IP_DEST_HOST_UNREACHABLE: rv = ipDestHostUnreachable; break;
77 case IP_DEST_PROT_UNREACHABLE: rv = ipDestProtUnreachable; break;
78 case IP_DEST_PORT_UNREACHABLE: rv = ipDestPortUnreachable; break;
79 case IP_NO_RESOURCES: rv = ipNoResources; break;
80 case IP_BAD_OPTION: rv = ipBadOption; break;
81 case IP_HW_ERROR: rv = ipHWError; break;
82 case IP_PACKET_TOO_BIG: rv = ipPacketTooBig; break;
83 case IP_REQ_TIMED_OUT: rv = ipTimeOut; break;
84 case IP_BAD_REQ: rv = ipBadRequest; break;
85 case IP_BAD_ROUTE: rv = ipBadRoute; break;
86 case IP_TTL_EXPIRED_TRANSIT: rv = ipTTLExpiredInTransit; break;
87 case IP_TTL_EXPIRED_REASSEM: rv = ipTTLExpiredInReasm; break;
88 case IP_PARAM_PROBLEM: rv = ipParamProblem; break;
89 case IP_SOURCE_QUENCH: rv = ipSourceQuench; break;
90 case IP_OPTION_TOO_BIG: rv = ipOptionTooBig; break;
91 case IP_BAD_DESTINATION: rv = ipBadDest; break;
92 }
93 if(pStatus)
94 (*pStatus)=rv;
95 return lrv;
96}
97
98BOOL CICMPDll::AdjustBuffers(UINT packetSize)
99{
100 if(!packetSize)
101 packetSize=1;
102 if(packetSize>m_sizeOut){
103 if(m_sizeOut && m_bsOut)
104 delete m_bsOut;
105 m_bsOut = new BYTE[m_sizeOut=packetSize];
106 if(!m_bsOut)
107 return FALSE;
108 }
109UINT sin = sizeof(ICMPECHO)+SIZE_ICMP_HDR+packetSize;
110 if(sin>m_sizeIn){
111 if(m_sizeIn && m_bsIn)
112 delete m_bsIn;
113 m_bsIn = new BYTE[m_sizeIn=sin];
114 if(!m_bsIn)
115 return FALSE;
116 }
117 return TRUE;
118}
119
120
121WORD CICMPWS::m_icmpSeq = 0;
122
123BOOL CICMPWS::Initialize()
124{
125 if(m_socket!=INVALID_SOCKET)
126 Deinitialize();
127 m_socket = socket(AF_INET,SOCK_RAW,1/*ICMP*/);
128 if(m_socket==INVALID_SOCKET)
129 return FALSE;
130 TRACE0("ICMP-WS Initialized\n");
131 return TRUE;
132}
133void CICMPWS::Deinitialize()
134{
135 if(m_socket!=INVALID_SOCKET){
136 closesocket(m_socket);
137 m_socket=INVALID_SOCKET;
138 }
139 if(m_sizeOut && m_bsOut){
140 delete m_bsOut;
141 m_bsOut = NULL; m_sizeOut = 0;
142 }
143 if(m_sizeIn && m_bsIn){
144 delete m_bsIn;
145 m_bsIn = NULL; m_sizeIn = 0;
146 }
147}
148LONG CICMPWS::Ping(const in_addr host,const UINT packetSize,
149 const UINT timeOut,LPINT pStatus)
150{
151 if(m_socket==INVALID_SOCKET){
152 if(pStatus)
153 (*pStatus)=icmpNotInitialized;
154 }
155 VERIFY(AdjustBuffers(packetSize));
156icmp* pPacket = (icmp*)m_bsOut;
157 memset(pPacket,0,m_sizeOut);
158 pPacket->icmp_type = ICMP_ECHO;
159 pPacket->icmp_seq = m_icmpSeq++;
160 pPacket->icmp_id = (WORD)(::GetCurrentThreadId()&0xFFFF);
161 for(UINT tmp=0;tmp<packetSize;tmp++)
162 pPacket->icmp_data[tmp]=tmp&0xFF;
163 pPacket->icmp_cksum = cksum(pPacket,SIZE_ICMP_HDR+packetSize);
164sockaddr_in to;
165 memset(&to,0,sizeof(to));
166 to.sin_addr.s_addr = host.s_addr;
167 to.sin_family = AF_INET;
168 if(sendto(m_socket,(char*)pPacket,SIZE_ICMP_HDR+packetSize,0,
169 (SOCKADDR*)&to,sizeof(to)) != (int)(SIZE_ICMP_HDR+packetSize)){
170 TRACE1("sendto: %lu\n",WSAGetLastError());
171 if(pStatus)
172 (*pStatus)=icmpSocketError;
173 return -1;
174 }
175DWORD sentTime = ::GetTickCount();
176sockaddr_in from;
177 memset(&from,0,sizeof(from));
178 from.sin_family=AF_INET;
179 from.sin_addr.s_addr=INADDR_ANY;
180fd_set fds;
181 FD_ZERO(&fds);
182 FD_SET(m_socket,&fds);
183long lrv = -1;
184INT rv = ipTimeOut;
185 for(;;){
186 DWORD ct = ::GetTickCount();
187 if((ct-sentTime)>=timeOut){
188 TRACE0("Timeout\n");
189 break;
190 }
191 timeval tv = {
192 (timeOut-ct+sentTime)/1000,
193 (timeOut-ct+sentTime)%1000
194 };// tv_sec, tv_usec (secs,microsecs)
195 if(!select(m_socket,&fds,NULL,NULL,&tv)){
196 TRACE1("select: %d\n",WSAGetLastError());
197 break;
198 }
199 DWORD rtime = ::GetTickCount();
200 ASSERT(FD_ISSET(m_socket,&fds));
201 int fl = sizeof(from);
202 int rb = recvfrom(m_socket,(char*)m_bsIn,m_sizeIn,0,(SOCKADDR*)&from,&fl);
203 ip* pIP = (ip*)m_bsIn;
204 icmp* pICMP = (icmp*)&m_bsIn[sizeof(ip)];
205 if(pICMP->icmp_id!=pPacket->icmp_id)
206 continue;
207 if(pICMP->icmp_seq!=pPacket->icmp_seq)
208 continue;
209 if(from.sin_addr.s_addr!=host.s_addr)
210 continue;
211 if(pICMP->icmp_type==ICMP_ECHOREPLY){
212 lrv=rtime-sentTime;
213 rv=ipSuccess;
214 break;
215 }
216 rv = ipUnknown;// ***
217 break;
218 }
219 if(pStatus)
220 (*pStatus)=rv;
221 return lrv;
222}
223
224BOOL CICMPWS::AdjustBuffers(UINT packetSize)
225{
226 if(!packetSize)
227 packetSize=0;
228UINT osize = packetSize+SIZE_ICMP_HDR;
229 if(m_sizeOut<osize){
230 if(m_sizeOut && m_bsOut)
231 delete m_bsOut;
232 m_bsOut = new BYTE[m_sizeOut=osize];
233 if(!m_bsOut)
234 return FALSE;
235 }
236UINT isize = osize+sizeof(ip);
237 if(m_sizeIn<isize){
238 if(m_sizeIn && m_bsIn)
239 delete m_bsIn;
240 m_bsIn = new BYTE[m_sizeIn=isize];
241 if(!m_bsIn)
242 return FALSE;
243 }
244 return TRUE;
245}
246
247WORD CICMPWS::cksum(LPVOID data,int count)
248{
249long lSum = 0;
250WORD *pData = (WORD*)data;
251 while(count>0){
252 if(count>1){
253 lSum+=*(pData++);
254 count-=2;
255 }else{
256 lSum+=((WORD)*(BYTE*)pData)&0xFF;
257 count--;
258 }
259 }
260 lSum = (lSum&0xFFFF)+(lSum>>16);
261 lSum += (lSum>>16);
262 return (~lSum)&0xFFFF;
263}
264
265CICMP* CICMP::CreateICMP()
266{
267 if(m_mechanismus==_icmpUndetermined)
268 GuessMechanismus();
269 switch(m_mechanismus){
270 case _icmpWinsock:
271 return new CICMPWS;
272 break;
273 case _icmpDLL:
274 return new CICMPDll;
275 break;
276 }
277 return NULL;
278}
279
280void CICMP::GuessMechanismus()
281{
282 m_mechanismus=_icmpUndetermined;
283SOCKET testSocket = socket(AF_INET,SOCK_RAW,1);
284 if(testSocket!=INVALID_SOCKET){
285 closesocket(testSocket);
286 m_mechanismus=_icmpWinsock;
287 }else{
288 HINSTANCE hICMP = ::LoadLibraryEx("ICMP",NULL,0);
289 if(!hICMP)
290 return;
291 BOOL isThere = (
292 ::GetProcAddress(hICMP,"IcmpCreateFile")
293 && ::GetProcAddress(hICMP,"IcmpSendEcho")
294 && ::GetProcAddress(hICMP,"IcmpCloseHandle")
295 );
296 ::FreeLibrary(hICMP);
297 if(isThere)
298 m_mechanismus=_icmpDLL;
299 }
300} \ 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 @@
1 #ifndef__KICMP_H
2#define __KICMP_H
3
4class CICMP {
5 enum _mechanismus {
6 _icmpUndetermined = -1,
7 _icmpWinsock = 0, _icmpDLL
8 };
9static _mechanismus m_mechanismus;
10static void GuessMechanismus();
11public:
12static
13 CICMP* CreateICMP();
14
15 enum {
16 ipSuccess = 0,
17 ipBuffTooSmall, ipDestNetUnreachable, ipDestHostUnreachable,
18 ipDestProtUnreachable, ipDestPortUnreachable, ipNoResources,
19 ipBadOption, ipHWError, ipPacketTooBig, ipTimeOut, ipBadRequest,
20 ipBadRoute, ipTTLExpiredInTransit, ipTTLExpiredInReasm,
21 ipParamProblem, ipSourceQuench, ipOptionTooBig, ipBadDest,
22 ipUnknown = -1,
23 icmpNotInitialized = -2,
24 icmpSocketError = -3
25 };
26
27 virtual BOOL Initialize() = 0;
28 virtual void Deinitialize() = 0;
29
30 virtual LONG Ping(const in_addr host,const UINT packetSize=0,
31 const UINT timeOut=10000,LPINT pStatus=NULL) = 0;
32};
33
34class CICMPDll : public CICMP {
35 HANDLE(WINAPI *m_icmpCF)(VOID);
36 BOOL(WINAPI *m_icmpSE)(HANDLE,ULONG,LPVOID,WORD,
37 PIPINFO,LPVOID,DWORD,DWORD);
38 BOOL(WINAPI *m_icmpCH)(HANDLE);
39public:
40 HINSTANCE m_hICMPDLL;
41 HANDLE m_hICMP;
42 LPBYTE m_bsIn, m_bsOut;
43 UINT m_sizeIn, m_sizeOut;
44
45 CICMPDll() : m_hICMP(INVALID_HANDLE_VALUE), m_hICMPDLL(NULL),
46 m_bsIn(NULL), m_bsOut(NULL), m_sizeIn(0), m_sizeOut(0) {}
47 virtual ~CICMPDll() { Deinitialize(); }
48
49 virtual BOOL Initialize();
50 virtual void Deinitialize();
51
52 virtual LONG Ping(const in_addr host,const UINT packetSize=0,
53 const UINT timeOut=10000,LPINT pStatus=NULL);
54
55 BOOL AdjustBuffers(UINT packetSize=0);
56};
57
58class CICMPWS : public CICMP {
59static
60 WORD m_icmpSeq;
61public:
62 SOCKET m_socket;
63 LPBYTE m_bsIn, m_bsOut;
64 UINT m_sizeIn, m_sizeOut;
65
66 CICMPWS() : m_socket(INVALID_SOCKET), m_bsIn(NULL), m_bsOut(NULL),
67 m_sizeIn(0), m_sizeOut(0) {}
68 virtual ~CICMPWS() { Deinitialize(); }
69
70 virtual BOOL Initialize();
71 virtual void Deinitialize();
72
73 virtual LONG Ping(const in_addr host,const UINT packetSize=0,
74 const UINT timeOut=10000,LPINT pStatus=NULL);
75
76 BOOL AdjustBuffers(UINT packetSize=0);
77 WORD cksum(LPVOID data,int count);
78};
79
80#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 @@
1<?xml version="1.0"?>
2<xsl:stylesheet version="1.0"
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 >
5 <xsl:output
6 method="text"
7 encoding="us-ascii"/>
8 <xsl:strip-space elements="*"/>
9
10 <xsl:template match="winhelp">
11 <xsl:text>{\rtf1\ansi</xsl:text>
12 <xsl:text>&#xA;@{\footnote</xsl:text>
13 <xsl:text>&#xA;THIS FILE WAS AUTOMATICALLY GENERATED FROM XML DOCUMENT.</xsl:text>
14 <xsl:text>&#xA;DO NOT MODIFY THIS FILE DIRECTLY. EDIT XML DOCUMENT INSTEAD</xsl:text>
15 <xsl:text>&#xA;}&#xA;</xsl:text>
16 <xsl:call-template name="fonttbl"/>
17 <xsl:call-template name="colortbl"/>
18 <xsl:apply-templates/>
19 <xsl:text>}</xsl:text>
20 </xsl:template>
21
22 <xsl:template match="topic">
23 <xsl:text>&#xA;\pard\plain</xsl:text>
24 <xsl:if test="descendant::*[ (@scroll='no') and
25 count(preceding-sibling::*[not(@scroll='no') and (name()!='a' and @name)])=0] ">
26 <xsl:text>\keepn</xsl:text>
27 </xsl:if>
28 <xsl:if test="@id">
29 <xsl:text>&#xA;#{\footnote </xsl:text>
30 <xsl:value-of select="@id"/>
31 <xsl:text>}</xsl:text>
32 </xsl:if>
33 <xsl:if test="@title">
34 <xsl:text>&#xA;${\footnote </xsl:text>
35 <xsl:value-of select="@title"/>
36 <xsl:text>}</xsl:text>
37 </xsl:if>
38 <xsl:if test="@keywords">
39 <xsl:text>&#xA;K{\footnote </xsl:text>
40 <xsl:value-of select="@keywords"/>
41 <xsl:text>}</xsl:text>
42 </xsl:if>
43 <xsl:apply-templates/>
44 <xsl:text>&#xA;\page&#xA;</xsl:text>
45 </xsl:template>
46
47 <xsl:template match="a[@name]">
48 <xsl:text>{#{\footnote </xsl:text>
49 <xsl:value-of select="@name"/>
50 <xsl:text>}}</xsl:text>
51 </xsl:template>
52 <xsl:template match="a[@href]">
53 <xsl:call-template name="hyperref">
54 <xsl:with-param name="href" select="@href"/>
55 <xsl:with-param name="inset"><xsl:apply-templates/></xsl:with-param>
56 </xsl:call-template>
57 </xsl:template>
58 <xsl:template name="hyperref">
59 <xsl:param name="href"/>
60 <xsl:param name="inset"/>
61 <xsl:choose>
62 <xsl:when test="starts-with($href,'http:') or starts-with($href,'mailto:') or
63 starts-with($href,'ftp:')">
64 <xsl:text>{\uldb </xsl:text>
65 <xsl:value-of select="$inset"/>
66 <xsl:text>}{\v %!ExecFile("</xsl:text>
67 <xsl:value-of select="$href"/>
68 <xsl:text>")}</xsl:text>
69 </xsl:when>
70 <xsl:when test="starts-with($href,'#')">
71 <xsl:text>{\uldb </xsl:text>
72 <xsl:value-of select="$inset"/>
73 <xsl:text>}{\v </xsl:text>
74 <xsl:value-of select="substring($href,2)"/>
75 <xsl:text>}</xsl:text>
76 </xsl:when>
77 <xsl:otherwise>
78 <xsl:message>Warining: Unqualified hyper-reference. Using as help-internal</xsl:message>
79 <xsl:text>{\uldb </xsl:text>
80 <xsl:value-of select="$inset"/>
81 <xsl:text>}{\v </xsl:text>
82 <xsl:value-of select="$href"/>
83 <xsl:text>}</xsl:text>
84 </xsl:otherwise>
85 </xsl:choose>
86 </xsl:template>
87
88 <xsl:template match="heading">
89 <xsl:text>&#xA;</xsl:text>
90 <xsl:if test="@scroll!='no'">
91 <xsl:text>\pard </xsl:text>
92 </xsl:if>
93 <xsl:text>{ \f1\fs18\b\sb120 </xsl:text>
94 <xsl:apply-templates/>
95 <xsl:text>}</xsl:text>
96 </xsl:template>
97
98 <xsl:template match="p">
99 <xsl:text>&#xA;\par\sa120\sb120\qj</xsl:text>
100 <xsl:if test="@scroll!='no'">
101 <xsl:text>\pard</xsl:text>
102 </xsl:if>
103 <xsl:text> \f1\fs18\sb120 </xsl:text>
104 <xsl:apply-templates/>
105 </xsl:template>
106
107 <xsl:template match="note">
108 <xsl:text>&#xA;\par\sa120\sb120\qj\f1\fs16 </xsl:text>
109 <xsl:apply-templates/>
110 </xsl:template>
111
112 <xsl:template match="dedication">
113 <xsl:text>&#xA;\par\sa120\sb120\qr\f1\fs16 </xsl:text>
114 <xsl:apply-templates/>
115 </xsl:template>
116
117 <xsl:template match="image">
118 <xsl:text>\{bmct </xsl:text>
119 <xsl:value-of select="@source"/>
120 <xsl:text>\}</xsl:text>
121 </xsl:template>
122
123 <xsl:template match="newsfor">
124 <xsl:text>&#xA;\par\pard\plain\f1\fs24\qc\cf2\b </xsl:text>
125 <xsl:value-of select="@version"/>
126 <xsl:text> - </xsl:text>
127 <xsl:value-of select="@date"/>
128 <xsl:apply-templates/>
129 </xsl:template>
130 <xsl:template match="ni">
131 <xsl:text>&#xA;\par\pard\plain\fi0\li0\f1\fs18 \bullet </xsl:text>
132 <xsl:apply-templates/>
133 </xsl:template>
134
135 <xsl:template match="b">
136 <xsl:text>{\b </xsl:text>
137 <xsl:apply-templates/>
138 <xsl:text>}</xsl:text>
139 </xsl:template>
140 <xsl:template match="i">
141 <xsl:text>{\i </xsl:text>
142 <xsl:apply-templates/>
143 <xsl:text>}</xsl:text>
144 </xsl:template>
145 <xsl:template match="u">
146 <xsl:text>{\ul </xsl:text>
147 <xsl:apply-templates/>
148 <xsl:text>}</xsl:text>
149 </xsl:template>
150 <xsl:template match="strike">
151 <xsl:text>{\strike </xsl:text>
152 <xsl:apply-templates/>
153 <xsl:text>}</xsl:text>
154 </xsl:template>
155
156 <xsl:template match="kin">
157 <xsl:choose>
158 <xsl:when test="@href">
159 <xsl:call-template name="hyperref">
160 <xsl:with-param name="href" select="@href"/>
161 <xsl:with-param name="inset"><xsl:text>{\b </xsl:text><xsl:apply-templates/><xsl:text>}</xsl:text></xsl:with-param>
162 </xsl:call-template>
163 </xsl:when>
164 <xsl:otherwise>
165 <xsl:text>{\b </xsl:text>
166 <xsl:apply-templates/>
167 <xsl:text>}</xsl:text>
168 </xsl:otherwise>
169 </xsl:choose>
170 </xsl:template>
171 <xsl:template match="product">
172 <xsl:choose>
173 <xsl:when test="@href">
174 <xsl:call-template name="hyperref">
175 <xsl:with-param name="href" select="@href"/>
176 <xsl:with-param name="inset"><xsl:text>{\b\cf6 </xsl:text><xsl:apply-templates/><xsl:text>}</xsl:text></xsl:with-param>
177 </xsl:call-template>
178 </xsl:when>
179 <xsl:otherwise>
180 <xsl:text>{\b\cf6 </xsl:text>
181 <xsl:apply-templates/>
182 <xsl:text>}</xsl:text>
183 </xsl:otherwise>
184 </xsl:choose>
185 </xsl:template>
186 <xsl:template match="term">
187 <xsl:text>{\i </xsl:text>
188 <xsl:apply-templates/>
189 <xsl:text>}</xsl:text>
190 </xsl:template>
191
192 <xsl:template match="rfc">
193 <xsl:call-template name="hyperref">
194 <xsl:with-param name="href" select="concat('http://www.rfc-editor.org/rfc/rfc',@num,'.txt')"/>
195 <xsl:with-param name="inset" select="concat('{\b RFC',@num,'}')"/>
196 </xsl:call-template>
197 </xsl:template>
198
199 <xsl:template match="license">
200 <xsl:text>&#xA;{</xsl:text>
201 <xsl:text>&#xA;\par\pard\plain\sb360\sa120 \f1\fs16 Copyright (c) </xsl:text>
202 <xsl:value-of select="@years"/>
203 <xsl:text> {\uldb\cf0 Klever Group (http://www.klever.net/)}{\v %!ExecFile("http://www.klever.net/")}</xsl:text>
204 <xsl:text>&#xA;\par\qj\sb120\sa120</xsl:text>
205 <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>
206 <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>
207 <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>
208 <xsl:text>&#xA;}</xsl:text>
209 </xsl:template>
210 <xsl:template match="credits">
211 <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>
212 <xsl:text>&#xA;\par \sa0\sb0 Fan mail send to {\i\uldb gefilte@klever.net}{\v %!ExecFile("mailto:gefilte@klever.net")}</xsl:text>
213 </xsl:template>
214
215 <xsl:template match="ul">
216 <xsl:text>\pard</xsl:text>
217 <xsl:apply-templates/>
218 <xsl:text>\pard</xsl:text>
219 </xsl:template>
220 <xsl:template match="li">
221 <!-- TODO: could be done better, but you never know with winhelp.. -->
222 <xsl:variable name="li" select=" count(ancestor::ul) "/>
223 <xsl:text>&#xA;\par \fi0\li</xsl:text><xsl:value-of
224 select="0"/><xsl:text> \bullet </xsl:text>
225 <xsl:apply-templates/>
226 </xsl:template>
227
228 <xsl:template match="topic/text()">
229 <!-- maybe only omit spaces? -->
230 </xsl:template>
231 <xsl:template match="ul/text()">
232 </xsl:template>
233
234 <xsl:template name="colortbl">
235 <xsl:text>{\colortbl;
236 \red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;
237 \red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;
238 \red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;
239 \red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;}
240 </xsl:text>
241 </xsl:template>
242 <xsl:template name="fonttbl">
243 <xsl:text>{\fonttbl</xsl:text>
244 <xsl:text>{\f0\froman Times New Roman;}</xsl:text>
245 <xsl:text>{\f1\fswiss Arial;}</xsl:text>
246 <xsl:text>{\f3\froman Symbol;}</xsl:text>
247 <xsl:text>}</xsl:text>
248 </xsl:template>
249
250</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 @@
1/*------------------------------------------------------------------
2* Filename: MS_ICMP.H
3*
4* Description: Prototypes of Microsoft's ICMP.DLL functions for
5* access to Internet Control Message Protocol (their stacks do
6* not support the standard Berkeley Sockets raw socket API).
7* Use this to do "ping" or "traceroute," although beware that
8* Microsoft discourages its use.
9*/
10
11
12/* Note 2: For the most part, you can refer to RFC 791 for detials on
13* how to fill in values for the IP option information structure. */
14typedef struct ip_option_information {
15 u_char Ttl; /* Time To Live (used for traceroute) */
16 u_char Tos; /* Type Of Service (usually 0) */
17 u_char Flags; /* IP header flags (usually 0) */
18 u_char OptionsSize; /* Size of options data (usually 0, max 40) */
19 u_char FAR *OptionsData;/* Options data buffer */
20 }IPINFO, *PIPINFO, FAR *LPIPINFO;
21
22/* Note 1: The Reply Buffer will have an array of ICMP_ECHO_REPLY
23* structures, followed by options and the data in ICMP echo reply
24* datagram received. You must have room for at least one ICMP
25* echo reply structure, plus 8 bytes for an ICMP header. */
26typedef struct icmp_echo_reply {
27 u_long Address; /* source address */
28 u_long Status; /* IP status value (see below) */
29 u_long RTTime; /* Round Trip Time in milliseconds */
30 u_short DataSize; /* reply data size */
31 u_short Reserved; /* */
32 void FAR *Data; /* reply data buffer */
33 typedef struct ip_option_information Options; /* reply options */
34 }ICMPECHO, *PICMPECHO, FAR *LPICMPECHO;
35
36#define IP_STATUS_BASE 11000
37#define IP_SUCCESS 0
38#define IP_BUF_TOO_SMALL (IP_STATUS_BASE + 1)
39#define IP_DEST_NET_UNREACHABLE (IP_STATUS_BASE + 2)
40#define IP_DEST_HOST_UNREACHABLE (IP_STATUS_BASE + 3)
41#define IP_DEST_PROT_UNREACHABLE (IP_STATUS_BASE + 4)
42#define IP_DEST_PORT_UNREACHABLE (IP_STATUS_BASE + 5)
43#define IP_NO_RESOURCES (IP_STATUS_BASE + 6)
44#define IP_BAD_OPTION (IP_STATUS_BASE + 7)
45#define IP_HW_ERROR (IP_STATUS_BASE + 8)
46#define IP_PACKET_TOO_BIG (IP_STATUS_BASE + 9)
47#define IP_REQ_TIMED_OUT (IP_STATUS_BASE + 10)
48#define IP_BAD_REQ (IP_STATUS_BASE + 11)
49#define IP_BAD_ROUTE (IP_STATUS_BASE + 12)
50#define IP_TTL_EXPIRED_TRANSIT (IP_STATUS_BASE + 13)
51#define IP_TTL_EXPIRED_REASSEM (IP_STATUS_BASE + 14)
52#define IP_PARAM_PROBLEM (IP_STATUS_BASE + 15)
53#define IP_SOURCE_QUENCH (IP_STATUS_BASE + 16)
54#define IP_OPTION_TOO_BIG (IP_STATUS_BASE + 17)
55#define IP_BAD_DESTINATION (IP_STATUS_BASE + 18)
56#define IP_ADDR_DELETED (IP_STATUS_BASE + 19)
57#define IP_SPEC_MTU_CHANGE (IP_STATUS_BASE + 20)
58#define IP_MTU_CHANGE (IP_STATUS_BASE + 21)
59#define IP_UNLOAD (IP_STATUS_BASE + 22)
60#define IP_GENERAL_FAILURE (IP_STATUS_BASE + 50)
61#define MAX_IP_STATUS IP_GENERAL_FAILURE
62#define IP_PENDING (IP_STATUS_BASE + 255)
63
64
65HANDLE WINAPI PASCAL IcmpCreateFile(VOID); /* INVALID_HANDLE_VALUE on error */
66BOOL WINAPI PASCAL IcmpCloseHandle(HANDLE IcmpHandle); /* FALSE on error */
67DWORD WINAPI PASCAL IcmpSendEcho(
68 HANDLE IcmpHandle, /* handle returned from IcmpCreateFile() */
69 u_long DestAddress, /* destination IP address (in network order) */
70 LPVOID RequestData, /* pointer to buffer to send */
71 WORD RequestSize, /* length of data in buffer */
72 LPIPINFO RequestOptns, /* see Note 2 below */
73 LPVOID ReplyBuffer, /* see Note 1 below */
74 DWORD ReplySize, /* length of reply (must allow at least 1 reply) */
75 DWORD Timeout /* time in milliseconds to wait for reply */
76);
77
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 @@
1// stdafx.cpp : source file that includes just the standard includes
2 //PumpKIN.pch will be the pre-compiled header
3 //stdafx.obj will contain the pre-compiled type information
4
5#include "stdafx.h"
6
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 @@
1// stdafx.h : include file for standard system include files,
2// or project specific include files that are used frequently, but
3// are changed infrequently
4//
5
6 #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
7
8#include <afxwin.h> // MFC core and standard components
9#include <afxext.h> // MFC extensions
10#ifndef _AFX_NO_AFXCMN_SUPPORT
11 #include <afxcmn.h> // MFC support for Windows 95 Common Controls
12#endif // _AFX_NO_AFXCMN_SUPPORT
13
14#include <afxtempl.h>
15
16 #include <afxsock.h> // MFC socket extensions
17#include <MMSystem.h>
18// CG: The following line was added by the Windows Multimedia component.
19#pragma comment(lib, "winmm.lib")
20
21 enum{
22 WM_RESOLVED = WM_USER,
23 WM_TRAYICON
24};
25
26#include "shared-code/kHelpers.h"
27#include "shared-code/BellsNWhistles.h" \ No newline at end of file