Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Andrea Odetti 2021-05-20 11:50:21 +01:00
commit 6a3ba0bd72
22 changed files with 123 additions and 127 deletions

View file

@ -23,7 +23,7 @@ enum SS_CARDTYPE
CT_Saturn128K, // Saturn 128K (but may be populated with less RAM, in multiples of 16K)
};
enum SLOTS { SLOT0=0, SLOT1, SLOT2, SLOT3, SLOT4, SLOT5, SLOT6, SLOT7 };
enum SLOTS { SLOT0=0, SLOT1, SLOT2, SLOT3, SLOT4, SLOT5, SLOT6, SLOT7, NUM_SLOTS };
class Card
{

View file

@ -6,8 +6,6 @@ const double CLK_6502_NTSC = (_14M_NTSC * 65.0) / (65.0*14.0+2.0); // 65 cycles
const double CLK_6502_PAL = (_14M_PAL * 65.0) / (65.0*14.0+2.0);
//const double CLK_6502 = 23 * 44100; // 1014300
#define NUM_SLOTS 8
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
@ -143,6 +141,12 @@ enum AppMode_e
#define WM_USER_FULLSCREEN WM_USER+8
#define VK_SNAPSHOT_TEXT WM_USER+9 // PrintScreen+Ctrl
#ifdef _MSC_VER
#define PATH_SEPARATOR '\\'
#else
#define PATH_SEPARATOR '/'
#endif
enum eIRQSRC {IS_6522=0, IS_SPEECH, IS_SSC, IS_MOUSE};
//

View file

@ -6,6 +6,7 @@
#include "../DiskImage.h" // Disk_Status_e
#include "../Harddisk.h" // HD_CardIsEnabled()
#include "../Interface.h" // VideoRefreshRate_e, GetVideoRefreshRate()
#include "../Tfe/tfe.h"
class CConfigNeedingRestart
{
@ -23,6 +24,9 @@ public:
m_Slot[SLOT4] = GetCardMgr().QuerySlot(SLOT4);
m_Slot[SLOT5] = GetCardMgr().QuerySlot(SLOT5);
m_Slot[SLOT7] = GetCardMgr().QuerySlot(SLOT7);
m_tfeEnabled = get_tfe_enabled();
m_tfeInterface = get_tfe_interface();
}
const CConfigNeedingRestart& operator= (const CConfigNeedingRestart& other)
@ -31,6 +35,8 @@ public:
m_CpuType = other.m_CpuType;
memcpy(m_Slot, other.m_Slot, sizeof(m_Slot));
m_bEnableHDD = other.m_bEnableHDD;
m_tfeEnabled = other.m_tfeEnabled;
m_tfeInterface = other.m_tfeInterface;
m_bEnableTheFreezesF8Rom = other.m_bEnableTheFreezesF8Rom;
m_uSaveLoadStateMsg = other.m_uSaveLoadStateMsg;
m_videoRefreshRate = other.m_videoRefreshRate;
@ -43,6 +49,8 @@ public:
m_CpuType == other.m_CpuType &&
memcmp(m_Slot, other.m_Slot, sizeof(m_Slot)) == 0 &&
m_bEnableHDD == other.m_bEnableHDD &&
m_tfeEnabled == other.m_tfeEnabled &&
m_tfeInterface == other.m_tfeInterface &&
m_bEnableTheFreezesF8Rom == other.m_bEnableTheFreezesF8Rom &&
m_uSaveLoadStateMsg == other.m_uSaveLoadStateMsg &&
m_videoRefreshRate == other.m_videoRefreshRate;
@ -58,6 +66,8 @@ public:
SS_CARDTYPE m_Slot[NUM_SLOTS]; // 0..7
SS_CARDTYPE m_SlotAux;
bool m_bEnableHDD;
int m_tfeEnabled;
std::string m_tfeInterface;
UINT m_bEnableTheFreezesF8Rom;
UINT m_uSaveLoadStateMsg;
VideoRefreshRate_e m_videoRefreshRate;

View file

@ -238,6 +238,11 @@ INT_PTR CPageConfig::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPA
EnableTrackbar(hWnd, bCustom);
}
{
m_PageConfigTfe.m_tfe_enabled = get_tfe_enabled();
m_PageConfigTfe.m_tfe_interface_name = get_tfe_interface();
}
InitOptions(hWnd);
break;
@ -310,6 +315,9 @@ void CPageConfig::DlgOK(HWND hWnd)
m_PropertySheetHelper.GetConfigNew().m_videoRefreshRate = isNewVideoRate50Hz ? VR_50HZ : VR_60HZ;
}
m_PropertySheetHelper.GetConfigNew().m_tfeEnabled = m_PageConfigTfe.m_tfe_enabled;
m_PropertySheetHelper.GetConfigNew().m_tfeInterface = m_PageConfigTfe.m_tfe_interface_name;
if (bVideoReinit)
{
win32Frame.FrameRefreshStatus(DRAW_TITLE);

View file

@ -196,29 +196,19 @@ void CPageConfigTfe::init_tfe_dialog(HWND hwnd)
HWND temp_hwnd;
int active_value;
int tfe_enable;
int xsize, ysize;
char *interface_name = NULL;
uilib_get_group_extent(hwnd, ms_leftgroup, &xsize, &ysize);
uilib_adjust_group_width(hwnd, ms_leftgroup);
uilib_move_group(hwnd, ms_rightgroup, xsize + 30);
//resources_get_value("ETHERNET_ACTIVE", (void *)&tfe_enabled);
get_tfe_enabled(&tfe_enable);
//resources_get_value("ETHERNET_AS_RR", (void *)&tfe_as_rr_net);
active_value = (tfe_enable ? 1 : 0);
active_value = (m_tfe_enabled > 0 ? 1 : 0);
temp_hwnd=GetDlgItem(hwnd,IDC_TFE_SETTINGS_ENABLE);
SendMessage(temp_hwnd, CB_ADDSTRING, 0, (LPARAM)"Disabled");
SendMessage(temp_hwnd, CB_ADDSTRING, 0, (LPARAM)"Uthernet");
SendMessage(temp_hwnd, CB_SETCURSEL, (WPARAM)active_value, 0);
//resources_get_value("ETHERNET_INTERFACE", (void *)&interface_name);
interface_name = (char *) get_tfe_interface();
if (tfe_enumadapter_open())
{
int cnt = 0;
@ -232,7 +222,7 @@ void CPageConfigTfe::init_tfe_dialog(HWND hwnd)
{
BOOL this_entry = FALSE;
if (strcmp(pname, interface_name) == 0)
if (strcmp(pname, m_tfe_interface_name.c_str()) == 0)
{
this_entry = TRUE;
}
@ -274,7 +264,6 @@ void CPageConfigTfe::init_tfe_dialog(HWND hwnd)
void CPageConfigTfe::save_tfe_dialog(HWND hwnd)
{
int active_value;
int tfe_enabled;
char buffer[256];
buffer[255] = 0;
@ -283,16 +272,13 @@ void CPageConfigTfe::save_tfe_dialog(HWND hwnd)
// RGJ - Added check for NULL interface so we don't set it active without a valid interface selected
if (strlen(buffer) > 0)
{
RegSaveString(TEXT(REG_CONFIG), TEXT(REGVALUE_UTHERNET_INTERFACE), 1, buffer);
m_tfe_interface_name = buffer;
active_value = SendMessage(GetDlgItem(hwnd, IDC_TFE_SETTINGS_ENABLE), CB_GETCURSEL, 0, 0);
tfe_enabled = active_value >= 1 ? 1 : 0;
REGSAVE(TEXT(REGVALUE_UTHERNET_ACTIVE) ,tfe_enabled);
m_tfe_enabled = active_value >= 1 ? 1 : 0;
}
else
{
REGSAVE(TEXT(REGVALUE_UTHERNET_ACTIVE) ,0);
m_tfe_enabled = 0;
m_tfe_interface_name.clear();
}
}

View file

@ -3,17 +3,23 @@
#include "IPropertySheetPage.h"
#include "../Tfe/Uilib.h"
#include <string>
class CPageConfigTfe : private IPropertySheetPage
{
public:
CPageConfigTfe()
{
CPageConfigTfe::ms_this = this;
m_tfe_enabled = 0;
}
virtual ~CPageConfigTfe(){}
static INT_PTR CALLBACK DlgProc(HWND window, UINT message, WPARAM wparam, LPARAM lparam);
int m_tfe_enabled;
std::string m_tfe_interface_name;
protected:
// IPropertySheetPage
virtual INT_PTR DlgProcInternal(HWND window, UINT message, WPARAM wparam, LPARAM lparam);

View file

@ -370,6 +370,17 @@ void CPropertySheetHelper::ApplyNewConfig(const CConfigNeedingRestart& ConfigNew
{
REGSAVE(TEXT(REGVALUE_VIDEO_REFRESH_RATE), ConfigNew.m_videoRefreshRate);
}
if (CONFIG_CHANGED_LOCAL(m_tfeEnabled))
{
REGSAVE(TEXT(REGVALUE_UTHERNET_ACTIVE), ConfigNew.m_tfeEnabled);
}
if (CONFIG_CHANGED_LOCAL(m_tfeInterface))
{
RegSaveString(TEXT(REG_CONFIG), TEXT(REGVALUE_UTHERNET_INTERFACE), 1, ConfigNew.m_tfeInterface);
}
}
void CPropertySheetHelper::ApplyNewConfig(void)
@ -387,6 +398,8 @@ void CPropertySheetHelper::SaveCurrentConfig(void)
m_ConfigOld.m_bEnableHDD = HD_CardIsEnabled();
m_ConfigOld.m_bEnableTheFreezesF8Rom = GetPropertySheet().GetTheFreezesF8Rom();
m_ConfigOld.m_videoRefreshRate = GetVideo().GetVideoRefreshRate();
m_ConfigOld.m_tfeEnabled = get_tfe_enabled();
m_ConfigOld.m_tfeInterface = get_tfe_interface();
// Reset flags each time:
m_ConfigOld.m_uSaveLoadStateMsg = 0;
@ -470,6 +483,9 @@ bool CPropertySheetHelper::HardwareConfigChanged(HWND hWnd)
if (CONFIG_CHANGED(m_bEnableTheFreezesF8Rom))
strMsgMain += ". F8 ROM changed (The Freeze's F8 Rom)\n";
if (CONFIG_CHANGED(m_tfeEnabled) || CONFIG_CHANGED(m_tfeInterface))
strMsgMain += ". Ethernet (TFE) Options\n";
}
std::string strMsgPost("\n");

View file

@ -288,8 +288,8 @@ bool SetCurrentImageDir(const std::string& pszImageDir)
{
g_sCurrentDir = pszImageDir;
if (!g_sCurrentDir.empty() && *g_sCurrentDir.rbegin() != '\\')
g_sCurrentDir += '\\';
if (!g_sCurrentDir.empty() && *g_sCurrentDir.rbegin() != PATH_SEPARATOR)
g_sCurrentDir += PATH_SEPARATOR;
if (SetCurrentDirectory(g_sCurrentDir.c_str()))
return true;

View file

@ -3690,7 +3690,7 @@ Update_t CmdConfigSetDebugDir (int nArgs)
{
sPath = g_aArgs[1].sArg;
}
else if (g_aArgs[1].sArg[0] == '\\') // Absolute
else if (g_aArgs[1].sArg[0] == PATH_SEPARATOR) // Absolute
{
if (g_sCurrentDir[1] == ':')
{
@ -5982,7 +5982,7 @@ Update_t CmdOutputRun (int nArgs)
sMiniFileName = pFileName.substr(0, MIN(pFileName.size(), CONSOLE_WIDTH));
// strcat( sMiniFileName, ".aws" ); // HACK: MAGIC STRING
if (pFileName[0] == '\\' || pFileName[1] == ':') // NB. Any prefix quote has already been stripped
if (pFileName[0] == PATH_SEPARATOR || pFileName[1] == ':') // NB. Any prefix quote has already been stripped
{
// Abs pathname
sFileName = sMiniFileName;

View file

@ -202,7 +202,7 @@ void Disk2InterfaceCard::SaveLastDiskImage(const int drive)
TCHAR szPathName[MAX_PATH];
StringCbCopy(szPathName, MAX_PATH, DiskGetFullPathName(drive).c_str());
TCHAR* slash = _tcsrchr(szPathName, TEXT('\\'));
TCHAR* slash = _tcsrchr(szPathName, TEXT(PATH_SEPARATOR));
if (slash != NULL)
{
slash[1] = '\0';
@ -599,7 +599,7 @@ void Disk2InterfaceCard::GetFilenameAndPathForSaveState(std::string& filename, s
filename = GetBaseName(i);
std::string pathname = DiskGetFullPathName(i);
int idx = pathname.find_last_of('\\');
int idx = pathname.find_last_of(PATH_SEPARATOR);
if (idx >= 0 && idx+1 < (int)pathname.length()) // path exists?
{
path = pathname.substr(0, idx+1);

View file

@ -260,8 +260,8 @@ void GetImageTitle(LPCTSTR pPathname, std::string & pImageName, std::string & pF
LPCTSTR startpos = pPathname;
// imagetitle = <FILENAME.EXT>
if (_tcsrchr(startpos, TEXT('\\')))
startpos = _tcsrchr(startpos, TEXT('\\'))+1;
if (_tcsrchr(startpos, TEXT(PATH_SEPARATOR)))
startpos = _tcsrchr(startpos, TEXT(PATH_SEPARATOR))+1;
_tcsncpy(imagetitle, startpos, MAX_DISK_FULL_NAME);
imagetitle[MAX_DISK_FULL_NAME] = 0;

View file

@ -1541,8 +1541,8 @@ void CImageHelperBase::GetCharLowerExt(TCHAR* pszExt, LPCTSTR pszImageFilename,
{
LPCTSTR pImageFileExt = pszImageFilename;
if (_tcsrchr(pImageFileExt, TEXT('\\')))
pImageFileExt = _tcsrchr(pImageFileExt, TEXT('\\'))+1;
if (_tcsrchr(pImageFileExt, TEXT(PATH_SEPARATOR)))
pImageFileExt = _tcsrchr(pImageFileExt, TEXT(PATH_SEPARATOR))+1;
if (_tcsrchr(pImageFileExt, TEXT('.')))
pImageFileExt = _tcsrchr(pImageFileExt, TEXT('.'));

View file

@ -175,7 +175,7 @@ static BYTE g_nHD_Command;
static HDD g_HardDisk[NUM_HARDDISKS];
static bool g_bSaveDiskImage = true; // Save the DiskImage name to Registry
static UINT g_uSlot = 7;
static UINT g_uSlot = SLOT7;
//===========================================================================
@ -247,9 +247,9 @@ static void HD_SaveLastDiskImage(const int iDrive)
char szPathName[MAX_PATH];
strcpy(szPathName, HD_GetFullPathName(iDrive).c_str());
if (_tcsrchr(szPathName, TEXT('\\')))
if (_tcsrchr(szPathName, TEXT(PATH_SEPARATOR)))
{
char* pPathEnd = _tcsrchr(szPathName, TEXT('\\'))+1;
char* pPathEnd = _tcsrchr(szPathName, TEXT(PATH_SEPARATOR))+1;
*pPathEnd = 0;
RegSaveString(TEXT(REG_PREFS), TEXT(REGVALUE_PREF_HDV_START_DIR), 1, szPathName);
}
@ -335,7 +335,7 @@ void HD_GetFilenameAndPathForSaveState(std::string& filename, std::string& path)
filename = HD_DiskGetBaseName(i);
std::string pathname = HD_GetFullPathName(i);
int idx = pathname.find_last_of('\\');
int idx = pathname.find_last_of(PATH_SEPARATOR);
if (idx >= 0 && idx+1 < (int)pathname.length()) // path exists?
{
path = pathname.substr(0, idx+1);

View file

@ -29,7 +29,7 @@ public:
static BYTE __stdcall IO(WORD PC, WORD uAddr, BYTE bWrite, BYTE uValue, ULONG nExecutedCycles);
static const UINT kMemModeInitialState;
static const UINT kSlot0 = 0;
static const UINT kSlot0 = SLOT0;
private:
UINT m_uLastRamWrite;

View file

@ -98,9 +98,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#define SY6522_DEVICE_A 0
#define SY6522_DEVICE_B 1
#define SLOT4 4
#define SLOT5 5
#define NUM_MB 2
#define NUM_DEVS_PER_MB 2
#define NUM_AY8910 (NUM_MB*NUM_DEVS_PER_MB)

View file

@ -86,8 +86,8 @@ static void Snapshot_SetPathname(const std::string& strPathname)
g_strSaveStateFilename = DEFAULT_SNAPSHOT_NAME;
g_strSaveStatePathname = g_sCurrentDir;
if (!g_strSaveStatePathname.empty() && *g_strSaveStatePathname.rbegin() != '\\')
g_strSaveStatePathname += "\\";
if (!g_strSaveStatePathname.empty() && *g_strSaveStatePathname.rbegin() != PATH_SEPARATOR)
g_strSaveStatePathname += PATH_SEPARATOR;
g_strSaveStatePathname.append(DEFAULT_SNAPSHOT_NAME);
g_strSaveStatePath = g_sCurrentDir;
@ -97,7 +97,7 @@ static void Snapshot_SetPathname(const std::string& strPathname)
std::string strFilename = strPathname; // Set default, as maybe there's no path
g_strSaveStatePath.clear();
int nIdx = strPathname.find_last_of('\\');
int nIdx = strPathname.find_last_of(PATH_SEPARATOR);
if (nIdx >= 0 && nIdx+1 < (int)strPathname.length()) // path exists?
{
strFilename = &strPathname[nIdx+1];
@ -113,12 +113,12 @@ void Snapshot_SetFilename(const std::string& filename, const std::string& path/*
if (path.empty())
return Snapshot_SetPathname(filename);
_ASSERT(filename.find('\\') == std::string::npos); // since we have a path, then filename mustn't contain a path too!
_ASSERT(filename.find(PATH_SEPARATOR) == std::string::npos); // since we have a path, then filename mustn't contain a path too!
// Ensure path is suffixed with '\' before adding filename
std::string pathname = path;
if (*pathname.rbegin() != '\\')
pathname += "\\";
if (*pathname.rbegin() != PATH_SEPARATOR)
pathname += PATH_SEPARATOR;
Snapshot_SetPathname(pathname+filename);
}

View file

@ -60,13 +60,6 @@ typedef unsigned int UINT;
/* ------------------------------------------------------------------------- */
/* variables needed */
/*
This variable is used when we need to postpone the initialization
because tfe_init() is not yet called
*/
static int should_activate = 0;
static int init_tfe_flag = 0;
/* status which received packages to accept
@ -100,7 +93,7 @@ int tfe_enabled = 0;
/* Flag: Do we use the "original" memory map or the memory map of the RR-Net? */
//static int tfe_as_rr_net = 0;
char *tfe_interface = NULL;
std::string tfe_interface;
/* TFE registers */
/* these are the 8 16-bit-ports for "I/O space configuration"
@ -397,7 +390,7 @@ static BYTE __stdcall TfeIo (WORD programcounter, WORD address, BYTE write, BYTE
void tfe_reset(void)
{
if (tfe_enabled && !should_activate)
if (tfe_enabled)
{
assert( tfe );
assert( tfe_packetpage );
@ -550,13 +543,7 @@ int tfe_activate(void) {
if(g_fh) fprintf( g_fh, "tfe_activate()." );
#endif
if (init_tfe_flag) {
return tfe_activate_i();
}
else {
should_activate = 1;
}
return 0;
return tfe_activate_i();
}
static
@ -565,28 +552,25 @@ int tfe_deactivate(void) {
if(g_fh) fprintf( g_fh, "tfe_deactivate()." );
#endif
if (should_activate)
should_activate = 0;
else {
if (init_tfe_flag)
return tfe_deactivate_i();
}
return 0;
return tfe_deactivate_i();
}
void tfe_init(void)
{
init_tfe_flag = 1;
if (!tfe_arch_init()) {
tfe_enabled = 0;
tfe_cannot_use = 1;
}
else
{
// the first time this is a NOOP
// but when called from RepeatInitialization()
// it ensures new settings are taken into account
if (tfe)
tfe_deactivate();
if (should_activate) {
should_activate = 0;
if (tfe_activate() < 0) {
// only activate if the settings say so
if (tfe_enabled && (tfe_activate() < 0)) {
tfe_enabled = 0;
tfe_cannot_use = 1;
}
@ -600,8 +584,7 @@ void tfe_shutdown(void)
if (tfe)
tfe_deactivate();
lib_free(tfe_interface);
tfe_interface = NULL;
tfe_interface.clear();
}
@ -1395,37 +1378,12 @@ int set_tfe_enabled(void *v, void *param)
static
int set_tfe_interface(void *v, void *param)
int set_tfe_interface(const std::string & name)
{
const char *name = (const char *)v;
if (tfe_interface != NULL && name != NULL
&& strcmp(name, tfe_interface) == 0)
return 0;
util_string_set(&tfe_interface, name);
if (tfe_enabled) {
/* ethernet is enabled, make sure that the new name is
taken account of
*/
if (tfe_deactivate() < 0) {
return -1;
}
if (tfe_activate() < 0) {
return -1;
}
/* virtually reset the LAN chip */
if (tfe) {
tfe_reset();
}
}
tfe_interface = name;
return 0;
}
/* ------------------------------------------------------------------------- */
/* commandline support functions */
@ -1547,21 +1505,19 @@ void get_disabled_state(int * param)
}
int update_tfe_interface(void *v, void *param)
int update_tfe_interface(const std::string & name)
{
return set_tfe_interface(v,param);
return set_tfe_interface(name);
}
void * get_tfe_interface(void)
const std::string & get_tfe_interface(void)
{
void *v;
v = tfe_interface;
return v;
return tfe_interface;
}
void get_tfe_enabled(int * param)
int get_tfe_enabled(void)
{
*param = tfe_enabled;
return tfe_enabled;
}
//#endif /* #ifdef HAVE_TFE */

View file

@ -29,6 +29,7 @@
#include "../CommonVICE/types.h"
#include <stdio.h>
#include <string>
/* define this only if VICE should write each and every frame received
and send into the VICE log
@ -43,7 +44,7 @@ extern int tfe_enabled;
extern void tfe_init(void);
extern int tfe_resources_init(void);
extern int tfe_cmdline_options_init(void);
extern int update_tfe_interface(void *v, void *param);
extern int update_tfe_interface(const std::string & name);
void get_disabled_state(int * param);
extern void tfe_reset(void);
@ -77,8 +78,8 @@ extern int tfe_enumadapter_open(void);
extern int tfe_enumadapter(char **ppname, char **ppdescription);
extern int tfe_enumadapter_close(void);
extern void* get_tfe_interface(void);
extern void get_tfe_enabled(int *tfe_enabled);
extern int get_tfe_enabled(void);
extern const std::string & get_tfe_interface(void);
extern FILE* g_fh; // Filehandle for log file

View file

@ -51,6 +51,7 @@
#ifdef _MSC_VER
typedef pcap_t *(*pcap_open_live_t)(const char *, int, int, int, char *);
typedef void (*pcap_close_t)(pcap_t *);
typedef int (*pcap_dispatch_t)(pcap_t *, int, pcap_handler, u_char *);
typedef int (*pcap_setnonblock_t)(pcap_t *, int, char *);
typedef int (*pcap_datalink_t)(pcap_t *);
@ -60,6 +61,7 @@ typedef int (*pcap_sendpacket_t)(pcap_t *p, u_char *buf, int size);
typedef const char *(*pcap_lib_version_t)(void);
static pcap_open_live_t p_pcap_open_live;
static pcap_close_t p_pcap_close;
static pcap_dispatch_t p_pcap_dispatch;
static pcap_setnonblock_t p_pcap_setnonblock;
static pcap_findalldevs_t p_pcap_findalldevs;
@ -80,6 +82,7 @@ void TfePcapFreeLibrary(void)
pcap_library = NULL;
p_pcap_open_live = NULL;
p_pcap_close = NULL;
p_pcap_dispatch = NULL;
p_pcap_setnonblock = NULL;
p_pcap_findalldevs = NULL;
@ -118,6 +121,7 @@ BOOL TfePcapLoadLibrary(void)
}
GET_PROC_ADDRESS_AND_TEST(pcap_open_live);
GET_PROC_ADDRESS_AND_TEST(pcap_close);
GET_PROC_ADDRESS_AND_TEST(pcap_dispatch);
GET_PROC_ADDRESS_AND_TEST(pcap_setnonblock);
GET_PROC_ADDRESS_AND_TEST(pcap_findalldevs);
@ -138,6 +142,7 @@ BOOL TfePcapLoadLibrary(void)
// libpcap is a standard package, just link to it
#define p_pcap_open_live pcap_open_live
#define p_pcap_close pcap_close
#define p_pcap_dispatch pcap_dispatch
#define p_pcap_setnonblock pcap_setnonblock
#define p_pcap_findalldevs pcap_findalldevs
@ -276,7 +281,7 @@ int tfe_arch_enumadapter_close(void)
}
static
BOOL TfePcapOpenAdapter(const char *interface_name)
BOOL TfePcapOpenAdapter(const std::string & interface_name)
{
pcap_if_t *TfePcapDevice = NULL;
@ -289,12 +294,12 @@ BOOL TfePcapOpenAdapter(const char *interface_name)
char *pdescription;
BOOL found = FALSE;
if (interface_name) {
if (!interface_name.empty()) {
/* we have an interface name, try it */
TfePcapDevice = TfePcapAlldevs;
while (tfe_enumadapter(&pname, &pdescription)) {
if (strcmp(pname, interface_name)==0) {
if (strcmp(pname, interface_name.c_str())==0) {
found = TRUE;
}
lib_free(pname);
@ -328,6 +333,8 @@ BOOL TfePcapOpenAdapter(const char *interface_name)
{
if(g_fh) fprintf(g_fh, "ERROR: TFE works only on Ethernet networks.\n");
tfe_enumadapter_close();
(*p_pcap_close)(TfePcapFP);
TfePcapFP = NULL;
return FALSE;
}
@ -365,7 +372,7 @@ void tfe_arch_post_reset( void )
#endif
}
int tfe_arch_activate(const char *interface_name)
int tfe_arch_activate(const std::string & interface_name)
{
#ifdef TFE_DEBUG_ARCH
if(g_fh) fprintf( g_fh, "tfe_arch_activate().\n" );
@ -381,6 +388,10 @@ void tfe_arch_deactivate( void )
#ifdef TFE_DEBUG_ARCH
if(g_fh) fprintf( g_fh, "tfe_arch_deactivate().\n" );
#endif
if (TfePcapFP) {
(*p_pcap_close)(TfePcapFP);
TfePcapFP = NULL;
}
}
void tfe_arch_set_mac( const BYTE mac[6] )

View file

@ -29,11 +29,12 @@
#define _TFEARCH_H
#include "../CommonVICE/types.h"
#include <string>
extern int tfe_arch_init(void);
extern void tfe_arch_pre_reset(void);
extern void tfe_arch_post_reset(void);
extern int tfe_arch_activate(const char *interface_name);
extern int tfe_arch_activate(const std::string & interface_name);
extern void tfe_arch_deactivate(void);
extern void tfe_arch_set_mac(const BYTE mac[6]);
extern void tfe_arch_set_hashfilter(const DWORD hash_mask[2]);

View file

@ -302,7 +302,7 @@ void LoadConfiguration(void)
tfe_enabled = dwTfeEnabled;
RegLoadString(TEXT(REG_CONFIG), TEXT(REGVALUE_UTHERNET_INTERFACE), 1, szFilename, MAX_PATH, TEXT(""));
update_tfe_interface(szFilename, NULL);
update_tfe_interface(szFilename);
//
@ -323,7 +323,7 @@ static std::string GetFullPath(LPCSTR szFileName)
{
std::string strPathName;
if (szFileName[0] == '\\' || szFileName[1] == ':')
if (szFileName[0] == PATH_SEPARATOR || szFileName[1] == ':')
{
// Abs pathname
strPathName = szFileName;
@ -346,7 +346,7 @@ static void SetCurrentDir(std::string pathname)
// . if -[sN]d1 and -[sN]d2 are specified, then g_sCurrentDir will be set to the d2 image's path
// This is purely dependent on the current order of InsertFloppyDisks() & InsertHardDisks() - ie. very brittle!
// . better to use -current-dir to be explicit
std::size_t found = pathname.find_last_of("\\");
std::size_t found = pathname.find_last_of(PATH_SEPARATOR);
std::string path = pathname.substr(0, found);
SetCurrentImageDir(path);
}

View file

@ -340,7 +340,7 @@ static void GetProgramDirectory(void)
int loop = g_sProgramDir.size();
while (loop--)
{
if ((g_sProgramDir[loop] == TEXT('\\')) || (g_sProgramDir[loop] == TEXT(':')))
if ((g_sProgramDir[loop] == TEXT(PATH_SEPARATOR)) || (g_sProgramDir[loop] == TEXT(':')))
{
g_sProgramDir.resize(loop + 1); // this reduces the size
break;
@ -619,7 +619,7 @@ int APIENTRY WinMain(HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
char startDir[_MAX_PATH];
GetCurrentDirectory(sizeof(startDir), startDir);
g_sStartDir = startDir;
if (*(g_sStartDir.end()-1) != '\\') g_sStartDir += '\\';
if (*(g_sStartDir.end()-1) != PATH_SEPARATOR) g_sStartDir += PATH_SEPARATOR;
if (!ProcessCmdLine(lpCmdLine))
return 0;
@ -948,7 +948,7 @@ static void RepeatInitialization(void)
if (g_cmdLine.szSnapshotName)
{
std::string strPathname(g_cmdLine.szSnapshotName);
int nIdx = strPathname.find_last_of('\\');
int nIdx = strPathname.find_last_of(PATH_SEPARATOR);
if (nIdx >= 0 && nIdx+1 < (int)strPathname.length()) // path exists?
{
const std::string strPath = strPathname.substr(0, nIdx+1);