1 /*
2 * Copyright (c) 2002 Fabrice Bellard
3 * Copyright (c) 2013 Michael Niedermayer
4 * Copyright (c) 2013 James Almer
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 #include "config.h"
27
28 #include <errno.h>
29 #include <fcntl.h>
30 #include <stdio.h>
31 #include <string.h>
32 #include <sys/stat.h>
33
34 #if HAVE_IO_H
35 #include <io.h>
36 #endif
37 #if HAVE_UNISTD_H
38 #include <unistd.h>
39 #endif
40
42
45
47 {
50
51 printf(
"usage: ffhash [b64:]algorithm [input]...\n");
52 printf(
"Supported hash algorithms:");
53 do {
60 }
61
63 {
65
70 } else {
73 }
74 }
75
77 {
79 int fd,
flags = O_RDONLY;
81
82 #ifdef O_BINARY
84 #endif
85 if (file) fd = open(file,
flags);
86 else fd = 0;
87 if (fd == -1) {
90 goto end;
91 }
92
94 for (;;) {
97 int err = errno;
100 printf(
"+READ-FAILED: %s", strerror(err));
102 goto end;
104 break;
106 }
108
110 end:
111 if (file)
114
116 }
117
118 int main(
int argc,
char **argv)
119 {
122 const char *hash_name;
123
124 if (argc == 1) {
126 return 0;
127 }
128
129 hash_name = argv[1];
134 printf(
"Invalid hash type: %s\n", hash_name);
135 break;
137 printf(
"%s\n", strerror(errno));
138 break;
139 }
140 return 1;
141 }
142
143 for (
i = 2;
i < argc;
i++)
145
146 if (argc < 3)
148
150
152 }