version 1.2, 2010/03/06 18:29:06
|
version 1.6, 2011/08/29 10:29:31
|
Line 58 main(int argc, char *argv[])
|
Line 58 main(int argc, char *argv[])
|
|
|
if (stat(fichier, &stat_buf) != 0) |
if (stat(fichier, &stat_buf) != 0) |
{ |
{ |
|
fprintf(stderr, "stat() failed\n"); |
|
perror("stat"); |
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
} |
} |
|
|
Line 65 main(int argc, char *argv[])
|
Line 67 main(int argc, char *argv[])
|
|
|
if ((chaine = malloc(taille_fichier)) == NULL) |
if ((chaine = malloc(taille_fichier)) == NULL) |
{ |
{ |
|
fprintf(stderr, "malloc() failed\n"); |
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
} |
} |
|
|
if ((in_fd = open(fichier, 0, O_RDONLY)) < 0) |
if ((in_fd = open(fichier, 0, O_RDONLY)) < 0) |
{ |
{ |
|
fprintf(stderr, "open() failed\n"); |
|
perror("open"); |
free(chaine); |
free(chaine); |
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
} |
} |
|
|
if ((octets_lus = read(in_fd, chaine, taille_fichier)) != taille_fichier) |
if ((octets_lus = read(in_fd, chaine, taille_fichier)) != taille_fichier) |
{ |
{ |
|
# ifndef OS2 |
|
// Sur des fichiers binaires et sous OS/2, le nombre d'octets lus peut |
|
// etre inferieur à la taille du fichier sur le disque. |
|
|
|
fprintf(stderr, "read() failed\n"); |
|
fprintf(stderr, "Meditation: %d < %d\n", (int) octets_lus, |
|
(int) taille_fichier); |
|
perror("read"); |
close(in_fd); |
close(in_fd); |
free(chaine); |
free(chaine); |
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
|
# endif |
} |
} |
|
|
close(in_fd); |
close(in_fd); |
|
|
if (EVP_DigestInit(&contexte, EVP_sum()) != 1) |
if (EVP_DigestInit(&contexte, EVP_sum()) != 1) |
{ |
{ |
|
fprintf(stderr, "EVP_DigestInit() failed\n"); |
close(in_fd); |
close(in_fd); |
free(chaine); |
free(chaine); |
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
Line 92 main(int argc, char *argv[])
|
Line 107 main(int argc, char *argv[])
|
|
|
if (EVP_DigestUpdate(&contexte, chaine, taille_fichier) != 1) |
if (EVP_DigestUpdate(&contexte, chaine, taille_fichier) != 1) |
{ |
{ |
|
fprintf(stderr, "EVP_DigestUpdate() failed\n"); |
close(in_fd); |
close(in_fd); |
free(chaine); |
free(chaine); |
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
Line 99 main(int argc, char *argv[])
|
Line 115 main(int argc, char *argv[])
|
|
|
if (EVP_DigestFinal_ex(&contexte, somme, &longueur_somme) != 1) |
if (EVP_DigestFinal_ex(&contexte, somme, &longueur_somme) != 1) |
{ |
{ |
|
fprintf(stderr, "EVP_DigestFinal_ex() failed\n"); |
close(in_fd); |
close(in_fd); |
free(chaine); |
free(chaine); |
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |