The pixie no longer needs to be setuid-root.
[u/mdw/catacomb] / mpscan.c
1 /* -*-c-*-
2 *
3 * $Id: mpscan.c,v 1.4 2004/04/08 01:36:15 mdw Exp $
4 *
5 * Sequential bit scan of multiprecision integers
6 *
7 * (c) 1999 Straylight/Edgeware
8 */
9
10 /*----- Licensing notice --------------------------------------------------*
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.
18 *
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.
23 *
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
30 /*----- Header files ------------------------------------------------------*/
31
32 #include "mpscan.h"
33
34 /*----- Right-to-left scanning --------------------------------------------*/
35
36 /* --- @mpscan_initx@ --- *
37 *
38 * Arguments: @mpscan *m@ = pointer to bitscanner structure
39 * @const mpw *v, *vl@ = vector of words to scan
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
49 void mpscan_initx(mpscan *m, const mpw *v, const mpw *vl)
50 {
51 MPSCAN_INITX(m, v, vl);
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
64 int 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
76 int mpscan_bit(const mpscan *m) { return (MPSCAN_BIT(m)); }
77
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
93 void 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
108 int 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
120 int mpscan_rbit(const mpscan *m) { return (MPSCAN_RBIT(m)); }
121
122 /*----- That's all, folks -------------------------------------------------*/