minor optimizations
[util-vserver.git] / util-vserver / tests / getctx.c
index 2d4fc49..0a7b492 100644 (file)
 #  include <config.h>
 #endif
 
+#include "compat.h"
 #include "vserver.h"
+#include "internal.h"
+#include "src/util.h"
 
-#include <stdio.h>
-
+#include <stdlib.h>
+#include <unistd.h>
 
 int main(int argc, char *argv[])
 {
-  if (argc==1) printf("%i\n", getcctx());
-  else         printf("%i\n", getctx(atoi(argv[1])));
+  char         buf[sizeof(int)*3+2];
+  xid_t                ctx;
+  
+  if (argc==1) ctx = vc_get_task_xid(0);
+  else         ctx = vc_get_task_xid(atoi(argv[1]));
+
+  utilvserver_fmt_int(buf, ctx);
+
+  WRITE_STR(1, buf);
+  WRITE_MSG(1, "\n");
 
   return 0;
 }