avoid use of all ctype macros
[libguestfs.git] / daemon / checksum.c
index bb30b05..2423265 100644 (file)
 #include "actions.h"
 
 char *
-do_checksum (char *csumtype, char *path)
+do_checksum (const char *csumtype, const char *path)
 {
   const char *program;
   char *buf;
   char *out, *err;
-  int r, len;
-
-  NEED_ROOT (NULL);
-  ABS_PATH (path, NULL);
+  int r;
+  int len;
 
   if (strcasecmp (csumtype, "crc") == 0)
     program = "cksum";
@@ -58,13 +56,11 @@ do_checksum (char *csumtype, char *path)
   }
 
   /* Make the path relative to /sysroot. */
-  len = strlen (path) + 9;
-  buf = malloc (len);
+  buf = sysroot_path (path);
   if (!buf) {
     reply_with_perror ("malloc");
     return NULL;
   }
-  snprintf (buf, len, "/sysroot%s", path);
 
   r = command (&out, &err, program, buf, NULL);
   free (buf);