--- rpl/rplsums/rplsum.c 2010/04/21 13:45:43 1.3 +++ rpl/rplsums/rplsum.c 2010/08/06 15:27:41 1.4 @@ -58,6 +58,8 @@ main(int argc, char *argv[]) if (stat(fichier, &stat_buf) != 0) { + fprintf(stderr, "stat() failed\n"); + perror("stat"); exit(EXIT_FAILURE); } @@ -65,26 +67,38 @@ main(int argc, char *argv[]) if ((chaine = malloc(taille_fichier)) == NULL) { + fprintf(stderr, "malloc() failed\n"); exit(EXIT_FAILURE); } if ((in_fd = open(fichier, 0, O_RDONLY)) < 0) { + fprintf(stderr, "open() failed\n"); + perror("open"); free(chaine); exit(EXIT_FAILURE); } 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", octets_lus, taille_fichier); + perror("read"); close(in_fd); free(chaine); exit(EXIT_FAILURE); +# endif } close(in_fd); if (EVP_DigestInit(&contexte, EVP_sum()) != 1) { + fprintf(stderr, "EVP_DigestInit() failed\n"); close(in_fd); free(chaine); exit(EXIT_FAILURE); @@ -92,6 +106,7 @@ main(int argc, char *argv[]) if (EVP_DigestUpdate(&contexte, chaine, taille_fichier) != 1) { + fprintf(stderr, "EVP_DigestUpdate() failed\n"); close(in_fd); free(chaine); exit(EXIT_FAILURE); @@ -99,6 +114,7 @@ main(int argc, char *argv[]) if (EVP_DigestFinal_ex(&contexte, somme, &longueur_somme) != 1) { + fprintf(stderr, "EVP_DigestFinal_ex() failed\n"); close(in_fd); free(chaine); exit(EXIT_FAILURE);