Добавил:
korayakov
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Лабы / 2 / lab.05.by mice / spice / src / csp_filter
.h/*******************************************************************************
* file: csp_filter.h *
* version: 0.0.1 *
* author: d-evil [tmd] (mailto:d-evil.tmd@mail.ru) *
* description: not available *
*******************************************************************************/
#ifndef CSP_FILTER_INCLUDED
#define CSP_FILTER_INCLUDED
////////////////////////////////////////////////////////////////////////////////
// headers
#include <afx.h>
#include <afxwin.h>
#include <afxdlgs.h>
#include <afxcmn.h>
#include <shlwapi.h>
#include <winsock2.h>
#include <stdio.h>
#include <vector>
#include "csp_parser.h"
#include "win_errors.h"
#include "resource.h"
////////////////////////////////////////////////////////////////////////////////
// csp_filter declaration
class csp_filter: public CDialog {
public:
////////////////////////////////////////////////////////////////////////////
// csp_filter public constants
static const int MODE_ONLY = 0x0;
static const int MODE_EXCEPT = 0xE;
static const int SPM_FLT_CLOSE_ME = WM_USER + 0xFCE;
static const char *DEF_FILTER_FILE;
csp_filter();
~csp_filter();
HICON get_icon() const { return _icon; }
void set_icon(const HICON icon) { _icon = icon; }
virtual BOOL OnInitDialog();
virtual void OnOK() {}
virtual void OnCancel() {}
virtual void OnClose();
int create(CWnd *const parent);
int destroy();
int show();
int hide();
int apply();
int is_visible() const { return _is_visible; }
int update() { return _update(); }
int load_from_file(const char *const fn = NULL);
int save_to_file(const char *const fn = NULL);
int set_from_mode(const int mode);
int set_to_mode(const int mode);
int set_on_mode(const int mode);
bool test(const header_ip *const hdr);
protected:
////////////////////////////////////////////////////////////////////////////
// csp_filter public constants
static const int _DEF_BUF_LEN = 0xFF;
////////////////////////////////////////////////////////////////////////////
// csp_filter protected controls
CButton *_btn_ok;
CButton *_btn_cancel;
CButton *_btn_apply;
CButton *_btn_del_from;
CButton *_btn_del_to;
CButton *_btn_del_proto;
CButton *_btn_add_from;
CButton *_btn_add_to;
CButton *_btn_add_proto;
CButton *_btn_chk_only_to;
CButton *_btn_chk_excpt_to;
CButton *_btn_chk_only_from;
CButton *_btn_chk_excpt_from;
CButton *_btn_chk_only_proto;
CButton *_btn_chk_excpt_proto;
CEdit *_edit_host;
CListBox *_lsb_from;
CListBox *_lsb_to;
CListBox *_lsb_proto;
CComboBox *_cmb_proto;
////////////////////////////////////////////////////////////////////////////
// csp_filter protected event handlers
DECLARE_MESSAGE_MAP();
void _on_btn_ok();
void _on_btn_cancel();
void _on_btn_apply();
void _on_btn_del_from();
void _on_btn_del_to();
void _on_btn_del_proto();
void _on_btn_add_from();
void _on_btn_add_to();
void _on_btn_add_proto();
void _on_btn_chk_only_to();
void _on_btn_chk_excpt_to();
void _on_btn_chk_only_from();
void _on_btn_chk_excpt_from();
void _on_btn_chk_only_proto();
void _on_btn_chk_excpt_proto();
void _on_proto_drop();
////////////////////////////////////////////////////////////////////////////
// csp_filter protected functions
int _update();
void _set_no_filter();
int _proto_str(const unsigned char proto, CString &str);
template <class T>
int _get_val_pos(std::vector<T>& v, const T val);
private:
bool _is_visible;
bool _no_filter;
int _from_mode;
int _to_mode;
int _on_mode;
int _from_mode_tmp;
int _to_mode_tmp;
int _on_mode_tmp;
std::vector<unsigned int> _from_ips;
std::vector<unsigned int> _to_ips;
std::vector<unsigned int> _from_ips_tmp;
std::vector<unsigned int> _to_ips_tmp;
std::vector<unsigned int> _on_protos;
std::vector<unsigned int> _on_protos_tmp;
HICON _icon;
HANDLE _test_mtx;
};
#endif
Соседние файлы в папке src