util.c: Rewrite `addmethods' to remove dependency on <mLib/darray.h>.
[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 #define PY_SSIZE_T_CLEAN
37
38 #include <Python.h>
39 #include <longintrepr.h>
40 #include <structmember.h>
41
42 #include <mLib/dstr.h>
43 #include <mLib/macros.h>
44 #include <mLib/quis.h>
45 #include <mLib/unihash.h>
46
47 #include <catacomb/buf.h>
48 #include <catacomb/ct.h>
49
50 #include <catacomb/grand.h>
51 #include <catacomb/rand.h>
52 #include <catacomb/noise.h>
53 #include <catacomb/bbs.h>
54 #include <catacomb/mprand.h>
55 #include <catacomb/lcrand.h>
56 #include <catacomb/fibrand.h>
57 #include <catacomb/dsarand.h>
58 #include <catacomb/sslprf.h>
59 #include <catacomb/tlsprf.h>
60 #include <catacomb/blkc.h>
61
62 #include <catacomb/gcipher.h>
63 #include <catacomb/gaead.h>
64 #include <catacomb/ghash.h>
65 #include <catacomb/gmac.h>
66 #include <catacomb/md5.h>
67 #include <catacomb/md5-hmac.h>
68 #include <catacomb/poly1305.h>
69 #include <catacomb/sha.h>
70 #include <catacomb/sha-mgf.h>
71 #include <catacomb/sha-hmac.h>
72 #include <catacomb/keccak1600.h>
73 #include <catacomb/sha3.h>
74
75 #include <catacomb/mp.h>
76 #include <catacomb/mpint.h>
77 #include <catacomb/mpmul.h>
78 #include <catacomb/mpcrt.h>
79 #include <catacomb/mpmont.h>
80 #include <catacomb/mpbarrett.h>
81 #include <catacomb/mpreduce.h>
82 #include <catacomb/mp-fibonacci.h>
83
84 #include <catacomb/pgen.h>
85 #include <catacomb/pfilt.h>
86 #include <catacomb/strongprime.h>
87 #include <catacomb/limlee.h>
88 #include <catacomb/dh.h>
89 #include <catacomb/ptab.h>
90 #include <catacomb/bintab.h>
91 #include <catacomb/dsa.h>
92 #include <catacomb/x25519.h>
93 #include <catacomb/x448.h>
94 #include <catacomb/ed25519.h>
95 #include <catacomb/ed448.h>
96
97 #include <catacomb/gf.h>
98 #include <catacomb/gfreduce.h>
99 #include <catacomb/gfn.h>
100
101 #include <catacomb/field.h>
102 #include <catacomb/field-guts.h>
103
104 #include <catacomb/ec.h>
105 #include <catacomb/ec-raw.h>
106 #include <catacomb/ectab.h>
107
108 #include <catacomb/group.h>
109 #include <catacomb/group-guts.h>
110
111 #include <catacomb/gdsa.h>
112 #include <catacomb/gkcdsa.h>
113 #include <catacomb/rsa.h>
114
115 #include <catacomb/key.h>
116 #include <catacomb/passphrase.h>
117 #include <catacomb/pixie.h>
118
119 #include <catacomb/share.h>
120 #include <catacomb/gfshare.h>
121
122 /*----- Other preliminaries -----------------------------------------------*/
123
124 #define GOBBLE_SEMI extern int notexist
125 #if defined(__GNUC__) && defined(__ELF__)
126 # define PRIVATE_SYMBOLS _Pragma("GCC visibility push(hidden)") GOBBLE_SEMI
127 # define PUBLIC_SYMBOLS _Pragma("GCC visibility pop") GOBBLE_SEMI
128 # define EXPORT __attribute__((__visibility__("default")))
129 #else
130 # define PRIVATE_SYMBOLS GOBBLE_SEMI
131 # define PUBLIC_SYMBOLS GOBBLE_SEMI
132 # define EXPORT
133 #endif
134
135 PRIVATE_SYMBOLS;
136
137 /*----- Utility macros ----------------------------------------------------*/
138
139 #define RETURN_OBJ(obj) do { Py_INCREF(obj); return (obj); } while (0)
140 #define RETURN_NONE RETURN_OBJ(Py_None)
141 #define RETURN_NOTIMPL RETURN_OBJ(Py_NotImplemented)
142 #define RETURN_TRUE RETURN_OBJ(Py_True)
143 #define RETURN_FALSE RETURN_OBJ(Py_False)
144 #define RETURN_ME RETURN_OBJ(me)
145
146 #define EXCERR(exc, str) do { \
147 PyErr_SetString(exc, str); \
148 goto end; \
149 } while (0)
150 #define VALERR(str) EXCERR(PyExc_ValueError, str)
151 #define OVFERR(str) EXCERR(PyExc_OverflowError, str)
152 #define TYERR(str) EXCERR(PyExc_TypeError, str)
153 #define IXERR(str) EXCERR(PyExc_IndexError, str)
154 #define ZDIVERR(str) EXCERR(PyExc_ZeroDivisionError, str)
155 #define SYSERR(str) EXCERR(PyExc_SystemError, str)
156 #define NIERR(str) EXCERR(PyExc_NotImplementedError, str)
157 #define INDEXERR(idx) do { \
158 PyErr_SetObject(PyExc_KeyError, idx); \
159 goto end; \
160 } while (0)
161 #define OSERR(name) do { \
162 PyErr_SetFromErrnoWithFilename(PyExc_OSError, name); \
163 goto end; \
164 } while (0)
165 #define PGENERR(exc) do { pgenerr(exc); goto end; } while (0)
166
167 #define CONVFUNC(ty, cty, ext) \
168 int conv##ty(PyObject *o, void *p) \
169 { \
170 if (!PyObject_TypeCheck(o, ty##_pytype)) \
171 TYERR("wanted a " #ty); \
172 *(cty *)p = ext(o); \
173 return (1); \
174 end: \
175 return (0); \
176 }
177
178 #define root_pytype 0
179 #define type_pytype &PyType_Type
180 #define INITTYPE_META(ty, base, meta) do { \
181 ty##_pytype_skel.tp_base = base##_pytype; \
182 ty##_pytype = inittype(&ty##_pytype_skel, meta##_pytype); \
183 } while (0)
184 #define INITTYPE(ty, base) INITTYPE_META(ty, base, type)
185
186 extern PyObject *home_module;
187 extern PyObject *modname;
188
189 #define INSERT(name, ob) do { \
190 PyObject *_o = (PyObject *)(ob); \
191 Py_INCREF(_o); \
192 PyModule_AddObject(mod, name, _o); \
193 } while (0)
194
195 #define INSEXC(name, var, base, meth) \
196 INSERT(name, var = mkexc(mod, base, name, meth))
197
198 #define METH(func, doc) \
199 { #func, METHNAME(func), METH_VARARGS, doc },
200 #define KWMETH(func, doc) \
201 { #func, (PyCFunction)METHNAME(func), \
202 METH_VARARGS | METH_KEYWORDS, doc },
203
204 #define GET(func, doc) \
205 { #func, GETSETNAME(get, func), 0, doc },
206 #define GETSET(func, doc) \
207 { #func, GETSETNAME(get, func), GETSETNAME(set, func), doc },
208
209 #define MEMBER(name, ty, f, doc) \
210 { #name, ty, offsetof(MEMBERSTRUCT, name), f, doc },
211
212 #define MODULES(_) \
213 _(util) \
214 _(bytestring) _(buffer) \
215 _(rand) _(algorithms) _(pubkey) _(pgen) \
216 _(mp) _(field) _(ec) _(group) \
217 _(passphrase) _(share) _(key)
218 #define DOMODINIT(m) m##_pyinit();
219 #define DOMODINSERT(m) m##_pyinsert(mod);
220 #define INIT_MODULES do { MODULES(DOMODINIT) } while (0)
221 #define INSERT_MODULES do { MODULES(DOMODINSERT) } while (0)
222
223 #define DO(m) \
224 extern void m##_pyinit(void); \
225 extern void m##_pyinsert(PyObject *);
226 MODULES(DO)
227 #undef DO
228
229 #define FREEOBJ(obj) \
230 (((PyObject *)(obj))->ob_type->tp_free((PyObject *)(obj)))
231
232 #define GEN(func, base) \
233 static PyObject *func(void) \
234 { \
235 PyObject *d = PyDict_New(); \
236 PyObject *o; \
237 int i; \
238 \
239 for (i = 0; g##base##tab[i]; i++) { \
240 o = gc##base##_pywrap((/*unconst*/ gc##base *)g##base##tab[i]); \
241 PyDict_SetItemString(d, \
242 (/*unconst*/ char *)g##base##tab[i]->name, \
243 o); \
244 Py_DECREF(o); \
245 } \
246 return (d); \
247 }
248
249 #define KWLIST (/*unconst*/ char **)kwlist
250
251 struct nameval { const char *name; unsigned f; unsigned long value; };
252 #define CF_SIGNED 1u
253 extern void setconstants(PyObject *, const struct nameval *);
254
255 extern PyObject *mexp_common(PyObject *, PyObject *, size_t,
256 PyObject *(*id)(PyObject *),
257 int (*fill)(void *, PyObject *,
258 PyObject *, PyObject *),
259 PyObject *(*exp)(PyObject *, void *, int),
260 void (*drop)(void *));
261
262 extern int convulong(PyObject *, void *);
263 #define DECL_CONVU_(n) extern int convu##n(PyObject *, void *);
264 DOUINTSZ(DECL_CONVU_)
265 extern int convmpw(PyObject *, void *);
266 extern int convuint(PyObject *, void *);
267 extern int convk64(PyObject *, void *);
268 extern int convszt(PyObject *, void *);
269 extern int convbool(PyObject *, void *);
270 extern PyObject *abstract_pynew(PyTypeObject *, PyObject *, PyObject *);
271 extern PyObject *getbool(int);
272 extern PyObject *getulong(unsigned long);
273 extern PyObject *getk64(kludge64);
274 extern void *newtype(PyTypeObject *, const PyTypeObject *, const char *);
275
276 struct excinfo { PyObject *ty, *val, *tb; };
277 #define EXCINFO_INIT { 0, 0, 0 }
278
279 extern PyObject *mkexc(PyObject *, PyObject *, const char *, PyMethodDef *);
280 #define INIT_EXCINFO(exc) do { \
281 struct excinfo *_exc = (exc); _exc->ty = _exc->val = _exc->tb = 0; \
282 } while (0)
283 #define RELEASE_EXCINFO(exc) do { \
284 struct excinfo *_exc = (exc); \
285 Py_XDECREF(_exc->ty); _exc->ty = 0; \
286 Py_XDECREF(_exc->val); _exc->val = 0; \
287 Py_XDECREF(_exc->tb); _exc->tb = 0; \
288 } while (0)
289 #define STASH_EXCINFO(exc) do { \
290 struct excinfo *_exc = (exc); \
291 PyErr_Fetch(&_exc->ty, &_exc->val, &_exc->tb); \
292 PyErr_NormalizeException(&_exc->ty, &_exc->val, &_exc->tb); \
293 } while (0)
294 #define RESTORE_EXCINFO(exc) do { \
295 struct excinfo *_exc = (exc); \
296 PyErr_Restore(_exc->ty, _exc->val, _exc->tb); \
297 _exc->ty = _exc->val = _exc->tb = 0; \
298 } while (0)
299 extern void report_lost_exception(struct excinfo *, const char *, ...);
300 extern void report_lost_exception_v(struct excinfo *, const char *, va_list);
301 extern void stash_exception(struct excinfo *, const char *, ...);
302 extern void restore_exception(struct excinfo *, const char *, ...);
303
304 extern void typeready(PyTypeObject *);
305 extern PyTypeObject *inittype(PyTypeObject *, PyTypeObject *);
306 extern void addmethods(const PyMethodDef *);
307 extern PyMethodDef *donemethods(void);
308
309 /*----- Mapping methods ---------------------------------------------------*/
310
311 #define GMAP_METH(func, doc) { #func, gmapmeth_##func, METH_VARARGS, doc },
312 #define GMAP_KWMETH(func, doc) \
313 { #func, (PyCFunction)gmapmeth_##func, METH_VARARGS|METH_KEYWORDS, doc },
314 #define GMAP_METHDECL(func, doc) \
315 extern PyObject *gmapmeth_##func(PyObject *, PyObject *);
316 #define GMAP_KWMETHDECL(func, doc) \
317 extern PyObject *gmapmeth_##func(PyObject *, PyObject *, PyObject *);
318
319 #define GMAP_DOROMETHODS(METH, KWMETH) \
320 METH (has_key, "D.has_key(KEY) -> BOOL") \
321 METH (keys, "D.keys() -> LIST") \
322 METH (values, "D.values() -> LIST") \
323 METH (items, "D.items() -> LIST") \
324 METH (iterkeys, "D.iterkeys() -> ITER") \
325 METH (itervalues, "D.itervalues() -> ITER") \
326 METH (iteritems, "D.iteritems() -> ITER") \
327 KWMETH(get, "D.get(KEY, [default = None]) -> VALUE") \
328
329 #define GMAP_DOMETHODS(METH, KWMETH) \
330 GMAP_DOROMETHODS(METH, KWMETH) \
331 METH (clear, "D.clear()") \
332 KWMETH(setdefault, "D.setdefault(K, [default = None]) -> VALUE") \
333 KWMETH(pop, "D.pop(KEY, [default = <error>]) -> VALUE") \
334 METH (popitem, "D.popitem() -> (KEY, VALUE)") \
335 METH (update, "D.update(MAP)")
336
337 GMAP_DOMETHODS(GMAP_METHDECL, GMAP_KWMETHDECL)
338 #define GMAP_ROMETHODS GMAP_DOROMETHODS(GMAP_METH, GMAP_KWMETH)
339 #define GMAP_METHODS GMAP_DOMETHODS(GMAP_METH, GMAP_KWMETH)
340 extern Py_ssize_t gmap_pysize(PyObject *);
341 extern PySequenceMethods gmap_pysequence;
342 extern PyMethodDef gmap_pymethods[];
343
344 /*----- Bytestrings -------------------------------------------------------*/
345
346 PyObject *bytestring_pywrap(const void *, size_t);
347 PyObject *bytestring_pywrapbuf(buf *);
348
349 /*----- Multiprecision arithmetic -----------------------------------------*/
350
351 typedef struct mp_pyobj {
352 PyObject_HEAD
353 mp *x;
354 } mp_pyobj;
355
356 extern PyTypeObject *mp_pytype;
357 extern PyTypeObject *gf_pytype;
358 #define MP_X(o) (((mp_pyobj *)(o))->x)
359 #define MP_PYCHECK(o) PyObject_TypeCheck((o), mp_pytype)
360 #define GF_PYCHECK(o) PyObject_TypeCheck((o), gf_pytype)
361
362 extern mp *mp_frompylong(PyObject *);
363 extern PyObject *mp_topylong(mp *);
364 extern mp *tomp(PyObject *);
365 extern mp *getmp(PyObject *);
366 extern int convmp(PyObject *, void *);
367 extern mp *getgf(PyObject *);
368 extern int convgf(PyObject *, void *);
369 extern PyObject *mp_pywrap(mp *);
370 extern PyObject *gf_pywrap(mp *);
371 extern long mphash(mp *);
372 extern mp *mp_frompyobject(PyObject *, int);
373 extern PyObject *mp_topystring(mp *, int,
374 const char *, const char *, const char *);
375 extern int mp_tolong_checked(mp *, long *, int);
376
377 /*----- Abstract fields ---------------------------------------------------*/
378
379 typedef struct field_pyobj {
380 PyHeapTypeObject ty;
381 field *f;
382 } field_pyobj;
383
384 extern PyTypeObject *field_pytype;
385 extern PyTypeObject *primefield_pytype;
386 extern PyTypeObject *niceprimefield_pytype;
387 extern PyTypeObject *binfield_pytype;
388 extern PyTypeObject *binpolyfield_pytype;
389 extern PyTypeObject *binnormfield_pytype;
390 #define FIELD_PYCHECK(o) PyObject_TypeCheck((o), field_pytype)
391 #define FIELD_F(o) (((field_pyobj *)(o))->f)
392 extern PyObject *field_pywrap(field *);
393 extern field *field_copy(field *);
394
395 typedef struct fe_pyobj {
396 PyObject_HEAD
397 field *f;
398 mp *x;
399 } fe_pyobj;
400
401 extern PyTypeObject *fe_pytype;
402 #define FE_PYCHECK(o) PyObject_TypeCheck((o), fe_pytype)
403 #define FE_F(o) (((fe_pyobj *)(o))->f)
404 #define FE_FOBJ(o) ((PyObject *)(o)->ob_type)
405 #define FE_X(o) (((fe_pyobj *)(o))->x)
406 extern PyObject *fe_pywrap(PyObject *, mp *);
407
408 /*----- Elliptic curves ---------------------------------------------------*/
409
410 typedef struct eccurve_pyobj {
411 PyHeapTypeObject ty;
412 ec_curve *c;
413 PyObject *fobj;
414 } eccurve_pyobj;
415
416 extern PyTypeObject *eccurve_pytype;
417 extern PyTypeObject *ecprimecurve_pytype;
418 extern PyTypeObject *ecprimeprojcurve_pytype;
419 extern PyTypeObject *ecbincurve_pytype;
420 extern PyTypeObject *ecbinprojcurve_pytype;
421 #define ECCURVE_PYCHECK(o) PyObject_TypeCheck((o), eccurve_pytype)
422 #define ECCURVE_C(o) (((eccurve_pyobj *)(o))->c)
423 #define ECCURVE_FOBJ(o) (((eccurve_pyobj *)(o))->fobj)
424 extern PyObject *eccurve_pywrap(PyObject *, ec_curve *);
425 extern ec_curve *eccurve_copy(ec_curve *);
426
427 typedef struct ecpt_pyobj {
428 PyObject_HEAD
429 ec_curve *c;
430 ec p;
431 } ecpt_pyobj;
432
433 extern PyTypeObject *ecpt_pytype, *ecptcurve_pytype;
434 #define ECPT_PYCHECK(o) PyObject_TypeCheck((o), ecpt_pytype)
435 #define ECPTCURVE_PYCHECK(o) PyObject_TypeCheck((o), ecptcurve_pytype)
436 #define ECPT_C(o) (((ecpt_pyobj *)(o))->c)
437 #define ECPT_COBJ(o) ((PyObject *)(o)->ob_type)
438 #define ECPT_FOBJ(o) ECCURVE_FOBJ(ECPT_COBJ((o)))
439 #define ECPT_P(o) (&((ecpt_pyobj *)(o))->p)
440 extern PyObject *ecpt_pywrap(PyObject *, ec *);
441 extern PyObject *ecpt_pywrapout(void *, ec *);
442 extern int toecpt(ec_curve *, ec *, PyObject *);
443 extern int getecpt(ec_curve *, ec *, PyObject *);
444 extern void getecptout(ec *, PyObject *);
445 extern int convecpt(PyObject *, void *);
446
447 typedef struct ecinfo_pyobj {
448 PyObject_HEAD
449 ec_info ei;
450 PyObject *cobj;
451 } ecinfo_pyobj;
452
453 extern PyTypeObject *ecinfo_pytype;
454 #define ECINFO_PYCHECK(o) PyObject_TypeCheck((o), ecinfo_pytype)
455 #define ECINFO_EI(o) (&((ecinfo_pyobj *)(o))->ei)
456 #define ECINFO_COBJ(o) (((ecinfo_pyobj *)(o))->cobj)
457 extern void ecinfo_copy(ec_info *, const ec_info *);
458 extern PyObject *ecinfo_pywrap(ec_info *);
459
460 /*----- Cyclic groups -----------------------------------------------------*/
461
462 typedef struct ge_pyobj {
463 PyObject_HEAD
464 ge *x;
465 group *g;
466 } ge_pyobj;
467
468 extern PyTypeObject *ge_pytype;
469 #define GE_PYCHECK(o) PyObject_TypeCheck((o), ge_pytype)
470 #define GE_X(o) (((ge_pyobj *)(o))->x)
471 #define GE_G(o) (((ge_pyobj *)(o))->g)
472 #define GE_GOBJ(o) ((PyObject *)(group_pyobj *)(o)->ob_type)
473 extern PyObject *ge_pywrap(PyObject *, ge *);
474
475 typedef struct group_pyobj {
476 PyHeapTypeObject ty;
477 group *g;
478 } group_pyobj;
479
480 extern PyTypeObject *group_pytype;
481 #define GROUP_G(o) (((group_pyobj *)(o))->g)
482 extern PyObject *group_pywrap(group *);
483 extern group *group_copy(group *);
484
485 /*----- Random number generators ------------------------------------------*/
486
487 #define f_freeme 1u
488
489 typedef struct grand_pyobj {
490 PyObject_HEAD
491 unsigned f;
492 grand *r;
493 } grand_pyobj;
494
495 extern PyTypeObject *grand_pytype;
496 extern PyObject *rand_pyobj;
497 #define GRAND_PYCHECK(o) PyObject_TypeCheck((o), grand_pytype)
498 #define GRAND_F(o) (((grand_pyobj *)(o))->f)
499 #define GRAND_R(o) (((grand_pyobj *)(o))->r)
500 extern PyObject *grand_pywrap(grand *, unsigned);
501 extern int convgrand(PyObject *, void *);
502
503 /*----- Symmetric cryptography --------------------------------------------*/
504
505 extern PyObject *keysz_pywrap(const octet *);
506
507 extern int convgccipher(PyObject *, void *);
508 extern PyObject *gccipher_pywrap(gccipher *);
509
510 typedef struct gchash_pyobj {
511 PyHeapTypeObject ty;
512 gchash *ch;
513 } gchash_pyobj;
514
515 extern PyTypeObject *gchash_pytype;
516 extern PyObject *sha_pyobj, *has160_pyobj;
517 #define GCHASH_PYCHECK(o) PyObject_TypeCheck((o), gchash_pytype)
518 #define GCHASH_CH(o) (((gchash_pyobj *)(o))->ch)
519 extern PyObject *ghash_pywrap(PyObject *, ghash *);
520 extern int convgchash(PyObject *, void *);
521 extern int convghash(PyObject *, void *);
522
523 extern int convgcmac(PyObject *, void *);
524
525 /*----- Key generation ----------------------------------------------------*/
526
527 typedef struct pfilt_pyobj {
528 PyObject_HEAD
529 pfilt f;
530 int st;
531 } pfilt_pyobj;
532
533 extern PyTypeObject *pfilt_pytype;
534 #define PFILT_PYCHECK(o) PyObject_TypeCheck(o, pfilt_pytype)
535 #define PFILT_F(o) (&((pfilt_pyobj *)(o))->f)
536 #define PFILT_ST(o) (((pfilt_pyobj *)(o))->st)
537
538 typedef struct { pgen_proc *proc; void *ctx; } pgev;
539 #define PGEV_HEAD PyObject_HEAD pgev pg;
540
541 typedef struct pgev_pyobj {
542 PGEV_HEAD
543 } pgev_pyobj;
544
545 extern PyTypeObject *pgev_pytype;
546 #define PGEV_PYCHECK(o) PyObject_TypeCheck(o, pgev_pytype)
547 #define PGEV_PG(o) (&((pgev_pyobj *)(o))->pg)
548
549 typedef struct pypgev {
550 pgev ev;
551 PyObject *obj;
552 struct excinfo *exc;
553 } pypgev;
554
555 extern int convpgev(PyObject *, void *);
556 extern void droppgev(pypgev *);
557 extern void pgenerr(struct excinfo *exc);
558
559 /*----- That's all, folks -------------------------------------------------*/
560
561 #ifdef __cplusplus
562 }
563 #endif
564
565 #endif