**********************************************************************/
#include <stdio.h>
#include <stdlib.h>
+#ifdef _MSC_VER
+#include "getopt.h"
+# ifndef PATH_MAX
+# define PATH_MAX _MAX_PATH
+# endif
+#include <BaseTsd.h>
+typedef SSIZE_T ssize_t;
+#else
#include <unistd.h>
+#endif
#include <limits.h>
#include <fcntl.h>
#ifdef _WIN32
init_gost_hash_ctx(&ctx, b);
if (check_file) {
char inhash[65], calcsum[65], filename[PATH_MAX];
- int failcount = 0, count = 0, errors = 0;
+ int failcount = 0, count = 0;
+ errors = 0;
if (check_file == stdin && optind < argc) {
check_file = fopen(argv[optind], "r");
if (!check_file) {
while (get_line(check_file, inhash, filename)) {
count++;
if (!hash_file(&ctx, filename, calcsum, open_mode)) {
- errors ++;
- continue;
+ errors++;
+ continue;
}
if (strncmp(calcsum, inhash, 65) == 0) {
if (verbose) {
"%s: %d of %d file(f) failed GOST hash sum check\n",
argv[0], failcount, count);
}
- exit((failcount || errors)? 1 : 0);
+ exit((failcount || errors) ? 1 : 0);
}
if (optind == argc) {
char sum[65];
#ifdef _WIN32
- if (open_mode & O_BINARY) {
- _setmode(fileno(stdin),O_BINARY);
- }
+ if (open_mode & O_BINARY) {
+ _setmode(fileno(stdin), O_BINARY);
+ }
#endif
if (!hash_stream(&ctx, fileno(stdin), sum)) {
perror("stdin");
}
if (!hash_stream(ctx, fd, sum)) {
perror(filename);
+ close(fd);
return 0;
}
close(fd);