| 74 | } |
| 75 | |
| 76 | static int check(char *file) |
| 77 | { |
| 78 | uint8_t buffer[SIZE]; |
| 79 | int fd, flags = O_RDONLY; |
| 80 | int ret = 0; |
| 81 | |
| 82 | #ifdef O_BINARY |
| 83 | flags |= O_BINARY; |
| 84 | #endif |
| 85 | if (file) fd = open(file, flags); |
| 86 | else fd = 0; |
| 87 | if (fd == -1) { |
| 88 | printf("%s=OPEN-FAILED: %s:", av_hash_get_name(hash), strerror(errno)); |
| 89 | ret = 1; |
| 90 | goto end; |
| 91 | } |
| 92 | |
| 93 | av_hash_init(hash); |
| 94 | for (;;) { |
| 95 | int size = read(fd, buffer, SIZE); |
| 96 | if (size < 0) { |
| 97 | int err = errno; |
| 98 | close(fd); |
| 99 | finish(); |
| 100 | printf("+READ-FAILED: %s", strerror(err)); |
| 101 | ret = 2; |
| 102 | goto end; |
| 103 | } else if(!size) |
| 104 | break; |
| 105 | av_hash_update(hash, buffer, size); |
| 106 | } |
| 107 | close(fd); |
| 108 | |
| 109 | finish(); |
| 110 | end: |
| 111 | if (file) |
| 112 | printf(" *%s", file); |
| 113 | printf("\n"); |
| 114 | |
| 115 | return ret; |
| 116 | } |
| 117 | |
| 118 | int main(int argc, char **argv) |
| 119 | { |
no test coverage detected