author | Markus Bröker <mbroeker@largo.dyndns.tv> |
Fri, 01 May 2009 18:27:06 +0200 | |
changeset 89 | 66f0244c2863 |
parent 77 | 49e0babccb23 |
child 121 | fef2ccfa7b12 |
permissions | -rw-r--r-- |
77 | 1 |
/** |
2 |
* lsflib/tools/digest.c |
|
3 |
* Copyright (C) 2008 Markus Broeker |
|
4 |
*/ |
|
5 |
||
6
c3dc3eb3b541
a small libtool demo added to the demo distribution
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
6 |
#include <stdio.h> |
c3dc3eb3b541
a small libtool demo added to the demo distribution
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
7 |
#include <stdlib.h> |
c3dc3eb3b541
a small libtool demo added to the demo distribution
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
8 |
|
c3dc3eb3b541
a small libtool demo added to the demo distribution
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
9 |
#include <lsf.h> |
c3dc3eb3b541
a small libtool demo added to the demo distribution
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
10 |
|
c3dc3eb3b541
a small libtool demo added to the demo distribution
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
11 |
int main (int argc, char **argv) |
c3dc3eb3b541
a small libtool demo added to the demo distribution
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
12 |
{ |
c3dc3eb3b541
a small libtool demo added to the demo distribution
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
13 |
unsigned char *value = NULL; |
c3dc3eb3b541
a small libtool demo added to the demo distribution
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
14 |
int i; |
c3dc3eb3b541
a small libtool demo added to the demo distribution
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
15 |
|
c3dc3eb3b541
a small libtool demo added to the demo distribution
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
16 |
if (argc != 2) { |
c3dc3eb3b541
a small libtool demo added to the demo distribution
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
17 |
printf ("Usage: %s [ <file> | <directory> ]\n\n", argv[0]); |
c3dc3eb3b541
a small libtool demo added to the demo distribution
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
18 |
printf ("Output is in md5sum compatible format\n"); |
c3dc3eb3b541
a small libtool demo added to the demo distribution
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
19 |
return EXIT_SUCCESS; |
c3dc3eb3b541
a small libtool demo added to the demo distribution
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
20 |
} |
c3dc3eb3b541
a small libtool demo added to the demo distribution
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
21 |
|
c3dc3eb3b541
a small libtool demo added to the demo distribution
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
22 |
if (isDir (argv[1])) |
c3dc3eb3b541
a small libtool demo added to the demo distribution
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
23 |
md5recursive (argv[1], 1); |
c3dc3eb3b541
a small libtool demo added to the demo distribution
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
24 |
else { |
c3dc3eb3b541
a small libtool demo added to the demo distribution
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
25 |
value = md5sum (argv[1]); |
c3dc3eb3b541
a small libtool demo added to the demo distribution
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
26 |
|
c3dc3eb3b541
a small libtool demo added to the demo distribution
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
27 |
if (!value) { |
c3dc3eb3b541
a small libtool demo added to the demo distribution
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
28 |
printf ("There was an error\n"); |
c3dc3eb3b541
a small libtool demo added to the demo distribution
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
29 |
free (value); |
c3dc3eb3b541
a small libtool demo added to the demo distribution
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
30 |
return EXIT_FAILURE; |
c3dc3eb3b541
a small libtool demo added to the demo distribution
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
31 |
} |
c3dc3eb3b541
a small libtool demo added to the demo distribution
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
32 |
for (i = 0; i < 16; i++) |
c3dc3eb3b541
a small libtool demo added to the demo distribution
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
33 |
printf ("%02x", value[i]); |
c3dc3eb3b541
a small libtool demo added to the demo distribution
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
34 |
printf (" %s\n", argv[1]); |
c3dc3eb3b541
a small libtool demo added to the demo distribution
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
35 |
if (value) |
c3dc3eb3b541
a small libtool demo added to the demo distribution
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
36 |
free (value); |
c3dc3eb3b541
a small libtool demo added to the demo distribution
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
37 |
} |
c3dc3eb3b541
a small libtool demo added to the demo distribution
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
38 |
|
c3dc3eb3b541
a small libtool demo added to the demo distribution
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
39 |
return 0; |
c3dc3eb3b541
a small libtool demo added to the demo distribution
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
diff
changeset
|
40 |
} |