Debian Codegraph @

src/bnpass/sha1hash.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 1999 Ross Combs ([email protected])
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18 #include "common/setup_before.h"cxx . . $ `<file>/src/common/setup_before.h`/
19 #include <cstdlib>
20 #include <cstring>
21 #include <cctype>
22
23 #include "common/eventlog.h"cxx . . $ `<file>/src/common/eventlog.h`/
24 #include "common/bnethash.h"cxx . . $ `<file>/src/common/bnethash.h`/
25 #include "common/version.h"cxx . . $ `<file>/src/common/version.h`/
26 #include "common/setup_after.h"cxx . . $ `<file>/src/common/setup_after.h`/
27
28 using namespace pvpgn;
29
30 namespacecxx . . $ `$anonymous_namespace_src/bnpass/sha1hash.cpp`/
31 {
32
33 void usagecxx . . $ `$anonymous_namespace_src/bnpass/sha1hash.cpp`/usage(85c52e162fed56f9).(char const * progname)
34 {
35 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,
36 "usage: %s [<options>] [--] [<cleartextpassword>]\n"
37 " -h, --help, --usage show this information and exit\n"
38 " -v, --version print version number and exit\n", progname);
39
40 stdcxx . . $ std/::exit(EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:92:9`!);
41 }
42
43 }
44
45 extern int maincxx . . $ main(afcd3168fc1188a4).(int argc, char * argv[])
46 {
47
48 char const * pass = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
49 int a;
50 int forcepass = 0;
51
52 if (argc < 1 || !argv || !argv[0])
53 {
54 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "bad arguments\n");
55 return EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:92:9`!;
56 }
57
58 for (a = 1; a < argc; a++)
59 if (forcepass && !pass)
60 pass = argv[a];
61 else if (stdcxx . . $ std/::strcmp(argv[a], "-") == 0 && !pass)
62 pass = argv[a];
63 else if (argv[a][0] != '-' && !pass)
64 pass = argv[a];
65 else if (forcepass || argv[a][0] != '-' || stdcxx . . $ std/::strcmp(argv[a], "-") == 0)
66 {
67 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: extra password argument \"%s\"\n", argv[0], argv[a]);
68 usagecxx . . $ `$anonymous_namespace_src/bnpass/sha1hash.cpp`/usage(85c52e162fed56f9).(argv[0]);
69 }
70 else if (stdcxx . . $ std/::strcmp(argv[a], "--") == 0)
71 forcepass = 1;
72 else if (stdcxx . . $ std/::strcmp(argv[a], "-v") == 0 || stdcxx . . $ std/::strcmp(argv[a], "--version") == 0)
73 {
74 stdcxx . . $ std/::printfcxx . . $ std/printf(581fddd72a8db8fc).("version " PVPGN_VERSIONcxx . . $ `src/common/version.h:23:9`! "\n");
75 return EXIT_SUCCESScxx . . $ `<external>/10696550936717951914/stdlib.h:93:9`!;
76 }
77 else if (stdcxx . . $ std/::strcmp(argv[a], "-h") == 0 || stdcxx . . $ std/::strcmp(argv[a], "--help") == 0 || stdcxx . . $ std/::strcmp(argv[a], "--usage")
78 == 0)
79 usagecxx . . $ `$anonymous_namespace_src/bnpass/sha1hash.cpp`/usage(85c52e162fed56f9).(argv[0]);
80 else
81 {
82 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: unknown option \"%s\"\n", argv[0], argv[a]);
83 usagecxx . . $ `$anonymous_namespace_src/bnpass/sha1hash.cpp`/usage(85c52e162fed56f9).(argv[0]);
84 }
85
86 {
87 char buff[256];
88 t_hashcxx . . $ pvpgn/t_hash# hash;
89
90 eventlog_setcxx . . $ pvpgn/eventlog_set(8d4262d45fc644ab).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!); /* sha1_hash() and friends use eventlog */
91
92 if (!pass)
93 {
94 stdcxx . . $ std/::printfcxx . . $ std/printf(581fddd72a8db8fc).("Enter password to hash: ");
95 stdcxx . . $ std/::fflushcxx . . $ std/fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
96 stdcxx . . $ std/::fgetscxx . . $ std/fgets(efb0aaba7ac866ae).(buff, 256, stdincxx . . $ `<external>/232824719582829767/stdio.h:153:9`!);
97 if (buff[0] != '\0')
98 buff[stdcxx . . $ std/::strlen(buff) - 1] = '\0';
99 }
100 else
101 {
102 stdcxx . . $ std/::strncpy(buff, pass, sizeof(buff));
103 buff[sizeof(buff)-1] = '\0';
104 }
105
106 sha1_hashcxx . . $ pvpgn/sha1_hash(2a8392f275be648).(&hash, stdcxx . . $ std/::strlen(buff), buff);
107 stdcxx . . $ std/::printfcxx . . $ std/printf(581fddd72a8db8fc).("sha1 hash = %s\n", hash_get_strcxx . . $ pvpgn/hash_get_str(d917ea147d03f908).(hash));
108 }
109
110 return EXIT_SUCCESScxx . . $ `<external>/10696550936717951914/stdlib.h:93:9`!;
111 }