]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - db/hash.c
xfsprogs: include headers for extern variables
[thirdparty/xfsprogs-dev.git] / db / hash.c
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
4 * All Rights Reserved.
5 */
6
7 #include "libxfs.h"
8 #include "addr.h"
9 #include "command.h"
10 #include "type.h"
11 #include "io.h"
12 #include "output.h"
13 #include "hash.h"
14
15 static int hash_f(int argc, char **argv);
16 static void hash_help(void);
17
18 static const cmdinfo_t hash_cmd =
19 { "hash", NULL, hash_f, 1, 1, 0, N_("string"),
20 N_("calculate hash value"), hash_help };
21
22 static void
23 hash_help(void)
24 {
25 dbprintf(_(
26 "\n"
27 " 'hash' prints out the calculated hash value for a string using the\n"
28 "directory/attribute code hash function.\n"
29 "\n"
30 " Usage: \"hash <string>\"\n"
31 "\n"
32 ));
33
34 }
35
36 /* ARGSUSED */
37 static int
38 hash_f(
39 int argc,
40 char **argv)
41 {
42 xfs_dahash_t hashval;
43
44 hashval = libxfs_da_hashname((unsigned char *)argv[1], (int)strlen(argv[1]));
45 dbprintf("0x%x\n", hashval);
46 return 0;
47 }
48
49 void
50 hash_init(void)
51 {
52 add_command(&hash_cmd);
53 }