mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.1 KiB

  1. /* simple program to check implanted md5sum in an iso 9660 image */
  2. /* Copyright 2001 Red Hat, Inc. */
  3. /* Michael Fulbright msf@redhat.com */
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. #include "md5.h"
  8. #include "libcheckisomd5.h"
  9. int main(int argc, char **argv) {
  10. int i;
  11. int rc;
  12. int verbose;
  13. int md5only;
  14. int filearg;
  15. if (argc < 2) {
  16. printf("Usage: checkisomd5 [--md5sumonly] [--verbose] <isofilename>|<blockdevice>\n\n");
  17. exit(1);
  18. }
  19. md5only = 0;
  20. verbose = 0;
  21. filearg = 1;
  22. for (i=1; i < argc; i++) {
  23. if (strcmp(argv[i], "--md5sumonly") == 0) {
  24. md5only = 1;
  25. filearg++;
  26. } else if (strcmp(argv[i], "--verbose") == 0) {
  27. filearg++;
  28. verbose = 1;
  29. } else
  30. break;
  31. }
  32. if (md5only|verbose)
  33. printMD5SUM(argv[filearg]);
  34. if (md5only)
  35. exit(0);
  36. rc = mediaCheckFile(argv[filearg], !verbose);
  37. /* 1 means it passed, 0 means it failed, -1 means we couldnt find chksum */
  38. if (rc == 1)
  39. exit(0);
  40. else
  41. exit(1);
  42. }