Esempio n. 1
0
static void test_get_set_text(void)
{
    HWND hwnd;
    CHAR ip[16];
    INT r;

    hwnd = create_ipaddress_control();
    if (!hwnd)
    {
        win_skip("IPAddress control not implemented\n");
        return;
    }

    /* check text just after creation */
    r = GetWindowTextA(hwnd, ip, ARRAY_SIZE(ip));
    expect(7, r);
    ok(strcmp(ip, "0.0.0.0") == 0, "Expected null IP address, got %s\n", ip);

    SendMessageA(hwnd, IPM_SETADDRESS, 0, MAKEIPADDRESS(127, 0, 0, 1));
    r = GetWindowTextA(hwnd, ip, ARRAY_SIZE(ip));
    expect(9, r);
    ok(strcmp(ip, "127.0.0.1") == 0, "Expected 127.0.0.1, got %s\n", ip);

    DestroyWindow(hwnd);
}
DWORD DetectIPAddress (char *pszURL)
   {
   DWORD dwRet = 0;
   HINTERNET hINet, hFile;
   hINet = InternetOpen("InetURL/1.0", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 );
   
   if ( !hINet )
      {
      // TODO: Good error handling
//      fprintf(stderr, "InternetOpen failed\n");
//      exit(-1);
      }

   hFile = InternetOpenUrl( hINet, pszURL, NULL, 0, 0, 0 ) ;

   if ( hFile )
      {
      CHAR buffer[32768];
      DWORD dwRead;
      char *psz = buffer;
      DWORD cch = 0;
      int cPasses = 0;
      
      while (InternetReadFile( hFile, psz, 32767 - cch, &dwRead)) 
         {
         if (dwRead == 0)
            break;

         psz += dwRead;
         cch += dwRead;

         ++cPasses;
         }

      if (cch > 0)
         {
         buffer[cch] = '\0';
         int nIP1, nIP2, nIP3, nIP4;
         char *psz;
         psz = FindIPAddressInString(buffer);
         if (psz)
            {
            sscanf(psz, "%d.%d.%d.%d", &nIP1, &nIP2, &nIP3, &nIP4);
            dwRet = MAKEIPADDRESS(nIP1, nIP2, nIP3, nIP4);
            }
         }

      InternetCloseHandle( hFile );
      }

   InternetCloseHandle( hINet );
   
   return dwRet;
   }
