From e22cc1e84130dfe1086088c0452efc6596e5b855 Mon Sep 17 00:00:00 2001 From: kraxel Date: Thu, 8 Dec 2005 11:17:50 +0000 Subject: Initial revision --- xenlog.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 xenlog.c (limited to 'xenlog.c') diff --git a/xenlog.c b/xenlog.c new file mode 100644 index 0000000..d5ab4d0 --- /dev/null +++ b/xenlog.c @@ -0,0 +1,55 @@ +#include +#include + +#include + +/* ------------------------------------------------------------- */ + +int main(int argc, char *argv[]) +{ + struct xs_handle *xenstore; + struct xs_transaction_handle *xst; + char *xs_value = NULL, **vec; + char *value; + unsigned int count; + + xenstore = xs_daemon_open_readonly(); + if (NULL == xenstore) { + fprintf(stderr,"can't connect to %s\n",xs_daemon_socket_ro()); + exit(1); + } + xs_watch(xenstore, "/", "token"); + + for (;;) { + vec = xs_read_watch(xenstore, &count); + if (NULL == vec) { + fprintf(stderr,"xs_read_watch() failed\n"); + exit(1); + } + switch (vec[XS_WATCH_PATH][0]) { + case '/': + xst = xs_transaction_start(xenstore); + if (NULL != xst) { + xs_value = xs_read(xenstore, xst, vec[XS_WATCH_PATH], NULL); + xs_transaction_end(xenstore, xst, 0); + if (NULL == xs_value) + value = ""; + else + value = xs_value; + } else { + value = ""; + } + break; + default: + value = ""; + break; + } + fprintf(stderr,"%-64s : \"%s\"\n", vec[XS_WATCH_PATH], value); + + if (xs_value) { + free(xs_value); + xs_value = NULL; + } + free(vec); + } +} -- cgit