/usr/include/mutils/mutils.h is in libmhash-dev 0.9.9.9-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | /*
* Copyright (C) 2005 Jonathan Day, Nikos Mavroyanopoulos
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#if !defined(__MUTILS_H)
#define __MUTILS_H
#include <mutils/mincludes.h>
#if defined(const)
#define __const const
#endif
/*
* The vast majority of user code won't care about mutils, so changes to
* this helper library API should not result in a change to the MHASH API
* version number.
*/
#define MUTILS_API 20060624
/* FIXME: We're assuming we've a standard integer types header and that it has been included
* correctly.
*/
#define MUTILS_STANDARD_TYPES 1
#if defined(MUTILS_STANDARD_TYPES)
#define TIGER_64BIT
#define mutils_word64 uint64_t
#define mutils_word32 uint32_t
#define mutils_word16 uint16_t
#define mutils_word8 uint8_t
#else /* Ok, we don't have the standard integer type definitions */
#if SIZEOF_UNSIGNED_LONG_INT == 8
typedef unsigned long int mutils_word64;
#define TIGER_64BIT
#elif SIZEOF_UNSIGNED_LONG_LONG_INT == 8
typedef unsigned long long int mutils_word64;
#else
#error "Cannot find a 64 bit integer in your system, sorry."
#endif
#if SIZEOF_UNSIGNED_LONG_INT == 4
typedef unsigned long int mutils_word32;
#elif SIZEOF_UNSIGNED_INT == 4
typedef unsigned int mutils_word32;
#else
#error "Cannot find a 32 bit integer in your system, sorry."
#endif
#if SIZEOF_UNSIGNED_INT == 2
typedef unsigned int mutils_word16;
#elif SIZEOF_UNSIGNED_SHORT_INT == 2
typedef unsigned short int mutils_word16;
#else
#error "Cannot find a 16 bit integer in your system, sorry."
#endif
#if SIZEOF_UNSIGNED_CHAR == 1
typedef unsigned char mutils_word8;
#else
#error "Cannot find an 8 bit char in your system, sorry."
#endif
#endif /* End of standard integer type declarationsd */
/*
* Due to buggy implementations of the boolean headers in some systems,
* we have to detect the boolean values separately from the boolean type.
* A big thank you to Heiko Lehmann for spotting the bug. Unfortunately,
* this fix may not be enough, as it is only going to work on things the
* precompiler knows about.
*
* Why go to all this trouble over something that should have a standard
* value anyway? Because.
*/
#if defined(HAVE__BOOL)
#define mutils_boolean _Bool
#else
typedef char mutils_boolean;
#endif
#if defined(false)
#define MUTILS_FALSE (mutils_boolean) false
#else
#if defined(FALSE)
#define MUTILS_FALSE (mutils_boolean) FALSE
#else
#define MUTILS_FALSE (mutils_boolean) 0
#endif /* FALSE */
#endif /* false */
#if defined(true)
#define MUTILS_TRUE (mutils_boolean) true
#else
#if defined(TRUE)
#define MUTILS_TRUE (mutils_boolean) TRUE
#else
#define MUTILS_TRUE (mutils_boolean) -1
#endif /* TRUE */
#endif /* true */
/*
* Other than OK, the only defined values should be for a category of error.
* Even then, the values shouldn't be assumed. Their only function is to
* make it easy to programmatically identify the nature of the error and to
* ensure a library upgrade won't break existing binaries, should new error
* codes be introduced.
*/
typedef enum __mutils_error_codes
{
MUTILS_OK = 0,
MUTILS_SYSTEM_ERROR = 0x100,
MUTILS_UNSPECIFIED_ERROR,
MUTILS_SYSTEM_RESOURCE_ERROR,
MUTILS_PARAMETER_ERROR = 0x200,
MUTILS_INVALID_FUNCTION,
MUTILS_INVALID_INPUT_BUFFER,
MUTILS_INVALID_OUTPUT_BUFFER,
MUTILS_INVALID_PASSES,
MUTILS_INVALID_FORMAT,
MUTILS_INVALID_SIZE,
MUTILS_INVALID_RESULT
} mutils_error_codes;
#define mutils_error mutils_word32
#include <mutils/mglobal.h>
/*
* Some useful, generic endian macros.
*/
#define mutils_swapendian64(x) \
((mutils_word64) \
(((x) & 0xff00000000000000ull) >> 56) | \
(((x) & 0x00ff000000000000ull) >> 40) | \
(((x) & 0x0000ff0000000000ull) >> 24) | \
(((x) & 0x000000ff00000000ull) >> 8) | \
(((x) & 0x00000000ff000000ull) << 8) | \
(((x) & 0x0000000000ff0000ull) << 24) | \
(((x) & 0x000000000000ff00ull) << 40) | \
(((x) & 0x00000000000000ffull) << 56))
#define mutils_swapendian32(a) \
((mutils_word32) \
(((a & (mutils_word32) 0x000000ffU) << 24) | \
((a & (mutils_word32) 0x0000ff00U) << 8) | \
((a & (mutils_word32) 0x00ff0000U) >> 8) | \
((a & (mutils_word32) 0xff000000U) >> 24)) \
)
#define mutils_swapendian16(a) \
((mutils_word16) \
(((a & (mutils_word16) 0x00ffU) << 8) | \
((a & (mutils_word16) 0xff00U) >> 8)) \
)
/* Change the endianness of the data if (and only if) the data type we want
* is the opposite from the native endianness. This allows us to have some
* reasonably generic macros, provided we always start from the native
* ordering.
*/
#if defined(WORDS_BIGENDIAN)
#define mutils_lend64(n) mutils_swapendian64(n)
#define mutils_lend32(n) mutils_swapendian32(n)
#define mutils_lend16(n) mutils_swapendian16(n)
#define mutils_bend64(n) n
#define mutils_bend32(n) n
#define mutils_bend16(n) n
#define mutils_lend2sys64(n) mutils_swapendian64(n)
#define mutils_lend2sys32(n) mutils_swapendian32(n)
#define mutils_lend2sys16(n) mutils_swapendian16(n)
#define mutils_bend2sys32(n) n
#define mutils_bend2sys16(n) n
#else
#define mutils_lend64(n) n
#define mutils_lend32(n) n
#define mutils_lend16(n) n
#define mutils_bend64(n) mutils_swapendian64(n)
#define mutils_bend32(n) mutils_swapendian32(n)
#define mutils_bend16(n) mutils_swapendian16(n)
#define mutils_lend2sys64(n) n
#define mutils_lend2sys32(n) n
#define mutils_lend2sys16(n) n
#define mutils_bend2sys64(n) mutils_swapendian64(n)
#define mutils_bend2sys32(n) mutils_swapendian32(n)
#define mutils_bend2sys16(n) mutils_swapendian16(n)
#endif
int mutils_mlock(__const void *addr, __const mutils_word32 len);
int mutils_munlock(__const void *addr, __const mutils_word32 len);
void *mutils_malloc(__const mutils_word32 n);
void *mutils_realloc(__const void *ptr, __const mutils_word32 n);
void mutils_free(__const void *ptr);
void mutils_bzero(void *s, __const mutils_word32 n);
void mutils_memset(void *dest, __const mutils_word8 c, __const mutils_word32 n);
void mutils_memcpy(void *dest, __const void *src, __const mutils_word32 n);
void mutils_memmove(void *dest, __const void *src, __const mutils_word32 n);
int mutils_memcmp(__const void *s1, __const void *s2, __const mutils_word32 n);
mutils_word32 mutils_strlen(__const mutils_word8 *str);
mutils_word8 *mutils_strdup(__const mutils_word8 *str);
mutils_word8 *mutils_strcat(mutils_word8 *dest, __const mutils_word8 *src);
mutils_word8 *mutils_strcpy(mutils_word8 *dest, __const mutils_word8 *src);
mutils_word8 *mutils_strncpy(mutils_word8 *dest, __const mutils_word8 *src, __const mutils_word32 n);
int mutils_strcmp(__const mutils_word8 *src1, __const mutils_word8 *src2);
int mutils_strncmp(__const mutils_word8 *src1, __const mutils_word8 *src2, __const mutils_word32 n);
long mutils_strtol(__const mutils_word8 *nptr, mutils_word8 **endptr, __const mutils_word8 base);
mutils_word32 mutils_word32swap(mutils_word32 x);
mutils_word32 *mutils_word32nswap(mutils_word32 *x, mutils_word32 n, mutils_boolean destructive);
mutils_word8 *mutils_asciify(mutils_word8 *in, __const mutils_word32 len);
mutils_boolean mutils_thequals(mutils_word8 *text, mutils_word8 *hash, __const mutils_word32 len);
#endif /* __MUTILS_H */
|