├── .gitignore ├── ACLTargetCombo.cpp ├── ACLTargetCombo.h ├── AUTHORS ├── COPYING ├── ConfirmRRQDlg.cpp ├── ConfirmRRQDlg.h ├── ConfirmWRQDlg.cpp ├── ConfirmWRQDlg.h ├── KTAGS ├── PropsACL.cpp ├── PropsACL.h ├── PropsNetwork.cpp ├── PropsNetwork.h ├── PropsServer.cpp ├── PropsServer.h ├── PropsSounds.cpp ├── PropsSounds.h ├── PumpKINDlg.cpp ├── PumpKINDlg.h ├── README.RELEASE ├── RequestDlg.cpp ├── RequestDlg.h ├── Resolver.cpp ├── Resolver.h ├── Retrier.cpp ├── Retrier.h ├── Trayer.cpp ├── Trayer.h ├── help ├── pumpkin.bmp ├── pumpkin.cnt ├── pumpkin.hpj ├── pumpkin.rtf └── pumpkin.xml ├── install ├── Install.clw ├── custom.rch ├── install.cpp ├── install.rc └── resource.h ├── makehelp.bat ├── pumpkin.clw ├── pumpkin.cpp ├── pumpkin.h ├── pumpkin.mak ├── pumpkin.rc ├── res ├── down.ico ├── failed.wav ├── finished.wav ├── pumpkin.ico ├── pumpkin.rc2 ├── remove.ico ├── ring.wav ├── rrq.ico ├── up.ico └── wrq.ico ├── resource.h ├── shared-code ├── BTreendex.h ├── BellsNWhistles.h ├── BitSet.h ├── Dynamide.h ├── FindIFace.h ├── LRUCache.h ├── RegEx.cpp ├── RegEx.h ├── SNMPExtDll.h ├── SNMPOIDs.h ├── SNMPeer.h ├── install.h ├── ip_icmp.h ├── kHelpers.h ├── kICMP.cpp ├── kICMP.h ├── kinhelp.xsl └── ms_icmp.h ├── shared-data ├── browse-icon.ico ├── install-icon.ico ├── klever-background.bmp └── play-icon.ico ├── stdafx.cpp └── stdafx.h /.gitignore: -------------------------------------------------------------------------------- 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 38 | -------------------------------------------------------------------------------- /ACLTargetCombo.cpp: -------------------------------------------------------------------------------- 1 | // ACLTargetCombo.cpp : implementation file 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "PumpKIN.h" 6 | #include "PumpKINDlg.h" 7 | #include "ACLTargetCombo.h" 8 | 9 | #ifdef _DEBUG 10 | #define new DEBUG_NEW 11 | #undef THIS_FILE 12 | static char THIS_FILE[] = __FILE__; 13 | #endif 14 | 15 | ///////////////////////////////////////////////////////////////////////////// 16 | // CACLTargetCombo 17 | 18 | CACLTargetCombo::CACLTargetCombo() 19 | : m_op(-1) 20 | { 21 | } 22 | 23 | CACLTargetCombo::~CACLTargetCombo() 24 | { 25 | } 26 | 27 | 28 | BEGIN_MESSAGE_MAP(CACLTargetCombo, CComboBox) 29 | //{{AFX_MSG_MAP(CACLTargetCombo) 30 | // NOTE - the ClassWizard will add and remove mapping macros here. 31 | //}}AFX_MSG_MAP 32 | END_MESSAGE_MAP() 33 | 34 | ///////////////////////////////////////////////////////////////////////////// 35 | // CACLTargetCombo message handlers 36 | 37 | void CACLTargetCombo::SetOp(int op) 38 | { 39 | m_op=op; 40 | ResetContent(); 41 | switch(op) { 42 | case tftp::opRRQ: 43 | m_tmap.RemoveAll(); 44 | SetItemData(m_tmap[acl_rule::rrqNone]=AddString("fallback to global"),acl_rule::rrqNone); 45 | SetItemData(m_tmap[acl_rule::rrqDeny]=AddString("deny access"),acl_rule::rrqDeny); 46 | SetItemData(m_tmap[acl_rule::rrqPrompt]=AddString("prompt"),acl_rule::rrqPrompt); 47 | SetItemData(m_tmap[acl_rule::rrqGrant]=AddString("grant access"),CPumpKINDlg::rrqGrant); 48 | SetCurSel(0); 49 | EnableWindow(TRUE); 50 | break; 51 | case tftp::opWRQ: 52 | m_tmap.RemoveAll(); 53 | SetItemData(m_tmap[acl_rule::wrqNone]=AddString("fallback to global"),acl_rule::wrqNone); 54 | SetItemData(m_tmap[acl_rule::wrqDeny]=AddString("deny access"),acl_rule::wrqDeny); 55 | SetItemData(m_tmap[acl_rule::wrqPrompt]=AddString("prompt"),acl_rule::wrqPrompt); 56 | SetItemData(m_tmap[acl_rule::wrqPromptIfExists]=AddString("prompt if file exists"),acl_rule::wrqPromptIfExists); 57 | SetItemData(m_tmap[acl_rule::wrqGrant]=AddString("grant access"),acl_rule::wrqGrant); 58 | SetCurSel(0); 59 | EnableWindow(TRUE); 60 | break; 61 | default: 62 | EnableWindow(FALSE); 63 | break; 64 | } 65 | } 66 | 67 | int CACLTargetCombo::GetTarget() 68 | { 69 | int cs=GetCurSel(); 70 | if(cs==CB_ERR) 71 | return -1; 72 | return GetItemData(cs); 73 | } 74 | 75 | void CACLTargetCombo::SetTarget(int t,int op) 76 | { 77 | if(op>=0) 78 | SetOp(op); 79 | ASSERT(m_op>=0); 80 | int i; 81 | if(m_tmap.Lookup(t,i)) 82 | SetCurSel(i); 83 | else 84 | SetCurSel(0); 85 | } 86 | -------------------------------------------------------------------------------- /ACLTargetCombo.h: -------------------------------------------------------------------------------- 1 | // ACLTargetCombo.h : header file 2 | // 3 | 4 | ///////////////////////////////////////////////////////////////////////////// 5 | // CACLTargetCombo window 6 | 7 | class CACLTargetCombo : public CComboBox 8 | { 9 | // Construction 10 | public: 11 | void SetTarget(int t,int op=-1); 12 | int GetTarget(); 13 | void SetOp(int op); 14 | int m_op; 15 | CACLTargetCombo(); 16 | 17 | // Attributes 18 | public: 19 | CMap m_tmap; 20 | 21 | // Operations 22 | public: 23 | 24 | // Overrides 25 | // ClassWizard generated virtual function overrides 26 | //{{AFX_VIRTUAL(CACLTargetCombo) 27 | //}}AFX_VIRTUAL 28 | 29 | // Implementation 30 | public: 31 | virtual ~CACLTargetCombo(); 32 | 33 | // Generated message map functions 34 | protected: 35 | //{{AFX_MSG(CACLTargetCombo) 36 | // NOTE - the ClassWizard will add and remove member functions here. 37 | //}}AFX_MSG 38 | 39 | DECLARE_MESSAGE_MAP() 40 | }; 41 | 42 | ///////////////////////////////////////////////////////////////////////////// 43 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Klever dissected: 2 | Michael 'hacker' Krelin 3 | Leonid Ivanov 4 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 1997-2006 Klever Group (http://www.klever.net/) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | -------------------------------------------------------------------------------- /ConfirmRRQDlg.cpp: -------------------------------------------------------------------------------- 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 12 | static char THIS_FILE[] = __FILE__; 13 | #endif 14 | 15 | ///////////////////////////////////////////////////////////////////////////// 16 | // CConfirmRRQDlg dialog 17 | 18 | 19 | CConfirmRRQDlg::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 | 30 | void 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 | 40 | BEGIN_MESSAGE_MAP(CConfirmRRQDlg, CDialog) 41 | //{{AFX_MSG_MAP(CConfirmRRQDlg) 42 | ON_WM_TIMER() 43 | //}}AFX_MSG_MAP 44 | END_MESSAGE_MAP() 45 | 46 | ///////////////////////////////////////////////////////////////////////////// 47 | // CConfirmRRQDlg message handlers 48 | 49 | BOOL 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 | 62 | void CConfirmRRQDlg::OnTimer(UINT nIDEvent) 63 | { 64 | if(nIDEvent==1) 65 | EndDialog(IDCANCEL); 66 | CDialog::OnTimer(nIDEvent); 67 | } 68 | -------------------------------------------------------------------------------- /ConfirmRRQDlg.h: -------------------------------------------------------------------------------- 1 | // ConfirmRRQDlg.h : header file 2 | // 3 | 4 | ///////////////////////////////////////////////////////////////////////////// 5 | // CConfirmRRQDlg dialog 6 | 7 | class CRRQSocket; 8 | class CConfirmRRQDlg : public CDialog 9 | { 10 | // Construction 11 | public: 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 | CString m_File; 19 | CString m_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 31 | protected: 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 | }; 40 | -------------------------------------------------------------------------------- /ConfirmWRQDlg.cpp: -------------------------------------------------------------------------------- 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 13 | static char THIS_FILE[] = __FILE__; 14 | #endif 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // CConfirmWRQDlg dialog 18 | 19 | 20 | CConfirmWRQDlg::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 | 30 | void 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 | 43 | BEGIN_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 49 | END_MESSAGE_MAP() 50 | 51 | ///////////////////////////////////////////////////////////////////////////// 52 | // CConfirmWRQDlg message handlers 53 | 54 | void CConfirmWRQDlg::OnRename() 55 | { 56 | EndDialog(IDC_RENAME); 57 | } 58 | 59 | BOOL 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 | 79 | void CConfirmWRQDlg::OnTimer(UINT nIDEvent) 80 | { 81 | if(nIDEvent==1) 82 | EndDialog(IDCANCEL); 83 | CDialog::OnTimer(nIDEvent); 84 | } 85 | 86 | void CConfirmWRQDlg::OnResume() 87 | { 88 | EndDialog(IDC_RESUME); 89 | } 90 | -------------------------------------------------------------------------------- /ConfirmWRQDlg.h: -------------------------------------------------------------------------------- 1 | // ConfirmWRQDlg.h : header file 2 | // 3 | 4 | ///////////////////////////////////////////////////////////////////////////// 5 | // CConfirmWRQDlg dialog 6 | 7 | class CWRQSocket; 8 | class CConfirmWRQDlg : public CDialog 9 | { 10 | // Construction 11 | public: 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 | CButton m_ResumeCtl; 19 | CButton m_OkCtl; 20 | CButton m_RenameCtl; 21 | CString m_File; 22 | CString m_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 34 | protected: 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 | }; 45 | -------------------------------------------------------------------------------- /KTAGS: -------------------------------------------------------------------------------- 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 /LoadIcon(IDI_RRQ)); 72 | m_iWRQ = m_Images.Add(AfxGetApp()->LoadIcon(IDI_WRQ)); 73 | ASSERT(m_iRRQ>=0); ASSERT(m_iWRQ>=0); 74 | m_ListCtl.SetImageList(&m_Images,LVSIL_NORMAL); 75 | m_ListCtl.SetImageList(&m_Images,LVSIL_SMALL); 76 | m_ListCtl.SetImageList(&m_Images,LVSIL_STATE); 77 | 78 | CRect lrc; m_ListCtl.GetClientRect(&lrc); 79 | long lrcw3 = lrc.Width()/3; 80 | m_ListCtl.InsertColumn(0,"IP",LVCFMT_LEFT,lrcw3,subitemIP); 81 | m_ListCtl.InsertColumn(1,"netmask",LVCFMT_LEFT,lrcw3,subitemNM); 82 | m_ListCtl.InsertColumn(2,"action",LVCFMT_LEFT,lrc.Width()-lrcw3*2,subitemAction); 83 | 84 | m_UpCtl.SetIcon(AfxGetApp()->LoadIcon(IDI_UP)); 85 | m_DownCtl.SetIcon(AfxGetApp()->LoadIcon(IDI_DOWN)); 86 | m_RemoveCtl.SetIcon(AfxGetApp()->LoadIcon(IDI_REMOVE)); 87 | 88 | m_XferCtl.SetItemData(0,tftp::opRRQ); 89 | m_XferCtl.SetItemData(1,tftp::opWRQ); 90 | 91 | m_AddrCtl.SetWindowText("192.168.0.0"); 92 | m_NetmaskCtl.SetWindowText("255.255.255.0"); 93 | 94 | for(int i=0;iuChanged&LVIF_STATE) 119 | && 120 | (pNMListView->uNewState&LVIS_FOCUSED)!=(pNMListView->uOldState&LVIS_FOCUSED) 121 | && 122 | pNMListView->iItem>=0 && pNMListView->iItemuNewState&LVIS_FOCUSED) 125 | m_FocusedRule=pNMListView->iItem; 126 | else if(pNMListView->iItem==m_FocusedRule) 127 | m_FocusedRule=-1; 128 | UpdateControls(); 129 | } 130 | 131 | *pResult = 0; 132 | } 133 | 134 | void CPropsACL::UpdateControls() { 135 | if(m_FocusedRule>=m_rulist.GetSize()) 136 | m_FocusedRule=-1; 137 | if(m_FocusedRule>=0) { 138 | m_UpCtl.EnableWindow(m_FocusedRule>0); 139 | m_DownCtl.EnableWindow(m_FocusedRule<(m_ListCtl.GetItemCount()-1)); 140 | acl_rule r; 141 | GetListRule(m_FocusedRule,r); 142 | SetRule(r); 143 | m_AddCtl.EnableWindow(TRUE); 144 | m_ReplaceCtl.EnableWindow(TRUE); 145 | }else{ 146 | OnSelchangeAclXfer(); 147 | m_AddCtl.EnableWindow(TRUE); 148 | m_ReplaceCtl.EnableWindow(FALSE); 149 | } 150 | m_RemoveCtl.EnableWindow(m_ListCtl.GetSelectedCount()!=0 || m_FocusedRule>=0); 151 | } 152 | 153 | void CPropsACL::OnAclAdd() { 154 | acl_rule r; 155 | UINT err=GetRule(r); 156 | if(err) { 157 | AfxMessageBox(err,MB_OK); 158 | }else{ 159 | int i=m_rulist.AppendRule(r); 160 | ASSERT(r.op==acl_rule::opRRQ || r.op==acl_rule::opWRQ); 161 | m_ListCtl.InsertItem(i,0); 162 | SetListRule(i,r); 163 | } 164 | } 165 | 166 | void CPropsACL::OnAclReplace() { 167 | acl_rule r; 168 | UINT err=GetRule(r); 169 | if(err) { 170 | AfxMessageBox(err,MB_OK); 171 | }else{ 172 | ASSERT(m_FocusedRule>=0); 173 | m_rulist[m_FocusedRule]=r; 174 | SetListRule(m_FocusedRule,r); 175 | } 176 | } 177 | 178 | int CPropsACL::GetOp() { 179 | int cs=m_XferCtl.GetCurSel(); 180 | if(cs==CB_ERR) 181 | return -1; 182 | else 183 | return m_XferCtl.GetItemData(cs); 184 | } 185 | 186 | void CPropsACL::SetOp(int op) { 187 | int os=m_XferCtl.GetCount(); 188 | for(int i=0;i=0); 241 | int fr=m_FocusedRule; 242 | if(fr<0 || fr>=m_rulist.GetSize()) return; 243 | m_rulist.DeleteRule(fr); 244 | m_ListCtl.DeleteItem(fr); 245 | ASSERT(m_rulist.GetSize()==m_ListCtl.GetItemCount()); 246 | if(fr>=m_rulist.GetSize()) { 247 | if(fr>0) { 248 | fr=m_rulist.GetSize()-1; 249 | } 250 | }else 251 | fr=-1; 252 | if(fr>0) 253 | SetListFocusSelection(fr); 254 | m_ListCtl.SetFocus(); 255 | } 256 | 257 | void CPropsACL::OnAclUp() { 258 | int s=m_FocusedRule; 259 | if(s<=0) return; 260 | int d=s-1; 261 | acl_rule r=m_rulist[s]; 262 | m_rulist[s]=m_rulist[d]; 263 | m_rulist[d]=r; 264 | SetListRule(d,m_rulist[d]); 265 | SetListRule(s,m_rulist[s]); 266 | SetListFocusSelection(d); 267 | m_ListCtl.SetFocus(); 268 | } 269 | 270 | void CPropsACL::OnAclDown() { 271 | int s=m_FocusedRule; 272 | int d=s+1; 273 | if(s<0 || d>=m_rulist.GetSize()) return; 274 | acl_rule r=m_rulist[s]; 275 | m_rulist[s]=m_rulist[d]; 276 | m_rulist[d]=r; 277 | SetListRule(d,m_rulist[d]); 278 | SetListRule(s,m_rulist[s]); 279 | SetListFocusSelection(d); 280 | m_ListCtl.SetFocus(); 281 | } 282 | 283 | void CPropsACL::SetListFocusSelection(int i) { 284 | int s=m_ListCtl.GetItemCount(); 285 | for(int t=0;tm_bSaveAndValidate) 48 | m_PromptTimeOut=m_PromptTimeoutCtl.GetPos(); 49 | else 50 | m_PromptTimeoutCtl.SetPos(m_PromptTimeOut); 51 | } 52 | 53 | 54 | BEGIN_MESSAGE_MAP(CPropsServer, CPropertyPage) 55 | //{{AFX_MSG_MAP(CPropsServer) 56 | ON_BN_CLICKED(IDC_BROWSE, OnBrowse) 57 | ON_BN_CLICKED(IDC_LOGFILE_BROWSE, OnLogfileBrowse) 58 | //}}AFX_MSG_MAP 59 | END_MESSAGE_MAP() 60 | 61 | ///////////////////////////////////////////////////////////////////////////// 62 | // CPropsServer message handlers 63 | 64 | BOOL CPropsServer::OnInitDialog() 65 | { 66 | CPropertyPage::OnInitDialog(); 67 | 68 | m_PromptTimeoutCtl.SetRange(5,60); 69 | m_BrowseCtl.SetIcon(AfxGetApp()->LoadIcon(IDI_BROWSE)); 70 | m_LogBrowseCtl.SetIcon(AfxGetApp()->LoadIcon(IDI_BROWSE)); 71 | 72 | return TRUE; // return TRUE unless you set the focus to a control 73 | // EXCEPTION: OCX Property Pages should return FALSE 74 | } 75 | 76 | void CPropsServer::OnBrowse() 77 | { 78 | CString nr = m_TFTPRoot; 79 | if(Klever::BrowseForFolder(nr,IDS_SELECT_TFTPROOT,this)){ 80 | UpdateData(TRUE); 81 | m_TFTPRoot=nr; 82 | UpdateData(FALSE); 83 | } 84 | } 85 | 86 | void CPropsServer::OnLogfileBrowse() 87 | { 88 | UpdateData(TRUE); 89 | CFileDialog cfd( 90 | FALSE, ".log", (LPCSTR)m_LogFile, 91 | OFN_EXPLORER|OFN_HIDEREADONLY|OFN_LONGNAMES|OFN_NOCHANGEDIR|OFN_OVERWRITEPROMPT|OFN_PATHMUSTEXIST, 92 | "Log files (*.log)|*.log|All Files (*.*)|*.*||", 93 | this); 94 | if(cfd.DoModal()==IDOK) { 95 | m_LogFile = cfd.GetPathName(); 96 | UpdateData(FALSE); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /PropsServer.h: -------------------------------------------------------------------------------- 1 | // PropsServer.h : header file 2 | // 3 | 4 | ///////////////////////////////////////////////////////////////////////////// 5 | // CPropsServer dialog 6 | 7 | class CPropsServer : public CPropertyPage 8 | { 9 | DECLARE_DYNCREATE(CPropsServer) 10 | 11 | // Construction 12 | public: 13 | UINT m_PromptTimeOut; 14 | CPropsServer(); 15 | ~CPropsServer(); 16 | 17 | // Dialog Data 18 | //{{AFX_DATA(CPropsServer) 19 | enum { IDD = IDD_PROPS_SERVER }; 20 | CButton m_LogBrowseCtl; 21 | CButton m_BrowseCtl; 22 | CSliderCtrl m_PromptTimeoutCtl; 23 | int m_RRQMode; 24 | CString m_TFTPRoot; 25 | BOOL m_TFTPSubdirs; 26 | int m_WRQMode; 27 | CString m_LogFile; 28 | //}}AFX_DATA 29 | 30 | 31 | // Overrides 32 | // ClassWizard generate virtual function overrides 33 | //{{AFX_VIRTUAL(CPropsServer) 34 | protected: 35 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 36 | //}}AFX_VIRTUAL 37 | 38 | // Implementation 39 | protected: 40 | // Generated message map functions 41 | //{{AFX_MSG(CPropsServer) 42 | virtual BOOL OnInitDialog(); 43 | afx_msg void OnBrowse(); 44 | afx_msg void OnLogfileBrowse(); 45 | //}}AFX_MSG 46 | DECLARE_MESSAGE_MAP() 47 | 48 | }; 49 | -------------------------------------------------------------------------------- /PropsSounds.cpp: -------------------------------------------------------------------------------- 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 12 | static char THIS_FILE[] = __FILE__; 13 | #endif 14 | 15 | ///////////////////////////////////////////////////////////////////////////// 16 | // CPropsSounds property page 17 | 18 | IMPLEMENT_DYNCREATE(CPropsSounds, CPropertyPage) 19 | 20 | CPropsSounds::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 | 29 | CPropsSounds::~CPropsSounds() 30 | { 31 | } 32 | 33 | void 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 | 53 | BEGIN_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 62 | END_MESSAGE_MAP() 63 | 64 | ///////////////////////////////////////////////////////////////////////////// 65 | // CPropsSounds message handlers 66 | 67 | BOOL CPropsSounds::OnInitDialog() 68 | { 69 | CPropertyPage::OnInitDialog(); 70 | 71 | HICON hP = AfxGetApp()->LoadIcon(IDI_PLAY); 72 | HICON 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 | 80 | CPumpKINDlg* 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 | 92 | void CPropsSounds::OnAbortedBrowse() 93 | { 94 | Browse(m_AbortCtl); 95 | } 96 | void CPropsSounds::OnFinishedBrowse() 97 | { 98 | Browse(m_SuccessCtl); 99 | } 100 | void CPropsSounds::OnRingBrowse() 101 | { 102 | Browse(m_RequestCtl); 103 | } 104 | 105 | void CPropsSounds::OnAbortedPlay() 106 | { 107 | Play(m_AbortCtl); 108 | } 109 | 110 | void CPropsSounds::OnFinishedPlay() 111 | { 112 | Play(m_SuccessCtl); 113 | } 114 | 115 | void CPropsSounds::OnRingPlay() 116 | { 117 | Play(m_RequestCtl); 118 | } 119 | 120 | void CPropsSounds::Browse(CComboBox& ctl) 121 | { 122 | CString f; 123 | ctl.GetWindowText(f); 124 | CString filter; 125 | filter.LoadString(IDS_FILTER_WAV); 126 | CFileDialog fd(TRUE,NULL,(LPCTSTR)f, 127 | OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY 128 | |OFN_LONGNAMES|OFN_NOCHANGEDIR|OFN_PATHMUSTEXIST, 129 | filter,this); 130 | CString 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 | 137 | void CPropsSounds::Play(CComboBox& ctl) 138 | { 139 | CString s; 140 | ctl.GetWindowText(s); 141 | CBellsNWhistles::Whistling w = m_bnw->StartSound(s); 142 | if(w){ 143 | Sleep(5000); 144 | m_bnw->StopSound(w); 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /PropsSounds.h: -------------------------------------------------------------------------------- 1 | // PropsSounds.h : header file 2 | // 3 | 4 | ///////////////////////////////////////////////////////////////////////////// 5 | // CPropsSounds dialog 6 | 7 | class CPropsSounds : public CPropertyPage 8 | { 9 | DECLARE_DYNCREATE(CPropsSounds) 10 | 11 | // Construction 12 | public: 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 | CButton m_RequestPlayCtl; 23 | CButton m_RequestBrowseCtl; 24 | CComboBox m_RequestCtl; 25 | CButton m_SuccessPlayCtl; 26 | CButton m_SuccessBrowseCtl; 27 | CComboBox m_SuccessCtl; 28 | CButton m_AbortPlayCtl; 29 | CButton m_AbortBrowseCtl; 30 | CComboBox m_AbortCtl; 31 | CString m_Abort; 32 | CString m_Success; 33 | CString m_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 45 | protected: 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 | }; 59 | -------------------------------------------------------------------------------- /README.RELEASE: -------------------------------------------------------------------------------- 1 | 2 | Before compiling canned install executable the following files should be placed 3 | in the build tree: 4 | 5 | redist/mfc42.dl_ 6 | 7 | Release 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 | 13 | Version 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 | 22 | If 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 | 32 | This is for vim (don't remove): 33 | vim:set tags=KTAGS isk=!-~,^*,^\|,^\" ft=help: 34 | -------------------------------------------------------------------------------- /RequestDlg.cpp: -------------------------------------------------------------------------------- 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 11 | static char THIS_FILE[] = __FILE__; 12 | #endif 13 | 14 | ///////////////////////////////////////////////////////////////////////////// 15 | // CRequestDlg dialog 16 | 17 | 18 | CRequestDlg::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 | 33 | void 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 | 55 | CString CRequestDlg::m_MRUHost; 56 | 57 | BEGIN_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 68 | END_MESSAGE_MAP() 69 | 70 | ///////////////////////////////////////////////////////////////////////////// 71 | // CRequestDlg message handlers 72 | 73 | BOOL 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 | 80 | CString 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 | 120 | void CRequestDlg::OnRefresh() 121 | { 122 | m_TalksCtl.ResetContent(); 123 | CWnd *wnd = CWnd::FindWindow(NULL,NULL); 124 | CString wtalkHead,wtalkAt; 125 | wtalkHead.LoadString(IDS_WTALKHEADING);wtalkAt.LoadString(IDS_WTALKAT); 126 | CString 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 | 163 | void CRequestDlg::OnBrowse() 164 | { 165 | UpdateData(TRUE); 166 | CFileDialog cfd(m_Put,NULL,m_LocalFile.IsEmpty()?NULL:m_LocalFile,OFN_EXPLORER|OFN_HIDEREADONLY|OFN_PATHMUSTEXIST|(m_Put?OFN_FILEMUSTEXIST:OFN_OVERWRITEPROMPT),NULL,this); 167 | CString 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 | 178 | void 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 | 209 | void CRequestDlg::OnChangeLocalfile() 210 | { 211 | if(m_Put) 212 | SyncNames(); 213 | UpdateOK(); 214 | } 215 | 216 | void CRequestDlg::OnChangeRemotefile() 217 | { 218 | if(!m_Put) 219 | SyncNames(); 220 | UpdateOK(); 221 | } 222 | 223 | void CRequestDlg::UpdateOK() 224 | { 225 | CString t; 226 | m_LocalFileCtl.GetWindowText(t); 227 | if(t.IsEmpty()) 228 | goto dAble; 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; 237 | dAble: 238 | m_OKCtl.EnableWindow(FALSE); 239 | } 240 | 241 | void CRequestDlg::OnEditchangeTalks() 242 | { 243 | UpdateOK(); 244 | } 245 | 246 | void CRequestDlg::OnSelchangeTalks() 247 | { 248 | UpdateOK(); 249 | } 250 | 251 | HBRUSH CRequestDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 252 | { 253 | HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); 254 | UpdateOK(); 255 | return hbr; 256 | } 257 | 258 | BOOL 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 | 270 | int CRequestDlg::DoModal() 271 | { 272 | int rv = CDialog::DoModal(); 273 | if(rv==IDOK) 274 | m_MRUHost=m_Host; 275 | return rv; 276 | } 277 | 278 | void CRequestDlg::OnDropFiles(HDROP hDropInfo) 279 | { 280 | UINT 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); 291 | CString theFile; 292 | UINT 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 | } 300 | -------------------------------------------------------------------------------- /RequestDlg.h: -------------------------------------------------------------------------------- 1 | // RequestDlg.h : header file 2 | // 3 | 4 | ///////////////////////////////////////////////////////////////////////////// 5 | // CRequestDlg dialog 6 | 7 | class CRequestDlg : public CDialog 8 | { 9 | // Construction 10 | public: 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 | CEdit m_RemoteFileCtl; 24 | CEdit m_LocalFileCtl; 25 | CButton m_RefreshCtl; 26 | CButton m_OKCtl; 27 | CComboBox m_TalksCtl; 28 | CButton m_BrowseCtl; 29 | CString m_Host; 30 | CString m_LocalFile; 31 | CString m_RemoteFile; 32 | CString m_Type; 33 | CString m_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 47 | protected: 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 | }; 64 | -------------------------------------------------------------------------------- /Resolver.cpp: -------------------------------------------------------------------------------- 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 12 | static char THIS_FILE[] = __FILE__; 13 | #endif 14 | 15 | ///////////////////////////////////////////////////////////////////////////// 16 | // CResolver 17 | 18 | CResolver::CResolver() 19 | { 20 | ASSERT(NULL); 21 | } 22 | 23 | CResolver::~CResolver() 24 | { 25 | } 26 | 27 | 28 | BEGIN_MESSAGE_MAP(CResolver, CWnd) 29 | //{{AFX_MSG_MAP(CResolver) 30 | ON_WM_CREATE() 31 | ON_MESSAGE(WM_RESOLVED, OnResolved) 32 | //}}AFX_MSG_MAP 33 | END_MESSAGE_MAP() 34 | 35 | 36 | ///////////////////////////////////////////////////////////////////////////// 37 | // CResolver message handlers 38 | 39 | CResolver::CResolver(CXferSocket *socket) 40 | : socket(socket) 41 | { 42 | } 43 | 44 | int CResolver::OnCreate(LPCREATESTRUCT lpCreateStruct) 45 | { 46 | if (CWnd::OnCreate(lpCreateStruct) == -1) 47 | return -1; 48 | 49 | ASSERT(socket); 50 | CString hostName = socket->m_HostName; 51 | int 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 | 59 | LRESULT CResolver::OnResolved(WPARAM wP,LPARAM lP) 60 | { 61 | if(WSAGETASYNCERROR(lP)) 62 | socket->OnFailedToResolve(); 63 | else 64 | socket->OnResolved(); 65 | return 0; 66 | } 67 | 68 | BOOL CResolver::Resolve() 69 | { 70 | return Create(NULL,"PumpKIN-Resolver",WS_CHILD,CRect(0,0,0,0),socket->m_Daddy,0); 71 | } 72 | -------------------------------------------------------------------------------- /Resolver.h: -------------------------------------------------------------------------------- 1 | // Resolver.h : header file 2 | // 3 | 4 | ///////////////////////////////////////////////////////////////////////////// 5 | // CResolver window 6 | 7 | class CXferSocket; 8 | class CResolver : public CWnd 9 | { 10 | // Construction 11 | public: 12 | BOOL Resolve(); 13 | HANDLE m_hAsync; 14 | CResolver(CXferSocket *socket); 15 | CXferSocket* socket; 16 | CResolver(); 17 | 18 | // Attributes 19 | public: 20 | 21 | // Operations 22 | public: 23 | 24 | // Overrides 25 | // ClassWizard generated virtual function overrides 26 | //{{AFX_VIRTUAL(CResolver) 27 | //}}AFX_VIRTUAL 28 | 29 | // Implementation 30 | public: 31 | virtual ~CResolver(); 32 | 33 | // Generated message map functions 34 | protected: 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 | ///////////////////////////////////////////////////////////////////////////// 43 | -------------------------------------------------------------------------------- /Retrier.cpp: -------------------------------------------------------------------------------- 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 13 | static char THIS_FILE[] = __FILE__; 14 | #endif 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // CRetrier 18 | 19 | CRetrier::CRetrier(CPumpKINDlg *daddy) 20 | : m_Daddy(daddy) 21 | { 22 | } 23 | 24 | CRetrier::~CRetrier() 25 | { 26 | } 27 | 28 | 29 | BEGIN_MESSAGE_MAP(CRetrier, CWnd) 30 | //{{AFX_MSG_MAP(CRetrier) 31 | ON_WM_TIMER() 32 | //}}AFX_MSG_MAP 33 | END_MESSAGE_MAP() 34 | 35 | 36 | ///////////////////////////////////////////////////////////////////////////// 37 | // CRetrier message handlers 38 | 39 | void CRetrier::OnTimer(UINT nIDEvent) 40 | { 41 | ASSERT(m_Daddy); 42 | CXferSocket *socket; 43 | if(m_Daddy->m_Xfers.Lookup(nIDEvent,socket)) 44 | socket->OnRetry(); 45 | CWnd::OnTimer(nIDEvent); 46 | } 47 | -------------------------------------------------------------------------------- /Retrier.h: -------------------------------------------------------------------------------- 1 | // Retrier.h : header file 2 | // 3 | 4 | ///////////////////////////////////////////////////////////////////////////// 5 | // CRetrier window 6 | 7 | class CPumpKINDlg; 8 | class CRetrier : public CWnd 9 | { 10 | // Construction 11 | public: 12 | CPumpKINDlg* m_Daddy; 13 | CRetrier(CPumpKINDlg *daddy); 14 | 15 | // Attributes 16 | public: 17 | 18 | // Operations 19 | public: 20 | 21 | // Overrides 22 | // ClassWizard generated virtual function overrides 23 | //{{AFX_VIRTUAL(CRetrier) 24 | //}}AFX_VIRTUAL 25 | 26 | // Implementation 27 | public: 28 | virtual ~CRetrier(); 29 | 30 | // Generated message map functions 31 | protected: 32 | //{{AFX_MSG(CRetrier) 33 | afx_msg void OnTimer(UINT nIDEvent); 34 | //}}AFX_MSG 35 | DECLARE_MESSAGE_MAP() 36 | }; 37 | 38 | ///////////////////////////////////////////////////////////////////////////// 39 | -------------------------------------------------------------------------------- /Trayer.cpp: -------------------------------------------------------------------------------- 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 13 | static char THIS_FILE[] = __FILE__; 14 | #endif 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // CTrayer 18 | 19 | CTrayer::CTrayer() 20 | { 21 | m_inMenu=0; 22 | } 23 | 24 | CTrayer::~CTrayer() 25 | { 26 | } 27 | 28 | 29 | BEGIN_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 | ON_COMMAND(ID_TRAY_LISTEN, OnTrayListen) 41 | //}}AFX_MSG_MAP 42 | END_MESSAGE_MAP() 43 | 44 | 45 | ///////////////////////////////////////////////////////////////////////////// 46 | // CTrayer message handlers 47 | 48 | CTrayer::CTrayer(CPumpKINDlg* daddy) 49 | : m_Daddy(daddy) 50 | { 51 | m_inMenu=0; 52 | } 53 | 54 | LRESULT CTrayer::OnTray(WPARAM wP,LPARAM lP) 55 | { 56 | ASSERT(wP==IDC_TRAYICON); 57 | switch(lP){ 58 | case WM_RBUTTONDOWN: 59 | { 60 | CMenu menu; 61 | VERIFY(menu.LoadMenu(IDM_POPUPS)); 62 | CMenu *popUp = menu.GetSubMenu(0); 63 | ASSERT(popUp); 64 | CPoint pt; 65 | VERIFY(::GetCursorPos(&pt)); 66 | m_inMenu++; 67 | SetForegroundWindow(); 68 | popUp->CheckMenuItem(ID_TRAY_SHOWPUMPKINWINDOW,MF_BYCOMMAND|(IsWindowVisible()?MF_CHECKED:MF_UNCHECKED)); 69 | popUp->CheckMenuItem(ID_TRAY_LISTEN,MF_BYCOMMAND|(m_Daddy->m_Listener.m_bListen?MF_CHECKED:MF_UNCHECKED)); 70 | popUp->TrackPopupMenu(TPM_RIGHTALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON,pt.x,pt.y,this); 71 | m_inMenu--; 72 | SendMessage(WM_NULL); 73 | } 74 | break; 75 | case WM_LBUTTONDOWN: 76 | m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_SHOWPUMPKINWINDOW); 77 | break; 78 | } 79 | return 0; 80 | } 81 | 82 | void CTrayer::OnTrayAboutpumpkin() 83 | { 84 | m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_ABOUTPUMPKIN); 85 | } 86 | 87 | void CTrayer::OnTrayExit() 88 | { 89 | m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_EXIT); 90 | } 91 | 92 | void CTrayer::OnTrayFetchfile() 93 | { 94 | m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_FETCHFILE); 95 | } 96 | 97 | void CTrayer::OnTrayHelp() 98 | { 99 | m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_HELP); 100 | } 101 | 102 | void CTrayer::OnTrayOpenfilesfolder() 103 | { 104 | m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_OPENFILESFOLDER); 105 | } 106 | 107 | void CTrayer::OnTrayOptions() 108 | { 109 | m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_OPTIONS); 110 | } 111 | 112 | void CTrayer::OnTraySendfile() 113 | { 114 | m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_SENDFILE); 115 | } 116 | 117 | void CTrayer::OnTrayShowpumpkinwindow() 118 | { 119 | m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_SHOWPUMPKINWINDOW); 120 | } 121 | 122 | void CTrayer::OnTrayListen() 123 | { 124 | m_Daddy->SendMessage(WM_COMMAND,ID_TRAY_LISTEN); 125 | } 126 | -------------------------------------------------------------------------------- /Trayer.h: -------------------------------------------------------------------------------- 1 | // Trayer.h : header file 2 | // 3 | 4 | ///////////////////////////////////////////////////////////////////////////// 5 | // CTrayer window 6 | 7 | class CPumpKINDlg; 8 | class CTrayer : public CWnd 9 | { 10 | // Construction 11 | public: 12 | int m_inMenu; 13 | CPumpKINDlg* m_Daddy; 14 | CTrayer(CPumpKINDlg* daddy); 15 | CTrayer(); 16 | 17 | // Attributes 18 | public: 19 | 20 | // Operations 21 | public: 22 | 23 | // Overrides 24 | // ClassWizard generated virtual function overrides 25 | //{{AFX_VIRTUAL(CTrayer) 26 | //}}AFX_VIRTUAL 27 | 28 | // Implementation 29 | public: 30 | virtual ~CTrayer(); 31 | 32 | // Generated message map functions 33 | protected: 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 void OnTrayListen(); 45 | //}}AFX_MSG 46 | DECLARE_MESSAGE_MAP() 47 | }; 48 | 49 | ///////////////////////////////////////////////////////////////////////////// 50 | -------------------------------------------------------------------------------- /help/pumpkin.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klevernothings/pumpkin/13a91d9b1723628301f9ace03e53a592ed4dda4a/help/pumpkin.bmp -------------------------------------------------------------------------------- /help/pumpkin.cnt: -------------------------------------------------------------------------------- 1 | :Base PumpKIN.hlp>Standard 2 | :Title PumpKIN 3 | 1 PumpKIN 4 | 2 About PumpKIN=About 5 | 2 What's New=News 6 | 2 Using PumpKIN=Using 7 | 1 PumpKIN Dialogs 8 | 2 Confirm Read Request Dialog=ConfirmRRQ 9 | 2 Confirm Write Request Dialog=ConfirmWRQ 10 | 2 Request Dialog=Request 11 | 1 PumpKIN Options 12 | 2 Server Options=ServerOptions 13 | 2 Network Options=NetworkOptions 14 | 2 Sounds Options=SoundsOptions 15 | 2 Access Lists=ACL 16 | -------------------------------------------------------------------------------- /help/pumpkin.hpj: -------------------------------------------------------------------------------- 1 | ; This file is maintained by HCW. Do not modify this file directly. 2 | 3 | [OPTIONS] 4 | COMPRESS=12 Hall Zeck 5 | LCID=0x409 0x0 0x0 ; English (United States) 6 | REPORT=Yes 7 | CONTENTS=Using 8 | TITLE=PumpKIN 9 | CNT=pumpkin.cnt 10 | HLP=PUMPKIN.HLP 11 | 12 | [FILES] 13 | pumpkin.rtf 14 | 15 | [MAP] 16 | #include pumpkin.hm 17 | 18 | [WINDOWS] 19 | Standard="",(2,6,732,884),20740,(r14876671),(r12632256),f2 20 | -------------------------------------------------------------------------------- /help/pumpkin.rtf: -------------------------------------------------------------------------------- 1 | {\rtf1\ansi 2 | @{\footnote 3 | THIS FILE WAS AUTOMATICALLY GENERATED FROM XML DOCUMENT. 4 | DO 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} 15 | K{\footnote about} 16 | { \f1\fs18\b\sb120 About {\b PumpKIN}} 17 | \par\sa120\sb120\qj \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://kin.klever.net/T42/")} or {\b\cf6 Wintalk} 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 \f1\fs18\sb120 19 | \par\sa120\sb120\qj \f1\fs18\sb120 {\b {\i Enjoy!}} 20 | { 21 | \par\pard\plain\sb360\sa120 \f1\fs16 Copyright (c) 1997-2011 {\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.7.2.1 - Apr 27th, 2011 32 | \par\pard\plain\fi0\li0\f1\fs18 \bullet Fixed a minor bug that lead to misdiagnosis of the packet from unexpected source 33 | \par\pard\plain\f1\fs24\qc\cf2\b 2.7.2 - October 18th, 2006 34 | \par\pard\plain\fi0\li0\f1\fs18 \bullet Added rejecting of too large file requests with explicit error message about the block size 35 | \par\pard\plain\fi0\li0\f1\fs18 \bullet A bit more elaborate logging 36 | \par\pard\plain\fi0\li0\f1\fs18 \bullet Not closing receive socket until the last ACK receved now 37 | \par\pard\plain\f1\fs24\qc\cf2\b 2.7.1 - March 13th, 2006 38 | \par\pard\plain\fi0\li0\f1\fs18 \bullet Bugfix release 39 | \par\pard\plain\f1\fs24\qc\cf2\b 2.7 - February 28th, 2006 40 | \par\pard\plain\fi0\li0\f1\fs18 \bullet Access lists based on request IP address and TFTP opcode for automating access policy 41 | \par\pard\plain\fi0\li0\f1\fs18 \bullet Possibility to start/stop TFTP server, while keeping client functionality intact 42 | \par\pard\plain\fi0\li0\f1\fs18 \bullet Logging to file 43 | \par\pard\plain\fi0\li0\f1\fs18 \bullet Resizable main window 44 | \par\pard\plain\f1\fs24\qc\cf2\b 2.6 - August 6th, 2005 45 | \par\pard\plain\fi0\li0\f1\fs18 \bullet more robust solution to the backslash/slash dilemma 46 | \par\pard\plain\fi0\li0\f1\fs18 \bullet A bit more elaborate error reporting 47 | \par\pard\plain\fi0\li0\f1\fs18 \bullet Fixed uninstall procedure so that it works on XP 48 | \par\pard\plain\f1\fs24\qc\cf2\b 2.5 - July 11th, 2004 49 | \par\pard\plain\fi0\li0\f1\fs18 \bullet Change of {\uldb license}{\v About} and opening the source. 50 | \par\pard\plain\fi0\li0\f1\fs18 \bullet Minor cosmetic changes 51 | \par\pard\plain\f1\fs24\qc\cf2\b 2.0 - June 13th, 1998 52 | \par\pard\plain\fi0\li0\f1\fs18 \bullet Sounds customization. Now you can customize {\b PumpKIN} bells and whistles or turn them off completely. 53 | \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}). 54 | \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. 55 | \par\pard\plain\fi0\li0\f1\fs18 \bullet Something else that you may not notice and I can not remember. 56 | \par\pard\plain\f1\fs24\qc\cf2\b 1.5 - February 12th, 1998 57 | \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. 58 | \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. 59 | \par\pard\plain\fi0\li0\f1\fs18 \bullet New Install program 60 | \page 61 | 62 | \pard\plain\keepn 63 | #{\footnote Using} 64 | ${\footnote Using PumpKIN} 65 | { \f1\fs18\b\sb120 Using {\b PumpKIN}} 66 | \par\sa120\sb120\qj \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://kin.klever.net/T42/")} or {\b\cf6 Wintalk} 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}. 67 | \par\sa120\sb120\qj \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. 68 | \par\sa120\sb120\qj \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. 69 | \par\sa120\sb120\qj \f1\fs18\sb120 Use {\uldb Options}{\v Options} button to set {\b PumpKIN} options. 70 | \par\sa120\sb120\qj \f1\fs18\sb120 You can start and stop {\b PumpKIN}'s {\i TFTP} server by checking and unchecking the {\b Server is running} checkbox in the lower right corner of main {\b PumpKIN} window. 71 | \page 72 | 73 | \pard\plain\keepn 74 | #{\footnote ConfirmRRQ} 75 | ${\footnote Confirm Read Request Dialog} 76 | { \f1\fs18\b\sb120 Confirm Read Request Dialog} 77 | \par\sa120\sb120\qj \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. 78 | \page 79 | 80 | \pard\plain\keepn 81 | #{\footnote ConfirmWRQ} 82 | ${\footnote Confirm Write Request Dialog} 83 | { \f1\fs18\b\sb120 Confirm Write Request Dialog} 84 | \par\sa120\sb120\qj \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). 85 | \page 86 | 87 | \pard\plain\keepn 88 | #{\footnote Request} 89 | ${\footnote Request Dialog} 90 | { \f1\fs18\b\sb120 Request Dialog} 91 | \par\sa120\sb120\qj \f1\fs18\sb120 Request dialog is aimed to let you form read or write request. You may set the following options:\pard 92 | \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. 93 | \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). 94 | \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. 95 | \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}'. 96 | \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 97 | \page 98 | 99 | \pard\plain\keepn 100 | #{\footnote Options} 101 | ${\footnote Options} 102 | { \f1\fs18\b\sb120 Options} 103 | \par\sa120\sb120\qj \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. 104 | \page 105 | 106 | \pard\plain\keepn 107 | #{\footnote NetworkOptions} 108 | ${\footnote Network Options} 109 | { \f1\fs18\b\sb120 Network Options}\pard 110 | \par \fi0\li0 \bullet {\b UDP Ports}\pard 111 | \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. 112 | \par \fi0\li0 \bullet {\b ip address} - ip address to listen to. 113 | \par \fi0\li0 \bullet {\b Send outgoing requests to port} - specifies the port we're going to send all requests to.\pard 114 | \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. 115 | \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 116 | \page 117 | 118 | \pard\plain\keepn 119 | #{\footnote ServerOptions} 120 | ${\footnote Server Options} 121 | { \f1\fs18\b\sb120 Server Options}\pard 122 | \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. 123 | \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. 124 | \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. 125 | \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}. 126 | \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. 127 | \par \fi0\li0 \bullet {\b Log file} - If you want to enable logging to file, set the destination file here.\pard 128 | \page 129 | 130 | \pard\plain\keepn 131 | #{\footnote SoundsOptions} 132 | ${\footnote Sounds Options} 133 | { \f1\fs18\b\sb120 Sounds} 134 | \par\sa120\sb120\qj \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. 135 | \par\sa120\sb120\qj \f1\fs18\sb120 You can select any {\b .wav} file or one of the predefined sounds from the dropdown list. 136 | \page 137 | 138 | \pard\plain\keepn 139 | #{\footnote ACL} 140 | ${\footnote Access Lists} 141 | { \f1\fs18\b\sb120 Access Lists} 142 | \par\sa120\sb120\qj \f1\fs18\sb120 You can slightly automate your access policies by setting up read/write request behavior for different incoming requests. 143 | \par\sa120\sb120\qj \f1\fs18\sb120 The rule consists of {\b request type}, source network ({\b ip} and {\b netmask}) and {\b action} to take (see also {\uldb Server Options}{\v ServerOptions}). 144 | \par\sa120\sb120\qj \f1\fs18\sb120 When {\b PumpKIN} receives request it goes through the list of rules and bases its decision on the first matching rule. To rearrange order of rules, select the rule you wish to move and use up and down arrows buttons on the right. To remove rule, use the cross button. 145 | \par\sa120\sb120\qj \f1\fs18\sb120 To add a new rule fill in the information about {\b request type}, source {\b address} and {\b netmask} and desired action. Then click on the 'Add new rule' button. 146 | \par\sa120\sb120\qj \f1\fs18\sb120 If you wish to amend the rule, select it in the rules list, change parameters below and click the 'Replace rule' button. 147 | \page 148 | } -------------------------------------------------------------------------------- /help/pumpkin.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | About PumpKIN 5 |

