Enjoy OO in driver instead of the same old boring ifdefery.

This commit is contained in:
riccardom 2010-04-20 22:42:50 +00:00
parent 8c80050dbe
commit 96a47a4af9
2 changed files with 34 additions and 29 deletions

View File

@ -46,7 +46,6 @@ public:
~BaseDriver();
#ifdef EXPERIMENTAL_WIFI_COMM
#ifdef _WINDOWS
virtual bool WIFI_SocketsAvailable() { return true; }
virtual bool WIFI_PCapAvailable() { return false; }
@ -59,33 +58,7 @@ public:
virtual int PCAP_setnonblock(pcap_t* dev, int nonblock, char* errbuf) { return -1; }
virtual int PCAP_sendpacket(pcap_t* dev, const u_char* data, int len) { return -1; }
virtual int PCAP_dispatch(pcap_t* dev, int num, pcap_handler callback, u_char* userdata) { return -1; }
#else
virtual bool WIFI_SocketsAvailable() { return true; }
virtual bool WIFI_PCapAvailable() { return true; }
virtual bool WIFI_WFCWarning() { return false; }
virtual int PCAP_findalldevs(pcap_if_t** alldevs, char* errbuf) {
return pcap_findalldevs(alldevs, errbuf); }
virtual void PCAP_freealldevs(pcap_if_t* alldevs) {
pcap_freealldevs(alldevs); }
virtual pcap_t* PCAP_open(const char* source, int snaplen, int flags, int readtimeout, char* errbuf) {
return pcap_open_live(source, snaplen, flags, readtimeout, errbuf); }
virtual void PCAP_close(pcap_t* dev) {
pcap_close(dev); }
virtual int PCAP_setnonblock(pcap_t* dev, int nonblock, char* errbuf) {
return pcap_setnonblock(dev, nonblock, errbuf); }
virtual int PCAP_sendpacket(pcap_t* dev, const u_char* data, int len) {
return pcap_sendpacket(dev, data, len); }
virtual int PCAP_dispatch(pcap_t* dev, int num, pcap_handler callback, u_char* userdata) {
return pcap_dispatch(dev, num, callback, userdata); }
#endif /* WINDOWS */
#endif /* EXPERIMENTAL_WIFI_COMM */
#endif
virtual void AVI_SoundUpdate(void* soundData, int soundLen) {}
virtual bool AVI_IsRecording() { return FALSE; }
@ -122,4 +95,36 @@ public:
};
extern BaseDriver* driver;
#ifndef _WINDOWS
class UnixDriver : public BaseDriver
{
#ifdef EXPERIMENTAL_WIFI_COMM
virtual bool WIFI_SocketsAvailable() { return true; }
virtual bool WIFI_PCapAvailable() { return true; }
virtual bool WIFI_WFCWarning() { return true; }
virtual int PCAP_findalldevs(pcap_if_t** alldevs, char* errbuf) {
return pcap_findalldevs(alldevs, errbuf); }
virtual void PCAP_freealldevs(pcap_if_t* alldevs) {
pcap_freealldevs(alldevs); }
virtual pcap_t* PCAP_open(const char* source, int snaplen, int flags, int readtimeout, char* errbuf) {
return pcap_open_live(source, snaplen, flags, readtimeout, errbuf); }
virtual void PCAP_close(pcap_t* dev) {
pcap_close(dev); }
virtual int PCAP_setnonblock(pcap_t* dev, int nonblock, char* errbuf) {
return pcap_setnonblock(dev, nonblock, errbuf); }
virtual int PCAP_sendpacket(pcap_t* dev, const u_char* data, int len) {
return pcap_sendpacket(dev, data, len); }
virtual int PCAP_dispatch(pcap_t* dev, int num, pcap_handler callback, u_char* userdata) {
return pcap_dispatch(dev, num, callback, userdata); }
#endif
};
#endif
#endif //_DRIVER_H_

View File

@ -1693,7 +1693,7 @@ static inline void _updateDTools()
/////////////////////////////// MAIN EMULATOR LOOP ///////////////////////////////
class GtkDriver : public BaseDriver
class GtkDriver : public UnixDriver
{
public:
virtual void EMU_DebugIdleUpdate()