home *** CD-ROM | disk | FTP | other *** search
- //
- // Copyright (c) 1997 Content Technologies Limited. All rights reserved.
- //
- // HEADER
- //
- // urlblock.hpp
- //
- // PACKAGE
- //
- // UBK - URL Blocker
- //
- // DESCRIPTION
- //
- // Use this class to derive your own URL blocker class. This class provides two methods for
- // accessing the section of the configuration file that relates to this URL blocker. String
- // values that need to be returned to the user make use of the BDS_Buffer class to save
- // your class from having to perform the memory management that would be necessarry,
- // otherwise.
- //
- //
- // REFERENCES
- //
- // None.
- //
- // HISTORY
- //
- // AUTHOR DATE CHANGES
- //
- // Dominic Chambers 12-December-1997 Initial Version
- // Dominic Chamber 13-January-1998 Host IP address is now a parameter
- // of url block queries.
- // Dominic Chambers 16-January-1998 Corrected error in comments
- //
-
- #ifndef _URLBLOCK_HPP
- #define _URLBLOCK_HPP
-
- #include "urlblock.h"
- #include "bds\bds_buff.hpp"
-
- // base class
- class Url_blocker
- {
- public:
- Url_blocker();
- // constructor
-
- virtual ~Url_blocker();
- // destructor
-
- virtual BOOL block_query(char* url, long host_ip_addr, BDS_Buffer& reason_text)=0;
- // must be overridden to block urls. return TRUE if url is should be blocked or
- // return FALSE and provide a reason in reason_text, otherwise. The host_ip_addr
- // parameter can be used to identify the computer the request originated from.
- // N.B. The reason text may be plain text or html, in which case it will be
- // placed inside a standard WEBsweeper notice page, or it can be a full HTTP
- // response, in which case it will be returned to the client browser without
- // modification.
-
- virtual BOOL thread_safe() {return TRUE;};
- // override if your block_query method is not thread safe.
-
- virtual BOOL initialise() {return TRUE;};
- // override so that you can check the configuration file is valid, and any other
- // custom requirements you may have.
-
- virtual void terminate() {};
- // do any cleaning up you may need to do here.
-
- friend BOOL _declspec(dllexport) url_block_init(char* config_file_name, char* config_section);
- friend BOOL _declspec(dllexport) url_block_query(char* url, long host_ip_addr, char* reason_text, int buff_size);
- friend void _declspec(dllexport) url_block_terminate(void);
-
- protected:
- BOOL get_first_config_entry(BDS_Buffer& key, BDS_Buffer& value) const;
- // provides access to the first configuration line. method will return FALSE
- // if this line does not exist.
-
- BOOL get_next_config_entry(BDS_Buffer& key, BDS_Buffer& value) const;
- // provides access to the next configuration line. method will return FALSE
- // if this line does not exist.
-
- private:
- BOOL m_initialised;
- void* m_configuration;
- void* m_mutex;
- };
-
- #endif