PumpKIN is a program designed to send and receive files over the net while having T42 or Wintalk session running using TFTP () protocol. It includes full-functional TFTP server/client so it may be useful for maintaining CISCO routers and other network equipment.

6 |

7 |

Enjoy!

8 | 9 | 10 |
11 | 12 | 13 | Added configuration option to bind to specific ip address 14 | Fixed a minor bug that lead to misdiagnosis of the packet from unexpected source 15 | 16 | 17 | Added rejecting of too large file requests with explicit error message about the block size 18 | A bit more elaborate logging 19 | Not closing receive socket until the last ACK receved now 20 | 21 | 22 | Bugfix release 23 | 24 | 25 | Access lists based on request IP address and TFTP opcode for automating access policy 26 | Possibility to start/stop TFTP server, while keeping client functionality intact 27 | Logging to file 28 | Resizable main window 29 | 30 | 31 | more robust solution to the backslash/slash dilemma 32 | A bit more elaborate error reporting 33 | Fixed uninstall procedure so that it works on XP 34 | 35 | 36 | Change of license and opening the source. 37 | Minor cosmetic changes 38 | 39 | 40 | Sounds customization. Now you can customize PumpKIN bells and whistles or turn them off completely. 41 | Previous version of PumpKIN had a bug causing it to misbehave when you're requesting file from remote tftp server using IP Address (as opposed to hostname). 42 | Typo causing PumpKIN to log outgoing request in reverse (i.e. Requesting 'hostname' from 'filename') fixed. 43 | Something else that you may not notice and I can not remember. 44 | 45 | 46 | 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. 47 | Support for block size, trasnfer size and transfer timeout options as described in , and . I'm not sure if there are any other TFTP implementations supporting this, but at least it makes sense if you use PumpKIN on both ends. 48 | New Install program 49 | 50 | 51 | 52 | Using PumpKIN 53 |

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 T42 or Wintalk conversation. It uses open sessions to determine IP address of your party. Also you may use it as a TFTP client/server by itself. To get/put files from/to TFTP server you need to enter host name/IP address manually in the Request Dialog.

