//eth0 ,eth0:1 //获取实际网口的网络信息 int sys_get_network(int eth, unsigned int *ip, unsigned int *gateway, unsigned int *netmask) { if(eth != ETH0 && eth != ETH0_1) { ERR_PRN("eth %d is invaild\n", eth); return -1; } int dhcp = 0; dhcp = g_network_info.dhcp[eth]; //static ip info if(dhcp == 0) { *ip = g_network_info.dwAddr[eth]; *gateway = g_network_info.dwGateWay[eth]; *netmask = g_network_info.dwNetMask[eth]; return 0; } else if(dhcp == 1) { //just eht0 have dhcp if(eth != ETH0) { ERR_PRN("eth %d is invaild\n", eth); return -1; } *ip = GetIPaddr("eth0"); *netmask = GetNetmask("eth0"); *gateway = GetBroadcast("eth0"); return 0; } return -1; }
void GetRouterLocal(char *dev) { struct ifreq ifr; int fd; fd = CreateSocket(PF_INET, SOCK_DGRAM, IPPROTO_IP); memcpy(ifr.ifr_name, dev, IFNAMSIZ); src_mac = GetMac(fd, dev); src_ip = GetIp(fd, dev); netmask = GetNetmask(fd, dev); router_ip = GetRouterIp(); broadcast = GetBroadcast(fd, dev); }
INT_PTR CALLBACK InterfaceDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam) { CHOOSECOLOR cc; COLORREF choice_colors[16]; TCHAR tmp[4]; int i = 0; BOOL bRedrawList = FALSE; int nCurSelection = 0; int nHistoryTab = 0; int nTabCount = 0; int nPatternCount = 0; int value = 0; const char* snapname = NULL; switch (Msg) { case WM_INITDIALOG: Button_SetCheck(GetDlgItem(hDlg,IDC_START_GAME_CHECK),GetGameCheck()); Button_SetCheck(GetDlgItem(hDlg,IDC_JOY_GUI),GetJoyGUI()); Button_SetCheck(GetDlgItem(hDlg,IDC_KEY_GUI),GetKeyGUI()); Button_SetCheck(GetDlgItem(hDlg,IDC_BROADCAST),GetBroadcast()); Button_SetCheck(GetDlgItem(hDlg,IDC_RANDOM_BG),GetRandomBackground()); Button_SetCheck(GetDlgItem(hDlg,IDC_HIDE_MOUSE),GetHideMouseOnStartup()); // Get the current value of the control SendDlgItemMessage(hDlg, IDC_CYCLETIMESEC, TBM_SETRANGE, (WPARAM)FALSE, (LPARAM)MAKELONG(0, 60)); /* [0, 60] */ value = GetCycleScreenshot(); SendDlgItemMessage(hDlg,IDC_CYCLETIMESEC, TBM_SETPOS, TRUE, value); _itot(value,tmp,10); SendDlgItemMessage(hDlg,IDC_CYCLETIMESECTXT,WM_SETTEXT,0, (WPARAM)tmp); Button_SetCheck(GetDlgItem(hDlg,IDC_STRETCH_SCREENSHOT_LARGER), GetStretchScreenShotLarger()); Button_SetCheck(GetDlgItem(hDlg,IDC_FILTER_INHERIT), GetFilterInherit()); Button_SetCheck(GetDlgItem(hDlg,IDC_NOOFFSET_CLONES), GetOffsetClones()); (void)ComboBox_AddString(GetDlgItem(hDlg, IDC_HISTORY_TAB), TEXT("Snapshot")); (void)ComboBox_SetItemData(GetDlgItem(hDlg, IDC_HISTORY_TAB), nTabCount++, TAB_SCREENSHOT); (void)ComboBox_AddString(GetDlgItem(hDlg, IDC_HISTORY_TAB), TEXT("Flyer")); (void)ComboBox_SetItemData(GetDlgItem(hDlg, IDC_HISTORY_TAB), nTabCount++, TAB_FLYER); (void)ComboBox_AddString(GetDlgItem(hDlg, IDC_HISTORY_TAB), TEXT("Cabinet")); (void)ComboBox_SetItemData(GetDlgItem(hDlg, IDC_HISTORY_TAB), nTabCount++, TAB_CABINET); (void)ComboBox_AddString(GetDlgItem(hDlg, IDC_HISTORY_TAB), TEXT("Marquee")); (void)ComboBox_SetItemData(GetDlgItem(hDlg, IDC_HISTORY_TAB), nTabCount++, TAB_MARQUEE); (void)ComboBox_AddString(GetDlgItem(hDlg, IDC_HISTORY_TAB), TEXT("Title")); (void)ComboBox_SetItemData(GetDlgItem(hDlg, IDC_HISTORY_TAB), nTabCount++, TAB_TITLE); (void)ComboBox_AddString(GetDlgItem(hDlg, IDC_HISTORY_TAB), TEXT("Control Panel")); (void)ComboBox_SetItemData(GetDlgItem(hDlg, IDC_HISTORY_TAB), nTabCount++, TAB_CONTROL_PANEL); (void)ComboBox_AddString(GetDlgItem(hDlg, IDC_HISTORY_TAB), TEXT("PCB")); (void)ComboBox_SetItemData(GetDlgItem(hDlg, IDC_HISTORY_TAB), nTabCount++, TAB_PCB); (void)ComboBox_AddString(GetDlgItem(hDlg, IDC_HISTORY_TAB), TEXT("All")); (void)ComboBox_SetItemData(GetDlgItem(hDlg, IDC_HISTORY_TAB), nTabCount++, TAB_ALL); (void)ComboBox_AddString(GetDlgItem(hDlg, IDC_HISTORY_TAB), TEXT("None")); (void)ComboBox_SetItemData(GetDlgItem(hDlg, IDC_HISTORY_TAB), nTabCount++, TAB_NONE); if (GetHistoryTab() < MAX_TAB_TYPES) { (void)ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_HISTORY_TAB), GetHistoryTab()); } else { (void)ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_HISTORY_TAB), GetHistoryTab()-TAB_SUBTRACT); } (void)ComboBox_AddString(GetDlgItem(hDlg, IDC_SNAPNAME), TEXT("Gamename")); (void)ComboBox_SetItemData(GetDlgItem(hDlg, IDC_SNAPNAME), nPatternCount++, "%g"); (void)ComboBox_AddString(GetDlgItem(hDlg, IDC_SNAPNAME), TEXT("Gamename + Increment")); (void)ComboBox_SetItemData(GetDlgItem(hDlg, IDC_SNAPNAME), nPatternCount++, "%g%i"); (void)ComboBox_AddString(GetDlgItem(hDlg, IDC_SNAPNAME), TEXT("Gamename/Gamename")); (void)ComboBox_SetItemData(GetDlgItem(hDlg, IDC_SNAPNAME), nPatternCount++, "%g/%g"); (void)ComboBox_AddString(GetDlgItem(hDlg, IDC_SNAPNAME), TEXT("Gamename/Gamename + Increment")); (void)ComboBox_SetItemData(GetDlgItem(hDlg, IDC_SNAPNAME), nPatternCount++, "%g/%g%i"); (void)ComboBox_AddString(GetDlgItem(hDlg, IDC_SNAPNAME), TEXT("Gamename/Increment")); (void)ComboBox_SetItemData(GetDlgItem(hDlg, IDC_SNAPNAME), nPatternCount, "%g/%i"); //Default to this setting (void)ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_SNAPNAME), nPatternCount++); snapname = GetSnapName(); if (core_stricmp(snapname,"%g" )==0) { (void)ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_SNAPNAME), 0); } if (core_stricmp(snapname,"%g%i" )==0) { (void)ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_SNAPNAME), 1); } if (core_stricmp(snapname,"%g/%g" )==0) { (void)ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_SNAPNAME), 2); } if (core_stricmp(snapname,"%g/%g%i" )==0) { (void)ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_SNAPNAME), 3); } if (core_stricmp(snapname,"%g/%i" )==0) { (void)ComboBox_SetCurSel(GetDlgItem(hDlg, IDC_SNAPNAME), 4); } SendDlgItemMessage(hDlg, IDC_SCREENSHOT_BORDERSIZE, TBM_SETRANGE, (WPARAM)FALSE, (LPARAM)MAKELONG(0, 100)); /* [0, 100] */ value = GetScreenshotBorderSize(); SendDlgItemMessage(hDlg,IDC_SCREENSHOT_BORDERSIZE, TBM_SETPOS, TRUE, value); _itot(value,tmp,10); SendDlgItemMessage(hDlg,IDC_SCREENSHOT_BORDERSIZETXT,WM_SETTEXT,0, (WPARAM)tmp); //return TRUE; break; case WM_HELP: /* User clicked the ? from the upper right on a control */ HelpFunction((HWND)((LPHELPINFO)lParam)->hItemHandle, MAMEUICONTEXTHELP, HH_TP_HELP_WM_HELP, GetHelpIDs()); break; case WM_CONTEXTMENU: HelpFunction((HWND)wParam, MAMEUICONTEXTHELP, HH_TP_HELP_CONTEXTMENU, GetHelpIDs()); break; case WM_HSCROLL: HANDLE_WM_HSCROLL(hDlg, wParam, lParam, OnHScroll); break; case WM_COMMAND : switch (GET_WM_COMMAND_ID(wParam, lParam)) { case IDC_SCREENSHOT_BORDERCOLOR: { for (i=0;i<16;i++) choice_colors[i] = GetCustomColor(i); cc.lStructSize = sizeof(CHOOSECOLOR); cc.hwndOwner = hDlg; cc.rgbResult = GetScreenshotBorderColor(); cc.lpCustColors = choice_colors; cc.Flags = CC_ANYCOLOR | CC_RGBINIT | CC_SOLIDCOLOR; if (!ChooseColor(&cc)) return TRUE; for (i=0;i<16;i++) SetCustomColor(i,choice_colors[i]); SetScreenshotBorderColor(cc.rgbResult); UpdateScreenShot(); return TRUE; } case IDOK : { BOOL checked = FALSE; SetGameCheck(Button_GetCheck(GetDlgItem(hDlg, IDC_START_GAME_CHECK))); SetJoyGUI(Button_GetCheck(GetDlgItem(hDlg, IDC_JOY_GUI))); SetKeyGUI(Button_GetCheck(GetDlgItem(hDlg, IDC_KEY_GUI))); SetBroadcast(Button_GetCheck(GetDlgItem(hDlg, IDC_BROADCAST))); SetRandomBackground(Button_GetCheck(GetDlgItem(hDlg, IDC_RANDOM_BG))); SetHideMouseOnStartup(Button_GetCheck(GetDlgItem(hDlg,IDC_HIDE_MOUSE))); if( Button_GetCheck(GetDlgItem(hDlg,IDC_RESET_PLAYCOUNT ) ) ) { ResetPlayCount( -1 ); bRedrawList = TRUE; } if( Button_GetCheck(GetDlgItem(hDlg,IDC_RESET_PLAYTIME ) ) ) { ResetPlayTime( -1 ); bRedrawList = TRUE; } value = SendDlgItemMessage(hDlg,IDC_CYCLETIMESEC, TBM_GETPOS, 0, 0); if( GetCycleScreenshot() != value ) { SetCycleScreenshot(value); } value = SendDlgItemMessage(hDlg,IDC_SCREENSHOT_BORDERSIZE, TBM_GETPOS, 0, 0); if( GetScreenshotBorderSize() != value ) { SetScreenshotBorderSize(value); UpdateScreenShot(); } value = SendDlgItemMessage(hDlg,IDC_HIGH_PRIORITY, TBM_GETPOS, 0, 0); checked = Button_GetCheck(GetDlgItem(hDlg,IDC_STRETCH_SCREENSHOT_LARGER)); if (checked != GetStretchScreenShotLarger()) { SetStretchScreenShotLarger(checked); UpdateScreenShot(); } checked = Button_GetCheck(GetDlgItem(hDlg,IDC_FILTER_INHERIT)); if (checked != GetFilterInherit()) { SetFilterInherit(checked); // LineUpIcons does just a ResetListView(), which is what we want here PostMessage(GetMainWindow(),WM_COMMAND, MAKEWPARAM(ID_VIEW_LINEUPICONS, FALSE),(LPARAM)NULL); } checked = Button_GetCheck(GetDlgItem(hDlg,IDC_NOOFFSET_CLONES)); if (checked != GetOffsetClones()) { SetOffsetClones(checked); // LineUpIcons does just a ResetListView(), which is what we want here PostMessage(GetMainWindow(),WM_COMMAND, MAKEWPARAM(ID_VIEW_LINEUPICONS, FALSE),(LPARAM)NULL); } nCurSelection = ComboBox_GetCurSel(GetDlgItem(hDlg,IDC_SNAPNAME)); if (nCurSelection != CB_ERR) { const char* snapname_selection = (const char*)ComboBox_GetItemData(GetDlgItem(hDlg,IDC_SNAPNAME), nCurSelection); if (snapname_selection) { SetSnapName(snapname_selection); } } EndDialog(hDlg, 0); nCurSelection = ComboBox_GetCurSel(GetDlgItem(hDlg,IDC_HISTORY_TAB)); if (nCurSelection != CB_ERR) nHistoryTab = ComboBox_GetItemData(GetDlgItem(hDlg,IDC_HISTORY_TAB), nCurSelection); EndDialog(hDlg, 0); if( GetHistoryTab() != nHistoryTab ) { SetHistoryTab(nHistoryTab, TRUE); ResizePickerControls(GetMainWindow()); UpdateScreenShot(); } if( bRedrawList ) { UpdateListView(); } return TRUE; } case IDCANCEL : EndDialog(hDlg, 0); return TRUE; } break; } return 0; }