MCPcopy Create free account
hub / github.com/defold/defold / UrlToString

Function UrlToString

engine/script/src/script_msg.cpp:55–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53 const uint32_t MAX_MESSAGE_DATA_SIZE = 2048;
54
55 const char* UrlToString(const dmMessage::URL* url, char* buffer, uint32_t buffer_size)
56 {
57 DM_HASH_REVERSE_MEM(hash_ctx, 512);
58 *buffer = '\0';
59
60 const char* unknown = "<unknown>";
61 const char* socketname = 0;
62 if (dmMessage::IsSocketValid(url->m_Socket))
63 {
64 // Backwards compatibility: If, for some reason, they want the socket name in Release mode, we keep this check
65 const char* s = dmMessage::GetSocketName(url->m_Socket);
66 socketname = s;
67 }
68
69 if( !socketname )
70 {
71 socketname = dmHashReverseSafe64Alloc(&hash_ctx, url->m_Socket);
72 }
73
74 dmStrlCpy(buffer, socketname ? socketname : unknown, buffer_size);
75 dmStrlCat(buffer, ":", buffer_size);
76 if (url->m_Path != 0)
77 {
78 const char* tmp = dmHashReverseSafe64Alloc(&hash_ctx, url->m_Path);
79 dmStrlCat(buffer, tmp, buffer_size);
80 }
81 if (url->m_Fragment != 0)
82 {
83 const char* tmp = dmHashReverseSafe64Alloc(&hash_ctx, url->m_Fragment);
84 dmStrlCat(buffer, "#", buffer_size);
85 dmStrlCat(buffer, tmp, buffer_size);
86 }
87 return buffer;
88 }
89
90 static int URL_tostring(lua_State *L)
91 {

Callers 5

GetComponentFromLuaFunction · 0.85
URL_tostringFunction · 0.85
URL_concatFunction · 0.85
Msg_PostFunction · 0.85
CheckRenderCameraFunction · 0.85

Calls 5

IsSocketValidFunction · 0.85
GetSocketNameFunction · 0.85
dmHashReverseSafe64AllocFunction · 0.85
dmStrlCpyFunction · 0.85
dmStrlCatFunction · 0.85

Tested by

no test coverage detected