54 |

To Abort transfer(s) currently in progress - select transfer(s) you want to terminate in the list and click Abort xfer button.

55 |

You may want to hide PumpKIN window and leave it as a tray icon only. Just click the icon in the tray or simply close the window.

56 |

Use Options button to set PumpKIN options.

57 |

You can start and stop PumpKIN's TFTP server by checking and unchecking the Server is running checkbox in the lower right corner of main PumpKIN window.

58 |
59 | 60 | Confirm Read Request Dialog 61 |

When the file is requested from your TFTP server you may choose to Grant Access to this file or to Deny Access. If you hesitate to answer for Confirmation timeout (default - 30 seconds) PumpKIN defaults to denial of all requests.

62 |
63 | 64 | Confirm Write Request Dialog 65 |

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 Rename option. If you already have file with such name you may chose to 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 PumpKIN on both ends. If you are still unsure for Confirmation timeout (default - 30 seconds) PumpKIN will make safe decision for you (deny).

66 |
67 | 68 | Request Dialog 69 |

Request dialog is aimed to let you form read or write request. You may set the following options:

70 |
    71 |
  • 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 Browse button to select the file.
  • 72 |
  • 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).
  • 73 |
  • Remote Host is your party's host or TFTP server you're requesting file from/sending file to. To refresh the list of your talk windows use REFRESH button.
  • 74 |
  • Type is the type of transfer as defined in . Doesn't mean much, really. Defined types are 'octet' or 'netascii'. Default is 'octet'.
  • 75 |
  • Block Size - Use this block size if remote is -compliant. If remote doesn't support this option PumpKIN will fallback to 512 bytes per block.
  • 76 |
