chiark / gitweb /
Overhaul build system using new `cfd' machinery.
[catacomb-python] / rand.c
diff --git a/rand.c b/rand.c
index 4b40a750580212e21230f55a3e4da897db373c19..9f086e60a6d397c294b47d04d7e15712ae182788 100644 (file)
--- a/rand.c
+++ b/rand.c
@@ -1,13 +1,11 @@
 /* -*-c-*-
- *
- * $Id$
  *
  * Random-number generators
  *
  * (c) 2004 Straylight/Edgeware
  */
 
-/*----- Licensing notice --------------------------------------------------* 
+/*----- Licensing notice --------------------------------------------------*
  *
  * This file is part of the Python interface to Catacomb.
  *
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- * 
+ *
  * Catacomb/Python 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 General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with Catacomb/Python; if not, write to the Free Software Foundation,
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
@@ -80,7 +78,7 @@ static PyObject *grmeth_byte(PyObject *me, PyObject *arg)
 static PyObject *grmeth_word(PyObject *me, PyObject *arg)
 {
   if (!PyArg_ParseTuple(arg, ":word")) return (0);
-  return (getu32(grand_word(GRAND_R(me))));
+  return (getulong(grand_word(GRAND_R(me))));
 }
 
 static PyObject *grmeth_range(PyObject *me, PyObject *arg)
@@ -524,7 +522,7 @@ static PyObject *trget_goodbits(PyObject *me, void *hunoz)
 
 static PyGetSetDef truerand_pygetset[] = {
 #define GETSETNAME(op, name) tr##op##_##name
-  GET  (goodbits,      "R.goodbits -> good bits of entropy remaining")
+  GET  (goodbits,      "R.goodbits -> good bits of entropy remaining")
 #undef GETSETNAME
   { 0 }
 };
@@ -619,7 +617,7 @@ static PyObject *gcrand_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
   if (keysz(n, info->keysz) != n) VALERR("bad key length");
   return (grand_dopywrap(ty, info->func(k, n), f_freeme));
 end:
-  return (0);  
+  return (0);
 }
 
 static PyObject *gcirand_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
@@ -638,26 +636,26 @@ static PyObject *gcirand_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
                         ((gcirand_func *)info->func)(k, n, i),
                         f_freeme));
 end:
-  return (0);  
+  return (0);
 }
 
 static PyObject *gccrand_pywrap(const gccrand_info *info)
 {
   gccrand_pyobj *g = newtype(gccrand_pytype, 0, info->name);
   g->info = info;
-  g->ty.type.tp_basicsize = sizeof(grand_pyobj);
-  g->ty.type.tp_base = gcrand_pytype;
+  g->ty.ht_type.tp_basicsize = sizeof(grand_pyobj);
+  g->ty.ht_type.tp_base = gcrand_pytype;
   Py_INCREF(gcrand_pytype);
-  g->ty.type.tp_flags = (Py_TPFLAGS_DEFAULT |
-                        Py_TPFLAGS_BASETYPE |
-                        Py_TPFLAGS_HEAPTYPE);
-  g->ty.type.tp_alloc = PyType_GenericAlloc;
-  g->ty.type.tp_free = 0;
+  g->ty.ht_type.tp_flags = (Py_TPFLAGS_DEFAULT |
+                           Py_TPFLAGS_BASETYPE |
+                           Py_TPFLAGS_HEAPTYPE);
+  g->ty.ht_type.tp_alloc = PyType_GenericAlloc;
+  g->ty.ht_type.tp_free = 0;
   if (info->f & RNGF_INT)
-    g->ty.type.tp_new = gcirand_pynew;
+    g->ty.ht_type.tp_new = gcirand_pynew;
   else
-    g->ty.type.tp_new = gcrand_pynew;
-  PyType_Ready(&g->ty.type);
+    g->ty.ht_type.tp_new = gcrand_pynew;
+  PyType_Ready(&g->ty.ht_type);
   return ((PyObject *)g);
 }
 
@@ -1076,7 +1074,7 @@ static PyObject *bbsmeth_bits(PyObject *me, PyObject *arg)
   grand *r = GRAND_R(me); unsigned n; uint32 w;
   if (!PyArg_ParseTuple(arg, "O&:bits", convuint, &n)) goto end;
   if (n > 32) VALERR("can't get more than 32 bits");
-  r->ops->misc(r, BBS_BITS, n, &w); return (getu32(w));
+  r->ops->misc(r, BBS_BITS, n, &w); return (getulong(w));
 end:
   return (0);
 }
@@ -1236,7 +1234,7 @@ static PyObject *meth__BBSPriv_generate(PyObject *me,
   rc->bp.n = MP_COPY(bp.n);
 end:
   mp_drop(bp.p); mp_drop(bp.q); mp_drop(bp.n); mp_drop(x);
-  return ((PyObject *)rc); 
+  return ((PyObject *)rc);
 }
 
 static void bbspriv_pydealloc(PyObject *me)
@@ -1281,9 +1279,9 @@ static PyMethodDef bbspriv_pymethods[] = {
 
 static PyGetSetDef bbspriv_pygetset[] = {
 #define GETSETNAME(op, name) bp##op##_##name
-  GET  (n,             "R.n -> Blum modulus")
-  GET  (p,             "R.p -> one of the factors of the modulus")
-  GET  (q,             "R.q -> one of the factors of the modulus")
+  GET  (n,             "R.n -> Blum modulus")
+  GET  (p,             "R.p -> one of the factors of the modulus")
+  GET  (q,             "R.q -> one of the factors of the modulus")
 #undef GETSETNAME
   { 0 }
 };