diff options
author | Richard Jones <rjones@redhat.com> | 2009-04-20 10:19:45 +0100 |
---|---|---|
committer | Richard Jones <rjones@redhat.com> | 2009-04-20 10:19:45 +0100 |
commit | 24ccbb29ac475187f51a27dcd318db2b4824a0c1 (patch) | |
tree | ecb06a1b2985b33b7bdd8dad6e222a380b274ac5 /fish | |
parent | aef3d2013fee188c9607f35657c45df88503cd64 (diff) | |
download | libguestfs-24ccbb29ac475187f51a27dcd318db2b4824a0c1.tar.gz libguestfs-24ccbb29ac475187f51a27dcd318db2b4824a0c1.tar.xz libguestfs-24ccbb29ac475187f51a27dcd318db2b4824a0c1.zip |
Generated code for 'checksum' command.
Diffstat (limited to 'fish')
-rw-r--r-- | fish/cmds.c | 26 | ||||
-rw-r--r-- | fish/completion.c | 1 |
2 files changed, 27 insertions, 0 deletions
diff --git a/fish/cmds.c b/fish/cmds.c index 9cd23c5e..dd574f24 100644 --- a/fish/cmds.c +++ b/fish/cmds.c @@ -57,6 +57,7 @@ void list_commands (void) printf ("%-20s %s\n", "blockdev-setro", "set block device to read-only"); printf ("%-20s %s\n", "blockdev-setrw", "set block device to read-write"); printf ("%-20s %s\n", "cat", "list the contents of a file"); + printf ("%-20s %s\n", "checksum", "compute MD5, SHAx or CRC checksum of file"); printf ("%-20s %s\n", "chmod", "change file mode"); printf ("%-20s %s\n", "chown", "change file owner and group"); printf ("%-20s %s\n", "command", "run a command from the guest filesystem"); @@ -368,6 +369,9 @@ void display_command (const char *cmd) if (strcasecmp (cmd, "download") == 0) pod2text ("download - download a file to the local machine", " download <remotefilename> <filename>\n\nDownload file C<remotefilename> and save it as C<filename>\non the local machine.\n\nC<filename> can also be a named pipe.\n\nSee also C<upload>, C<cat>."); else + if (strcasecmp (cmd, "checksum") == 0) + pod2text ("checksum - compute MD5, SHAx or CRC checksum of file", " checksum <csumtype> <path>\n\nThis call computes the MD5, SHAx or CRC checksum of the\nfile named C<path>.\n\nThe type of checksum to compute is given by the C<csumtype>\nparameter which must have one of the following values:\n\n=over 4\n\n=item C<crc>\n\nCompute the cyclic redundancy check (CRC) specified by POSIX\nfor the C<cksum> command.\n\n=item C<md5>\n\nCompute the MD5 hash (using the C<md5sum> program).\n\n=item C<sha1>\n\nCompute the SHA1 hash (using the C<sha1sum> program).\n\n=item C<sha224>\n\nCompute the SHA224 hash (using the C<sha224sum> program).\n\n=item C<sha256>\n\nCompute the SHA256 hash (using the C<sha256sum> program).\n\n=item C<sha384>\n\nCompute the SHA384 hash (using the C<sha384sum> program).\n\n=item C<sha512>\n\nCompute the SHA512 hash (using the C<sha512sum> program).\n\n=back\n\nThe checksum is returned as a printable string."); + else display_builtin_command (cmd); } @@ -1778,6 +1782,25 @@ static int run_download (const char *cmd, int argc, char *argv[]) return r; } +static int run_checksum (const char *cmd, int argc, char *argv[]) +{ + char *r; + const char *csumtype; + const char *path; + if (argc != 2) { + fprintf (stderr, "%s should have 2 parameter(s)\n", cmd); + fprintf (stderr, "type 'help %s' for help on %s\n", cmd, cmd); + return -1; + } + csumtype = argv[0]; + path = argv[1]; + r = guestfs_checksum (g, csumtype, path); + if (r == NULL) return -1; + printf ("%s\n", r); + free (r); + return 0; +} + int run_action (const char *cmd, int argc, char *argv[]) { if (strcasecmp (cmd, "launch") == 0 || strcasecmp (cmd, "run") == 0) @@ -2029,6 +2052,9 @@ int run_action (const char *cmd, int argc, char *argv[]) if (strcasecmp (cmd, "download") == 0) return run_download (cmd, argc, argv); else + if (strcasecmp (cmd, "checksum") == 0) + return run_checksum (cmd, argc, argv); + else { fprintf (stderr, "%s: unknown command\n", cmd); return -1; diff --git a/fish/completion.c b/fish/completion.c index a0ba5ae1..49f912b9 100644 --- a/fish/completion.c +++ b/fish/completion.c @@ -63,6 +63,7 @@ static const char *commands[] = { "blockdev-setrw", "cat", "cdrom", + "checksum", "chmod", "chown", "command", |