77 |
78 | 79 | Options 80 |

PumpKIN options property sheet consists of two tabs. For more information see Network and Server options.

81 |
82 | 83 | Network Options 84 |
    85 |
  • UDP Ports 86 |
      87 |
    • Listen for incoming connections on port - specifies the port we're listening to. The default as defined in is 69.
    • 88 |
    • ip address - ip address to listen to.
    • 89 |
    • Send outgoing requests to port - specifies the port we're going to send all requests to.
    • 90 |
    91 |
  • 92 |
  • Default Connection timeout - if there's no activity for specified time, transfer is considered to be dead and terminated. PumpKIN tries to propagate this value to remote as described in and if possible.
  • 93 |
  • Default Block Size - PumpKIN tries to negotiate block size with remote using this value unless specified explicitly in request. If remote doesn't support and PumpKIN falls back to 512 bytes per block.
  • 94 |
95 |
96 | 97 | Server Options 98 | 106 | 107 | 108 | Sounds 109 |

You can customize PumpKIN sounds notifications here. There are three customizable sounds defined - Incoming request, which notifies you about incoming request prompt if you're set to be prompted whenever incoming request occurs. xfer Aborted - which happens to sound every time transfer is interrupted for whatever reason - time out, explicit kill, denied access, etc. xfer Finished means that your file was successfully transmitted.

