lsflib/tools/digest.c
changeset 6 c3dc3eb3b541
child 77 49e0babccb23
equal deleted inserted replaced
5:d752cbe8208e 6:c3dc3eb3b541
       
     1 #include <stdio.h>
       
     2 #include <stdlib.h>
       
     3 
       
     4 #include <lsf.h>
       
     5 
       
     6 int main (int argc, char **argv)
       
     7 {
       
     8     unsigned char *value = NULL;
       
     9     int i;
       
    10 
       
    11     if (argc != 2) {
       
    12         printf ("Usage: %s [ <file> | <directory> ]\n\n", argv[0]);
       
    13         printf ("Output is in md5sum compatible format\n");
       
    14         return EXIT_SUCCESS;
       
    15     }
       
    16 
       
    17     if (isDir (argv[1]))
       
    18         md5recursive (argv[1], 1);
       
    19     else {
       
    20         value = md5sum (argv[1]);
       
    21 
       
    22         if (!value) {
       
    23             printf ("There was an error\n");
       
    24             free (value);
       
    25             return EXIT_FAILURE;
       
    26         }
       
    27         for (i = 0; i < 16; i++)
       
    28             printf ("%02x", value[i]);
       
    29         printf ("  %s\n", argv[1]);
       
    30         if (value)
       
    31             free (value);
       
    32     }
       
    33 
       
    34     return 0;
       
    35 }