summaryrefslogtreecommitdiff
path: root/src/webserver.c
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2014-11-13 21:50:54 +0100
committerAndreas Baumann <mail@andreasbaumann.cc>2014-11-13 21:50:54 +0100
commit7342b11a3c12f48b44597232723304150e868328 (patch)
tree23ff7738cc5c8a679ef73912fc368b170e4eab43 /src/webserver.c
parent5d92b737f031acd99e7e2011c679fe03d15930ec (diff)
downloadbiruda-7342b11a3c12f48b44597232723304150e868328.tar.gz
biruda-7342b11a3c12f48b44597232723304150e868328.tar.bz2
showing status and keeping track of coordinators
Diffstat (limited to 'src/webserver.c')
-rw-r--r--src/webserver.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/webserver.c b/src/webserver.c
index 71d896d..6f67fdc 100644
--- a/src/webserver.c
+++ b/src/webserver.c
@@ -1,4 +1,5 @@
#include "webserver.h"
+#include "master.h"
#include <microhttpd.h>
@@ -21,10 +22,24 @@ static int handle_request( void *cls, struct MHD_Connection *connection,
if( strcmp( version, "HTTP/1.1" ) != 0 ) {
return MHD_NO;
}
-
+
fprintf( stderr, "http request: %s\n", url );
-
- char *biruda_msg = "Welcome to biruda!";
+
+ char biruda_msg[1024];
+ biruda_msg[0] = '\0';
+ if( strcmp( url, "/status" ) == 0 ) {
+ for( int pos = 0; pos < MAX_COORDINATORS; pos++ ) {
+ coordinator_t *c = &coordinator[pos];
+ if( c->used ) {
+ char part[128];
+ snprintf( part, 128, "%s %s %s %d (%d)\n", c->host, c->os, c->arch, c->cpus, pos );
+ strncat( biruda_msg, part, 1024 );
+ }
+ }
+ } else {
+ snprintf( biruda_msg, 1024, "Welcome to biruda! Please state your wish..\n" );
+ }
+
response = MHD_create_response_from_buffer( strlen( biruda_msg ),
(void *)biruda_msg, MHD_RESPMEM_MUST_COPY );
ret = MHD_queue_response( connection, MHD_HTTP_OK, response );