110 |

You can select any .wav file or one of the predefined sounds from the dropdown list.

111 |
112 | 113 | Access Lists 114 |

You can slightly automate your access policies by setting up read/write request behavior for different incoming requests.

115 |

The rule consists of request type, source network (ip and netmask) and action to take (see also Server Options).

116 |

When PumpKIN receives request it goes through the list of rules and bases its decision on the first matching rule. To rearrange order of rules, select the rule you wish to move and use up and down arrows buttons on the right. To remove rule, use the cross button.

117 |

To add a new rule fill in the information about request type, source address and netmask and desired action. Then click on the 'Add new rule' button.

118 |

If you wish to amend the rule, select it in the rules list, change parameters below and click the 'Replace rule' button.

119 | 120 |
121 | -------------------------------------------------------------------------------- /install/Install.clw: -------------------------------------------------------------------------------- 1 | ; CLW file contains information for the MFC ClassWizard 2 | 3 | [General Info] 4 | Version=1 5 | LastClass= 6 | LastTemplate=CDialog 7 | NewFileInclude1=#include "stdafx.h" 8 | NewFileInclude2=#include "install.h" 9 | LastPage=0 10 | 11 | ClassCount=0 12 | 13 | ResourceCount=2 14 | Resource1=IDD_INSTALLING (FALSE) 15 | Resource2=IDD_PATH 16 | 17 | [DLG:IDD_INSTALLING (FALSE)] 18 | Type=1 19 | Class=? 20 | ControlCount=4 21 | Control1=IDCANCEL,button,1342295808 22 | Control2=IDC_DISKS,SysAnimate32,1342242822 23 | Control3=IDC_STATE,static,1342308736 24 | Control4=IDC_PROGRESS,msctls_progress32,1342177280 25 | 26 | [DLG:IDD_PATH] 27 | Type=1 28 | Class=? 29 | ControlCount=5 30 | Control1=IDC_PROMPT,static,1342308352 31 | Control2=IDC_PATH,edit,1350631552 32 | Control3=IDC_BROWSE,button,1342242816 33 | Control4=IDOK,button,1342242817 34 | Control5=IDCANCEL,button,1342242816 35 | 36 | -------------------------------------------------------------------------------- /install/custom.rch: -------------------------------------------------------------------------------- 1 | #ifdef STATI_K 2 | PumpKIN.ex_ rcdata discardable "../releast/pumpkin.ex_" 3 | #else 4 | PumpKIN.ex_ rcdata discardable "../release/pumpkin.ex_" 5 | #endif 6 | PumpKIN.cn_ rcdata discardable "../release/pumpkin.cn_" 7 | PumpKIN.hl_ rcdata discardable "../release/pumpkin.hl_" 8 | #ifdef K_ANNED 9 | mfc42.dl_ rcdata discardable "../redist/mfc42.dl_" 10 | #endif 11 | -------------------------------------------------------------------------------- /install/install.cpp: -------------------------------------------------------------------------------- 1 | #include "resource.h" 2 | #include "../shared-code/install.h" 3 | 4 | #define VERSION "2.7.3" 5 | #define KINAME "PumpKIN " VERSION 6 | #define SKINAME "PumpKIN" 7 | 8 | BOOL Install(void) 9 | { 10 | STRING dPath = strFETCH_REG_KEY(HKEY_LOCAL_MACHINE,"Software\\Klever Group",SKINAME "Path"); 11 | STRING kPath = strFETCH_REG_KEY(HKEY_LOCAL_MACHINE,"Software\\Klever Group","KINPath"); 12 | LPCSTR qPath = ((LPCSTR)dPath)?(LPCSTR)dPath:(((LPCSTR)kPath)?(LPSTR)kPath:"C:\\Program Files\\Klever\\Nothings"); 13 | STRING path = REQUESTPATH(" " KINAME,"\nEnter destination path:",qPath); 14 | if(!path) 15 | return NULL; 16 | 17 | #ifdef K_ANNED 18 | STRING sysDir(_MAX_PATH); 19 | GetSystemDirectory(sysDir,_MAX_PATH); 20 | INSTALLFILE("mfc42.dl_",sysDir,"mfc42.dll"); 21 | #endif 22 | 23 | MAKE_PATH(path); 24 | STRING shortPath = GET_SHORT_PATH(path); 25 | if(!shortPath){ 26 | MessageBox(NULL,"Failed to install " KINAME " in specified directory",NULL,MB_ICONERROR|MB_OK); 27 | return FALSE; 28 | } 29 | 30 | if(!( 31 | INSTALLFILE(SKINAME ".ex_",path,SKINAME ".exe") && 32 | INSTALLFILE(SKINAME ".hl_",path,SKINAME ".hlp") && 33 | INSTALLFILE(SKINAME ".cn_",path,SKINAME ".cnt") 34 | )){ 35 | MessageBox(NULL,"Failed to install " KINAME " in specified directory",NULL,MB_ICONERROR|MB_OK); 36 | return FALSE; 37 | } 38 | ADDMENU("Klever Group",SKINAME,path, SKINAME ".exe"); 39 | 40 | strSET_REG_KEY(HKEY_LOCAL_MACHINE,"Software\\Klever Group",SKINAME "Path",path); 41 | strSET_REG_KEY(HKEY_LOCAL_MACHINE,"Software\\Klever Group","KINPath",path); 42 | 43 | FILE* inf=CREATE_INF_FILE(path,SKINAME ".INF"); 44 | if(!inf){ 45 | MessageBox(NULL,"Failed to install " KINAME,NULL,MB_ICONERROR|MB_OK); 46 | return FALSE; 47 | } 48 | INF_FILE_HEADER(inf); 49 | INF_FILE_SECTION(inf,"Uninstall"); 50 | fprintf(inf,"AddReg=kFiles\nDelReg=kReg\nUpdateInis=kMenu\n"); 51 | INF_FILE_SECTION(inf,"kFiles"); 52 | INF_REMOVE_ROOT(inf,SKINAME "Files",shortPath); 53 | INF_REMOVE_FILE(inf,SKINAME "Files",SKINAME ".exe"); 54 | INF_REMOVE_HELP_FILE(inf,SKINAME "Files",SKINAME); 55 | INF_REMOVE_FILE(inf,SKINAME "Files",SKINAME ".inf"); 56 | INF_FILE_SECTION(inf,"kReg"); 57 | INF_UNINSTALL_REG(inf,SKINAME); 58 | INF_FILE_SECTION(inf,"kMenu"); 59 | INF_MENU_GROUP(inf,1,"Klever Group"); 60 | INF_MENU_ITEM(inf,1,SKINAME); 61 | fclose(inf); 62 | 63 | REG_UNINSTALL_COMMAND(SKINAME,"Klever " KINAME,shortPath,SKINAME ".INF","Uninstall"); 64 | REG_UNINSTALL_ICON(SKINAME,path,SKINAME ".exe",0); 65 | REG_UNINSTALL_COMMENT(SKINAME,"Klever PumpKIN"); 66 | REG_UNINSTALL_VERSION(SKINAME,VERSION); 67 | REG_UNINSTALL_LOCATION(SKINAME,path); 68 | REG_UNINSTALL_PUBLISHER(SKINAME,"Klever Group"); 69 | REG_UNINSTALL_URLS(SKINAME,"http://www.klever.net/","http://kin.klever.net/pumpkin/"); 70 | 71 | MessageBox(NULL,KINAME " installed successfully, you may now run it from 'Programs/Klever Group' menu or remove it using Control Panel Add/Remove Programs applet."," Rejoice!",MB_ICONINFORMATION|MB_OK); 72 | 73 | return TRUE; 74 | } 75 | -------------------------------------------------------------------------------- /install/install.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klevernothings/pumpkin/13a91d9b1723628301f9ace03e53a592ed4dda4a/install/install.rc -------------------------------------------------------------------------------- /install/resource.h: -------------------------------------------------------------------------------- 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 25 | -------------------------------------------------------------------------------- /makehelp.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | REM -- First make map file from Microsoft Visual C++ generated resource.h 3 | echo // MAKEHELP.BAT generated Help Map file. Used by PUMPKIN.HPJ. >"help\pumpkin.hm" 4 | echo. >>"help\pumpkin.hm" 5 | echo // Commands (ID_* and IDM_*) >>"help\pumpkin.hm" 6 | makehm ID_,HID_,0x10000 IDM_,HIDM_,0x10000 resource.h >>"help\pumpkin.hm" 7 | echo. >>"help\pumpkin.hm" 8 | echo // Prompts (IDP_*) >>"help\pumpkin.hm" 9 | makehm IDP_,HIDP_,0x30000 resource.h >>"help\pumpkin.hm" 10 | echo. >>"help\pumpkin.hm" 11 | echo // Resources (IDR_*) >>"help\pumpkin.hm" 12 | makehm IDR_,HIDR_,0x20000 resource.h >>"help\pumpkin.hm" 13 | echo. >>"help\pumpkin.hm" 14 | echo // Dialogs (IDD_*) >>"help\pumpkin.hm" 15 | makehm IDD_,HIDD_,0x20000 resource.h >>"help\pumpkin.hm" 16 | echo. >>"help\pumpkin.hm" 17 | echo // Frame Controls (IDW_*) >>"help\pumpkin.hm" 18 | makehm IDW_,HIDW_,0x50000 resource.h >>"help\pumpkin.hm" 19 | REM -- Make help for Project PUMPKIN 20 | 21 | echo Building RTF file 22 | xsltproc -o help/pumpkin.rtf shared-code/kinhelp.xsl help/pumpkin.xml 23 | echo Building Win32 Help files 24 | start /wait hcrtf -x "help\pumpkin.hpj" 25 | echo. 26 | if exist Debug\nul copy "help\pumpkin.hlp" Debug 27 | if exist Debug\nul copy "help\pumpkin.cnt" Debug 28 | if exist Release\nul copy "help\pumpkin.hlp" Release 29 | if exist Release\nul copy "help\pumpkin.cnt" Release 30 | if exist Releast\nul copy "help\pumpkin.hlp" Releast 31 | if exist Releast\nul copy "help\pumpkin.cnt" Releast 32 | echo. 33 | -------------------------------------------------------------------------------- /pumpkin.clw: -------------------------------------------------------------------------------- 1 | ; CLW file contains information for the MFC ClassWizard 2 | 3 | [General Info] 4 | Version=1 5 | LastClass=CPropsNetwork 6 | LastTemplate=CComboBox 7 | NewFileInclude1=#include "stdafx.h" 8 | NewFileInclude2=#include "PumpKIN.h" 9 | 10 | ClassCount=14 11 | Class1=CPumpKINApp 12 | Class2=CPumpKINDlg 13 | Class3=CAboutDlg 14 | 15 | ResourceCount=10 16 | Resource1=IDD_REQUEST 17 | Resource2=IDD_PUMPKIN_DIALOG 18 | Resource3=IDD_CONFIRM_RRQ 19 | Resource4=IDD_PROPS_SERVER 20 | Class4=CPropsServer 21 | Class5=CPropsNetwork 22 | Resource5=IDD_CONFIRM_WRQ 23 | Resource6=IDD_PROPS_ACL 24 | Class6=CConfirmRRQDlg 25 | Class7=CConfirmWRQDlg 26 | Resource7=IDD_ABOUTBOX 27 | Class8=CRequestDlg 28 | Class9=CResolver 29 | Class10=CRetrier 30 | Class11=CTrayer 31 | Resource8=IDD_PROPS_SOUNDS 32 | Class12=CPropsSounds 33 | Resource9=IDM_POPUPS 34 | Class13=CPropsACL 35 | Class14=CACLTargetCombo 36 | Resource10=IDD_PROPS_NETWORK 37 | 38 | [CLS:CPumpKINApp] 39 | Type=0 40 | HeaderFile=PumpKIN.h 41 | ImplementationFile=PumpKIN.cpp 42 | Filter=N 43 | 44 | [CLS:CPumpKINDlg] 45 | Type=0 46 | HeaderFile=PumpKINDlg.h 47 | ImplementationFile=PumpKINDlg.cpp 48 | Filter=W 49 | BaseClass=CDialog 50 | VirtualFilter=dWC 51 | LastObject=CPumpKINDlg 52 | 53 | [CLS:CAboutDlg] 54 | Type=0 55 | HeaderFile=PumpKINDlg.h 56 | ImplementationFile=PumpKINDlg.cpp 57 | Filter=D 58 | BaseClass=CDialog 59 | VirtualFilter=dWC 60 | LastObject=CAboutDlg 61 | 62 | [DLG:IDD_ABOUTBOX] 63 | Type=1 64 | Class=CAboutDlg 65 | ControlCount=5 66 | Control1=IDC_STATIC,static,1342177283 67 | Control2=IDC_STATIC,static,1342308480 68 | Control3=IDC_STATIC,static,1342308352 69 | Control4=IDOK,button,1342373889 70 | Control5=IDC_KLEVERNET,button,1342242816 71 | 72 | [DLG:IDD_PUMPKIN_DIALOG] 73 | Type=1 74 | Class=CPumpKINDlg 75 | ControlCount=10 76 | Control1=IDC_CONNECTIONS,SysListView32,1350631681 77 | Control2=IDC_GET,button,1342259200 78 | Control3=IDC_PUT,button,1342259200 79 | Control4=IDC_ABORT,button,1342259200 80 | Control5=IDC_OPTIONS,button,1342259200 81 | Control6=IDC_EXIT,button,1342259200 82 | Control7=ID_HELP,button,1342259200 83 | Control8=IDC_LOG,listbox,1353728385 84 | Control9=IDCANCEL,button,1073741824 85 | Control10=IDC_LISTENING,button,1342275619 86 | 87 | [DLG:IDD_PROPS_SERVER] 88 | Type=1 89 | Class=CPropsServer 90 | ControlCount=18 91 | Control1=IDC_STATIC,button,1342177287 92 | Control2=IDC_TFTPROOT,edit,1350631552 93 | Control3=IDC_BROWSE,button,1342242880 94 | Control4=IDC_TFTPSUBDIRS,button,1342242819 95 | Control5=IDC_STATIC,button,1342177287 96 | Control6=IDC_RRQ_GIVEALL,button,1342324745 97 | Control7=IDC_RRQ_ALWAYSCONFIRM,button,1342193673 98 | Control8=IDC_RRQ_DENYALL,button,1342193673 99 | Control9=IDC_STATIC,button,1342308359 100 | Control10=IDC_WRQ_TAKEALL,button,1342308361 101 | Control11=IDC_WRQ_PROMPTEXISTING,button,1342177289 102 | Control12=IDC_WRQ_ALWAYSCONFIRM,button,1342177289 103 | Control13=IDC_WRQ_DENYALL,button,1342177289 104 | Control14=IDC_STATIC,static,1342308609 105 | Control15=IDC_PROMPTTIMEOUT,msctls_trackbar32,1342242823 106 | Control16=IDC_STATIC,button,1342177287 107 | Control17=IDC_LOGFILE,edit,1350631552 108 | Control18=IDC_LOGFILE_BROWSE,button,1342242880 109 | 110 | [DLG:IDD_PROPS_NETWORK] 111 | Type=1 112 | Class=CPropsNetwork 113 | ControlCount=17 114 | Control1=IDC_STATIC,button,1342177287 115 | Control2=IDC_STATIC,static,1342308354 116 | Control3=IDC_LISTENPORT,edit,1350631552 117 | Control4=IDC_LISTENSPIN,msctls_updown32,1342177463 118 | Control5=IDC_STATIC,static,1342308354 119 | Control6=IDC_SPEAKPORT,edit,1350631552 120 | Control7=IDC_SPEAKSPIN,msctls_updown32,1342177463 121 | Control8=IDC_STATIC,static,1342308352 122 | Control9=IDC_TIMEOUT,edit,1350639744 123 | Control10=IDC_TIMESPIN,msctls_updown32,1342177463 124 | Control11=IDC_STATIC,static,1342308352 125 | Control12=IDC_STATIC,static,1342308352 126 | Control13=IDC_STATIC,static,1342308352 127 | Control14=IDC_BLOCKSIZE,edit,1350639744 128 | Control15=IDC_BSIZESPIN,msctls_updown32,1342177463 129 | Control16=IDC_STATIC,static,1342308354 130 | Control17=IDC_LISTENADDRESS,edit,1350631552 131 | 132 | [CLS:CPropsServer] 133 | Type=0 134 | HeaderFile=PropsServer.h 135 | ImplementationFile=PropsServer.cpp 136 | BaseClass=CPropertyPage 137 | Filter=D 138 | VirtualFilter=idWC 139 | LastObject=CPropsServer 140 | 141 | [CLS:CPropsNetwork] 142 | Type=0 143 | HeaderFile=PropsNetwork.h 144 | ImplementationFile=PropsNetwork.cpp 145 | BaseClass=CPropertyPage 146 | Filter=D 147 | VirtualFilter=idWC 148 | LastObject=IDC_LISTENADDRESS 149 | 150 | [DLG:IDD_CONFIRM_RRQ] 151 | Type=1 152 | Class=CConfirmRRQDlg 153 | ControlCount=9 154 | Control1=IDOK,button,1342242817 155 | Control2=IDCANCEL,button,1342242816 156 | Control3=IDC_STATIC,static,1342308352 157 | Control4=IDC_HOST,static,1350701313 158 | Control5=IDC_STATIC,static,1342308353 159 | Control6=IDC_FILE,static,1350701313 160 | Control7=IDC_STATIC,static,1342177296 161 | Control8=IDC_STATIC,static,1342177283 162 | Control9=IDC_STATIC,static,1342177283 163 | 164 | [DLG:IDD_CONFIRM_WRQ] 165 | Type=1 166 | Class=CConfirmWRQDlg 167 | ControlCount=11 168 | Control1=IDOK,button,1342242817 169 | Control2=IDC_RENAME,button,1342242816 170 | Control3=IDCANCEL,button,1342242816 171 | Control4=IDC_STATIC,static,1342308352 172 | Control5=IDC_HOST,static,1350701313 173 | Control6=IDC_STATIC,static,1342308353 174 | Control7=IDC_FILE,static,1350701313 175 | Control8=IDC_STATIC,static,1342177296 176 | Control9=IDC_STATIC,static,1342177283 177 | Control10=IDC_STATIC,static,1342177283 178 | Control11=IDC_RESUME,button,1342242816 179 | 180 | [CLS:CConfirmRRQDlg] 181 | Type=0 182 | HeaderFile=ConfirmRRQDlg.h 183 | ImplementationFile=ConfirmRRQDlg.cpp 184 | BaseClass=CDialog 185 | Filter=D 186 | VirtualFilter=dWC 187 | LastObject=CConfirmRRQDlg 188 | 189 | [CLS:CConfirmWRQDlg] 190 | Type=0 191 | HeaderFile=ConfirmWRQDlg.h 192 | ImplementationFile=ConfirmWRQDlg.cpp 193 | BaseClass=CDialog 194 | Filter=D 195 | VirtualFilter=dWC 196 | LastObject=IDC_RESUME 197 | 198 | [DLG:IDD_REQUEST] 199 | Type=1 200 | Class=CRequestDlg 201 | ControlCount=15 202 | Control1=IDC_STATIC,static,1342308608 203 | Control2=IDC_LOCALFILE,edit,1350631552 204 | Control3=IDC_BROWSE,button,1342242880 205 | Control4=IDC_STATIC,static,1342308608 206 | Control5=IDC_REMOTEFILE,edit,1350631552 207 | Control6=IDC_STATIC,static,1342308608 208 | Control7=IDC_TALKS,combobox,1344341313 209 | Control8=IDC_REFRESH,button,1342271232 210 | Control9=IDC_STATIC,static,1342308352 211 | Control10=IDC_TYPE,combobox,1344356418 212 | Control11=IDC_STATIC,static,1342308352 213 | Control12=IDC_BSIZE,combobox,1344339970 214 | Control13=IDOK,button,1342242817 215 | Control14=IDCANCEL,button,1342242816 216 | Control15=IDC_STATIC,static,1342177297 217 | 218 | [CLS:CRequestDlg] 219 | Type=0 220 | HeaderFile=RequestDlg.h 221 | ImplementationFile=RequestDlg.cpp 222 | BaseClass=CDialog 223 | Filter=W 224 | VirtualFilter=dWC 225 | LastObject=CRequestDlg 226 | 227 | [CLS:CResolver] 228 | Type=0 229 | HeaderFile=Resolver.h 230 | ImplementationFile=Resolver.cpp 231 | BaseClass=CWnd 232 | Filter=W 233 | LastObject=CResolver 234 | VirtualFilter=WC 235 | 236 | [MNU:IDM_POPUPS] 237 | Type=1 238 | Class=CPumpKINDlg 239 | Command1=ID_TRAY_SENDFILE 240 | Command2=ID_TRAY_FETCHFILE 241 | Command3=ID_TRAY_OPTIONS 242 | Command4=ID_TRAY_LISTEN 243 | Command5=ID_TRAY_SHOWPUMPKINWINDOW 244 | Command6=ID_TRAY_OPENFILESFOLDER 245 | Command7=ID_TRAY_HELP 246 | Command8=ID_TRAY_ABOUTPUMPKIN 247 | Command9=ID_TRAY_EXIT 248 | CommandCount=9 249 | 250 | [CLS:CRetrier] 251 | Type=0 252 | HeaderFile=Retrier.h 253 | ImplementationFile=Retrier.cpp 254 | BaseClass=CWnd 255 | Filter=W 256 | LastObject=CRetrier 257 | VirtualFilter=WC 258 | 259 | [CLS:CTrayer] 260 | Type=0 261 | HeaderFile=Trayer.h 262 | ImplementationFile=Trayer.cpp 263 | BaseClass=CWnd 264 | Filter=W 265 | LastObject=CTrayer 266 | VirtualFilter=WC 267 | 268 | [DLG:IDD_PROPS_SOUNDS] 269 | Type=1 270 | Class=CPropsSounds 271 | ControlCount=12 272 | Control1=IDC_STATIC,static,1342308352 273 | Control2=IDC_RING,combobox,1344340290 274 | Control3=IDC_RING_BROWSE,button,1342242880 275 | Control4=IDC_RING_PLAY,button,1342242880 276 | Control5=IDC_STATIC,static,1342308352 277 | Control6=IDC_FINISHED,combobox,1344340290 278 | Control7=IDC_FINISHED_BROWSE,button,1342242880 279 | Control8=IDC_FINISHED_PLAY,button,1342242880 280 | Control9=IDC_STATIC,static,1342308352 281 | Control10=IDC_ABORTED,combobox,1344340290 282 | Control11=IDC_ABORTED_BROWSE,button,1342242880 283 | Control12=IDC_ABORTED_PLAY,button,1342242880 284 | 285 | [CLS:CPropsSounds] 286 | Type=0 287 | HeaderFile=PropsSounds.h 288 | ImplementationFile=PropsSounds.cpp 289 | BaseClass=CPropertyPage 290 | Filter=D 291 | LastObject=CPropsSounds 292 | VirtualFilter=idWC 293 | 294 | [DLG:IDD_PROPS_ACL] 295 | Type=1 296 | Class=CPropsACL 297 | ControlCount=14 298 | Control1=IDC_ACL_LIST,SysListView32,1350631425 299 | Control2=IDC_ACL_UP,button,1342246720 300 | Control3=IDC_ACL_DOWN,button,1342246720 301 | Control4=IDC_ACL_REMOVE,button,1342246720 302 | Control5=IDC_STATIC,static,1342308352 303 | Control6=IDC_ACL_XFER,combobox,1344339971 304 | Control7=IDC_STATIC,static,1342308352 305 | Control8=IDC_ACL_ADDR,edit,1350631552 306 | Control9=IDC_STATIC,static,1342308352 307 | Control10=IDC_ACL_NETMASK,edit,1350631552 308 | Control11=IDC_STATIC,static,1342308352 309 | Control12=IDC_ACL_RULE,combobox,1344339971 310 | Control13=IDC_ACL_ADD,button,1342242816 311 | Control14=IDC_ACL_REPLACE,button,1342242816 312 | 313 | [CLS:CPropsACL] 314 | Type=0 315 | HeaderFile=PropsACL.h 316 | ImplementationFile=PropsACL.cpp 317 | BaseClass=CPropertyPage 318 | Filter=D 319 | LastObject=CPropsACL 320 | VirtualFilter=idWC 321 | 322 | [CLS:CACLTargetCombo] 323 | Type=0 324 | HeaderFile=ACLTargetCombo.h 325 | ImplementationFile=ACLTargetCombo.cpp 326 | BaseClass=CComboBox 327 | Filter=W 328 | LastObject=CACLTargetCombo 329 | 330 | -------------------------------------------------------------------------------- /pumpkin.cpp: -------------------------------------------------------------------------------- 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 11 | static char THIS_FILE[] = __FILE__; 12 | #endif 13 | 14 | ///////////////////////////////////////////////////////////////////////////// 15 | // CPumpKINApp 16 | 17 | BEGIN_MESSAGE_MAP(CPumpKINApp, CWinApp) 18 | //{{AFX_MSG_MAP(CPumpKINApp) 19 | //}}AFX_MSG 20 | ON_COMMAND(ID_HELP, CWinApp::OnHelp) 21 | END_MESSAGE_MAP() 22 | 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // CPumpKINApp construction 25 | 26 | CPumpKINApp::CPumpKINApp() 27 | { 28 | } 29 | 30 | ///////////////////////////////////////////////////////////////////////////// 31 | // The one and only CPumpKINApp object 32 | 33 | CPumpKINApp theApp; 34 | 35 | ///////////////////////////////////////////////////////////////////////////// 36 | // CPumpKINApp initialization 37 | 38 | BOOL 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 | } 70 | -------------------------------------------------------------------------------- /pumpkin.h: -------------------------------------------------------------------------------- 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 | 15 | class CPumpKINApp : public CWinApp 16 | { 17 | public: 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 | ///////////////////////////////////////////////////////////////////////////// 37 | -------------------------------------------------------------------------------- /pumpkin.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klevernothings/pumpkin/13a91d9b1723628301f9ace03e53a592ed4dda4a/pumpkin.rc -------------------------------------------------------------------------------- /res/down.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klevernothings/pumpkin/13a91d9b1723628301f9ace03e53a592ed4dda4a/res/down.ico -------------------------------------------------------------------------------- /res/failed.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klevernothings/pumpkin/13a91d9b1723628301f9ace03e53a592ed4dda4a/res/failed.wav -------------------------------------------------------------------------------- /res/finished.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klevernothings/pumpkin/13a91d9b1723628301f9ace03e53a592ed4dda4a/res/finished.wav -------------------------------------------------------------------------------- /res/pumpkin.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klevernothings/pumpkin/13a91d9b1723628301f9ace03e53a592ed4dda4a/res/pumpkin.ico -------------------------------------------------------------------------------- /res/pumpkin.rc2: -------------------------------------------------------------------------------- 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 | ///////////////////////////////////////////////////////////////////////////// 14 | -------------------------------------------------------------------------------- /res/remove.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klevernothings/pumpkin/13a91d9b1723628301f9ace03e53a592ed4dda4a/res/remove.ico -------------------------------------------------------------------------------- /res/ring.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klevernothings/pumpkin/13a91d9b1723628301f9ace03e53a592ed4dda4a/res/ring.wav -------------------------------------------------------------------------------- /res/rrq.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klevernothings/pumpkin/13a91d9b1723628301f9ace03e53a592ed4dda4a/res/rrq.ico -------------------------------------------------------------------------------- /res/up.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klevernothings/pumpkin/13a91d9b1723628301f9ace03e53a592ed4dda4a/res/up.ico -------------------------------------------------------------------------------- /res/wrq.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klevernothings/pumpkin/13a91d9b1723628301f9ace03e53a592ed4dda4a/res/wrq.ico -------------------------------------------------------------------------------- /resource.h: -------------------------------------------------------------------------------- 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 IDD_PROPS_ACL 150 77 | #define IDS_TFTP_ERROR_BSIZE 151 78 | #define IDS_TFTP_ERROR_TOUT 152 79 | #define IDI_UP 152 80 | #define IDS_SELECT_TFTPROOT 153 81 | #define IDI_DOWN 153 82 | #define IDS_FILTER_WAV 154 83 | #define IDI_REMOVE 154 84 | #define IDS_TITLE_WAV 155 85 | #define IDS_BOX_CANTBIND 156 86 | #define IDS_NO_XFER_OP 157 87 | #define IDS_INVALID_IP 158 88 | #define IDS_INVALID_NETMASK 159 89 | #define IDS_INVALID_RULE 160 90 | #define IDS_LOG_LOGERROR 161 91 | #define IDS_TFTP_ERROR_TOOBIG 162 92 | #define IDS_LOG_DENYING 163 93 | #define IDC_KLEVERNET 1000 94 | #define IDC_CONNECTIONS 1001 95 | #define IDC_LOG 1003 96 | #define IDC_GET 1004 97 | #define IDC_PUT 1005 98 | #define IDC_ABORT 1006 99 | #define IDC_EXIT 1007 100 | #define IDC_TFTPROOT 1008 101 | #define IDC_TFTPSUBDIRS 1009 102 | #define IDC_RRQ_GIVEALL 1010 103 | #define IDC_RRQ_ALWAYSCONFIRM 1011 104 | #define IDC_RRQ_DENYALL 1012 105 | #define IDC_WRQ_TAKEALL 1013 106 | #define IDC_WRQ_PROMPTEXISTING 1014 107 | #define IDC_WRQ_ALWAYSCONFIRM 1015 108 | #define IDC_WRQ_DENYALL 1016 109 | #define IDC_PROMPTTIMEOUT 1017 110 | #define IDC_LISTENPORT 1018 111 | #define IDC_LISTENSPIN 1019 112 | #define IDC_SPEAKPORT 1020 113 | #define IDC_SPEAKSPIN 1021 114 | #define IDC_MAXUDPSIZE 1022 115 | #define IDC_MAXUDPSPIN 1023 116 | #define IDC_TIMEOUT 1024 117 | #define IDC_TIMESPIN 1025 118 | #define IDC_OPTIONS 1026 119 | #define IDC_BLOCKSIZE 1026 120 | #define IDC_BSIZESPIN 1027 121 | #define IDC_HOST 1028 122 | #define IDC_FILE 1029 123 | #define IDC_RENAME 1030 124 | #define IDC_REMOTEFILE 1030 125 | #define IDC_RESUME 1031 126 | #define IDC_REFRESH 1032 127 | #define IDC_BROWSE 1034 128 | #define IDC_TALKS 1035 129 | #define IDC_LOCALFILE 1036 130 | #define IDC_TYPE 1037 131 | #define IDC_BSIZE 1039 132 | #define IDC_RING 1041 133 | #define IDC_RING_BROWSE 1042 134 | #define IDC_RING_PLAY 1043 135 | #define IDC_ACL_LIST 1043 136 | #define IDC_FINISHED 1044 137 | #define IDC_ACL_UP 1044 138 | #define IDC_FINISHED_BROWSE 1045 139 | #define IDC_ACL_DOWN 1045 140 | #define IDC_FINISHED_PLAY 1046 141 | #define IDC_ACL_REMOVE 1046 142 | #define IDC_ABORTED 1047 143 | #define IDC_ACL_ADDR 1047 144 | #define IDC_ABORTED_BROWSE 1048 145 | #define IDC_ACL_RULE 1048 146 | #define IDC_ABORTED_PLAY 1049 147 | #define IDC_ACL_NETMASK 1049 148 | #define IDC_ACL_ADD 1050 149 | #define IDC_ACL_XFER 1051 150 | #define IDC_ACL_REPLACE 1052 151 | #define IDC_LISTENING 1052 152 | #define IDC_LOGFILE 1053 153 | #define IDC_LOGFILE_BROWSE 1054 154 | #define IDC_LISTENADDRESS 1055 155 | #define ID_TRAY_HELP 32771 156 | #define ID_TRAY_ABOUTPUMPKIN 32772 157 | #define ID_TRAY_EXIT 32773 158 | #define ID_TRAY_SENDFILE 32774 159 | #define ID_TRAY_FETCHFILE 32775 160 | #define ID_TRAY_OPTIONS 32776 161 | #define ID_TRAY_SHOWPUMPKINWINDOW 32777 162 | #define ID_TRAY_OPENFILESFOLDER 32778 163 | #define ID_TRAY_LISTEN 32780 164 | 165 | // Next default values for new objects 166 | // 167 | #ifdef APSTUDIO_INVOKED 168 | #ifndef APSTUDIO_READONLY_SYMBOLS 169 | #define _APS_NEXT_RESOURCE_VALUE 156 170 | #define _APS_NEXT_COMMAND_VALUE 32781 171 | #define _APS_NEXT_CONTROL_VALUE 1056 172 | #define _APS_NEXT_SYMED_VALUE 102 173 | #endif 174 | #endif 175 | -------------------------------------------------------------------------------- /shared-code/BellsNWhistles.h: -------------------------------------------------------------------------------- 1 | #ifndef __BELLSNWHISTLES_H 2 | #define __BELLSNWHISTLES_H 3 | 4 | class CBellsNWhistles { 5 | public: 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 CBangs; 26 | struct CBelling { 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 -------------------------------------------------------------------------------- /shared-code/BitSet.h: -------------------------------------------------------------------------------- 1 | #ifndef __BITSET_H 2 | #define __BITSET_H 3 | 4 | namespace Klever { 5 | 6 | class CBitSet : public CObject { 7 | public: 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=0;i--) 68 | m_Bits[i]=~m_Bits[i]; 69 | } 70 | CBitSet& operator&=(CBitSet& o) { 71 | if(o.m_BitsInSet=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 106 | -------------------------------------------------------------------------------- /shared-code/Dynamide.h: -------------------------------------------------------------------------------- 1 | #ifndef __DYNAMIDE_H 2 | #define __DYNAMIDE_H 3 | 4 | #include "LRUCache.h" 5 | 6 | namespace Klever { 7 | 8 | template 9 | class CDynamide : public CObject { 10 | struct firstBlock { 11 | LONG freeFile; 12 | BYTE crap[fbSize-sizeof(LONG)]; 13 | }; 14 | struct theBlock { 15 | LONG next; 16 | BYTE data[bSize-sizeof(LONG)]; 17 | }; 18 | public: 19 | static firstBlock FirstBlock; 20 | static theBlock TheBlock; 21 | private: 22 | class CDynaCache : public CLRUCache { 23 | public: 24 | CFile* m_File; 25 | BOOL m_bAutodelete; 26 | CDynaCache(CFile* file,BOOL bAutodelete=TRUE) : CLRUCache(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 | }; 118 | public: 119 | class CDynaFile : public CFile { 120 | public: 121 | CDynamide* m_Daddy; 122 | CArray m_Blocks; 123 | LONG m_Position; 124 | 125 | CDynaFile(CDynamide* daddy) : m_Daddy(NULL) { AttachToDaddy(daddy); } 126 | virtual ~CDynaFile() { Close(); DetachFromDaddy(); } 127 | 128 | void AttachToDaddy(CDynamide* 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(dwNewLen1){ 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_Positionm_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 444 | -------------------------------------------------------------------------------- /shared-code/FindIFace.h: -------------------------------------------------------------------------------- 1 | #ifndef __FINDIFACE_H 2 | #define __FINDIFACE_H 3 | 4 | #include "SNMPeer.h" 5 | #include "SNMPExtDLL.h" 6 | #include "SNMPOIDs.h" 7 | 8 | namespace Klever { 9 | 10 | inline 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]; 23 | int nRoutes = 0; 24 | CSNMPVarBindList 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)))); 29 | CSNMPExtDLL 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; 75 | int rn = 0; 76 | if(nRoutes>1){ 77 | for(int tmp=1;tmproutes[rn].nm 81 | ) 82 | rn = tmp; 83 | } 84 | int 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 126 | -------------------------------------------------------------------------------- /shared-code/LRUCache.h: -------------------------------------------------------------------------------- 1 | #ifndef __LRUCACHE_H 2 | #define __LRUCACHE_H 3 | 4 | namespace Klever { 5 | 6 | template 7 | class CLRUCache : public CObject { 8 | public: 9 | struct CacheEntry { 10 | enum cacheState { 11 | cacheClean, cacheDirty, cacheEmpty 12 | }; 13 | cacheState m_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 CCacheMap; 23 | typedef CList CCacheList; 24 | 25 | CCacheList m_Cache; 26 | CCacheMap m_Map; 27 | 28 | CLRUCache(UINT cacheSize) { 29 | for(int tmp=0;tmpm_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 | virtual BOOL _ReadIn(ARGIDX idx,DATA* data) = 0; 108 | virtual BOOL _WriteOut(ARGIDX idx,DATA* data) = 0; 109 | }; 110 | 111 | }; 112 | 113 | #endif // __LRUCACHE_H 114 | -------------------------------------------------------------------------------- /shared-code/RegEx.h: -------------------------------------------------------------------------------- 1 | #ifndef __REGEX_H 2 | #define __REGEX_H 3 | 4 | class CRegEx { 5 | public: 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 | typedef CArray 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 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 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); 104 | private: 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 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 CParens; 151 | CParens m_ParseParens; 152 | int m_ParsePointer; 153 | }; 154 | #ifdef _DEBUG 155 | inline CDumpContext& operator<<(CDumpContext& dc, CRegEx::CSop& sop) { sop.Dump(dc); return dc; } 156 | #endif 157 | 158 | #endif // __REGEX_H -------------------------------------------------------------------------------- /shared-code/SNMPExtDll.h: -------------------------------------------------------------------------------- 1 | #ifndef __SNMPEXTDLL_H 2 | #define __SNMPEXTDLL_H 3 | 4 | #include "snmpeer.h" 5 | 6 | #include 7 | 8 | namespace Klever { 9 | 10 | class CSNMPExtDLL : public CSNMPeer { 11 | public: 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;tmpsizeof(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 253 | -------------------------------------------------------------------------------- /shared-code/SNMPOIDs.h: -------------------------------------------------------------------------------- 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 -------------------------------------------------------------------------------- /shared-code/SNMPeer.h: -------------------------------------------------------------------------------- 1 | #ifndef __SNMPEER_H 2 | #define __SNMPEER_H 3 | 4 | namespace Klever { 5 | 6 | class CASNAny { 7 | public: 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 | typedef LONG asnInteger; 63 | typedef LARGE_INTEGER asnInteger64; 64 | typedef DWORD asnCounter; 65 | typedef ULARGE_INTEGER asnCounter64; 66 | typedef DWORD asnGauge; 67 | typedef ULARGE_INTEGER asnGauge64; 68 | typedef DWORD 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 | typedef asnDynamic 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 { 237 | public: 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 { 267 | public: 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 { 280 | public: 281 | virtual BOOL Request(BYTE type,CSNMPVarBindList& in,CSNMPVarBindList& ou) = 0; 282 | }; 283 | 284 | }; 285 | 286 | #endif // __SNMPEER_H 287 | -------------------------------------------------------------------------------- /shared-code/install.h: -------------------------------------------------------------------------------- 1 | #define WIN32_LEAN_AND_MEAN 2 | #define VC_EXTRALEAN 3 | #define WIN32_EXTRALEAN 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | extern "C" WINSHELLAPI void WINAPI SHFree( LPVOID); 12 | 13 | template class Smart { 14 | public: 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 | typedef Smart STRING; 30 | 31 | #define APPEND_SLASH(str) if((str)[strlen(str)-1]!='\\')strcat(str,"\\") 32 | 33 | HINSTANCE theInstance; 34 | 35 | LPSTR strFETCH_REG_KEY(HKEY hRoot,LPCSTR subKey,LPCSTR val) 36 | { 37 | HKEY hkey; 38 | if(RegOpenKeyEx(hRoot,subKey,0,KEY_QUERY_VALUE,&hkey)!=ERROR_SUCCESS) 39 | return NULL; 40 | DWORD kType,cb=0; 41 | STRING 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 | 52 | BOOL strSET_REG_KEY(HKEY hRoot,LPCSTR subKey,LPCSTR valName,LPCSTR val) 53 | { 54 | HKEY hkey; 55 | DWORD 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; 58 | BOOL rv = (RegSetValueEx(hkey,valName,0,REG_SZ,(LPBYTE)val,strlen(val)+1)==ERROR_SUCCESS); 59 | RegCloseKey(hkey); 60 | return rv; 61 | } 62 | 63 | void MAKE_PATH(LPCSTR path) 64 | { 65 | STRING tmp(strlen(path)+1); 66 | LPCSTR t0=path; 67 | LPSTR 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 | 79 | BOOL ADDMENU(LPCSTR menu,LPCSTR item,LPCSTR path,LPCSTR program) 80 | { 81 | STRING stm = strFETCH_REG_KEY(HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders","Programs"); 82 | if(!stm) 83 | return FALSE; 84 | int pil = 1+strlen(path)+1+strlen(program)+1+1; 85 | STRING pi(pil); 86 | strcpy(pi,path); 87 | APPEND_SLASH(pi); 88 | strcat(pi,program); 89 | int ipl = strlen(stm)+1+strlen(menu)+1+strlen(item)+4+1; 90 | STRING 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"); 98 | IShellLink* sl = NULL; 99 | IPersistFile* pf = NULL; 100 | BOOL 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 | 123 | FILE* CREATE_INF_FILE(LPCSTR path,LPCSTR file) 124 | { 125 | STRING 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 | 132 | BOOL INSTALLFILE(LPCSTR res,LPCSTR path,LPCSTR file) 133 | { 134 | STRING temp(MAX_PATH); 135 | if(!GetTempPath(MAX_PATH,temp)) return FALSE; 136 | STRING tf(MAX_PATH); 137 | if(!GetTempFileName(temp,"KGI",0,tf)) return FALSE; 138 | HRSRC hrsrc = FindResource(NULL,res,MAKEINTRESOURCE(RT_RCDATA)); 139 | if(!hrsrc) return FALSE; 140 | DWORD sor = SizeofResource(NULL,hrsrc); 141 | if(!sor) return FALSE; 142 | HGLOBAL hglobal = LoadResource(NULL,hrsrc); 143 | if(!hglobal) return FALSE; 144 | LPVOID lpv = LockResource(hglobal); 145 | if(!lpv) return FALSE; 146 | HANDLE 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; 148 | DWORD written = 0; 149 | if(!WriteFile(hf,lpv,sor,&written,NULL) || written!=sor){ 150 | CloseHandle(hf); 151 | return FALSE; 152 | } 153 | CloseHandle(hf); 154 | STRING 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; 159 | STRING nothing(_MAX_PATH); 160 | UINT nothingLength=_MAX_PATH; 161 | if(VerInstallFile(0,&tf[tmp],(LPSTR)file,tf,(LPSTR)path,NULL,nothing,¬hingLength)){ 162 | DeleteFile(toKill); 163 | return FALSE; 164 | } 165 | DeleteFile(toKill); 166 | return TRUE; 167 | } 168 | 169 | LPCSTR pdTitle, pdPrompt; 170 | char pdPath[_MAX_PATH]; 171 | BOOL 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 | 226 | LPSTR 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; 232 | STRING rv(strlen(pdPath)+1); 233 | strcpy(rv,pdPath); 234 | return rv.Detach(); 235 | } 236 | 237 | HKEY 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 | 247 | BOOL 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 | } 270 | BOOL 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 | } 287 | BOOL 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 | } 297 | BOOL 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 | } 307 | BOOL 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 | } 317 | BOOL 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 | } 327 | BOOL 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 | #define INF_FILE_HEADER(i) fprintf(i,"[Version]\nSignature=\"$CHICAGO$\"\n\n") 341 | #define INF_FILE_SECTION(i,s) fprintf(i,"\n[%s]\n",s) 342 | #define INF_UNINSTALL_REG(i,p) fprintf(i,"HKLM,Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s\nHKLM,Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s,DisplayName\nHKLM,Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s,UninstallString\n",p,p,p) 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 | 349 | LPSTR GET_SHORT_PATH(LPCSTR path) 350 | { 351 | char tmp; 352 | DWORD len = GetShortPathName(path,&tmp,1); 353 | if(!len) 354 | return NULL; 355 | STRING rv(len+1); 356 | if(!GetShortPathName(path,rv,len+1)) 357 | return NULL; 358 | return rv.Detach(); 359 | } 360 | 361 | BOOL Install(void); 362 | 363 | int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE,LPSTR,int) 364 | { 365 | theInstance=hInstance; 366 | CoInitialize(NULL); 367 | Install(); 368 | CoUninitialize(); 369 | return 0; 370 | } 371 | -------------------------------------------------------------------------------- /shared-code/ip_icmp.h: -------------------------------------------------------------------------------- 1 | #ifndef IP_ICMPHEADER 2 | 3 | #define IP_ICMPHEADER 4 | 5 | struct 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 | 17 | struct 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 | 92 | -------------------------------------------------------------------------------- /shared-code/kHelpers.h: -------------------------------------------------------------------------------- 1 | #ifndef __KHELPERS_H 2 | #define __KHELPERS_H 3 | 4 | #include 5 | 6 | extern "C" WINSHELLAPI void WINAPI SHFree( LPVOID); 7 | 8 | namespace 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 160 | -------------------------------------------------------------------------------- /shared-code/kICMP.cpp: -------------------------------------------------------------------------------- 1 | #include "../stdafx.h" 2 | #include "kICMP.h" 3 | 4 | CICMP::_mechanismus CICMP::m_mechanismus = CICMP::_icmpUndetermined; 5 | 6 | BOOL 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 | } 26 | void 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 | 47 | LONG 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)); 56 | IPINFO ipi; 57 | memset(&ipi,0,sizeof(ipi)); 58 | ipi.Ttl = 30; 59 | for(UINT tmp=0;tmpStatus = 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"); 68 | LONG lrv = -1; 69 | INT 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 | 98 | BOOL 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 | } 109 | UINT 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 | 121 | WORD CICMPWS::m_icmpSeq = 0; 122 | 123 | BOOL 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 | } 133 | void 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 | } 148 | LONG 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)); 156 | icmp* 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;tmpicmp_data[tmp]=tmp&0xFF; 163 | pPacket->icmp_cksum = cksum(pPacket,SIZE_ICMP_HDR+packetSize); 164 | sockaddr_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 | } 175 | DWORD sentTime = ::GetTickCount(); 176 | sockaddr_in from; 177 | memset(&from,0,sizeof(from)); 178 | from.sin_family=AF_INET; 179 | from.sin_addr.s_addr=INADDR_ANY; 180 | fd_set fds; 181 | FD_ZERO(&fds); 182 | FD_SET(m_socket,&fds); 183 | long lrv = -1; 184 | INT 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 | 224 | BOOL CICMPWS::AdjustBuffers(UINT packetSize) 225 | { 226 | if(!packetSize) 227 | packetSize=0; 228 | UINT osize = packetSize+SIZE_ICMP_HDR; 229 | if(m_sizeOut0){ 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 | 265 | CICMP* 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 | 280 | void CICMP::GuessMechanismus() 281 | { 282 | m_mechanismus=_icmpUndetermined; 283 | SOCKET 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 | } -------------------------------------------------------------------------------- /shared-code/kICMP.h: -------------------------------------------------------------------------------- 1 | #ifndef __KICMP_H 2 | #define __KICMP_H 3 | 4 | class CICMP { 5 | enum _mechanismus { 6 | _icmpUndetermined = -1, 7 | _icmpWinsock = 0, _icmpDLL 8 | }; 9 | static _mechanismus m_mechanismus; 10 | static void GuessMechanismus(); 11 | public: 12 | static 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 | 34 | class 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); 39 | public: 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 | 58 | class CICMPWS : public CICMP { 59 | static 60 | WORD m_icmpSeq; 61 | public: 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 -------------------------------------------------------------------------------- /shared-code/kinhelp.xsl: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 10 | 11 | {\rtf1\ansi 12 | @{\footnote 13 | THIS FILE WAS AUTOMATICALLY GENERATED FROM XML DOCUMENT. 14 | DO NOT MODIFY THIS FILE DIRECTLY. EDIT XML DOCUMENT INSTEAD 15 | } 16 | 17 | 18 | 19 | } 20 | 21 | 22 | 23 | \pard\plain 24 | 26 | \keepn 27 | 28 | 29 | #{\footnote 30 | 31 | } 32 | 33 | 34 | ${\footnote 35 | 36 | } 37 | 38 | 39 | K{\footnote 40 | 41 | } 42 | 43 | 44 | \page 45 | 46 | 47 | 48 | {#{\footnote 49 | 50 | }} 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 64 | {\uldb 65 | 66 | }{\v %!ExecFile(" 67 | 68 | ")} 69 | 70 | 71 | {\uldb 72 | 73 | }{\v 74 | 75 | } 76 | 77 | 78 | Warining: Unqualified hyper-reference. Using as help-internal 79 | {\uldb 80 | 81 | }{\v 82 | 83 | } 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | \pard 92 | 93 | { \f1\fs18\b\sb120 94 | 95 | } 96 | 97 | 98 | 99 | \par\sa120\sb120\qj 100 | 101 | \pard 102 | 103 | \f1\fs18\sb120 104 | 105 | 106 | 107 | 108 | \par\sa120\sb120\qj\f1\fs16 109 | 110 | 111 | 112 | 113 | \par\sa120\sb120\qr\f1\fs16 114 | 115 | 116 | 117 | 118 | \{bmct 119 | 120 | \} 121 | 122 | 123 | 124 | \par\pard\plain\f1\fs24\qc\cf2\b 125 | 126 | - 127 | 128 | 129 | 130 | 131 | \par\pard\plain\fi0\li0\f1\fs18 \bullet 132 | 133 | 134 | 135 | 136 | {\b 137 | 138 | } 139 | 140 | 141 | {\i 142 | 143 | } 144 | 145 | 146 | {\ul 147 | 148 | } 149 | 150 | 151 | {\strike 152 | 153 | } 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | {\b } 162 | 163 | 164 | 165 | {\b 166 | 167 | } 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | {\b\cf6 } 177 | 178 | 179 | 180 | {\b\cf6 181 | 182 | } 183 | 184 | 185 | 186 | 187 | {\i 188 | 189 | } 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | { 201 | \par\pard\plain\sb360\sa120 \f1\fs16 Copyright (c) 202 | 203 | {\uldb\cf0 Klever Group (http://www.klever.net/)}{\v %!ExecFile("http://www.klever.net/")} 204 | \par\qj\sb120\sa120 205 | 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: 206 | \par The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 207 | \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. 208 | } 209 | 210 | 211 | \par \sa0\sb120\ql \f1\fs16 Author: {\b\uldb\cf11 Michael Krelin ({\i hacker@klever.net})}{\v %!ExecFile("mailto:hacker@klever.net")} 212 | \par \sa0\sb0 Fan mail send to {\i\uldb gefilte@klever.net}{\v %!ExecFile("mailto:gefilte@klever.net")} 213 | 214 | 215 | 216 | \pard 217 | 218 | \pard 219 | 220 | 221 | 222 | 223 | \par \fi0\li \bullet 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | {\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 | 241 | 242 | 243 | {\fonttbl 244 | {\f0\froman Times New Roman;} 245 | {\f1\fswiss Arial;} 246 | {\f3\froman Symbol;} 247 | } 248 | 249 | 250 | 251 | -------------------------------------------------------------------------------- /shared-code/ms_icmp.h: -------------------------------------------------------------------------------- 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. */ 14 | typedef 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. */ 26 | typedef 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 | 65 | HANDLE WINAPI PASCAL IcmpCreateFile(VOID); /* INVALID_HANDLE_VALUE on error */ 66 | BOOL WINAPI PASCAL IcmpCloseHandle(HANDLE IcmpHandle); /* FALSE on error */ 67 | DWORD 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 | 78 | -------------------------------------------------------------------------------- /shared-data/browse-icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klevernothings/pumpkin/13a91d9b1723628301f9ace03e53a592ed4dda4a/shared-data/browse-icon.ico -------------------------------------------------------------------------------- /shared-data/install-icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klevernothings/pumpkin/13a91d9b1723628301f9ace03e53a592ed4dda4a/shared-data/install-icon.ico -------------------------------------------------------------------------------- /shared-data/klever-background.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klevernothings/pumpkin/13a91d9b1723628301f9ace03e53a592ed4dda4a/shared-data/klever-background.bmp -------------------------------------------------------------------------------- /shared-data/play-icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/klevernothings/pumpkin/13a91d9b1723628301f9ace03e53a592ed4dda4a/shared-data/play-icon.ico -------------------------------------------------------------------------------- /stdafx.cpp: -------------------------------------------------------------------------------- 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 | 7 | -------------------------------------------------------------------------------- /stdafx.h: -------------------------------------------------------------------------------- 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 // MFC core and standard components 9 | #include // MFC extensions 10 | #ifndef _AFX_NO_AFXCMN_SUPPORT 11 | #include // MFC support for Windows 95 Common Controls 12 | #endif // _AFX_NO_AFXCMN_SUPPORT 13 | 14 | #include 15 | 16 | #include // MFC socket extensions 17 | #include 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" --------------------------------------------------------------------------------