| 962 | }; |
| 963 | |
| 964 | extern "C" RENDERDOC_API ITargetControl *RENDERDOC_CC RENDERDOC_CreateTargetControl( |
| 965 | const rdcstr &URL, uint32_t ident, const rdcstr &clientName, bool forceConnection) |
| 966 | { |
| 967 | rdcstr host = "localhost"; |
| 968 | if(!URL.empty()) |
| 969 | host = URL; |
| 970 | |
| 971 | rdcstr deviceID = host; |
| 972 | uint16_t port = ident & 0xffff; |
| 973 | |
| 974 | IDeviceProtocolHandler *protocol = RenderDoc::Inst().GetDeviceProtocol(deviceID); |
| 975 | |
| 976 | if(protocol) |
| 977 | { |
| 978 | deviceID = protocol->GetDeviceID(deviceID); |
| 979 | host = protocol->RemapHostname(deviceID); |
| 980 | if(host.empty()) |
| 981 | return NULL; |
| 982 | |
| 983 | port = protocol->RemapPort(deviceID, port); |
| 984 | } |
| 985 | else |
| 986 | { |
| 987 | int32_t idx = deviceID.indexOf(':'); |
| 988 | if(idx > 0) |
| 989 | { |
| 990 | host = deviceID.substr(0, idx); |
| 991 | } |
| 992 | } |
| 993 | |
| 994 | if(port == 0) |
| 995 | return NULL; |
| 996 | |
| 997 | Network::Socket *sock = Network::CreateClientSocket(host, port, 750); |
| 998 | |
| 999 | if(sock == NULL) |
| 1000 | return NULL; |
| 1001 | |
| 1002 | TargetControl *remote = new TargetControl(sock, clientName, forceConnection != 0); |
| 1003 | |
| 1004 | if(remote->Connected()) |
| 1005 | return remote; |
| 1006 | |
| 1007 | delete remote; |
| 1008 | return NULL; |
| 1009 | } |
no test coverage detected