lsflib/tools/digest.c
author Markus Bröker <mbroeker@largo.dyndns.tv>
Thu, 16 Apr 2009 12:50:39 +0200
changeset 69 b5912e5f899f
parent 6 c3dc3eb3b541
child 77 49e0babccb23
permissions -rw-r--r--
Useless cross_getch hack removed cross_getch provides a version of getch for every os. The Windows Part does not work under wine, but it works on the target platform. committer: Markus Bröker <mbroeker@largo.homelinux.org>

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

#include <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;
}