1@echo off
2
3:: ###############################################################################
4:: #
5:: # Copyright (C) 2009-2013 Nintendo.  All rights reserved.
6:: #
7:: # These coded instructions, statements, and computer programs contain
8:: # proprietary information of Nintendo of America Inc. and/or Nintendo
9:: # Company Ltd., and are protected by Federal copyright law.  They may
10:: # not be disclosed to third parties or copied or duplicated in any form,
11:: # in whole or in part, without the prior written consent of Nintendo.
12:: #
13:: ###############################################################################
14
15:: Run setbridgeconfig to update INI file
16setbridgeconfig.exe %*
17if not "%errorlevel%"=="0" (
18    :: Something went wrong; setbridgeconfig should have
19    :: issued an error message, so let's just die here.
20    exit /b 1
21)
22
23set is_default=0
24if "%1"=="-default" (
25    set is_default=1
26    shift
27)
28set bridge_name=%1
29set bridge_ipaddr=
30
31:: Look up the bridges IP from the INI file by name.
32::   This allows us to set the bridge by it's name only.
33for /f "eol=; tokens=1,2 delims==" %%i in (%APPDATA%\bridge_env.ini) do (
34    if "BRIDGE_NAME_%bridge_name%"=="%%i" (
35        set bridge_ipaddr=%%j
36    )
37)
38
39if "%bridge_ipaddr%"=="" (
40    :: Must've deleted a bridge with "-d" option...
41    :: TODO: Should I clear the BRIDGE_CURRENT_* variables, or set them to
42    ::       the default bridge, if we cleared the current session's bridge?
43    echo Cleared stored IP address for %bridge_name%. ^(current environment unchanged^).
44) else (
45    if "%is_default%"=="1" (
46        echo Setting hostbridge for current session ^(and default^) to %bridge_name% %bridge_ipaddr%.
47    ) else (
48        echo Setting hostbridge for current session to %bridge_name% %bridge_ipaddr%.
49    )
50
51    set BRIDGE_CURRENT_NAME=%bridge_name%
52    set BRIDGE_CURRENT_IP_ADDRESS=%bridge_ipaddr%
53)
54
55set bridge_name=
56set bridge_ipaddr=
57set is_default=
58
59if "%SESSION_MANAGER%"=="1" (
60    if not "%bridge_ipaddr%"=="" (
61        title Multi-Cafe Session for %bridge_name%^(%bridge_ipaddr%^)
62    ) else (
63        title Multi-Cafe Session
64    )
65)
66