mirror of
https://github.com/webui-dev/webui.git
synced 2024-09-11 22:17:13 +03:00
Adding webui_get_url
- Adding `char* webui_get_url(size_t window);`
This commit is contained in:
parent
1478c4ffdd
commit
6f782bc1a8
@ -415,6 +415,17 @@ WEBUI_EXPORT void webui_set_position(size_t window, unsigned int x, unsigned int
|
||||
*/
|
||||
WEBUI_EXPORT void webui_set_profile(size_t window, const char* name, const char* path);
|
||||
|
||||
/**
|
||||
* @brief Get the server URL
|
||||
*
|
||||
* @param window The window number
|
||||
*
|
||||
* @return Returns the server URL
|
||||
*
|
||||
* @example char* URL = webui_get_url(myWindow);
|
||||
*/
|
||||
WEBUI_EXPORT char* webui_get_url(size_t window);
|
||||
|
||||
// -- JavaScript ----------------------
|
||||
|
||||
// Run JavaScript without waiting for the response.
|
||||
|
17
src/webui.c
17
src/webui.c
@ -1142,6 +1142,23 @@ void webui_set_profile(size_t window, const char* name, const char* path) {
|
||||
win->custom_profile = true;
|
||||
}
|
||||
|
||||
char* webui_get_url(size_t window) {
|
||||
#ifdef WEBUI_LOG
|
||||
printf("[User] webui_get_url([%zu])...\n", window);
|
||||
#endif
|
||||
|
||||
// Dereference
|
||||
_webui_init();
|
||||
if(_webui_core.exit_now || _webui_core.wins[window] == NULL) return NULL;
|
||||
_webui_window_t* win = _webui_core.wins[window];
|
||||
|
||||
// Get current URL
|
||||
char* url = (char*) _webui_malloc(32);
|
||||
sprintf(url, "http://127.0.0.1:%zu", win->server_port);
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
void webui_send_raw(size_t window, const char* function, const void* raw, size_t size) {
|
||||
|
||||
#ifdef WEBUI_LOG
|
||||
|
Loading…
Reference in New Issue
Block a user