2 * feature.c --- convert between features and strings
4 * Copyright (C) 1999 Theodore Ts'o <tytso@mit.edu>
7 * This file may be redistributed under the terms of the GNU Library
8 * General Public License, version 2.
26 static struct hash hash_list[] = {
27 { EXT2_HASH_LEGACY, "legacy" },
28 { EXT2_HASH_HALF_MD4, "half_md4" },
29 { EXT2_HASH_TEA, "tea" },
33 const char *e2p_hash2string(int num)
38 for (p = hash_list; p->string; p++) {
42 sprintf(buf, "HASHALG_%d", num);
47 * Returns the hash algorithm, or -1 on error
49 int e2p_string2hash(char *string)
55 for (p = hash_list; p->string; p++) {
56 if (!strcasecmp(string, p->string)) {
60 if (strncasecmp(string, "HASHALG_", 8))
65 num = strtol(string+8, &eptr, 10);
66 if (num > 255 || num < 0)