radio

radio.ircforever.org
git clone git://git.ircforever.org/radio
Log | Files | Refs | Submodules | README | LICENSE

commit ac16f989860962b7f49159092c9539efd20ff39f
parent 5e6122e453f81b9ad5c1691a2982b50cd19c14eb
Author: libredev <libredev@ircforever.org>
Date:   Wed, 15 Mar 2023 18:33:59 +0530

handle no source

Diffstat:
Mmain.c | 16+++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/main.c b/main.c @@ -29,6 +29,7 @@ struct icestats { char *server_id; char *server_start; char *server_start_iso8601; + char *dummy; }; struct source { @@ -102,7 +103,7 @@ icestats_set(struct icestats *s, json_stream *json, const char *key) else if (strcmp(key, "server_id" ) == 0) var = &s->server_id; else if (strcmp(key, "server_start" ) == 0) var = &s->server_start; else if (strcmp(key, "server_start_iso8601" ) == 0) var = &s->server_start_iso8601; - else if (strcmp(key, "dummy" ) == 0) return; + else if (strcmp(key, "dummy" ) == 0) var = &s->dummy; if (var == NULL) fatal("failed to handle icestats key: %s", key); @@ -440,8 +441,17 @@ main(int argc, char *argv[]) if (strcmp(request_url, "/stream") == 0 || *request_url == '\0') { print_navigation_bar(0); - for (int i = 0; i < srclen; i++) - source_print(&srces[i]); + if (srclen == 0) + { + printf("<p style=\"text-align: center\"><b>\n" + "It seems like there are no streams going on currently.\n" + "Try refreshing the page to see if a new stream is available.\n" + "</b></p>\n" + "<hr>\n"); + } else { + for (int i = 0; i < srclen; i++) + source_print(&srces[i]); + } puts("<h2> Comments </h2>"); /* comment box */