lsflib/tools/digest.c
author Markus Bröker <mbroeker@largo.dyndns.tv>
Wed, 26 May 2010 13:08:42 +0200
changeset 124 8a983ee5fab7
parent 121 fef2ccfa7b12
child 158 2cddd4d26139
permissions -rw-r--r--
md5rec: the location of the header has changed i have moved the lsf.h header to lsf/lsf.h in the lsflib project committer: Markus Bröker <mbroeker@largo.homelinux.org>

/**
 * lsflib/tools/digest.c
 * Copyright (C) 2008 Markus Broeker
 */

#include <stdio.h>
#include <stdlib.h>

#include <lsf/lsf.h>

int main (int argc, char **argv)
{
    unsigned char *value = NULL;
    int i;

    if (argc != 2) {
        printf ("Usage: %s [ <file> | <directory> ]\n\n", argv[0]);
        printf ("Output is in md5sum compatible format\n");
        return EXIT_SUCCESS;
    }

    if (isDir (argv[1]))
        md5recursive (argv[1], 1);
    else {
        value = md5sum (argv[1]);

        if (!value) {
            printf ("There was an error\n");
            free (value);
            return EXIT_FAILURE;
        }
        for (i = 0; i < 16; i++)
            printf ("%02x", value[i]);
        printf ("  %s\n", argv[1]);
        if (value)
            free (value);
    }

    return 0;
}