80f5854f8734db4b85b10b39c2d3697487afbdb2
[pyke] / catacomb-python.h
1 /* -*-c-*-
2 *
3 * Definitions for Catacomb bindings
4 *
5 * (c) 2004 Straylight/Edgeware
6 */
7
8 /*----- Licensing notice --------------------------------------------------*
9 *
10 * This file is part of the Python interface to Catacomb.
11 *
12 * Catacomb/Python is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * Catacomb/Python is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with Catacomb/Python; if not, write to the Free Software Foundation,
24 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 */
26
27 #ifndef CATACOMB_PYTHON_H
28 #define CATACOMB_PYTHON_H
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 /*----- Header files ------------------------------------------------------*/
35
36 #include <Python.h>
37 #include <longintrepr.h>
38 #include <structmember.h>
39
40 #include <mLib/darray.h>
41 #include <mLib/dstr.h>
42 #include <mLib/macros.h>
43 #include <mLib/quis.h>
44 #include <mLib/unihash.h>
45
46 #include <catacomb/buf.h>
47
48 #include <catacomb/grand.h>
49 #include <catacomb/rand.h>
50 #include <catacomb/noise.h>
51 #include <catacomb/bbs.h>
52 #include <catacomb/mprand.h>
53 #include <catacomb/lcrand.h>
54 #include <catacomb/fibrand.h>
55 #include <catacomb/dsarand.h>
56 #include <catacomb/sslprf.h>
57 #include <catacomb/tlsprf.h>
58 #include <catacomb/blkc.h>
59
60 #include <catacomb/gcipher.h>
61 #include <catacomb/ghash.h>
62 #include <catacomb/gmac.h>
63 #include <catacomb/md5.h>
64 #include <catacomb/md5-hmac.h>
65 #include <catacomb/sha.h>
66 #include <catacomb/sha-mgf.h>
67 #include <catacomb/sha-hmac.h>
68
69 #include <catacomb/mp.h>
70 #include <catacomb/mpint.h>
71 #include <catacomb/mpmul.h>
72 #include <catacomb/mpcrt.h>
73 #include <catacomb/mpmont.h>
74 #include <catacomb/mpbarrett.h>
75 #include <catacomb/mpreduce.h>
76 #include <catacomb/mp-fibonacci.h>
77
78 #include <catacomb/pgen.h>
79 #include <catacomb/pfilt.h>
80 #include <catacomb/strongprime.h>
81 #include <catacomb/limlee.h>
82 #include <catacomb/dh.h>
83 #include <catacomb/ptab.h>
84 #include <catacomb/bintab.h>
85 #include <catacomb/dsa.h>
86
87 #include <catacomb/gf.h>
88 #include <catacomb/gfreduce.h>
89 #include <catacomb/gfn.h>
90
91 #include <catacomb/field.h>
92 #include <catacomb/field-guts.h>
93
94 #include <catacomb/ec.h>
95 #include <catacomb/ec-raw.h>
96 #include <catacomb/ectab.h>
97
98 #include <catacomb/group.h>
99 #include <catacomb/group-guts.h>
100
101 #include <catacomb/gdsa.h>
102 #include <catacomb/gkcdsa.h>
103 #include <catacomb/rsa.h>
104
105 #include <catacomb/key.h>
106 #include <catacomb/passphrase.h>
107 #include <catacomb/pixie.h>
108
109 #include <catacomb/share.h>
110 #include <catacomb/gfshare.h>
111
112 /*----- Utility macros ----------------------------------------------------*/
113
114 #define RETURN_OBJ(obj) do { Py_INCREF(obj); return (obj); } while (0)
115 #define RETURN_NONE RETURN_OBJ(Py_None)
116 #define RETURN_NOTIMPL RETURN_OBJ(Py_NotImplemented)
117 #define RETURN_TRUE RETURN_OBJ(Py_True)
118 #define RETURN_FALSE RETURN_OBJ(Py_False)
119 #define RETURN_ME RETURN_OBJ(me)
120
121 #define EXCERR(exc, str) do { \
122 PyErr_SetString(exc, str); \
123 goto end; \
124 } while (0)
125 #define VALERR(str) EXCERR(PyExc_ValueError, str)
126 #define TYERR(str) EXCERR(PyExc_TypeError, str)
127 #define ZDIVERR(str) EXCERR(PyExc_ZeroDivisionError, str)
128 #define SYSERR(str) EXCERR(PyExc_SystemError, str)
129 #define NIERR(str) EXCERR(PyExc_NotImplementedError, str)
130 #define INDEXERR(idx) do { \
131 PyErr_SetObject(PyExc_KeyError, idx); \
132 goto end; \
133 } while (0)
134 #define OSERR(name) do { \
135 PyErr_SetFromErrnoWithFilename(PyExc_OSError, name); \
136 goto end; \
137 } while (0)
138 #define PGENERR do { pgenerr(); goto end; } while (0)
139
140 #define CONVFUNC(ty, cty, ext) \
141 int conv##ty(PyObject *o, void *p) \
142 { \
143 if (!PyObject_TypeCheck(o, ty##_pytype)) \
144 TYERR("wanted a " #ty); \
145 *(cty *)p = ext(o); \
146 return (1); \
147 end: \
148 return (0); \
149 }
150
151 #if PY_VERSION_HEX < 0x02050000 /* Compatibility hack */
152 # define ht_name name
153 # define ht_type type
154 #endif
155
156 #define root_pytype 0
157 #define type_pytype &PyType_Type
158 #define INITTYPE(ty, base) do { \
159 ty##_pytype_skel.tp_base = base##_pytype; \
160 ty##_pytype = inittype(&ty##_pytype_skel); \
161 } while (0)
162
163 #define INSERT(name, ob) do { \
164 PyObject *_o = (PyObject *)(ob); \
165 Py_INCREF(_o); \
166 PyModule_AddObject(mod, name, _o); \
167 } while (0)
168
169 #define INSEXC(name, var, base, meth) \
170 INSERT(name, var = mkexc(mod, base, name, meth))
171
172 #define METH(func, doc) \
173 { #func, METHNAME(func), METH_VARARGS, doc },
174 #define KWMETH(func, doc) \
175 { #func, (PyCFunction)METHNAME(func), \
176 METH_VARARGS | METH_KEYWORDS, doc },
177
178 #define GET(func, doc) \
179 { #func, GETSETNAME(get, func), 0, doc },
180 #define GETSET(func, doc) \
181 { #func, GETSETNAME(get, func), GETSETNAME(set, func), doc },
182
183 #define MEMBER(name, ty, f, doc) \
184 { #name, ty, offsetof(MEMBERSTRUCT, name), f, doc },
185
186 #define MODULES(_) \
187 _(util) \
188 _(bytestring) _(buffer) \
189 _(rand) _(algorithms) _(pubkey) _(pgen) \
190 _(mp) _(field) _(ec) _(group) \
191 _(passphrase) _(share) _(key)
192 #define DOMODINIT(m) m##_pyinit();
193 #define DOMODINSERT(m) m##_pyinsert(mod);
194 #define INIT_MODULES do { MODULES(DOMODINIT) } while (0)
195 #define INSERT_MODULES do { MODULES(DOMODINSERT) } while (0)
196
197 #define DO(m) \
198 extern void m##_pyinit(void); \
199 extern void m##_pyinsert(PyObject *);
200 MODULES(DO)
201 #undef DO
202
203 #define FREEOBJ(obj) \
204 (((PyObject *)(obj))->ob_type->tp_free((PyObject *)(obj)))
205
206 #define GEN(func, base) \
207 static PyObject *func(void) \
208 { \
209 PyObject *d = PyDict_New(); \
210 PyObject *o; \
211 int i; \
212 \
213 for (i = 0; g##base##tab[i]; i++) { \
214 o = gc##base##_pywrap((/*unconst*/ gc##base *)g##base##tab[i]); \
215 PyDict_SetItemString(d, \
216 (/*unconst*/ char *)g##base##tab[i]->name, \
217 o); \
218 Py_DECREF(o); \
219 } \
220 return (d); \
221 }
222
223 struct nameval { const char *name; unsigned long value; };
224 extern void setconstants(PyObject *, const struct nameval *);
225
226 extern PyObject *mexp_common(PyObject *, PyObject *, size_t,
227 PyObject *(*id)(PyObject *),
228 int (*fill)(void *, PyObject *,
229 PyObject *, PyObject *),
230 PyObject *(*exp)(PyObject *, void *, int),
231 void (*drop)(void *));
232
233 extern int convulong(PyObject *, void *);
234 #define DECL_CONVU_(n) extern int convu##n(PyObject *, void *);
235 DOUINTSZ(DECL_CONVU_)
236 extern int convmpw(PyObject *, void *);
237 extern int convuint(PyObject *, void *);
238 extern int convszt(PyObject *, void *);
239 extern int convbool(PyObject *, void *);
240 extern PyObject *abstract_pynew(PyTypeObject *, PyObject *, PyObject *);
241 extern PyObject *getbool(int);
242 extern PyObject *getulong(unsigned long);
243 extern void *newtype(PyTypeObject *, const PyTypeObject *, const char *);
244
245 extern PyObject *mkexc(PyObject *, PyObject *, const char *, PyMethodDef *);
246 extern void typeready(PyTypeObject *);
247 extern PyTypeObject *inittype(PyTypeObject *);
248 extern void addmethods(const PyMethodDef *);
249 extern PyMethodDef *donemethods(void);
250
251 /*----- Mapping methods ---------------------------------------------------*/
252
253 #define GMAP_METH(func, doc) { #func, gmapmeth_##func, METH_VARARGS, doc },
254 #define GMAP_KWMETH(func, doc) \
255 { #func, (PyCFunction)gmapmeth_##func, METH_VARARGS|METH_KEYWORDS, doc },
256 #define GMAP_METHDECL(func, doc) \
257 extern PyObject *gmapmeth_##func(PyObject *, PyObject *);
258 #define GMAP_KWMETHDECL(func, doc) \
259 extern PyObject *gmapmeth_##func(PyObject *, PyObject *, PyObject *);
260
261 #define GMAP_DOROMETHODS(METH, KWMETH) \
262 METH (has_key, "D.has_key(KEY) -> BOOL") \
263 METH (keys, "D.keys() -> LIST") \
264 METH (values, "D.values() -> LIST") \
265 METH (items, "D.items() -> LIST") \
266 METH (iterkeys, "D.iterkeys() -> ITER") \
267 METH (itervalues, "D.itervalues() -> ITER") \
268 METH (iteritems, "D.iteritems() -> ITER") \
269 KWMETH(get, "D.get(KEY, [default = None]) -> VALUE") \
270
271 #define GMAP_DOMETHODS(METH, KWMETH) \
272 GMAP_DOROMETHODS(METH, KWMETH) \
273 METH (clear, "D.clear()") \
274 KWMETH(setdefault, "D.setdefault(K, [default = None]) -> VALUE") \
275 KWMETH(pop, "D.pop(KEY, [default = <error>]) -> VALUE") \
276 METH (popitem, "D.popitem() -> (KEY, VALUE)") \
277 METH (update, "D.update(MAP)")
278
279 GMAP_DOMETHODS(GMAP_METHDECL, GMAP_KWMETHDECL)
280 #define GMAP_ROMETHODS GMAP_DOROMETHODS(GMAP_METH, GMAP_KWMETH)
281 #define GMAP_METHODS GMAP_DOMETHODS(GMAP_METH, GMAP_KWMETH)
282 extern Py_ssize_t gmap_pysize(PyObject *);
283 extern PySequenceMethods gmap_pysequence;
284 extern PyMethodDef gmap_pymethods[];
285
286 /*----- Bytestrings -------------------------------------------------------*/
287
288 PyTypeObject *bytestring_pyobj;
289 PyObject *bytestring_pywrap(const void *, size_t);
290 PyObject *bytestring_pywrapbuf(buf *);
291
292 /*----- Multiprecision arithmetic -----------------------------------------*/
293
294 typedef struct mp_pyobj {
295 PyObject_HEAD
296 mp *x;
297 } mp_pyobj;
298
299 extern PyTypeObject *mp_pytype;
300 extern PyTypeObject *gf_pytype;
301 #define MP_X(o) (((mp_pyobj *)(o))->x)
302 #define MP_PYCHECK(o) PyObject_TypeCheck((o), mp_pytype)
303 #define GF_PYCHECK(o) PyObject_TypeCheck((o), gf_pytype)
304
305 extern mp *mp_frompylong(PyObject *);
306 extern PyObject *mp_topylong(mp *);
307 extern mp *tomp(PyObject *);
308 extern mp *getmp(PyObject *);
309 extern int convmp(PyObject *, void *);
310 extern mp *getgf(PyObject *);
311 extern int convgf(PyObject *, void *);
312 extern PyObject *mp_pywrap(mp *);
313 extern PyObject *gf_pywrap(mp *);
314 extern mp *mp_frompyobject(PyObject *, int);
315 extern PyObject *mp_topystring(mp *, int,
316 const char *, const char *, const char *);
317 extern int mp_tolong_checked(mp *, long *);
318
319 /*----- Abstract fields ---------------------------------------------------*/
320
321 typedef struct field_pyobj {
322 PyHeapTypeObject ty;
323 field *f;
324 } field_pyobj;
325
326 extern PyTypeObject *fe_pytype;
327 #define FE_PYCHECK(o) PyObject_TypeCheck((o), fe_pytype)
328 #define FE_F(o) (((fe_pyobj *)(o))->f)
329 #define FE_FOBJ(o) ((PyObject *)(o)->ob_type)
330 #define FE_X(o) (((fe_pyobj *)(o))->x)
331 extern PyObject *fe_pywrap(PyObject *, mp *);
332 extern mp *getfe(field *, PyObject *);
333
334 typedef struct fe_pyobj {
335 PyObject_HEAD
336 field *f;
337 mp *x;
338 } fe_pyobj;
339
340 extern PyTypeObject *field_pytype;
341 extern PyTypeObject *primefield_pytype;
342 extern PyTypeObject *niceprimefield_pytype;
343 extern PyTypeObject *binfield_pytype;
344 extern PyTypeObject *binpolyfield_pytype;
345 extern PyTypeObject *binnormfield_pytype;
346 #define FIELD_PYCHECK(o) PyObject_TypeCheck((o), field_pytype)
347 #define FIELD_F(o) (((field_pyobj *)(o))->f)
348 extern PyObject *field_pywrap(field *);
349 extern field *field_copy(field *);
350
351 /*----- Elliptic curves ---------------------------------------------------*/
352
353 typedef struct ecpt_pyobj {
354 PyObject_HEAD
355 ec_curve *c;
356 ec p;
357 } ecpt_pyobj;
358
359 extern PyTypeObject *ecpt_pytype, *ecptcurve_pytype;
360 #define ECPT_PYCHECK(o) PyObject_TypeCheck((o), ecpt_pytype)
361 #define ECPTCURVE_PYCHECK(o) PyObject_TypeCheck((o), ecptcurve_pytype)
362 #define ECPT_C(o) (((ecpt_pyobj *)(o))->c)
363 #define ECPT_COBJ(o) ((PyObject *)(o)->ob_type)
364 #define ECPT_FOBJ(o) ECCURVE_FOBJ(ECPT_COBJ((o)))
365 #define ECPT_P(o) (&((ecpt_pyobj *)(o))->p)
366 extern PyObject *ecpt_pywrap(PyObject *, ec *);
367 extern PyObject *ecpt_pywrapout(void *, ec *);
368 extern int toecpt(ec_curve *, ec *, PyObject *);
369 extern int getecpt(ec_curve *, ec *, PyObject *);
370 extern void getecptout(ec *, PyObject *);
371 extern int convecpt(PyObject *, void *);
372
373 typedef struct eccurve_pyobj {
374 PyHeapTypeObject ty;
375 ec_curve *c;
376 PyObject *fobj;
377 } eccurve_pyobj;
378
379 extern PyTypeObject *eccurve_pytype;
380 extern PyTypeObject *ecprimecurve_pytype;
381 extern PyTypeObject *ecprimeprojcurve_pytype;
382 extern PyTypeObject *ecbincurve_pytype;
383 extern PyTypeObject *ecbinprojcurve_pytype;
384 #define ECCURVE_PYCHECK(o) PyObject_TypeCheck((o), eccurve_pytype)
385 #define ECCURVE_C(o) (((eccurve_pyobj *)(o))->c)
386 #define ECCURVE_FOBJ(o) (((eccurve_pyobj *)(o))->fobj)
387 extern PyObject *eccurve_pywrap(PyObject *, ec_curve *);
388 extern ec_curve *eccurve_copy(ec_curve *);
389
390 typedef struct ecinfo_pyobj {
391 PyObject_HEAD
392 ec_info ei;
393 PyObject *cobj;
394 } ecinfo_pyobj;
395
396 extern PyTypeObject *ecinfo_pytype;
397 #define ECINFO_PYCHECK(o) PyObject_TypeCheck((o), ecinfo_pytype)
398 #define ECINFO_EI(o) (&((ecinfo_pyobj *)(o))->ei)
399 #define ECINFO_COBJ(o) (((ecinfo_pyobj *)(o))->cobj)
400 extern void ecinfo_copy(ec_info *, const ec_info *);
401 extern PyObject *ecinfo_pywrap(ec_info *);
402
403 /*----- Cyclic groups -----------------------------------------------------*/
404
405 typedef struct fginfo_pyobj {
406 PyObject_HEAD
407 gprime_param dp;
408 } fginfo_pyobj;
409
410 PyTypeObject *fginfo_pytype, *dhinfo_pytype, *bindhinfo_pytype;
411 #define FGINFO_DP(fg) (&((fginfo_pyobj *)(fg))->dp)
412 PyObject *fginfo_pywrap(gprime_param *, PyTypeObject *);
413
414 typedef struct ge_pyobj {
415 PyObject_HEAD
416 ge *x;
417 group *g;
418 } ge_pyobj;
419
420 extern PyTypeObject *ge_pytype;
421 #define GE_PYCHECK(o) PyObject_TypeCheck((o), ge_pytype)
422 #define GE_X(o) (((ge_pyobj *)(o))->x)
423 #define GE_G(o) (((ge_pyobj *)(o))->g)
424 #define GE_GOBJ(o) ((PyObject *)(group_pyobj *)(o)->ob_type)
425 extern PyObject *ge_pywrap(PyObject *, ge *);
426
427 typedef struct group_pyobj {
428 PyHeapTypeObject ty;
429 group *g;
430 } group_pyobj;
431
432 extern PyTypeObject *group_pytype;
433 extern PyTypeObject *primegroup_pytype, *bingroup_pytype, *ecgroup_pytype;
434 #define GROUP_G(o) (((group_pyobj *)(o))->g)
435 extern PyObject *group_pywrap(group *);
436 extern group *group_copy(group *);
437
438 /*----- Random number generators ------------------------------------------*/
439
440 #define f_freeme 1u
441
442 typedef struct grand_pyobj {
443 PyObject_HEAD
444 unsigned f;
445 grand *r;
446 } grand_pyobj;
447
448 extern PyTypeObject *grand_pytype, *truerand_pytype;
449 extern PyTypeObject *lcrand_pytype,* fibrand_pytype;
450 extern PyTypeObject *dsarand_pytype, *bbs_pytype;
451 extern PyObject *rand_pyobj;
452 #define GRAND_PYCHECK(o) PyObject_TypeCheck((o), grand_pytype)
453 #define GRAND_F(o) (((grand_pyobj *)(o))->f)
454 #define GRAND_R(o) (((grand_pyobj *)(o))->r)
455 extern PyObject *grand_pywrap(grand *, unsigned);
456 extern int convgrand(PyObject *, void *);
457
458 /*----- Key sizes ---------------------------------------------------------*/
459
460 typedef struct keysz_pyobj {
461 PyObject_HEAD
462 int dfl;
463 } keysz_pyobj;
464
465 typedef struct keyszrange_pyobj {
466 PyObject_HEAD
467 int dfl;
468 int min, max, mod;
469 } keyszrange_pyobj;
470
471 typedef struct keyszset_pyobj {
472 PyObject_HEAD
473 int dfl;
474 PyObject *set;
475 } keyszset_pyobj;
476
477 #define KEYSZ_PYCHECK(o) PyObject_TypeCheck((o), keysz_pytype)
478 extern PyObject *keysz_pywrap(const octet *);
479
480 /*----- Symmetric cryptography --------------------------------------------*/
481
482 typedef struct gccipher_pyobj {
483 PyHeapTypeObject ty;
484 gccipher *cc;
485 } gccipher_pyobj;
486
487 extern PyTypeObject *gccipher_pytype;
488 #define GCCIPHER_PYCHECK(o) PyObject_TypeCheck((o), gccipher_pytype)
489 #define GCCIPHER_CC(o) (((gccipher_pyobj *)(o))->cc)
490 #define GCCIPHER_F(o) (((gccipher_pyobj *)(o))->f)
491 extern PyObject *gccipher_pywrap(gccipher *);
492 extern int convgccipher(PyObject *, void *);
493 extern int convgcipher(PyObject *, void *);
494
495 typedef struct gcipher_pyobj {
496 PyObject_HEAD
497 unsigned f;
498 gcipher *c;
499 } gcipher_pyobj;
500
501 extern PyTypeObject *gcipher_pytype;
502 #define GCIPHER_PYCHECK(o) PyObject_TypeCheck((o), gcipher_pytype)
503 #define GCIPHER_C(o) (((gcipher_pyobj *)(o))->c)
504 #define GCIPHER_F(o) (((gcipher_pyobj *)(o))->f)
505 extern PyObject *gcipher_pywrap(PyObject *, gcipher *, unsigned);
506 extern int convgcipher(PyObject *, void *);
507
508 typedef struct gchash_pyobj {
509 PyHeapTypeObject ty;
510 gchash *ch;
511 } gchash_pyobj;
512
513 extern PyTypeObject *gchash_pytype;
514 #define GCHASH_PYCHECK(o) PyObject_TypeCheck((o), gchash_pytype)
515 #define GCHASH_CH(o) (((gchash_pyobj *)(o))->ch)
516 #define GCHASH_F(o) (((gchash_pyobj *)(o))->f)
517 extern PyObject *gchash_pywrap(gchash *);
518 extern int convgchash(PyObject *, void *);
519
520 typedef struct ghash_pyobj {
521 PyObject_HEAD
522 unsigned f;
523 ghash *h;
524 } ghash_pyobj;
525
526 extern PyTypeObject *ghash_pytype, *gmhash_pytype;
527 extern PyObject *sha_pyobj, *has160_pyobj;
528 #define GHASH_PYCHECK(o) PyObject_TypeCheck((o), ghash_pytype)
529 #define GHASH_H(o) (((ghash_pyobj *)(o))->h)
530 #define GHASH_F(o) (((ghash_pyobj *)(o))->f)
531 extern PyObject *ghash_pywrap(PyObject *, ghash *, unsigned);
532 extern int convghash(PyObject *, void *);
533 extern int convgmhash(PyObject *, void *);
534
535 typedef struct gcmac_pyobj {
536 PyHeapTypeObject ty;
537 gcmac *cm;
538 } gcmac_pyobj;
539
540 extern PyTypeObject *gcmac_pytype;
541 #define GCMAC_PYCHECK(o) PyObject_TypeCheck((o), gcmac_pytype)
542 #define GCMAC_CM(o) (((gcmac_pyobj *)(o))->cm)
543 #define GCMAC_F(o) (((gcmac_pyobj *)(o))->f)
544 extern PyObject *gcmac_pywrap(gcmac *);
545 extern int convgcmac(PyObject *, void *);
546
547 typedef struct gmac_pyobj {
548 PyHeapTypeObject ty;
549 unsigned f;
550 gmac *m;
551 } gmac_pyobj;
552
553 extern PyTypeObject *gmac_pytype;
554 #define GMAC_PYCHECK(o) PyObject_TypeCheck((o), gmac_pytype)
555 #define GMAC_M(o) (((gmac_pyobj *)(o))->m)
556 #define GMAC_F(o) (((gmac_pyobj *)(o))->f)
557 extern PyObject *gmac_pywrap(PyObject *, gmac *, unsigned);
558 extern int convgmac(PyObject *, void *);
559
560 /*----- Key generation ----------------------------------------------------*/
561
562 typedef struct pfilt_pyobj {
563 PyObject_HEAD
564 pfilt f;
565 int st;
566 } pfilt_pyobj;
567
568 extern PyTypeObject *pfilt_pytype;
569 #define PFILT_PYCHECK(o) PyObject_TypeCheck(o, pfilt_pytype)
570 #define PFILT_F(o) (&((pfilt_pyobj *)(o))->f)
571 #define PFILT_ST(o) (((pfilt_pyobj *)(o))->st)
572
573 typedef struct { pgen_proc *proc; void *ctx; } pgev;
574 #define PGEV_HEAD PyObject_HEAD pgev pg;
575
576 typedef struct pgev_pyobj {
577 PGEV_HEAD
578 } pgev_pyobj;
579
580 extern PyTypeObject *pgev_pytype;
581 #define PGEV_PYCHECK(o) PyObject_TypeCheck(o, pgev_pytype)
582 #define PGEV_PG(o) (&((pgev_pyobj *)(o))->pg)
583
584 extern int convpgev(PyObject *, void *);
585 extern void droppgev(pgev *);
586 extern void pgenerr(void);
587
588 /*----- That's all, folks -------------------------------------------------*/
589
590 #ifdef __cplusplus
591 }
592 #endif
593
594 #endif