t/t-rand.py: Set the correct refernce seed value for `dsarand'.
[catacomb-python] / passphrase.c
index a72bd90..1796629 100644 (file)
@@ -1,13 +1,11 @@
 /* -*-c-*-
  *
- * $Id$
- *
  * Reading and writing passphrases
  *
  * (c) 2005 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.
@@ -41,6 +39,7 @@ static PyTypeObject *pixie_pytype;
 #define PIXIE_PYCHECK(o) PyObject_TypeCheck((o), pixie_pytype)
 #define PIXIE_FD(o) (((pixie_pyobj *)(o))->fd)
 
+#ifdef WANT_CONVPIXIE
 static int convpixie(PyObject *o, void *p)
 {
   if (!PIXIE_PYCHECK(o))
@@ -50,15 +49,16 @@ static int convpixie(PyObject *o, void *p)
 end:
   return (0);
 }
+#endif
 
 static PyObject *pixie_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
 {
   pixie_pyobj *rc = 0;
-  char *kwlist[] = { "socket", 0 };
+  static const char *const kwlist[] = { "socket", 0 };
   char *sock = 0;
   int fd;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|s:new", kwlist, &sock))
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|s:new", KWLIST, &sock))
     goto end;
   if ((fd = pixie_open(sock)) < 0)
     OSERR(sock);
@@ -71,20 +71,19 @@ end:
 static void pixie_pydealloc(PyObject *me)
 {
   close(PIXIE_FD(me));
-  PyObject_DEL(me);
-  
+  FREEOBJ(me);
 }
 
 static PyObject *pixmeth_read(PyObject *me, PyObject *arg, PyObject *kw)
 {
   unsigned mode = PMODE_READ;
   char *tag;
-  char *kwlist[] = { "tag", "mode", 0 };
+  static const char *const kwlist[] = { "tag", "mode", 0 };
   PyObject *rc = 0;
   int r;
   char buf[1024];
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s|O&:read", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s|O&:read", KWLIST,
                                   &tag, convuint, &mode))
     goto end;
   r = pixie_read(PIXIE_FD(me), tag, mode, buf, sizeof(buf));
@@ -129,8 +128,8 @@ static PyMethodDef pixie_pymethods[] = {
 };
 
 static PyTypeObject pixie_pytype_skel = {
-  PyObject_HEAD_INIT(&PyType_Type) 0,  /* Header */
-  "catacomb.Pixie",                    /* @tp_name@ */
+  PyObject_HEAD_INIT(0) 0,             /* Header */
+  "Pixie",                             /* @tp_name@ */
   sizeof(pixie_pyobj),                 /* @tp_basicsize@ */
   0,                                   /* @tp_itemsize@ */
 
@@ -153,14 +152,14 @@ static PyTypeObject pixie_pytype_skel = {
     Py_TPFLAGS_BASETYPE,
 
   /* @tp_doc@ */
-"Passphrase pixie connection.",
+"Pixie([socket = ?]): passphrase pixie connection.",
 
   0,                                   /* @tp_traverse@ */
   0,                                   /* @tp_clear@ */
   0,                                   /* @tp_richcompare@ */
   0,                                   /* @tp_weaklistoffset@ */
   0,                                   /* @tp_iter@ */
-  0,                                   /* @tp_iternexr@ */
+  0,                                   /* @tp_iternext@ */
   pixie_pymethods,                     /* @tp_methods@ */
   0,                                   /* @tp_members@ */
   0,                                   /* @tp_getset@ */
@@ -172,7 +171,7 @@ static PyTypeObject pixie_pytype_skel = {
   0,                                   /* @tp_init@ */
   PyType_GenericAlloc,                 /* @tp_alloc@ */
   pixie_pynew,                         /* @tp_new@ */
-  _PyObject_Del,                       /* @tp_free@ */
+  0,                                   /* @tp_free@ */
   0                                    /* @tp_is_gc@ */
 };
 
@@ -183,10 +182,10 @@ static PyObject *meth_ppread(PyObject *me, PyObject *arg, PyObject *kw)
   char *tag;
   unsigned f = PMODE_READ;
   PyObject *rc = 0;
-  char *kwlist[] = { "tag", "mode", 0 };
+  static const char *const kwlist[] = { "tag", "mode", 0 };
   char buf[1024];
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s|O&:ppread", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s|O&:ppread", KWLIST,
                                   &tag, convuint, &f))
     goto end;
   if (passphrase_read(tag, f, buf, sizeof(buf)))