Esempio n. 3
0
int HostIO_TCP::ListDevices(std::vector<CameraID> &vID)
{
	QSI_Registry reg;
	in_addr ipAddr;
	vID.clear();
//
// TODO
// No TCP devices for now
//
#ifdef HASTCPIP
	ipAddr.S_un.S_addr = reg.GetIPv4Addresss(true, MAKEIPADDRESS(0,0,0,0));
	CameraID cID("", ipAddr);
	vID.push_back(cID);

	ipAddr.S_un.S_addr = reg.GetIPv4Addresss(false, MAKEIPADDRESS(0,0,0,0));
	CameraID cgID("", ipAddr);
	vID.push_back(cgID);
#endif
	m_log->Write(2, _T("TCP/IP ListDevices Done."));
	return 0;
}
Esempio n. 4
0
VOID CIpAddressControl::SetData(
	const UINT &uOct1,
	const UINT &uOct2,
	const UINT &uOct3,
	const UINT &uOct4
	) {
	SetData(
		MAKEIPADDRESS(
			static_cast<DWORD>(uOct1),
			static_cast<DWORD>(uOct2),
			static_cast<DWORD>(uOct3),
			static_cast<DWORD>(uOct4)
			)
		);
}
DWORD GetLocalIpAddress()   
{   
	WORD wVersionRequested = MAKEWORD(2, 2);   
	WSADATA wsaData;   
	if (WSAStartup(wVersionRequested, &wsaData) != 0)   
		return 0;   
	char local[255] = {0};   
	gethostname(local, sizeof(local));   
	hostent* ph = gethostbyname(local);   
	if (ph == NULL)   
		return 0;   
	in_addr addr;   
	memcpy(&addr, ph->h_addr_list[0], sizeof(in_addr));   
	DWORD dwIP = MAKEIPADDRESS(addr.S_un.S_un_b.s_b1, addr.S_un.S_un_b.s_b2, addr.S_un.S_un_b.s_b3, addr.S_un.S_un_b.s_b4);
	return dwIP;
}
Esempio n. 6
0
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hprevInstance,
                   LPSTR lspszCmdParam, int nCmdShow)
{
    MSG Msg;

    mainDialog = CreateDialogParam(hInst, MAKEINTRESOURCE(NETWORKDIALOG), 0, WndProc, 0);
    ShowWindow(mainDialog, nCmdShow);


    //Radio Buttons
    clientRadio = GetDlgItem(mainDialog, CLIENTRADIO);
    serverRadio = GetDlgItem(mainDialog, SERVERRADIO);
    TCPRadio = GetDlgItem(mainDialog, TCPRADIO);
    UDPRadio = GetDlgItem(mainDialog, UDPRADIO);
    //Fields
    IPField = GetDlgItem(mainDialog, IPFIELD);
    portField = GetDlgItem(mainDialog, PORTFIELD);
    packetField = GetDlgItem(mainDialog, PACKETCOMBO);
    numberField = GetDlgItem(mainDialog, SIZECOMBO);
    //Buttons
    sendButton = GetDlgItem(mainDialog, SENDBUTTON);
    fileButton = GetDlgItem(mainDialog, FILEBUTTON);
    clearButton = GetDlgItem(mainDialog, CLEARBUTTON);
    serverButton = GetDlgItem(mainDialog, SERVERBUTTON);
    //ListBox
    fileBox = GetDlgItem(mainDialog, FILEBOX);

    //Populate Fields
    initPacketSizeField(packetField, packetsizeList);
    initPacketCountField(numberField, numOfPackets);

    SendMessage(numberField, (UINT)CB_SETCURSEL, 0, 0);
    SendMessage(packetField, (UINT)CB_SETCURSEL, 0, 0);

    SendMessage(IPField, (UINT)IPM_SETADDRESS, 0, LPARAM(MAKEIPADDRESS(192, 168, 0, 19)));
    SetWindowText(portField, "7000");

    while (GetMessage(&Msg, NULL, 0, 0))
    {
        TranslateMessage(&Msg);
        DispatchMessage(&Msg);
    }

    return Msg.wParam;
}
DWORD CNetInstall::GetLocalIP()
{
	DWORD dwIP = 0;
	WSAData wsaData;
	if (!WSAStartup(MAKEWORD(2, 2), &wsaData)) {
		char host_name[255];
		if (gethostname(host_name, sizeof(host_name)) != SOCKET_ERROR) {
			struct addrinfo *result = NULL;
			struct addrinfo *ptr = NULL;
			struct addrinfo hints;
			ZeroMemory(&hints, sizeof(hints));
			hints.ai_family = AF_UNSPEC;
			hints.ai_socktype = SOCK_STREAM;
			hints.ai_protocol = IPPROTO_TCP;

			getaddrinfo(host_name, 0, &hints, &result);
			if (result)
			{
				for (ptr = result; ptr != NULL; ptr = ptr->ai_next) {
					if (ptr->ai_family == AF_INET)
					{
						IN_ADDR *qip = &((struct sockaddr_in *)ptr->ai_addr)->sin_addr;
						dwIP = MAKEIPADDRESS(qip->S_un.S_un_b.s_b1, qip->S_un.S_un_b.s_b2, qip->S_un.S_un_b.s_b3, qip->S_un.S_un_b.s_b4);
						//dwIP = ((struct sockaddr_in *)ptr->ai_addr)->sin_addr.S_un.S_addr;
						if (dwIP)
						{
							break;
						}
						
					}
				}
				
			}
		}	
	}
	
	WSACleanup();
	return dwIP;
}
Esempio n. 8
0
//--------------------------------------------------
// Check valid ip against ip vectors
//--------------------------------------------------
bool Server::ValidateIpAddress(sockaddr_in addr)
{
    DWORD dwIp = MAKEIPADDRESS(
			addr.sin_addr.S_un.S_un_b.s_b1,
			addr.sin_addr.S_un.S_un_b.s_b2,
			addr.sin_addr.S_un.S_un_b.s_b3,
			addr.sin_addr.S_un.S_un_b.s_b4);

    if (ConfigManager::Get()->GetConfig()->IsAllowAllIpEnabled())
    {
        if (ConfigManager::Get()->GetConfig()->IsDeniedIp(dwIp))
            return false;
        return true;
    }
    else
    {
        if (ConfigManager::Get()->GetConfig()->IsAllowedIp(dwIp))
            return true;
        return false;
    }
    
}
BOOL CTestOptionsListCtrlDialog::OnInitDialog()
{
  CRhinoUiDockBarDialog::OnInitDialog();

  CRect r;
  GetClientRect( r);

  m_options_list.SetBorders( 0, 0, 0, 0 );

  if( m_options_list.CreateOptionsList(this, WS_VISIBLE | WS_CHILD, r) )
  {
    m_options_list.SetIndentItems( true );

    m_options_list.AddItem( new CRhinoUiOptionsListCtrlStaticText(L"Object type", L"unknown type") );
    m_options_list.AddItem( new CRhinoUiOptionsListCtrlEditBox(L"Name", L"*unnamed*") );
    m_pLayerItem = new CRhinoUiOptionsListCtrlLayerComboBox( L"Layer", L"Layer 01" );
    m_options_list.AddItem( m_pLayerItem );
    m_pColorItem = new CRhinoUiOptionsListCtrlColorComboBox( L"Color", L"Black" );
    m_options_list.AddItem( m_pColorItem );
    m_options_list.AddItem( new CRhinoUiOptionsListCtrlPushButton(L"Details", L"...") );
    m_options_list.AddItem( new CRhinoUiOptionsListCtrlColorButton(L"Color button", RGB(255,0,0)) );

    m_options_list.m_HasIsoCurves.SetAutoDelete( false );
    m_options_list.m_HasIsoCurves.SetCheck( BST_CHECKED );
    m_options_list.m_HasIsoCurves.SetLabel( L"Object has Isocurves" );
    m_options_list.m_HasIsoCurves.SetText( L"True" );
    m_options_list.m_HasIsoCurves.SetCheckText( L"True" );
    m_options_list.AddItem( &m_options_list.m_HasIsoCurves );

    m_options_list.m_ShowIsoCurves.SetAutoDelete( false );
    m_options_list.m_ShowIsoCurves.SetLabel( L"Isocurves" );
    m_options_list.m_ShowIsoCurves.SetText( L"Display" );
    m_options_list.m_ShowIsoCurves.SetCheckText( L"Display" );
    m_options_list.AddItem( &m_options_list.m_ShowIsoCurves );

    m_options_list.m_IsoCurveDinsity.SetAutoDelete( false );
    m_options_list.m_IsoCurveDinsity.SetLabel( L"Isocurve density" );
    m_options_list.m_IsoCurveDinsity.SetEditType( CRhinoUiEdit::et_int );
    m_options_list.m_IsoCurveDinsity.SetText( L"1" );
    m_options_list.m_IsoCurveDinsity.SetValue( 1 );
    m_options_list.m_IsoCurveDinsity.SetMin( true, 0 );
    m_options_list.m_IsoCurveDinsity.SetMax( true, 99 );
    m_options_list.m_IsoCurveDinsity.SetAllowEmpty( false );
    m_options_list.m_IsoCurveDinsity.SetNonZero( false );
    m_options_list.m_IsoCurveDinsity.SetIncludeSpinner( true );
    m_options_list.AddItem( &m_options_list.m_IsoCurveDinsity );

    m_options_list.m_PointEditBox.SetLabel( L"Point edit test" );
    m_options_list.m_PointEditBox.SetPoint( 1.0, 2.0, 3.0 );
    m_options_list.AddItem( &m_options_list.m_PointEditBox );

    m_options_list.AddItem( new CRhinoUiOptionsListCtrlSeparator(L"This is a separator") );
    
    m_options_list.m_ExpandCheckBox1.SetLabel( L"Expandable item" );
    m_options_list.m_ExpandCheckBox1.SetText( L"One" );
    m_options_list.m_ExpandCheckBox1.SetCheckText( L"One" );
    m_options_list.m_ExpandCheckBox1.SetCheck( BST_CHECKED );
    int iCheck1 = m_options_list.AddItem( &m_options_list.m_ExpandCheckBox1 );

    int iIndent = 1;
    m_options_list.m_ExpandCheckBox2.SetLabel( L"Expandable item" );
    m_options_list.m_ExpandCheckBox2.SetText( L"Two" );
    m_options_list.m_ExpandCheckBox2.SetCheckText( L"Two" );
    m_options_list.m_ExpandCheckBox2.SetIndentLevel( iIndent++ );
    m_options_list.m_ExpandCheckBox2.SetCheck( BST_CHECKED );
    m_options_list.m_ExpandCheckBox2.SetIsFullRowItem( true );
    int iCheck2 = m_options_list.AddItem( &m_options_list.m_ExpandCheckBox2 );
    m_options_list.m_ExpandCheckBox2.SetParentIndex( iCheck1 );

    m_options_list.m_ExpandCheckBox3.SetLabel( L"Expandable item" );
    m_options_list.m_ExpandCheckBox3.SetText( L"Three" );
    m_options_list.m_ExpandCheckBox3.SetCheckText( L"Three" );
    m_options_list.m_ExpandCheckBox3.SetIndentLevel( iIndent++ );
    m_options_list.m_ExpandCheckBox3.SetCheck( BST_CHECKED );
    int iCheck3 = m_options_list.AddItem( &m_options_list.m_ExpandCheckBox3 );
    m_options_list.m_ExpandCheckBox3.SetParentIndex( iCheck2 );

    m_options_list.m_ExpandCheckBox4.SetLabel( L"Expandable item" );
    m_options_list.m_ExpandCheckBox4.SetText( L"Four" );
    m_options_list.m_ExpandCheckBox4.SetCheckText( L"Four" );
    m_options_list.m_ExpandCheckBox4.SetIndentLevel( 1 );
    m_options_list.m_ExpandCheckBox4.SetCheck( BST_CHECKED );
    m_options_list.AddItem( &m_options_list.m_ExpandCheckBox4 );
    m_options_list.m_ExpandCheckBox4.SetParentIndex( iCheck1 );

    m_options_list.m_GroupCombo.SetLabel( L"Group combo" );
    m_options_list.AddItem( &m_options_list.m_GroupCombo );
    m_options_list.m_GroupCombo.SetParentIndex( iCheck1 );
    m_options_list.m_GroupCombo.SetIndentLevel( 1 );

    m_options_list.m_GroupCombo.AddGroupItem( L"No controls", NULL, 0 );
    CreateGroup( m_options_list.m_GroupCombo, L"One", &m_options_list.m_NestedGroupCombo );
    m_options_list.m_GroupCombo.SetCurGroupSel( 0 );

    int iTestFullRow = m_options_list.AddItem( new CRhinoUiOptionsListCtrlStaticText( L"label", L"Indented, full row", 1));
    if( iTestFullRow >= 0)
    {
      CRhinoUiOptionsListCtrlStaticText* pST = static_cast<CRhinoUiOptionsListCtrlStaticText*>( m_options_list.GetItem( iTestFullRow));
      if( pST)
      {
        pST->SetParentIndex( iCheck1);
        pST->SetIndentLevel( 1);
        pST->SetIsFullRowItem( true);
        int iTestFullRowSubItem = m_options_list.AddItem( new CRhinoUiOptionsListCtrlStaticText( L"label", L"full row sub item", 1));
        if( iTestFullRowSubItem >= 0)
        {
          CRhinoUiOptionsListCtrlStaticText* pSI = static_cast<CRhinoUiOptionsListCtrlStaticText*>( m_options_list.GetItem( iTestFullRowSubItem));
          if( pSI)
          {
            pSI->SetParentIndex( iTestFullRow);
            pSI->SetIndentLevel( 2);
            pSI->SetIsFullRowItem( true);
          }
        }
      }
    }

    m_options_list.ExpandItem( iCheck1, true );
    m_options_list.ExpandItem( iCheck2, true );

    int iFullRowCheck = m_options_list.AddItem( new CRhinoUiOptionsListCtrlCheckBox( L"Full row check", L"Full row check", 1));
    if( iFullRowCheck >= 0)
    {
      CRhinoUiOptionsListCtrlItem* pI = m_options_list.GetItem( iFullRowCheck );
      if( pI)
      {
        pI->SetIsFullRowItem( true );
        static_cast<CRhinoUiOptionsListCtrlCheckBox*>(pI)->SetCheckText( L"Full row check" );
      }
    }

    m_options_list.m_VerticalCheckBox.SetAutoDelete( false );
    m_options_list.m_VerticalCheckBox.SetLabel( L"Tab Alignment" );
    m_options_list.m_VerticalCheckBox.SetText( L"Top" );
    m_options_list.m_VerticalCheckBox.SetCheckText( L"Top" );
    m_options_list.m_VerticalCheckBox.SetCheck( BST_CHECKED );
    m_options_list.m_VerticalCheckBox.SetLabelBackGroundColor( RGB(200,0,0) );
    m_options_list.m_VerticalCheckBox.SetLabelTextColor( RGB(255,255,255) );
    m_options_list.m_VerticalCheckBox.SetIndentLevel( 1 );
    //m_options_list.AddItem( &m_options_list.m_VerticalCheckBox);

    m_options_list.m_HideTabCheckBox.SetAutoDelete( false );
    m_options_list.m_HideTabCheckBox.SetLabel( L"Test Tab Three" );
    m_options_list.m_HideTabCheckBox.SetText( L"Show" );
    m_options_list.m_HideTabCheckBox.SetCheckText( L"Show" );
    m_options_list.m_HideTabCheckBox.SetCheck( BST_CHECKED );
    m_options_list.m_HideTabCheckBox.SetLabelBackGroundColor( RGB(255,0,0) );
    m_options_list.m_HideTabCheckBox.SetLabelTextColor( RGB(255,255,255) );
    m_options_list.AddItem( &m_options_list.m_HideTabCheckBox );

    m_options_list.m_IPAddress.SetAutoDelete( false );
    m_options_list.m_IPAddress.SetLabel( L"Test IP Address" );
    m_options_list.m_IPAddress.SetIPAddress( MAKEIPADDRESS(255, 255, 255, 255) );
    m_options_list.m_IPAddress.SetIsReadOnly( true );
    m_options_list.m_IPAddress.SetIndentLevel( 1 );
    m_options_list.AddItem( &m_options_list.m_IPAddress );

    m_options_list.m_RadioColumn.SetLabel( L"Radio button test" );
    m_options_list.m_RadioColumn.SetAutoDelete( false );
    m_options_list.m_RadioColumn.AddRadioButton( L"One" );
    m_options_list.m_RadioColumn.AddRadioButton( L"Two" );
    m_options_list.m_RadioColumn.AddRadioButton( L"Three" );
    m_options_list.m_RadioColumn.SetSelectedButton( 1 );
    m_options_list.m_RadioColumn.SetIndentLevel( 1 );
    m_options_list.AddItem( &m_options_list.m_RadioColumn );

    m_options_list.AddItem( new CRhinoUiOptionsListCtrlColorComboBox(L"Color combo test", L"Black", 1) );
    m_options_list.AddItem( new CRhinoUiOptionsListCtrlEditBox(L"File name test", L"C:\\Temp\\3dm\\AtoZ.jpg", 1) );
    m_options_list.AddItem( new CRhinoUiOptionsListCtrlFontComboBox(L"Font combo test", L"Arial", 1) );

    m_ComboBoxItem.SetLabel( L"Combo Box test" );
    m_ComboBoxItem.SetText( L"Item 01" );
    m_ComboBoxItem.SetAutoDelete( false );
    m_ComboBoxItem.SetIndentLevel( 1 );
    m_options_list.AddItem( &m_ComboBoxItem );

    CRect rBefore;
    m_options_list.GetWindowRect( rBefore );
    m_options_list.SizeToContent( true );
    
    CRect rAfter;
    m_options_list.GetWindowRect( rAfter );
    
    CRect r;
    GetWindowRect( r );
    if( rAfter.Height() != rBefore.Height() )
      SetWindowPos( NULL, 0, 0, r.Width(), r.Height() + (rAfter.Height() - rBefore.Height()), SWP_NOZORDER|SWP_NOMOVE );

    m_Resize.Add( &m_options_list, CRhinoUiDialogItemResizer::resize_lockall );
  }

  return TRUE;
}
Esempio n. 10
0
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Yabause; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
*/

#include <windows.h>
#include <commctrl.h>
#undef FASTCALL
#include "../resource.h"
#include "settings.h"

DWORD netlinklocalremoteip=MAKEIPADDRESS(127, 0, 0, 1);
int netlinkport=7845;

//////////////////////////////////////////////////////////////////////////////

LRESULT CALLBACK NetlinkSettingsDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam,
                                        LPARAM lParam)
{
   WCHAR tempwstr[MAX_PATH];
   char tempstr[MAX_PATH];

   switch (uMsg)
   {
      case WM_INITDIALOG:
      {
         SendDlgItemMessage(hDlg, IDC_LOCALREMOTEIP, IPM_SETADDRESS, 0, netlinklocalremoteip);