Files
bubblebabble/main.c

55 lines
1.4 KiB
C
Raw Normal View History

2025-12-01 20:42:23 +01:00
/*
This file is part of bubblebabble.
Copyright (C) 2018-2025 T.v.Dein.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact me by mail: <tom AT vondein DOT org>.
*/
#include "bubblebabble.h"
int main(int argc, char **argv) {
FILE *input;
u_char digest[1024];
size_t digestlen;
char *hash;
int out = 1;
if (argc < 2) {
input = stdin;
} else {
if ((input = fopen(argv[1], "rb")) == NULL) {
fprintf(stderr, "oops, could not open file!\n");
goto done;
}
}
digestlen = fread(digest, 1, 1024, input);
if (digestlen > 0) {
hash = fingerprint_bubblebabble(digest, digestlen);
fprintf(stdout, "%s\n", hash);
free(hash);
out = 0;
} else {
fprintf(stderr, "oops, could not calculate bubbles!\n");
goto done;
}
done:
return out;
}