예제 #1
0
파일: actions.c 프로젝트: Nadrin/fsproxy
void UpdateInterfaces(HWND hWnd)
{
	wchar_t iface_uid[256];
	int iface_index;
	NET_IFACE *iface;

	ConfigGetString(L"net_uid", iface_uid);
	gInterfaceCount = EnumerateInterfaces(gInterfaces, IFACE_MAX);
	iface = ResolveInterface(iface_uid, &iface_index, gInterfaces, gInterfaceCount);

	if(hWnd)
	{
		int i, list_index=0;
		SendMessage(GetDlgItem(hWnd, IDC_IFNAME), CB_RESETCONTENT, 0, 0);
		SendMessage(GetDlgItem(hWnd, IDC_IFNAME), CB_ADDSTRING, 0, (LPARAM)GetString(IDS_LISTNONE));
		SetDlgItemText(hWnd, IDC_TAP, GetString(IDS_LISTNONE));
		for(i=0; i<gInterfaceCount; i++)
			SendMessage(GetDlgItem(hWnd, IDC_IFNAME), CB_ADDSTRING, 0, (LPARAM)gInterfaces[i].fname);
		if(iface)
			list_index = iface_index+1;
		SendMessage(GetDlgItem(hWnd, IDC_IFNAME), CB_SETCURSEL, (WPARAM)list_index, 0);
	}

	if(!iface)
	{
		ConfigPutString(L"net_uid", L"");
		ConfigPutString(L"net_name", L"");
	}
	else
	{
		ConfigPutString(L"net_name", iface->fname);
		if(hWnd)
			SetDlgItemText(hWnd, IDC_TAP, iface->fname);
	}
}
예제 #2
0
bool CSynapseServer::Initialize( const char* conf_file, PFN_SYN_PRINTF_VA pf ) {
    // browse the paths to locate all potential modules

    Set_Syn_Printf( pf );

    if ( conf_file ) {
        // if a config file is specified and we fail to load it, we fail
        Syn_Printf( "loading synapse XML config file '%s'\n", conf_file );
        mpDoc = xmlParseFile( conf_file );
        if ( !mpDoc ) {
            Syn_Printf( "'%s' invalid/not found\n", conf_file );
            return false;
        }
    }

    for ( list<char *>::iterator iPath = mSearchPaths.begin(); iPath != mSearchPaths.end(); iPath++ )
    {
        const char* path = *iPath;

        Syn_Printf( "Synapse Scanning modules path: %s\n", path );

        GDir* dir = g_dir_open( path, 0, NULL );

        if ( dir != NULL ) {
            while ( 1 )
            {
                const gchar* name = g_dir_read_name( dir );
                if ( name == NULL ) {
                    break;
                }

                // too small to be isolated in win32/ and linux/ directories..
#if defined( _WIN32 )
                const char* ext_so = ".dll";
#elif defined ( __linux__ ) || defined ( __APPLE__ )
                const char* ext_so = ".so";
#endif
                const char* ext = strrchr( name, '.' );
                if ( ( ext == NULL ) || ( stricmp( ext, ext_so ) != 0 ) ) {
                    continue;
                }

                Str newModule;
                newModule.Format( "%s%s", path, name );
                Syn_Printf( "Found '%s'\n", newModule.GetBuffer() );
                EnumerateInterfaces( newModule );
            }

            g_dir_close( dir );
        }
    }
    return true;
}