gdsa: Fix the conversion of hashes to integers to conform to the spec.
[u/mdw/catacomb] / mpscan.c
CommitLineData
d03ab969 1/* -*-c-*-
2 *
b817bfc6 3 * $Id: mpscan.c,v 1.4 2004/04/08 01:36:15 mdw Exp $
d03ab969 4 *
5 * Sequential bit scan of multiprecision integers
6 *
7 * (c) 1999 Straylight/Edgeware
8 */
9
45c0fd36 10/*----- Licensing notice --------------------------------------------------*
d03ab969 11 *
12 * This file is part of Catacomb.
13 *
14 * Catacomb is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU Library General Public License as
16 * published by the Free Software Foundation; either version 2 of the
17 * License, or (at your option) any later version.
45c0fd36 18 *
d03ab969 19 * Catacomb is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Library General Public License for more details.
45c0fd36 23 *
d03ab969 24 * You should have received a copy of the GNU Library General Public
25 * License along with Catacomb; if not, write to the Free
26 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
27 * MA 02111-1307, USA.
28 */
29
d03ab969 30/*----- Header files ------------------------------------------------------*/
31
962405ef 32#include "mpscan.h"
d03ab969 33
5fbe3846 34/*----- Right-to-left scanning --------------------------------------------*/
d03ab969 35
36/* --- @mpscan_initx@ --- *
37 *
38 * Arguments: @mpscan *m@ = pointer to bitscanner structure
962405ef 39 * @const mpw *v, *vl@ = vector of words to scan
d03ab969 40 *
41 * Returns: ---
42 *
43 * Use: Initializes a bitscanner from a low-level vector-and-length
44 * representation of an integer. Initially no bit is ready; you
45 * must call @mpscan_step@ before anything useful will come
46 * out.
47 */
48
962405ef 49void mpscan_initx(mpscan *m, const mpw *v, const mpw *vl)
d03ab969 50{
962405ef 51 MPSCAN_INITX(m, v, vl);
d03ab969 52}
53
54/* --- @mpscan_step@ --- *
55 *
56 * Arguments: @mpscan *m@ = pointer to bitscanner
57 *
58 * Returns: Nonzero if there is another bit to read.
59 *
60 * Use: Steps on to the next bit in the integer. The macro version
61 * evaluates its argument multiple times.
62 */
63
64int mpscan_step(mpscan *m) { return (MPSCAN_STEP(m)); }
65
66/* --- @mpscan_bit@ --- *
67 *
68 * Arguments: @const mpscan *m@ = pointer to bitscanner
69 *
70 * Returns: The value of the current bit.
71 *
72 * Use: Reads the value of the current bit looked at by a
73 * bitscanner.
74 */
75
76int mpscan_bit(const mpscan *m) { return (MPSCAN_BIT(m)); }
77
5fbe3846 78/*----- Left-to right-scanning --------------------------------------------*/
79
80/* --- @mpscan_rinitx@ --- *
81 *
82 * Arguments: @mpscan *m@ = pointer to bitscanner structure
83 * @const mpw *v, *vl@ = vector of words to scan
84 *
85 * Returns: ---
86 *
87 * Use: Initializes a reverse bitscanner from a low-level
88 * vector-and-length representation of an integer. Initially no
89 * bit is ready; you must call @mpscan_rstep@ before anything
90 * useful will come out.
91 */
92
93void mpscan_rinitx(mpscan *m, const mpw *v, const mpw *vl)
94{
95 MPSCAN_RINITX(m, v, vl);
96}
97
98/* --- @mpscan_rstep@ --- *
99 *
100 * Arguments: @mpscan *m@ = pointer to bitscanner
101 *
102 * Returns: Nonzero if there is another bit to read.
103 *
104 * Use: Steps on to the next bit in the integer. The macro version
105 * evaluates its argument multiple times.
106 */
107
108int mpscan_rstep(mpscan *m) { return (MPSCAN_RSTEP(m)); }
109
110/* --- @mpscan_rbit@ --- *
111 *
112 * Arguments: @const mpscan *m@ = pointer to bitscanner
113 *
114 * Returns: The value of the current bit.
115 *
116 * Use: Reads the value of the current bit looked at by a
117 * reverse bitscanner.
118 */
119
120int mpscan_rbit(const mpscan *m) { return (MPSCAN_RBIT(m)); }
121
d03ab969 122/*----- That's all, folks -------------------------------------------------*/