aboutsummaryrefslogtreecommitdiffstats
path: root/xenlog.c
diff options
context:
space:
mode:
authorkraxel <kraxel>2006-07-03 12:00:31 +0000
committerkraxel <kraxel>2006-07-03 12:00:31 +0000
commit8f4db7fb5130a0b327154eddc62b161fb66af688 (patch)
treecb43a91e2fdd769e7285c8f7fa76e0a4e83173fb /xenlog.c
parenta27248c91a6a7a48ce794efc4ed51cc9a6e7172b (diff)
downloadxenwatch-8f4db7fb5130a0b327154eddc62b161fb66af688.tar.gz
xen screen management tool
Diffstat (limited to 'xenlog.c')
-rw-r--r--xenlog.c56
1 files changed, 12 insertions, 44 deletions
diff --git a/xenlog.c b/xenlog.c
index d7e951c..b93bdd4 100644
--- a/xenlog.c
+++ b/xenlog.c
@@ -1,42 +1,21 @@
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <xs.h>
+#include "xenstore.h"
+
/* ------------------------------------------------------------- */
int main(int argc, char *argv[])
{
struct xs_handle *xenstore = NULL;
- xs_transaction_t xst;
- char *xs_value = NULL, **vec;
- char *value;
- unsigned int count;
-
- if (NULL == xenstore) {
- xenstore = xs_daemon_open_readonly();
- if (NULL == xenstore)
- fprintf(stderr,"can't connect to %s\n",xs_daemon_socket_ro());
- else
- printf("connected to %s\n", xs_daemon_socket_ro());
- }
-
- if (NULL == xenstore) {
- xenstore = xs_daemon_open();
- if (NULL == xenstore)
- fprintf(stderr,"can't connect to %s\n",xs_daemon_socket());
- else
- printf("connected to %s\n", xs_daemon_socket());
- }
-
- if (NULL == xenstore) {
- xenstore = xs_domain_open();
- if (NULL == xenstore)
- fprintf(stderr, "can't connect to %s\n", xs_domain_dev());
- else
- printf("connected to %s\n", xs_domain_dev());
- }
+ char **vec;
+ char value[256];
+ unsigned int count, rc;
+ xenstore = xenstore_open(1,1,1,1);
if (NULL == xenstore) {
fprintf(stderr, "can't access xenstore, exiting\n");
exit(1);
@@ -51,29 +30,18 @@ int main(int argc, char *argv[])
}
switch (vec[XS_WATCH_PATH][0]) {
case '/':
- xst = xs_transaction_start(xenstore);
- if (xst) {
- xs_value = xs_read(xenstore, xst, vec[XS_WATCH_PATH], NULL);
- xs_transaction_end(xenstore, xst, 0);
- if (NULL == xs_value)
- value = "<deleted>";
- else
- value = xs_value;
- } else {
- value = "<error>";
+ rc = xenstore_read(xenstore, vec[XS_WATCH_PATH], value, sizeof(value));
+ switch (rc) {
+ case -1: strcpy(value, "<error>"); break;
+ case -2: strcpy(value, "<deleted>"); break;
}
break;
default:
- value = "<null>";
+ strcpy(value, "<null>");
break;
}
printf("%-64s : \"%s\"\n", vec[XS_WATCH_PATH], value);
fflush(stdout);
-
- if (xs_value) {
- free(xs_value);
- xs_value = NULL;
- }
free(vec);
}
}